22 #define _(sym, str) str, 36 u8 *
a = va_arg (*args,
u8 *);
37 return format (s,
"%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
44 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
48 i_first_zero = i_max_n_zero;
53 if (is_zero && i_first_zero >= ARRAY_LEN (a->
as_u16))
59 if ((!is_zero && n_zeros > max_n_zeros)
62 i_max_n_zero = i_first_zero;
63 max_n_zeros = n_zeros;
69 last_double_colon = 0;
72 if (i == i_max_n_zero && max_n_zeros > 1)
76 last_double_colon = 1;
81 (last_double_colon || i == 0) ?
"" :
":",
82 clib_net_to_host_u16 (a->
as_u16[i]));
83 last_double_colon = 0;
94 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
120 i32 error = va_arg (*args,
u32);
126 s =
format (s,
"%s", p[0]);
128 s =
format (s,
"%d", error);
138 #define _(n,v,s) hash_set (em->error_string_by_error_number, -v, s); 152 session->session_index);
158 u32 session_type = va_arg (*args,
u32);
159 switch (session_type)
162 return format (s,
"Qsession");
164 return format (s,
"Stream");
166 return format (s,
"Lsession");
170 return format (s,
"BadSession");
176 u32 session_state = va_arg (*args,
u32);
177 switch (session_state)
180 return format (s,
"ECHO_SESSION_STATE_INITIAL (%u)", session_state);
182 return format (s,
"ECHO_SESSION_STATE_READY (%u)", session_state);
184 return format (s,
"ECHO_SESSION_STATE_AWAIT_CLOSING (%u)",
187 return format (s,
"ECHO_SESSION_STATE_AWAIT_DATA (%u)", session_state);
189 return format (s,
"ECHO_SESSION_STATE_CLOSING (%u)", session_state);
191 return format (s,
"ECHO_SESSION_STATE_CLOSED (%u)", session_state);
195 return format (s,
"unknown session state (%u)", session_state);
203 return format (s,
"STATE_START (%u)", state);
205 return format (s,
"STATE_ATTACHED (%u)", state);
207 return format (s,
"STATE_ATTACHED_NO_CERT (%u)", state);
209 return format (s,
"STATE_LISTEN (%u)", state);
211 return format (s,
"STATE_READY (%u)", state);
213 return format (s,
"STATE_DATA_DONE (%u)", state);
215 return format (s,
"STATE_DISCONNECTED (%u)", state);
217 return format (s,
"STATE_DETACHED (%u)", state);
219 return format (s,
"unknown state (%u)", state);
225 u8 *
a = va_arg (*args,
u8 *);
240 u8 *
a = va_arg (*args,
u8 *);
243 else if (
unformat (input,
"qconnected"))
245 else if (
unformat (input,
"qconnect"))
247 else if (
unformat (input,
"sconnected"))
249 else if (
unformat (input,
"sconnect"))
251 else if (
unformat (input,
"lastbyte"))
263 f64 bps = va_arg (*args,
f64) * 8;
265 return format (s,
"%.3f Gb/s", bps / 1e9);
267 return format (s,
"%.3f Mb/s", bps / 1e6);
269 return format (s,
"%.3f Kb/s", bps / 1e3);
271 return format (s,
"%.3f b/s", bps);
277 u32 timing_event = va_arg (*args,
u32);
279 return format (s,
"start");
281 return format (s,
"qconnect");
283 return format (s,
"qconnected");
285 return format (s,
"sconnect");
287 return format (s,
"sconnected");
289 return format (s,
"lastbyte");
291 return format (s,
"exit");
293 return format (s,
"unknown timing event");
301 *proto = TRANSPORT_PROTO_TCP;
303 *proto = TRANSPORT_PROTO_TCP;
305 *proto = TRANSPORT_PROTO_UDPC;
307 *proto = TRANSPORT_PROTO_UDPC;
309 *proto = TRANSPORT_PROTO_UDP;
311 *proto = TRANSPORT_PROTO_UDP;
313 *proto = TRANSPORT_PROTO_SCTP;
315 *proto = TRANSPORT_PROTO_SCTP;
317 *proto = TRANSPORT_PROTO_TLS;
319 *proto = TRANSPORT_PROTO_TLS;
321 *proto = TRANSPORT_PROTO_QUIC;
323 *proto = TRANSPORT_PROTO_QUIC;
332 u32 transport_proto = va_arg (*args,
u32);
333 switch (transport_proto)
335 case TRANSPORT_PROTO_TCP:
338 case TRANSPORT_PROTO_UDP:
341 case TRANSPORT_PROTO_SCTP:
344 case TRANSPORT_PROTO_NONE:
347 case TRANSPORT_PROTO_TLS:
350 case TRANSPORT_PROTO_UDPC:
353 case TRANSPORT_PROTO_QUIC:
357 s =
format (s,
"UNKNOWN");
366 u8 *result = va_arg (*args,
u8 *);
369 if (!
unformat (input,
"%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
372 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
388 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
389 uword c, n_colon, double_colon_index;
391 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
392 double_colon_index =
ARRAY_LEN (hex_quads);
396 if (c >=
'0' && c <=
'9')
398 else if (c >=
'a' && c <=
'f')
399 hex_digit = c + 10 -
'a';
400 else if (c >=
'A' && c <=
'F')
401 hex_digit = c + 10 -
'A';
402 else if (c ==
':' && n_colon < 2)
411 if (n_hex_quads >=
ARRAY_LEN (hex_quads))
416 hex_quad = (hex_quad << 4) | hex_digit;
419 if (n_hex_digits >= 4)
430 if (double_colon_index <
ARRAY_LEN (hex_quads))
432 double_colon_index = n_hex_quads;
435 if (n_colon > 0 && n_hex_digits > 0)
437 hex_quads[n_hex_quads++] = hex_quad;
443 if (n_hex_digits > 0)
444 hex_quads[n_hex_quads++] = hex_quad;
450 if (double_colon_index <
ARRAY_LEN (hex_quads))
454 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
455 hex_quads[n_zero + i] = hex_quads[i];
457 for (i = 0; i < n_zero; i++)
458 hex_quads[double_colon_index + i] = 0;
467 for (i = 0; i <
ARRAY_LEN (hex_quads); i++)
468 result->
as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
477 ip46_address_t *
ip = va_arg (*args, ip46_address_t *);
493 return format (s,
"mbedtls");
495 return format (s,
"openssl");
497 return format (s,
"picotls");
501 return format (s,
"unknown crypto engine");
507 u8 *
a = va_arg (*args,
u8 *);
510 else if (
unformat (input,
"openssl"))
512 else if (
unformat (input,
"picotls"))
534 ECHO_LOG (3,
"hash_unset(0x%lx)", handle);
539 ECHO_LOG (3,
"hash_set(0x%lx) S[%d]", handle, sid);
562 ECHO_FAIL (ECHO_FAIL_RPC_SIZE,
"RPC lock failed");
568 ECHO_FAIL (ECHO_FAIL_RPC_SIZE,
"RPC ring is full");
589 ECHO_LOG (2,
"unknown handle 0x%lx", handle);
602 if (em->
state == state)
627 ECHO_LOG (1,
"Session 0x%x done in %.6fs RX[%.4f] TX[%.4f] Gbit/s\n",
#define hash_set(h, key, value)
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
static u8 svm_msg_q_ring_is_full(svm_msg_q_t *mq, u32 ring_index)
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
u8 * echo_format_timing_event(u8 *s, va_list *args)
u8 * echo_format_session(u8 *s, va_list *args)
#define hash_unset(h, key)
uword unformat_ip6_address(unformat_input_t *input, va_list *args)
echo_session_t * sessions
u8 * format_ip6_address(u8 *s, va_list *args)
clib_spinlock_t sid_vpp_handles_lock
static f64 clib_time_now(clib_time_t *c)
uword echo_unformat_timing_event(unformat_input_t *input, va_list *args)
uword unformat_ip4_address(unformat_input_t *input, va_list *args)
volatile connection_state_t state
char * echo_fail_code_str[]
uword echo_unformat_crypto_engine(unformat_input_t *input, va_list *args)
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
int wait_for_state_change(echo_main_t *em, connection_state_t state, f64 timeout)
foreach_app_session_field u64 vpp_session_handle
struct echo_main_t::@572 timing
#define clib_memcpy(d, s, n)
u8 * echo_format_session_state(u8 *s, va_list *args)
echo_session_t * echo_session_new(echo_main_t *em)
volatile u64 bytes_received
void echo_session_handle_add_del(echo_main_t *em, u64 handle, u32 sid)
#define ECHO_FAIL(fail, _fmt, _args...)
uword unformat_ip46_address(unformat_input_t *input, va_list *args)
vl_api_fib_path_type_t type
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void init_error_string_table()
u8 * echo_format_bytes_per_sec(u8 *s, va_list *args)
u8 * echo_format_app_state(u8 *s, va_list *args)
uword * error_string_by_error_number
#define SESSION_INVALID_INDEX
u8 * format_ip46_address(u8 *s, va_list *args)
enum echo_test_evt_ echo_test_evt_t
static void svm_msg_q_unlock(svm_msg_q_t *mq)
Unlock message queue.
u8 * format_ip4_address(u8 *s, va_list *args)
#define ECHO_LOG(lvl, _fmt, _args...)
void echo_notify_event(echo_main_t *em, echo_test_evt_t e)
uword unformat_transport_proto(unformat_input_t *input, va_list *args)
#define foreach_vnet_api_error
int echo_send_rpc(echo_main_t *em, void *fp, echo_rpc_args_t *args)
#define hash_create(elts, value_bytes)
void svm_msg_q_add_and_unlock(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Producer enqueue one message to queue with mutex held.
volatile u32 nxt_available_sidx
echo_session_t * echo_get_session_from_handle(echo_main_t *em, u64 handle)
u8 * echo_format_session_type(u8 *s, va_list *args)
#define clib_atomic_fetch_add(a, b)
u8 * format_api_error(u8 *s, va_list *args)
uword * session_index_by_vpp_handles
svm_msg_q_t * rpc_msq_queue
vl_api_dhcp_client_state_t state
static int svm_msg_q_lock(svm_msg_q_t *mq)
Lock, or block trying, the message queue.
void echo_session_print_stats(echo_main_t *em, echo_session_t *session)
u8 * echo_format_crypto_engine(u8 *s, va_list *args)
svm_msg_q_msg_t svm_msg_q_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index)
Allocate message buffer on ring.
uword echo_unformat_close(unformat_input_t *input, va_list *args)
u8 * format_transport_proto(u8 *s, va_list *args)