blob: acfd348d64f141c6db191691c7779bd4e0ee9e3a [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):
Neale Ranns33ce60d2017-12-14 08:51:32 -080012 """ Create VPP GRE 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):
Neale Ranns33ce60d2017-12-14 08:51:32 -080045 """ Create VPP GRE interface """
Ciara Loftus7eac9162016-09-30 15:47:03 +010046 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)