diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2021-06-22 14:10:41 +0000 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2021-06-22 19:54:55 +0000 |
commit | ce74c6f016dafd234431bbf561632b107fc11d06 (patch) | |
tree | b4be4c329eec2d0e408301e1e0f05c2c198267f6 | |
parent | 6fc9cb2ed5f993901ce134bf8f1ff1c5d64a163c (diff) |
misc: punt: api cleanup
Use autogenerated code.
Does not change API definitions.
Type: improvement
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Change-Id: I13dae61ddb7150c7fe9a7fd0eae73055ff3f2816
-rw-r--r-- | src/vat/api_format.c | 44 | ||||
-rw-r--r-- | src/vnet/ip/punt.h | 1 | ||||
-rw-r--r-- | src/vnet/ip/punt_api.c | 56 | ||||
-rw-r--r-- | src/vnet/vnet_all_api_h.h | 1 |
4 files changed, 9 insertions, 93 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c index f5c8291dd66..c296a5b58a0 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -1981,7 +1981,6 @@ _(ip_source_and_port_range_check_add_del_reply) \ _(ip_source_and_port_range_check_interface_add_del_reply)\ _(delete_subif_reply) \ _(l2_interface_pbb_tag_rewrite_reply) \ -_(set_punt_reply) \ _(sw_interface_tag_add_del_reply) \ _(sw_interface_add_del_mac_address_reply) \ _(hw_interface_set_mtu_reply) \ @@ -2116,7 +2115,6 @@ _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \ ip_source_and_port_range_check_interface_add_del_reply) \ _(DELETE_SUBIF_REPLY, delete_subif_reply) \ _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \ -_(SET_PUNT_REPLY, set_punt_reply) \ _(IP_TABLE_DETAILS, ip_table_details) \ _(IP_ROUTE_DETAILS, ip_route_details) \ _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \ @@ -8333,47 +8331,6 @@ api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam) } static int -api_set_punt (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_address_family_t af; - vl_api_set_punt_t *mp; - u32 protocol = ~0; - u32 port = ~0; - int is_add = 1; - int ret; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U", unformat_vl_api_address_family, &af)) - ; - else if (unformat (i, "protocol %d", &protocol)) - ; - else if (unformat (i, "port %d", &port)) - ; - else if (unformat (i, "del")) - is_add = 0; - else - { - clib_warning ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - M (SET_PUNT, mp); - - mp->is_add = (u8) is_add; - mp->punt.type = PUNT_API_TYPE_L4; - mp->punt.punt.l4.af = af; - mp->punt.punt.l4.protocol = (u8) protocol; - mp->punt.punt.l4.port = htons ((u16) port); - - S (mp); - W (ret); - return ret; -} - -static int api_delete_subif (vat_main_t * vam) { unformat_input_t *i = vam->input; @@ -9806,7 +9763,6 @@ _(l2_interface_pbb_tag_rewrite, \ "<intfc> | sw_if_index <nn> \n" \ "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \ "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \ -_(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \ _(ip_table_dump, "") \ _(ip_route_dump, "table-id [ip4|ip6]") \ _(ip_mtable_dump, "") \ diff --git a/src/vnet/ip/punt.h b/src/vnet/ip/punt.h index 858ea531ef7..a2612d60f07 100644 --- a/src/vnet/ip/punt.h +++ b/src/vnet/ip/punt.h @@ -161,6 +161,7 @@ typedef struct u32 *rx_buffers; punt_thread_data_t *thread_data; vlib_punt_hdl_t hdl; + u16 msg_id_base; } punt_main_t; extern punt_main_t punt_main; diff --git a/src/vnet/ip/punt_api.c b/src/vnet/ip/punt_api.c index 3a964b4b7f5..bcbf939f69d 100644 --- a/src/vnet/ip/punt_api.c +++ b/src/vnet/ip/punt_api.c @@ -22,31 +22,13 @@ #include <vnet/ip/punt.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/ip/punt.api_enum.h> +#include <vnet/ip/punt.api_types.h> +#define REPLY_MSG_ID_BASE punt_main.msg_id_base #include <vlibapi/api_helper_macros.h> -#define foreach_punt_api_msg \ -_(SET_PUNT, set_punt) \ -_(PUNT_SOCKET_REGISTER, punt_socket_register) \ -_(PUNT_SOCKET_DEREGISTER, punt_socket_deregister) \ -_(PUNT_SOCKET_DUMP, punt_socket_dump) \ -_(PUNT_REASON_DUMP, punt_reason_dump) - static int vl_api_punt_type_decode (vl_api_punt_type_t in, punt_type_t * out) { @@ -267,7 +249,7 @@ vl_api_punt_socket_send_details (const punt_client_t * pc, void *args) return (WALK_STOP); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_PUNT_SOCKET_DETAILS); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_PUNT_SOCKET_DETAILS); mp->context = ctx->context; vl_api_punt_encode (&pc->reg, &mp->punt); memcpy (mp->pathname, pc->caddr.sun_path, sizeof (pc->caddr.sun_path)); @@ -349,7 +331,7 @@ punt_reason_dump_walk_cb (vlib_punt_reason_t id, const u8 * name, void *args) return (0); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_PUNT_REASON_DETAILS); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_PUNT_REASON_DETAILS); mp->context = ctx->context; mp->reason.id = clib_host_to_net_u32 (id); @@ -380,37 +362,15 @@ vl_api_punt_reason_dump_t_handler (vl_api_punt_reason_dump_t * mp) vec_free (ctx.name); } -#define vl_msg_name_crc_list -#include <vnet/ip/punt.api.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_punt; -#undef _ -} +#include <vnet/ip/punt.api.c> static clib_error_t * punt_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_punt_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/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h index 7868882fa6b..0e1cdd6fa28 100644 --- a/src/vnet/vnet_all_api_h.h +++ b/src/vnet/vnet_all_api_h.h @@ -42,7 +42,6 @@ #include <vnet/mpls/mpls.api.h> #include <vnet/srmpls/sr_mpls.api.h> #include <vnet/tcp/tcp.api.h> -#include <vnet/ip/punt.api.h> #include <vnet/syslog/syslog.api.h> #include <vnet/devices/virtio/virtio.api.h> |