Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1 | |
| 2 | from vpp_interface import VppInterface |
| 3 | import socket |
| 4 | |
| 5 | |
| 6 | class VppGreInterface(VppInterface): |
| 7 | """ |
| 8 | VPP GRE interface |
| 9 | """ |
| 10 | |
| 11 | def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, is_teb=0): |
| 12 | """ Create VPP loopback interface """ |
Neale Ranns | 39f9973 | 2016-11-28 16:10:59 +0000 | [diff] [blame] | 13 | self._sw_if_index = 0 |
| 14 | super(VppGreInterface, self).__init__(test) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 15 | self._test = test |
| 16 | self.t_src = src_ip |
| 17 | self.t_dst = dst_ip |
| 18 | self.t_outer_fib = outer_fib_id |
| 19 | self.t_is_teb = is_teb |
| 20 | |
| 21 | def add_vpp_config(self): |
| 22 | s = socket.inet_pton(socket.AF_INET, self.t_src) |
| 23 | d = socket.inet_pton(socket.AF_INET, self.t_dst) |
| 24 | r = self.test.vapi.gre_tunnel_add_del(s, d, |
| 25 | outer_fib_id=self.t_outer_fib, |
| 26 | is_teb=self.t_is_teb) |
| 27 | self._sw_if_index = r.sw_if_index |
Neale Ranns | 39f9973 | 2016-11-28 16:10:59 +0000 | [diff] [blame] | 28 | self.generate_remote_hosts() |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 29 | |
| 30 | def remove_vpp_config(self): |
| 31 | s = socket.inet_pton(socket.AF_INET, self.t_src) |
| 32 | d = socket.inet_pton(socket.AF_INET, self.t_dst) |
| 33 | self.unconfig() |
| 34 | r = self.test.vapi.gre_tunnel_add_del(s, d, |
| 35 | outer_fib_id=self.t_outer_fib, |
| 36 | is_add=0) |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame^] | 37 | |
| 38 | |
| 39 | class VppGre6Interface(VppInterface): |
| 40 | """ |
| 41 | VPP GRE IPv6 interface |
| 42 | """ |
| 43 | |
| 44 | def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, is_teb=0): |
| 45 | """ Create VPP loopback interface """ |
| 46 | self._sw_if_index = 0 |
| 47 | super(VppGre6Interface, self).__init__(test) |
| 48 | self._test = test |
| 49 | self.t_src = src_ip |
| 50 | self.t_dst = dst_ip |
| 51 | self.t_outer_fib = outer_fib_id |
| 52 | self.t_is_teb = is_teb |
| 53 | |
| 54 | def add_vpp_config(self): |
| 55 | s = socket.inet_pton(socket.AF_INET6, self.t_src) |
| 56 | d = socket.inet_pton(socket.AF_INET6, self.t_dst) |
| 57 | r = self.test.vapi.gre_tunnel_add_del(s, d, |
| 58 | outer_fib_id=self.t_outer_fib, |
| 59 | is_teb=self.t_is_teb, |
| 60 | is_ip6=1) |
| 61 | self._sw_if_index = r.sw_if_index |
| 62 | self.generate_remote_hosts() |
| 63 | |
| 64 | def remove_vpp_config(self): |
| 65 | s = socket.inet_pton(socket.AF_INET6, self.t_src) |
| 66 | d = socket.inet_pton(socket.AF_INET6, self.t_dst) |
| 67 | self.unconfig() |
| 68 | r = self.test.vapi.gre_tunnel_add_del(s, d, |
| 69 | outer_fib_id=self.t_outer_fib, |
| 70 | is_add=0, |
| 71 | is_ip6=1) |