X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=blobdiff_plain;f=src%2Fplugins%2Fct6%2Fct6.c;h=15fa44a5d45106df19326334a4a3270ea29dcb7c;hp=3dfa09f1875d2a738d110473203514e02848fedd;hb=ee98904e0;hpb=0aa35a7fad65236eb2d7845169690f1b809217c7 diff --git a/src/plugins/ct6/ct6.c b/src/plugins/ct6/ct6.c index 3dfa09f1875..15fa44a5d45 100644 --- a/src/plugins/ct6/ct6.c +++ b/src/plugins/ct6/ct6.c @@ -24,39 +24,14 @@ #include /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) -#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 #define REPLY_MSG_ID_BASE cmp->msg_id_base #include ct6_main_t ct6_main; -/* List of message types that this plugin understands */ - -#define foreach_ct6_plugin_api_msg \ -_(CT6_ENABLE_DISABLE, ct6_enable_disable) - /* Action function shared between message handler and debug CLI */ static void @@ -209,59 +184,18 @@ static void vl_api_ct6_enable_disable_t_handler REPLY_MACRO (VL_API_CT6_ENABLE_DISABLE_REPLY); } -/* Set up the API message handling tables */ -static clib_error_t * -ct6_plugin_api_hookup (vlib_main_t * vm) -{ - ct6_main_t *cmp = &ct6_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + cmp->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_ct6_plugin_api_msg; -#undef _ - - return 0; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (ct6_main_t * cmp, api_main_t * am) -{ -#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + cmp->msg_id_base); - foreach_vl_msg_name_crc_ct6; -#undef _ -} - +#include static clib_error_t * ct6_init (vlib_main_t * vm) { ct6_main_t *cmp = &ct6_main; clib_error_t *error = 0; - u8 *name; cmp->vlib_main = vm; cmp->vnet_main = vnet_get_main (); - name = format (0, "ct6_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - cmp->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - - error = ct6_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (cmp, &api_main); - - vec_free (name); + cmp->msg_id_base = setup_message_id_table (); /* * Set default parameters...