summaryrefslogtreecommitdiffstats
path: root/src/plugins/nsim/nsim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/nsim/nsim.c')
-rw-r--r--src/plugins/nsim/nsim.c79
1 files changed, 5 insertions, 74 deletions
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 <vpp/app/version.h>
/* define message IDs */
-#include <nsim/nsim_msg_enum.h>
-
-/* define message structures */
-#define vl_typedefs
-#include <nsim/nsim_all_api_h.h>
-#undef vl_typedefs
-
-/* define generated endian-swappers */
-#define vl_endianfun
-#include <nsim/nsim_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 <nsim/nsim_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <nsim/nsim_all_api_h.h>
-#undef vl_api_version
+#include <nsim/nsim.api_enum.h>
+#include <nsim/nsim.api_types.h>
#define REPLY_MSG_ID_BASE nsm->msg_id_base
#include <vlibapi/api_helper_macros.h>
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 <nsim/nsim_all_api_h.h>
-#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 <nsim/nsim.api.c>
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);