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