summaryrefslogtreecommitdiffstats
path: root/src/plugins/mactime
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/mactime')
-rw-r--r--src/plugins/mactime/CMakeLists.txt4
-rw-r--r--src/plugins/mactime/mactime.api2
-rw-r--r--src/plugins/mactime/mactime.c76
-rw-r--r--src/plugins/mactime/mactime_all_api_h.h19
-rw-r--r--src/plugins/mactime/mactime_msg_enum.h31
-rw-r--r--src/plugins/mactime/mactime_test.c92
6 files changed, 10 insertions, 214 deletions
diff --git a/src/plugins/mactime/CMakeLists.txt b/src/plugins/mactime/CMakeLists.txt
index 9f5d431480a..ac5077d1860 100644
--- a/src/plugins/mactime/CMakeLists.txt
+++ b/src/plugins/mactime/CMakeLists.txt
@@ -19,10 +19,6 @@ add_vpp_plugin(mactime
API_FILES
mactime.api
- INSTALL_HEADERS
- mactime_all_api_h.h
- mactime_msg_enum.h
-
API_TEST_SOURCES
mactime_test.c
)
diff --git a/src/plugins/mactime/mactime.api b/src/plugins/mactime/mactime.api
index 5d5731bc75b..edad2c48362 100644
--- a/src/plugins/mactime/mactime.api
+++ b/src/plugins/mactime/mactime.api
@@ -28,6 +28,7 @@ autoreply define mactime_enable_disable
u32 context; /**< application context */
u8 enable_disable; /**< enable=1, disable=0 */
u32 sw_if_index; /**< the interface handle */
+ option vat_help = "<intfc> [disable]";
};
/** \brief a time range structure
@@ -82,6 +83,7 @@ autoreply define mactime_add_del_range
u32 count; /**< number of time ranges to follow */
/** time ranges, in seconds since Sunday began */
vl_api_time_range_t ranges[count];
+ option vat_help = "name <devname> mac <mac-addr> allow drop allow-range Mon - Fri 9:00 - 17:00";
};
/*
diff --git a/src/plugins/mactime/mactime.c b/src/plugins/mactime/mactime.c
index 57895404390..e346171bd42 100644
--- a/src/plugins/mactime/mactime.c
+++ b/src/plugins/mactime/mactime.c
@@ -24,28 +24,10 @@
#include <vpp/app/version.h>
/* define message IDs */
-#include <mactime/mactime_msg_enum.h>
+#include <mactime/mactime.api_enum.h>
+#include <mactime/mactime.api_types.h>
-/* define message structures */
-#define vl_typedefs
-#include <mactime/mactime_all_api_h.h>
-#undef vl_typedefs
-
-/* define generated endian-swappers */
-#define vl_endianfun
-#include <mactime/mactime_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 <mactime/mactime_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <mactime/mactime_all_api_h.h>
-#undef vl_api_version
#define REPLY_MSG_ID_BASE mm->msg_id_base
#include <vlibapi/api_helper_macros.h>
@@ -55,12 +37,6 @@ mactime_main_t mactime_main;
/** \file time-base src-mac filter device-input feature arc implementation
*/
-/* List of message types that this plugin understands */
-
-#define foreach_mactime_plugin_api_msg \
-_(MACTIME_ENABLE_DISABLE, mactime_enable_disable) \
-_(MACTIME_ADD_DEL_RANGE, mactime_add_del_range)
-
static void
feature_init (mactime_main_t * mm)
{
@@ -343,64 +319,22 @@ reply:
REPLY_MACRO (VL_API_MACTIME_ADD_DEL_RANGE_REPLY);
}
-/* Set up the API message handling tables */
-static clib_error_t *
-mactime_plugin_api_hookup (vlib_main_t * vm)
-{
- mactime_main_t *mm = &mactime_main;
-#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_mactime_plugin_api_msg;
-#undef _
-
- return 0;
-}
-
-#define vl_msg_name_crc_list
-#include <mactime/mactime_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-setup_message_id_table (mactime_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_mactime;
-#undef _
-}
-
+#include <mactime/mactime.api.c>
static clib_error_t *
mactime_init (vlib_main_t * vm)
{
mactime_main_t *mm = &mactime_main;
- clib_error_t *error = 0;
- u8 *name;
mm->vlib_main = vm;
mm->vnet_main = vnet_get_main ();
- name = format (0, "mactime_%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);
-
- error = mactime_plugin_api_hookup (vm);
-
- /* Add our API messages to the global name_crc hash table */
- setup_message_id_table (mm, &api_main);
-
- vec_free (name);
+ mm->msg_id_base = setup_message_id_table ();
mm->lookup_table_num_buckets = MACTIME_NUM_BUCKETS;
mm->lookup_table_memory_size = MACTIME_MEMORY_SIZE;
mm->timezone_offset = -5; /* US EST / EDT */
- return error;
+ return 0;
}
VLIB_INIT_FUNCTION (mactime_init);
diff --git a/src/plugins/mactime/mactime_all_api_h.h b/src/plugins/mactime/mactime_all_api_h.h
deleted file mode 100644
index f3bd6731ecb..00000000000
--- a/src/plugins/mactime/mactime_all_api_h.h
+++ /dev/null
@@ -1,19 +0,0 @@
-
-/*
- * mactime_all_api_h.h - skeleton vpp engine plug-in api #include file
- *
- * Copyright (c) <current-year> <your-organization>
- * 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 <mactime/mactime.api.h>
diff --git a/src/plugins/mactime/mactime_msg_enum.h b/src/plugins/mactime/mactime_msg_enum.h
deleted file mode 100644
index 2a2bc81139a..00000000000
--- a/src/plugins/mactime/mactime_msg_enum.h
+++ /dev/null
@@ -1,31 +0,0 @@
-
-/*
- * mactime_msg_enum.h - skeleton vpp engine plug-in message enumeration
- *
- * Copyright (c) <current-year> <your-organization>
- * 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_mactime_msg_enum_h
-#define included_mactime_msg_enum_h
-
-#include <vppinfra/byte_order.h>
-
-#define vl_msg_id(n,h) n,
-typedef enum {
-#include <mactime/mactime_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 /* included_mactime_msg_enum_h */
diff --git a/src/plugins/mactime/mactime_test.c b/src/plugins/mactime/mactime_test.c
index c9c1a475ad9..8d87e788b7a 100644
--- a/src/plugins/mactime/mactime_test.c
+++ b/src/plugins/mactime/mactime_test.c
@@ -24,29 +24,8 @@
uword vat_unformat_sw_if_index (unformat_input_t * input, va_list * args);
/* Declare message IDs */
-#include <mactime/mactime_msg_enum.h>
-
-/* define message structures */
-#define vl_typedefs
-#include <mactime/mactime_all_api_h.h>
-#undef vl_typedefs
-
-/* declare message handlers for each api */
-
-#define vl_endianfun /* define message structures */
-#include <mactime/mactime_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...)
-#define vl_printfun
-#include <mactime/mactime_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number. */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <mactime/mactime_all_api_h.h>
-#undef vl_api_version
+#include <mactime/mactime.api_enum.h>
+#include <mactime/mactime.api_types.h>
typedef struct
{
@@ -60,34 +39,6 @@ mactime_test_main_t mactime_test_main;
#define __plugin_msg_base mactime_test_main.msg_id_base
#include <vlibapi/vat_helper_macros.h>
-#define foreach_standard_reply_retval_handler \
-_(mactime_enable_disable_reply) \
-_(mactime_add_del_range_reply)
-
-#define _(n) \
- static void vl_api_##n##_t_handler \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = mactime_test_main.vat_main; \
- i32 retval = ntohl(mp->retval); \
- if (vam->async_mode) { \
- vam->async_errors += (retval < 0); \
- } else { \
- vam->retval = retval; \
- vam->result_ready = 1; \
- } \
- }
-foreach_standard_reply_retval_handler;
-#undef _
-
-/*
- * Table of message reply handlers, must include boilerplate handlers
- * we just generated
- */
-#define foreach_vpe_api_reply_msg \
-_(MACTIME_ENABLE_DISABLE_REPLY, mactime_enable_disable_reply) \
-_(MACTIME_ADD_DEL_RANGE_REPLY, mactime_add_del_range_reply)
-
static int
api_mactime_enable_disable (vat_main_t * vam)
{
@@ -263,44 +214,7 @@ api_mactime_add_del_range (vat_main_t * vam)
return ret;
}
-/*
- * List of messages that the api test plugin sends,
- * and that the data plane plugin processes
- */
-#define foreach_vpe_api_msg \
-_(mactime_enable_disable, "<intfc> [disable]") \
-_(mactime_add_del_range, \
- "name <devname> mac <mac-addr> allow drop\n" \
- "allow-range Mon - Fri 9:00 - 17:00")
-
-static void
-mactime_api_hookup (vat_main_t * vam)
-{
- mactime_test_main_t *sm = &mactime_test_main;
- /* Hook up handlers for replies from the data plane plug-in */
-#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_vpe_api_reply_msg;
-#undef _
-
- /* API messages we can send */
-#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
- foreach_vpe_api_msg;
-#undef _
-
- /* Help strings */
-#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
- foreach_vpe_api_msg;
-#undef _
-}
-
-VAT_PLUGIN_REGISTER (mactime);
+#include <mactime/mactime.api_test.c>
/*
* fd.io coding-style-patch-verification: ON