From 7eef62b6736a96ab0e4ffe0363c0fb5ba55841b8 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Fri, 27 Sep 2019 09:59:53 +0200 Subject: igmp: remove api boilerplate Type: refactor Signed-off-by: Ole Troan Change-Id: I578b09ec223c8e4a04b7590b55354b1104ac6628 --- src/plugins/igmp/CMakeLists.txt | 4 -- src/plugins/igmp/igmp_all_api_h.h | 30 --------------- src/plugins/igmp/igmp_api.c | 78 +++------------------------------------ src/plugins/igmp/igmp_msg_enum.h | 39 -------------------- 4 files changed, 6 insertions(+), 145 deletions(-) delete mode 100644 src/plugins/igmp/igmp_all_api_h.h delete mode 100644 src/plugins/igmp/igmp_msg_enum.h (limited to 'src/plugins/igmp') diff --git a/src/plugins/igmp/CMakeLists.txt b/src/plugins/igmp/CMakeLists.txt index 725f5185569..8e1371f4bdf 100644 --- a/src/plugins/igmp/CMakeLists.txt +++ b/src/plugins/igmp/CMakeLists.txt @@ -30,8 +30,4 @@ add_vpp_plugin(igmp API_FILES igmp.api - - INSTALL_HEADERS - igmp_all_api_h.h - igmp_msg_enum.h ) diff --git a/src/plugins/igmp/igmp_all_api_h.h b/src/plugins/igmp/igmp_all_api_h.h deleted file mode 100644 index 9b552566a27..00000000000 --- a/src/plugins/igmp/igmp_all_api_h.h +++ /dev/null @@ -1,30 +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. - *------------------------------------------------------------------ - */ - -#ifdef vl_printfun -#include -#endif - -#include - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/src/plugins/igmp/igmp_api.c b/src/plugins/igmp/igmp_api.c index 548d828267f..a298ff1a8cc 100644 --- a/src/plugins/igmp/igmp_api.c +++ b/src/plugins/igmp/igmp_api.c @@ -23,45 +23,14 @@ #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 +#include #include #define IGMP_MSG_ID(_id) (_id + igmp_main.msg_id_base) -#define foreach_igmp_plugin_api_msg \ -_(IGMP_LISTEN, igmp_listen) \ -_(IGMP_ENABLE_DISABLE, igmp_enable_disable) \ -_(IGMP_PROXY_DEVICE_ADD_DEL, igmp_proxy_device_add_del) \ -_(IGMP_PROXY_DEVICE_ADD_DEL_INTERFACE, igmp_proxy_device_add_del_interface) \ -_(IGMP_DUMP, igmp_dump) \ -_(IGMP_CLEAR_INTERFACE, igmp_clear_interface) \ -_(IGMP_CLEAR_INTERFACE, igmp_clear_interface) \ -_(IGMP_GROUP_PREFIX_SET, igmp_group_prefix_set) \ -_(IGMP_GROUP_PREFIX_DUMP, igmp_group_prefix_dump) \ -_(WANT_IGMP_EVENTS, want_igmp_events) - static void vl_api_igmp_listen_t_handler (vl_api_igmp_listen_t * mp) { @@ -443,51 +412,16 @@ igmp_event (igmp_filter_mode_t filter, /* *INDENT-ON* */ } -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (igmp_main_t * im, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + im->msg_id_base); - foreach_vl_msg_name_crc_igmp; -#undef _ -} - /* Set up the API message handling tables */ +#include static clib_error_t * igmp_plugin_api_hookup (vlib_main_t * vm) { igmp_main_t *im = &igmp_main; - api_main_t *am = &api_main; - u8 *name; - - /* Construct the API name */ - name = format (0, "igmp_%08x%c", api_version, 0); /* Ask for a correctly-sized block of API message decode slots */ - im->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + im->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_igmp_plugin_api_msg; -#undef _ - - /* - * Set up the (msg_name, crc, message-id) table - */ - setup_message_id_table (im, am); - - vec_free (name); + im->msg_id_base = setup_message_id_table (); + return 0; } diff --git a/src/plugins/igmp/igmp_msg_enum.h b/src/plugins/igmp/igmp_msg_enum.h deleted file mode 100644 index 9848ceba86c..00000000000 --- a/src/plugins/igmp/igmp_msg_enum.h +++ /dev/null @@ -1,39 +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 _IGMP_MSG_ENUM_H_ -#define _IGMP_MSG_ENUM_H_ - -#include - -#define vl_msg_id(n,h) n, -typedef enum -{ -#include - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif /* IGMP_MSG_ENUM_H_ */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ -- cgit 1.2.3-korg