def writeConnectResponse(self, stream: BytesIO, pdu: MCSConnectResponsePDU): """ Encode a Connect Response PDU :param stream: The destination stream to write into. :param pdu: the PDU to encode. """ substream = BytesIO() substream.write(ber.writeEnumeration(pdu.result)) substream.write(ber.writeInteger(pdu.calledConnectID)) self.writeDomainParams(substream, pdu.domainParams) substream.write(ber.writeOctetString(pdu.payload)) allData = substream.getvalue() stream.write(ber.writeLength(len(allData))) stream.write(allData)
def writeConnectInitial(self, stream: BytesIO, pdu: MCSConnectInitialPDU): """ Encode a Connect Initial PDU :param stream: The destination stream to write into. :param pdu: the PDU to encode. """ substream = BytesIO() substream.write(ber.writeOctetString(pdu.callingDomain)) substream.write(ber.writeOctetString(pdu.calledDomain)) substream.write(ber.writeBoolean(pdu.upward)) self.writeDomainParams(substream, pdu.targetParams) self.writeDomainParams(substream, pdu.minParams) self.writeDomainParams(substream, pdu.maxParams) substream.write(ber.writeOctetString(pdu.payload)) data = substream.getvalue() stream.write(ber.writeLength(len(data))) stream.write(data)
def writeDomainParams(self, stream: BytesIO, params: MCSDomainParams): """ Encode a Domain Params structure into the provided stream :param stream: The destination stream to write into. :param params: the domain params to encode. """ substream = BytesIO() substream.write(ber.writeInteger(params.maxChannelIDs)) substream.write(ber.writeInteger(params.maxUserIDs)) substream.write(ber.writeInteger(params.maxTokenIDs)) substream.write(ber.writeInteger(params.numPriorities)) substream.write(ber.writeInteger(params.minThroughput)) substream.write(ber.writeInteger(params.maxHeight)) substream.write(ber.writeInteger(params.maxMCSPDUSize)) substream.write(ber.writeInteger(params.protocolVersion)) substream = substream.getvalue() stream.write(ber.writeUniversalTag(ber.Tag.BER_TAG_SEQUENCE, True)) stream.write(ber.writeLength(len(substream))) stream.write(substream)