diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2021-06-22 22:01:19 +0000 |
---|---|---|
committer | Filip Tehlar <ftehlar@cisco.com> | 2021-06-23 13:41:21 +0000 |
commit | da5088c9306cafbe71e90f7ebd8a411488afb121 (patch) | |
tree | c182c20fbe71c2928cbf76d42393d819da7a2fa6 /src/vnet/mpls | |
parent | 6f6663f3ba814e5f721f7cc679e3098812ad93c3 (diff) |
mpls: api cleanup
Use autogenerated code.
Does not change API definitions.
Type: improvement
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Change-Id: I148022278a792b3687402b6915fe6fb513858a2a
Diffstat (limited to 'src/vnet/mpls')
-rw-r--r-- | src/vnet/mpls/mpls.h | 1 | ||||
-rw-r--r-- | src/vnet/mpls/mpls_api.c | 67 |
2 files changed, 10 insertions, 58 deletions
diff --git a/src/vnet/mpls/mpls.h b/src/vnet/mpls/mpls.h index 2cd41ea01c6..00b493f4576 100644 --- a/src/vnet/mpls/mpls.h +++ b/src/vnet/mpls/mpls.h @@ -60,6 +60,7 @@ typedef struct u8 *mpls_enabled_by_sw_if_index; u32 mpls_lookup_node_index; + u16 msg_id_base; } mpls_main_t; extern mpls_main_t mpls_main; diff --git a/src/vnet/mpls/mpls_api.c b/src/vnet/mpls/mpls_api.c index 97928a744d8..e89732f0d10 100644 --- a/src/vnet/mpls/mpls_api.c +++ b/src/vnet/mpls/mpls_api.c @@ -30,34 +30,13 @@ #include <vnet/fib/fib_path_list.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/mpls/mpls.api_enum.h> +#include <vnet/mpls/mpls.api_types.h> +#define REPLY_MSG_ID_BASE mpls_main.msg_id_base #include <vlibapi/api_helper_macros.h> -#define foreach_vpe_api_msg \ -_(MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind) \ -_(MPLS_ROUTE_ADD_DEL, mpls_route_add_del) \ -_(MPLS_TABLE_ADD_DEL, mpls_table_add_del) \ -_(MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del) \ -_(MPLS_TUNNEL_DUMP, mpls_tunnel_dump) \ -_(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \ -_(MPLS_TABLE_DUMP, mpls_table_dump) \ -_(MPLS_ROUTE_DUMP, mpls_route_dump) - void mpls_table_delete (u32 table_id, u8 is_api) { @@ -356,7 +335,7 @@ send_mpls_tunnel_entry (u32 mti, void *arg) mp = vl_msg_api_alloc (sizeof (*mp) + n * sizeof (vl_api_fib_path_t)); clib_memset (mp, 0, sizeof (*mp) + n * sizeof (vl_api_fib_path_t)); - mp->_vl_msg_id = ntohs (VL_API_MPLS_TUNNEL_DETAILS); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_MPLS_TUNNEL_DETAILS); mp->context = ctx->context; mp->mt_tunnel.mt_n_paths = n; @@ -407,7 +386,7 @@ send_mpls_table_details (vpe_api_main_t * am, mp = vl_msg_api_alloc (sizeof (*mp)); memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_MPLS_TABLE_DETAILS); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_MPLS_TABLE_DETAILS); mp->context = context; mp->mt_table.mt_table_id = htonl (table->ft_table_id); @@ -457,7 +436,7 @@ send_mpls_route_details (vpe_api_main_t * am, if (!mp) return; clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_MPLS_ROUTE_DETAILS); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_MPLS_ROUTE_DETAILS); mp->context = context; mp->mr_route.mr_table_id = @@ -528,40 +507,12 @@ vl_api_mpls_route_dump_t_handler (vl_api_mpls_route_dump_t * mp) } } -/* - * mpls_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_mpls; -#undef _ -} - +#include <vnet/mpls/mpls.api.c> static clib_error_t * mpls_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 _ - /* * Trace space for 8 MPLS encap labels */ @@ -570,7 +521,7 @@ mpls_api_hookup (vlib_main_t * vm) /* * Set up the (msg_name, crc, message-id) table */ - setup_message_id_table (am); + REPLY_MSG_ID_BASE = setup_message_id_table (); return 0; } |