blob: 0542b05c05fd88c8c86bce5060a87dd2d58c107d [file] [log] [blame]
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001
2from vpp_interface import VppInterface
3from vpp_ip_route import VppRoutePath
4import socket
5
6
7class VppMPLSTunnelInterface(VppInterface):
8 """
9 VPP MPLS Tunnel interface
10 """
11
Neale Rannsda78f952017-05-24 09:15:43 -070012 def __init__(self, test, paths, is_multicast=0, is_l2=0):
Neale Ranns0f26c5a2017-03-01 15:12:11 -080013 """ Create MPLS Tunnel interface """
14 self._sw_if_index = 0
15 super(VppMPLSTunnelInterface, self).__init__(test)
16 self._test = test
17 self.t_paths = paths
18 self.is_multicast = is_multicast
Neale Rannsda78f952017-05-24 09:15:43 -070019 self.is_l2 = is_l2
Neale Ranns0f26c5a2017-03-01 15:12:11 -080020
21 def add_vpp_config(self):
22 self._sw_if_index = 0xffffffff
23 for path in self.t_paths:
24 reply = self.test.vapi.mpls_tunnel_add_del(
25 self._sw_if_index,
26 1, # IPv4 next-hop
27 path.nh_addr,
28 path.nh_itf,
29 path.nh_table_id,
30 path.weight,
31 next_hop_out_label_stack=path.nh_labels,
32 next_hop_n_out_labels=len(path.nh_labels),
Neale Rannsda78f952017-05-24 09:15:43 -070033 is_multicast=self.is_multicast,
34 l2_only=self.is_l2)
Neale Ranns0f26c5a2017-03-01 15:12:11 -080035 self._sw_if_index = reply.sw_if_index
36
37 def remove_vpp_config(self):
38 for path in self.t_paths:
39 reply = self.test.vapi.mpls_tunnel_add_del(
40 self.sw_if_index,
41 1, # IPv4 next-hop
42 path.nh_addr,
43 path.nh_itf,
44 path.nh_table_id,
45 path.weight,
46 next_hop_out_label_stack=path.nh_labels,
47 next_hop_n_out_labels=len(path.nh_labels),
48 is_add=0)