From 53dea2792b55bc2bc1b29a7a1b7169023acae406 Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Mon, 21 Jun 2021 10:57:49 +0000 Subject: misc: ipfix api cleanup Use autogenerated code. Does not change API definitions. Type: improvement Change-Id: I864979ce490651bf1f5fed107620e9bc4ca4bf93 Signed-off-by: Filip Tehlar --- src/vnet/ipfix-export/flow_api.c | 64 +++++-------------------------------- src/vnet/ipfix-export/flow_report.h | 2 ++ 2 files changed, 10 insertions(+), 56 deletions(-) (limited to 'src/vnet/ipfix-export') diff --git a/src/vnet/ipfix-export/flow_api.c b/src/vnet/ipfix-export/flow_api.c index f4b3fc8be3b..75a656468db 100644 --- a/src/vnet/ipfix-export/flow_api.c +++ b/src/vnet/ipfix-export/flow_api.c @@ -29,33 +29,13 @@ #include #include -#include - -#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 +#include +#include +#include +#define REPLY_MSG_ID_BASE frm->msg_id_base #include -#define foreach_vpe_api_msg \ -_(SET_IPFIX_EXPORTER, set_ipfix_exporter) \ -_(IPFIX_EXPORTER_DUMP, ipfix_exporter_dump) \ -_(SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream) \ -_(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump) \ -_(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del) \ -_(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump) \ -_(IPFIX_FLUSH, ipfix_flush) - static void vl_api_set_ipfix_exporter_t_handler (vl_api_set_ipfix_exporter_t * mp) { @@ -366,6 +346,7 @@ static void static void vl_api_ipfix_flush_t_handler (vl_api_ipfix_flush_t * mp) { + flow_report_main_t *frm = &flow_report_main; vl_api_ipfix_flush_reply_t *rmp; vl_api_registration_t *reg; vlib_main_t *vm = vlib_get_main (); @@ -382,44 +363,15 @@ vl_api_ipfix_flush_t_handler (vl_api_ipfix_flush_t * mp) REPLY_MACRO (VL_API_IPFIX_FLUSH_REPLY); } -/* - * flow_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 -#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_ipfix_export; -#undef _ -} - +#include static clib_error_t * flow_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 _ - + flow_report_main_t *frm = &flow_report_main; /* * 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/ipfix-export/flow_report.h b/src/vnet/ipfix-export/flow_report.h index 98da146427a..f40015879c4 100644 --- a/src/vnet/ipfix-export/flow_report.h +++ b/src/vnet/ipfix-export/flow_report.h @@ -134,6 +134,8 @@ typedef struct flow_report_main /* convenience variables */ vlib_main_t *vlib_main; vnet_main_t *vnet_main; + + u16 msg_id_base; } flow_report_main_t; extern flow_report_main_t flow_report_main; -- cgit 1.2.3-korg