}
static int
-server_add_segment_callback (u32 client_index,
- const u8 * seg_name, u32 seg_size)
+server_add_segment_callback (u32 client_index, const ssvm_private_t * sp)
{
clib_warning ("called...");
return -1;
{
evt.fifo = active_open_tx_fifo;
evt.event_type = FIFO_EVENT_APP_TX;
- if (unix_shared_memory_queue_add
+ if (svm_queue_add
(bpm->active_open_event_queue[thread_index], (u8 *) & evt,
0 /* do wait for mutex */ ))
clib_warning ("failed to enqueue tx evt");
clib_spinlock_unlock_if_init (&bpm->sessions_lock);
- a->uri = "tcp://6.0.2.2/23";
+ a->uri = (char *) bpm->client_uri;
a->api_context = proxy_index;
a->app_index = bpm->active_open_app_index;
a->mp = 0;
{
evt.fifo = s->server_tx_fifo;
evt.event_type = FIFO_EVENT_APP_TX;
- if (unix_shared_memory_queue_add
+ if (svm_queue_add
(bpm->active_open_event_queue[thread_index], (u8 *) & evt,
0 /* do wait for mutex */ ))
clib_warning ("failed to enqueue tx evt");
{
evt.fifo = server_rx_fifo;
evt.event_type = FIFO_EVENT_APP_TX;
- if (unix_shared_memory_queue_add
+ if (svm_queue_add
(bpm->server_event_queue[thread_index], (u8 *) & evt,
0 /* do wait for mutex */ ))
clib_warning ("failed to enqueue server rx evt");
server_attach ()
{
builtin_proxy_main_t *bpm = &builtin_proxy_main;
- u8 segment_name[128];
- u64 options[SESSION_OPTIONS_N_OPTIONS];
+ u64 options[APP_OPTIONS_N_OPTIONS];
vnet_app_attach_args_t _a, *a = &_a;
+ u32 segment_size = 512 << 20;
memset (a, 0, sizeof (*a));
memset (options, 0, sizeof (options));
+ if (bpm->private_segment_size)
+ segment_size = bpm->private_segment_size;
a->api_client_index = bpm->server_client_index;
a->session_cb_vft = &builtin_session_cb_vft;
a->options = options;
- a->options[SESSION_OPTIONS_SEGMENT_SIZE] = 512 << 20;
- a->options[SESSION_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size;
- a->options[SESSION_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size;
+ a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
+ a->options[APP_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size;
+ a->options[APP_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size;
a->options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = bpm->private_segment_count;
- a->options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE] = bpm->private_segment_size;
a->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] =
bpm->prealloc_fifos ? bpm->prealloc_fifos : 1;
a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
- a->segment_name = segment_name;
- a->segment_name_length = ARRAY_LEN (segment_name);
-
if (vnet_application_attach (a))
{
clib_warning ("failed to attach server");
{
builtin_proxy_main_t *bpm = &builtin_proxy_main;
vnet_app_attach_args_t _a, *a = &_a;
- u8 segment_name[128];
- u32 segment_name_length;
u64 options[16];
- segment_name_length = ARRAY_LEN (segment_name);
-
memset (a, 0, sizeof (*a));
memset (options, 0, sizeof (options));
a->api_client_index = bpm->active_open_client_index;
- a->segment_name = segment_name;
- a->segment_name_length = segment_name_length;
a->session_cb_vft = &builtin_clients;
- options[SESSION_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
- options[SESSION_OPTIONS_SEGMENT_SIZE] = 512 << 20;
- options[SESSION_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size;
- options[SESSION_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size;
+ options[APP_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
+ options[APP_OPTIONS_SEGMENT_SIZE] = 512 << 20;
+ options[APP_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size;
+ options[APP_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size;
options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = bpm->private_segment_count;
- options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE] = bpm->private_segment_size;
options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] =
bpm->prealloc_fifos ? bpm->prealloc_fifos : 1;
vnet_bind_args_t _a, *a = &_a;
memset (a, 0, sizeof (*a));
a->app_index = bpm->server_app_index;
- a->uri = "tcp://0.0.0.0/23";
+ a->uri = (char *) bpm->server_uri;
return vnet_bind_uri (a);
}
bpm->prealloc_fifos = 0;
bpm->private_segment_count = 0;
bpm->private_segment_size = 0;
+ bpm->server_uri = 0;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
(0, "private segment size %lld (%llu) too large", tmp, tmp);
bpm->private_segment_size = tmp;
}
+ else if (unformat (input, "server-uri %s", &bpm->server_uri))
+ ;
+ else if (unformat (input, "client-uri %s", &bpm->client_uri))
+ ;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
+ if (!bpm->server_uri)
+ bpm->server_uri = format (0, "%s%c", "tcp://0.0.0.0/23", 0);
+ if (!bpm->client_uri)
+ bpm->client_uri = format (0, "%s%c", "tcp://6.0.2.2/23", 0);
+
vnet_session_enable_disable (vm, 1 /* turn on TCP, etc. */ );
rv = server_create (vm);
VLIB_CLI_COMMAND (server_create_command, static) =
{
.path = "test proxy server",
- .short_help = "test proxy server",
+ .short_help = "test proxy server [server-uri <tcp://ip/port>]"
+ "[client-uri <tcp://ip/port>][fifo-size <nn>][rcv-buf-size <nn>]"
+ "[prealloc-fifos <nn>][private-segment-size <mem>]"
+ "[private-segment-count <nn>]",
.function = proxy_server_create_command_fn,
};
/* *INDENT-ON* */