aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/acl/acl_test.c51
-rw-r--r--src/plugins/flowperpkt/flowperpkt_test.c45
-rw-r--r--src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c46
-rw-r--r--src/plugins/ioam/export/ioam_export_test.c44
-rw-r--r--src/plugins/ioam/lib-pot/pot_test.c48
-rw-r--r--src/plugins/ioam/lib-trace/trace_test.c48
-rw-r--r--src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c56
-rw-r--r--src/plugins/lb/lb_test.c35
-rw-r--r--src/plugins/snat/snat_test.c57
9 files changed, 39 insertions, 391 deletions
diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c
index a0e413e16da..5cacf7162bc 100644
--- a/src/plugins/acl/acl_test.c
+++ b/src/plugins/acl/acl_test.c
@@ -25,6 +25,7 @@
#include <vppinfra/error.h>
#include <vnet/ip/ip.h>
#include <arpa/inet.h>
+#include <vlibapi/vat_helper_macros.h>
uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
@@ -259,42 +260,6 @@ _(MACIP_ACL_INTERFACE_ADD_DEL_REPLY, macip_acl_interface_add_del_reply) \
_(MACIP_ACL_INTERFACE_GET_REPLY, macip_acl_interface_get_reply) \
_(ACL_PLUGIN_GET_VERSION_REPLY, acl_plugin_get_version_reply)
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
static int api_acl_plugin_get_version (vat_main_t * vam)
{
acl_test_main_t * sm = &acl_test_main;
@@ -520,7 +485,6 @@ static int api_acl_add_replace (vat_main_t * vam)
static int api_acl_del (vat_main_t * vam)
{
- acl_test_main_t * sm = &acl_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_acl_del_t * mp;
@@ -544,7 +508,6 @@ static int api_acl_del (vat_main_t * vam)
static int api_macip_acl_del (vat_main_t * vam)
{
- acl_test_main_t * sm = &acl_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_acl_del_t * mp;
@@ -568,7 +531,6 @@ static int api_macip_acl_del (vat_main_t * vam)
static int api_acl_interface_add_del (vat_main_t * vam)
{
- acl_test_main_t * sm = &acl_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_acl_interface_add_del_t * mp;
@@ -636,7 +598,6 @@ static int api_acl_interface_add_del (vat_main_t * vam)
static int api_macip_acl_interface_add_del (vat_main_t * vam)
{
- acl_test_main_t * sm = &acl_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_macip_acl_interface_add_del_t * mp;
@@ -687,7 +648,6 @@ static int api_macip_acl_interface_add_del (vat_main_t * vam)
static int api_acl_interface_set_acl_list (vat_main_t * vam)
{
- acl_test_main_t * sm = &acl_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_acl_interface_set_acl_list_t * mp;
@@ -746,7 +706,6 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam)
static int api_acl_interface_list_dump (vat_main_t * vam)
{
- acl_test_main_t * sm = &acl_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
u32 sw_if_index = ~0;
@@ -775,7 +734,6 @@ static int api_acl_interface_list_dump (vat_main_t * vam)
static int api_acl_dump (vat_main_t * vam)
{
- acl_test_main_t * sm = &acl_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
u32 acl_index = ~0;
@@ -802,7 +760,6 @@ static int api_acl_dump (vat_main_t * vam)
static int api_macip_acl_dump (vat_main_t * vam)
{
- acl_test_main_t * sm = &acl_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
u32 acl_index = ~0;
@@ -978,8 +935,8 @@ _(macip_acl_interface_add_del, "<intfc> | sw_if_index <if-idx> [add|del] acl <ac
_(macip_acl_interface_get, "")
-
-void vat_api_hookup (vat_main_t *vam)
+static
+void acl_vat_api_hookup (vat_main_t *vam)
{
acl_test_main_t * sm = &acl_test_main;
/* Hook up handlers for replies from the data plane plug-in */
@@ -1016,7 +973,7 @@ clib_error_t * vat_plugin_register (vat_main_t *vam)
sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (sm->msg_id_base != (u16) ~0)
- vat_api_hookup (vam);
+ acl_vat_api_hookup (vam);
vec_free(name);
diff --git a/src/plugins/flowperpkt/flowperpkt_test.c b/src/plugins/flowperpkt/flowperpkt_test.c
index 716818ffe0a..9211ebe32dd 100644
--- a/src/plugins/flowperpkt/flowperpkt_test.c
+++ b/src/plugins/flowperpkt/flowperpkt_test.c
@@ -19,6 +19,7 @@
#include <vlibmemory/api.h>
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
+#include <vlibapi/vat_helper_macros.h>
/**
* @file vpp_api_test plugin
@@ -88,47 +89,9 @@ foreach_standard_reply_retval_handler;
_(FLOWPERPKT_TX_INTERFACE_ADD_DEL_REPLY, \
flowperpkt_tx_interface_add_del_reply)
-
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
static int
api_flowperpkt_tx_interface_add_del (vat_main_t * vam)
{
- flowperpkt_test_main_t *sm = &flowperpkt_test_main;
unformat_input_t *i = vam->input;
f64 timeout;
int enable_disable = 1;
@@ -177,8 +140,8 @@ api_flowperpkt_tx_interface_add_del (vat_main_t * vam)
#define foreach_vpe_api_msg \
_(flowperpkt_tx_interface_add_del, "<intfc> [disable]")
-void
-vat_api_hookup (vat_main_t * vam)
+static void
+flowperpkt_vat_api_hookup (vat_main_t * vam)
{
flowperpkt_test_main_t *sm = &flowperpkt_test_main;
/* Hook up handlers for replies from the data plane plug-in */
@@ -218,7 +181,7 @@ vat_plugin_register (vat_main_t * vam)
/* Don't attempt to hook up API messages if the data plane plugin is AWOL */
if (sm->msg_id_base != (u16) ~ 0)
- vat_api_hookup (vam);
+ flowperpkt_vat_api_hookup (vam);
vec_free (name);
diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c
index 494263d9a1a..5b641cc7ce7 100644
--- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c
+++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c
@@ -23,7 +23,7 @@
#include <vlibmemory/api.h>
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
-
+#include <vlibapi/vat_helper_macros.h>
/* Declare message IDs */
#include <ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_msg_enum.h>
@@ -86,47 +86,9 @@ foreach_standard_reply_retval_handler;
#define foreach_vpe_api_reply_msg \
_(VXLAN_GPE_IOAM_EXPORT_ENABLE_DISABLE_REPLY, vxlan_gpe_ioam_export_enable_disable_reply)
-
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
static int
api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam)
{
- export_test_main_t *sm = &export_test_main;
unformat_input_t *i = vam->input;
f64 timeout;
int is_disable = 0;
@@ -160,8 +122,8 @@ api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam)
#define foreach_vpe_api_msg \
_(vxlan_gpe_ioam_export_enable_disable, "<intfc> [disable]")
-void
-vat_api_hookup (vat_main_t * vam)
+static void
+vxlan_gpe_ioam_vat_api_hookup (vat_main_t * vam)
{
export_test_main_t *sm = &export_test_main;
/* Hook up handlers for replies from the data plane plug-in */
@@ -199,7 +161,7 @@ vat_plugin_register (vat_main_t * vam)
sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (sm->msg_id_base != (u16) ~ 0)
- vat_api_hookup (vam);
+ vxlan_gpe_ioam_vat_api_hookup (vam);
vec_free (name);
diff --git a/src/plugins/ioam/export/ioam_export_test.c b/src/plugins/ioam/export/ioam_export_test.c
index f991fc0c795..a4ec80d0713 100644
--- a/src/plugins/ioam/export/ioam_export_test.c
+++ b/src/plugins/ioam/export/ioam_export_test.c
@@ -23,6 +23,7 @@
#include <vlibmemory/api.h>
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
+#include <vlibapi/vat_helper_macros.h>
/* Declare message IDs */
@@ -87,46 +88,9 @@ foreach_standard_reply_retval_handler;
_(IOAM_EXPORT_IP6_ENABLE_DISABLE_REPLY, ioam_export_ip6_enable_disable_reply)
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
static int
api_ioam_export_ip6_enable_disable (vat_main_t * vam)
{
- export_test_main_t *sm = &export_test_main;
unformat_input_t *i = vam->input;
f64 timeout;
int is_disable = 0;
@@ -159,8 +123,8 @@ api_ioam_export_ip6_enable_disable (vat_main_t * vam)
#define foreach_vpe_api_msg \
_(ioam_export_ip6_enable_disable, "<intfc> [disable]")
-void
-vat_api_hookup (vat_main_t * vam)
+static void
+ioam_export_vat_api_hookup (vat_main_t * vam)
{
export_test_main_t *sm = &export_test_main;
/* Hook up handlers for replies from the data plane plug-in */
@@ -198,7 +162,7 @@ vat_plugin_register (vat_main_t * vam)
sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (sm->msg_id_base != (u16) ~ 0)
- vat_api_hookup (vam);
+ ioam_export_vat_api_hookup (vam);
vec_free (name);
diff --git a/src/plugins/ioam/lib-pot/pot_test.c b/src/plugins/ioam/lib-pot/pot_test.c
index 2e87023896e..9f9d0c99bcf 100644
--- a/src/plugins/ioam/lib-pot/pot_test.c
+++ b/src/plugins/ioam/lib-pot/pot_test.c
@@ -23,6 +23,7 @@
#include <vlibmemory/api.h>
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
+#include <vlibapi/vat_helper_macros.h>
/* Declare message IDs */
#include <ioam/lib-pot/pot_msg_enum.h>
@@ -118,48 +119,9 @@ _(POT_PROFILE_ACTIVATE_REPLY, pot_profile_activate_reply) \
_(POT_PROFILE_DEL_REPLY, pot_profile_del_reply) \
_(POT_PROFILE_SHOW_CONFIG_DETAILS, pot_profile_show_config_details)
-
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
-
static int api_pot_profile_add (vat_main_t *vam)
{
#define MAX_BITS 64
- pot_test_main_t * sm = &pot_test_main;
unformat_input_t *input = vam->input;
vl_api_pot_profile_add_t *mp;
u8 *name = NULL;
@@ -234,7 +196,6 @@ OUT:
static int api_pot_profile_activate (vat_main_t *vam)
{
#define MAX_BITS 64
- pot_test_main_t * sm = &pot_test_main;
unformat_input_t *input = vam->input;
vl_api_pot_profile_activate_t *mp;
u8 *name = NULL;
@@ -275,7 +236,6 @@ OUT:
static int api_pot_profile_del (vat_main_t *vam)
{
- pot_test_main_t * sm = &pot_test_main;
vl_api_pot_profile_del_t *mp;
f64 timeout;
@@ -287,7 +247,6 @@ static int api_pot_profile_del (vat_main_t *vam)
static int api_pot_profile_show_config_dump (vat_main_t *vam)
{
- pot_test_main_t * sm = &pot_test_main;
unformat_input_t *input = vam->input;
vl_api_pot_profile_show_config_dump_t *mp;
f64 timeout;
@@ -320,7 +279,8 @@ _(pot_profile_activate, "name <name> id [0-1] ") \
_(pot_profile_del, "[id <nn>]") \
_(pot_profile_show_config_dump, "id [0-1]")
-void vat_api_hookup (vat_main_t *vam)
+static void
+pot_vat_api_hookup (vat_main_t *vam)
{
pot_test_main_t * sm = &pot_test_main;
/* Hook up handlers for replies from the data plane plug-in */
@@ -357,7 +317,7 @@ clib_error_t * vat_plugin_register (vat_main_t *vam)
sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (sm->msg_id_base != (u16) ~0)
- vat_api_hookup (vam);
+ pot_vat_api_hookup (vam);
vec_free(name);
diff --git a/src/plugins/ioam/lib-trace/trace_test.c b/src/plugins/ioam/lib-trace/trace_test.c
index 111dd461b5b..f4f1d4d54e2 100644
--- a/src/plugins/ioam/lib-trace/trace_test.c
+++ b/src/plugins/ioam/lib-trace/trace_test.c
@@ -23,6 +23,7 @@
#include <vlibmemory/api.h>
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
+#include <vlibapi/vat_helper_macros.h>
/* Declare message IDs */
#include <ioam/lib-trace/trace_msg_enum.h>
@@ -115,48 +116,9 @@ _(TRACE_PROFILE_ADD_REPLY, trace_profile_add_reply) \
_(TRACE_PROFILE_DEL_REPLY, trace_profile_del_reply) \
_(TRACE_PROFILE_SHOW_CONFIG_REPLY, trace_profile_show_config_reply)
-
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
-
static int
api_trace_profile_add (vat_main_t * vam)
{
- trace_test_main_t *sm = &trace_test_main;
unformat_input_t *input = vam->input;
vl_api_trace_profile_add_t *mp;
u8 trace_type = 0;
@@ -204,7 +166,6 @@ api_trace_profile_add (vat_main_t * vam)
static int
api_trace_profile_del (vat_main_t * vam)
{
- trace_test_main_t *sm = &trace_test_main;
vl_api_trace_profile_del_t *mp;
f64 timeout;
@@ -217,7 +178,6 @@ api_trace_profile_del (vat_main_t * vam)
static int
api_trace_profile_show_config (vat_main_t * vam)
{
- trace_test_main_t *sm = &trace_test_main;
vl_api_trace_profile_show_config_t *mp;
f64 timeout;
M (TRACE_PROFILE_SHOW_CONFIG, trace_profile_show_config);
@@ -237,8 +197,8 @@ _(trace_profile_del, "[id <nn>]") \
_(trace_profile_show_config, "[id <nn>]")
-void
-vat_api_hookup (vat_main_t * vam)
+static void
+ioam_trace_vat_api_hookup (vat_main_t * vam)
{
trace_test_main_t *sm = &trace_test_main;
/* Hook up handlers for replies from the data plane plug-in */
@@ -276,7 +236,7 @@ vat_plugin_register (vat_main_t * vam)
sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (sm->msg_id_base != (u16) ~ 0)
- vat_api_hookup (vam);
+ ioam_trace_vat_api_hookup (vam);
vec_free (name);
diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c
index b5fee7246b4..7c4088ee71a 100644
--- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c
+++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c
@@ -23,6 +23,7 @@
#include <vlibmemory/api.h>
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
+#include <vlibapi/vat_helper_macros.h>
/* Declare message IDs */
#include <ioam/lib-vxlan-gpe/vxlan_gpe_msg_enum.h>
@@ -96,49 +97,9 @@ _(VXLAN_GPE_IOAM_VNI_DISABLE_REPLY, vxlan_gpe_ioam_vni_disable_reply) \
_(VXLAN_GPE_IOAM_TRANSIT_ENABLE_REPLY, vxlan_gpe_ioam_transit_enable_reply) \
_(VXLAN_GPE_IOAM_TRANSIT_DISABLE_REPLY, vxlan_gpe_ioam_transit_disable_reply) \
-
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
-
static int
api_vxlan_gpe_ioam_enable (vat_main_t * vam)
{
- vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main;
-
unformat_input_t *input = vam->input;
vl_api_vxlan_gpe_ioam_enable_t *mp;
f64 timeout;
@@ -179,7 +140,6 @@ api_vxlan_gpe_ioam_enable (vat_main_t * vam)
static int
api_vxlan_gpe_ioam_disable (vat_main_t * vam)
{
- vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main;
vl_api_vxlan_gpe_ioam_disable_t *mp;
f64 timeout;
@@ -192,8 +152,6 @@ api_vxlan_gpe_ioam_disable (vat_main_t * vam)
static int
api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam)
{
- vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main;
-
unformat_input_t *line_input = vam->input;
vl_api_vxlan_gpe_ioam_vni_enable_t *mp;
ip4_address_t local4, remote4;
@@ -289,8 +247,6 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam)
static int
api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam)
{
- vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main;
-
unformat_input_t *line_input = vam->input;
vl_api_vxlan_gpe_ioam_vni_disable_t *mp;
ip4_address_t local4, remote4;
@@ -386,8 +342,6 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam)
static int
api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam)
{
- vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main;
-
unformat_input_t *line_input = vam->input;
vl_api_vxlan_gpe_ioam_transit_enable_t *mp;
ip4_address_t local4;
@@ -458,8 +412,6 @@ api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam)
static int
api_vxlan_gpe_ioam_transit_disable (vat_main_t * vam)
{
- vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main;
-
unformat_input_t *line_input = vam->input;
vl_api_vxlan_gpe_ioam_transit_disable_t *mp;
ip4_address_t local4;
@@ -545,8 +497,8 @@ _(vxlan_gpe_ioam_transit_disable, ""\
"dst-ip <dst_ip> [outer-fib-index <outer_fib_index>]") \
-void
-vat_api_hookup (vat_main_t * vam)
+static void
+vxlan_gpe_vat_api_hookup (vat_main_t * vam)
{
vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main;
/* Hook up handlers for replies from the data plane plug-in */
@@ -584,7 +536,7 @@ vat_plugin_register (vat_main_t * vam)
sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (sm->msg_id_base != (u16) ~ 0)
- vat_api_hookup (vam);
+ vxlan_gpe_vat_api_hookup (vam);
vec_free (name);
diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c
index 8c2eaa91ce9..7e3519a8e4f 100644
--- a/src/plugins/lb/lb_test.c
+++ b/src/plugins/lb/lb_test.c
@@ -19,6 +19,7 @@
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
#include <lb/lb.h>
+#include <vlibapi/vat_helper_macros.h>
//TODO: Move that to vat/plugin_api.c
//////////////////////////
@@ -127,35 +128,8 @@ foreach_standard_reply_retval_handler;
_(LB_ADD_DEL_VIP_REPLY, lb_add_del_vip_reply) \
_(LB_ADD_DEL_AS_REPLY, lb_add_del_as_reply)
-/* M: construct, but don't yet send a message */
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memcpy (mp, &mps, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + lbtm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
static int api_lb_conf (vat_main_t * vam)
{
- lb_test_main_t *lbtm = &lb_test_main;
unformat_input_t *i = vam->input;
f64 timeout;
vl_api_lb_conf_t mps, *mp;
@@ -177,7 +151,6 @@ static int api_lb_conf (vat_main_t * vam)
static int api_lb_add_del_vip (vat_main_t * vam)
{
- lb_test_main_t *lbtm = &lb_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_lb_add_del_vip_t mps, *mp;
@@ -215,7 +188,6 @@ static int api_lb_add_del_vip (vat_main_t * vam)
static int api_lb_add_del_as (vat_main_t * vam)
{
- lb_test_main_t *lbtm = &lb_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_lb_add_del_as_t mps, *mp;
@@ -246,7 +218,8 @@ _(lb_conf, "<ip4-src-addr> <ip6-src-address> <sticky_buckets_per_core> <flow_tim
_(lb_add_del_vip, "<ip-prefix> [gre4|gre6] <new_table_len> [del]") \
_(lb_add_del_as, "<vip-ip-prefix> <address> [del]")
-void vat_api_hookup (vat_main_t *vam)
+static void
+lb_vat_api_hookup (vat_main_t *vam)
{
lb_test_main_t * lbtm = &lb_test_main;
/* Hook up handlers for replies from the data plane plug-in */
@@ -285,7 +258,7 @@ clib_error_t * vat_plugin_register (vat_main_t *vam)
lbtm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (lbtm->msg_id_base != (u16) ~0)
- vat_api_hookup (vam);
+ lb_vat_api_hookup (vam);
vec_free(name);
diff --git a/src/plugins/snat/snat_test.c b/src/plugins/snat/snat_test.c
index 013d7d9b700..b601d7d9c86 100644
--- a/src/plugins/snat/snat_test.c
+++ b/src/plugins/snat/snat_test.c
@@ -21,6 +21,7 @@
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
#include <vnet/ip/ip.h>
+#include <vlibapi/vat_helper_macros.h>
uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
@@ -103,44 +104,8 @@ _(SNAT_INTERFACE_ADDR_DETAILS, snat_interface_addr_details) \
_(SNAT_IPFIX_ENABLE_DISABLE_REPLY, \
snat_ipfix_enable_disable_reply)
-/* M: construct, but don't yet send a message */
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
static int api_snat_add_address_range (vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
ip4_address_t start_addr, end_addr;
@@ -200,7 +165,6 @@ static int api_snat_add_address_range (vat_main_t * vam)
static int api_snat_interface_add_del_feature (vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_snat_interface_add_del_feature_t * mp;
@@ -246,7 +210,6 @@ static int api_snat_interface_add_del_feature (vat_main_t * vam)
static int api_snat_add_static_mapping(vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_snat_add_static_mapping_t * mp;
@@ -338,7 +301,6 @@ static void vl_api_snat_static_mapping_details_t_handler
static int api_snat_static_mapping_dump(vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
f64 timeout;
vl_api_snat_static_mapping_dump_t * mp;
@@ -398,7 +360,6 @@ static void vl_api_snat_show_config_reply_t_handler
static int api_snat_show_config(vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
f64 timeout;
vl_api_snat_show_config_t * mp;
@@ -425,7 +386,6 @@ static void vl_api_snat_address_details_t_handler
static int api_snat_address_dump(vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
f64 timeout;
vl_api_snat_address_dump_t * mp;
@@ -460,7 +420,6 @@ static void vl_api_snat_interface_details_t_handler
static int api_snat_interface_dump(vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
f64 timeout;
vl_api_snat_interface_dump_t * mp;
@@ -485,7 +444,6 @@ static int api_snat_interface_dump(vat_main_t * vam)
static int api_snat_set_workers (vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_snat_set_workers_t * mp;
@@ -523,7 +481,6 @@ static void vl_api_snat_worker_details_t_handler
static int api_snat_worker_dump(vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
f64 timeout;
vl_api_snat_worker_dump_t * mp;
@@ -548,7 +505,6 @@ static int api_snat_worker_dump(vat_main_t * vam)
static int api_snat_ipfix_enable_disable (vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_snat_add_del_interface_addr_t * mp;
@@ -597,7 +553,6 @@ static void vl_api_snat_interface_addr_details_t_handler
static int api_snat_interface_addr_dump(vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
f64 timeout;
vl_api_snat_interface_addr_dump_t * mp;
@@ -622,7 +577,6 @@ static int api_snat_interface_addr_dump(vat_main_t * vam)
static int api_snat_add_del_interface_addr (vat_main_t * vam)
{
- snat_test_main_t * sm = &snat_test_main;
unformat_input_t * i = vam->input;
f64 timeout;
vl_api_snat_ipfix_enable_disable_t * mp;
@@ -677,7 +631,8 @@ _(snat_interface_addr_dump, "") \
_(snat_ipfix_enable_disable, "[domain <id>] [src_port <n>] " \
"[disable]")
-void vat_api_hookup (vat_main_t *vam)
+static void
+snat_vat_api_hookup (vat_main_t *vam)
{
snat_test_main_t * sm __attribute__((unused)) = &snat_test_main;
/* Hook up handlers for replies from the data plane plug-in */
@@ -693,7 +648,9 @@ void vat_api_hookup (vat_main_t *vam)
#undef _
/* API messages we can send */
-#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
+#define _(n,h) \
+ hash_set_mem (vam->function_by_name, #n, api_##n); \
+ clib_warning ("vam %llx add '%s' handler %llx", vam, #n, api_##n);
foreach_vpe_api_msg;
#undef _
@@ -715,7 +672,7 @@ clib_error_t * vat_plugin_register (vat_main_t *vam)
sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (sm->msg_id_base != (u16) ~0)
- vat_api_hookup (vam);
+ snat_vat_api_hookup (vam);
vec_free(name);