def parseConferenceCreateResponse( self, stream: BytesIO) -> GCCConferenceCreateResponsePDU: """ Parse ConferenceCreateResponse data into a GCCPDU :param stream: byte stream containing the PDU data """ nodeID = Uint16BE.unpack(stream.read(2)) + 1001 tag = per.readInteger(stream) result = per.readEnumeration(stream) userDataCount = per.readNumberOfSet(stream) if userDataCount != 1: raise ParsingError("Expected user data count to be 1, got %d" % userDataCount) userDataType = per.readChoice(stream) if userDataType != 0xc0: raise ParsingError( "Expected user data type to be 0xc0 (h221NonStandard), got %d" % userDataType) key = per.readOctetStream(stream, 4) if key != GCCParser.H221_SERVER_KEY: raise ParsingError("Expected user data key to be %s, got %s" % (GCCParser.H221_SERVER_KEY, key)) payload = per.readOctetStream(stream) return GCCConferenceCreateResponsePDU(nodeID, tag, result, payload)
def parseConferenceCreateRequest( self, stream: BytesIO) -> GCCConferenceCreateRequestPDU: """ Parse ConferenceCreateRequest data into a GCCPDU :param stream: byte stream containing the PDU data """ prop = per.readSelection(stream) if prop != 8: raise ParsingError( "Expected property to be 8 (conference name), got %d" % prop) conferenceName = per.readNumericString(stream, 1) stream.read(1) userDataCount = per.readNumberOfSet(stream) if userDataCount != 1: raise ParsingError("Expected user data count to be 1, got %d" % userDataCount) userDataType = per.readChoice(stream) if userDataType != 0xc0: raise ParsingError( "Expected user data type to be 0xc0 (h221NonStandard), got %d" % userDataType) key = per.readOctetStream(stream, 4) if key != GCCParser.H221_CLIENT_KEY: raise ParsingError("Expected user data key to be %s, got %s" % (GCCParser.H221_CLIENT_KEY, key)) payload = per.readOctetStream(stream) return GCCConferenceCreateRequestPDU(conferenceName, payload)
def parseDataPDU(self, stream: BytesIO, PDUClass: type) -> Union[MCSSendDataRequestPDU, MCSSendDataIndicationPDU]: """ Common logic for parsing Send Data Request and Send Data Indication PDUs :param stream: stream containing the data :param PDUClass: the actual PDU class: MCSSendDataRequestPDU or MCSSendDataIndicationPDU """ initiator = Uint16BE.unpack(stream.read(2)) + MCSChannelID.USERCHANNEL_BASE channelID = Uint16BE.unpack(stream.read(2)) priority = per.readEnumeration(stream) payload = per.readOctetStream(stream) return PDUClass(initiator, channelID, priority, payload)