2018-06-24 22:49:55 +02:00
|
|
|
import unittest
|
|
|
|
import socket
|
|
|
|
from scapy.layers.ipsec import ESP
|
|
|
|
from framework import VppTestRunner
|
2018-09-26 11:19:00 +02:00
|
|
|
from template_ipsec import TemplateIpsec, IpsecTun4Tests, IpsecTcpTests
|
2018-06-24 22:49:55 +02:00
|
|
|
from vpp_ipsec_tun_interface import VppIpsecTunInterface
|
2019-01-24 04:52:25 -08:00
|
|
|
from vpp_ip_route import VppIpRoute, VppRoutePath
|
2018-06-24 22:49:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TemplateIpsecTunIfEsp(TemplateIpsec):
|
|
|
|
""" IPsec tunnel interface tests """
|
|
|
|
|
|
|
|
encryption_type = ESP
|
|
|
|
|
|
|
|
def setUp(self):
|
2019-01-23 08:16:17 -08:00
|
|
|
super(TemplateIpsecTunIfEsp, self).setUp()
|
|
|
|
|
|
|
|
self.tun_if = self.pg0
|
|
|
|
|
2018-09-26 11:19:00 +02:00
|
|
|
p = self.ipv4_params
|
|
|
|
tun_if = VppIpsecTunInterface(self, self.pg0, p.vpp_tun_spi,
|
|
|
|
p.scapy_tun_spi, p.crypt_algo_vpp_id,
|
|
|
|
p.crypt_key, p.crypt_key,
|
|
|
|
p.auth_algo_vpp_id, p.auth_key,
|
|
|
|
p.auth_key)
|
|
|
|
tun_if.add_vpp_config()
|
|
|
|
tun_if.admin_up()
|
|
|
|
tun_if.config_ip4()
|
2019-01-24 04:52:25 -08:00
|
|
|
|
|
|
|
VppIpRoute(self, p.remote_tun_if_host, 32,
|
|
|
|
[VppRoutePath(tun_if.remote_ip4,
|
|
|
|
0xffffffff)]).add_vpp_config()
|
2018-06-24 22:49:55 +02:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
if not self.vpp_dead:
|
|
|
|
self.vapi.cli("show hardware")
|
|
|
|
super(TemplateIpsecTunIfEsp, self).tearDown()
|
|
|
|
|
|
|
|
|
2018-09-26 11:19:00 +02:00
|
|
|
class TestIpsecTunIfEsp1(TemplateIpsecTunIfEsp, IpsecTun4Tests):
|
2018-06-24 22:49:55 +02:00
|
|
|
""" Ipsec ESP - TUN tests """
|
2018-11-08 13:00:02 +01:00
|
|
|
tun4_encrypt_node_name = "esp4-encrypt"
|
|
|
|
tun4_decrypt_node_name = "esp4-decrypt"
|
2018-06-24 22:49:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TestIpsecTunIfEsp2(TemplateIpsecTunIfEsp, IpsecTcpTests):
|
|
|
|
""" Ipsec ESP - TCP tests """
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(testRunner=VppTestRunner)
|