aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_dhcp6.py19
-rw-r--r--test/test_ip6.py8
-rw-r--r--test/util.py8
3 files changed, 14 insertions, 21 deletions
diff --git a/test/test_dhcp6.py b/test/test_dhcp6.py
index 6c203868673..7510543af8e 100644
--- a/test/test_dhcp6.py
+++ b/test/test_dhcp6.py
@@ -1,3 +1,5 @@
+from socket import AF_INET6
+
from scapy.layers.dhcp6 import DHCP6_Advertise, DHCP6OptClientId, \
DHCP6OptStatusCode, DHCP6OptPref, DHCP6OptIA_PD, DHCP6OptIAPrefix, \
DHCP6OptServerId, DHCP6_Solicit, DHCP6_Reply, DHCP6_Request, DHCP6_Renew, \
@@ -6,20 +8,15 @@ from scapy.layers.dhcp6 import DHCP6_Advertise, DHCP6OptClientId, \
from scapy.layers.inet6 import IPv6, Ether, UDP
from scapy.utils6 import in6_mactoifaceid
from scapy.utils import inet_ntop, inet_pton
-from socket import AF_INET6
+
from framework import VppTestCase
+import util
def ip6_normalize(ip6):
return inet_ntop(AF_INET6, inet_pton(AF_INET6, ip6))
-def mk_ll_addr(mac):
- euid = in6_mactoifaceid(mac)
- addr = "fe80::" + euid
- return addr
-
-
class TestDHCPv6DataPlane(VppTestCase):
""" DHCPv6 Data Plane Test Case """
@@ -88,7 +85,7 @@ class TestDHCPv6DataPlane(VppTestCase):
ia_na_opts = DHCP6OptIAAddress(addr='7:8::2', preflft=60,
validlft=120)
p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
- IPv6(src=mk_ll_addr(self.pg0.remote_mac),
+ IPv6(src=util.mk_ll_addr(self.pg0.remote_mac),
dst=self.pg0.local_ip6_ll) /
UDP(sport=547, dport=546) /
DHCP6_Advertise(trid=trid) /
@@ -165,7 +162,7 @@ class TestDHCPv6DataPlane(VppTestCase):
ia_pd_opts = DHCP6OptIAPrefix(prefix='7:8::', plen=56, preflft=60,
validlft=120)
p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
- IPv6(src=mk_ll_addr(self.pg0.remote_mac),
+ IPv6(src=util.mk_ll_addr(self.pg0.remote_mac),
dst=self.pg0.local_ip6_ll) /
UDP(sport=547, dport=546) /
DHCP6_Advertise(trid=trid) /
@@ -317,7 +314,7 @@ class TestDHCPv6IANAControlPlane(VppTestCase):
else:
opt_ia_na = DHCP6OptIA_NA(iaid=1, T1=t1, T2=t2, ianaopts=ianaopts)
p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
- IPv6(src=mk_ll_addr(self.pg0.remote_mac),
+ IPv6(src=util.mk_ll_addr(self.pg0.remote_mac),
dst=self.pg0.local_ip6_ll) /
UDP(sport=547, dport=546) /
msg_type(trid=self.trid) /
@@ -569,7 +566,7 @@ class TestDHCPv6PDControlPlane(VppTestCase):
else:
opt_ia_pd = DHCP6OptIA_PD(iaid=1, T1=t1, T2=t2, iapdopt=iapdopt)
p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
- IPv6(src=mk_ll_addr(self.pg0.remote_mac),
+ IPv6(src=util.mk_ll_addr(self.pg0.remote_mac),
dst=self.pg0.local_ip6_ll) /
UDP(sport=547, dport=546) /
msg_type(trid=self.trid) /
diff --git a/test/test_ip6.py b/test/test_ip6.py
index 6832498dc26..5a5ba51f0ed 100644
--- a/test/test_ip6.py
+++ b/test/test_ip6.py
@@ -18,7 +18,7 @@ from scapy.utils6 import in6_getnsma, in6_getnsmac, in6_ptop, in6_islladdr, \
from six import moves
from framework import VppTestCase, VppTestRunner
-from util import ppp, ip6_normalize
+from util import ppp, ip6_normalize, mk_ll_addr
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath, find_route, VppIpMRoute, \
VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
@@ -36,12 +36,6 @@ except NameError:
text_type = str
-def mk_ll_addr(mac):
- euid = in6_mactoifaceid(mac)
- addr = "fe80::" + euid
- return addr
-
-
class TestIPv6ND(VppTestCase):
def validate_ra(self, intf, rx, dst_ip=None):
if not dst_ip:
diff --git a/test/util.py b/test/util.py
index 5ce84070a87..fc0ebd73500 100644
--- a/test/util.py
+++ b/test/util.py
@@ -2,18 +2,19 @@
import abc
import socket
+from socket import AF_INET6
import six
import sys
import os.path
-from scapy.utils6 import in6_mactoifaceid
from scapy.layers.l2 import Ether
-from scapy.packet import Raw
from scapy.layers.inet import IP
from scapy.layers.inet6 import IPv6, IPv6ExtHdrFragment, IPv6ExtHdrRouting,\
IPv6ExtHdrHopByHop
+from scapy.packet import Raw
from scapy.utils import hexdump
-from socket import AF_INET6
+from scapy.utils6 import in6_mactoifaceid
+
from io import BytesIO
from vpp_papi import mac_pton
@@ -54,6 +55,7 @@ def ip4n_range(ip4n, s, e):
for ip in ip4_range(ip4, s, e))
+# wrapper around scapy library function.
def mk_ll_addr(mac):
euid = in6_mactoifaceid(mac)
addr = "fe80::" + euid