api: deprecate vl_msg_api_set_handlers
Type: refactor
Change-Id: I7b7ca9ec62cb70243c5b7e87968eab1338d67ec8
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
index 0652b86..868cc3a 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
@@ -585,11 +585,18 @@
return;
#define _(N, n) \
- vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_##N, #n, \
- vl_api_##n##_t_handler, vl_api_##n##_t_endian, \
- vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 1, \
- vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson, \
- vl_api_##n##_t_calc_size);
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){ \
+ .id = REPLY_MSG_ID_BASE + VL_API_##N, \
+ .name = #n, \
+ .handler = vl_api_##n##_t_handler, \
+ .endian = vl_api_##n##_t_endian, \
+ .format_fn = vl_api_##n##_t_format, \
+ .size = sizeof (vl_api_##n##_t), \
+ .traced = 1, \
+ .tojson = vl_api_##n##_t_tojson, \
+ .fromjson = vl_api_##n##_t_fromjson, \
+ .calc_size = vl_api_##n##_t_calc_size, \
+ });
foreach_quic_echo_msg;
#undef _
}
diff --git a/src/plugins/tracedump/tracedump_test.c b/src/plugins/tracedump/tracedump_test.c
index f2bb63e..1a2c818 100644
--- a/src/plugins/tracedump/tracedump_test.c
+++ b/src/plugins/tracedump/tracedump_test.c
@@ -248,12 +248,18 @@
void
manual_setup_message_id_table (vat_main_t * vam)
{
- vl_msg_api_set_handlers (
- VL_API_TRACE_DETAILS + tracedump_test_main.msg_id_base, "trace_details",
- vl_api_trace_details_t_handler, vl_api_trace_details_t_endian,
- vl_api_trace_details_t_format, sizeof (vl_api_trace_details_t), 1,
- vl_api_trace_details_t_tojson, vl_api_trace_details_t_fromjson,
- vl_api_trace_details_t_calc_size);
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){
+ .id = VL_API_TRACE_DETAILS + tracedump_test_main.msg_id_base,
+ .name = "trace_details",
+ .handler = vl_api_trace_details_t_handler,
+ .endian = vl_api_trace_details_t_endian,
+ .format_fn = vl_api_trace_details_t_format,
+ .size = sizeof (vl_api_trace_details_t),
+ .traced = 1,
+ .tojson = vl_api_trace_details_t_tojson,
+ .fromjson = vl_api_trace_details_t_fromjson,
+ .calc_size = vl_api_trace_details_t_calc_size,
+ });
}
#define VL_API_LOCAL_SETUP_MESSAGE_ID_TABLE manual_setup_message_id_table
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py
index b9f9e07..5ca2ed5 100644
--- a/src/tools/vppapigen/vppapigen_c.py
+++ b/src/tools/vppapigen/vppapigen_c.py
@@ -1669,17 +1669,18 @@
write("setup_message_id_table (vat_main_t * vam, u16 msg_id_base) {\n")
for s in services:
write(
- " vl_msg_api_set_handlers(VL_API_{ID} + msg_id_base, "
- ' "{n}",\n'
- " vl_api_{n}_t_handler, "
- " vl_api_{n}_t_endian, "
- " vl_api_{n}_t_format,\n"
- " sizeof(vl_api_{n}_t), 1,\n"
- " vl_api_{n}_t_tojson,\n"
- " vl_api_{n}_t_fromjson,\n"
- " vl_api_{n}_t_calc_size);\n".format(
- n=s.reply, ID=s.reply.upper()
- )
+ " vl_msg_api_config (&(vl_msg_api_msg_config_t){{\n"
+ " .id = VL_API_{ID} + msg_id_base,\n"
+ ' .name = "{n}",\n'
+ " .handler = vl_api_{n}_t_handler,\n"
+ " .endian = vl_api_{n}_t_endian,\n"
+ " .format_fn = vl_api_{n}_t_format,\n"
+ " .size = sizeof(vl_api_{n}_t),\n"
+ " .traced = 1,\n"
+ " .tojson = vl_api_{n}_t_tojson,\n"
+ " .fromjson = vl_api_{n}_t_fromjson,\n"
+ " .calc_size = vl_api_{n}_t_calc_size,\n"
+ " }});".format(n=s.reply, ID=s.reply.upper())
)
write(
' hash_set_mem (vam->function_by_name, "{n}", api_{n});\n'.format(
@@ -1698,17 +1699,18 @@
# Events
for e in s.events:
write(
- " vl_msg_api_set_handlers(VL_API_{ID} + msg_id_base, "
- ' "{n}",\n'
- " vl_api_{n}_t_handler, "
- " vl_api_{n}_t_endian, "
- " vl_api_{n}_t_format,\n"
- " sizeof(vl_api_{n}_t), 1,\n"
- " vl_api_{n}_t_tojson,\n"
- " vl_api_{n}_t_fromjson,\n"
- " vl_api_{n}_t_calc_size);\n".format(
- n=e, ID=e.upper()
- )
+ " vl_msg_api_config (&(vl_msg_api_msg_config_t){{\n"
+ " .id = VL_API_{ID} + msg_id_base,\n"
+ ' .name = "{n}",\n'
+ " .handler = vl_api_{n}_t_handler,\n"
+ " .endian = vl_api_{n}_t_endian,\n"
+ " .format_fn = vl_api_{n}_t_format,\n"
+ " .size = sizeof(vl_api_{n}_t),\n"
+ " .traced = 1,\n"
+ " .tojson = vl_api_{n}_t_tojson,\n"
+ " .fromjson = vl_api_{n}_t_fromjson,\n"
+ " .calc_size = vl_api_{n}_t_calc_size,\n"
+ " }});".format(n=e, ID=e.upper())
)
write("}\n")
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 72ce34f..45ba025 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -2733,10 +2733,18 @@
vat_api_hookup (vat_main_t * vam)
{
#define _(N, n) \
- vl_msg_api_set_handlers ( \
- VL_API_##N + 1, #n, vl_api_##n##_t_handler_uni, vl_api_##n##_t_endian, \
- vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 1, vl_api_##n##_t_tojson, \
- vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size);
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){ \
+ .id = VL_API_##N + 1, \
+ .name = #n, \
+ .handler = vl_api_##n##_t_handler_uni, \
+ .endian = vl_api_##n##_t_endian, \
+ .format_fn = vl_api_##n##_t_format, \
+ .size = sizeof (vl_api_##n##_t), \
+ .traced = 1, \
+ .tojson = vl_api_##n##_t_tojson, \
+ .fromjson = vl_api_##n##_t_fromjson, \
+ .calc_size = vl_api_##n##_t_calc_size, \
+ });
foreach_vpe_api_reply_msg;
#if VPP_API_TEST_BUILTIN == 0
foreach_standalone_reply_msg;
diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c
index 7e5203d..afe8824 100644
--- a/src/vcl/vcl_bapi.c
+++ b/src/vcl/vcl_bapi.c
@@ -302,11 +302,18 @@
return;
#define _(N, n) \
- vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_##N, #n, \
- vl_api_##n##_t_handler, vl_api_##n##_t_endian, \
- vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 1, \
- vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson, \
- vl_api_##n##_t_calc_size);
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){ \
+ .id = REPLY_MSG_ID_BASE + VL_API_##N, \
+ .name = #n, \
+ .handler = vl_api_##n##_t_handler, \
+ .endian = vl_api_##n##_t_endian, \
+ .format_fn = vl_api_##n##_t_format, \
+ .size = sizeof (vl_api_##n##_t), \
+ .traced = 1, \
+ .tojson = vl_api_##n##_t_tojson, \
+ .fromjson = vl_api_##n##_t_fromjson, \
+ .calc_size = vl_api_##n##_t_calc_size, \
+ });
foreach_sock_msg;
#undef _
}
diff --git a/src/vlibapi/api_common.h b/src/vlibapi/api_common.h
index 37ffb58..d644d93 100644
--- a/src/vlibapi/api_common.h
+++ b/src/vlibapi/api_common.h
@@ -171,10 +171,6 @@
void vl_msg_api_cleanup_handler (void *the_msg);
void vl_msg_api_replay_handler (void *the_msg);
void vl_msg_api_socket_handler (void *the_msg, uword msg_len);
-void vl_msg_api_set_handlers (int msg_id, char *msg_name, void *handler,
- void *endian, format_function_t *format,
- int msg_size, int traced, void *tojson,
- void *fromjson, void *validate_size);
void vl_msg_api_clean_handlers (int msg_id);
void vl_msg_api_config (vl_msg_api_msg_config_t *);
void vl_msg_api_set_cleanup_handler (int msg_id, void *fp);
diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c
index 0a98348..bf03751 100644
--- a/src/vlibapi/api_shared.c
+++ b/src/vlibapi/api_shared.c
@@ -784,36 +784,6 @@
hash_set_mem (am->msg_id_by_name, c->name, c->id);
}
-/*
- * vl_msg_api_set_handlers
- * preserve the old API for a while
- */
-void
-vl_msg_api_set_handlers (int id, char *name, void *handler, void *endian,
- format_function_t *format, int size, int traced,
- void *tojson, void *fromjson, void *calc_size)
-{
- vl_msg_api_msg_config_t cfg;
- vl_msg_api_msg_config_t *c = &cfg;
-
- clib_memset (c, 0, sizeof (*c));
-
- c->id = id;
- c->name = name;
- c->handler = handler;
- c->endian = endian;
- c->format_fn = format;
- c->traced = traced;
- c->replay = 1;
- c->message_bounce = 0;
- c->is_mp_safe = 0;
- c->is_autoendian = 0;
- c->tojson = tojson;
- c->fromjson = fromjson;
- c->calc_size = calc_size;
- vl_msg_api_config (c);
-}
-
void
vl_msg_api_clean_handlers (int msg_id)
{
diff --git a/src/vlibmemory/memclnt_api.c b/src/vlibmemory/memclnt_api.c
index 0717d81..29858dd 100644
--- a/src/vlibmemory/memclnt_api.c
+++ b/src/vlibmemory/memclnt_api.c
@@ -707,22 +707,36 @@
{
api_main_t *am = vlibapi_get_main ();
#define _(N, n) \
- vl_msg_api_set_handlers ( \
- VL_API_##N, #n, vl_api_##n##_t_handler, 0, vl_api_##n##_t_format, \
- sizeof (vl_api_##n##_t), 0 /* do not trace */, vl_api_##n##_t_tojson, \
- vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size);
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){ \
+ .id = VL_API_##N, \
+ .name = #n, \
+ .handler = vl_api_##n##_t_handler, \
+ .format_fn = vl_api_##n##_t_format, \
+ .size = sizeof (vl_api_##n##_t), \
+ .traced = 0, \
+ .tojson = vl_api_##n##_t_tojson, \
+ .fromjson = vl_api_##n##_t_fromjson, \
+ .calc_size = vl_api_##n##_t_calc_size, \
+ });
foreach_rpc_api_msg;
#undef _
#define _(N, n) \
- vl_msg_api_set_handlers ( \
- VL_API_##N, #n, vl_api_##n##_t_handler, 0, vl_api_##n##_t_format, \
- sizeof (vl_api_##n##_t), 1 /* do trace */, vl_api_##n##_t_tojson, \
- vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size);
- foreach_plugin_trace_msg;
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){ \
+ .id = VL_API_##N, \
+ .name = #n, \
+ .handler = vl_api_##n##_t_handler, \
+ .format_fn = vl_api_##n##_t_format, \
+ .size = sizeof (vl_api_##n##_t), \
+ .traced = 1, \
+ .tojson = vl_api_##n##_t_tojson, \
+ .fromjson = vl_api_##n##_t_fromjson, \
+ .calc_size = vl_api_##n##_t_calc_size, \
+ });
+ foreach_plugin_trace_msg
#undef _
- vl_api_allow_msg_replay (am, VL_API_TRACE_PLUGIN_MSG_IDS, 0);
+ vl_api_allow_msg_replay (am, VL_API_TRACE_PLUGIN_MSG_IDS, 0);
/* No reason to halt the parade to create a trace record... */
vl_api_set_msg_thread_safe (am, VL_API_TRACE_PLUGIN_MSG_IDS, 1);
diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c
index 738c4e5..d2323de 100644
--- a/src/vlibmemory/memory_client.c
+++ b/src/vlibmemory/memory_client.c
@@ -366,10 +366,18 @@
{
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_api_##n##_t_endian, \
- vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 0, vl_api_##n##_t_tojson, \
- vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); \
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){ \
+ .id = VL_API_##N, \
+ .name = #n, \
+ .handler = vl_api_##n##_t_handler, \
+ .endian = vl_api_##n##_t_endian, \
+ .format_fn = vl_api_##n##_t_format, \
+ .size = sizeof (vl_api_##n##_t), \
+ .traced = 0, \
+ .tojson = vl_api_##n##_t_tojson, \
+ .fromjson = vl_api_##n##_t_fromjson, \
+ .calc_size = vl_api_##n##_t_calc_size, \
+ }); \
am->msg_data[VL_API_##N].replay_allowed = 0;
foreach_api_msg;
#undef _
diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c
index 106fcb2..6559f73 100644
--- a/src/vlibmemory/socket_api.c
+++ b/src/vlibmemory/socket_api.c
@@ -796,10 +796,18 @@
return 0;
#define _(N, n, t) \
- vl_msg_api_set_handlers ( \
- VL_API_##N, #n, vl_api_##n##_t_handler, vl_api_##n##_t_endian, \
- vl_api_##n##_t_format, sizeof (vl_api_##n##_t), t, vl_api_##n##_t_tojson, \
- vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); \
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){ \
+ .id = VL_API_##N, \
+ .name = #n, \
+ .handler = vl_api_##n##_t_handler, \
+ .endian = vl_api_##n##_t_endian, \
+ .format_fn = vl_api_##n##_t_format, \
+ .size = sizeof (vl_api_##n##_t), \
+ .traced = t, \
+ .tojson = vl_api_##n##_t_tojson, \
+ .fromjson = vl_api_##n##_t_fromjson, \
+ .calc_size = vl_api_##n##_t_calc_size, \
+ }); \
am->msg_data[VL_API_##N].replay_allowed = 0;
foreach_vlib_api_msg;
#undef _
diff --git a/src/vlibmemory/socket_client.c b/src/vlibmemory/socket_client.c
index 1eccb73..82c6bfe 100644
--- a/src/vlibmemory/socket_client.c
+++ b/src/vlibmemory/socket_client.c
@@ -431,10 +431,18 @@
{
#define _(N, n) \
- vl_msg_api_set_handlers ( \
- VL_API_##N, #n, vl_api_##n##_t_handler, vl_api_##n##_t_endian, \
- vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 0, vl_api_##n##_t_tojson, \
- vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size);
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){ \
+ .id = VL_API_##N, \
+ .name = #n, \
+ .handler = vl_api_##n##_t_handler, \
+ .endian = vl_api_##n##_t_endian, \
+ .format_fn = vl_api_##n##_t_format, \
+ .size = sizeof (vl_api_##n##_t), \
+ .traced = 0, \
+ .tojson = vl_api_##n##_t_tojson, \
+ .fromjson = vl_api_##n##_t_fromjson, \
+ .calc_size = vl_api_##n##_t_calc_size, \
+ });
foreach_sock_client_api_msg;
#undef _
}
diff --git a/src/vnet/srmpls/sr_mpls_api.c b/src/vnet/srmpls/sr_mpls_api.c
index 8642db9..920856a 100644
--- a/src/vnet/srmpls/sr_mpls_api.c
+++ b/src/vnet/srmpls/sr_mpls_api.c
@@ -193,11 +193,18 @@
vec_free (name);
#define _(N, n) \
- vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_##N, #n, \
- vl_api_##n##_t_handler, vl_api_##n##_t_endian, \
- vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 1, \
- vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson, \
- vl_api_##n##_t_calc_size);
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){ \
+ .id = REPLY_MSG_ID_BASE + VL_API_##N, \
+ .name = #n, \
+ .handler = vl_api_##n##_t_handler, \
+ .endian = vl_api_##n##_t_endian, \
+ .format_fn = vl_api_##n##_t_format, \
+ .size = sizeof (vl_api_##n##_t), \
+ .traced = 1, \
+ .tojson = vl_api_##n##_t_tojson, \
+ .fromjson = vl_api_##n##_t_fromjson, \
+ .calc_size = vl_api_##n##_t_calc_size, \
+ });
foreach_vpe_api_msg;
#undef _
@@ -205,23 +212,34 @@
* Manually register the sr policy add msg, so we trace enough bytes
* to capture a typical segment list
*/
- vl_msg_api_set_handlers (
- REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_ADD, "sr_mpls_policy_add",
- vl_api_sr_mpls_policy_add_t_handler, vl_api_sr_mpls_policy_add_t_endian,
- vl_api_sr_mpls_policy_add_t_format, 256, 1,
- vl_api_sr_mpls_policy_add_t_tojson, vl_api_sr_mpls_policy_add_t_fromjson,
- vl_api_sr_mpls_policy_add_t_calc_size);
-
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){
+ .id = REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_ADD,
+ .name = "sr_mpls_policy_add",
+ .handler = vl_api_sr_mpls_policy_add_t_handler,
+ .endian = vl_api_sr_mpls_policy_add_t_endian,
+ .format_fn = vl_api_sr_mpls_policy_add_t_format,
+ .size = 256,
+ .traced = 1,
+ .tojson = vl_api_sr_mpls_policy_add_t_tojson,
+ .fromjson = vl_api_sr_mpls_policy_add_t_fromjson,
+ .calc_size = vl_api_sr_mpls_policy_add_t_calc_size,
+ });
/*
* Manually register the sr policy mod msg, so we trace enough bytes
* to capture a typical segment list
*/
- vl_msg_api_set_handlers (
- REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_MOD, "sr_mpls_policy_mod",
- vl_api_sr_mpls_policy_mod_t_handler, vl_api_sr_mpls_policy_mod_t_endian,
- vl_api_sr_mpls_policy_mod_t_format, 256, 1,
- vl_api_sr_mpls_policy_mod_t_tojson, vl_api_sr_mpls_policy_mod_t_fromjson,
- vl_api_sr_mpls_policy_mod_t_calc_size);
+ vl_msg_api_config (&(vl_msg_api_msg_config_t){
+ .id = REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_MOD,
+ .name = "sr_mpls_policy_mod",
+ .handler = vl_api_sr_mpls_policy_mod_t_handler,
+ .endian = vl_api_sr_mpls_policy_mod_t_endian,
+ .format_fn = vl_api_sr_mpls_policy_mod_t_format,
+ .size = 256,
+ .traced = 1,
+ .tojson = vl_api_sr_mpls_policy_mod_t_tojson,
+ .fromjson = vl_api_sr_mpls_policy_mod_t_fromjson,
+ .calc_size = vl_api_sr_mpls_policy_mod_t_calc_size,
+ });
/*
* Set up the (msg_name, crc, message-id) table