From 3ae1a91430a341cd9ca96023e4fb619efe7cac7e Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Thu, 13 Oct 2016 16:19:40 +0200 Subject: Add macro for sending large data structures to API clients Change-Id: I1c4ec4dd02ce5a16e33aa0908a606496ad0d64cc Signed-off-by: Florin Coras --- vpp/vpp-api/api.c | 21 ++++++++++++++++++--- 1 file 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); -- cgit 1.2.3-korg