blob: 50dcb29b7d570b411b4b9f3dcbf1e2b4bfd274b1 [file] [log] [blame]
Neale Rannsc87b66c2019-02-07 07:26:12 -08001from vpp_tunnel_interface import VppTunnelInterface
Neale Ranns14053c92019-12-29 23:55:18 +00002from vpp_papi import VppEnum
Neale Rannsc87b66c2019-02-07 07:26:12 -08003
4
5class VppIpIpTunInterface(VppTunnelInterface):
6 """
7 VPP IP-IP Tunnel interface
8 """
9
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020010 def __init__(
11 self, test, parent_if, src, dst, table_id=0, dscp=0x0, flags=0, mode=None
12 ):
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 Ranns14053c92019-12-29 23:55:18 +000019 self.mode = mode
20 if not self.mode:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020021 self.mode = VppEnum.vl_api_tunnel_mode_t.TUNNEL_API_MODE_P2P
Neale Rannsc87b66c2019-02-07 07:26:12 -080022
23 def add_vpp_config(self):
24 r = self.test.vapi.ipip_add_tunnel(
25 tunnel={
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020026 "src": self.src,
27 "dst": self.dst,
28 "table_id": self.table_id,
29 "flags": self.flags,
30 "dscp": self.dscp,
31 "instance": 0xFFFFFFFF,
32 "mode": self.mode,
33 }
34 )
Neale Rannsc87b66c2019-02-07 07:26:12 -080035 self.set_sw_if_index(r.sw_if_index)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020036 r = self.test.vapi.ipip_tunnel_dump(sw_if_index=self.sw_if_index)
Neale Ranns89d939e2021-06-07 09:34:07 +000037 self.instance = r[0].tunnel.instance
Neale Rannsc87b66c2019-02-07 07:26:12 -080038 self.test.registry.register(self, self.test.logger)
Neale Ranns95346962019-11-25 13:04:44 +000039 return self
Neale Rannsc87b66c2019-02-07 07:26:12 -080040
41 def remove_vpp_config(self):
42 self.test.vapi.ipip_del_tunnel(sw_if_index=self._sw_if_index)
43
44 def query_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020045 ts = self.test.vapi.ipip_tunnel_dump(sw_if_index=0xFFFFFFFF)
Neale Rannsc87b66c2019-02-07 07:26:12 -080046 for t in ts:
47 if t.tunnel.sw_if_index == self._sw_if_index:
48 return True
49 return False
50
51 def __str__(self):
52 return self.object_id()
53
54 def object_id(self):
Neale Ranns89d939e2021-06-07 09:34:07 +000055 return "ipip%d" % self.instance
Neale Ranns12989b52019-09-26 16:20:19 +000056
57 @property
58 def remote_ip(self):
59 return self.dst
60
61 @property
62 def local_ip(self):
63 return self.src