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);
454 name_copy =
format (0,
"%s%c", msg_name, 0);
467 u16 id = ntohs (*((
u16 *) the_msg));
468 u8 *(*handler) (
void *,
void *,
void *);
475 .format =
"api-msg: %s",
502 (*handler) (the_msg,
vm, node);
522 .format =
"api-msg-done: %s",
592 u16 id = ntohs (*((
u16 *) the_msg));
613 u16 id = ntohs (*((
u16 *) the_msg));
646 #define foreach_msg_api_vector \ 649 _(msg_cleanup_handlers) \ 650 _(msg_endian_handlers) \ 651 _(msg_print_handlers) \ 673 clib_warning (
"Trying to register a NULL msg with a NULL msg id!");
674 clib_warning (
"Did you forget to call setup_message_id_table?");
678 #define _(a) vec_validate (am->a, c->id); 684 (
"BUG: re-registering 'vl_api_%s_t_handler'." 685 "Handler was %llx, replaced by %llx",
707 void *endian,
void *print,
int size,
int traced)
712 memset (c, 0,
sizeof (*c));
733 memset (c, 0,
sizeof (*c));
797 snprintf (filename,
sizeof (filename),
"/tmp/api_post_mortem.%d",
800 fp = fopen (filename,
"w");
803 rv = write (2,
"Couldn't create ", 16);
804 rv = write (2, filename, strlen (filename));
805 rv = write (2,
"\n", 1);
812 rv = write (2,
"Failed to save post-mortem API trace to ", 40);
813 rv = write (2, filename, strlen (filename));
814 rv = write (2,
"\n", 1);
827 if (msg_id_host_byte_order > 10000)
828 clib_warning (
"msg_id_host_byte_order endian issue? %d arg vs %d",
829 msg_id_host_byte_order,
830 clib_net_to_host_u16 (msg_id_host_byte_order));
839 int (*fp) (
void *, int);
843 msg_id = clib_net_to_host_u16 (*((
u16 *) mp));
845 msg_id = *((
u16 *) mp);
876 name_copy =
format (0,
"%s%c", name, 0);
881 clib_warning (
"WARNING: duplicate message range registration for '%s'",
887 if (n < 0 || n > 1024)
890 (
"WARNING: bad number of message-IDs (%d) requested by '%s'",
901 rp->
name = name_copy;
919 clib_warning (
"attempt to redefine '%s' ignored...",
string);
931 ASSERT (strlen (
string) < 64);
932 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
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
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)
int elog_trace_api_messages
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)
static u32 elog_id_for_msg_name(vlib_main_t *vm, const char *msg_name)
void vl_msg_api_cleanup_handler(void *the_msg)
memset(h->entries, 0, sizeof(h->entries[0])*entries)
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.
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.
#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)
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.
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.
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.
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)
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.
void vl_msg_pop_heap(void *oldheap)
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)