Example #1
0
 def sendError(self, cause: int, destination=0):
     """
     :param cause: the error cause.
     :param destination: the PDU's destination property.
     """
     pdu = X224ErrorPDU(destination, cause)
     self.sendPDU(pdu)
Example #2
0
    def sendError(self, cause, **kwargs):
        """
        :param cause: the error cause.
        :type cause: int
        """
        destination = kwargs.pop("destination", 0)

        pdu = X224ErrorPDU(destination, cause)
        self.previous.send(self.mainParser.write(pdu))
Example #3
0
    def parseError(self, data, length):
        """
        Parse a Error PDU from the raw bytes
        :type data: bytes
        :param length: The length in bytes of the Error PDU.
        :return: X224ErrorPDU
        """

        if length < 4:
            raise ParsingError("Invalid X224 Error PDU length indicator: indicator = %d, expected at least 4 bytes")

        destination = Uint16BE.unpack(data[2 : 4])
        cause = Uint8.unpack(data[4])
        payload = data[5 :]

        if len(payload) != length - 4:
            raise ParsingError("Invalid X224 Error PDU payload length: expected = %d, length = %d" % (length - 4, len(payload)))

        return X224ErrorPDU(destination, cause, payload)