X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fct6%2Fct6.c;h=15fa44a5d45106df19326334a4a3270ea29dcb7c;hb=ee98904e0;hp=dc2b7357d63a072fac43418fbb5f57801c7fa899;hpb=f7c1a70ba502c83d6e5813344c01edbdfbff6738;p=vpp.git diff --git a/src/plugins/ct6/ct6.c b/src/plugins/ct6/ct6.c index dc2b7357d63..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 @@ -196,6 +171,8 @@ static void vl_api_ct6_enable_disable_t_handler ct6_main_t *cmp = &ct6_main; int rv; + VALIDATE_SW_IF_INDEX (mp); + if (mp->is_inside) rv = ct6_in2out_enable_disable (cmp, ntohl (mp->sw_if_index), (int) (mp->enable_disable)); @@ -203,62 +180,22 @@ static void vl_api_ct6_enable_disable_t_handler rv = ct6_out2in_enable_disable (cmp, ntohl (mp->sw_if_index), (int) (mp->enable_disable)); + BAD_SW_IF_INDEX_LABEL; 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... @@ -301,7 +238,7 @@ VNET_FEATURE_INIT (ct6in2out, static) = VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, - .description = "ipv6 connection tracker", + .description = "IPv6 Connection Tracker", }; /* *INDENT-ON* */