From ab96454e3aba8e60094e773a39e9d28f50d7192e Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Tue, 8 Oct 2019 11:35:23 +0200 Subject: ioam: remove api boilerplate Note: The VAT _test.c plugins need some more adjustments. Type: refactor Change-Id: Ifa150683d7d68db7950f66ef85eea73c8281ba14 Signed-off-by: Ole Troan --- src/plugins/ioam/CMakeLists.txt | 14 ---- .../ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c | 80 ++------------------- .../vxlan_gpe_ioam_export_all_api_h.h | 16 ----- .../vxlan_gpe_ioam_export_msg_enum.h | 28 -------- .../export-vxlan-gpe/vxlan_gpe_ioam_export_test.c | 25 ++----- src/plugins/ioam/export/ioam_export.c | 78 ++------------------ src/plugins/ioam/export/ioam_export_all_api_h.h | 16 ----- src/plugins/ioam/export/ioam_export_msg_enum.h | 28 -------- src/plugins/ioam/export/ioam_export_test.c | 27 ++----- src/plugins/ioam/ip6/ioam_cache.c | 77 ++------------------ src/plugins/ioam/ip6/ioam_cache_all_api_h.h | 16 ----- src/plugins/ioam/ip6/ioam_cache_msg_enum.h | 28 -------- src/plugins/ioam/lib-pot/pot_all_api_h.h | 16 ----- src/plugins/ioam/lib-pot/pot_api.c | 80 ++------------------- src/plugins/ioam/lib-pot/pot_msg_enum.h | 28 -------- src/plugins/ioam/lib-pot/pot_test.c | 27 ++----- src/plugins/ioam/lib-trace/trace_all_api_h.h | 16 ----- src/plugins/ioam/lib-trace/trace_api.c | 81 ++------------------- src/plugins/ioam/lib-trace/trace_msg_enum.h | 28 -------- src/plugins/ioam/lib-trace/trace_test.c | 25 ++----- .../ioam/lib-vxlan-gpe/vxlan_gpe_all_api_h.h | 16 ----- src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c | 83 ++-------------------- .../ioam/lib-vxlan-gpe/vxlan_gpe_msg_enum.h | 28 -------- src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c | 25 ++----- src/plugins/ioam/udp-ping/udp_ping_all_api_h.h | 24 ------- src/plugins/ioam/udp-ping/udp_ping_api.c | 78 ++------------------ src/plugins/ioam/udp-ping/udp_ping_msg_enum.h | 37 ---------- src/plugins/ioam/udp-ping/udp_ping_test.c | 25 ++----- 28 files changed, 76 insertions(+), 974 deletions(-) delete mode 100644 src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_all_api_h.h delete mode 100644 src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_msg_enum.h delete mode 100644 src/plugins/ioam/export/ioam_export_all_api_h.h delete mode 100644 src/plugins/ioam/export/ioam_export_msg_enum.h delete mode 100644 src/plugins/ioam/ip6/ioam_cache_all_api_h.h delete mode 100644 src/plugins/ioam/ip6/ioam_cache_msg_enum.h delete mode 100644 src/plugins/ioam/lib-pot/pot_all_api_h.h delete mode 100644 src/plugins/ioam/lib-pot/pot_msg_enum.h delete mode 100644 src/plugins/ioam/lib-trace/trace_all_api_h.h delete mode 100644 src/plugins/ioam/lib-trace/trace_msg_enum.h delete mode 100644 src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_all_api_h.h delete mode 100644 src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_msg_enum.h delete mode 100644 src/plugins/ioam/udp-ping/udp_ping_all_api_h.h delete mode 100644 src/plugins/ioam/udp-ping/udp_ping_msg_enum.h (limited to 'src') diff --git a/src/plugins/ioam/CMakeLists.txt b/src/plugins/ioam/CMakeLists.txt index 145c156619e..d2a78c7e56c 100644 --- a/src/plugins/ioam/CMakeLists.txt +++ b/src/plugins/ioam/CMakeLists.txt @@ -79,35 +79,21 @@ add_vpp_plugin(ioam udp-ping/udp_ping.api INSTALL_HEADERS - lib-pot/pot_all_api_h.h - lib-pot/pot_msg_enum.h lib-pot/pot_util.h lib-pot/math64.h - export/ioam_export_all_api_h.h - export/ioam_export_msg_enum.h - lib-trace/trace_all_api_h.h - lib-trace/trace_msg_enum.h lib-trace/trace_util.h encap/ip6_ioam_trace.h lib-trace/trace_config.h export-common/ioam_export.h - lib-vxlan-gpe/vxlan_gpe_all_api_h.h - lib-vxlan-gpe/vxlan_gpe_msg_enum.h lib-vxlan-gpe/vxlan_gpe_ioam_util.h lib-vxlan-gpe/vxlan_gpe_ioam_packet.h lib-vxlan-gpe/vxlan_gpe_ioam.h - export-vxlan-gpe/vxlan_gpe_ioam_export_all_api_h.h - export-vxlan-gpe/vxlan_gpe_ioam_export_msg_enum.h encap/ip6_ioam_e2e.h encap/ip6_ioam_seqno.h lib-e2e/ioam_seqno_lib.h - ip6/ioam_cache_all_api_h.h - ip6/ioam_cache_msg_enum.h udp-ping/udp_ping_packet.h udp-ping/udp_ping.h udp-ping/udp_ping_util.h - udp-ping/udp_ping_all_api_h.h - udp-ping/udp_ping_msg_enum.h API_TEST_SOURCES ioam_test.c diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c index 976c831fcce..cc3713c5413 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c @@ -29,36 +29,12 @@ #include /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#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 - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#include #define REPLY_MSG_ID_BASE sm->msg_id_base #include -/* List of message types that this plugin understands */ -#define foreach_vxlan_gpe_ioam_export_plugin_api_msg \ -_(VXLAN_GPE_IOAM_EXPORT_ENABLE_DISABLE, vxlan_gpe_ioam_export_enable_disable) - ioam_export_main_t vxlan_gpe_ioam_export_main; extern vlib_node_registration_t vxlan_export_node; @@ -133,41 +109,6 @@ static void vl_api_vxlan_gpe_ioam_export_enable_disable_t_handler REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_EXPORT_ENABLE_DISABLE_REPLY); } /* API message handler */ - - -/* Set up the API message handling tables */ -static clib_error_t * -vxlan_gpe_ioam_export_plugin_api_hookup (vlib_main_t * vm) -{ - ioam_export_main_t *sm = &vxlan_gpe_ioam_export_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #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_vxlan_gpe_ioam_export_plugin_api_msg; -#undef _ - - return 0; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (ioam_export_main_t * sm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); - foreach_vl_msg_name_crc_vxlan_gpe_ioam_export; -#undef _ -} - - static clib_error_t * set_vxlan_gpe_ioam_export_ipfix_command_fn (vlib_main_t * vm, unformat_input_t * input, @@ -226,36 +167,25 @@ VLIB_CLI_COMMAND (set_vxlan_gpe_ioam_ipfix_command, static) = }; /* *INDENT-ON* */ - +#include static clib_error_t * vxlan_gpe_ioam_export_init (vlib_main_t * vm) { ioam_export_main_t *em = &vxlan_gpe_ioam_export_main; - clib_error_t *error = 0; - u8 *name; em->set_id = IPFIX_VXLAN_IOAM_EXPORT_ID; - name = format (0, "vxlan_gpe_ioam_export_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - em->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); + em->msg_id_base = setup_message_id_table (); em->unix_time_0 = (u32) time (0); /* Store starting time */ em->vlib_time_0 = vlib_time_now (vm); - error = vxlan_gpe_ioam_export_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (em, &api_main); - em->my_hbh_slot = ~0; em->vlib_main = vm; em->vnet_main = vnet_get_main (); ioam_export_reset_next_node (em); - vec_free (name); - return error; + return 0; } VLIB_INIT_FUNCTION (vxlan_gpe_ioam_export_init); diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_all_api_h.h b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_all_api_h.h deleted file mode 100644 index 6d93f09341a..00000000000 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_all_api_h.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Include the generated file, see BUILT_SOURCES in Makefile.am */ -#include diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_msg_enum.h b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_msg_enum.h deleted file mode 100644 index cc5698de334..00000000000 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_msg_enum.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef included_vxlan_gpe_ioam_export_msg_enum_h -#define included_vxlan_gpe_ioam_export_msg_enum_h - -#include - -#define vl_msg_id(n,h) n, -typedef enum { -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif /* included_vxlan_gpe_ioam_export_msg_enum_h */ diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c index ff3f36783fc..a3a253fd9c1 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c @@ -27,31 +27,20 @@ #include /* Declare message IDs */ -#include +#include +#include -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ +/* instantiate all the print functions we know about */ +#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) #define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) #define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ #define vl_api_version(n,v) static u32 api_version=(v); -#include +#include +#undef vl_endianfun +#undef vl_printfun #undef vl_api_version - typedef struct { /* API message ID base */ diff --git a/src/plugins/ioam/export/ioam_export.c b/src/plugins/ioam/export/ioam_export.c index 98e5f116c8a..f4c39a03c5c 100644 --- a/src/plugins/ioam/export/ioam_export.c +++ b/src/plugins/ioam/export/ioam_export.c @@ -28,36 +28,12 @@ /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#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 - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#include #define REPLY_MSG_ID_BASE sm->msg_id_base #include -/* List of message types that this plugin understands */ -#define foreach_ioam_export_plugin_api_msg \ -_(IOAM_EXPORT_IP6_ENABLE_DISABLE, ioam_export_ip6_enable_disable) - ioam_export_main_t ioam_export_main; extern vlib_node_registration_t export_node; @@ -116,38 +92,6 @@ static void vl_api_ioam_export_ip6_enable_disable_t_handler REPLY_MACRO (VL_API_IOAM_EXPORT_IP6_ENABLE_DISABLE_REPLY); } -/* Set up the API message handling tables */ -static clib_error_t * -ioam_export_plugin_api_hookup (vlib_main_t * vm) -{ - ioam_export_main_t *sm = &ioam_export_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #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_ioam_export_plugin_api_msg; -#undef _ - - return 0; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (ioam_export_main_t * sm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); - foreach_vl_msg_name_crc_ioam_export; -#undef _ -} - static clib_error_t * set_ioam_export_ipfix_command_fn (vlib_main_t * vm, unformat_input_t * input, @@ -201,13 +145,11 @@ VLIB_CLI_COMMAND (set_ipfix_command, static) = function = set_ioam_export_ipfix_command_fn,}; /* *INDENT-ON* */ - +#include static clib_error_t * ioam_export_init (vlib_main_t * vm) { ioam_export_main_t *em = &ioam_export_main; - clib_error_t *error = 0; - u8 *name; u32 node_index = export_node.index; vlib_node_t *ip6_hbyh_node = NULL; @@ -216,25 +158,17 @@ ioam_export_init (vlib_main_t * vm) em->set_id = IPFIX_IOAM_EXPORT_ID; ioam_export_reset_next_node (em); - name = format (0, "ioam_export_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - em->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); + em->msg_id_base = setup_message_id_table (); + em->unix_time_0 = (u32) time (0); /* Store starting time */ em->vlib_time_0 = vlib_time_now (vm); - error = ioam_export_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (em, &api_main); - /* Hook this export node to ip6-hop-by-hop */ ip6_hbyh_node = vlib_get_node_by_name (vm, (u8 *) "ip6-hop-by-hop"); em->my_hbh_slot = vlib_node_add_next (vm, ip6_hbyh_node->index, node_index); - vec_free (name); - return error; + return 0; } VLIB_INIT_FUNCTION (ioam_export_init); diff --git a/src/plugins/ioam/export/ioam_export_all_api_h.h b/src/plugins/ioam/export/ioam_export_all_api_h.h deleted file mode 100644 index bc4368f2acb..00000000000 --- a/src/plugins/ioam/export/ioam_export_all_api_h.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Include the generated file, see BUILT_SOURCES in Makefile.am */ -#include diff --git a/src/plugins/ioam/export/ioam_export_msg_enum.h b/src/plugins/ioam/export/ioam_export_msg_enum.h deleted file mode 100644 index c2de798893c..00000000000 --- a/src/plugins/ioam/export/ioam_export_msg_enum.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef included_ioam_export_msg_enum_h -#define included_ioam_export_msg_enum_h - -#include - -#define vl_msg_id(n,h) n, -typedef enum { -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif /* included_ioam_export_msg_enum_h */ diff --git a/src/plugins/ioam/export/ioam_export_test.c b/src/plugins/ioam/export/ioam_export_test.c index cd98877ac22..b7d53c2b0f3 100644 --- a/src/plugins/ioam/export/ioam_export_test.c +++ b/src/plugins/ioam/export/ioam_export_test.c @@ -28,31 +28,18 @@ /* Declare message IDs */ -#include +#include +#include -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ - -#define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) +#define vl_endianfun /* define message structures */ #define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ #define vl_api_version(n,v) static u32 api_version=(v); -#include +#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) +#include +#undef vl_endianfun +#undef vl_printfun #undef vl_api_version - typedef struct { /* API message ID base */ diff --git a/src/plugins/ioam/ip6/ioam_cache.c b/src/plugins/ioam/ip6/ioam_cache.c index d315bc6c61c..74b50c9282e 100644 --- a/src/plugins/ioam/ip6/ioam_cache.c +++ b/src/plugins/ioam/ip6/ioam_cache.c @@ -29,38 +29,14 @@ #include "ioam_cache.h" /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#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 - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#include #define REPLY_MSG_ID_BASE cm->msg_id_base #include ioam_cache_main_t ioam_cache_main; -/* List of message types that this plugin understands */ -#define foreach_ioam_cache_plugin_api_msg \ -_(IOAM_CACHE_IP6_ENABLE_DISABLE, ioam_cache_ip6_enable_disable) - static u8 * ioam_e2e_id_trace_handler (u8 * s, ip6_hop_by_hop_option_t * opt) { @@ -183,38 +159,6 @@ static void vl_api_ioam_cache_ip6_enable_disable_t_handler REPLY_MACRO (VL_API_IOAM_CACHE_IP6_ENABLE_DISABLE_REPLY); } -/* Set up the API message handling tables */ -static clib_error_t * -ioam_cache_plugin_api_hookup (vlib_main_t * vm) -{ - ioam_cache_main_t *sm = &ioam_cache_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #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_ioam_cache_plugin_api_msg; -#undef _ - - return 0; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (ioam_cache_main_t * sm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); - foreach_vl_msg_name_crc_ioam_cache; -#undef _ -} - static clib_error_t * set_ioam_cache_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) @@ -368,29 +312,20 @@ VLIB_CLI_COMMAND (show_ioam_cache_command, static) = "show ioam ip6 cache [verbose]",.function = show_ioam_cache_command_fn}; /* *INDENT_ON* */ +#include static clib_error_t * ioam_cache_init (vlib_main_t * vm) { vlib_node_t *node; ioam_cache_main_t *em = &ioam_cache_main; - clib_error_t *error = 0; - u8 *name; u32 cache_node_index = ioam_cache_node.index; u32 ts_node_index = ioam_cache_ts_node.index; vlib_node_t *ip6_hbyh_node = NULL, *ip6_hbh_pop_node = NULL, *error_node = NULL; - name = format (0, "ioam_cache_%08x%c", api_version, 0); - clib_memset (&ioam_cache_main, 0, sizeof (ioam_cache_main)); /* Ask for a correctly-sized block of API message decode slots */ - em->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - - error = ioam_cache_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (em, &api_main); + em->msg_id_base = setup_message_id_table (); /* Hook this node to ip6-hop-by-hop */ ip6_hbyh_node = vlib_get_node_by_name (vm, (u8 *) "ip6-hop-by-hop"); @@ -412,9 +347,7 @@ ioam_cache_init (vlib_main_t * vm) node = vlib_get_node_by_name (vm, (u8 *) "ip6-add-syn-hop-by-hop"); em->ip6_reset_ts_hbh_node_index = node->index; - vec_free (name); - - return error; + return 0; } VLIB_INIT_FUNCTION (ioam_cache_init); diff --git a/src/plugins/ioam/ip6/ioam_cache_all_api_h.h b/src/plugins/ioam/ip6/ioam_cache_all_api_h.h deleted file mode 100644 index 61272a5187e..00000000000 --- a/src/plugins/ioam/ip6/ioam_cache_all_api_h.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Include the generated file, see BUILT_SOURCES in Makefile.am */ -#include diff --git a/src/plugins/ioam/ip6/ioam_cache_msg_enum.h b/src/plugins/ioam/ip6/ioam_cache_msg_enum.h deleted file mode 100644 index 8afd067b808..00000000000 --- a/src/plugins/ioam/ip6/ioam_cache_msg_enum.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef included_ioam_cache_msg_enum_h -#define included_ioam_cache_msg_enum_h - -#include - -#define vl_msg_id(n,h) n, -typedef enum { -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif /* included_ioam_cache_msg_enum_h */ diff --git a/src/plugins/ioam/lib-pot/pot_all_api_h.h b/src/plugins/ioam/lib-pot/pot_all_api_h.h deleted file mode 100644 index 63967c45444..00000000000 --- a/src/plugins/ioam/lib-pot/pot_all_api_h.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Include the generated file, see BUILT_SOURCES in Makefile.am */ -#include diff --git a/src/plugins/ioam/lib-pot/pot_api.c b/src/plugins/ioam/lib-pot/pot_api.c index 52ea68e083d..0d0e49de20a 100644 --- a/src/plugins/ioam/lib-pot/pot_api.c +++ b/src/plugins/ioam/lib-pot/pot_api.c @@ -27,39 +27,12 @@ #include /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#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 - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#include #define REPLY_MSG_ID_BASE sm->msg_id_base #include -/* List of message types that this plugin understands */ -#define foreach_pot_plugin_api_msg \ -_(POT_PROFILE_ADD, pot_profile_add) \ -_(POT_PROFILE_ACTIVATE, pot_profile_activate) \ -_(POT_PROFILE_DEL, pot_profile_del) \ -_(POT_PROFILE_SHOW_CONFIG_DUMP, pot_profile_show_config_dump) \ - static void vl_api_pot_profile_add_t_handler (vl_api_pot_profile_add_t *mp) { @@ -175,43 +148,10 @@ static void vl_api_pot_profile_del_t_handler REPLY_MACRO(VL_API_POT_PROFILE_DEL_REPLY); } -/* Set up the API message handling tables */ -static clib_error_t * -pot_plugin_api_hookup (vlib_main_t *vm) -{ - pot_main_t * sm = &pot_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #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_pot_plugin_api_msg; -#undef _ - - return 0; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (pot_main_t * sm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); - foreach_vl_msg_name_crc_pot; -#undef _ -} - +#include static clib_error_t * pot_init (vlib_main_t * vm) { pot_main_t * sm = &pot_main; - clib_error_t * error = 0; - u8 * name; bzero(sm, sizeof(pot_main)); (void)pot_util_init(); @@ -219,20 +159,10 @@ static clib_error_t * pot_init (vlib_main_t * vm) sm->vlib_main = vm; sm->vnet_main = vnet_get_main(); - name = format (0, "ioam_pot_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - sm->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - - error = pot_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (sm, &api_main); - - vec_free(name); + sm->msg_id_base = setup_message_id_table (); - return error; + return 0; } VLIB_INIT_FUNCTION (pot_init); diff --git a/src/plugins/ioam/lib-pot/pot_msg_enum.h b/src/plugins/ioam/lib-pot/pot_msg_enum.h deleted file mode 100644 index a4a88bed20f..00000000000 --- a/src/plugins/ioam/lib-pot/pot_msg_enum.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef included_pot_msg_enum_h -#define included_pot_msg_enum_h - -#include - -#define vl_msg_id(n,h) n, -typedef enum { -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif /* included_pot_msg_enum_h */ diff --git a/src/plugins/ioam/lib-pot/pot_test.c b/src/plugins/ioam/lib-pot/pot_test.c index d0cf49eea37..1db4286b7dc 100644 --- a/src/plugins/ioam/lib-pot/pot_test.c +++ b/src/plugins/ioam/lib-pot/pot_test.c @@ -28,31 +28,18 @@ #include /* Declare message IDs */ -#include +#include +#include -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ - -#define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) +#define vl_endianfun /* define message structures */ #define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ #define vl_api_version(n,v) static u32 api_version=(v); -#include +#define vl_print(handle, ...) +#include +#undef vl_endianfun +#undef vl_printfun #undef vl_api_version - typedef struct { /* API message ID base */ u16 msg_id_base; diff --git a/src/plugins/ioam/lib-trace/trace_all_api_h.h b/src/plugins/ioam/lib-trace/trace_all_api_h.h deleted file mode 100644 index 223f95450aa..00000000000 --- a/src/plugins/ioam/lib-trace/trace_all_api_h.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Include the generated file, see BUILT_SOURCES in Makefile.am */ -#include diff --git a/src/plugins/ioam/lib-trace/trace_api.c b/src/plugins/ioam/lib-trace/trace_api.c index f74d4e7f43b..fbabc6d7243 100644 --- a/src/plugins/ioam/lib-trace/trace_api.c +++ b/src/plugins/ioam/lib-trace/trace_api.c @@ -27,37 +27,9 @@ #include #include - /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#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 - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version - -/* List of message types that this plugin understands */ - -#define foreach_trace_plugin_api_msg \ -_(TRACE_PROFILE_ADD, trace_profile_add) \ -_(TRACE_PROFILE_DEL, trace_profile_del) \ -_(TRACE_PROFILE_SHOW_CONFIG, trace_profile_show_config) +#include +#include static void vl_api_trace_profile_add_t_handler (vl_api_trace_profile_add_t * mp) @@ -122,44 +94,11 @@ static void vl_api_trace_profile_show_config_t_handler } } -/* Set up the API message handling tables */ -static clib_error_t * -trace_plugin_api_hookup (vlib_main_t * vm) -{ - trace_main_t *sm = &trace_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #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_trace_plugin_api_msg; -#undef _ - - return 0; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (trace_main_t * sm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); - foreach_vl_msg_name_crc_trace; -#undef _ -} - +#include static clib_error_t * trace_init (vlib_main_t * vm) { trace_main_t *sm = &trace_main; - clib_error_t *error = 0; - u8 *name; bzero (sm, sizeof (trace_main)); (void) trace_util_init (); @@ -167,20 +106,10 @@ trace_init (vlib_main_t * vm) sm->vlib_main = vm; sm->vnet_main = vnet_get_main (); - name = format (0, "ioam_trace_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - sm->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - - error = trace_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (sm, &api_main); + sm->msg_id_base = setup_message_id_table (); - vec_free (name); - - return error; + return 0; } VLIB_INIT_FUNCTION (trace_init); diff --git a/src/plugins/ioam/lib-trace/trace_msg_enum.h b/src/plugins/ioam/lib-trace/trace_msg_enum.h deleted file mode 100644 index 78c35665f3c..00000000000 --- a/src/plugins/ioam/lib-trace/trace_msg_enum.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef included_trace_msg_enum_h -#define included_trace_msg_enum_h - -#include - -#define vl_msg_id(n,h) n, -typedef enum { -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif /* included_trace_msg_enum_h */ diff --git a/src/plugins/ioam/lib-trace/trace_test.c b/src/plugins/ioam/lib-trace/trace_test.c index 060c621836a..89814783455 100644 --- a/src/plugins/ioam/lib-trace/trace_test.c +++ b/src/plugins/ioam/lib-trace/trace_test.c @@ -28,31 +28,18 @@ #include /* Declare message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ +#include +#include #define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) #define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ #define vl_api_version(n,v) static u32 api_version=(v); -#include +#define vl_print(handle, ...) +#include +#undef vl_endianfun +#undef vl_printfun #undef vl_api_version - typedef struct { /* API message ID base */ diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_all_api_h.h b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_all_api_h.h deleted file mode 100644 index 06fa0d2cd34..00000000000 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_all_api_h.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Include the generated file, see BUILT_SOURCES in Makefile.am */ -#include diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c index e46d0fbf866..77484341add 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c @@ -28,39 +28,8 @@ /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#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 - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version - -/* List of message types that this plugin understands */ - -#define foreach_vxlan_gpe_plugin_api_msg \ -_(VXLAN_GPE_IOAM_ENABLE, vxlan_gpe_ioam_enable) \ -_(VXLAN_GPE_IOAM_DISABLE, vxlan_gpe_ioam_disable) \ -_(VXLAN_GPE_IOAM_VNI_ENABLE, vxlan_gpe_ioam_vni_enable) \ -_(VXLAN_GPE_IOAM_VNI_DISABLE, vxlan_gpe_ioam_vni_disable) \ -_(VXLAN_GPE_IOAM_TRANSIT_ENABLE, vxlan_gpe_ioam_transit_enable) \ -_(VXLAN_GPE_IOAM_TRANSIT_DISABLE, vxlan_gpe_ioam_transit_disable) \ - +#include +#include static void vl_api_vxlan_gpe_ioam_enable_t_handler (vl_api_vxlan_gpe_ioam_enable_t * mp) @@ -239,44 +208,11 @@ static void vl_api_vxlan_gpe_ioam_transit_disable_t_handler REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_TRANSIT_DISABLE_REPLY); } -/* Set up the API message handling tables */ -static clib_error_t * -vxlan_gpe_plugin_api_hookup (vlib_main_t * vm) -{ - vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #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_vxlan_gpe_plugin_api_msg; -#undef _ - - return 0; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (vxlan_gpe_ioam_main_t * sm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); - foreach_vl_msg_name_crc_ioam_vxlan_gpe; -#undef _ -} - +#include static clib_error_t * vxlan_gpe_init (vlib_main_t * vm) { vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; - clib_error_t *error = 0; - u8 *name; u32 encap_node_index = vxlan_gpe_encap_ioam_v4_node.index; u32 decap_node_index = vxlan_gpe_decap_ioam_v4_node.index; vlib_node_t *vxlan_gpe_encap_node = NULL; @@ -288,16 +224,8 @@ vxlan_gpe_init (vlib_main_t * vm) sm->unix_time_0 = (u32) time (0); /* Store starting time */ sm->vlib_time_0 = vlib_time_now (vm); - name = format (0, "ioam_vxlan_gpe_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - sm->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - - error = vxlan_gpe_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (sm, &api_main); + sm->msg_id_base = setup_message_id_table (); /* Hook the ioam-encap node to vxlan-gpe-encap */ vxlan_gpe_encap_node = vlib_get_node_by_name (vm, (u8 *) "vxlan-gpe-encap"); @@ -316,9 +244,8 @@ vxlan_gpe_init (vlib_main_t * vm) sm->dst_by_ip6 = hash_create_mem (0, sizeof (fib_prefix_t), sizeof (uword)); vxlan_gpe_ioam_interface_init (); - vec_free (name); - return error; + return 0; } VLIB_INIT_FUNCTION (vxlan_gpe_init); diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_msg_enum.h b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_msg_enum.h deleted file mode 100644 index cc0a10a3fec..00000000000 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_msg_enum.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef included_vxlan_gpe_msg_enum_h -#define included_vxlan_gpe_msg_enum_h - -#include - -#define vl_msg_id(n,h) n, -typedef enum { -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif /* included_vxlan_gpe_msg_enum_h */ diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c index ef24a500b9f..c7eea8b64b8 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c @@ -28,29 +28,18 @@ #include /* Declare message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ +#include +#include #define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) #define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ #define vl_api_version(n,v) static u32 api_version=(v); -#include +#define vl_print(handle, ...) +#include +#undef vl_endianfun +#undef vl_printfun #undef vl_api_version + #include #include diff --git a/src/plugins/ioam/udp-ping/udp_ping_all_api_h.h b/src/plugins/ioam/udp-ping/udp_ping_all_api_h.h deleted file mode 100644 index 1ed2e10b72d..00000000000 --- a/src/plugins/ioam/udp-ping/udp_ping_all_api_h.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Include the generated file, see BUILT_SOURCES in Makefile.am */ -#include - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/src/plugins/ioam/udp-ping/udp_ping_api.c b/src/plugins/ioam/udp-ping/udp_ping_api.c index b66c1696010..82f56aa01bf 100644 --- a/src/plugins/ioam/udp-ping/udp_ping_api.c +++ b/src/plugins/ioam/udp-ping/udp_ping_api.c @@ -28,37 +28,12 @@ /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#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 - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#include #define REPLY_MSG_ID_BASE sm->msg_id_base #include -/* List of message types that this module understands */ -#define foreach_udp_ping_api_msg \ - _(UDP_PING_ADD_DEL, udp_ping_add_del) \ - _(UDP_PING_EXPORT, udp_ping_export) \ - static void vl_api_udp_ping_add_del_t_handler (vl_api_udp_ping_add_del_t * mp) { @@ -103,59 +78,16 @@ vl_api_udp_ping_export_t_handler (vl_api_udp_ping_export_t * mp) REPLY_MACRO (VL_API_UDP_PING_EXPORT_REPLY); } -/* Set up the API message handling tables */ -static clib_error_t * -udp_ping_api_hookup (vlib_main_t * vm) -{ - udp_ping_main_t *sm = &udp_ping_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #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_udp_ping_api_msg; -#undef _ - - return 0; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (udp_ping_main_t * sm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); - foreach_vl_msg_name_crc_udp_ping; -#undef _ -} - +#include static clib_error_t * udp_ping_api_init (vlib_main_t * vm) { udp_ping_main_t *sm = &udp_ping_main; - clib_error_t *error = 0; - u8 *name; - - name = format (0, "udp_ping_%08x%c", api_version, 0); /* Ask for a correctly-sized block of API message decode slots */ - sm->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - - error = udp_ping_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (sm, &api_main); + sm->msg_id_base = setup_message_id_table (); - vec_free (name); - - return error; + return 0; } VLIB_INIT_FUNCTION (udp_ping_api_init); diff --git a/src/plugins/ioam/udp-ping/udp_ping_msg_enum.h b/src/plugins/ioam/udp-ping/udp_ping_msg_enum.h deleted file mode 100644 index dded18842d2..00000000000 --- a/src/plugins/ioam/udp-ping/udp_ping_msg_enum.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef included_udp_ping_msg_enum_h -#define included_udp_ping_msg_enum_h - -#include - -#define vl_msg_id(n,h) n, -typedef enum -{ -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif /* included_udp_ping_msg_enum_h */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/src/plugins/ioam/udp-ping/udp_ping_test.c b/src/plugins/ioam/udp-ping/udp_ping_test.c index 9c795969d51..d435b224476 100644 --- a/src/plugins/ioam/udp-ping/udp_ping_test.c +++ b/src/plugins/ioam/udp-ping/udp_ping_test.c @@ -26,31 +26,18 @@ #include /* Declare message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ +#include +#include #define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) #define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ +#define vl_print(handle, ...) #define vl_api_version(n,v) static u32 api_version=(v); -#include +#include +#undef vl_endianfun +#undef vl_printfun #undef vl_api_version - typedef struct { /* API message ID base */ -- cgit 1.2.3-korg