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 | 80f6fd5 | 2019-04-16 02:41:34 +0000 | [diff] [blame] | 13 | is_ip6=False): |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 14 | super(VppIpsecTunInterface, self).__init__(test, parent_if) |
| 15 | self.local_spi = local_spi |
| 16 | self.remote_spi = remote_spi |
| 17 | self.crypto_alg = crypto_alg |
| 18 | self.local_crypto_key = local_crypto_key |
| 19 | self.remote_crypto_key = remote_crypto_key |
| 20 | self.integ_alg = integ_alg |
| 21 | self.local_integ_key = local_integ_key |
| 22 | self.remote_integ_key = remote_integ_key |
Neale Ranns | 80f6fd5 | 2019-04-16 02:41:34 +0000 | [diff] [blame] | 23 | self.salt = salt |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 24 | if is_ip6: |
| 25 | self.local_ip = self.parent_if.local_ip6 |
| 26 | self.remote_ip = self.parent_if.remote_ip6 |
| 27 | else: |
| 28 | self.local_ip = self.parent_if.local_ip4 |
| 29 | self.remote_ip = self.parent_if.remote_ip4 |
Neale Ranns | 41afb33 | 2019-07-16 06:19:35 -0700 | [diff] [blame] | 30 | self.udp_encap = udp_encap |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 31 | |
| 32 | def add_vpp_config(self): |
| 33 | r = self.test.vapi.ipsec_tunnel_if_add_del( |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 34 | self.local_ip, self.remote_ip, |
| 35 | self.remote_spi, self.local_spi, |
| 36 | self.crypto_alg, self.local_crypto_key, self.remote_crypto_key, |
Neale Ranns | 80f6fd5 | 2019-04-16 02:41:34 +0000 | [diff] [blame] | 37 | self.integ_alg, self.local_integ_key, self.remote_integ_key, |
Neale Ranns | a6bee0a | 2019-06-14 01:13:25 -0700 | [diff] [blame] | 38 | salt=self.salt, |
| 39 | udp_encap=self.udp_encap) |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 40 | self.set_sw_if_index(r.sw_if_index) |
| 41 | self.generate_remote_hosts() |
| 42 | self.test.registry.register(self, self.test.logger) |
| 43 | |
| 44 | def remove_vpp_config(self): |
| 45 | self.test.vapi.ipsec_tunnel_if_add_del( |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 46 | self.local_ip, self.remote_ip, |
| 47 | self.remote_spi, self.local_spi, |
| 48 | self.crypto_alg, self.local_crypto_key, self.remote_crypto_key, |
| 49 | self.integ_alg, self.local_integ_key, self.remote_integ_key, |
| 50 | is_add=0) |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 51 | |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 52 | def object_id(self): |
| 53 | return "ipsec-tun-if-%d" % self._sw_if_index |