summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2016-10-13 16:19:40 +0200
committerFlorin Coras <fcoras@cisco.com>2016-10-14 00:33:59 +0200
commit3ae1a91430a341cd9ca96023e4fb619efe7cac7e (patch)
tree7646d72f1efd6ddb84b7193b5b7cdb81736575e2
parent77378332ac585f0558a640b148bac0308675a459 (diff)
Add macro for sending large data structures to API clients
Change-Id: I1c4ec4dd02ce5a16e33aa0908a606496ad0d64cc Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--vpp/vpp-api/api.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 3840b820aa9..ca56ab24480 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -170,13 +170,29 @@ do { \
#define REPLY_MACRO3(t, n, body) \
do { \
unix_shared_memory_queue_t * q; \
- u8 is_error = 0; \
rv = vl_msg_api_pd_handler (mp, rv); \
q = vl_api_client_index_to_input_queue (mp->client_index); \
if (!q) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp) + n); \
+ rmp->_vl_msg_id = ntohs((t)); \
+ rmp->context = mp->context; \
+ rmp->retval = ntohl(rv); \
+ do {body;} while (0); \
+ vl_msg_api_send_shmem (q, (u8 *)&rmp); \
+} while(0);
+
+#define REPLY_MACRO4(t, n, body) \
+do { \
+ unix_shared_memory_queue_t * q; \
+ u8 is_error = 0; \
+ rv = vl_msg_api_pd_handler (mp, rv); \
+ q = vl_api_client_index_to_input_queue (mp->client_index); \
+ if (!q) \
+ return; \
+ \
+ rmp = vl_msg_api_alloc_or_null (sizeof (*rmp) + n); \
if (!rmp) \
{ \
/* if there isn't enough memory, try to allocate */ \
@@ -189,7 +205,6 @@ do { \
rv = VNET_API_ERROR_TABLE_TOO_BIG; \
is_error = 1; \
} \
- \
rmp->_vl_msg_id = ntohs((t)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
@@ -6093,7 +6108,7 @@ vl_api_lisp_adjacencies_get_t_handler (vl_api_lisp_adjacencies_get_t * mp)
size = vec_len (adjs) * sizeof (a);
/* *INDENT-OFF* */
- REPLY_MACRO3 (VL_API_LISP_ADJACENCIES_GET_REPLY, size,
+ REPLY_MACRO4 (VL_API_LISP_ADJACENCIES_GET_REPLY, size,
{
rmp->count = clib_host_to_net_u32 (vec_len (adjs));
lisp_adjacency_copy (rmp->adjacencies, adjs);