Ejemplo n.º 1
0
    def parseDomainParams(self, stream):
        """
        Parse a MCSDomainParam from stream
        :param stream: byte stream containing the data
        :type stream: BytesIO
        :return: MCSDomainParam
        """
        if not ber.readUniversalTag(stream, ber.Tag.BER_TAG_SEQUENCE, True):
            raise ParsingError("Invalid BER tag (%d expected)" %
                               ber.Tag.BER_TAG_SEQUENCE)

        length = ber.readLength(stream)
        if length > len(stream.getvalue()):
            raise ParsingError(
                "Invalid size for DomainParameters (got %d, %d bytes left)" %
                (length, len(stream.getvalue())))

        maxChannelIDs = ber.readInteger(stream)
        maxUserIDs = ber.readInteger(stream)
        maxTokenIDs = ber.readInteger(stream)
        numPriorities = ber.readInteger(stream)
        minThroughput = ber.readInteger(stream)
        maxHeight = ber.readInteger(stream)
        maxMCSPDUSize = ber.readInteger(stream)
        protocolVersion = ber.readInteger(stream)
        return MCSDomainParams(maxChannelIDs, maxUserIDs, maxTokenIDs,
                               numPriorities, minThroughput, maxHeight,
                               maxMCSPDUSize, protocolVersion)
Ejemplo n.º 2
0
 def parseConnectResponse(self, stream: BytesIO) -> MCSConnectResponsePDU:
     """
     Parse a Connect Response PDU
     :param stream: stream containing the data
     """
     _length = ber.readLength(stream)
     result = ber.readEnumeration(stream)
     calledConnectID = ber.readInteger(stream)
     domainParams = self.parseDomainParams(stream)
     payload = ber.readOctetString(stream)
     return MCSConnectResponsePDU(result, calledConnectID, domainParams, payload)
Ejemplo n.º 3
0
 def parseConnectInitial(self, stream: BytesIO) -> MCSConnectInitialPDU:
     """
     Parse a Connect Initial PDU
     :param stream: stream containing the data
     """
     _length = ber.readLength(stream)
     callingDomain = ber.readOctetString(stream)
     calledDomain = ber.readOctetString(stream)
     upward = ber.readBoolean(stream)
     targetParams = self.parseDomainParams(stream)
     minParams = self.parseDomainParams(stream)
     maxParams = self.parseDomainParams(stream)
     payload = ber.readOctetString(stream)
     return MCSConnectInitialPDU(callingDomain, calledDomain, upward, targetParams, minParams, maxParams, payload)