X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp%2Fapi%2Fapi.c;h=b5ff3ccad7152e2d8015c33bd208de1fbfa50f43;hb=refs%2Fchanges%2F38%2F14138%2F13;hp=86865099532d017358a7b53019e0341cc56a09bc;hpb=5d64c7868f67749a6c99eb4ee5998b518ab6c71c;p=vpp.git diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c index 86865099532..b5ff3ccad71 100644 --- a/src/vpp/api/api.c +++ b/src/vpp/api/api.c @@ -59,6 +59,7 @@ #include #include +#include #define vl_typedefs /* define message structures */ #include @@ -102,9 +103,6 @@ memclnt_delete_callback (u32 client_index) vpe_api_main_t *vam = &vpe_api_main; vpe_client_registration_t *rp; uword *p; - int stats_memclnt_delete_callback (u32 client_index); - - stats_memclnt_delete_callback (client_index); #define _(a) \ p = hash_get (vam->a##_registration_hash, client_index); \ @@ -217,16 +215,26 @@ vl_api_cli_inband_t_handler (vl_api_cli_inband_t * mp) vlib_main_t *vm = vlib_get_main (); unformat_input_t input; u8 *out_vec = 0; + u32 len = 0; + + if (vl_msg_api_get_msg_length (mp) < + vl_api_string_len (&mp->cmd) + sizeof (*mp)) + { + rv = -1; + goto error; + } - unformat_init_string (&input, (char *) mp->cmd, ntohl (mp->length)); + unformat_init_string (&input, (char *) vl_api_from_api_string (&mp->cmd), + vl_api_string_len (&mp->cmd)); vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec); - u32 len = vec_len (out_vec); + len = vec_len (out_vec); + +error: /* *INDENT-OFF* */ REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len, ({ - rmp->length = htonl (len); - clib_memcpy (rmp->reply, out_vec, len); + vl_api_to_api_string(len, (const char *)out_vec, &rmp->reply); })); /* *INDENT-ON* */ vec_free (out_vec); @@ -241,16 +249,21 @@ vl_api_show_version_t_handler (vl_api_show_version_t * mp) char *vpe_api_get_version (void); char *vpe_api_get_build_date (void); + u32 program_len = strnlen_s ("vpe", 32); + u32 version_len = strnlen_s (vpe_api_get_version (), 32); + u32 build_date_len = strnlen_s (vpe_api_get_build_date (), 32); + u32 build_directory_len = strnlen_s (vpe_api_get_build_directory (), 256); + + u32 n = program_len + version_len + build_date_len + build_directory_len; + /* *INDENT-OFF* */ - REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY, + REPLY_MACRO3(VL_API_SHOW_VERSION_REPLY, n, ({ - strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1); - strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(), - ARRAY_LEN(rmp->build_directory)-1); - strncpy ((char *) rmp->version, vpe_api_get_version(), - ARRAY_LEN(rmp->version)-1); - strncpy ((char *) rmp->build_date, vpe_api_get_build_date(), - ARRAY_LEN(rmp->build_date)-1); + char *p = (char *)&rmp->program; + p += vl_api_to_api_string(program_len, "vpe", (vl_api_string_t *)p); + p += vl_api_to_api_string(version_len, vpe_api_get_version(), (vl_api_string_t *)p); + p += vl_api_to_api_string(build_date_len, vpe_api_get_build_date(), (vl_api_string_t *)p); + vl_api_to_api_string(build_directory_len, vpe_api_get_build_directory(), (vl_api_string_t *)p); })); /* *INDENT-ON* */ } @@ -292,7 +305,7 @@ vl_api_show_threads_t_handler (vl_api_show_threads_t * mp) return; rmp = vl_msg_api_alloc (msg_size); - memset (rmp, 0, msg_size); + clib_memset (rmp, 0, msg_size); rmp->_vl_msg_id = htons (VL_API_SHOW_THREADS_REPLY); rmp->context = mp->context; rmp->count = htonl (count); @@ -686,7 +699,7 @@ format_arp_event (u8 * s, va_list * args) vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *); s = format (s, "pid %d: ", ntohl (event->pid)); - s = format (s, "resolution for %U", format_ip4_address, &event->address); + s = format (s, "resolution for %U", format_vl_api_ip4_address, event->ip); return s; } @@ -696,7 +709,7 @@ format_nd_event (u8 * s, va_list * args) vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *); s = format (s, "pid %d: ", ntohl (event->pid)); - s = format (s, "resolution for %U", format_ip6_address, event->address); + s = format (s, "resolution for %U", format_vl_api_ip6_address, event->ip); return s; }