aboutsummaryrefslogtreecommitdiffstats
path: root/test/vpp_udp_encap.py
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-08-08 01:06:40 -0700
committerOle Trøan <otroan@employees.org>2018-08-10 08:26:00 +0000
commitd0df49f26eabf2f534b567f3370e50c4e804aeea (patch)
treeeea014e723f00b4e00e57937fc5f6e043e2162f9 /test/vpp_udp_encap.py
parent404d88edce63a635b58ba54d21d91735ff933584 (diff)
Use IP address types on UDP encap API
Change-Id: I3c714c519b6d0009329b50947ce250c18ee2a85a Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test/vpp_udp_encap.py')
-rw-r--r--test/vpp_udp_encap.py46
1 files changed, 19 insertions, 27 deletions
diff --git a/test/vpp_udp_encap.py b/test/vpp_udp_encap.py
index d4daa7430b3..002f9f4023a 100644
--- a/test/vpp_udp_encap.py
+++ b/test/vpp_udp_encap.py
@@ -5,13 +5,21 @@
from vpp_object import *
from socket import inet_pton, inet_ntop, AF_INET, AF_INET6
+from vpp_ip import *
-def find_udp_encap(test, id):
+def find_udp_encap(test, ue):
encaps = test.vapi.udp_encap_dump()
for e in encaps:
- if id == e.id:
+ if ue.id == e.udp_encap.id \
+ and compare_ip_address(e.udp_encap.src_ip.un,
+ ue.src_ip.addr.ip_addr) \
+ and compare_ip_address(e.udp_encap.dst_ip.un,
+ ue.dst_ip.addr.ip_addr) \
+ and e.udp_encap.dst_port == ue.dst_port \
+ and e.udp_encap.src_port == ue.src_port:
return True
+
return False
@@ -24,48 +32,32 @@ class VppUdpEncap(VppObject):
dst_ip,
src_port,
dst_port,
- table_id=0,
- is_ip6=0):
+ table_id=0):
self._test = test
self.id = id
self.table_id = table_id
- self.is_ip6 = is_ip6
self.src_ip_s = src_ip
self.dst_ip_s = dst_ip
- if is_ip6:
- self.src_ip = inet_pton(AF_INET6, src_ip)
- self.dst_ip = inet_pton(AF_INET6, dst_ip)
- else:
- self.src_ip = inet_pton(AF_INET, src_ip)
- self.dst_ip = inet_pton(AF_INET, dst_ip)
+ self.src_ip = VppIpAddress(src_ip)
+ self.dst_ip = VppIpAddress(dst_ip)
self.src_port = src_port
self.dst_port = dst_port
def add_vpp_config(self):
- self._test.vapi.udp_encap_add_del(
+ self._test.vapi.udp_encap_add(
self.id,
- self.src_ip,
- self.dst_ip,
+ self.src_ip.encode(),
+ self.dst_ip.encode(),
self.src_port,
self.dst_port,
- self.table_id,
- is_ip6=self.is_ip6,
- is_add=1)
+ self.table_id)
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- self._test.vapi.udp_encap_add_del(
- self.id,
- self.src_ip,
- self.dst_ip,
- self.src_port,
- self.dst_port,
- self.table_id,
- is_ip6=self.is_ip6,
- is_add=0)
+ self._test.vapi.udp_encap_del(self.id)
def query_vpp_config(self):
- return find_udp_encap(self._test, self.id)
+ return find_udp_encap(self._test, self)
def __str__(self):
return self.object_id()