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);
437 #define ELOG_API_MESSAGE_HANDLERS 0 439 #if ELOG_API_MESSAGE_HANDLERS > 0 455 name_copy =
format (0,
"%s%c", msg_name, 0);
469 u16 id = ntohs (*((
u16 *) the_msg));
470 u8 *(*handler) (
void *,
void *,
void *);
472 #if ELOG_API_MESSAGE_HANDLERS > 0 477 .format =
"api-msg: %s",
502 (*handler) (the_msg,
vm, node);
518 #if ELOG_API_MESSAGE_HANDLERS > 0 522 .format =
"api-msg-done: %s",
593 u16 id = ntohs (*((
u16 *) the_msg));
614 u16 id = ntohs (*((
u16 *) the_msg));
641 #define foreach_msg_api_vector \ 644 _(msg_cleanup_handlers) \ 645 _(msg_endian_handlers) \ 646 _(msg_print_handlers) \ 658 #define _(a) vec_validate (am->a, c->id); 663 clib_warning (
"BUG: multiple registrations of 'vl_api_%s_t_handler'",
685 void *endian,
void *print,
int size,
int traced)
690 memset (c, 0,
sizeof (*c));
763 snprintf (filename,
sizeof (filename),
"/tmp/api_post_mortem.%d",
766 fp = fopen (filename,
"w");
769 rv = write (2,
"Couldn't create ", 16);
770 rv = write (2, filename, strlen (filename));
771 rv = write (2,
"\n", 1);
778 rv = write (2,
"Failed to save post-mortem API trace to ", 40);
779 rv = write (2, filename, strlen (filename));
780 rv = write (2,
"\n", 1);
793 if (msg_id_host_byte_order > 10000)
794 clib_warning (
"msg_id_host_byte_order endian issue? %d arg vs %d",
795 msg_id_host_byte_order,
796 clib_net_to_host_u16 (msg_id_host_byte_order));
805 int (*fp) (
void *, int);
809 msg_id = clib_net_to_host_u16 (*((
u16 *) mp));
811 msg_id = *((
u16 *) mp);
842 name_copy =
format (0,
"%s%c", name, 0);
847 clib_warning (
"WARNING: duplicate message range registration for '%s'",
853 if (n < 0 || n > 1024)
856 (
"WARNING: bad number of message-IDs (%d) requested by '%s'",
867 rp->
name = name_copy;
885 clib_warning (
"attempt to redefine '%s' ignored...",
string);
#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)
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)
sll srl srl sll sra u16x4 i
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)
static void msg_handler_internal(api_main_t *am, void *the_msg, int trace_it, int do_it, int free_it)
static u8 post_mortem_dump_enabled
#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)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#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(** msg_cleanup_handlers)(void *)
void vl_noop_handler(void *mp)
trace_cfg_t * api_trace_cfg
static void cleanup(void)
void vl_msg_api_handler_no_trace_no_free(void *the_msg)
void vl_msg_api_add_msg_name_crc(api_main_t *am, char *string, u32 id)
void vl_msg_api_cleanup_handler(void *the_msg)
vl_api_trace_t * rx_trace
void vl_msg_api_config(vl_msg_api_msg_config_t *c)
void vl_msg_api_free(void *)
void vl_msg_api_post_mortem_dump_enable_disable(int enable)
#define clib_arch_is_little_endian
int vl_msg_api_tx_trace_enabled(api_main_t *am)
void vl_msg_api_trace_only(void *the_msg)
#define hash_create_string(elts, value_bytes)
void vl_msg_api_queue_handler(unix_shared_memory_queue_t *q)
void vl_msg_api_handler_with_vm_node(api_main_t *am, void *the_msg, vlib_main_t *vm, vlib_node_runtime_t *node)
int vl_msg_api_rx_trace_enabled(api_main_t *am)
void(** msg_print_handlers)(void *, void *)
#define clib_arch_is_big_endian
int unix_shared_memory_queue_sub(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
#define VL_API_LITTLE_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
void vl_msg_api_post_mortem_dump(void)
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
#define ELOG_TYPE_DECLARE(f)
void vl_msg_api_socket_handler(void *the_msg)
vl_api_trace_t * tx_trace
static u32 elog_id_for_msg_name(mc_main_t *m, char *msg_name)
#define VL_API_BIG_ENDIAN
void vl_msg_api_replay_handler(void *the_msg)
void vl_msg_api_handler_no_free(void *the_msg)
void vl_msg_api_increment_missing_client_counter(void)
void vl_msg_api_register_pd_handler(void *fp, u16 msg_id_host_byte_order)
void(** msg_endian_handlers)(void *)
u32 elog_string(elog_main_t *em, char *fmt,...)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
int(** pd_msg_handlers)(void *, int)
#define foreach_msg_api_vector
#define hash_get_mem(h, key)
u16 first_available_msg_id
void(** msg_handlers)(void *)
void vl_msg_api_trace(api_main_t *am, vl_api_trace_t *tp, void *msg)
u16 vl_msg_api_get_msg_ids(char *name, int n)
uword * msg_index_by_name_and_crc
uword * msg_range_by_name
struct _unix_shared_memory_queue unix_shared_memory_queue_t
void vl_msg_api_barrier_sync(void)