MCPcopy
hub / github.com/GoSecure/pyrdp / write

Method write

pyrdp/parser/mcs.py:244–262  ·  view source on GitHub ↗

Encode an MCS PDU into raw bytes :param pdu: the MCSPDU to encode :return: The raw bytes to send

(self, pdu: MCSPDU)

Source from the content-addressed store, hash-verified

242 return self.parseDataPDU(stream, MCSSendDataIndicationPDU)
243
244 def write(self, pdu: MCSPDU) -> bytes:
245 """
246 Encode an MCS PDU into raw bytes
247 :param pdu: the MCSPDU to encode
248 :return: The raw bytes to send
249 """
250 if pdu.header not in self.writers:
251 raise UnknownPDUTypeError("Trying to write unknown MCS PDU type %s" % pdu.header, pdu.header)
252
253 stream = BytesIO()
254
255 if pdu.header in [MCSPDUType.CONNECT_INITIAL, MCSPDUType.CONNECT_RESPONSE]:
256 stream.write(Uint8.pack(ber.Class.BER_CLASS_APPL | ber.PC.BER_CONSTRUCT | ber.Tag.BER_TAG_MASK))
257 stream.write(Uint8.pack(pdu.header))
258 else:
259 stream.write(Uint8.pack((pdu.header << 2) | self.headerOptions[pdu.header]))
260
261 self.writers[pdu.header](stream, pdu)
262 return stream.getvalue()
263
264 def writeDomainParams(self, stream: BytesIO, params: MCSDomainParams):
265 """

Calls 2

UnknownPDUTypeErrorClass · 0.90
packMethod · 0.80