aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/udp/udp.c
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2019-06-19 13:42:37 +0200
committerFlorin Coras <florin.coras@gmail.com>2019-06-27 17:24:10 +0000
commite971bc9bab2d1be9e129caa585448bb81dc6541f (patch)
tree5911a1dfb5905c6169d6798b2b1dca21e84c6862 /src/vnet/udp/udp.c
parent706079c92abe2c218da15c13d2c933914af18d18 (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/udp/udp.c')
-rw-r--r--src/vnet/udp/udp.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index bf91c905eb6..d0c515a9d06 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -320,11 +320,13 @@ udp_session_get_half_open (u32 conn_index)
/* We don't poll main thread if we have workers */
thread_index = vlib_num_workers ()? 1 : 0;
uc = udp_connection_get (conn_index, thread_index);
+ if (!uc)
+ return 0;
return &uc->connection;
}
/* *INDENT-OFF* */
-const static transport_proto_vft_t udp_proto = {
+static const transport_proto_vft_t udp_proto = {
.start_listen = udp_session_bind,
.connect = udp_open_connection,
.stop_listen = udp_session_unbind,
@@ -339,8 +341,10 @@ const static transport_proto_vft_t udp_proto = {
.format_connection = format_udp_session,
.format_half_open = format_udp_half_open_session,
.format_listener = format_udp_listener_session,
- .tx_type = TRANSPORT_TX_DGRAM,
- .service_type = TRANSPORT_SERVICE_CL,
+ .transport_options = {
+ .tx_type = TRANSPORT_TX_DGRAM,
+ .service_type = TRANSPORT_SERVICE_CL,
+ },
};
/* *INDENT-ON* */
@@ -354,7 +358,8 @@ udpc_connection_open (transport_endpoint_cfg_t * rmt)
u32 uc_index;
uc_index = udp_open_connection (rmt);
uc = udp_connection_get (uc_index, thread_index);
- uc->is_connected = 1;
+ if (uc)
+ uc->is_connected = 1;
return uc_index;
}
@@ -370,7 +375,7 @@ udpc_connection_listen (u32 session_index, transport_endpoint_t * lcl)
}
/* *INDENT-OFF* */
-const static transport_proto_vft_t udpc_proto = {
+static const transport_proto_vft_t udpc_proto = {
.start_listen = udpc_connection_listen,
.stop_listen = udp_session_unbind,
.connect = udpc_connection_open,
@@ -385,8 +390,10 @@ const static transport_proto_vft_t udpc_proto = {
.format_connection = format_udp_session,
.format_half_open = format_udp_half_open_session,
.format_listener = format_udp_listener_session,
- .tx_type = TRANSPORT_TX_DGRAM,
- .service_type = TRANSPORT_SERVICE_CL,
+ .transport_options = {
+ .tx_type = TRANSPORT_TX_DGRAM,
+ .service_type = TRANSPORT_SERVICE_VC,
+ },
};
/* *INDENT-ON* */