summaryrefslogtreecommitdiffstats
path: root/test/vpp_papi_provider.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/vpp_papi_provider.py')
-rw-r--r--test/vpp_papi_provider.py162
1 files changed, 162 insertions, 0 deletions
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index c8954f842b4..338ca27eaa1 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -2811,3 +2811,165 @@ class VppPapiProvider(object):
return self.api(
self.papi.session_enable_disable,
{'is_enable': is_enabled})
+
+ def ipsec_spd_add_del(self, spd_id, is_add=1):
+ """ SPD add/del - Wrapper to add or del ipsec SPD
+ Sample CLI : 'ipsec spd add 1'
+
+ :param spd_id - SPD ID to be created in the vpp . mandatory
+ :param is_add - create (1) or delete(0) SPD (Default 1 - add) .
+ optional
+ :returns: reply from the API
+ """
+ return self.api(
+ self.papi.ipsec_spd_add_del, {
+ 'spd_id': spd_id, 'is_add': is_add})
+
+ def ipsec_interface_add_del_spd(self, spd_id, sw_if_index, is_add=1):
+ """ IPSEC interface SPD add/del - \
+ Wrapper to associate/disassociate SPD to interface in VPP
+ Sample CLI : 'set interface ipsec spd GigabitEthernet0/6/0 1'
+
+ :param spd_id - SPD ID to associate with the interface . mandatory
+ :param sw_if_index - Interface Index which needs to ipsec \
+ association mandatory
+ :param is_add - add(1) or del(0) association with interface \
+ (Default 1 - add) . optional
+ :returns: reply from the API
+ """
+ return self.api(
+ self.papi.ipsec_interface_add_del_spd, {
+ 'spd_id': spd_id,
+ 'sw_if_index': sw_if_index, 'is_add': is_add})
+
+ def ipsec_sad_add_del_entry(self,
+ sad_id,
+ spi,
+ tunnel_src_address='',
+ tunnel_dst_address='',
+ protocol=0,
+ integrity_algorithm=2,
+ integrity_key_length=0,
+ integrity_key='C91KUR9GYMm5GfkEvNjX',
+ crypto_algorithm=1,
+ crypto_key_length=0,
+ crypto_key='JPjyOWBeVEQiMe7h',
+ is_add=1,
+ is_tunnel=1):
+ """ IPSEC SA add/del
+ Sample CLI : 'ipsec sa add 10 spi 1001 esp \
+ crypto-key 4a506a794f574265564551694d653768 \
+ crypto-alg aes-cbc-128 \
+ integ-key 4339314b55523947594d6d3547666b45764e6a58 \
+ integ-alg sha1-96 tunnel-src 192.168.100.3 \
+ tunnel-dst 192.168.100.2'
+ Sample CLI : 'ipsec sa add 20 spi 2001 \
+ integ-key 4339314b55523947594d6d3547666b45764e6a58 \
+ integ-alg sha1-96'
+
+ :param sad_id - Security Association ID to be \
+ created or deleted. mandatory
+ :param spi - security param index of the SA in decimal. mandatory
+ :param tunnel_src_address - incase of tunnel mode outer src address .\
+ mandatory for tunnel mode
+ :param tunnel_dst_address - incase of transport mode \
+ outer dst address. mandatory for tunnel mode
+ :param protocol - AH(0) or ESP(1) protocol (Default 0 - AH). optional
+ :param integrity_algorithm - value range 1-6 Default(2 - SHA1_96).\
+ optional **
+ :param integrity_key - value in string \
+ (Default C91KUR9GYMm5GfkEvNjX).optional
+ :param integrity_key_length - length of the key string in bytes\
+ (Default 0 - integrity disabled). optional
+ :param crypto_algorithm - value range 1-11 Default \
+ (1- AES_CBC_128).optional **
+ :param crypto_key - value in string(Default JPjyOWBeVEQiMe7h).optional
+ :param crypto_key_length - length of the key string in bytes\
+ (Default 0 - crypto disabled). optional
+ :param is_add - add(1) or del(0) ipsec SA entry(Default 1 - add) .\
+ optional
+ :param is_tunnel - tunnel mode (1) or transport mode(0) \
+ (Default 1 - tunnel). optional
+ :returns: reply from the API
+ :** reference /vpp/src/vnet/ipsec/ipsec.h file for enum values of
+ crypto and ipsec algorithms
+ """
+ return self.api(
+ self.papi.ipsec_sad_add_del_entry,
+ {'sad_id': sad_id,
+ 'spi': spi,
+ 'tunnel_src_address': tunnel_src_address,
+ 'tunnel_dst_address': tunnel_dst_address,
+ 'protocol': protocol,
+ 'integrity_algorithm': integrity_algorithm,
+ 'integrity_key_length': integrity_key_length,
+ 'integrity_key': integrity_key,
+ 'crypto_algorithm': crypto_algorithm,
+ 'crypto_key_length': crypto_key_length,
+ 'crypto_key': crypto_key,
+ 'is_add': is_add,
+ 'is_tunnel': is_tunnel})
+
+ def ipsec_spd_add_del_entry(self,
+ spd_id,
+ local_address_start,
+ local_address_stop,
+ remote_address_start,
+ remote_address_stop,
+ local_port_start=0,
+ local_port_stop=65535,
+ remote_port_start=0,
+ remote_port_stop=65535,
+ protocol=0,
+ sa_id=10,
+ policy=0,
+ priority=100,
+ is_outbound=1,
+ is_add=1,
+ is_ip_any=0):
+ """ IPSEC policy SPD add/del -
+ Wrapper to configure ipsec SPD policy entries in VPP
+ Sample CLI : 'ipsec policy add spd 1 inbound priority 10 action \
+ protect sa 20 local-ip-range 192.168.4.4 - 192.168.4.4 \
+ remote-ip-range 192.168.3.3 - 192.168.3.3'
+
+ :param spd_id - SPD ID for the policy . mandatory
+ :param local_address_start - local-ip-range start address . mandatory
+ :param local_address_stop - local-ip-range stop address . mandatory
+ :param remote_address_start - remote-ip-range start address . mandatory
+ :param remote_address_stop - remote-ip-range stop address . mandatory
+ :param local_port_start - (Default 0) . optional
+ :param local_port_stop - (Default 65535). optional
+ :param remote_port_start - (Default 0). optional
+ :param remote_port_stop - (Default 65535). optional
+ :param protocol - Any(0), AH(51) & ESP(50) protocol (Default 0 - Any).
+ optional
+ :param sa_id - Security Association ID for mapping it to SPD
+ (default 10). optional
+ :param policy - bypass(0), discard(1), resolve(2) or protect(3)action
+ (Default 0 - bypass). optional
+ :param priotity - value for the spd action (Default 100). optional
+ :param is_outbound - flag for inbound(0) or outbound(1)
+ (Default 1 - outbound). optional
+ :param is_add flag - for addition(1) or deletion(0) of the spd
+ (Default 1 - addtion). optional
+ :returns: reply from the API
+ """
+ return self.api(
+ self.papi.ipsec_spd_add_del_entry,
+ {'spd_id': spd_id,
+ 'local_address_start': local_address_start,
+ 'local_address_stop': local_address_stop,
+ 'remote_address_start': remote_address_start,
+ 'remote_address_stop': remote_address_stop,
+ 'local_port_start': local_port_start,
+ 'local_port_stop': local_port_stop,
+ 'remote_port_start': remote_port_start,
+ 'remote_port_stop': remote_port_stop,
+ 'is_add': is_add,
+ 'protocol': protocol,
+ 'policy': policy,
+ 'priority': priority,
+ 'is_outbound': is_outbound,
+ 'sa_id': sa_id,
+ 'is_ip_any': is_ip_any})