session: Add transport vft protocol options
Type: refactor
Change-Id: I4e0afc206e4871596c2ed8a6ca00914a379f1526
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index bf91c90..d0c515a 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -320,11 +320,13 @@
/* 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 @@
.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 @@
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 @@
}
/* *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 @@
.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* */