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, ...) 78 struct sockaddr_in send_data_addr;
106 printf (
"total rx pkts %llu, total rx bytes %llu\n",
109 printf (
"total tx pkts %llu, total tx bytes %llu\n",
115 sb =
format (sb,
"%v,%.0f,%llu,%llu,%llu,%llu\n%c",
131 #define foreach_api_msg \ 132 _(VNET_SUMMARY_STATS_REPLY, vnet_summary_stats_reply) 141 vl_msg_api_set_handlers(VL_API_##N, #n, \ 142 vl_api_##n##_t_handler, \ 144 vl_api_##n##_t_endian, \ 145 vl_api_##n##_t_print, \ 146 sizeof(vl_api_##n##_t), 1); 170 u8 * result = va_arg (*args,
u8 *);
173 if (!
unformat (input,
"%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
176 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
187 int main (
int argc,
char ** argv)
195 u8 * display_name = 0;
196 u16 collector_port = 7654;
203 if (
unformat (input,
"collector-ip %U",
206 else if (
unformat (input,
"display-name %v", &display_name))
208 else if (
unformat (input,
"collector-port %d", &collector_port))
213 (0,
"Usage: %s collector-ip <ip>\n" 214 " [display-name <string>] [collector-port <num>]\n" 215 " port defaults to 7654", argv[0]);
220 if (error == 0 && collector_ip.
as_u32 == (
u32)~0)
229 if (display_name == 0) {
230 display_name =
format (0,
"vpe-to-%d.%d.%d.%d",
231 collector_ip.
as_u8[0],
232 collector_ip.
as_u8[1],
233 collector_ip.
as_u8[2],
234 collector_ip.
as_u8[3]);
260 fformat(stdout,
"Send SIGINT or SIGTERM to quit...\n");
269 memset(mp, 0,
sizeof (*mp));
270 mp->_vl_msg_id = ntohs (VL_API_VNET_GET_SUMMARY_STATS);
275 fformat(stdout,
"Exiting...\n");
int vl_client_connect_to_vlib(char *svm_name, char *client_name, int rx_queue_size)
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
void vl_client_disconnect_from_vlib(void)
unix_shared_memory_queue_t * vl_input_queue
Request for a single block of summary stats.
#define clib_error_report(e)
#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
#define clib_warning(format, args...)
struct vl_shmem_hdr_ * shmem_hdr
uword unformat_ip4_address(unformat_input_t *input, va_list *args)
vl_shmem_hdr_t * shmem_hdr
static void vl_api_vnet_summary_stats_reply_t_handler(vl_api_vnet_summary_stats_reply_t *mp)
void * vl_msg_api_alloc(int nbytes)
int connect_to_vpe(char *name)
#define clib_unix_warning(format, args...)
int disconnect_from_vpe(void)
Reply for vnet_get_summary_stats request.
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)
#define clib_error_return(e, args...)
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