#include <vlib/unix/unix.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
+#include <vlibapi/api_helper_macros.h>
/**
* @file
#include <vlibmemory/vl_memory_api_h.h>
#undef vl_endianfun
+#define vl_calcsizefun
+#include <vlibmemory/vl_memory_api_h.h>
+#undef vl_calcsizefun
+
static void
vl_api_get_first_msg_id_t_handler (vl_api_get_first_msg_id_t *mp)
{
vl_api_send_msg (reg, (u8 *) rmp);
}
+static void
+vl_api_control_ping_t_handler (vl_api_control_ping_t *mp)
+{
+ vl_api_control_ping_reply_t *rmp;
+ int rv = 0;
+
+ REPLY_MACRO2 (VL_API_CONTROL_PING_REPLY,
+ ({ rmp->vpe_pid = ntohl (getpid ()); }));
+}
+
#define foreach_vlib_api_msg \
_ (GET_FIRST_MSG_ID, get_first_msg_id) \
- _ (API_VERSIONS, api_versions)
+ _ (API_VERSIONS, api_versions) \
+ _ (CONTROL_PING, control_ping)
/*
* vl_api_init
static int
vlib_api_init (void)
{
+ api_main_t *am = vlibapi_get_main ();
vl_msg_api_msg_config_t cfg;
vl_msg_api_msg_config_t *c = &cfg;
c->cleanup = vl_noop_handler; \
c->endian = vl_api_##n##_t_endian; \
c->print = vl_api_##n##_t_print; \
+ c->print_json = vl_api_##n##_t_print_json; \
+ c->tojson = vl_api_##n##_t_tojson; \
+ c->fromjson = vl_api_##n##_t_fromjson; \
+ c->calc_size = vl_api_##n##_t_calc_size; \
c->size = sizeof (vl_api_##n##_t); \
c->traced = 1; /* trace, so these msgs print */ \
c->replay = 0; /* don't replay client create/delete msgs */ \
foreach_vlib_api_msg;
#undef _
+ am->is_mp_safe[VL_API_CONTROL_PING] = 1;
+ am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
+
return 0;
}
vec_add (long_msg, msg, msg_len);
}
msg = long_msg;
+ msg_len = vec_len (long_msg);
}
- vl_msg_api_handler_no_trace_no_free (msg);
+ vl_msg_api_handler_no_trace_no_free (msg, msg_len);
}
/* Free what we've been given. */
{
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_noop_handler, \
- vl_api_##n##_t_print, sizeof (vl_api_##n##_t), \
- 0 /* do not trace */, vl_api_##n##_t_print_json, \
- vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson);
+ vl_msg_api_set_handlers ( \
+ VL_API_##N, #n, vl_api_##n##_t_handler, vl_noop_handler, vl_noop_handler, \
+ vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 0 /* do not trace */, \
+ vl_api_##n##_t_print_json, vl_api_##n##_t_tojson, \
+ vl_api_##n##_t_fromjson, 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, \
- vl_noop_handler, vl_noop_handler, \
- vl_api_##n##_t_print, sizeof (vl_api_##n##_t), \
- 1 /* do trace */, vl_api_##n##_t_print_json, \
- vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson);
+ vl_msg_api_set_handlers ( \
+ VL_API_##N, #n, vl_api_##n##_t_handler, vl_noop_handler, vl_noop_handler, \
+ vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 1 /* do trace */, \
+ vl_api_##n##_t_print_json, vl_api_##n##_t_tojson, \
+ vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size);
foreach_plugin_trace_msg;
#undef _