Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 1 | |
| 2 | from vpp_interface import VppInterface |
| 3 | from vpp_ip_route import VppRoutePath |
| 4 | import socket |
| 5 | |
| 6 | |
| 7 | class VppMPLSTunnelInterface(VppInterface): |
| 8 | """ |
| 9 | VPP MPLS Tunnel interface |
| 10 | """ |
| 11 | |
| 12 | def __init__(self, test, paths, is_multicast=0): |
| 13 | """ 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 |
| 19 | |
| 20 | def add_vpp_config(self): |
| 21 | self._sw_if_index = 0xffffffff |
| 22 | for path in self.t_paths: |
| 23 | reply = self.test.vapi.mpls_tunnel_add_del( |
| 24 | self._sw_if_index, |
| 25 | 1, # IPv4 next-hop |
| 26 | path.nh_addr, |
| 27 | path.nh_itf, |
| 28 | path.nh_table_id, |
| 29 | path.weight, |
| 30 | next_hop_out_label_stack=path.nh_labels, |
| 31 | next_hop_n_out_labels=len(path.nh_labels), |
| 32 | is_multicast=self.is_multicast) |
| 33 | self._sw_if_index = reply.sw_if_index |
| 34 | |
| 35 | def remove_vpp_config(self): |
| 36 | for path in self.t_paths: |
| 37 | reply = self.test.vapi.mpls_tunnel_add_del( |
| 38 | self.sw_if_index, |
| 39 | 1, # IPv4 next-hop |
| 40 | path.nh_addr, |
| 41 | path.nh_itf, |
| 42 | path.nh_table_id, |
| 43 | path.weight, |
| 44 | next_hop_out_label_stack=path.nh_labels, |
| 45 | next_hop_n_out_labels=len(path.nh_labels), |
| 46 | is_add=0) |