blob: c561a1fd11f07ad1043495dbfaf7c27ff5454fd4 [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,
Neale Ranns80f6fd52019-04-16 02:41:34 +000011 integ_alg, local_integ_key, remote_integ_key, salt=0,
Neale Rannsa6bee0a2019-06-14 01:13:25 -070012 udp_encap=False,
Neale Ranns80f6fd52019-04-16 02:41:34 +000013 is_ip6=False):
Klement Sekera31da2e32018-06-24 22:49:55 +020014 super(VppIpsecTunInterface, self).__init__(test, parent_if)
15 self.local_spi = local_spi
16 self.remote_spi = remote_spi
17 self.crypto_alg = crypto_alg
18 self.local_crypto_key = local_crypto_key
19 self.remote_crypto_key = remote_crypto_key
20 self.integ_alg = integ_alg
21 self.local_integ_key = local_integ_key
22 self.remote_integ_key = remote_integ_key
Neale Ranns80f6fd52019-04-16 02:41:34 +000023 self.salt = salt
Kingwel Xie1ba5bc82019-03-20 07:21:58 -040024 if is_ip6:
25 self.local_ip = self.parent_if.local_ip6
26 self.remote_ip = self.parent_if.remote_ip6
27 else:
28 self.local_ip = self.parent_if.local_ip4
29 self.remote_ip = self.parent_if.remote_ip4
Neale Ranns41afb332019-07-16 06:19:35 -070030 self.udp_encap = udp_encap
Klement Sekera31da2e32018-06-24 22:49:55 +020031
32 def add_vpp_config(self):
33 r = self.test.vapi.ipsec_tunnel_if_add_del(
Kingwel Xie1ba5bc82019-03-20 07:21:58 -040034 self.local_ip, self.remote_ip,
35 self.remote_spi, self.local_spi,
36 self.crypto_alg, self.local_crypto_key, self.remote_crypto_key,
Neale Ranns80f6fd52019-04-16 02:41:34 +000037 self.integ_alg, self.local_integ_key, self.remote_integ_key,
Neale Rannsa6bee0a2019-06-14 01:13:25 -070038 salt=self.salt,
39 udp_encap=self.udp_encap)
Klement Sekera31da2e32018-06-24 22:49:55 +020040 self.set_sw_if_index(r.sw_if_index)
41 self.generate_remote_hosts()
42 self.test.registry.register(self, self.test.logger)
43
44 def remove_vpp_config(self):
45 self.test.vapi.ipsec_tunnel_if_add_del(
Kingwel Xie1ba5bc82019-03-20 07:21:58 -040046 self.local_ip, self.remote_ip,
47 self.remote_spi, self.local_spi,
48 self.crypto_alg, self.local_crypto_key, self.remote_crypto_key,
49 self.integ_alg, self.local_integ_key, self.remote_integ_key,
50 is_add=0)
Klement Sekera31da2e32018-06-24 22:49:55 +020051
Klement Sekera31da2e32018-06-24 22:49:55 +020052 def object_id(self):
53 return "ipsec-tun-if-%d" % self._sw_if_index