22 #include <sys/types.h> 23 #include <sys/socket.h> 26 #include <netinet/in.h> 57 #define f64_print(a,b) 68 #define vl_print(handle, ...) 79 struct sockaddr_in send_data_addr;
111 printf (
"total rx pkts %llu, total rx bytes %llu\n",
114 printf (
"total tx pkts %llu, total tx bytes %llu\n",
120 sb =
format (sb,
"%v,%.0f,%llu,%llu,%llu,%llu\n%c",
136 #define foreach_api_msg \ 137 _(VNET_GET_SUMMARY_STATS_REPLY, vnet_get_summary_stats_reply) 147 vl_msg_api_set_handlers(VL_API_##N, #n, \ 148 vl_api_##n##_t_handler, \ 150 vl_api_##n##_t_endian, \ 151 vl_api_##n##_t_print, \ 152 sizeof(vl_api_##n##_t), 1); 179 u8 *result = va_arg (*args,
u8 *);
182 if (!
unformat (input,
"%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
185 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
205 u8 *display_name = 0;
206 u16 collector_port = 7654;
214 if (
unformat (input,
"collector-ip %U",
217 else if (
unformat (input,
"display-name %v", &display_name))
219 else if (
unformat (input,
"collector-port %d", &collector_port))
225 (0,
"Usage: %s collector-ip <ip>\n" 226 " [display-name <string>] [collector-port <num>]\n" 227 " port defaults to 7654", argv[0]);
232 if (error == 0 && collector_ip.
as_u32 == (
u32) ~ 0)
242 if (display_name == 0)
244 display_name =
format (0,
"vpe-to-%d.%d.%d.%d",
245 collector_ip.
as_u8[0],
246 collector_ip.
as_u8[1],
247 collector_ip.
as_u8[2], collector_ip.
as_u8[3]);
274 fformat (stdout,
"Send SIGINT or SIGTERM to quit...\n");
284 memset (mp, 0,
sizeof (*mp));
285 mp->_vl_msg_id = ntohs (VL_API_VNET_GET_SUMMARY_STATS);
290 fformat (stdout,
"Exiting...\n");
vlib_main_t vlib_global_main
vlib_main_t ** vlib_mains
Fixed length block allocator.
unix_shared_memory_queue_t * vl_input_queue
int my_client_index
All VLIB-side message handlers use my_client_index to identify the queue / client.
Request for a single block of summary stats.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void sigterm_handler(int sig)
struct sockaddr_in send_data_addr
int vl_client_connect_to_vlib(const char *svm_name, const char *client_name, int rx_queue_size)
#define clib_error_return(e, args...)
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
static void vl_api_vnet_get_summary_stats_reply_t_handler(vl_api_vnet_get_summary_stats_reply_t *mp)
void * vl_msg_api_alloc(int nbytes)
uword unformat_ip4_address(unformat_input_t *input, va_list *args)
vl_shmem_hdr_t * shmem_hdr
API main structure, used by both vpp and binary API clients.
#define clib_warning(format, args...)
int connect_to_vpe(char *name)
int disconnect_from_vpe(void)
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
Bitmaps built as vectors of machine words.
#define clib_error_report(e)
volatile int sigterm_received
int main(int argc, char **argv)
unix_shared_memory_queue_t * vl_input_queue
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void vl_client_disconnect_from_vlib(void)
#define clib_unix_warning(format, args...)
Reply for vnet_get_summary_stats request.
void vlib_cli_output(struct vlib_main_t *vm, char *fmt,...)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
struct _unix_shared_memory_queue unix_shared_memory_queue_t