aboutsummaryrefslogtreecommitdiffstats
path: root/test/vpp_ip_route.py
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2016-11-15 09:46:51 +0000
committerDamjan Marion <dmarion.lists@gmail.com>2016-11-22 21:26:55 +0000
commit177bbdcd8fa4e7621c5bdd3afd8c6e74b603e096 (patch)
treecf234b5bf8d79dac6a43570a903a11de44e26497 /test/vpp_ip_route.py
parent7afe9e38269a30682a5e392b0e876e18d1465c31 (diff)
GRE tests and fixes
Change-Id: I234240e9bdd4b69ad64a17b1449ae1e81c0edaca Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test/vpp_ip_route.py')
-rw-r--r--test/vpp_ip_route.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py
new file mode 100644
index 00000000..78e6aaa2
--- /dev/null
+++ b/test/vpp_ip_route.py
@@ -0,0 +1,46 @@
+"""
+ IP Routes
+
+ object abstractions for representing IP routes in VPP
+"""
+
+import socket
+
+
+class IpPath:
+
+ def __init__(self, nh_addr, nh_sw_if_index, nh_table_id=0):
+ self.nh_addr = socket.inet_pton(socket.AF_INET, nh_addr)
+ self.nh_itf = nh_sw_if_index
+ self.nh_table_id = nh_table_id
+
+
+class IpRoute:
+ """
+ IP Route
+ """
+
+ def __init__(self, test, dest_addr,
+ dest_addr_len, paths, table_id=0):
+ self._test = test
+ self.paths = paths
+ self.dest_addr = socket.inet_pton(socket.AF_INET, dest_addr)
+ self.dest_addr_len = dest_addr_len
+ self.table_id = table_id
+
+ def add_vpp_config(self):
+ for path in self.paths:
+ self._test.vapi.ip_add_del_route(self.dest_addr,
+ self.dest_addr_len,
+ path.nh_addr,
+ path.nh_itf,
+ table_id=self.table_id)
+
+ def remove_vpp_config(self):
+ for path in self.paths:
+ self._test.vapi.ip_add_del_route(self.dest_addr,
+ self.dest_addr_len,
+ path.nh_addr,
+ path.nh_itf,
+ table_id=self.table_id,
+ is_add=0)