aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-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
-rw-r--r--src/vat/api_format.c309
-rw-r--r--src/vcl/vcl_bapi.c71
-rw-r--r--src/vnet/session/session.h1
-rw-r--r--src/vnet/session/session_api.c106
-rw-r--r--src/vnet/vnet_all_api_h.h2
-rw-r--r--src/vpp/api/types.h1
9 files changed, 117 insertions, 441 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)
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 8c10b95b0c1..bb168f8459e 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -1080,7 +1080,7 @@ format_hex_bytes (u8 * s, va_list * va)
* a single function, but that could break in subtle ways.
*/
-#define foreach_standard_reply_retval_handler _ (session_rule_add_del_reply)
+#define foreach_standard_reply_retval_handler
#define _(n) \
static void vl_api_##n##_t_handler \
@@ -1129,9 +1129,6 @@ foreach_standard_reply_retval_handler;
_ (ADD_NODE_NEXT_REPLY, add_node_next_reply) \
_ (SHOW_VERSION_REPLY, show_version_reply) \
_ (SHOW_THREADS_REPLY, show_threads_reply) \
- _ (APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
- _ (SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
- _ (SESSION_RULES_DETAILS, session_rules_details)
#define foreach_standalone_reply_msg \
@@ -2660,90 +2657,6 @@ _("disable", L2_VTR_DISABLED) \
_("pop", L2_VTR_POP_2) \
_("push", L2_VTR_PUSH_2)
-
-static void vl_api_app_namespace_add_del_reply_t_handler
- (vl_api_app_namespace_add_del_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;
- if (retval == 0)
- errmsg ("app ns index %d\n", ntohl (mp->appns_index));
- vam->result_ready = 1;
- }
-}
-
-static void vl_api_app_namespace_add_del_reply_t_handler_json
- (vl_api_app_namespace_add_del_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static int
-api_app_namespace_add_del (vat_main_t * vam)
-{
- vl_api_app_namespace_add_del_t *mp;
- unformat_input_t *i = vam->input;
- u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
- u32 sw_if_index, ip4_fib_id, ip6_fib_id;
- u64 secret;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "id %_%v%_", &ns_id))
- ;
- else if (unformat (i, "secret %lu", &secret))
- secret_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
- ;
- else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
- ;
- else
- break;
- }
- if (!ns_id || !secret_set || !sw_if_index_set)
- {
- errmsg ("namespace id, secret and sw_if_index must be set");
- return -99;
- }
- if (vec_len (ns_id) > 64)
- {
- errmsg ("namespace id too long");
- return -99;
- }
- M (APP_NAMESPACE_ADD_DEL, mp);
-
- vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
- mp->secret = clib_host_to_net_u64 (secret);
- mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
- mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
- mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
- vec_free (ns_id);
- S (mp);
- W (ret);
- return ret;
-}
-
static int
api_sock_init_shm (vat_main_t * vam)
{
@@ -2803,221 +2716,6 @@ api_sock_init_shm (vat_main_t * vam)
#endif
}
-static void
-vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- fib_prefix_t lcl, rmt;
-
- ip_prefix_decode (&mp->lcl, &lcl);
- ip_prefix_decode (&mp->rmt, &rmt);
-
- if (lcl.fp_proto == FIB_PROTOCOL_IP4)
- {
- print (vam->ofp,
- "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
- clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
- mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
- clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
- &rmt.fp_addr.ip4, rmt.fp_len,
- clib_net_to_host_u16 (mp->rmt_port),
- clib_net_to_host_u32 (mp->action_index), mp->tag);
- }
- else
- {
- print (vam->ofp,
- "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
- clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
- mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
- clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
- &rmt.fp_addr.ip6, rmt.fp_len,
- clib_net_to_host_u16 (mp->rmt_port),
- clib_net_to_host_u32 (mp->action_index), mp->tag);
- }
-}
-
-static void
-vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
- mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
- struct in6_addr ip6;
- struct in_addr ip4;
-
- fib_prefix_t lcl, rmt;
-
- ip_prefix_decode (&mp->lcl, &lcl);
- ip_prefix_decode (&mp->rmt, &rmt);
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
- vat_json_init_object (node);
-
- vat_json_object_add_uint (node, "appns_index",
- clib_net_to_host_u32 (mp->appns_index));
- vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
- vat_json_object_add_uint (node, "scope", mp->scope);
- vat_json_object_add_uint (node, "action_index",
- clib_net_to_host_u32 (mp->action_index));
- vat_json_object_add_uint (node, "lcl_port",
- clib_net_to_host_u16 (mp->lcl_port));
- vat_json_object_add_uint (node, "rmt_port",
- clib_net_to_host_u16 (mp->rmt_port));
- vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
- vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
- vat_json_object_add_string_copy (node, "tag", mp->tag);
- if (lcl.fp_proto == FIB_PROTOCOL_IP4)
- {
- clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
- vat_json_object_add_ip4 (node, "lcl_ip", ip4);
- clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
- vat_json_object_add_ip4 (node, "rmt_ip", ip4);
- }
- else
- {
- clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
- vat_json_object_add_ip6 (node, "lcl_ip", ip6);
- clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
- vat_json_object_add_ip6 (node, "rmt_ip", ip6);
- }
-}
-
-static int
-api_session_rule_add_del (vat_main_t * vam)
-{
- vl_api_session_rule_add_del_t *mp;
- unformat_input_t *i = vam->input;
- u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
- u32 appns_index = 0, scope = 0;
- ip4_address_t lcl_ip4, rmt_ip4;
- ip6_address_t lcl_ip6, rmt_ip6;
- u8 is_ip4 = 1, conn_set = 0;
- u8 is_add = 1, *tag = 0;
- int ret;
- fib_prefix_t lcl, rmt;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- ;
- else if (unformat (i, "proto tcp"))
- proto = 0;
- else if (unformat (i, "proto udp"))
- proto = 1;
- else if (unformat (i, "appns %d", &appns_index))
- ;
- else if (unformat (i, "scope %d", &scope))
- ;
- else if (unformat (i, "tag %_%v%_", &tag))
- ;
- else
- if (unformat
- (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
- &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
- &rmt_port))
- {
- is_ip4 = 1;
- conn_set = 1;
- }
- else
- if (unformat
- (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
- &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
- &rmt_port))
- {
- is_ip4 = 0;
- conn_set = 1;
- }
- else if (unformat (i, "action %d", &action))
- ;
- else
- break;
- }
- if (proto == ~0 || !conn_set || action == ~0)
- {
- errmsg ("transport proto, connection and action must be set");
- return -99;
- }
-
- if (scope > 3)
- {
- errmsg ("scope should be 0-3");
- return -99;
- }
-
- M (SESSION_RULE_ADD_DEL, mp);
-
- clib_memset (&lcl, 0, sizeof (lcl));
- clib_memset (&rmt, 0, sizeof (rmt));
- if (is_ip4)
- {
- ip_set (&lcl.fp_addr, &lcl_ip4, 1);
- ip_set (&rmt.fp_addr, &rmt_ip4, 1);
- lcl.fp_len = lcl_plen;
- rmt.fp_len = rmt_plen;
- }
- else
- {
- ip_set (&lcl.fp_addr, &lcl_ip6, 0);
- ip_set (&rmt.fp_addr, &rmt_ip6, 0);
- lcl.fp_len = lcl_plen;
- rmt.fp_len = rmt_plen;
- }
-
-
- ip_prefix_encode (&lcl, &mp->lcl);
- ip_prefix_encode (&rmt, &mp->rmt);
- mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
- mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
- mp->transport_proto =
- proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
- mp->action_index = clib_host_to_net_u32 (action);
- mp->appns_index = clib_host_to_net_u32 (appns_index);
- mp->scope = scope;
- mp->is_add = is_add;
- if (tag)
- {
- clib_memcpy (mp->tag, tag, vec_len (tag));
- vec_free (tag);
- }
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_session_rules_dump (vat_main_t * vam)
-{
- vl_api_session_rules_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
-
- if (!vam->json_output)
- {
- print (vam->ofp, "%=20s", "Session Rules");
- }
-
- M (SESSION_RULES_DUMP, mp);
- /* send it... */
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
static int
q_or_quit (vat_main_t * vam)
{
@@ -3530,11 +3228,6 @@ _(get_first_msg_id, "client <name>") \
_(get_node_graph, " ") \
_(get_next_index, "node-name <node-name> next-node-name <node-name>") \
_(sock_init_shm, "size <nnn>") \
-_(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
-_(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
- "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
-_(session_rules_dump, "") \
-
/* List of command functions, CLI names map directly to functions */
#define foreach_cli_function \
_(comment, "usage: comment <ignore-rest-of-line>") \
diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c
index 5928b541945..32ded0d9eff 100644
--- a/src/vcl/vcl_bapi.c
+++ b/src/vcl/vcl_bapi.c
@@ -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;
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 4984ff011d9..2d01eb6a67a 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -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;
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index fe9ebc15db3..31022294be5 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -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
*
diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h
index 41e5b8d9a15..8b50f3946e6 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -33,8 +33,6 @@
#include <vnet/format_fns.h>
#endif
-#include <vnet/session/session.api.h>
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vpp/api/types.h b/src/vpp/api/types.h
index 3c035c8fd2a..feafe8f5cb3 100644
--- a/src/vpp/api/types.h
+++ b/src/vpp/api/types.h
@@ -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>