blob: bd635417f02a59876d304af5e617b4cc4bbf5311 [file] [log] [blame]
Klement Sekera31da2e32018-06-24 22:49:55 +02001from vpp_tunnel_interface import VppTunnelInterface
2
3
4class VppIpsecTunInterface(VppTunnelInterface):
5 """
6 VPP IPsec Tunnel interface
7 """
8
9 def __init__(self, test, parent_if, local_spi,
10 remote_spi, crypto_alg, local_crypto_key, remote_crypto_key,
11 integ_alg, local_integ_key, remote_integ_key):
12 super(VppIpsecTunInterface, self).__init__(test, parent_if)
13 self.local_spi = local_spi
14 self.remote_spi = remote_spi
15 self.crypto_alg = crypto_alg
16 self.local_crypto_key = local_crypto_key
17 self.remote_crypto_key = remote_crypto_key
18 self.integ_alg = integ_alg
19 self.local_integ_key = local_integ_key
20 self.remote_integ_key = remote_integ_key
21
22 def add_vpp_config(self):
23 r = self.test.vapi.ipsec_tunnel_if_add_del(
24 self.parent_if.local_ip4n, self.parent_if.remote_ip4n,
25 self.remote_spi, self.local_spi, self.crypto_alg,
26 self.local_crypto_key, self.remote_crypto_key, self.integ_alg,
27 self.local_integ_key, self.remote_integ_key)
28 self.set_sw_if_index(r.sw_if_index)
29 self.generate_remote_hosts()
30 self.test.registry.register(self, self.test.logger)
31
32 def remove_vpp_config(self):
33 self.test.vapi.ipsec_tunnel_if_add_del(
34 self.parent_if.local_ip4n, self.parent_if.remote_ip4n,
35 self.remote_spi, self.local_spi, self.crypto_alg,
36 self.local_crypto_key, self.remote_crypto_key, self.integ_alg,
37 self.local_integ_key, self.remote_integ_key, is_add=0)
38
39 def __str__(self):
40 return self.object_id()
41
42 def object_id(self):
43 return "ipsec-tun-if-%d" % self._sw_if_index