session: api cleanup

Use autogenerated code.
Does not change API definitions.

Type: improvement

Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Change-Id: Iacc58d27ac51c8a1c571087f98297e046b3477c2
This commit is contained in:
Filip Tehlar
2021-06-26 22:12:08 +00:00
committed by Ole Tr�an
parent 0972edc1c2
commit 0046e97eb9
9 changed files with 117 additions and 441 deletions

View File

@ -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))
{

View File

@ -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 _
}

View File

@ -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)

File diff suppressed because it is too large Load Diff

View File

@ -15,23 +15,14 @@
#include <vcl/vcl_private.h>
#include <vlibmemory/api.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
#include <vnet/format_fns.h>
#include <vnet/session/session.api_enum.h>
#include <vnet/session/session.api_types.h>
/* declare message handlers for each api */
#define REPLY_MSG_ID_BASE msg_id_base
#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
static u16 msg_id_base;
static u8 *
format_api_error (u8 * s, va_list * args)
@ -280,16 +271,38 @@ vl_api_app_del_cert_key_pair_reply_t_handler (
_ (APP_DEL_CERT_KEY_PAIR_REPLY, app_del_cert_key_pair_reply) \
_ (APP_WORKER_ADD_DEL_REPLY, app_worker_add_del_reply)
#define vl_print(handle, ...) fformat (handle, __VA_ARGS__)
#define vl_endianfun /* define message structures */
#include <vnet/session/session.api.h>
#undef vl_endianfun
/* instantiate all the print functions we know about */
#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
static void
vcl_bapi_hookup (void)
{
#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 *msg_base_lookup_name = format (0, "session_%08x%c", api_version, 0);
REPLY_MSG_ID_BASE =
vl_client_get_first_plugin_msg_id ((char *) msg_base_lookup_name);
vec_free (msg_base_lookup_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_sock_msg;
#undef _
}
@ -305,7 +318,7 @@ vcl_bapi_send_session_enable_disable (u8 is_enable)
bmp = vl_msg_api_alloc (sizeof (*bmp));
memset (bmp, 0, sizeof (*bmp));
bmp->_vl_msg_id = ntohs (VL_API_SESSION_ENABLE_DISABLE);
bmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SESSION_ENABLE_DISABLE);
bmp->client_index = wrk->api_client_handle;
bmp->context = htonl (0xfeedface);
bmp->is_enable = is_enable;
@ -327,7 +340,7 @@ vcl_bapi_send_attach (void)
bmp = vl_msg_api_alloc (sizeof (*bmp));
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 = wrk->api_client_handle;
bmp->context = htonl (0xfeedface);
bmp->options[APP_OPTIONS_FLAGS] =
@ -363,7 +376,7 @@ vcl_bapi_send_detach (void)
bmp = vl_msg_api_alloc (sizeof (*bmp));
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 = wrk->api_client_handle;
bmp->context = htonl (0xfeedface);
vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & bmp);
@ -378,7 +391,7 @@ vcl_bapi_send_app_worker_add_del (u8 is_add)
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_APP_WORKER_ADD_DEL);
mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_APP_WORKER_ADD_DEL);
mp->client_index = wrk->api_client_handle;
mp->app_index = clib_host_to_net_u32 (vcm->app_index);
mp->context = wrk->wrk_index;
@ -398,7 +411,7 @@ vcl_bapi_send_child_worker_del (vcl_worker_t * child_wrk)
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_APP_WORKER_ADD_DEL);
mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_APP_WORKER_ADD_DEL);
mp->client_index = wrk->api_client_handle;
mp->app_index = clib_host_to_net_u32 (vcm->app_index);
mp->context = wrk->wrk_index;
@ -419,7 +432,7 @@ vcl_bapi_send_app_add_cert_key_pair (vppcom_cert_key_pair_t *ckpair)
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 = wrk->api_client_handle;
bmp->context = wrk->wrk_index;
bmp->cert_len = clib_host_to_net_u16 (cert_len);
@ -438,7 +451,7 @@ vcl_bapi_send_app_del_cert_key_pair (u32 ckpair_index)
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 = wrk->api_client_handle;
bmp->context = wrk->wrk_index;
bmp->index = clib_host_to_net_u32 (ckpair_index);
@ -496,7 +509,6 @@ vcl_bapi_connect_to_vpp (void)
vlibapi_set_main (&wrk->bapi_api_ctx);
vlibapi_set_memory_client_main (&wrk->bapi_mem_ctx);
vcl_bapi_hookup ();
if (!vcl_cfg->vpp_bapi_socket_name)
{
@ -521,6 +533,7 @@ vcl_bapi_connect_to_vpp (void)
rv = VPPCOM_ECONNREFUSED;
goto error;
}
vcl_bapi_hookup ();
am = vlibapi_get_main ();
wrk->vl_input_queue = am->shmem_hdr->vl_input_queue;

View File

@ -241,6 +241,7 @@ typedef struct session_main_
/** Preallocate session config parameter */
u32 preallocated_sessions;
u16 msg_id_base;
} session_main_t;
extern session_main_t session_main;

View File

@ -21,38 +21,15 @@
#include <vnet/session/session_rules_table.h>
#include <vnet/session/session_table.h>
#include <vnet/session/session.h>
#include <vnet/ip/ip_types_api.h>
#include <vnet/vnet_msg_enum.h>
#define vl_typedefs /* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_typedefs
#define vl_endianfun /* define message structures */
#include <vnet/vnet_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 <vnet/vnet_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 REPLY_MSG_ID_BASE session_main.msg_id_base
#include <vlibapi/api_helper_macros.h>
#define foreach_session_api_msg \
_(APP_ATTACH, app_attach) \
_(APPLICATION_DETACH, application_detach) \
_(SESSION_ENABLE_DISABLE, session_enable_disable) \
_(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \
_(SESSION_RULE_ADD_DEL, session_rule_add_del) \
_(SESSION_RULES_DUMP, session_rules_dump) \
_(APP_ADD_CERT_KEY_PAIR, app_add_cert_key_pair) \
_(APP_DEL_CERT_KEY_PAIR, app_del_cert_key_pair) \
_(APP_WORKER_ADD_DEL, app_worker_add_del) \
static transport_proto_t
api_session_transport_proto_decode (const vl_api_transport_proto_t * api_tp)
{
@ -921,7 +898,7 @@ send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local,
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SESSION_RULES_DETAILS);
rmp->context = context;
clib_memset (&lcl, 0, sizeof (lcl));
@ -963,7 +940,7 @@ send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local,
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SESSION_RULES_DETAILS);
rmp->context = context;
clib_memset (&lcl, 0, sizeof (lcl));
@ -1138,50 +1115,6 @@ application_reaper_cb (u32 client_index)
VL_MSG_API_REAPER_FUNCTION (application_reaper_cb);
#define vl_msg_name_crc_list
#include <vnet/vnet_all_api_h.h>
#undef vl_msg_name_crc_list
static void
setup_message_id_table (api_main_t * am)
{
#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
foreach_vl_msg_name_crc_session;
#undef _
}
/*
* session_api_hookup
* Add uri's API message handlers to the table.
* vlib has already mapped shared memory and
* added the client registration handlers.
* See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
*/
static clib_error_t *
session_api_hookup (vlib_main_t * vm)
{
api_main_t *am = vlibapi_get_main ();
#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);
foreach_session_api_msg;
#undef _
/*
* Set up the (msg_name, crc, message-id) table
*/
setup_message_id_table (am);
return 0;
}
VLIB_API_INIT_FUNCTION (session_api_hookup);
/*
* Socket api functions
*/
@ -1713,6 +1646,33 @@ error:
return rv;
}
static void
vl_api_application_tls_cert_add_t_handler (
vl_api_application_tls_cert_add_t *mp)
{
/* deprecated */
}
static void
vl_api_application_tls_key_add_t_handler (vl_api_application_tls_key_add_t *mp)
{
/* deprecated */
}
#include <vnet/session/session.api.c>
static clib_error_t *
session_api_hookup (vlib_main_t *vm)
{
/*
* Set up the (msg_name, crc, message-id) table
*/
REPLY_MSG_ID_BASE = setup_message_id_table ();
return 0;
}
VLIB_API_INIT_FUNCTION (session_api_hookup);
/*
* fd.io coding-style-patch-verification: ON
*

View File

@ -33,8 +33,6 @@
#include <vnet/format_fns.h>
#endif
#include <vnet/session/session.api.h>
/*
* fd.io coding-style-patch-verification: ON
*

View File

@ -19,6 +19,7 @@
#include <vlibapi/api_common.h>
#include <vlibapi/api_types.h>
#include <vnet/ip/ip_types.api_types.h>
#include <vnet/ethernet/ethernet_types.api_types.h>
#define vl_typedefs /* define message structures */
#include <vpp/api/vpe_all_api_h.h>