diff options
author | Damjan Marion <damarion@cisco.com> | 2022-05-18 22:16:11 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2022-05-19 18:32:23 +0200 |
commit | cada9eb7894117db898f7c4def92cba5511baa4f (patch) | |
tree | 4cf552e2ad9e67b8bbc144eb5c6cb9aad0a8424b /src/vlibmemory/memory_client.c | |
parent | bf95e3efde3402cf2f7beaf6d70433646cc68280 (diff) |
api: refactor api data storage
single struct to hold all api handler, flags, etc.
Provide functions to toggle flags instead of writing directly to
internal data.
Type: refactor
Change-Id: I4730d7290e57489de8eda34a72211527e015b721
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlibmemory/memory_client.c')
-rw-r--r-- | src/vlibmemory/memory_client.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c index 585fca67998..330390e9b1a 100644 --- a/src/vlibmemory/memory_client.c +++ b/src/vlibmemory/memory_client.c @@ -377,7 +377,7 @@ vl_client_install_client_message_handlers (void) vl_api_##n##_t_endian, vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 0, \ vl_api_##n##_t_print_json, vl_api_##n##_t_tojson, \ vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); \ - am->api_trace_cfg[VL_API_##N].replay_enable = 0; + am->msg_data[VL_API_##N].replay_allowed = 0; foreach_api_msg; #undef _ } @@ -562,6 +562,8 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name) vl_api_get_first_msg_id_t *mp; api_main_t *am = vlibapi_get_main (); memory_client_main_t *mm = vlibapi_get_memory_client_main (); + vl_api_msg_data_t *m = + vl_api_get_msg_data (am, VL_API_GET_FIRST_MSG_ID_REPLY); f64 timeout; void *old_handler; clib_time_t clib_time; @@ -574,12 +576,11 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name) clib_time_init (&clib_time); /* Push this plugin's first_msg_id_reply handler */ - old_handler = am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY]; - am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = (void *) - vl_api_get_first_msg_id_reply_t_handler; - if (!am->msg_calc_size_funcs[VL_API_GET_FIRST_MSG_ID_REPLY]) + old_handler = m->handler; + m->handler = (void *) vl_api_get_first_msg_id_reply_t_handler; + if (!m->calc_size_func) { - am->msg_calc_size_funcs[VL_API_GET_FIRST_MSG_ID_REPLY] = + m->calc_size_func = (uword (*) (void *)) vl_api_get_first_msg_id_reply_t_calc_size; } @@ -608,7 +609,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name) sock_err: /* Restore old handler */ - am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = old_handler; + m->handler = old_handler; return -1; } @@ -633,7 +634,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name) } } /* Restore old handler */ - am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = old_handler; + m->handler = old_handler; return rv; } @@ -641,7 +642,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name) result: /* Restore the old handler */ - am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = old_handler; + m->handler = old_handler; if (rv == (u16) ~ 0) clib_warning ("plugin '%s' not registered", plugin_name); |