41 if (app->api_client_index == ~0)
48 if (q->cursize == q->maxsize)
81 memset (app, 0,
sizeof (*app));
83 app->connects_seg_manager = ~0;
92 u32 index, *handles = 0;
104 if (app->connects_seg_manager != (
u32) ~ 0)
113 vec_add1 (handles, handle);
118 for (i = 0; i <
vec_len (handles); i++)
120 a->app_index = app->index;
121 a->handle = handles[
i];
133 if (cb_fns->session_accept_callback == 0)
135 if (cb_fns->session_connected_callback == 0)
136 clib_warning (
"No session connected callback function provided");
137 if (cb_fns->session_disconnect_callback == 0)
138 clib_warning (
"No session disconnect callback function provided");
139 if (cb_fns->session_reset_callback == 0)
140 clib_warning (
"No session reset callback function provided");
149 u32 app_evt_queue_size, first_seg_size;
157 sm->app_index = app->index;
158 props = &app->sm_properties;
162 props->add_segment = props->add_segment_size != 0;
165 & APP_OPTIONS_FLAGS_BUILTIN_APP;
172 app->api_client_index = api_client_index;
174 app->cb_fns = *cb_fns;
214 if (app->first_segment_manager != (
u32) ~ 0)
217 app->first_segment_manager = ~0;
243 s->app_index = srv->index;
277 if (srv &&
hash_get (srv->listeners_table, handle) == 0)
286 indexp =
hash_get (srv->listeners_table, handle);
306 if (app->connects_seg_manager == (
u32) ~ 0)
319 tc->s_index = api_context;
327 ASSERT (app->connects_seg_manager != (
u32) ~ 0);
349 app_name =
format (0,
"builtin-%d%c", app->index, 0);
360 u64 handle = va_arg (*args,
u64);
361 u32 index = va_arg (*args,
u32);
362 int verbose = va_arg (*args,
int);
369 s =
format (s,
"%-40s%-20s%-15s%-15s%-10s",
"Connection",
"App",
370 "API Client",
"ListenerID",
"SegManager");
372 s =
format (s,
"%-40s%-20s",
"Connection",
"App");
383 s =
format (s,
"%-40s%-20s%-15u%-15u%-10u", str, app_name,
384 app->api_client_index, handle, index);
387 s =
format (s,
"%-40s%-20s", str, app_name);
398 u8 *app_name, *s = 0;
406 "API Client",
"SegManager");
413 if (app->connects_seg_manager == (
u32) ~ 0)
420 for (j = 0; j <
vec_len (sm->segment_indices); j++)
430 u32 session_index, thread_index;
433 session_index = fifo->master_session_index;
434 thread_index = fifo->master_thread_index;
440 s =
format (s,
"%-40s%-20s%-15u%-10u", str, app_name,
441 app->api_client_index, app->connects_seg_manager);
443 s =
format (s,
"%-40s%-20s", str, app_name);
467 s =
format (s,
"%-10s%-20s%-15s%-15s%-15s%-15s",
"Index",
"Name",
468 "API Client",
"Add seg size",
"Rx fifo size",
471 s =
format (s,
"%-10s%-20s%-20s",
"Index",
"Name",
"API Client");
477 s =
format (s,
"%-10d%-20s%-15d%-15d%-15d%-15d", app->index, app_name,
478 app->api_client_index, app->sm_properties.add_segment_size,
479 app->sm_properties.rx_fifo_size,
480 app->sm_properties.tx_fifo_size);
482 s =
format (s,
"%-10d%-20s%-20d", app->index, app_name,
483 app->api_client_index);
505 else if (
unformat (input,
"client"))
507 else if (
unformat (input,
"verbose"))
526 if (
hash_elts (app->listeners_table) == 0)
530 vlib_cli_output (vm,
"%U", format_application_listener, app,
531 handle, index, verbose);
549 if (app->connects_seg_manager == (
u32)~0)
560 if (!do_server && !do_client)
579 .short_help =
"show app [server|client] [verbose]",
static void application_table_add(application_t *app)
static segment_manager_t * segment_manager_new()
int application_stop_listen(application_t *srv, u64 handle)
Stop listening on session associated to handle.
#define hash_set(h, key, value)
static u32 default_app_evt_queue_size
Default application event queue size.
sll srl srl sll sra u16x4 i
static stream_session_t * listen_session_get_from_handle(u64 handle)
#define hash_unset(h, key)
struct _transport_connection transport_connection_t
struct _segment_manager_properties segment_manager_properties_t
static clib_error_t * show_app_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
application_t * application_new()
application_t * application_lookup(u32 api_client_index)
static stream_session_t * listen_session_new(session_type_t type)
static u8 session_manager_is_enabled()
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
struct _stream_session_t stream_session_t
struct _svm_fifo svm_fifo_t
segment_manager_t * application_get_listen_segment_manager(application_t *app, stream_session_t *s)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static void application_table_del(application_t *app)
struct _stream_session_cb_vft session_cb_vft_t
struct _vnet_unbind_args_t vnet_unbind_args_t
#define hash_foreach(key_var, value_var, h, body)
#define clib_error_return(e, args...)
unix_shared_memory_queue_t * segment_manager_alloc_queue(segment_manager_t *sm, u32 queue_size)
Allocates shm queue in the first segment.
static u8 * app_get_name_from_reg_index(application_t *app)
static void application_verify_cb_fns(session_cb_vft_t *cb_fns)
static void listen_session_del(stream_session_t *s)
static svm_fifo_t * svm_fifo_segment_get_fifo_list(svm_fifo_segment_private_t *fifo_segment)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static application_t * app_pool
Pool from which we allocate all applications.
#define pool_put(P, E)
Free an object E in pool P.
int stream_session_open(u32 app_index, session_type_t st, transport_endpoint_t *tep, transport_connection_t **res)
Ask transport to open connection to remote transport endpoint.
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).
segment_manager_t * application_get_connect_segment_manager(application_t *app)
#define clib_warning(format, args...)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
struct _application application_t
static uword * app_by_api_client_index
Hash table of apps by api client index.
static svm_fifo_segment_private_t * svm_fifo_get_segment(u32 segment_index)
static u32 segment_manager_index(segment_manager_t *sm)
static segment_manager_t * application_alloc_segment_manager(application_t *app)
#define VLIB_CLI_COMMAND(x,...)
static uword hash_elts(void *v)
int application_init(application_t *app, u32 api_client_index, u64 *options, session_cb_vft_t *cb_fns)
void application_del(application_t *app)
u32 application_get_index(application_t *app)
int application_start_listen(application_t *srv, session_type_t session_type, transport_endpoint_t *tep, u64 *res)
Start listening local transport endpoint for requested transport.
int stream_session_stop_listen(stream_session_t *s)
Ask transport to stop listening on local transport endpoint.
static vlib_main_t * vlib_get_main(void)
void segment_manager_del(segment_manager_t *sm)
Removes segment manager.
int segment_manager_init(segment_manager_t *sm, segment_manager_properties_t *properties, u32 first_seg_size)
Initializes segment manager based on options provided.
u8 * format_application_listener(u8 *s, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u8 * format_application(u8 *s, va_list *args)
application_t * application_get(u32 index)
struct _transport_endpoint transport_endpoint_t
int vnet_unbind(vnet_unbind_args_t *a)
struct _segment_manager segment_manager_t
int stream_session_listen(stream_session_t *s, transport_endpoint_t *tep)
Ask transport to listen on local transport endpoint.
vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
int application_api_queue_is_full(application_t *app)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static segment_manager_t * segment_manager_get(u32 index)
static u64 listen_session_get_handle(stream_session_t *s)
int application_open_session(application_t *app, session_type_t sst, transport_endpoint_t *tep, u32 api_context)
application_t * application_get_if_valid(u32 index)
void application_format_connects(application_t *app, int verbose)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static stream_session_t * stream_session_get(u32 si, u32 thread_index)
static uword pool_elts(void *v)
Number of active elements in a pool.