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

Class ReversePadField

scapy/fields.py:661–687  ·  view source on GitHub ↗

Add bytes BEFORE the proxified field so that it starts at the specified alignment from its beginning

Source from the content-addressed store, hash-verified

659
660
661class ReversePadField(PadField):
662 """Add bytes BEFORE the proxified field so that it starts at the specified
663 alignment from its beginning"""
664
665 def original_length(self, pkt):
666 # type: (Packet) -> int
667 return len(pkt.original)
668
669 def getfield(self,
670 pkt, # type: Packet
671 s, # type: bytes
672 ):
673 # type: (...) -> Tuple[bytes, Any]
674 # We need to get the length that has already been dissected
675 padlen = self.padlen(self.original_length(pkt) - len(s), pkt)
676 return self.fld.getfield(pkt, s[padlen:])
677
678 def addfield(self,
679 pkt, # type: Packet
680 s, # type: bytes
681 val, # type: Any
682 ):
683 # type: (...) -> bytes
684 sval = self.fld.addfield(pkt, b"", val)
685 return s + struct.pack("%is" % (
686 self.padlen(len(s), pkt)
687 ), self._padwith) + sval
688
689
690class TrailerBytes(bytes):

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…