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