diff options
author | Neale Ranns <nranns@cisco.com> | 2017-11-05 16:26:46 -0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2017-11-07 16:13:42 +0000 |
commit | 810086d8fd08445919ae03bf36161037e53a712a (patch) | |
tree | 76a91d3ed49759ef3adae32066f9dcedd75df889 /test/vpp_udp_encap.py | |
parent | 595992c5c3b5abbdb7e90e61acbee212f25ad59f (diff) |
UDP Encapsulation.
A UDP-encap object that particiapates in the FIB graph and contributes
DPO to teh output chain. It thereofre resembles a tunnel but without the
interface. FIB paths (and henace routes) can then be created to egress
through the UDP-encap. Said routes can have MPLS labels, hence this also
allows MPLSoUPD.
Encap is uni-directional. For decap, one still registers with the UDP port
dispatcher.
Change-Id: I23bd345523b20789a1de1b02022ea1148ca50797
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test/vpp_udp_encap.py')
-rw-r--r-- | test/vpp_udp_encap.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/test/vpp_udp_encap.py b/test/vpp_udp_encap.py new file mode 100644 index 00000000000..56d23cc45dc --- /dev/null +++ b/test/vpp_udp_encap.py @@ -0,0 +1,73 @@ +""" + UDP encap objects +""" + +from vpp_object import * +from socket import inet_pton, inet_ntop, AF_INET, AF_INET6 + + +def find_udp_encap(test, id): + encaps = test.vapi.udp_encap_dump() + for e in encaps: + if id == e.id: + return True + return False + + +class VppUdpEncap(VppObject): + + def __init__(self, + test, + id, + src_ip, + dst_ip, + src_port, + dst_port, + table_id=0, + is_ip6=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_port = src_port + self.dst_port = dst_port + + def add_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=1) + 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) + + def query_vpp_config(self): + return find_udp_encap(self._test, self.id) + + def __str__(self): + return self.object_id() + + def object_id(self): + return ("udp-encap-%d" % self.id) |