Add bytes BEFORE the proxified field so that it starts at the specified alignment from its beginning
| 659 | |
| 660 | |
| 661 | class 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 | |
| 690 | class TrailerBytes(bytes): |
no outgoing calls
no test coverage detected
searching dependent graphs…