blob: 3558523f61d4d1f5819de7d1799e5009641fdabc [file] [log] [blame]
Neale Rannsc87b66c2019-02-07 07:26:12 -08001from vpp_tunnel_interface import VppTunnelInterface
2from ipaddress import ip_address
3
4
5class VppIpIpTunInterface(VppTunnelInterface):
6 """
7 VPP IP-IP Tunnel interface
8 """
9
10 def __init__(self, test, parent_if, src, dst):
11 super(VppIpIpTunInterface, self).__init__(test, parent_if)
12 self.src = src
13 self.dst = dst
14
15 def add_vpp_config(self):
16 r = self.test.vapi.ipip_add_tunnel(
17 tunnel={
18 'src': self.src,
19 'dst': self.dst,
20 'table_id': 0,
21 'instance': 0xffffffff,
22 })
23 self.set_sw_if_index(r.sw_if_index)
24 self.test.registry.register(self, self.test.logger)
25
26 def remove_vpp_config(self):
27 self.test.vapi.ipip_del_tunnel(sw_if_index=self._sw_if_index)
28
29 def query_vpp_config(self):
30 ts = self.test.vapi.ipip_tunnel_dump(sw_if_index=0xffffffff)
31 for t in ts:
32 if t.tunnel.sw_if_index == self._sw_if_index:
33 return True
34 return False
35
36 def __str__(self):
37 return self.object_id()
38
39 def object_id(self):
40 return "ipip-%d" % self._sw_if_index
Neale Ranns12989b52019-09-26 16:20:19 +000041
42 @property
43 def remote_ip(self):
44 return self.dst
45
46 @property
47 def local_ip(self):
48 return self.src