aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlibmemory
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-07-23 22:03:05 +0000
committerOle Tr�an <otroan@employees.org>2021-10-18 07:03:12 +0000
commitf0e67d78ae23ff3d5751ea10e9e76cb6e81ba4a5 (patch)
treec63b1ac48809a7247bb288e01d5c9cdfb6038b7c /src/vlibmemory
parent2e55823af6c1cc6856e4a1f2cea659170bd76fb7 (diff)
interface: add api test file
Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: Ib07029204ecf12bf2adb5a39afa54bc98fb81f34
Diffstat (limited to 'src/vlibmemory')
-rw-r--r--src/vlibmemory/memclnt.api25
-rw-r--r--src/vlibmemory/memclnt_api.c18
-rw-r--r--src/vlibmemory/vlib.api26
-rw-r--r--src/vlibmemory/vlib_api.c13
-rw-r--r--src/vlibmemory/vlibapi_test.c25
5 files changed, 43 insertions, 64 deletions
diff --git a/src/vlibmemory/memclnt.api b/src/vlibmemory/memclnt.api
index a5194cd58c4..bd999b51dd0 100644
--- a/src/vlibmemory/memclnt.api
+++ b/src/vlibmemory/memclnt.api
@@ -207,3 +207,28 @@ autoreply define memclnt_keepalive
u32 client_index;
u32 context;
};
+
+/** \brief Control ping from client to api server request
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+*/
+define control_ping
+{
+ u32 client_index;
+ u32 context;
+};
+
+/** \brief Control ping from the client to the server response
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param retval - return code for the request
+ @param vpe_pid - the pid of the vpe, returned by the server
+*/
+define control_ping_reply
+{
+ u32 context;
+ i32 retval;
+ u32 client_index;
+ u32 vpe_pid;
+};
+
diff --git a/src/vlibmemory/memclnt_api.c b/src/vlibmemory/memclnt_api.c
index e7d689b614a..2b4a2393db3 100644
--- a/src/vlibmemory/memclnt_api.c
+++ b/src/vlibmemory/memclnt_api.c
@@ -29,6 +29,7 @@
#include <vlib/unix/unix.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
+#include <vlibapi/api_helper_macros.h>
/**
* @file
@@ -131,9 +132,20 @@ vl_api_api_versions_t_handler (vl_api_api_versions_t *mp)
vl_api_send_msg (reg, (u8 *) rmp);
}
+static void
+vl_api_control_ping_t_handler (vl_api_control_ping_t *mp)
+{
+ vl_api_control_ping_reply_t *rmp;
+ int rv = 0;
+
+ REPLY_MACRO2 (VL_API_CONTROL_PING_REPLY,
+ ({ rmp->vpe_pid = ntohl (getpid ()); }));
+}
+
#define foreach_vlib_api_msg \
_ (GET_FIRST_MSG_ID, get_first_msg_id) \
- _ (API_VERSIONS, api_versions)
+ _ (API_VERSIONS, api_versions) \
+ _ (CONTROL_PING, control_ping)
/*
* vl_api_init
@@ -141,6 +153,7 @@ vl_api_api_versions_t_handler (vl_api_api_versions_t *mp)
static int
vlib_api_init (void)
{
+ api_main_t *am = vlibapi_get_main ();
vl_msg_api_msg_config_t cfg;
vl_msg_api_msg_config_t *c = &cfg;
@@ -175,6 +188,9 @@ vlib_api_init (void)
foreach_vlib_api_msg;
#undef _
+ am->is_mp_safe[VL_API_CONTROL_PING] = 1;
+ am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
+
return 0;
}
diff --git a/src/vlibmemory/vlib.api b/src/vlibmemory/vlib.api
index c017fc7919a..ce1236826aa 100644
--- a/src/vlibmemory/vlib.api
+++ b/src/vlibmemory/vlib.api
@@ -243,32 +243,8 @@ define get_f64_increment_by_one_reply
f64 f64_value;
};
-/** \brief Control ping from client to api server request
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define control_ping
-{
- u32 client_index;
- u32 context;
-};
-
-/** \brief Control ping from the client to the server response
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param retval - return code for the request
- @param vpe_pid - the pid of the vpe, returned by the server
-*/
-define control_ping_reply
-{
- u32 context;
- i32 retval;
- u32 client_index;
- u32 vpe_pid;
-};
-
/*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
- */ \ No newline at end of file
+ */
diff --git a/src/vlibmemory/vlib_api.c b/src/vlibmemory/vlib_api.c
index 6962ea01f5d..b598f0b9852 100644
--- a/src/vlibmemory/vlib_api.c
+++ b/src/vlibmemory/vlib_api.c
@@ -329,16 +329,6 @@ vl_api_get_f64_increment_by_one_t_handler (
}));
}
-static void
-vl_api_control_ping_t_handler (vl_api_control_ping_t *mp)
-{
- vl_api_control_ping_reply_t *rmp;
- int rv = 0;
-
- REPLY_MACRO2 (VL_API_CONTROL_PING_REPLY,
- ({ rmp->vpe_pid = ntohl (getpid ()); }));
-}
-
#include <vlibmemory/vlib.api.c>
static clib_error_t *
vlib_apis_hookup (vlib_main_t *vm)
@@ -351,9 +341,6 @@ vlib_apis_hookup (vlib_main_t *vm)
msg_id_base = setup_message_id_table ();
am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
- am->is_mp_safe[VL_API_CONTROL_PING] = 1;
- am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
-
return 0;
}
diff --git a/src/vlibmemory/vlibapi_test.c b/src/vlibmemory/vlibapi_test.c
index c91cd7942f9..820096ab80d 100644
--- a/src/vlibmemory/vlibapi_test.c
+++ b/src/vlibmemory/vlibapi_test.c
@@ -449,31 +449,6 @@ api_get_node_graph (vat_main_t *vam)
return ret;
}
-static void
-vl_api_control_ping_reply_t_handler (vl_api_control_ping_reply_t *mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->result_ready = 1;
- }
- if (vam->socket_client_main)
- vam->socket_client_main->control_pings_outstanding--;
-}
-
-static int
-api_control_ping (vat_main_t *vam)
-{
- // not yet implemented
- return -1;
-}
-
#define VL_API_LOCAL_SETUP_MESSAGE_ID_TABLE local_setup_message_id_table
static void
local_setup_message_id_table (vat_main_t *vam)