From 2725e5a6ba524e991829570db2c6711384124ab6 Mon Sep 17 00:00:00 2001
From: Pierre LALET <pierre.lalet@cea.fr>
Date: Wed, 21 Dec 2016 12:56:58 +0100
Subject: [PATCH] Fix & test MIP6MH_HoT.answers()

---
 scapy/layers/inet6.py | 2 +-
 test/regression.uts   | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py
index 0e510fae..385d4712 100644
--- a/scapy/layers/inet6.py
+++ b/scapy/layers/inet6.py
@@ -2850,7 +2850,7 @@ class MIP6MH_HoT(_MobilityHeader):
     overload_fields = { IPv6: { "nh": 135 } }
     def hashret(self):
         return self.cookie
-    def answers(self):
+    def answers(self, other):
         if (isinstance(other, MIP6MH_HoTI) and
             self.cookie == other.cookie):
             return 1
diff --git a/test/regression.uts b/test/regression.uts
index de2e9ee1..a5a2f710 100644
--- a/test/regression.uts
+++ b/test/regression.uts
@@ -4502,6 +4502,15 @@ a=IPv6('`\x00\x00\x00\x00\x18\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x0
 b = a.payload
 a.nh == 135 and isinstance(b, MIP6MH_HoT) and b.nh==59 and b.mhtype == 3 and b.len== 2 and b.res == 0x77 and b.cksum == 0x8899 and b.index == 0xAABB and b.cookie == '\xAA'*8 and b.token == '\xCC'*8
 
+= MIP6MH_HoT answers
+a1, a2 = "2001:db8::1", "2001:db8::2"
+cookie = RandString(8)._fix()
+p1 = IPv6(src=a1, dst=a2)/MIP6MH_HoTI(cookie=cookie)
+p2 = IPv6(src=a2, dst=a1)/MIP6MH_HoT(cookie=cookie)
+p2_ko = IPv6(src=a2, dst=a1)/MIP6MH_HoT(cookie="".join(chr((ord('\xff') + 1) % 256)))
+assert p1.hashret() == p2.hashret() and p2.answers(p1) and not p1.answers(p2)
+assert p1.hashret() != p2_ko.hashret() and not p2_ko.answers(p1) and not p1.answers(p2_ko)
+
 
 ############
 ############
-- 
GitLab