aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2017-02-01 08:50:31 +0100
committerFlorin Coras <florin.coras@gmail.com>2017-02-02 07:04:54 +0000
commit05a057bb3af7d83f62a2919ccab57aa0a41b04a9 (patch)
tree4623cde1670e38afa83b7f266f084e83485389cb
parenta93ea428fe60cc3fb64b758f5d97ebf87a07f95f (diff)
LISP: enhance binary part of some APIs
Remote mapping and locator set binary APIs uses zero length arrays defined as 'u8 array[0]' in .api file. This path will change such cases to form 'type_t array[count];' in order to enhance maintainability. Change-Id: I98d0252b441020609c550d48186ed0d8338a3f2d Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r--src/vat/api_format.c18
-rw-r--r--src/vnet/lisp-cp/lisp.api40
-rw-r--r--src/vnet/lisp-cp/lisp_api.c39
-rw-r--r--src/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/LispAdjacencyTest.java3
-rw-r--r--src/vpp/api/custom_dump.c58
5 files changed, 41 insertions, 117 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 26df1aff4df..0bbefd6901f 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -13243,16 +13243,6 @@ lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
clib_memcpy (dst, eid, lisp_eid_size_vat (type));
}
-/* *INDENT-OFF* */
-/** Used for transferring locators via VPP API */
-typedef CLIB_PACKED(struct
-{
- u32 sw_if_index; /**< locator sw_if_index */
- u8 priority; /**< locator priority */
- u8 weight; /**< locator weight */
-}) ls_locator_t;
-/* *INDENT-ON* */
-
static int
api_lisp_add_del_locator_set (vat_main_t * vam)
{
@@ -13262,7 +13252,7 @@ api_lisp_add_del_locator_set (vat_main_t * vam)
u8 is_add = 1;
u8 *locator_set_name = NULL;
u8 locator_set_name_set = 0;
- ls_locator_t locator, *locators = 0;
+ vl_api_local_locator_t locator, *locators = 0;
u32 sw_if_index, priority, weight;
u32 data_len = 0;
@@ -13315,7 +13305,7 @@ api_lisp_add_del_locator_set (vat_main_t * vam)
}
vec_add1 (locator_set_name, 0);
- data_len = sizeof (ls_locator_t) * vec_len (locators);
+ data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
/* Construct the API message */
M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
@@ -14317,7 +14307,7 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
u32 action = ~0, p, w, data_len;
ip4_address_t rloc4;
ip6_address_t rloc6;
- rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
+ vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
memset (&rloc, 0, sizeof (rloc));
@@ -14396,7 +14386,7 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
return -99;
}
- data_len = vec_len (rlocs) * sizeof (rloc_t);
+ data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
mp->is_add = is_add;
diff --git a/src/vnet/lisp-cp/lisp.api b/src/vnet/lisp-cp/lisp.api
index f0feafeecc8..a50a5ccbe03 100644
--- a/src/vnet/lisp-cp/lisp.api
+++ b/src/vnet/lisp-cp/lisp.api
@@ -13,6 +13,13 @@
* limitations under the License.
*/
+typeonly manual_print manual_endian define local_locator
+{
+ u32 sw_if_index;
+ u8 priority;
+ u8 weight;
+};
+
/** \brief add or delete locator_set
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@@ -20,22 +27,15 @@
@param locator_set_name - locator name
@param locator_num - number of locators
@param locators - LISP locator records
- Structure of one locator record is as follows:
-
- define locator_t {
- u32 sw_if_index;
- u8 priority;
- u8 weight;
- }
*/
-define lisp_add_del_locator_set
+manual_endian manual_print define lisp_add_del_locator_set
{
u32 client_index;
u32 context;
u8 is_add;
u8 locator_set_name[64];
u32 locator_num;
- u8 locators[0];
+ vl_api_local_locator_t locators[locator_num];
};
/** \brief Reply for locator_set add/del
@@ -405,6 +405,14 @@ define show_lisp_map_request_mode_reply
u8 mode;
};
+typeonly manual_endian manual_print define remote_locator
+{
+ u8 is_ip4;
+ u8 priority;
+ u8 weight;
+ u8 addr[16];
+};
+
/** \brief add or delete remote static mapping
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@@ -421,16 +429,8 @@ define show_lisp_map_request_mode_reply
@param seid - src EID, valid only if is_src_dst is enabled
@param rloc_num - number of remote locators
@param rlocs - remote locator records
- Structure of remote locator:
-
- define rloc_t {
- u8 is_ip4;
- u8 priority;
- u8 weight;
- u8 addr[16];
- }
*/
-define lisp_add_del_remote_mapping
+manual_print manual_endian define lisp_add_del_remote_mapping
{
u32 client_index;
u32 context;
@@ -445,7 +445,7 @@ define lisp_add_del_remote_mapping
u8 seid[16];
u8 seid_len;
u32 rloc_num;
- u8 rlocs[0];
+ vl_api_remote_locator_t rlocs[rloc_num];
};
/** \brief Reply for lisp_add_del_remote_mapping
@@ -883,4 +883,4 @@ define show_lisp_pitr_reply
* eval: (c-set-style "gnu")
* End:
*/
- \ No newline at end of file
+
diff --git a/src/vnet/lisp-cp/lisp_api.c b/src/vnet/lisp-cp/lisp_api.c
index 6f34d02c407..a877540b3ed 100644
--- a/src/vnet/lisp-cp/lisp_api.c
+++ b/src/vnet/lisp-cp/lisp_api.c
@@ -27,6 +27,16 @@
#include <vnet/vnet_msg_enum.h>
+#define vl_api_remote_locator_t_endian vl_noop_handler
+#define vl_api_remote_locator_t_print vl_noop_handler
+#define vl_api_local_locator_t_endian vl_noop_handler
+#define vl_api_local_locator_t_print vl_noop_handler
+
+#define vl_api_lisp_add_del_locator_set_t_endian vl_noop_handler
+#define vl_api_lisp_add_del_locator_set_t_print vl_noop_handler
+#define vl_api_lisp_add_del_remote_mapping_t_endian vl_noop_handler
+#define vl_api_lisp_add_del_remote_mapping_t_print vl_noop_handler
+
#define vl_typedefs /* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_typedefs
@@ -76,36 +86,17 @@ _(SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode) \
_(LISP_USE_PETR, lisp_use_petr) \
_(SHOW_LISP_USE_PETR, show_lisp_use_petr) \
-/** Used for transferring locators via VPP API */
-/* *INDENT-OFF* */
-typedef CLIB_PACKED (struct {
- u8 is_ip4; /**< is locator an IPv4 address */
- u8 priority; /**< locator priority */
- u8 weight; /**< locator weight */
- u8 addr[16]; /**< IPv4/IPv6 address */
-}) rloc_t;
-/* *INDENT-ON* */
-
-/** Used for transferring locators via VPP API */
-/* *INDENT-OFF* */
-typedef CLIB_PACKED (struct {
- u32 sw_if_index; /**< locator sw_if_index */
- u8 priority; /**< locator priority */
- u8 weight; /**< locator weight */
-}) ls_locator_t;
-/* *INDENT-ON* */
-
static locator_t *
-unformat_lisp_locs (void *rmt_locs, u32 rloc_num)
+unformat_lisp_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
{
u32 i;
locator_t *locs = 0, loc;
- rloc_t *r;
+ vl_api_remote_locator_t *r;
for (i = 0; i < rloc_num; i++)
{
/* remote locators */
- r = &((rloc_t *) rmt_locs)[i];
+ r = &rmt_locs[i];
memset (&loc, 0, sizeof (loc));
gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
@@ -125,7 +116,7 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
int rv = 0;
vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
locator_t locator;
- ls_locator_t *ls_loc;
+ vl_api_local_locator_t *ls_loc;
u32 ls_index = ~0, locator_num;
u8 *locator_name = NULL;
int i;
@@ -142,7 +133,7 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
memset (&locator, 0, sizeof (locator));
for (i = 0; i < locator_num; i++)
{
- ls_loc = &((ls_locator_t *) mp->locators)[i];
+ ls_loc = &mp->locators[i];
VALIDATE_SW_IF_INDEX (ls_loc);
locator.sw_if_index = htonl (ls_loc->sw_if_index);
diff --git a/src/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/LispAdjacencyTest.java b/src/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/LispAdjacencyTest.java
index d7f5039b152..e7b17335748 100644
--- a/src/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/LispAdjacencyTest.java
+++ b/src/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/LispAdjacencyTest.java
@@ -73,7 +73,8 @@ public class LispAdjacencyTest {
request.eid = new byte[] {1, 2, 1, 20};
request.eidLen = 32;
request.rlocNum = 1;
- request.rlocs = new byte[] {1, 1, 1, 1, 2, 1, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ // FIXME!!!!
+ //request.rlocs = new byte[] {1, 1, 1, 1, 2, 1, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
jvpp.lispAddDelRemoteMapping(request).toCompletableFuture().get();
LOG.info("Remote mapping created successfully:" + request.toString());
}
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 8f59f5eec37..a4e97216b66 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -2377,34 +2377,6 @@ format_lisp_flat_eid (u8 * s, va_list * args)
return 0;
}
-/** Used for transferring locators via VPP API */
-typedef CLIB_PACKED (struct
- {
- u8 is_ip4;
- /**< is locator an IPv4 address */
- u8 priority;
- /**< locator priority */
- u8 weight;
- /**< locator weight */
- u8 addr[16];
- /**< IPv4/IPv6 address */
- }) rloc_t;
-
-static u8 *
-format_rloc (u8 * s, va_list * args)
-{
- rloc_t *rloc = va_arg (*args, rloc_t *);
-
- if (rloc->is_ip4)
- s = format (s, "%U ", format_ip4_address, rloc->addr);
- else
- s = format (s, "%U ", format_ip6_address, rloc->addr);
-
- s = format (s, "p %d w %d", rloc->priority, rloc->weight);
-
- return s;
-}
-
static void *vl_api_lisp_add_del_remote_mapping_t_print
(vl_api_lisp_add_del_remote_mapping_t * mp, void *handle)
{
@@ -2432,12 +2404,6 @@ static void *vl_api_lisp_add_del_remote_mapping_t_print
if (0 == rloc_num)
s = format (s, "action %d", mp->action);
- else
- {
- rloc_t *rloc = (rloc_t *) mp->rlocs;
- for (i = 0; i < rloc_num; i++)
- s = format (s, "%U ", format_rloc, &rloc[i]);
- }
FINISH;
}
@@ -2553,31 +2519,11 @@ static void *vl_api_lisp_gpe_enable_disable_t_print
FINISH;
}
-typedef CLIB_PACKED (struct
- {
- u32 sw_if_index;
- /**< locator sw_if_index */
- u8 priority;
- /**< locator priority */
- u8 weight;
- /**< locator weight */
- }) ls_locator_t;
-
-static u8 *
-format_locator (u8 * s, va_list * args)
-{
- ls_locator_t *l = va_arg (*args, ls_locator_t *);
-
- return format (s, "sw_if_index %d p %d w %d",
- l->sw_if_index, l->priority, l->weight);
-}
-
static void *vl_api_lisp_add_del_locator_set_t_print
(vl_api_lisp_add_del_locator_set_t * mp, void *handle)
{
u8 *s;
u32 loc_num = 0, i;
- ls_locator_t *locs;
s = format (0, "SCRIPT: lisp_add_del_locator_set ");
@@ -2587,10 +2533,6 @@ static void *vl_api_lisp_add_del_locator_set_t_print
s = format (s, "locator-set %s ", mp->locator_set_name);
loc_num = clib_net_to_host_u32 (mp->locator_num);
- locs = (ls_locator_t *) mp->locators;
-
- for (i = 0; i < loc_num; i++)
- s = format (s, "%U ", format_locator, &locs[i]);
FINISH;
}