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 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)