aboutsummaryrefslogtreecommitdiffstats
path: root/test/vpp_ipsec_tun_interface.py
blob: c427936fa087274d2a9fbf30ddab3e6eff70521f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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,
                 integ_alg, local_integ_key, remote_integ_key, is_ip6=False):
        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
        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

    def add_vpp_config(self):
        r = self.test.vapi.ipsec_tunnel_if_add_del(
            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)
        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(
            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)

    def object_id(self):
        return "ipsec-tun-if-%d" % self._sw_if_index