summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-06-26 22:12:08 +0000
committerOle Tr�an <otroan@employees.org>2021-07-12 10:36:46 +0000
commit0046e97eb94cbcf278be2c892e4b686da670a414 (patch)
tree22d6f52cc3ac48dae9a3c74d36e030e38ee79456 /src/plugins
parent0972edc1c2a232e9fb7364d517f6eaf9b71431b9 (diff)
session: api cleanup
Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: Iacc58d27ac51c8a1c571087f98297e046b3477c2
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo.c3
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_bapi.c45
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_common.h20
3 files changed, 39 insertions, 29 deletions
diff --git a/src/plugins/hs_apps/sapi/vpp_echo.c b/src/plugins/hs_apps/sapi/vpp_echo.c
index d78bd12f96c..80d274db5b0 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo.c
@@ -1343,7 +1343,6 @@ main (int argc, char **argv)
signal (SIGINT, stop_signal);
signal (SIGQUIT, stop_signal);
signal (SIGTERM, stop_signal);
- echo_api_hookup (em);
app_name = em->i_am_master ? "echo_server" : "echo_client";
if (connect_to_vpp (app_name))
@@ -1356,6 +1355,8 @@ main (int argc, char **argv)
echo_session_prealloc (em);
echo_notify_event (em, ECHO_EVT_START);
+ echo_api_hookup (em);
+
echo_send_attach (em);
if (wait_for_state_change (em, STATE_ATTACHED_NO_CERT, TIMEOUT))
{
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
index 7cf15eb1486..38fb522351c 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
@@ -18,6 +18,9 @@
#include <hs_apps/sapi/vpp_echo_common.h>
+#define REPLY_MSG_ID_BASE msg_id_base
+static u16 msg_id_base;
+
/*
*
* Binary API Messages
@@ -31,7 +34,7 @@ echo_send_attach (echo_main_t * em)
bmp = vl_msg_api_alloc (sizeof (*bmp));
clib_memset (bmp, 0, sizeof (*bmp));
- bmp->_vl_msg_id = ntohs (VL_API_APP_ATTACH);
+ bmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_APP_ATTACH);
bmp->client_index = em->my_client_index;
bmp->context = ntohl (0xfeedface);
bmp->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_ACCEPT_REDIRECT;
@@ -58,7 +61,7 @@ echo_send_detach (echo_main_t * em)
bmp = vl_msg_api_alloc (sizeof (*bmp));
clib_memset (bmp, 0, sizeof (*bmp));
- bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_DETACH);
+ bmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_APPLICATION_DETACH);
bmp->client_index = em->my_client_index;
bmp->context = ntohl (0xfeedface);
@@ -75,7 +78,7 @@ echo_send_add_cert_key (echo_main_t * em)
bmp = vl_msg_api_alloc (sizeof (*bmp) + cert_len + key_len);
clib_memset (bmp, 0, sizeof (*bmp) + cert_len + key_len);
- bmp->_vl_msg_id = ntohs (VL_API_APP_ADD_CERT_KEY_PAIR);
+ bmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_APP_ADD_CERT_KEY_PAIR);
bmp->client_index = em->my_client_index;
bmp->context = ntohl (0xfeedface);
bmp->cert_len = clib_host_to_net_u16 (cert_len);
@@ -93,7 +96,7 @@ echo_send_del_cert_key (echo_main_t * em)
bmp = vl_msg_api_alloc (sizeof (*bmp));
clib_memset (bmp, 0, sizeof (*bmp));
- bmp->_vl_msg_id = ntohs (VL_API_APP_DEL_CERT_KEY_PAIR);
+ bmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_APP_DEL_CERT_KEY_PAIR);
bmp->client_index = em->my_client_index;
bmp->context = ntohl (0xfeedface);
bmp->index = clib_host_to_net_u32 (em->ckpair_index);
@@ -540,16 +543,36 @@ _(APPLICATION_DETACH_REPLY, application_detach_reply) \
_(APP_ADD_CERT_KEY_PAIR_REPLY, app_add_cert_key_pair_reply) \
_(APP_DEL_CERT_KEY_PAIR_REPLY, app_del_cert_key_pair_reply)
+#define vl_print(handle, ...) fformat (handle, __VA_ARGS__)
+#define vl_endianfun
+#include <vnet/session/session.api.h>
+#undef vl_endianfun
+
+#define vl_printfun
+#include <vnet/session/session.api.h>
+#undef vl_printfun
+
+#define vl_api_version(n, v) static u32 api_version = v;
+#include <vnet/session/session.api.h>
+#undef vl_api_version
+
void
echo_api_hookup (echo_main_t * em)
{
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #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);
+ u8 *name = format (0, "session_%08x%c", api_version, 0);
+
+ REPLY_MSG_ID_BASE = vl_client_get_first_plugin_msg_id ((char *) name);
+
+ vec_free (name);
+
+ if (REPLY_MSG_ID_BASE == (u16) ~0)
+ return;
+
+#define _(N, n) \
+ vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_##N, #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_quic_echo_msg;
#undef _
}
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_common.h b/src/plugins/hs_apps/sapi/vpp_echo_common.h
index 4760f3b06e3..80c539ccb0f 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_common.h
+++ b/src/plugins/hs_apps/sapi/vpp_echo_common.h
@@ -17,23 +17,9 @@
#define __included_vpp_echo_common_h__
#include <vnet/session/application_interface.h>
-#include <vpp/api/vpe_msg_enum.h>
-
-#define vl_typedefs /* define message structures */
-#include <vpp/api/vpe_all_api_h.h>
-#undef vl_typedefs
-
-/* declare message handlers for each api */
-
-#define vl_endianfun /* define message structures */
-#include <vpp/api/vpe_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...)
-#define vl_printfun
-#include <vpp/api/vpe_all_api_h.h>
-#undef vl_printfun
+#include <vnet/format_fns.h>
+#include <vnet/session/session.api_enum.h>
+#include <vnet/session/session.api_types.h>
#define TIMEOUT 10.0
#define LOGGING_BATCH (100)