2018-06-24 22:49:55 +02:00
|
|
|
from vpp_tunnel_interface import VppTunnelInterface
|
|
|
|
|
|
|
|
|
|
|
|
class VppIpsecTunInterface(VppTunnelInterface):
|
|
|
|
"""
|
|
|
|
VPP IPsec Tunnel interface
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, test, parent_if, local_spi,
|
|
|
|
remote_spi, crypto_alg, local_crypto_key, remote_crypto_key,
|
2019-04-16 02:41:34 +00:00
|
|
|
integ_alg, local_integ_key, remote_integ_key, salt=0,
|
2019-06-14 01:13:25 -07:00
|
|
|
udp_encap=False,
|
2019-04-16 02:41:34 +00:00
|
|
|
is_ip6=False):
|
2018-06-24 22:49:55 +02:00
|
|
|
super(VppIpsecTunInterface, self).__init__(test, parent_if)
|
|
|
|
self.local_spi = local_spi
|
|
|
|
self.remote_spi = remote_spi
|
|
|
|
self.crypto_alg = crypto_alg
|
|
|
|
self.local_crypto_key = local_crypto_key
|
|
|
|
self.remote_crypto_key = remote_crypto_key
|
|
|
|
self.integ_alg = integ_alg
|
|
|
|
self.local_integ_key = local_integ_key
|
|
|
|
self.remote_integ_key = remote_integ_key
|
2019-04-16 02:41:34 +00:00
|
|
|
self.salt = salt
|
2019-03-20 07:21:58 -04:00
|
|
|
if is_ip6:
|
|
|
|
self.local_ip = self.parent_if.local_ip6
|
|
|
|
self.remote_ip = self.parent_if.remote_ip6
|
|
|
|
else:
|
|
|
|
self.local_ip = self.parent_if.local_ip4
|
|
|
|
self.remote_ip = self.parent_if.remote_ip4
|
2019-07-16 06:19:35 -07:00
|
|
|
self.udp_encap = udp_encap
|
2018-06-24 22:49:55 +02:00
|
|
|
|
|
|
|
def add_vpp_config(self):
|
|
|
|
r = self.test.vapi.ipsec_tunnel_if_add_del(
|
2019-03-20 07:21:58 -04:00
|
|
|
self.local_ip, self.remote_ip,
|
|
|
|
self.remote_spi, self.local_spi,
|
|
|
|
self.crypto_alg, self.local_crypto_key, self.remote_crypto_key,
|
2019-04-16 02:41:34 +00:00
|
|
|
self.integ_alg, self.local_integ_key, self.remote_integ_key,
|
2019-06-14 01:13:25 -07:00
|
|
|
salt=self.salt,
|
|
|
|
udp_encap=self.udp_encap)
|
2018-06-24 22:49:55 +02:00
|
|
|
self.set_sw_if_index(r.sw_if_index)
|
|
|
|
self.generate_remote_hosts()
|
|
|
|
self.test.registry.register(self, self.test.logger)
|
|
|
|
|
|
|
|
def remove_vpp_config(self):
|
|
|
|
self.test.vapi.ipsec_tunnel_if_add_del(
|
2019-03-20 07:21:58 -04:00
|
|
|
self.local_ip, self.remote_ip,
|
|
|
|
self.remote_spi, self.local_spi,
|
|
|
|
self.crypto_alg, self.local_crypto_key, self.remote_crypto_key,
|
|
|
|
self.integ_alg, self.local_integ_key, self.remote_integ_key,
|
|
|
|
is_add=0)
|
2018-06-24 22:49:55 +02:00
|
|
|
|
|
|
|
def object_id(self):
|
|
|
|
return "ipsec-tun-if-%d" % self._sw_if_index
|