blob: 1c71875f73a5f4b6b52b2e301e211b8a1000522b [file] [log] [blame]
Neale Ranns177bbdc2016-11-15 09:46:51 +00001
2from vpp_interface import VppInterface
3import socket
4
5
6class 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 Ranns39f99732016-11-28 16:10:59 +000013 self._sw_if_index = 0
14 super(VppGreInterface, self).__init__(test)
Neale Ranns177bbdc2016-11-15 09:46:51 +000015 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 Ranns39f99732016-11-28 16:10:59 +000028 self.generate_remote_hosts()
Neale Ranns177bbdc2016-11-15 09:46:51 +000029
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 Loftus7eac9162016-09-30 15:47:03 +010037
38
39class 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)