X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlibmemory%2Fmemclnt_api.c;h=299e8d93f0282ddbd6f8ae4ab8e86f4d65c2ade4;hb=ac0babd412e3b5282136a5c5c5be2c4cc4be6895;hp=728edf7804ab7927b61b92ac2d67598dd35ad418;hpb=5b32d3a13bc66b884bbf25f1409174ed34a8adc7;p=vpp.git diff --git a/src/vlibmemory/memclnt_api.c b/src/vlibmemory/memclnt_api.c index 728edf7804a..299e8d93f02 100644 --- a/src/vlibmemory/memclnt_api.c +++ b/src/vlibmemory/memclnt_api.c @@ -145,10 +145,44 @@ vl_api_control_ping_t_handler (vl_api_control_ping_t *mp) ({ rmp->vpe_pid = ntohl (getpid ()); })); } +static void +vl_api_get_api_json_t_handler (vl_api_get_api_json_t *mp) +{ + vl_api_get_api_json_reply_t *rmp; + api_main_t *am = vlibapi_get_main (); + int rv = 0, n = 0; + u8 *s = 0; + + vl_api_registration_t *rp = + vl_api_client_index_to_registration (mp->client_index); + if (rp == 0) + return; + + s = format (s, "[\n"); + u8 **ptr; + vec_foreach (ptr, am->json_api_repr) + { + s = format (s, "%s,", ptr[0]); + } + s[vec_len (s) - 1] = ']'; // Replace last comma with a bracket + vec_terminate_c_string (s); + n = vec_len (s); + +done: + REPLY_MACRO3 (VL_API_GET_API_JSON_REPLY, n, ({ + if (rv == 0) + { + vl_api_c_string_to_api_string ((char *) s, &rmp->json); + } + })); + vec_free (s); +} + #define foreach_vlib_api_msg \ _ (GET_FIRST_MSG_ID, get_first_msg_id) \ _ (API_VERSIONS, api_versions) \ - _ (CONTROL_PING, control_ping) + _ (CONTROL_PING, control_ping) \ + _ (GET_API_JSON, get_api_json) /* * vl_api_init @@ -190,6 +224,9 @@ vlib_api_init (void) foreach_vlib_api_msg; #undef _ + /* Mark messages as mp safe */ + vl_api_set_msg_thread_safe (am, VL_API_GET_FIRST_MSG_ID, 1); + vl_api_set_msg_thread_safe (am, VL_API_API_VERSIONS, 1); vl_api_set_msg_thread_safe (am, VL_API_CONTROL_PING, 1); vl_api_set_msg_thread_safe (am, VL_API_CONTROL_PING_REPLY, 1);