aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/transport.c
diff options
context:
space:
mode:
authorAloys Augustin <aloaugus@cisco.com>2019-04-08 17:54:39 +0200
committerFlorin Coras <florin.coras@gmail.com>2019-04-24 17:54:38 +0000
commitcdb7170ab44affe51c574eb2218744fff1bdd369 (patch)
tree56b852f5a203f96126df528198324baaead9317e /src/vnet/session/transport.c
parent689f5b5425ea0f179f7c5400e79440927b10198c (diff)
Add get_endpoint in transport vft
This allows QUIC & TLS specific logic to be implemented, and meaningfull IP/port to be returned when connection is overridden. Change-Id: Id79c59fe4d7b16d36f0e96ad3e281c4026b5fe65 Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
Diffstat (limited to 'src/vnet/session/transport.c')
-rw-r--r--src/vnet/session/transport.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index d83ecfb133c..9efe0e17307 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -319,6 +319,57 @@ transport_protocol_is_cl (transport_proto_t tp)
return (tp_vfts[tp].service_type == TRANSPORT_SERVICE_CL);
}
+always_inline void
+default_get_transport_endpoint (transport_connection_t * tc,
+ ip46_address_t * ip, u16 * port, u8 * is_ip4,
+ u8 is_lcl)
+{
+ if (is_lcl)
+ {
+ *port = tc->lcl_port;
+ *is_ip4 = tc->is_ip4;
+ clib_memcpy_fast (ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
+ }
+ else
+ {
+ *port = tc->rmt_port;
+ *is_ip4 = tc->is_ip4;
+ clib_memcpy_fast (ip, &tc->rmt_ip, sizeof (tc->rmt_ip));
+ }
+}
+
+void
+transport_get_endpoint (transport_proto_t tp, u32 conn_index,
+ u32 thread_index, ip46_address_t * ip, u16 * port,
+ u8 * is_ip4, u8 is_lcl)
+{
+ if (tp_vfts[tp].get_transport_endpoint)
+ tp_vfts[tp].get_transport_endpoint (conn_index, thread_index, ip, port,
+ is_ip4, is_lcl);
+ else
+ {
+ transport_connection_t *tc;
+ tc = transport_get_connection (tp, conn_index, thread_index);
+ default_get_transport_endpoint (tc, ip, port, is_ip4, is_lcl);
+ }
+}
+
+void
+transport_get_listener_endpoint (transport_proto_t tp, u32 conn_index,
+ ip46_address_t * ip, u16 * port, u8 * is_ip4,
+ u8 is_lcl)
+{
+ if (tp_vfts[tp].get_transport_listener_endpoint)
+ tp_vfts[tp].get_transport_listener_endpoint (conn_index, ip, port, is_ip4,
+ is_lcl);
+ else
+ {
+ transport_connection_t *tc;
+ tc = transport_get_listener (tp, conn_index);
+ default_get_transport_endpoint (tc, ip, port, is_ip4, is_lcl);
+ }
+}
+
#define PORT_MASK ((1 << 16)- 1)
void