igmp: remove api boilerplate 36/22336/2
authorOle Troan <ot@cisco.com>
Fri, 27 Sep 2019 07:59:53 +0000 (09:59 +0200)
committerNeale Ranns <nranns@cisco.com>
Fri, 27 Sep 2019 09:06:05 +0000 (09:06 +0000)
Type: refactor
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I578b09ec223c8e4a04b7590b55354b1104ac6628

src/plugins/igmp/CMakeLists.txt
src/plugins/igmp/igmp_all_api_h.h [deleted file]
src/plugins/igmp/igmp_api.c
src/plugins/igmp/igmp_msg_enum.h [deleted file]

index 725f518..8e1371f 100644 (file)
@@ -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 (file)
index 9b55256..0000000
+++ /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 <vnet/format_fns.h>
-#endif
-
-#include <igmp/igmp.api.h>
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
index 548d828..a298ff1 100644 (file)
 #include <igmp/igmp_ssm_range.h>
 
 /* define message IDs */
-#include <igmp/igmp_msg_enum.h>
-
-/* define message structures */
-#define vl_typedefs
-#include <igmp/igmp_all_api_h.h>
-#undef vl_typedefs
-
-/* define generated endian-swappers */
-#define vl_endianfun
-#include <igmp/igmp_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 <igmp/igmp_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <igmp/igmp_all_api_h.h>
-#undef vl_api_version
+#include <igmp/igmp.api_enum.h>
+#include <igmp/igmp.api_types.h>
+#include <vnet/format_fns.h>
 
 #include <vlibapi/api_helper_macros.h>
 
 #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 <igmp/igmp_all_api_h.h>
-#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 <igmp/igmp.api.c>
 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 (file)
index 9848ceb..0000000
+++ /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 <vppinfra/byte_order.h>
-
-#define vl_msg_id(n,h) n,
-typedef enum
-{
-#include <igmp/igmp_all_api_h.h>
-  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:
- */