Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 1 | from vpp_tunnel_interface import VppTunnelInterface |
| 2 | |
| 3 | |
| 4 | class 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 Ranns | 80f6fd5 | 2019-04-16 02:41:34 +0000 | [diff] [blame] | 11 | integ_alg, local_integ_key, remote_integ_key, salt=0, |
Neale Ranns | a6bee0a | 2019-06-14 01:13:25 -0700 | [diff] [blame] | 12 | udp_encap=False, |
Neale Ranns | 12989b5 | 2019-09-26 16:20:19 +0000 | [diff] [blame] | 13 | is_ip6=False, |
| 14 | dst=None): |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 15 | 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 Ranns | 80f6fd5 | 2019-04-16 02:41:34 +0000 | [diff] [blame] | 24 | self.salt = salt |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 25 | 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 Ranns | 12989b5 | 2019-09-26 16:20:19 +0000 | [diff] [blame] | 31 | if dst: |
| 32 | self.remote_ip = dst |
Neale Ranns | 41afb33 | 2019-07-16 06:19:35 -0700 | [diff] [blame] | 33 | self.udp_encap = udp_encap |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 34 | |
| 35 | def add_vpp_config(self): |
| 36 | r = self.test.vapi.ipsec_tunnel_if_add_del( |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 37 | 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 Ranns | 80f6fd5 | 2019-04-16 02:41:34 +0000 | [diff] [blame] | 40 | self.integ_alg, self.local_integ_key, self.remote_integ_key, |
Neale Ranns | a6bee0a | 2019-06-14 01:13:25 -0700 | [diff] [blame] | 41 | salt=self.salt, |
| 42 | udp_encap=self.udp_encap) |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 43 | 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 Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 49 | 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 Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 54 | |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 55 | def object_id(self): |
| 56 | return "ipsec-tun-if-%d" % self._sw_if_index |