-msg_api_config (vl_msg_api_msg_config_t * c)
-{
- rd_cp_main_t *rm = &rd_cp_main;
-
- vec_validate (rm->msg_handlers, c->id);
-
- if (rm->msg_handlers[c->id] && rm->msg_handlers[c->id] != c->handler)
- clib_warning
- ("BUG: re-registering 'vl_api_%s_t_handler'."
- "Handler was %llx, replaced by %llx",
- c->name, rm->msg_handlers[c->id], c->handler);
-
- rm->msg_handlers[c->id] = c->handler;
-}
-
-static void
-set_handler (int id, char *name, void *handler)
-{
- vl_msg_api_msg_config_t cfg;
- vl_msg_api_msg_config_t *c = &cfg;
-
- memset (c, 0, sizeof (*c));
-
- c->id = id;
- c->name = name;
- c->handler = handler;
- c->replay = 1;
- c->message_bounce = 0;
- c->is_mp_safe = 0;
- msg_api_config (c);
-}
-
-static_always_inline void
-check_queue (void)
-{
- rd_cp_main_t *rm = &rd_cp_main;
- uword msgp;
-
- if (!rm->api_connected)
- return;
-
- if (svm_queue_sub2 (rm->vl_input_queue, (u8 *) & msgp))
- return;
-
- u16 id = ntohs (*((u16 *) msgp));
- u8 *(*handler) (void *);
-
- if (id < vec_len (rm->msg_handlers) && rm->msg_handlers[id])
- {
- handler = (void *) rm->msg_handlers[id];
- (*handler) ((void *) msgp);
- }
- else
- {
- if (id != VL_API_MEMCLNT_KEEPALIVE)
- clib_warning ("no handler for msg id %d", id);
- }
-}
-
-static_always_inline int
-wait_for_reply (void)
-{
- rd_cp_main_t *rm = &rd_cp_main;
- vlib_main_t *vm = rm->vlib_main;
- f64 timeout;
-
- timeout = vlib_time_now (vm) + 1.0;
- while (vlib_time_now (vm) < timeout)
- {
- check_queue ();
- if (rm->api_reply.arrived)
- break;
- vlib_process_suspend (vm, 1e-5);
- }
-
- if (!rm->api_reply.arrived)
- return 1;
-
- return rm->api_reply.retval;
-}
-
-static_always_inline void
-send_msg (void *msg)
-{
- rd_cp_main_t *rm = &rd_cp_main;
-
- vl_msg_api_send_shmem (rm->api_main->shmem_hdr->vl_input_queue,
- (u8 *) & msg);
-}
-
-static_always_inline int
-send_msg_and_wait_for_reply (void *msg)
-{
- rd_cp_main_t *rm = &rd_cp_main;
-
- rm->api_reply.arrived = 0;
- send_msg (msg);
- return wait_for_reply ();
-}
-
-static int