66 esm->
rx_retries[s->thread_index][s->session_index] = 0;
116 for (i = 0; i < actual_transfer; i++)
122 esm->
rx_buf[my_thread_id][i]);
139 rx_fifo = s->server_rx_fifo;
145 esm->
rx_buf[my_thread_id]);
147 while (actual_transfer > 0);
154 u32 n_written, max_dequeue, max_enqueue, max_transfer;
158 session_fifo_event_t evt;
161 ASSERT (s->thread_index == thread_index);
163 rx_fifo = s->server_rx_fifo;
164 tx_fifo = s->server_tx_fifo;
166 ASSERT (rx_fifo->master_thread_index == thread_index);
167 ASSERT (tx_fifo->master_thread_index == thread_index);
176 max_transfer = (max_dequeue < max_enqueue) ? max_dequeue : max_enqueue;
197 if (esm->
rx_retries[thread_index][s->session_index] == 500000)
201 if (esm->
rx_retries[thread_index][s->session_index] < 500001)
202 esm->
rx_retries[thread_index][s->session_index]++;
208 _vec_len (esm->
rx_buf[thread_index]) = max_transfer;
211 esm->
rx_buf[thread_index]);
212 ASSERT (actual_transfer == max_transfer);
221 esm->
rx_buf[thread_index]);
223 if (n_written != max_transfer)
275 u32 segment_size = 512 << 20;
277 memset (a, 0,
sizeof (*a));
278 memset (options, 0,
sizeof (options));
292 a->options = options;
305 a->namespace_id = appns_id;
317 memset (a_cert, 0,
sizeof (*a_cert));
318 a_cert->app_index = a->app_index;
323 memset (a_key, 0,
sizeof (*a_key));
324 a_key->app_index = a->app_index;
349 memset (a, 0,
sizeof (*a));
379 for (i = 0; i < num_threads; i++)
402 u8 server_uri_set = 0, *appns_id = 0;
403 u64 tmp, appns_flags = 0, appns_secret = 0;
404 char *default_uri =
"tcp://0.0.0.0/1234";
420 else if (
unformat (input,
"no-echo"))
428 else if (
unformat (input,
"private-segment-count %d",
431 else if (
unformat (input,
"private-segment-size %U",
434 if (tmp >= 0x100000000ULL)
436 (0,
"private segment size %lld (%llu) too large", tmp, tmp);
439 else if (
unformat (input,
"appns %_%v%_", &appns_id))
441 else if (
unformat (input,
"all-scope"))
442 appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
443 | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
444 else if (
unformat (input,
"local-scope"))
445 appns_flags |= APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
446 else if (
unformat (input,
"global-scope"))
447 appns_flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
448 else if (
unformat (input,
"secret %lu", &appns_secret))
479 clib_warning (
"No uri provided! Using default: %s", default_uri);
497 .path =
"test echo server",
498 .short_help =
"test echo server proto <proto> [no echo][fifo-size <mbytes>]" 499 "[rcv-buf-size <bytes>][prealloc-fifos <count>]" 500 "[private-segment-count <count>][private-segment-size <bytes[m|g]>]" 501 "[uri <tcp://ip/port>]",
static int echo_server_listen()
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static svm_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
int echo_server_rx_callback(stream_session_t *s)
int svm_queue_add(svm_queue_t *q, u8 *elem, int nowait)
u32 vl_api_memclnt_create_internal(char *name, svm_queue_t *q)
const u32 test_srv_crt_rsa_len
void echo_server_session_reset_callback(stream_session_t *s)
int vnet_bind_uri(vnet_bind_args_t *a)
const u32 test_srv_key_rsa_len
u8 no_echo
Don't echo traffic.
u32 private_segment_size
Size of private segments.
static int echo_server_detach(void)
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
struct _vnet_application_add_tls_cert_args_t vnet_app_add_tls_cert_args_t
int echo_server_session_connected_callback(u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
u32 tls_engine
TLS engine: mbedtls/openssl.
clib_error_t * vnet_app_add_tls_cert(vnet_app_add_tls_cert_args_t *a)
u32 my_client_index
API client handle.
struct _svm_fifo svm_fifo_t
int echo_server_builtin_server_rx_callback_no_echo(stream_session_t *s)
u32 prealloc_fifos
Preallocate fifos.
#define VLIB_INIT_FUNCTION(x)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
svm_queue_t * vl_input_queue
Sever's event queue.
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
struct _stream_session_cb_vft session_cb_vft_t
#define clib_error_return(e, args...)
int svm_fifo_enqueue_nowait(svm_fifo_t *f, u32 max_bytes, const u8 *copy_from_here)
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
struct _stream_session_t stream_session_t
static int echo_server_attach(u8 *appns_id, u64 appns_flags, u64 appns_secret)
echo_server_main_t echo_server_main
struct _vnet_app_attach_args_t vnet_app_attach_args_t
vl_shmem_hdr_t * shmem_hdr
clib_error_t * vnet_app_add_tls_key(vnet_app_add_tls_key_args_t *a)
static session_handle_t session_handle(stream_session_t *s)
const char test_srv_crt_rsa[]
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
static clib_error_t * echo_server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 app_index
Server app index.
API main structure, used by both vpp and binary API clients.
void test_bytes(echo_server_main_t *esm, int actual_transfer)
void echo_server_session_disconnect_callback(stream_session_t *s)
static u8 svm_fifo_set_event(svm_fifo_t *f)
Sets fifo event flag.
static_always_inline uword vlib_get_thread_index(void)
clib_error_t * echo_server_main_init(vlib_main_t *vm)
static int create_api_loopback(vlib_main_t *vm)
u8 * format_stream_session(u8 *s, va_list *args)
Format stream session as per the following format.
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
int echo_server_session_accept_callback(stream_session_t *s)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
u32 node_index
process node index for evnt scheduling
svm_queue_t * vl_input_queue
#define VLIB_CLI_COMMAND(x,...)
int echo_server_redirect_connect_callback(u32 client_index, void *mp)
struct _vnet_application_add_tls_key_args_t vnet_app_add_tls_key_args_t
struct _vnet_app_detach_args_t vnet_app_detach_args_t
clib_error_t * vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
u8 ** rx_buf
Per-thread RX buffer.
char * server_uri
Server URI.
u32 private_segment_count
Number of private segments.
struct _svm_queue svm_queue_t
static vlib_thread_main_t * vlib_get_thread_main()
u32 rcv_buffer_size
Rcv buffer size.
int echo_server_add_segment_callback(u32 client_index, const ssvm_private_t *sp)
static int echo_server_create(vlib_main_t *vm, u8 *appns_id, u64 appns_flags, u64 appns_secret)
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
int svm_fifo_dequeue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_here)
struct _vnet_bind_args_t vnet_bind_args_t
static session_cb_vft_t echo_server_session_cb_vft
const char test_srv_key_rsa[]