summaryrefslogtreecommitdiffstats
path: root/src/plugins/ct6/ct6.c
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-09-25 18:42:47 +0200
committerOle Troan <ot@cisco.com>2019-09-30 10:40:16 +0200
commitee98904e0c0357f75fa019ed7b9f0f4eda480377 (patch)
tree43d5624505029dd39672ae418e6027cadfd40ab7 /src/plugins/ct6/ct6.c
parent0aa35a7fad65236eb2d7845169690f1b809217c7 (diff)
ct6: remove api boilerplate
Type: refactor Change-Id: Ibf00279d8065e7ef4fc06e8b9946dcc7bfd647de Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/plugins/ct6/ct6.c')
-rw-r--r--src/plugins/ct6/ct6.c74
1 files changed, 4 insertions, 70 deletions
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 <vpp/app/version.h>
/* define message IDs */
-#include <ct6/ct6_msg_enum.h>
-
-/* define message structures */
-#define vl_typedefs
-#include <ct6/ct6_all_api_h.h>
-#undef vl_typedefs
-
-/* define generated endian-swappers */
-#define vl_endianfun
-#include <ct6/ct6_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 <ct6/ct6_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <ct6/ct6_all_api_h.h>
-#undef vl_api_version
+#include <ct6/ct6.api_enum.h>
+#include <ct6/ct6.api_types.h>
#define REPLY_MSG_ID_BASE cmp->msg_id_base
#include <vlibapi/api_helper_macros.h>
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 <ct6/ct6_all_api_h.h>
-#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 <ct6/ct6.api.c>
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...