diff options
author | Aloys Augustin <aloaugus@cisco.com> | 2019-04-09 11:40:57 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-04-24 14:57:32 +0000 |
commit | 502785b65c40351f62e510a245ccee56084a07f4 (patch) | |
tree | 3ddc2c3f55e4b5b747bbfa5dd2a45efa5bac301b /src/vnet/session-apps/echo_server.c | |
parent | 8e58499690a278a598c9ef7abf47b72fafad7e50 (diff) |
QUIC: Add multi-stream support to internal test apps
Change-Id: Iab07697ef482529e62c11433cffa1f8f894e5bb7
Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/vnet/session-apps/echo_server.c')
-rw-r--r-- | src/vnet/session-apps/echo_server.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/vnet/session-apps/echo_server.c b/src/vnet/session-apps/echo_server.c index 4249ed83292..7459d03202f 100644 --- a/src/vnet/session-apps/echo_server.c +++ b/src/vnet/session-apps/echo_server.c @@ -19,6 +19,11 @@ #include <vnet/session/application_interface.h> #include <vnet/session/session.h> +#define ECHO_SERVER_DBG (0) +#define DBG(_fmt, _args...) \ + if (ECHO_SERVER_DBG) \ + clib_warning (_fmt, ##_args) + typedef struct { /* @@ -49,6 +54,7 @@ typedef struct u8 **rx_buf; /**< Per-thread RX buffer */ u64 byte_index; u32 **rx_retries; + u8 transport_proto; vlib_main_t *vlib_main; } echo_server_main_t; @@ -56,10 +62,34 @@ typedef struct echo_server_main_t echo_server_main; int -echo_server_session_accept_callback (session_t * s) +quic_echo_server_qsession_accept_callback (session_t * s) +{ + DBG ("QSession %u accept w/opaque %d", s->session_index, s->opaque); + return 0; +} + +int +quic_echo_server_session_accept_callback (session_t * s) { echo_server_main_t *esm = &echo_server_main; + if (!(s->flags & SESSION_F_QUIC_STREAM)) + return quic_echo_server_qsession_accept_callback (s); + DBG ("SSESSION %u accept w/opaque %d", s->session_index, s->opaque); + + esm->vpp_queue[s->thread_index] = + session_main_get_vpp_event_queue (s->thread_index); + s->session_state = SESSION_STATE_READY; + esm->byte_index = 0; + ASSERT (vec_len (esm->rx_retries) > s->thread_index); + vec_validate (esm->rx_retries[s->thread_index], s->session_index); + esm->rx_retries[s->thread_index][s->session_index] = 0; + return 0; +} +int +echo_server_session_accept_callback (session_t * s) +{ + echo_server_main_t *esm = &echo_server_main; esm->vpp_queue[s->thread_index] = session_main_get_vpp_event_queue (s->thread_index); s->session_state = SESSION_STATE_READY; @@ -304,6 +334,9 @@ echo_server_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret) else echo_server_session_cb_vft.builtin_app_rx_callback = echo_server_rx_callback; + if (esm->transport_proto == TRANSPORT_PROTO_QUIC) + echo_server_session_cb_vft.session_accept_callback = + quic_echo_server_session_accept_callback; if (esm->private_segment_size) segment_size = esm->private_segment_size; @@ -426,6 +459,7 @@ echo_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, u64 tmp, appns_flags = 0, appns_secret = 0; char *default_uri = "tcp://0.0.0.0/1234"; int rv, is_stop = 0; + session_endpoint_cfg_t sep = SESSION_ENDPOINT_CFG_NULL; esm->no_echo = 0; esm->fifo_size = 64 << 10; @@ -434,7 +468,6 @@ echo_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, esm->private_segment_count = 0; esm->private_segment_size = 0; esm->tls_engine = TLS_ENGINE_OPENSSL; - esm->is_dgram = 0; vec_free (esm->server_uri); while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -503,8 +536,11 @@ echo_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, clib_warning ("No uri provided! Using default: %s", default_uri); esm->server_uri = (char *) format (0, "%s%c", default_uri, 0); } - if (esm->server_uri[0] == 'u' && esm->server_uri[3] != 'c') - esm->is_dgram = 1; + + if ((rv = parse_uri ((char *) esm->server_uri, &sep))) + return clib_error_return (0, "Uri parse error: %d", rv); + esm->transport_proto = sep.transport_proto; + esm->is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP); rv = echo_server_create (vm, appns_id, appns_flags, appns_secret); vec_free (appns_id); |