summaryrefslogtreecommitdiffstats
path: root/src/plugins/map
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-09-19 01:08:30 +0200
committerDave Barach <openvpp@barachs.net>2019-09-25 12:02:32 +0000
commit2a1ca787b9ca0021bd5da73450caedc2ff41c76d (patch)
treef9d879e07099f727ca565cfd8bc1624d3e7dc405 /src/plugins/map
parent33af8c1ed89f15cf0601ee891e9603bef16f2c93 (diff)
api: split api generated files
Split generation of API message enum and the typedefs into separate files, so that the type file can be included from elsewhere. Generate a C file for VPP that contains the API registration, this was previously done via X macros by the C pre- processor. This allows deleting lots of skeleton/copy paste code for each feature. plugins/flowprobe plugins/map examples/sample-plugin vnet/ipip used as Guinea pigs. Generate a C Test file for VAT, that does the same for VAT plugins. Also add support for a per-message CLI option, that is currently limited to VAT help text. option vat_help = "<help text>"; Type: refactor Change-Id: I245e3104bb76f7e1fb69a59ab20cc7c8dfcdd460 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/plugins/map')
-rw-r--r--src/plugins/map/CMakeLists.txt2
-rw-r--r--src/plugins/map/map_all_api_h.h24
-rw-r--r--src/plugins/map/map_api.c78
-rw-r--r--src/plugins/map/map_msg_enum.h31
4 files changed, 6 insertions, 129 deletions
diff --git a/src/plugins/map/CMakeLists.txt b/src/plugins/map/CMakeLists.txt
index bf28e5ba2c3..5ebcb55e229 100644
--- a/src/plugins/map/CMakeLists.txt
+++ b/src/plugins/map/CMakeLists.txt
@@ -25,8 +25,6 @@ add_vpp_plugin(map
map.api
INSTALL_HEADERS
- map_all_api_h.h
- map_msg_enum.h
map.h
lpm.h
)
diff --git a/src/plugins/map/map_all_api_h.h b/src/plugins/map/map_all_api_h.h
deleted file mode 100644
index c622bec170b..00000000000
--- a/src/plugins/map/map_all_api_h.h
+++ /dev/null
@@ -1,24 +0,0 @@
-
-/*
- * map_all_api_h.h - skeleton vpp engine plug-in api #include file
- *
- * Copyright (c) 2018 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 */
-
-#ifdef vl_printfun
-#include <vnet/format_fns.h>
-#endif
-
-#include <map/map.api.h>
diff --git a/src/plugins/map/map_api.c b/src/plugins/map/map_api.c
index 654e1793064..159c9d7569b 100644
--- a/src/plugins/map/map_api.c
+++ b/src/plugins/map/map_api.c
@@ -19,30 +19,12 @@
#include <vnet/ip/ip_types_api.h>
#include <map/map.h>
-#include <map/map_msg_enum.h>
+#include <map/map.api_enum.h>
+#include <map/map.api_types.h>
#include <vnet/ip/ip.h>
#include <vnet/fib/fib_table.h>
#include <vlibmemory/api.h>
-#define vl_typedefs /* define message structures */
-#include <map/map_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun /* define message structures */
-#include <map/map_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 <map/map_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <map/map_all_api_h.h>
-#undef vl_api_version
-
#define REPLY_MSG_ID_BASE mm->msg_id_base
#include <vlibapi/api_helper_macros.h>
@@ -672,65 +654,17 @@ vl_api_map_if_enable_disable_t_handler (vl_api_map_if_enable_disable_t * mp)
REPLY_MACRO (VL_API_MAP_IF_ENABLE_DISABLE_REPLY);
}
-
-#define foreach_map_plugin_api_msg \
-_(MAP_ADD_DOMAIN, map_add_domain) \
-_(MAP_DEL_DOMAIN, map_del_domain) \
-_(MAP_ADD_DEL_RULE, map_add_del_rule) \
-_(MAP_DOMAIN_DUMP, map_domain_dump) \
-_(MAP_RULE_DUMP, map_rule_dump) \
-_(MAP_IF_ENABLE_DISABLE, map_if_enable_disable) \
-_(MAP_SUMMARY_STATS, map_summary_stats) \
-_(MAP_PARAM_SET_FRAGMENTATION, map_param_set_fragmentation) \
-_(MAP_PARAM_SET_ICMP, map_param_set_icmp) \
-_(MAP_PARAM_SET_ICMP6, map_param_set_icmp6) \
-_(MAP_PARAM_ADD_DEL_PRE_RESOLVE, map_param_add_del_pre_resolve) \
-_(MAP_PARAM_SET_REASSEMBLY, map_param_set_reassembly) \
-_(MAP_PARAM_SET_SECURITY_CHECK, map_param_set_security_check) \
-_(MAP_PARAM_SET_TRAFFIC_CLASS, map_param_set_traffic_class) \
-_(MAP_PARAM_SET_TCP, map_param_set_tcp) \
-_(MAP_PARAM_GET, map_param_get)
-
-#define vl_msg_name_crc_list
-#include <map/map_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-setup_message_id_table (map_main_t * mm, api_main_t * am)
-{
-#define _(id,n,crc) \
- vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base);
- foreach_vl_msg_name_crc_map;
-#undef _
-}
+/* API definitions */
+#include <vnet/format_fns.h>
+#include <map/map.api.c>
/* Set up the API message handling tables */
clib_error_t *
map_plugin_api_hookup (vlib_main_t * vm)
{
map_main_t *mm = &map_main;
- u8 *name = format (0, "map_%08x%c", api_version, 0);
-
- /* Ask for a correctly-sized block of API message decode slots */
- mm->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 + mm->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_map_plugin_api_msg;
-#undef _
-
- /*
- * Set up the (msg_name, crc, message-id) table
- */
- setup_message_id_table (mm, &api_main);
- vec_free (name);
+ mm->msg_id_base = setup_message_id_table ();
return 0;
}
diff --git a/src/plugins/map/map_msg_enum.h b/src/plugins/map/map_msg_enum.h
deleted file mode 100644
index b135cfc7510..00000000000
--- a/src/plugins/map/map_msg_enum.h
+++ /dev/null
@@ -1,31 +0,0 @@
-
-/*
- * map_msg_enum.h - skeleton vpp engine plug-in message enumeration
- *
- * Copyright (c) 2018 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_map_msg_enum_h
-#define included_map_msg_enum_h
-
-#include <vppinfra/byte_order.h>
-
-#define vl_msg_id(n,h) n,
-typedef enum {
-#include <map/map_all_api_h.h>
- /* We'll want to know how many messages IDs we need... */
- VL_MSG_FIRST_AVAILABLE,
-} vl_msg_id_t;
-#undef vl_msg_id
-
-#endif