diff options
author | Ole Troan <ot@cisco.com> | 2019-10-09 12:39:32 +0200 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2019-10-10 07:33:42 +0000 |
commit | 3ae9f5a90ac23ceaa1d5052cfdab417c1ef8dfdc (patch) | |
tree | 8227537e35b4a55428ab15334c83a4591514e21c /src/plugins/memif/memif_api.c | |
parent | 1890e9ce57a4b6dbc732f8f11d78001bea7c5855 (diff) |
memif: remove api boilerplate
Type: refactor
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: Icab769607c4a5890dc80b8f2661faa7e297c2a27
Diffstat (limited to 'src/plugins/memif/memif_api.c')
-rw-r--r-- | src/plugins/memif/memif_api.c | 73 |
1 files changed, 5 insertions, 68 deletions
diff --git a/src/plugins/memif/memif_api.c b/src/plugins/memif/memif_api.c index 60b9d5f75a3..00edc7ac2d7 100644 --- a/src/plugins/memif/memif_api.c +++ b/src/plugins/memif/memif_api.c @@ -30,40 +30,13 @@ #include <vnet/ethernet/ethernet_types_api.h> /* define message IDs */ -#include <memif/memif_msg_enum.h> - -/* define message structures */ -#define vl_typedefs -#include <memif/memif_all_api_h.h> -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#include <memif/memif_all_api_h.h> -#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 <memif/memif_all_api_h.h> -#undef vl_printfun - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include <memif/memif_all_api_h.h> -#undef vl_api_version +#include <vnet/format_fns.h> +#include <memif/memif.api_enum.h> +#include <memif/memif.api_types.h> #define REPLY_MSG_ID_BASE mm->msg_id_base #include <vlibapi/api_helper_macros.h> -#define foreach_memif_plugin_api_msg \ -_(MEMIF_SOCKET_FILENAME_ADD_DEL, memif_socket_filename_add_del) \ -_(MEMIF_CREATE, memif_create) \ -_(MEMIF_DELETE, memif_delete) \ -_(MEMIF_SOCKET_FILENAME_DUMP, memif_socket_filename_dump) \ -_(MEMIF_DUMP, memif_dump) \ - - /** * @brief Message handler for memif_socket_filename_add_del API. * @param mp the vl_api_memif_socket_filename_add_del_t API message @@ -375,51 +348,15 @@ void /* *INDENT-ON* */ } -#define vl_msg_name_crc_list -#include <memif/memif_all_api_h.h> -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (memif_main_t * mm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base); - foreach_vl_msg_name_crc_memif; -#undef _ -} - /* Set up the API message handling tables */ +#include <memif/memif.api.c> clib_error_t * memif_plugin_api_hookup (vlib_main_t * vm) { memif_main_t *mm = &memif_main; - api_main_t *am = &api_main; - u8 *name; - - /* Construct the API name */ - name = format (0, "memif_%08x%c", api_version, 0); /* Ask for a correctly-sized block of API message decode slots */ - mm->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + mm->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_memif_plugin_api_msg; -#undef _ - - /* - * Set up the (msg_name, crc, message-id) table - */ - setup_message_id_table (mm, am); - - vec_free (name); + mm->msg_id_base = setup_message_id_table (); return 0; } |