aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2019-09-30 13:06:48 +0200
committerJakub Grajciar <jgrajcia@cisco.com>2019-10-09 13:52:32 +0200
commitd5262831a3379afc77cab9a16067765585dd5175 (patch)
treef5e771058e0eb73f2f9dd3ab46ccbb2a94fd56c1
parentde312c2d5fd709e2562955f0a57a56ea91455d7d (diff)
dhcp: dhcp6_pd_client_cp API cleanup
Use consistent API types. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: If6c102a53d074cba7eca6b6af9855aa4486f38cc
-rw-r--r--src/plugins/dhcp/dhcp6_pd_client_cp.api20
-rw-r--r--src/plugins/dhcp/dhcp6_pd_client_cp.c1
-rw-r--r--src/plugins/dhcp/dhcp6_pd_client_cp_api.c5
-rw-r--r--src/plugins/dhcp/test/test_dhcp6.py80
-rw-r--r--test/vpp_papi_provider.py10
5 files changed, 53 insertions, 63 deletions
diff --git a/src/plugins/dhcp/dhcp6_pd_client_cp.api b/src/plugins/dhcp/dhcp6_pd_client_cp.api
index 43ed868e81e..681479fcfc8 100644
--- a/src/plugins/dhcp/dhcp6_pd_client_cp.api
+++ b/src/plugins/dhcp/dhcp6_pd_client_cp.api
@@ -13,7 +13,10 @@
* limitations under the License.
*/
-option version = "1.0.0";
+option version = "2.0.0";
+
+import "vnet/interface_types.api";
+import "vnet/ip/ip_types.api";
/** \brief Enable/disable DHCPv6 PD client on interface
@param client_index - opaque cookie to identify the sender
@@ -26,9 +29,9 @@ autoreply define dhcp6_pd_client_enable_disable
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 prefix_group[64];
- u8 enable;
+ vl_api_interface_index_t sw_if_index;
+ string prefix_group[64];
+ bool enable;
};
/** \brief Add/delete IPv6 address optionally using available prefix
@@ -47,11 +50,10 @@ autoreply define ip6_add_del_address_using_prefix
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 prefix_group[64];
- u8 address[16];
- u8 prefix_length;
- u8 is_add;
+ vl_api_interface_index_t sw_if_index;
+ string prefix_group[64];
+ vl_api_ip6_address_with_prefix_t address_with_prefix;
+ bool is_add;
};
/*
diff --git a/src/plugins/dhcp/dhcp6_pd_client_cp.c b/src/plugins/dhcp/dhcp6_pd_client_cp.c
index 6f151430e58..45921d34f97 100644
--- a/src/plugins/dhcp/dhcp6_pd_client_cp.c
+++ b/src/plugins/dhcp/dhcp6_pd_client_cp.c
@@ -22,6 +22,7 @@
#include <float.h>
#include <math.h>
#include <string.h>
+#include <vnet/ip/ip_types_api.h>
typedef struct
{
diff --git a/src/plugins/dhcp/dhcp6_pd_client_cp_api.c b/src/plugins/dhcp/dhcp6_pd_client_cp_api.c
index 4999fd7f623..7430028f69f 100644
--- a/src/plugins/dhcp/dhcp6_pd_client_cp_api.c
+++ b/src/plugins/dhcp/dhcp6_pd_client_cp_api.c
@@ -15,6 +15,7 @@
#include <vnet/vnet.h>
#include <vlibmemory/api.h>
+#include <vnet/ip/ip_types_api.h>
#include <dhcp/dhcp6_pd_client_dp.h>
@@ -65,8 +66,8 @@ static void
sw_if_index = ntohl (mp->sw_if_index);
- memcpy (address.as_u8, mp->address, 16);
- prefix_length = mp->prefix_length;
+ ip6_address_decode (mp->address_with_prefix.address, &address);
+ prefix_length = mp->address_with_prefix.len;
rv = dhcp6_cp_ip6_address_add_del (sw_if_index, mp->prefix_group, address,
prefix_length, mp->is_add);
diff --git a/src/plugins/dhcp/test/test_dhcp6.py b/src/plugins/dhcp/test/test_dhcp6.py
index 02f420243cb..9beff5a60e5 100644
--- a/src/plugins/dhcp/test/test_dhcp6.py
+++ b/src/plugins/dhcp/test/test_dhcp6.py
@@ -641,15 +641,13 @@ class TestDHCPv6PDControlPlane(VppTestCase):
def test_prefixes(self):
""" Test handling of prefixes """
- address_bin_1 = None
- address_bin_2 = None
+ address1 = '::2:0:0:0:405/60'
+ address2 = '::76:0:0:0:406/62'
try:
- address_bin_1 = '\x00' * 6 + '\x00\x02' + '\x00' * 6 + '\x04\x05'
- address_prefix_length_1 = 60
- self.vapi.ip6_add_del_address_using_prefix(self.pg1.sw_if_index,
- address_bin_1,
- address_prefix_length_1,
- self.prefix_group)
+ self.vapi.ip6_add_del_address_using_prefix(
+ sw_if_index=self.pg1.sw_if_index,
+ address_with_prefix=address1,
+ prefix_group=self.prefix_group)
ia_pd_opts = DHCP6OptIAPrefix(prefix='7:8::', plen=56, preflft=2,
validlft=3)
@@ -668,12 +666,10 @@ class TestDHCPv6PDControlPlane(VppTestCase):
self.sleep(1)
- address_bin_2 = '\x00' * 6 + '\x00\x76' + '\x00' * 6 + '\x04\x06'
- address_prefix_length_2 = 62
- self.vapi.ip6_add_del_address_using_prefix(self.pg1.sw_if_index,
- address_bin_2,
- address_prefix_length_2,
- self.prefix_group)
+ self.vapi.ip6_add_del_address_using_prefix(
+ sw_if_index=self.pg1.sw_if_index,
+ address_with_prefix=address2,
+ prefix_group=self.prefix_group)
self.sleep(1)
@@ -698,14 +694,16 @@ class TestDHCPv6PDControlPlane(VppTestCase):
self.assertEqual(len(new_addresses), 0)
finally:
- if address_bin_1 is not None:
+ if address1 is not None:
self.vapi.ip6_add_del_address_using_prefix(
- self.pg1.sw_if_index, address_bin_1,
- address_prefix_length_1, self.prefix_group, is_add=0)
- if address_bin_2 is not None:
+ sw_if_index=self.pg1.sw_if_index,
+ address_with_prefix=address1,
+ prefix_group=self.prefix_group, is_add=0)
+ if address2 is not None:
self.vapi.ip6_add_del_address_using_prefix(
- self.pg1.sw_if_index, address_bin_2,
- address_prefix_length_2, self.prefix_group, is_add=0)
+ sw_if_index=self.pg1.sw_if_index,
+ address_with_prefix=address2,
+ prefix_group=self.prefix_group, is_add=0)
def test_sending_client_messages_solicit(self):
""" VPP receives messages from DHCPv6 client """
@@ -742,13 +740,12 @@ class TestDHCPv6PDControlPlane(VppTestCase):
def test_preferred_greater_than_valid_lifetime(self):
""" Preferred lifetime is greater than valid lifetime """
+ address1 = '::2:0:0:0:405/60'
try:
- address_bin = '\x00' * 6 + '\x00\x02' + '\x00' * 6 + '\x04\x05'
- address_prefix_length = 60
- self.vapi.ip6_add_del_address_using_prefix(self.pg1.sw_if_index,
- address_bin,
- address_prefix_length,
- self.prefix_group)
+ self.vapi.ip6_add_del_address_using_prefix(
+ sw_if_index=self.pg1.sw_if_index,
+ address_with_prefix=address1,
+ prefix_group=self.prefix_group)
self.wait_for_solicit()
self.send_advertise()
@@ -766,22 +763,21 @@ class TestDHCPv6PDControlPlane(VppTestCase):
self.assertEqual(len(new_addresses), 0)
finally:
- self.vapi.ip6_add_del_address_using_prefix(self.pg1.sw_if_index,
- address_bin,
- address_prefix_length,
- self.prefix_group,
- is_add=0)
+ self.vapi.ip6_add_del_address_using_prefix(
+ sw_if_index=self.pg1.sw_if_index,
+ address_with_prefix=address1,
+ prefix_group=self.prefix_group,
+ is_add=0)
def test_T1_greater_than_T2(self):
""" T1 is greater than T2 """
+ address1 = '::2:0:0:0:405/60'
try:
- address_bin = '\x00' * 6 + '\x00\x02' + '\x00' * 6 + '\x04\x05'
- address_prefix_length = 60
- self.vapi.ip6_add_del_address_using_prefix(self.pg1.sw_if_index,
- address_bin,
- address_prefix_length,
- self.prefix_group)
+ self.vapi.ip6_add_del_address_using_prefix(
+ sw_if_index=self.pg1.sw_if_index,
+ address_with_prefix=address1,
+ prefix_group=self.prefix_group)
self.wait_for_solicit()
self.send_advertise()
@@ -799,8 +795,8 @@ class TestDHCPv6PDControlPlane(VppTestCase):
self.assertEqual(len(new_addresses), 0)
finally:
- self.vapi.ip6_add_del_address_using_prefix(self.pg1.sw_if_index,
- address_bin,
- address_prefix_length,
- self.prefix_group,
- is_add=0)
+ self.vapi.ip6_add_del_address_using_prefix(
+ sw_if_index=self.pg1.sw_if_index,
+ prefix_group=self.prefix_group,
+ address_with_prefix=address1,
+ is_add=False)
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index bc27352adc9..8cb7c971758 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -401,16 +401,6 @@ class VppPapiProvider(object):
'learn_limit': learn_limit,
'pid': os.getpid(), })
- def ip6_add_del_address_using_prefix(self, sw_if_index, address,
- prefix_length, prefix_group,
- is_add=1):
- return self.api(self.papi.ip6_add_del_address_using_prefix,
- {'sw_if_index': sw_if_index,
- 'prefix_group': prefix_group,
- 'address': address,
- 'prefix_length': prefix_length,
- 'is_add': is_add})
-
def sw_interface_set_mac_address(self, sw_if_index, mac):
return self.api(self.papi.sw_interface_set_mac_address,
{'sw_if_index': sw_if_index,