X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fflowprobe%2Fflowprobe_test.c;h=a694e45ae9b3739730ea4c96962c39ecd796b436;hb=61717cc38;hp=19b7a733795a637531a155be0f19d87152f3b4e2;hpb=59b2565cd91a67ced650739f36129650830211ac;p=vpp.git diff --git a/src/plugins/flowprobe/flowprobe_test.c b/src/plugins/flowprobe/flowprobe_test.c index 19b7a733795..a694e45ae9b 100644 --- a/src/plugins/flowprobe/flowprobe_test.c +++ b/src/plugins/flowprobe/flowprobe_test.c @@ -30,29 +30,8 @@ uword unformat_sw_if_index (unformat_input_t * input, va_list * args); /* Declare message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ - -#define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) -#define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#include typedef struct { @@ -64,35 +43,6 @@ typedef struct flowprobe_test_main_t flowprobe_test_main; -#define foreach_standard_reply_retval_handler \ -_(flowprobe_tx_interface_add_del_reply) \ -_(flowprobe_params_reply) - -#define _(n) \ - static void vl_api_##n##_t_handler \ - (vl_api_##n##_t * mp) \ - { \ - vat_main_t * vam = flowprobe_test_main.vat_main; \ - i32 retval = ntohl(mp->retval); \ - if (vam->async_mode) { \ - vam->async_errors += (retval < 0); \ - } else { \ - vam->retval = retval; \ - vam->result_ready = 1; \ - } \ - } -foreach_standard_reply_retval_handler; -#undef _ - -/* - * Table of message reply handlers, must include boilerplate handlers - * we just generated - */ -#define foreach_vpe_api_reply_msg \ -_(FLOWPROBE_TX_INTERFACE_ADD_DEL_REPLY, \ - flowprobe_tx_interface_add_del_reply) \ -_(FLOWPROBE_PARAMS_REPLY, flowprobe_params_reply) - static int api_flowprobe_tx_interface_add_del (vat_main_t * vam) { @@ -146,11 +96,11 @@ static int api_flowprobe_params (vat_main_t * vam) { unformat_input_t *i = vam->input; - u8 record_l2 = 0, record_l3 = 0, record_l4 = 0; u32 active_timer = ~0; u32 passive_timer = ~0; vl_api_flowprobe_params_t *mp; int ret; + u8 record_flags = 0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -162,11 +112,11 @@ api_flowprobe_params (vat_main_t * vam) while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { if (unformat (i, "l2")) - record_l2 = 1; + record_flags |= FLOWPROBE_RECORD_FLAG_L2; else if (unformat (i, "l3")) - record_l3 = 1; + record_flags |= FLOWPROBE_RECORD_FLAG_L3; else if (unformat (i, "l4")) - record_l4 = 1; + record_flags |= FLOWPROBE_RECORD_FLAG_L4; else break; } @@ -182,9 +132,7 @@ api_flowprobe_params (vat_main_t * vam) /* Construct the API message */ M (FLOWPROBE_PARAMS, mp); - mp->record_l2 = record_l2; - mp->record_l3 = record_l3; - mp->record_l4 = record_l4; + mp->record_flags = record_flags; mp->active_timer = ntohl (active_timer); mp->passive_timer = ntohl (passive_timer); @@ -201,57 +149,7 @@ api_flowprobe_params (vat_main_t * vam) * List of messages that the api test plugin sends, * and that the data plane plugin processes */ -#define foreach_vpe_api_msg \ -_(flowprobe_tx_interface_add_del, " [disable]") \ -_(flowprobe_params, "record <[l2] [l3] [l4]> [active passive ]") - -static void -flowprobe_vat_api_hookup (vat_main_t * vam) -{ - flowprobe_test_main_t *sm = &flowprobe_test_main; - /* Hook up handlers for replies from the data plane plug-in */ -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_vpe_api_reply_msg; -#undef _ - - /* API messages we can send */ -#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n); - foreach_vpe_api_msg; -#undef _ - - /* Help strings */ -#define _(n,h) hash_set_mem (vam->help_by_name, #n, h); - foreach_vpe_api_msg; -#undef _ -} - -clib_error_t * -vat_plugin_register (vat_main_t * vam) -{ - flowprobe_test_main_t *sm = &flowprobe_test_main; - u8 *name; - - sm->vat_main = vam; - - /* Ask the vpp engine for the first assigned message-id */ - name = format (0, "flowprobe_%08x%c", api_version, 0); - sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); - - /* Don't attempt to hook up API messages if the data plane plugin is AWOL */ - if (sm->msg_id_base != (u16) ~ 0) - flowprobe_vat_api_hookup (vam); - - vec_free (name); - - return 0; -} +#include /* * fd.io coding-style-patch-verification: ON