83 u16 msg_id = clib_net_to_host_u16 (*((
u16 *) msg));
111 msg_copy = *old_trace;
113 this_trace = old_trace;
116 length = clib_net_to_host_u32 (header->
data_len);
120 *this_trace = msg_copy;
156 if (tp == 0 || tp->
nitems == 0)
187 if (!tp || tp->
nitems == 0)
217 serialize_likely_small_unsigned_integer (sm, hp->value[0]);
218 serialize_cstring (sm, (char *) hp->key);
229 vl_api_trace_file_header_t fh;
262 fh.msgtbl_size = clib_host_to_net_u32 (
vec_len (m));
264 if (fwrite (&fh,
sizeof (fh), 1, fp) != 1)
270 if (fwrite (m,
vec_len (m), 1, fp) != 1)
297 msg_length = clib_host_to_net_u32 (vec_len (msg));
298 if (fwrite (&msg_length, 1,
sizeof (msg_length), fp)
299 !=
sizeof (msg_length))
303 if (fwrite (msg, 1, vec_len (msg), fp) != vec_len (msg))
323 msg_length = clib_host_to_net_u32 (
vec_len (msg));
324 if (fwrite (&msg_length, 1,
sizeof (msg_length), fp)
325 !=
sizeof (msg_length))
348 msg_length = clib_host_to_net_u32 (
vec_len (msg));
349 if (fwrite (&msg_length, 1,
sizeof (msg_length), fp)
350 !=
sizeof (msg_length))
437 void *the_msg,
int trace_it,
int do_it,
int free_it)
439 u16 id = clib_net_to_host_u16 (*((
u16 *) the_msg));
440 u8 *(*print_fp) (
void *,
void *);
447 .format =
"api-msg: %s",
473 fformat (stdout,
" [no registered print fn]\n");
477 (*print_fp) (the_msg, stdout);
506 .format =
"api-msg-done(%s): %s",
507 .format_args =
"t4T4",
542 u16 id = clib_net_to_host_u16 (*((
u16 *) the_msg));
543 u8 *(*handler) (
void *,
void *,
void *);
544 u8 *(*print_fp) (
void *,
void *);
546 void *save_shmem_hdr;
554 .format =
"api-msg: %s",
582 fformat (stdout,
" [no registered print fn for msg %d]\n",
id);
586 (*print_fp) (the_msg,
vm);
603 (*handler) (the_msg,
vm,
node);
629 .format =
"api-msg-done(%s): %s",
630 .format_args =
"t4T4",
650 ed->barrier = is_mp_safe;
707 u16 id = clib_net_to_host_u16 (*((
u16 *) the_msg));
728 u16 id = clib_net_to_host_u16 (*((
u16 *) the_msg));
761 #define foreach_msg_api_vector \ 764 _(msg_cleanup_handlers) \ 765 _(msg_endian_handlers) \ 766 _(msg_print_handlers) \ 788 clib_warning (
"Trying to register a NULL msg with a NULL msg id!");
789 clib_warning (
"Did you forget to call setup_message_id_table?");
793 #define _(a) vec_validate (am->a, c->id); 799 (
"BUG: re-registering 'vl_api_%s_t_handler'." 800 "Handler was %llx, replaced by %llx",
822 void *endian,
void *print,
int size,
int traced)
912 snprintf (filename,
sizeof (filename),
"/tmp/api_post_mortem.%d",
915 fp = fopen (filename,
"w");
918 rv = write (2,
"Couldn't create ", 16);
919 rv = write (2, filename, strlen (filename));
920 rv = write (2,
"\n", 1);
927 rv = write (2,
"Failed to save post-mortem API trace to ", 40);
928 rv = write (2, filename, strlen (filename));
929 rv = write (2,
"\n", 1);
942 if (msg_id_host_byte_order > 10000)
943 clib_warning (
"msg_id_host_byte_order endian issue? %d arg vs %d",
944 msg_id_host_byte_order,
945 clib_net_to_host_u16 (msg_id_host_byte_order));
954 int (*fp) (
void *, int);
958 msg_id = clib_net_to_host_u16 (*((
u16 *) mp));
960 msg_id = *((
u16 *) mp);
991 name_copy =
format (0,
"%s%c", name, 0);
996 clib_warning (
"WARNING: duplicate message range registration for '%s'",
1002 if (n < 0 || n > 1024)
1005 (
"WARNING: bad number of message-IDs (%d) requested by '%s'",
1016 rp->
name = name_copy;
1034 clib_warning (
"attempt to redefine '%s' ignored...",
string);
1046 ASSERT (strlen (
string) < 64);
1047 strncpy (version.
name,
string, 64 - 1);
1069 pthread_mutex_lock (&vlib_rp->
mutex);
1084 pthread_mutex_unlock (&vlib_rp->
mutex);
1099 str->
length = htonl (len);
1100 return len +
sizeof (
u32);
1108 str->
length = htonl (len);
1109 return len +
sizeof (
u32);
1122 return clib_net_to_host_u32 (astr->
length);
#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)
int vl_api_to_api_string(u32 len, const char *buf, vl_api_string_t *str)
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
static void svm_pop_heap(void *oldheap)
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
Optimized string handling code, including c11-compliant "safe C library" variants.
int size
for sanity checking
#define clib_memcpy_fast(a, b, c)
static void msg_handler_internal(api_main_t *am, void *the_msg, int trace_it, int do_it, int free_it)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
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)
void vl_msg_api_set_global_main(void *am_arg)
#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)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define clib_memcpy(d, s, n)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
void vl_msg_api_cleanup_handler(void *the_msg)
void * endian
message endian function
u8 * vl_api_from_api_to_vec(vl_api_string_t *astr)
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.
static void * svm_push_data_heap(svm_region_t *rp)
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
svm_region_t * vlib_rp
Current binary api segment descriptor.
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
#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)
u16 last_msg_id
last assigned message ID
int vl_api_get_elog_trace_api_messages(void)
int elog_trace_api_messages
void vl_msg_pop_heap_w_region(svm_region_t *vlib_rp, void *oldheap)
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)
u32 vl_api_string_len(vl_api_string_t *astr)
elog_main_t * elog_main
event log
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
void vl_msg_api_handler_with_vm_node(api_main_t *am, svm_region_t *vlib_rp, void *the_msg, vlib_main_t *vm, vlib_node_runtime_t *node, u8 is_private)
void serialize_open_vector(serialize_main_t *m, u8 *vector)
#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...)
int vl_api_set_elog_trace_api_messages(int enable)
static void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
blocking call - best used in combination with condvars, for eventfds we don't yield the cpu ...
#define ELOG_TYPE_DECLARE(f)
const char ** msg_names
Message name vector.
vlib_main_t vlib_node_runtime_t * node
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 uword hash_elts(void *v)
__thread api_main_t * my_api_main
api_main_t api_global_main
u32 data_len
message length not including header
Message header structure.
vl_api_trace_which_t
Trace RX / TX enum.
u8 * vl_api_serialize_message_table(api_main_t *am, u8 *vector)
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 *)
void vl_api_set_elog_main(elog_main_t *m)
u32 missing_clients
Number of missing clients / failed message sends.
void * vl_msg_push_heap(void)
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)
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
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.
static api_main_t * vlibapi_get_main(void)
void vl_msg_pop_heap(void *oldheap)
u8 * vl_api_from_api_string(vl_api_string_t *astr)
u8 * vl_api_format_string(u8 *s, va_list *args)
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.
void * serialize_close_vector(serialize_main_t *m)
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.
void * vl_msg_push_heap_w_region(svm_region_t *vlib_rp)
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.
int vl_api_vec_to_api_string(const u8 *vec, vl_api_string_t *str)
void * handler
the message handler
void vl_msg_api_barrier_sync(void)