blob: 998f6eab32b9fb1121ba88d9716a5715e569c3ea [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()
Klement Sekera75e7d132017-09-20 08:26:30 +020029 self._test.registry.register(self, self._test.logger)
Neale Ranns177bbdc2016-11-15 09:46:51 +000030
31 def remove_vpp_config(self):
32 s = socket.inet_pton(socket.AF_INET, self.t_src)
33 d = socket.inet_pton(socket.AF_INET, self.t_dst)
34 self.unconfig()
Klement Sekera75e7d132017-09-20 08:26:30 +020035 self.test.vapi.gre_tunnel_add_del(s, d,
36 outer_fib_id=self.t_outer_fib,
37 is_add=0)
38
39 def __str__(self):
40 return self.object_id()
41
42 def object_id(self):
43 return "gre-%d" % self._sw_if_index
Ciara Loftus7eac9162016-09-30 15:47:03 +010044
45
46class VppGre6Interface(VppInterface):
47 """
48 VPP GRE IPv6 interface
49 """
50
51 def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, is_teb=0):
Neale Ranns33ce60d2017-12-14 08:51:32 -080052 """ Create VPP GRE interface """
Ciara Loftus7eac9162016-09-30 15:47:03 +010053 self._sw_if_index = 0
54 super(VppGre6Interface, self).__init__(test)
55 self._test = test
56 self.t_src = src_ip
57 self.t_dst = dst_ip
58 self.t_outer_fib = outer_fib_id
59 self.t_is_teb = is_teb
60
61 def add_vpp_config(self):
62 s = socket.inet_pton(socket.AF_INET6, self.t_src)
63 d = socket.inet_pton(socket.AF_INET6, self.t_dst)
64 r = self.test.vapi.gre_tunnel_add_del(s, d,
65 outer_fib_id=self.t_outer_fib,
66 is_teb=self.t_is_teb,
67 is_ip6=1)
68 self._sw_if_index = r.sw_if_index
69 self.generate_remote_hosts()
Klement Sekera75e7d132017-09-20 08:26:30 +020070 self._test.registry.register(self, self._test.logger)
Ciara Loftus7eac9162016-09-30 15:47:03 +010071
72 def remove_vpp_config(self):
73 s = socket.inet_pton(socket.AF_INET6, self.t_src)
74 d = socket.inet_pton(socket.AF_INET6, self.t_dst)
75 self.unconfig()
Klement Sekera75e7d132017-09-20 08:26:30 +020076 self.test.vapi.gre_tunnel_add_del(s, d,
77 outer_fib_id=self.t_outer_fib,
78 is_add=0,
79 is_ip6=1)
80
81 def __str__(self):
82 return self.object_id()
83
84 def object_id(self):
85 return "gre-%d" % self._sw_if_index