summaryrefslogtreecommitdiffstats
path: root/src/plugins/lb
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/lb')
-rw-r--r--src/plugins/lb/api.c97
-rw-r--r--src/plugins/lb/lb.api8
-rw-r--r--src/plugins/lb/lb_all_api_h.h19
-rw-r--r--src/plugins/lb/lb_msg_enum.h31
4 files changed, 112 insertions, 43 deletions
diff --git a/src/plugins/lb/api.c b/src/plugins/lb/api.c
index 953654cd956..ad92b9b97dd 100644
--- a/src/plugins/lb/api.c
+++ b/src/plugins/lb/api.c
@@ -13,6 +13,8 @@
* limitations under the License.
*/
+#include <vnet/vnet.h>
+#include <vnet/plugin/plugin.h>
#include <lb/lb.h>
#include <vppinfra/byte_order.h>
@@ -20,50 +22,42 @@
#include <vlibapi/api.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
+#include <vpp/app/version.h>
-
-#define vl_msg_id(n,h) n,
-typedef enum {
-#include <lb/lb.api.h>
- /* We'll want to know how many messages IDs we need... */
- VL_MSG_FIRST_AVAILABLE,
-} vl_msg_id_t;
-#undef vl_msg_id
-
+/* define message IDs */
+#include <lb/lb_msg_enum.h>
/* define message structures */
#define vl_typedefs
-#include <lb/lb.api.h>
+#include <lb/lb_all_api_h.h>
#undef vl_typedefs
/* define generated endian-swappers */
#define vl_endianfun
-#include <lb/lb.api.h>
+#include <lb/lb_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 <lb/lb_all_api_h.h>
+#undef vl_printfun
/* Get the API version number */
#define vl_api_version(n,v) static u32 api_version=(v);
-#include <lb/lb.api.h>
+#include <lb/lb_all_api_h.h>
#undef vl_api_version
-#define vl_msg_name_crc_list
-#include <lb/lb.api.h>
-#undef vl_msg_name_crc_list
-
-
#define REPLY_MSG_ID_BASE lbm->msg_id_base
#include <vlibapi/api_helper_macros.h>
-static void
-setup_message_id_table (lb_main_t * lbm, api_main_t * am)
-{
-#define _(id,n,crc) \
- vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + lbm->msg_id_base);
- foreach_vl_msg_name_crc_lb;
-#undef _
-}
+/* List of message types that this plugin understands */
+#define foreach_lb_plugin_api_msg \
+_(LB_CONF, lb_conf) \
+_(LB_ADD_DEL_VIP, lb_add_del_vip) \
+_(LB_ADD_DEL_AS, lb_add_del_as) \
+_(LB_FLUSH_VIP, lb_flush_vip) \
+
/* Macro to finish up custom dump fns */
#define FINISH \
@@ -290,20 +284,11 @@ static void *vl_api_lb_flush_vip_t_print
FINISH;
}
-/* List of message types that this plugin understands */
-#define foreach_lb_plugin_api_msg \
-_(LB_CONF, lb_conf) \
-_(LB_ADD_DEL_VIP, lb_add_del_vip) \
-_(LB_ADD_DEL_AS, lb_add_del_as) \
-_(LB_FLUSH_VIP, lb_flush_vip)
-
-static clib_error_t * lb_api_init (vlib_main_t * vm)
+/* Set up the API message handling tables */
+static clib_error_t *
+lb_plugin_api_hookup (vlib_main_t *vm)
{
- lb_main_t *lbm = &lb_main;
- u8 *name = format (0, "lb_%08x%c", api_version, 0);
- lbm->msg_id_base = vl_msg_api_get_msg_ids
- ((char *) name, VL_MSG_FIRST_AVAILABLE);
-
+lb_main_t *lbm = &lb_main;
#define _(N,n) \
vl_msg_api_set_handlers((VL_API_##N + lbm->msg_id_base), \
#n, \
@@ -315,10 +300,44 @@ static clib_error_t * lb_api_init (vlib_main_t * vm)
foreach_lb_plugin_api_msg;
#undef _
+ return 0;
+}
+
+#define vl_msg_name_crc_list
+#include <lb/lb_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (lb_main_t * lmp, api_main_t * am)
+{
+#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + lmp->msg_id_base);
+ foreach_vl_msg_name_crc_lb ;
+#undef _
+}
+
+static clib_error_t * lb_api_init (vlib_main_t * vm)
+{
+ lb_main_t * lbm = &lb_main;
+ clib_error_t * error = 0;
+ u8 * name;
+
+ lbm->vlib_main = vm;
+ lbm->vnet_main = vnet_get_main();
+
+ name = format (0, "lb_%08x%c", api_version, 0);
+
+ /* Ask for a correctly-sized block of API message decode slots */
+ lbm->msg_id_base = vl_msg_api_get_msg_ids
+ ((char *) name, VL_MSG_FIRST_AVAILABLE);
+
+ error = lb_plugin_api_hookup (vm);
+
/* Add our API messages to the global name_crc hash table */
setup_message_id_table (lbm, &api_main);
- return 0;
+ vec_free (name);
+
+ return error;
}
VLIB_INIT_FUNCTION (lb_api_init);
diff --git a/src/plugins/lb/lb.api b/src/plugins/lb/lb.api
index 190e32011b3..c24440936d3 100644
--- a/src/plugins/lb/lb.api
+++ b/src/plugins/lb/lb.api
@@ -11,7 +11,7 @@ import "vnet/ip/ip_types.api";
@param flow_timeout - Time in seconds after which, if no packet is received
for a given flow, the flow is removed from the established flow table.
*/
-autoreply define lb_conf
+autoreply manual_print define lb_conf
{
u32 client_index;
u32 context;
@@ -37,7 +37,7 @@ autoreply define lb_conf
for this VIP (must be power of 2).
@param is_del - The VIP should be removed.
*/
-autoreply define lb_add_del_vip {
+autoreply manual_print define lb_add_del_vip {
u32 client_index;
u32 context;
u8 ip_prefix[16];
@@ -64,7 +64,7 @@ autoreply define lb_add_del_vip {
@param is_del - The AS should be removed.
@param is_flush - The sessions related to this AS should be flushed.
*/
-autoreply define lb_add_del_as {
+autoreply manual_print define lb_add_del_as {
u32 client_index;
u32 context;
u8 vip_ip_prefix[16];
@@ -84,7 +84,7 @@ autoreply define lb_add_del_as {
@param protocol - tcp or udp.
@param port - destination port.
*/
-autoreply define lb_flush_vip {
+autoreply manual_print define lb_flush_vip {
u32 client_index;
u32 context;
u8 ip_prefix[16];
diff --git a/src/plugins/lb/lb_all_api_h.h b/src/plugins/lb/lb_all_api_h.h
new file mode 100644
index 00000000000..6d830d710d2
--- /dev/null
+++ b/src/plugins/lb/lb_all_api_h.h
@@ -0,0 +1,19 @@
+
+/*
+ * api_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 <lb/lb.api.h>
diff --git a/src/plugins/lb/lb_msg_enum.h b/src/plugins/lb/lb_msg_enum.h
new file mode 100644
index 00000000000..b087aa6c4ef
--- /dev/null
+++ b/src/plugins/lb/lb_msg_enum.h
@@ -0,0 +1,31 @@
+
+/*
+ * api_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_lb_msg_enum_h
+#define included_lb_msg_enum_h
+
+#include <vppinfra/byte_order.h>
+
+#define vl_msg_id(n,h) n,
+typedef enum {
+#include <lb/lb_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_lb_msg_enum_h */