MCPcopy Index your code
hub / github.com/secdev/scapy / post_build

Method post_build

scapy/layers/inet.py:760–779  ·  view source on GitHub ↗
(self, p, pay)

Source from the content-addressed store, hash-verified

758 TCPOptionsField("options", "")]
759
760 def post_build(self, p, pay):
761 p += pay
762 dataofs = self.dataofs
763 if dataofs is None:
764 opt_len = len(self.get_field("options").i2m(self, self.options))
765 dataofs = 5 + ((opt_len + 3) // 4)
766 dataofs = (dataofs << 4) | orb(p[12]) & 0x0f
767 p = p[:12] + chb(dataofs & 0xff) + p[13:]
768 if self.chksum is None:
769 if isinstance(self.underlayer, IP):
770 ck = in4_chksum(socket.IPPROTO_TCP, self.underlayer, p)
771 p = p[:16] + struct.pack("!H", ck) + p[18:]
772 elif conf.ipv6_enabled and isinstance(self.underlayer, scapy.layers.inet6.IPv6) or isinstance(self.underlayer, scapy.layers.inet6._IPv6ExtHdr): # noqa: E501
773 ck = scapy.layers.inet6.in6_chksum(socket.IPPROTO_TCP, self.underlayer, p) # noqa: E501
774 p = p[:16] + struct.pack("!H", ck) + p[18:]
775 else:
776 log_runtime.info(
777 "No IP underlayer to compute checksum. Leaving null."
778 )
779 return p
780
781 def hashret(self):
782 if conf.checkIPsrc:

Callers

nothing calls this directly

Calls 5

orbFunction · 0.90
chbFunction · 0.90
in4_chksumFunction · 0.85
get_fieldMethod · 0.80
i2mMethod · 0.45

Tested by

no test coverage detected