Skip to content

Commit ed5fd3e

Browse files
authored
Update inet6.py for Destination Option
Extension Headers can show weird behavious. Linux's sk_buff considers the IPv6 Payload to be either TCP, UDP or ICMP. It does not consider Extension Headers to be the payload. Following similar architecture, This small modification let's packet flow with Destination Option on both, request and response packets be captured as well.
1 parent a4f958b commit ed5fd3e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

scapy/layers/inet6.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,20 @@ def answers(self, other):
481481
elif other.nh == 43 and isinstance(other.payload, IPv6ExtHdrSegmentRouting): # noqa: E501
482482
return self.payload.answers(other.payload.payload) # Buggy if self.payload is a IPv6ExtHdrRouting # noqa: E501
483483
elif other.nh == 60 and isinstance(other.payload, IPv6ExtHdrDestOpt):
484-
return self.payload.answers(other.payload.payload)
484+
# Extension Headers can show weird behavious.
485+
# Linux's sk_buff considers the IPv6 Payload
486+
# to be either TCP, UDP or ICMP. It does not
487+
# consider Extension Headers to be the payload.
488+
# Following similar architecture, This small
489+
# modification let's packet flow with Destination
490+
# Option on both, request and response packets
491+
# be captured as well.
492+
if UDP in self and UDP in other:
493+
return self[UDP].answers(other[UDP])
494+
elif TCP in self and TCP in other:
495+
return self[TCP].answers(other[TCP])
496+
else:
497+
return self.payload.answers(other.payload.payload) # Previous Implementation
485498
elif self.nh == 60 and isinstance(self.payload, IPv6ExtHdrDestOpt): # BU in reply to BRR, for instance # noqa: E501
486499
return self.payload.payload.answers(other.payload)
487500
else:

0 commit comments

Comments
 (0)