From d5e4a897680762663fd14993a4f2c9691675ec29 Mon Sep 17 00:00:00 2001 From: Guillaume Valadon Date: Wed, 7 Aug 2013 10:13:46 +0200 Subject: [PATCH 1/3] Issue #600: Fragmenting long IPv6 packet produces deprecation warnings --HG-- branch : Issue #600 --- scapy/layers/inet6.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py index bd2122ef6..b7dcb4161 100644 --- a/scapy/layers/inet6.py +++ b/scapy/layers/inet6.py @@ -958,10 +958,6 @@ def fragment6(pkt, fragSize): """ pkt = pkt.copy() - s = str(pkt) # for instantiation to get upper layer checksum right - - if len(s) <= fragSize: - return [pkt] if not IPv6ExtHdrFragment in pkt: # TODO : automatically add a fragment before upper Layer @@ -969,6 +965,15 @@ def fragment6(pkt, fragSize): # as single element of a list return [pkt] + # If the payload is bigger than 65535, IPv6().post_build() will throw an exception + if len(str(pkt[IPv6ExtHdrFragment])) > 65535: + pkt[IPv6].plen = 65535 + + s = str(pkt) # for instantiation to get upper layer checksum right + + if len(s) <= fragSize: + return [pkt] + # Fragmentable part : fake IPv6 for Fragmentable part length computation fragPart = pkt[IPv6ExtHdrFragment].payload tmp = str(IPv6(src="::1", dst="::1")/fragPart) From 348d11f14f7c7cba0d5334ae9a52da51811fa358 Mon Sep 17 00:00:00 2001 From: Guillaume Valadon Date: Wed, 7 Aug 2013 11:01:38 +0200 Subject: [PATCH 2/3] Issue #600 should not be fixed --HG-- branch : Issue #600 extra : close : 1 From 95776ce795664e3f0703cf245792dc6e9d8d6ca6 Mon Sep 17 00:00:00 2001 From: Guillaume Valadon Date: Mon, 26 Aug 2013 10:38:00 +0200 Subject: [PATCH 3/3] Warning printed if the IPv6 payload is longer thant 65535 bytes. --HG-- branch : Issue #600 --- scapy/layers/inet6.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py index b7dcb4161..f03e6cae5 100644 --- a/scapy/layers/inet6.py +++ b/scapy/layers/inet6.py @@ -965,9 +965,11 @@ def fragment6(pkt, fragSize): # as single element of a list return [pkt] - # If the payload is bigger than 65535, IPv6().post_build() will throw an exception + # If the payload is bigger than 65535, a Jumbo payload must be used, as + # an IPv6 packet can't be bigger than 65535 bytes. if len(str(pkt[IPv6ExtHdrFragment])) > 65535: - pkt[IPv6].plen = 65535 + warning("An IPv6 packet can'be bigger than 65535, please use a Jumbo payload.") + return [] s = str(pkt) # for instantiation to get upper layer checksum right