Example #1
0
	def __init__(self, ir_node):
		"""method __init__(): Parameter 'ir_node' is a ref to an instance of an RzvcIfRouteNode."""
		
		Thread.__init__(self)
		
		self._ir_node = ir_node
		self._file = self._ir_node._file
		self._fd = self._ir_node._file.fileno()
		
		self._poll_obj = None
		
		self.go = 1
		
		self._rd_buf_len = 256
		self._rd_buf = array.array('B', '\0' * self._rd_buf_len)
		self._rd_buf_start_idx = 0 # holds index of first byte in (potential) pkt
		self._rd_buf_cur_idx = 0 # holds index of current byte in buffer (logically, if not physically, between start and end)
		self._rd_buf_end_idx = 0 # holds index of last byte read
		self._bytes_read = 0
		
		self._rd_state = 0 # start the subclass reading state machine in the 1st state
		self._pkt_ext_len = 0 # set to non-zero in transition from State 2 to State 3, if any for a given pkt
		self._total_pkt_len = 0 # sum of _pkt_hdr_len and _pkt_ext_len for any given pkt
		
		self._ser_num = 30000 # 0x7530: choose higher number than expected from regular Mozaic, RZ100, or Tessera; @fixme: what about multi-Mediator systems?
		# Prepare to send pkts by breaking _ser_num into component bytes:
		self._ser_num_bytes = long_to_bytes(self._ser_num)
		
		self._low_rzc = sys.maxint # listen for and store lowest dst/src address
		self._high_rzc = 0 # listen for and store highest dst/src address
Example #2
0
    def __init__(self, ir_node):
        """method __init__(): Parameter 'ir_node' is a ref to an instance of an RzvcIfRouteNode."""

        Thread.__init__(self)

        self._ir_node = ir_node
        self._file = self._ir_node._file
        self._fd = self._ir_node._file.fileno()

        self._poll_obj = None

        self.go = 1

        self._rd_buf_len = 256
        self._rd_buf = array.array("B", "\0" * self._rd_buf_len)
        self._rd_buf_start_idx = 0  # holds index of first byte in (potential) pkt
        self._rd_buf_cur_idx = (
            0
        )  # holds index of current byte in buffer (logically, if not physically, between start and end)
        self._rd_buf_end_idx = 0  # holds index of last byte read
        self._bytes_read = 0

        self._rd_state = 0  # start the subclass reading state machine in the 1st state
        self._pkt_ext_len = 0  # set to non-zero in transition from State 2 to State 3, if any for a given pkt
        self._total_pkt_len = 0  # sum of _pkt_hdr_len and _pkt_ext_len for any given pkt

        self._ser_num = (
            30000
        )  # 0x7530: choose higher number than expected from regular Mozaic, RZ100, or Tessera; @fixme: what about multi-Mediator systems?
        # Prepare to send pkts by breaking _ser_num into component bytes:
        self._ser_num_bytes = long_to_bytes(self._ser_num)

        self._low_rzc = sys.maxint  # listen for and store lowest dst/src address
        self._high_rzc = 0  # listen for and store highest dst/src address
Example #3
0
    def create_pkt(self, dst, pkt_type, hdr_data=0x0000, ext_data=None):
        # @fixme: Add processing for extended pkts.
        assert isinstance(dst, int), 'RzvcIfWrap.create_pkt(): Param "dst" not an integer!'
        dst_bytes = long_to_bytes(dst)
        pkt_buf = array.array(
            "B",
            [
                0x16,
                0x01,
                dst_bytes[0],
                dst_bytes[1],
                dst_bytes[2],
                dst_bytes[3],
                self._ser_num_bytes[0],
                self._ser_num_bytes[1],
                self._ser_num_bytes[2],
                self._ser_num_bytes[3],
                pkt_type,
                hdr_data,
                (hdr_data >> 8),
                0x00,
            ],
        )

        pkt_buf[self._pkt_hdr_chksum_idx] = checksum(pkt_buf, 2, self._pkt_hdr_chksum_idx - 1)

        return pkt_buf
Example #4
0
	def create_pkt(self, dst, pkt_type, hdr_data = 0x0000, ext_data = None):
		#@fixme: Add processing for extended pkts.
		assert isinstance(dst, int), 'RzvcIfWrap.create_pkt(): Param "dst" not an integer!'
		dst_bytes = long_to_bytes(dst)
		pkt_buf = array.array('B', [0x16, 0x01, dst_bytes[0], dst_bytes[1], dst_bytes[2], dst_bytes[3], \
			self._ser_num_bytes[0], self._ser_num_bytes[1], self._ser_num_bytes[2], self._ser_num_bytes[3], \
			pkt_type, hdr_data, (hdr_data >> 8), 0x00])
		
		pkt_buf[self._pkt_hdr_chksum_idx] = checksum(pkt_buf, 2, self._pkt_hdr_chksum_idx - 1)
		
		return pkt_buf