From 9f3d21170a3c408707e07e4f3ffbee2fd27c2b03 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Wed, 25 Sep 2019 17:33:27 +0200 Subject: abf: remove api boilerplate Type: refactor Signed-off-by: Ole Troan Change-Id: I80a371baf7715de1acee90952a0dd270172d8538 Signed-off-by: Ole Troan --- src/plugins/abf/abf_api.c | 81 ++++------------------------------------------- 1 file changed, 6 insertions(+), 75 deletions(-) (limited to 'src/plugins/abf/abf_api.c') diff --git a/src/plugins/abf/abf_api.c b/src/plugins/abf/abf_api.c index a14c9008332..cc55b214e35 100644 --- a/src/plugins/abf/abf_api.c +++ b/src/plugins/abf/abf_api.c @@ -29,28 +29,9 @@ #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 +#include /** * Base message ID fot the plugin @@ -59,15 +40,6 @@ static u32 abf_base_msg_id; #include -/* List of message types that this plugin understands */ - -#define foreach_abf_plugin_api_msg \ -_(ABF_PLUGIN_GET_VERSION, abf_plugin_get_version) \ -_(ABF_POLICY_ADD_DEL, abf_policy_add_del) \ -_(ABF_POLICY_DUMP, abf_policy_dump) \ -_(ABF_ITF_ATTACH_ADD_DEL, abf_itf_attach_add_del) \ -_(ABF_ITF_ATTACH_DUMP, abf_itf_attach_dump) - static void vl_api_abf_plugin_get_version_t_handler (vl_api_abf_plugin_get_version_t * mp) { @@ -260,56 +232,15 @@ vl_api_abf_itf_attach_dump_t_handler (vl_api_abf_itf_attach_dump_t * mp) abf_itf_attach_walk (abf_itf_attach_send_details, &ctx); } -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -/* Set up the API message handling tables */ -static clib_error_t * -abf_plugin_api_hookup (vlib_main_t * vm) -{ -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + abf_base_msg_id), \ - #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_abf_plugin_api_msg; -#undef _ - - return 0; -} - -static void -setup_message_id_table (api_main_t * apim) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (apim, #n "_" #crc, id + abf_base_msg_id); - foreach_vl_msg_name_crc_abf; -#undef _ -} +#include static clib_error_t * abf_api_init (vlib_main_t * vm) { - clib_error_t *error = 0; - - u8 *name = format (0, "abf_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - abf_base_msg_id = vl_msg_api_get_msg_ids ((char *) name, - VL_MSG_FIRST_AVAILABLE); - - error = abf_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (&api_main); + abf_base_msg_id = setup_message_id_table (); - vec_free (name); - - return error; + return 0; } VLIB_INIT_FUNCTION (abf_api_init); -- cgit 1.2.3-korg