blob: 7f11b7ebb1aaf5d64c203c8d4665c196aca913f1 [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 Ranns12989b52019-09-26 16:20:19 +000013 is_ip6=False,
14 dst=None):
Klement Sekera31da2e32018-06-24 22:49:55 +020015 super(VppIpsecTunInterface, self).__init__(test, parent_if)
16 self.local_spi = local_spi
17 self.remote_spi = remote_spi
18 self.crypto_alg = crypto_alg
19 self.local_crypto_key = local_crypto_key
20 self.remote_crypto_key = remote_crypto_key
21 self.integ_alg = integ_alg
22 self.local_integ_key = local_integ_key
23 self.remote_integ_key = remote_integ_key
Neale Ranns80f6fd52019-04-16 02:41:34 +000024 self.salt = salt
Kingwel Xie1ba5bc82019-03-20 07:21:58 -040025 if is_ip6:
26 self.local_ip = self.parent_if.local_ip6
27 self.remote_ip = self.parent_if.remote_ip6
28 else:
29 self.local_ip = self.parent_if.local_ip4
30 self.remote_ip = self.parent_if.remote_ip4
Neale Ranns12989b52019-09-26 16:20:19 +000031 if dst:
32 self.remote_ip = dst
Neale Ranns41afb332019-07-16 06:19:35 -070033 self.udp_encap = udp_encap
Klement Sekera31da2e32018-06-24 22:49:55 +020034
35 def add_vpp_config(self):
36 r = self.test.vapi.ipsec_tunnel_if_add_del(
Kingwel Xie1ba5bc82019-03-20 07:21:58 -040037 self.local_ip, self.remote_ip,
38 self.remote_spi, self.local_spi,
39 self.crypto_alg, self.local_crypto_key, self.remote_crypto_key,
Neale Ranns80f6fd52019-04-16 02:41:34 +000040 self.integ_alg, self.local_integ_key, self.remote_integ_key,
Neale Rannsa6bee0a2019-06-14 01:13:25 -070041 salt=self.salt,
42 udp_encap=self.udp_encap)
Klement Sekera31da2e32018-06-24 22:49:55 +020043 self.set_sw_if_index(r.sw_if_index)
44 self.generate_remote_hosts()
45 self.test.registry.register(self, self.test.logger)
46
47 def remove_vpp_config(self):
48 self.test.vapi.ipsec_tunnel_if_add_del(
Kingwel Xie1ba5bc82019-03-20 07:21:58 -040049 self.local_ip, self.remote_ip,
50 self.remote_spi, self.local_spi,
51 self.crypto_alg, self.local_crypto_key, self.remote_crypto_key,
52 self.integ_alg, self.local_integ_key, self.remote_integ_key,
53 is_add=0)
Klement Sekera31da2e32018-06-24 22:49:55 +020054
Klement Sekera31da2e32018-06-24 22:49:55 +020055 def object_id(self):
56 return "ipsec-tun-if-%d" % self._sw_if_index