summaryrefslogtreecommitdiffstats
path: root/test/patches/scapy-2.4
diff options
context:
space:
mode:
authorFrancois Clad <fclad@cisco.com>2018-07-09 16:33:39 +0200
committerDamjan Marion <dmarion@me.com>2018-07-11 13:17:46 +0000
commitd47da680eb8d55a6eef64becb7459030df3c7241 (patch)
tree9dd3c9388895796424cfcc8a5393620740c87006 /test/patches/scapy-2.4
parentf46d8f8d3fa1e0cefbc4c70645f2121b14662d4f (diff)
srv6: Fixing SRH parsing bug in Scapy 2.4
Change-Id: Ib2cb345d07665735697bf54ad48d353ba4112eda Signed-off-by: Francois Clad <fclad@cisco.com>
Diffstat (limited to 'test/patches/scapy-2.4')
-rw-r--r--test/patches/scapy-2.4/inet6.py.patch28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/patches/scapy-2.4/inet6.py.patch b/test/patches/scapy-2.4/inet6.py.patch
new file mode 100644
index 00000000000..0cb33d43e8c
--- /dev/null
+++ b/test/patches/scapy-2.4/inet6.py.patch
@@ -0,0 +1,28 @@
+diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py
+index 6f9f16b..d61c621 100644
+--- a/scapy/layers/inet6.py
++++ b/scapy/layers/inet6.py
+@@ -1089,9 +1089,9 @@ class IPv6ExtHdrSegmentRouting(_IPv6ExtHdr):
+ BitField("unused2", 0, 3),
+ ShortField("tag", 0),
+ IP6ListField("addresses", ["::1"],
+- count_from=lambda pkt: pkt.lastentry),
++ count_from=lambda pkt: pkt.lastentry+1),
+ PacketListField("tlv_objects", [], IPv6ExtHdrSegmentRoutingTLV,
+- length_from=lambda pkt: 8*pkt.len - 16*pkt.lastentry) ]
++ length_from=lambda pkt: 8*pkt.len - 16*(pkt.lastentry+1)) ]
+
+ overload_fields = { IPv6: { "nh": 43 } }
+
+@@ -1119,7 +1119,10 @@ class IPv6ExtHdrSegmentRouting(_IPv6ExtHdr):
+ pkt = pkt[:3] + struct.pack("B", tmp_len) + pkt[4:]
+
+ if self.lastentry is None:
+- pkt = pkt[:4] + struct.pack("B", len(self.addresses)) + pkt[5:]
++ tmp_len = len(self.addresses)
++ if tmp_len:
++ tmp_len -= 1
++ pkt = pkt[:4] + struct.pack("B", tmp_len) + pkt[5:]
+
+ return _IPv6ExtHdr.post_build(self, pkt, pay)
+