MCPcopy Create free account
hub / github.com/secdev/scapy / post_build

Method post_build

scapy/contrib/pnio_rpc.py:635–654  ·  view source on GitHub ↗
(self, p, pay)

Source from the content-addressed store, hash-verified

633 subslotNumber = 0xffff
634
635 def post_build(self, p, pay):
636 # patch the update of block_length, as requests field must not be
637 # included. block_length is always 60
638 if self.block_length is None:
639 p = p[:2] + struct.pack("!H", 60) + p[4:]
640
641 # Remove the final padding added in requests
642 fld, val = self.getfield_and_val("blocks")
643 if fld.i2count(self, val) > 0:
644 length = len(val[-1])
645 pad = fld.field.padlen(length, self)
646 if pad > 0:
647 p = p[:-pad]
648 # also reduce the recordDataLength accordingly
649 if self.recordDataLength is None:
650 val = struct.unpack("!I", p[36:40])[0]
651 val -= pad
652 p = p[:36] + struct.pack("!I", val) + p[40:]
653
654 return Packet.post_build(self, p, pay)
655
656 def get_response(self):
657 """Generate the response block of this request.

Callers

nothing calls this directly

Calls 4

getfield_and_valMethod · 0.45
i2countMethod · 0.45
padlenMethod · 0.45
post_buildMethod · 0.45

Tested by

no test coverage detected