blob: ea5cfa118aa0260138c20f5d65f2ba73e4ad02be [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
Neale Ranns95346962019-11-25 13:04:44 +000010 def __init__(self, test, parent_if, src, dst,
11 table_id=0, dscp=0x0,
12 flags=0):
Neale Rannsc87b66c2019-02-07 07:26:12 -080013 super(VppIpIpTunInterface, self).__init__(test, parent_if)
14 self.src = src
15 self.dst = dst
Neale Ranns95346962019-11-25 13:04:44 +000016 self.table_id = table_id
17 self.dscp = dscp
18 self.flags = flags
Neale Rannsc87b66c2019-02-07 07:26:12 -080019
20 def add_vpp_config(self):
21 r = self.test.vapi.ipip_add_tunnel(
22 tunnel={
23 'src': self.src,
24 'dst': self.dst,
Neale Ranns95346962019-11-25 13:04:44 +000025 'table_id': self.table_id,
26 'flags': self.flags,
27 'dscp': self.dscp,
Neale Rannsc87b66c2019-02-07 07:26:12 -080028 'instance': 0xffffffff,
29 })
30 self.set_sw_if_index(r.sw_if_index)
31 self.test.registry.register(self, self.test.logger)
Neale Ranns95346962019-11-25 13:04:44 +000032 return self
Neale Rannsc87b66c2019-02-07 07:26:12 -080033
34 def remove_vpp_config(self):
35 self.test.vapi.ipip_del_tunnel(sw_if_index=self._sw_if_index)
36
37 def query_vpp_config(self):
38 ts = self.test.vapi.ipip_tunnel_dump(sw_if_index=0xffffffff)
39 for t in ts:
40 if t.tunnel.sw_if_index == self._sw_if_index:
41 return True
42 return False
43
44 def __str__(self):
45 return self.object_id()
46
47 def object_id(self):
48 return "ipip-%d" % self._sw_if_index
Neale Ranns12989b52019-09-26 16:20:19 +000049
50 @property
51 def remote_ip(self):
52 return self.dst
53
54 @property
55 def local_ip(self):
56 return self.src