X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnsim%2Fnsim.c;fp=src%2Fplugins%2Fnsim%2Fnsim.c;h=5bc9eaecdd68475403047d6abd3638bb36e23197;hb=2e7a43ca453c677c00d371ea5dfdba71267ab185;hp=a8c00337364df041050b5378e1bfade30988ddb2;hpb=025166dc79a6931ea24384b2f27c6c11081d06c9;p=vpp.git diff --git a/src/plugins/nsim/nsim.c b/src/plugins/nsim/nsim.c index a8c00337364..5bc9eaecdd6 100644 --- a/src/plugins/nsim/nsim.c +++ b/src/plugins/nsim/nsim.c @@ -30,41 +30,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 nsm->msg_id_base #include nsim_main_t nsim_main; -/* List of message types that this plugin understands */ - -#define foreach_nsim_plugin_api_msg \ -_(NSIM_CROSS_CONNECT_ENABLE_DISABLE, nsim_cross_connect_enable_disable) \ -_(NSIM_OUTPUT_FEATURE_ENABLE_DISABLE, nsim_output_feature_enable_disable) \ -_(NSIM_CONFIGURE, nsim_configure) - /* Action functions shared between message handlers and debug CLI */ int @@ -503,61 +476,19 @@ VLIB_CLI_COMMAND (nsim_output_feature_enable_disable_command, static) = }; /* *INDENT-ON* */ -/* Set up the API message handling tables */ -static clib_error_t * -nsim_plugin_api_hookup (vlib_main_t * vm) -{ - nsim_main_t *nsm = &nsim_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + nsm->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_nsim_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 (nsim_main_t * nsm, api_main_t * am) -{ -#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + nsm->msg_id_base); - foreach_vl_msg_name_crc_nsim; -#undef _ -} - +#include static clib_error_t * nsim_init (vlib_main_t * vm) { nsim_main_t *nsm = &nsim_main; - clib_error_t *error = 0; - u8 *name; nsm->vlib_main = vm; nsm->vnet_main = vnet_get_main (); - name = format (0, "nsim_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - nsm->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - - error = nsim_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (nsm, &api_main); + nsm->msg_id_base = setup_message_id_table (); - vec_free (name); - - return error; + return 0; } VLIB_INIT_FUNCTION (nsim_init);