From 45aee45ae81a3f46b800b0902ae66b6bbf1e9cba Mon Sep 17 00:00:00 2001 From: Shu-xueyuan <35594064+Shu-xueyuan@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:55:22 +0800 Subject: [PATCH] Update inet.py --- scapy/layers/inet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scapy/layers/inet.py b/scapy/layers/inet.py index 325df766075..24464f7ccc9 100644 --- a/scapy/layers/inet.py +++ b/scapy/layers/inet.py @@ -755,7 +755,7 @@ def post_build(self, p, pay): elif conf.ipv6_enabled and isinstance(self.underlayer, scapy.layers.inet6.IPv6) or isinstance(self.underlayer, scapy.layers.inet6._IPv6ExtHdr): # noqa: E501 ck = scapy.layers.inet6.in6_chksum(socket.IPPROTO_TCP, self.underlayer, p) # noqa: E501 p = p[:16] + struct.pack("!H", ck) + p[18:] - elif self.underlayer and self.underlayer.name == "AH" and isinstance(self.underlayer.underlayer, IP): + elif self.underlayer and self.underlayer.name == "AH" and isinstance(self.underlayer.underlayer, IP): # noqa: E501 ck = in4_chksum(socket.IPPROTO_TCP, self.underlayer.underlayer, p) p = p[:16] + struct.pack("!H", ck) + p[18:] elif self.underlayer and self.underlayer.name == "AH" and ((conf.ipv6_enabled and isinstance(self.underlayer.underlayer, scapy.layers.inet6.IPv6)) or isinstance(self.underlayer.underlayer, scapy.layers.inet6._IPv6ExtHdr)): # noqa: E501 @@ -839,7 +839,7 @@ def post_build(self, p, pay): if ck == 0: ck = 0xFFFF p = p[:6] + struct.pack("!H", ck) + p[8:] - elif self.underlayer and self.underlayer.name == "AH" and isinstance(self.underlayer.underlayer, IP): + elif self.underlayer and self.underlayer.name == "AH" and isinstance(self.underlayer.underlayer, IP): # noqa: E501 ck = in4_chksum(socket.IPPROTO_UDP, self.underlayer.underlayer, p) # According to RFC768 if the result checksum is 0, it should be set to 0xFFFF # noqa: E501 if ck == 0: