def send(self, payload, roa=False, eot=True): """ Encapsulate the payload in a X.224 Data PDU and send it to the transport (previous) layer. :type payload: bytes :param eot: End of transmission. :param roa: Request of acknowledgement """ pdu = X224DataPDU(roa, eot, payload) self.previous.send(self.mainParser.write(pdu))
def sendBytes(self, data: bytes, roa: bool = False, eot: bool = True): """ Encapsulate the payload in a X.224 Data PDU and send it to the previous layer. :param data: bytes to send. :param eot: End of transmission. :param roa: Request of acknowledgement """ pdu = X224DataPDU(roa, eot, data) self.previous.sendBytes(self.mainParser.write(pdu))
def parseData(self, data, length): """ Parse a Data PDU from the raw bytes :type data: bytes :param length: The length in bytes of the Data PDU. :return: X224DataPDU """ if length != 2: raise ParsingError("Invalid X224 Data PDU length indicator: expected = 2, indicator = %d" % length) code = Uint8.unpack(data[1]) & 0xf sequence = Uint8.unpack(data[2]) payload = data[3 :] return X224DataPDU(code & 1 == 1, sequence & 0x80 == 0x80, payload)