lisp: Move to plugin
[vpp.git] / src / plugins / lisp / lisp-gpe / lisp_gpe_api.c
similarity index 83%
rename from src/vnet/lisp-gpe/lisp_gpe_api.c
rename to src/plugins/lisp/lisp-gpe/lisp_gpe_api.c
index e20347a..df90ef5 100644 (file)
 
 #include <vnet/interface.h>
 #include <vnet/api_errno.h>
-#include <vnet/lisp-gpe/lisp_gpe.h>
-#include <vnet/lisp-gpe/lisp_gpe_adjacency.h>
-#include <vnet/lisp-gpe/lisp_gpe_tunnel.h>
-#include <vnet/lisp-gpe/lisp_gpe_fwd_entry.h>
-#include <vnet/lisp-gpe/lisp_gpe_tenant.h>
+#include <lisp/lisp-gpe/lisp_gpe.h>
+#include <lisp/lisp-gpe/lisp_gpe_adjacency.h>
+#include <lisp/lisp-gpe/lisp_gpe_tunnel.h>
+#include <lisp/lisp-gpe/lisp_gpe_fwd_entry.h>
+#include <lisp/lisp-gpe/lisp_gpe_tenant.h>
 #include <vnet/fib/fib_table.h>
-#include <vnet/vnet_msg_enum.h>
 #include <vnet/ip/ip_types_api.h>
 #include <vnet/ethernet/ethernet_types_api.h>
-#include <vnet/lisp-gpe/lisp_types_api.h>
+#include <lisp/lisp-gpe/lisp_types_api.h>
 
-#define vl_api_gpe_locator_pair_t_endian vl_noop_handler
-#define vl_api_gpe_locator_pair_t_print vl_noop_handler
-#define vl_api_gpe_add_del_fwd_entry_t_endian vl_noop_handler
-#define vl_api_gpe_add_del_fwd_entry_t_print vl_noop_handler
+/* define message IDs */
+#include <vnet/format_fns.h>
+#include <lisp/lisp-gpe/lisp_gpe.api_enum.h>
+#include <lisp/lisp-gpe/lisp_gpe.api_types.h>
 
-#define vl_typedefs            /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun           /* define message structures */
-#include <vnet/vnet_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 <vnet/vnet_all_api_h.h>
-#undef vl_printfun
+/**
+ * Base message ID fot the plugin
+ */
+static u32 gpe_base_msg_id;
+#define REPLY_MSG_ID_BASE gpe_base_msg_id
 
 #include <vlibapi/api_helper_macros.h>
 
-#define foreach_vpe_api_msg                                    \
-_(GPE_ADD_DEL_FWD_ENTRY, gpe_add_del_fwd_entry)                \
-_(GPE_FWD_ENTRIES_GET, gpe_fwd_entries_get)                    \
-_(GPE_FWD_ENTRY_PATH_DUMP, gpe_fwd_entry_path_dump)            \
-_(GPE_ENABLE_DISABLE, gpe_enable_disable)                      \
-_(GPE_ADD_DEL_IFACE, gpe_add_del_iface)                        \
-_(GPE_FWD_ENTRY_VNIS_GET, gpe_fwd_entry_vnis_get)              \
-_(GPE_SET_ENCAP_MODE, gpe_set_encap_mode)                      \
-_(GPE_GET_ENCAP_MODE, gpe_get_encap_mode)                      \
-_(GPE_ADD_DEL_NATIVE_FWD_RPATH, gpe_add_del_native_fwd_rpath)  \
-_(GPE_NATIVE_FWD_RPATHS_GET, gpe_native_fwd_rpaths_get)
-
 static locator_pair_t *
 unformat_gpe_loc_pairs (void *locs, u32 rloc_num)
 {
@@ -497,45 +476,23 @@ vl_api_gpe_native_fwd_rpaths_get_t_handler (vl_api_gpe_native_fwd_rpaths_get_t
 }
 
 /*
- * gpe_api_hookup
+ * lisp_api_hookup
  * Add vpe's API message handlers to the table.
  * vlib has already mapped shared memory and
  * added the client registration handlers.
  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
  */
-#define vl_msg_name_crc_list
-#include <vnet/vnet_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-setup_message_id_table (api_main_t * am)
-{
-#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
-  foreach_vl_msg_name_crc_lisp_gpe;
-#undef _
-}
+#include <lisp/lisp-gpe/lisp_gpe.api.c>
 
 static clib_error_t *
 gpe_api_hookup (vlib_main_t * vm)
 {
-  api_main_t *am = vlibapi_get_main ();
-
-#define _(N,n)                                                  \
-    vl_msg_api_set_handlers(VL_API_##N, #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_vpe_api_msg;
-#undef _
-
   /*
    * Set up the (msg_name, crc, message-id) table
    */
-  setup_message_id_table (am);
+  gpe_base_msg_id = setup_message_id_table ();
 
-  return 0;
+  return NULL;
 }
 
 VLIB_API_INIT_FUNCTION (gpe_api_hookup);