X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Flisp%2Flisp-cp%2Flisp_api.c;fp=src%2Fvnet%2Flisp-cp%2Flisp_api.c;h=041069d5613d200d3f820cdbeec1ab2029666759;hb=2b202bc4b2d870d76bfe6fb1906ae62e253cec72;hp=3cb892f035c108b91e87ea27ca7cec3cf8304845;hpb=b468773aa4164bf52e0751fdf780f67248037cc0;p=vpp.git diff --git a/src/vnet/lisp-cp/lisp_api.c b/src/plugins/lisp/lisp-cp/lisp_api.c similarity index 84% rename from src/vnet/lisp-cp/lisp_api.c rename to src/plugins/lisp/lisp-cp/lisp_api.c index 3cb892f035c..041069d5613 100644 --- a/src/vnet/lisp-cp/lisp_api.c +++ b/src/plugins/lisp/lisp-cp/lisp_api.c @@ -22,74 +22,25 @@ #include #include -#include -#include +#include +#include #include #include -#include +#include -#include +/* define message IDs */ +#include +#include +#include - -#define vl_api_lisp_add_del_locator_set_t_endian vl_noop_handler -#define vl_api_lisp_add_del_locator_set_t_print vl_noop_handler -#define vl_api_lisp_add_del_remote_mapping_t_endian vl_noop_handler -#define vl_api_lisp_add_del_remote_mapping_t_print vl_noop_handler - -#define vl_api_one_add_del_locator_set_t_endian vl_noop_handler -#define vl_api_one_add_del_locator_set_t_print vl_noop_handler -#define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler -#define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler - -#define vl_typedefs /* define message structures */ -#include -#undef vl_typedefs - -#define vl_endianfun /* define message structures */ -#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 +/** + * Base message ID fot the plugin + */ +static u32 lisp_base_msg_id; +#define REPLY_MSG_ID_BASE lisp_base_msg_id #include -#define foreach_vpe_api_msg \ -_(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set) \ -_(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator) \ -_(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid) \ -_(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver) \ -_(LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server) \ -_(LISP_ENABLE_DISABLE, lisp_enable_disable) \ -_(LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable) \ -_(LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable) \ -_(LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping) \ -_(LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency) \ -_(LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set) \ -_(LISP_MAP_REQUEST_MODE, lisp_map_request_mode) \ -_(LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map) \ -_(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \ -_(LISP_LOCATOR_DUMP, lisp_locator_dump) \ -_(LISP_EID_TABLE_DUMP, lisp_eid_table_dump) \ -_(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \ -_(LISP_MAP_SERVER_DUMP, lisp_map_server_dump) \ -_(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump) \ -_(LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump) \ -_(LISP_ADJACENCIES_GET, lisp_adjacencies_get) \ -_(SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state) \ -_(SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state) \ -_(SHOW_LISP_STATUS, show_lisp_status) \ -_(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \ - lisp_add_del_map_request_itr_rlocs) \ -_(LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs) \ -_(SHOW_LISP_PITR, show_lisp_pitr) \ -_(SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode) \ -_(LISP_USE_PETR, lisp_use_petr) \ -_(SHOW_LISP_USE_PETR, show_lisp_use_petr) \ - static locator_t * unformat_lisp_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num) { @@ -532,7 +483,7 @@ send_lisp_locator_details (lisp_cp_main_t * lcm, rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_DETAILS); + rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_DETAILS + REPLY_MSG_ID_BASE); rmp->context = context; rmp->local = loc->local; @@ -604,7 +555,8 @@ send_lisp_locator_set_details (lisp_cp_main_t * lcm, rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_SET_DETAILS); + rmp->_vl_msg_id = + ntohs (VL_API_LISP_LOCATOR_SET_DETAILS + REPLY_MSG_ID_BASE); rmp->context = context; rmp->ls_index = htonl (ls_index); @@ -687,7 +639,7 @@ send_lisp_eid_table_details (mapping_t * mapit, rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS); + rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS + REPLY_MSG_ID_BASE); ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index); if (vec_len (ls->locator_indices) == 0) @@ -769,7 +721,8 @@ send_lisp_map_server_details (ip_address_t * ip, vl_api_registration_t * reg, rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_SERVER_DETAILS); + rmp->_vl_msg_id = + ntohs (VL_API_LISP_MAP_SERVER_DETAILS + REPLY_MSG_ID_BASE); ip_address_encode2 (ip, &rmp->ip_address); rmp->context = context; @@ -802,7 +755,8 @@ send_lisp_map_resolver_details (ip_address_t * ip, rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS); + rmp->_vl_msg_id = + ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS + REPLY_MSG_ID_BASE); ip_address_encode2 (ip, &rmp->ip_address); rmp->context = context; @@ -835,7 +789,8 @@ send_eid_table_map_pair (hash_pair_t * p, vl_api_registration_t * reg, rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS); + rmp->_vl_msg_id = + ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS + REPLY_MSG_ID_BASE); rmp->vni = clib_host_to_net_u32 (p->key); rmp->dp_table = clib_host_to_net_u32 (p->value[0]); @@ -880,7 +835,8 @@ send_eid_table_vni (u32 vni, vl_api_registration_t * reg, u32 context) rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_VNI_DETAILS); + rmp->_vl_msg_id = + ntohs (VL_API_LISP_EID_TABLE_VNI_DETAILS + REPLY_MSG_ID_BASE); rmp->context = context; rmp->vni = clib_host_to_net_u32 (vni); vl_api_send_msg (reg, (u8 *) rmp); @@ -1088,39 +1044,17 @@ vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp) * added the client registration handlers. * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process() */ -#define vl_msg_name_crc_list -#include -#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; -#undef _ -} +#include static clib_error_t * lisp_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); + lisp_base_msg_id = setup_message_id_table (); - return 0; + return NULL; } VLIB_API_INIT_FUNCTION (lisp_api_hookup);