From bb7e8d7b4a6fe4a6d71c6d3b77898618d5286100 Mon Sep 17 00:00:00 2001 From: gpotter2 <gabriel@potter.fr> Date: Fri, 5 May 2017 00:02:22 +0200 Subject: [PATCH] Fix Net6 repr + add tests --- scapy/layers/inet6.py | 3 +++ test/regression.uts | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py index 3e61a90e..1a66889f 100644 --- a/scapy/layers/inet6.py +++ b/scapy/layers/inet6.py @@ -107,6 +107,9 @@ def getmacbyip6(ip6, chainCC=0): (chainCC parameter value ends up being passed to sending function used to perform the resolution, if needed) """ + + if isinstance(ip6,Net6): + ip6 = iter(ip6).next() if in6_ismaddr(ip6): # Multicast mac = in6_getnsmac(inet_pton(socket.AF_INET6, ip6)) diff --git a/test/regression.uts b/test/regression.uts index 4e445490..c0bc96ce 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -3134,6 +3134,21 @@ p = IPv6(s) ICMPv6MLQuery in p and p[IPv6].dst == "ff02::1" +############ +############ ++ Ether tests with IPv6 + += Ether IPv6 checking for dst +~ netaccess + +# No more routing test after this line +if WINDOWS: + route_add_loopback() + +p = Ether()/IPv6(dst="www.google.com")/TCP() +assert p.dst != p[IPv6].dst +p.show() + ############ ############ + TracerouteResult6 @@ -4437,8 +4452,6 @@ not a < b and a > b + Mobile Prefix Solicitation/Advertisement = ICMPv6MPSol - build (default values) -if WINDOWS: - route_add_loopback() s = b'`\x00\x00\x00\x00\x08:@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x92\x00m\xbb\x00\x00\x00\x00' str(IPv6()/ICMPv6MPSol()) == s @@ -7922,6 +7935,14 @@ len([ip for ip in n3]) == 5 (n3 in n2) == True += Net using web address + +ip = IP(dst="www.google.fr") +n1 = ip.dst +assert isinstance(n1, Net) +assert n1.ip_regex.match(str(n1)) +ip.show() + = OID oid = OID("1.2.3.4.5.6-8") @@ -7932,6 +7953,13 @@ len([ o for o in oid ]) == 3 n1 = Net6("2001:db8::/127") len([ip for ip in n1]) == 2 += Net6 using web address + +ip = IPv6(dst="www.google.fr") +n1 = ip.dst +assert isinstance(n1, Net6) +assert n1.ip_regex.match(str(n1)) +ip.show() ############ ############ -- GitLab