73 u16 msg_id = ntohs (*((
u16 *) msg));
101 this_trace = old_trace;
104 length = clib_net_to_host_u32 (header->
data_len);
108 *this_trace = msg_copy;
144 if (tp == 0 || tp->
nitems == 0)
175 if (!tp || tp->
nitems == 0)
194 vl_api_trace_file_header_t fh;
228 if (fwrite (&fh,
sizeof (fh), 1, fp) != 1)
254 msg_length = clib_host_to_net_u32 (vec_len (msg));
255 if (fwrite (&msg_length, 1,
sizeof (msg_length), fp)
256 !=
sizeof (msg_length))
260 if (fwrite (msg, 1, vec_len (msg), fp) != vec_len (msg))
280 msg_length = clib_host_to_net_u32 (
vec_len (msg));
281 if (fwrite (&msg_length, 1,
sizeof (msg_length), fp)
282 !=
sizeof (msg_length))
305 msg_length = clib_host_to_net_u32 (
vec_len (msg));
306 if (fwrite (&msg_length, 1,
sizeof (msg_length), fp)
307 !=
sizeof (msg_length))
363 memset (tp, 0,
sizeof (*tp));
394 void *the_msg,
int trace_it,
int do_it,
int free_it)
396 u16 id = ntohs (*((
u16 *) the_msg));
397 u8 *(*print_fp) (
void *,
void *);
410 fformat (stdout,
" [no registered print fn]\n");
414 (*print_fp) (the_msg, stdout);
440 #define ELOG_API_MESSAGE_HANDLERS 0 442 #if ELOG_API_MESSAGE_HANDLERS > 0 458 name_copy =
format (0,
"%s%c", msg_name, 0);
472 u16 id = ntohs (*((
u16 *) the_msg));
473 u8 *(*handler) (
void *,
void *,
void *);
475 #if ELOG_API_MESSAGE_HANDLERS > 0 480 .format =
"api-msg: %s",
508 (*handler) (the_msg,
vm, node);
524 #if ELOG_API_MESSAGE_HANDLERS > 0 528 .format =
"api-msg-done: %s",
599 u16 id = ntohs (*((
u16 *) the_msg));
620 u16 id = ntohs (*((
u16 *) the_msg));
653 #define foreach_msg_api_vector \ 656 _(msg_cleanup_handlers) \ 657 _(msg_endian_handlers) \ 658 _(msg_print_handlers) \ 680 clib_warning (
"Trying to register a NULL msg with a NULL msg id!");
681 clib_warning (
"Did you forget to call setup_message_id_table?");
685 #define _(a) vec_validate (am->a, c->id); 691 (
"BUG: re-registering 'vl_api_%s_t_handler'." 692 "Handler was %llx, replaced by %llx",
714 void *endian,
void *print,
int size,
int traced)
719 memset (c, 0,
sizeof (*c));
740 memset (c, 0,
sizeof (*c));
804 snprintf (filename,
sizeof (filename),
"/tmp/api_post_mortem.%d",
807 fp = fopen (filename,
"w");
810 rv = write (2,
"Couldn't create ", 16);
811 rv = write (2, filename, strlen (filename));
812 rv = write (2,
"\n", 1);
819 rv = write (2,
"Failed to save post-mortem API trace to ", 40);
820 rv = write (2, filename, strlen (filename));
821 rv = write (2,
"\n", 1);
834 if (msg_id_host_byte_order > 10000)
835 clib_warning (
"msg_id_host_byte_order endian issue? %d arg vs %d",
836 msg_id_host_byte_order,
837 clib_net_to_host_u16 (msg_id_host_byte_order));
846 int (*fp) (
void *, int);
850 msg_id = clib_net_to_host_u16 (*((
u16 *) mp));
852 msg_id = *((
u16 *) mp);
883 name_copy =
format (0,
"%s%c", name, 0);
888 clib_warning (
"WARNING: duplicate message range registration for '%s'",
894 if (n < 0 || n > 1024)
897 (
"WARNING: bad number of message-IDs (%d) requested by '%s'",
908 rp->
name = name_copy;
926 clib_warning (
"attempt to redefine '%s' ignored...",
string);
938 ASSERT (strlen (
string) < 64);
939 strncpy (version.
name,
string, 64 - 1);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vl_msg_api_set_first_available_msg_id(u16 first_avail)
Message range (belonging to a plugin)
int vl_msg_api_trace_onoff(api_main_t *am, vl_api_trace_which_t which, int onoff)
int vl_msg_api_trace_save(api_main_t *am, vl_api_trace_which_t which, FILE *fp)
void vl_msg_api_set_handlers(int id, char *name, void *handler, void *cleanup, void *endian, void *print, int size, int traced)
int vl_msg_api_trace_free(api_main_t *am, vl_api_trace_which_t which)
u8 * name
name of the plugin
void vl_msg_api_set_cleanup_handler(int msg_id, void *fp)
int vl_msg_api_pd_handler(void *mp, int rv)
void vl_msg_api_handler(void *the_msg)
void * print
message print function
u8 wrapped
trace has wrapped
int size
for sanity checking
static void msg_handler_internal(api_main_t *am, void *the_msg, int trace_it, int do_it, int free_it)
u8 * message_bounce
Don't automatically free message buffer vetor.
static u8 post_mortem_dump_enabled
Message configuration definition.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vl_api_trace_t * vl_msg_api_trace_get(api_main_t *am, vl_api_trace_which_t which)
u32 vl_msg_api_get_msg_length(void *msg_arg)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
api_version_t * api_version_list
api version list
#define hash_set_mem(h, key, value)
int vl_msg_api_trace_configure(api_main_t *am, vl_api_trace_which_t which, u32 nitems)
#define vl_msg_api_barrier_trace_context(X)
void(** msg_cleanup_handlers)(void *)
non-default message cleanup handler vector
void vl_noop_handler(void *mp)
void * cleanup
non-default message cleanup handler
trace_cfg_t * api_trace_cfg
Current trace configuration.
void vl_msg_api_handler_no_trace_no_free(void *the_msg)
void vl_msg_api_cleanup_handler(void *the_msg)
void * endian
message endian function
int svm_queue_sub(svm_queue_t *q, u8 *elem, svm_q_conditional_wait_t cond, u32 time)
vl_api_trace_t * rx_trace
Received message trace configuration.
void vl_msg_api_config(vl_msg_api_msg_config_t *c)
void vl_msg_api_post_mortem_dump_enable_disable(int enable)
#define clib_arch_is_little_endian
#define VL_API_BIG_ENDIAN
int vl_msg_api_tx_trace_enabled(api_main_t *am)
void vl_msg_api_trace_only(void *the_msg)
void vl_msg_api_clean_handlers(int msg_id)
#define hash_create_string(elts, value_bytes)
void vl_msg_api_handler_with_vm_node(api_main_t *am, void *the_msg, vlib_main_t *vm, vlib_node_runtime_t *node)
u16 last_msg_id
last assigned message ID
void vl_msg_api_add_msg_name_crc(api_main_t *am, const char *string, u32 id)
int vl_msg_api_rx_trace_enabled(api_main_t *am)
void(** msg_print_handlers)(void *, void *)
Message print function vector.
int replay_enable
This message can be replayed.
int message_bounce
do not free message after processing
u32 curindex
Current index in circular buffer.
static void cleanup(void)
API main structure, used by both vpp and binary API clients.
u8 enabled
trace is enabled
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
#define clib_arch_is_big_endian
#define vec_free(V)
Free vector's memory (no header).
void vl_msg_api_barrier_release(void)
vl_api_msg_range_t * msg_ranges
vector of message ranges
void vl_msg_api_post_mortem_dump(void)
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
#define ELOG_TYPE_DECLARE(f)
const char ** msg_names
Message name vector.
int replay
is this message to be replayed?
void vl_msg_api_socket_handler(void *the_msg)
vl_api_trace_t * tx_trace
Sent message trace configuration.
static u32 elog_id_for_msg_name(mc_main_t *m, char *msg_name)
u32 data_len
message length not including header
Message header structure.
vl_api_trace_which_t
Trace RX / TX enum.
void vl_msg_api_replay_handler(void *the_msg)
void vl_msg_api_add_version(api_main_t *am, const char *string, u32 major, u32 minor, u32 patch)
void vl_msg_api_handler_no_free(void *the_msg)
void vl_msg_api_free(void *)
u32 missing_clients
Number of missing clients / failed message sends.
u32 vl_msg_api_get_msg_index(u8 *name_and_crc)
void vl_msg_api_increment_missing_client_counter(void)
u16 first_msg_id
first assigned message ID
void vl_msg_api_register_pd_handler(void *fp, u16 msg_id_host_byte_order)
void(** msg_endian_handlers)(void *)
Message endian handler vector.
u32 elog_string(elog_main_t *em, char *fmt,...)
add a string to the event-log string table
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static u32 vl_msg_api_get_msg_length_inline(void *msg_arg)
int(** pd_msg_handlers)(void *, int)
Plaform-dependent (aka hardware) message handler vector.
#define foreach_msg_api_vector
struct _svm_queue svm_queue_t
#define hash_get_mem(h, key)
u16 vl_msg_api_get_msg_ids(const char *name, int n)
u16 first_available_msg_id
First available message ID, for theplugin msg allocator.
u8 endian
trace endianness
void(** msg_handlers)(void *)
Message handler vector.
u8 * is_mp_safe
Message is mp safe vector.
void vl_msg_api_queue_handler(svm_queue_t *q)
void vl_msg_api_trace(api_main_t *am, vl_api_trace_t *tp, void *msg)
int trace_enable
trace this message
int msg_print_flag
Print every received message.
int is_mp_safe
worker thread barrier required?
int traced
is this message to be traced?
const char * region_name
Shared VM binary API region name.
Trace configuration for a single message.
#define VL_API_LITTLE_ENDIAN
uword * msg_index_by_name_and_crc
client message index hash table
uword * msg_range_by_name
Message range by name hash.
char * name
the message name
u32 nitems
Number of trace records.
void * handler
the message handler
void vl_msg_api_barrier_sync(void)