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]);
43 ip6_address_t *
a = va_arg (*args, ip6_address_t *);
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;
50 for (i = 0; i <
ARRAY_LEN (a->as_u16); i++)
52 u32 is_zero = a->as_u16[
i] == 0;
53 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
59 if ((!is_zero && n_zeros > max_n_zeros)
60 || (i + 1 >=
ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
62 i_max_n_zero = i_first_zero;
63 max_n_zeros = n_zeros;
69 last_double_colon = 0;
70 for (i = 0; i <
ARRAY_LEN (a->as_u16); i++)
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 *);
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_UDP;
307 *proto = TRANSPORT_PROTO_UDP;
309 *proto = TRANSPORT_PROTO_TLS;
311 *proto = TRANSPORT_PROTO_TLS;
313 *proto = TRANSPORT_PROTO_QUIC;
315 *proto = TRANSPORT_PROTO_QUIC;
325 switch (transport_proto)
327 case TRANSPORT_PROTO_TCP:
330 case TRANSPORT_PROTO_UDP:
333 case TRANSPORT_PROTO_NONE:
336 case TRANSPORT_PROTO_TLS:
339 case TRANSPORT_PROTO_QUIC:
343 s =
format (s,
"UNKNOWN");
352 u8 *result = va_arg (*args,
u8 *);
355 if (!
unformat (input,
"%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
358 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
372 ip6_address_t *result = va_arg (*args, ip6_address_t *);
374 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
375 uword c, n_colon, double_colon_index;
377 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
378 double_colon_index =
ARRAY_LEN (hex_quads);
382 if (c >=
'0' && c <=
'9')
384 else if (c >=
'a' && c <=
'f')
385 hex_digit = c + 10 -
'a';
386 else if (c >=
'A' && c <=
'F')
387 hex_digit = c + 10 -
'A';
388 else if (c ==
':' && n_colon < 2)
397 if (n_hex_quads >=
ARRAY_LEN (hex_quads))
402 hex_quad = (hex_quad << 4) | hex_digit;
405 if (n_hex_digits >= 4)
416 if (double_colon_index <
ARRAY_LEN (hex_quads))
418 double_colon_index = n_hex_quads;
421 if (n_colon > 0 && n_hex_digits > 0)
423 hex_quads[n_hex_quads++] = hex_quad;
429 if (n_hex_digits > 0)
430 hex_quads[n_hex_quads++] = hex_quad;
436 if (double_colon_index <
ARRAY_LEN (hex_quads))
440 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
441 hex_quads[n_zero + i] = hex_quads[i];
443 for (i = 0; i < n_zero; i++)
444 hex_quads[double_colon_index + i] = 0;
453 for (i = 0; i <
ARRAY_LEN (hex_quads); i++)
454 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
463 ip46_address_t *
ip = va_arg (*args, ip46_address_t *);
479 return format (s,
"mbedtls");
481 return format (s,
"openssl");
483 return format (s,
"picotls");
487 return format (s,
"unknown crypto engine");
493 u8 *
a = va_arg (*args,
u8 *);
496 else if (
unformat (input,
"openssl"))
498 else if (
unformat (input,
"picotls"))
520 ECHO_LOG (3,
"hash_unset(0x%lx)", handle);
525 ECHO_LOG (3,
"hash_set(0x%lx) S[%d]", handle, sid);
548 ECHO_FAIL (ECHO_FAIL_RPC_SIZE,
"RPC lock failed");
554 ECHO_FAIL (ECHO_FAIL_RPC_SIZE,
"RPC ring is full");
575 ECHO_LOG (2,
"unknown handle 0x%lx", handle);
588 if (em->
state == state)
613 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
#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)
description fragment has unexpected format
#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)
sll srl srl sll sra u16x4 i
#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)
struct echo_main_t::@664 timing
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)