diff options
Diffstat (limited to 'src/vnet/bfd')
-rw-r--r-- | src/vnet/bfd/bfd_api.c | 71 | ||||
-rw-r--r-- | src/vnet/bfd/bfd_main.h | 2 |
2 files changed, 11 insertions, 62 deletions
diff --git a/src/vnet/bfd/bfd_api.c b/src/vnet/bfd/bfd_api.c index 4760df2ac1b..0ae8508f865 100644 --- a/src/vnet/bfd/bfd_api.c +++ b/src/vnet/bfd/bfd_api.c @@ -30,39 +30,13 @@ #include <vnet/bfd/bfd_api.h> #include <vnet/ip/ip_types_api.h> -#include <vnet/vnet_msg_enum.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 +#include <vnet/format_fns.h> +#include <vnet/bfd/bfd.api_enum.h> +#include <vnet/bfd/bfd.api_types.h> +#define REPLY_MSG_ID_BASE bfd_main.msg_id_base #include <vlibapi/api_helper_macros.h> -#define foreach_vpe_api_msg \ - _ (BFD_UDP_ADD, bfd_udp_add) \ - _ (BFD_UDP_MOD, bfd_udp_mod) \ - _ (BFD_UDP_DEL, bfd_udp_del) \ - _ (BFD_UDP_SESSION_DUMP, bfd_udp_session_dump) \ - _ (BFD_UDP_SESSION_SET_FLAGS, bfd_udp_session_set_flags) \ - _ (WANT_BFD_EVENTS, want_bfd_events) \ - _ (BFD_AUTH_SET_KEY, bfd_auth_set_key) \ - _ (BFD_AUTH_DEL_KEY, bfd_auth_del_key) \ - _ (BFD_AUTH_KEYS_DUMP, bfd_auth_keys_dump) \ - _ (BFD_UDP_AUTH_ACTIVATE, bfd_udp_auth_activate) \ - _ (BFD_UDP_AUTH_DEACTIVATE, bfd_udp_auth_deactivate) \ - _ (BFD_UDP_SET_ECHO_SOURCE, bfd_udp_set_echo_source) \ - _ (BFD_UDP_DEL_ECHO_SOURCE, bfd_udp_del_echo_source) \ - _ (BFD_UDP_GET_ECHO_SOURCE, bfd_udp_get_echo_source) pub_sub_handler (bfd_events, BFD_EVENTS); @@ -143,7 +117,7 @@ send_bfd_udp_session_details (vl_api_registration_t * reg, u32 context, vl_api_bfd_udp_session_details_t *mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_BFD_UDP_SESSION_DETAILS); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_BFD_UDP_SESSION_DETAILS); mp->context = context; mp->state = clib_host_to_net_u32 (bs->local_state); bfd_udp_session_t *bus = &bs->udp; @@ -186,7 +160,7 @@ send_bfd_udp_session_event (vl_api_registration_t *reg, u32 pid, vl_api_bfd_udp_session_event_t *mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_BFD_UDP_SESSION_EVENT); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_BFD_UDP_SESSION_EVENT); mp->pid = pid; mp->state = clib_host_to_net_u32 (bs->local_state); bfd_udp_session_t *bus = &bs->udp; @@ -310,7 +284,7 @@ vl_api_bfd_auth_keys_dump_t_handler (vl_api_bfd_auth_keys_dump_t * mp) pool_foreach (key, bfd_main.auth_keys) { rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_BFD_AUTH_KEYS_DETAILS); + rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_BFD_AUTH_KEYS_DETAILS); rmp->context = mp->context; rmp->conf_key_id = clib_host_to_net_u32 (key->conf_key_id); rmp->auth_type = key->auth_type; @@ -436,41 +410,14 @@ vl_api_bfd_udp_get_echo_source_t_handler (vl_api_bfd_udp_get_echo_source_t * /* *INDENT-ON* */ } -/* - * bfd_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_bfd; -#undef _ -} - +#include <vnet/bfd/bfd.api.c> static clib_error_t * bfd_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); + REPLY_MSG_ID_BASE = setup_message_id_table (); return 0; } diff --git a/src/vnet/bfd/bfd_main.h b/src/vnet/bfd/bfd_main.h index a7540004dcc..0bdcfb87622 100644 --- a/src/vnet/bfd/bfd_main.h +++ b/src/vnet/bfd/bfd_main.h @@ -320,6 +320,8 @@ typedef struct /** log class */ vlib_log_class_t log_class; + + u16 msg_id_base; } bfd_main_t; extern bfd_main_t bfd_main; |