blob: 6e5ade6eb3df3d311f1a783d8d2216bccaf237fb [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