35 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 113 const u8 * seg_name,
u32 seg_size)
132 for (i = 0; i < actual_transfer; i++)
138 bsm->
rx_buf[my_thread_id][i]);
155 rx_fifo = s->server_rx_fifo;
161 bsm->
rx_buf[my_thread_id]);
163 while (actual_transfer > 0);
170 u32 n_written, max_dequeue, max_enqueue, max_transfer;
174 session_fifo_event_t evt;
175 static int serial_number = 0;
178 rx_fifo = s->server_rx_fifo;
179 tx_fifo = s->server_tx_fifo;
188 max_transfer = (max_dequeue < max_enqueue) ? max_dequeue : max_enqueue;
215 _vec_len (bsm->
rx_buf[my_thread_id]) = max_transfer;
218 bsm->
rx_buf[my_thread_id]);
219 ASSERT (actual_transfer == max_transfer);
228 bsm->
rx_buf[my_thread_id]);
230 if (n_written != max_transfer)
238 evt.event_id = serial_number++;
269 uword *event_data = 0, event_type;
279 memset (mp, 0,
sizeof (*mp));
280 mp->_vl_msg_id = VL_API_MEMCLNT_CREATE;
283 strncpy ((
char *) mp->
name,
"tcp_test_server", sizeof (mp->
name) - 1);
312 u8 segment_name[128];
316 memset (a, 0,
sizeof (*a));
317 memset (options, 0,
sizeof (options));
327 a->options = options;
334 a->segment_name = segment_name;
335 a->segment_name_length =
ARRAY_LEN (segment_name);
351 memset (a, 0,
sizeof (*a));
353 a->uri =
"tcp://0.0.0.0/1234";
377 for (i = 0; i < num_threads; i++)
404 #define foreach_tcp_builtin_server_api_msg \ 405 _(MEMCLNT_CREATE_REPLY, memclnt_create_reply) \ 413 #define _(N,n) do { \ 414 c->id = VL_API_##N; \ 416 c->handler = vl_api_##n##_t_handler; \ 417 c->cleanup = vl_noop_handler; \ 418 c->endian = vl_api_##n##_t_endian; \ 419 c->print = vl_api_##n##_t_print; \ 420 c->size = sizeof(vl_api_##n##_t); \ 423 c->message_bounce = 0; \ 424 vl_msg_api_config(c);} while (0); 477 .path =
"test tcp server",
478 .short_help =
"test tcp server",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void test_bytes(builtin_server_main_t *bsm, int actual_transfer)
sll srl srl sll sra u16x4 i
u32 rcv_buffer_size
Rcv buffer size.
unix_shared_memory_queue_t ** vpp_queue
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
vlib_node_runtime_t node_runtime
int vnet_bind_uri(vnet_bind_args_t *a)
static clib_error_t * server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
unix_shared_memory_queue_t * vl_input_queue
int builtin_redirect_connect_callback(u32 client_index, void *mp)
u8 ** rx_buf
Per-thread RX buffer.
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
u32 prealloc_fifos
Preallocate fifos.
builtin_server_main_t builtin_server_main
struct _stream_session_t stream_session_t
struct _svm_fifo svm_fifo_t
u8 no_echo
Don't echo traffic.
#define VLIB_INIT_FUNCTION(x)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
struct _stream_session_cb_vft session_cb_vft_t
unix_shared_memory_queue_t * vl_input_queue
Sever's event queue.
#define clib_error_return(e, args...)
static int server_attach()
struct vl_shmem_hdr_ * shmem_hdr
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
static clib_error_t * tcp_builtin_server_api_hookup(vlib_main_t *vm)
static uword pointer_to_uword(const void *p)
static int create_api_loopback(vlib_main_t *vm)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
vl_shmem_hdr_t * shmem_hdr
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
void builtin_session_disconnect_callback(stream_session_t *s)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
u32 my_client_index
API client handle.
u32 node_index
Node index.
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
static int server_create(vlib_main_t *vm)
static u8 svm_fifo_set_event(svm_fifo_t *f)
Sets fifo event flag.
static unix_shared_memory_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
int builtin_add_segment_callback(u32 client_index, const u8 *seg_name, u32 seg_size)
static_always_inline uword vlib_get_thread_index(void)
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
#define foreach_tcp_builtin_server_api_msg
#define clib_warning(format, args...)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
int svm_fifo_enqueue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_from_here)
int builtin_session_accept_callback(stream_session_t *s)
#define VLIB_CLI_COMMAND(x,...)
int vnet_application_attach(vnet_app_attach_args_t *a)
Attaches application.
clib_error_t * builtin_tcp_server_main_init(vlib_main_t *vm)
int builtin_server_rx_callback(stream_session_t *s)
static void vl_api_memclnt_create_reply_t_handler(vl_api_memclnt_create_reply_t *mp)
static vlib_main_t * vlib_get_main(void)
int builtin_server_rx_callback_no_echo(stream_session_t *s)
static u64 stream_session_handle(stream_session_t *s)
u32 node_index
process node index for evnt scheduling
void vl_api_memclnt_create_t_handler(vl_api_memclnt_create_t *mp)
void builtin_session_reset_callback(stream_session_t *s)
static session_cb_vft_t builtin_session_cb_vft
static int server_listen()
int builtin_session_connected_callback(u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
static vlib_thread_main_t * vlib_get_thread_main()
u32 app_index
Server app index.
int svm_fifo_dequeue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_here)
struct _vnet_bind_args_t vnet_bind_args_t
struct _unix_shared_memory_queue unix_shared_memory_queue_t