3 from scapy.layers.ipsec import ESP
4 from framework import VppTestRunner
5 from template_ipsec import TemplateIpsec, IpsecTun4Tests, IpsecTun6Tests, \
7 from vpp_ipsec_tun_interface import VppIpsecTunInterface
8 from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto
11 class TemplateIpsec4TunIfEsp(TemplateIpsec):
12 """ IPsec tunnel interface tests """
17 super(TemplateIpsec4TunIfEsp, self).setUp()
19 self.tun_if = self.pg0
22 tun_if = VppIpsecTunInterface(self, self.pg0, p.vpp_tun_spi,
23 p.scapy_tun_spi, p.crypt_algo_vpp_id,
24 p.crypt_key, p.crypt_key,
25 p.auth_algo_vpp_id, p.auth_key,
27 tun_if.add_vpp_config()
31 VppIpRoute(self, p.remote_tun_if_host, 32,
32 [VppRoutePath(tun_if.remote_ip4,
33 0xffffffff)]).add_vpp_config()
37 self.vapi.cli("show hardware")
38 super(TemplateIpsec4TunIfEsp, self).tearDown()
41 class TestIpsec4TunIfEsp1(TemplateIpsec4TunIfEsp, IpsecTun4Tests):
42 """ Ipsec ESP - TUN tests """
43 tun4_encrypt_node_name = "esp4-encrypt"
44 tun4_decrypt_node_name = "esp4-decrypt"
47 class TestIpsec4TunIfEsp2(TemplateIpsec4TunIfEsp, IpsecTcpTests):
48 """ Ipsec ESP - TCP tests """
52 class TemplateIpsec6TunIfEsp(TemplateIpsec):
53 """ IPsec tunnel interface tests """
58 super(TemplateIpsec6TunIfEsp, self).setUp()
60 self.tun_if = self.pg0
63 tun_if = VppIpsecTunInterface(self, self.pg0, p.vpp_tun_spi,
64 p.scapy_tun_spi, p.crypt_algo_vpp_id,
65 p.crypt_key, p.crypt_key,
66 p.auth_algo_vpp_id, p.auth_key,
67 p.auth_key, is_ip6=True)
68 tun_if.add_vpp_config()
72 VppIpRoute(self, p.remote_tun_if_host, 32,
73 [VppRoutePath(tun_if.remote_ip6,
75 proto=DpoProto.DPO_PROTO_IP6)],
76 is_ip6=1).add_vpp_config()
80 self.vapi.cli("show hardware")
81 super(TemplateIpsec6TunIfEsp, self).tearDown()
84 class TestIpsec6TunIfEsp1(TemplateIpsec6TunIfEsp, IpsecTun6Tests):
85 """ Ipsec ESP - TUN tests """
86 tun6_encrypt_node_name = "esp6-encrypt"
87 tun6_decrypt_node_name = "esp6-decrypt"
90 if __name__ == '__main__':
91 unittest.main(testRunner=VppTestRunner)