diff options
author | Nathan Skrzypczak <nathan.skrzypczak@gmail.com> | 2019-06-19 13:42:37 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-06-27 17:24:10 +0000 |
commit | e971bc9bab2d1be9e129caa585448bb81dc6541f (patch) | |
tree | 5911a1dfb5905c6169d6798b2b1dca21e84c6862 /src/vnet/session | |
parent | 706079c92abe2c218da15c13d2c933914af18d18 (diff) |
session: Add transport vft protocol options
Type: refactor
Change-Id: I4e0afc206e4871596c2ed8a6ca00914a379f1526
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r-- | src/vnet/session/application_local.c | 8 | ||||
-rw-r--r-- | src/vnet/session/session.c | 3 | ||||
-rw-r--r-- | src/vnet/session/session_node.c | 10 | ||||
-rw-r--r-- | src/vnet/session/transport.c | 6 | ||||
-rw-r--r-- | src/vnet/session/transport.h | 9 |
5 files changed, 23 insertions, 13 deletions
diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c index 2fcf070767c..4a93d3a2ae5 100644 --- a/src/vnet/session/application_local.c +++ b/src/vnet/session/application_local.c @@ -540,7 +540,7 @@ format_ct_session (u8 * s, va_list * args) } /* *INDENT-OFF* */ -const static transport_proto_vft_t cut_thru_proto = { +static const transport_proto_vft_t cut_thru_proto = { .start_listen = ct_start_listen, .stop_listen = ct_stop_listen, .get_listener = ct_listener_get, @@ -549,10 +549,12 @@ const static transport_proto_vft_t cut_thru_proto = { .get_connection = ct_session_get, .custom_tx = ct_custom_tx, .app_rx_evt = ct_app_rx_evt, - .tx_type = TRANSPORT_TX_INTERNAL, - .service_type = TRANSPORT_SERVICE_APP, .format_listener = format_ct_listener, .format_connection = format_ct_session, + .transport_options = { + .tx_type = TRANSPORT_TX_INTERNAL, + .service_type = TRANSPORT_SERVICE_APP, + }, }; /* *INDENT-ON* */ diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index ea52b75086d..0e5fb8edb1a 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -1283,7 +1283,8 @@ session_register_transport (transport_proto_t transport_proto, /* *INDENT-ON* */ smm->session_type_to_next[session_type] = next_index; - smm->session_tx_fns[session_type] = session_tx_fns[vft->tx_type]; + smm->session_tx_fns[session_type] = + session_tx_fns[vft->transport_options.tx_type]; } transport_connection_t * diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 067ab585e6f..8d01938ad85 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -395,7 +395,8 @@ session_tx_fifo_chain_tail (vlib_main_t * vm, session_tx_context_t * ctx, } else { - if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM) + if (ctx->transport_vft->transport_options.tx_type == + TRANSPORT_TX_DGRAM) { svm_fifo_t *f = ctx->s->tx_fifo; session_dgram_hdr_t *hdr = &ctx->hdr; @@ -466,7 +467,7 @@ session_tx_fill_buffer (vlib_main_t * vm, session_tx_context_t * ctx, } else { - if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM) + if (ctx->transport_vft->transport_options.tx_type == TRANSPORT_TX_DGRAM) { session_dgram_hdr_t *hdr = &ctx->hdr; svm_fifo_t *f = ctx->s->tx_fifo; @@ -572,7 +573,7 @@ session_tx_set_dequeue_params (vlib_main_t * vm, session_tx_context_t * ctx, } else { - if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM) + if (ctx->transport_vft->transport_options.tx_type == TRANSPORT_TX_DGRAM) { if (ctx->max_dequeue <= sizeof (ctx->hdr)) { @@ -782,7 +783,8 @@ session_tx_fifo_read_and_snd_i (vlib_main_t * vm, vlib_node_runtime_t * node, if (svm_fifo_set_event (ctx->s->tx_fifo)) vec_add1 (wrk->pending_event_vector, *e); - if (!peek_data && ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM) + if (!peek_data + && ctx->transport_vft->transport_options.tx_type == TRANSPORT_TX_DGRAM) { /* Fix dgram pre header */ if (ctx->max_len_to_snd < ctx->max_dequeue) diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c index bbd9c3555f4..f971288f90c 100644 --- a/src/vnet/session/transport.c +++ b/src/vnet/session/transport.c @@ -291,13 +291,13 @@ transport_protocol_get_vft (transport_proto_t transport_proto) transport_service_type_t transport_protocol_service_type (transport_proto_t tp) { - return tp_vfts[tp].service_type; + return tp_vfts[tp].transport_options.service_type; } transport_tx_fn_type_t transport_protocol_tx_fn_type (transport_proto_t tp) { - return tp_vfts[tp].tx_type; + return tp_vfts[tp].transport_options.tx_type; } void @@ -334,7 +334,7 @@ transport_stop_listen (transport_proto_t tp, u32 conn_index) u8 transport_protocol_is_cl (transport_proto_t tp) { - return (tp_vfts[tp].service_type == TRANSPORT_SERVICE_CL); + return (tp_vfts[tp].transport_options.service_type == TRANSPORT_SERVICE_CL); } always_inline void diff --git a/src/vnet/session/transport.h b/src/vnet/session/transport.h index fadb02d6710..978e3f072b1 100644 --- a/src/vnet/session/transport.h +++ b/src/vnet/session/transport.h @@ -19,6 +19,12 @@ #include <vnet/vnet.h> #include <vnet/session/transport_types.h> +typedef struct _transport_options_t +{ + transport_tx_fn_type_t tx_type; + transport_service_type_t service_type; +} transport_options_t; + /* * Transport protocol virtual function table */ @@ -74,8 +80,7 @@ typedef struct _transport_proto_vft /* * Properties */ - transport_tx_fn_type_t tx_type; - transport_service_type_t service_type; + transport_options_t transport_options; } transport_proto_vft_t; /* *INDENT-ON* */ |