From 0b81915af417ca568aa3c8d976e0ecfd3fdffe39 Mon Sep 17 00:00:00 2001 From: Yu Ping Date: Tue, 7 May 2019 02:24:30 +0800 Subject: add TLS endpoint function a bit like QUIC, and the added function can get the endpoint info in TLS, so that the VCL layer can get those info correctly Change-Id: Ied7aa3077087c1814499364dfa7654a088ad9910 Signed-off-by: Yu Ping --- src/vnet/session/session_api.c | 11 ++++++----- src/vnet/tls/tls.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) (limited to 'src/vnet') diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index 83af125946e..85a4c6197ec 100755 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -387,7 +387,7 @@ mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context, { svm_msg_q_msg_t _msg, *msg = &_msg; svm_msg_q_t *app_mq, *vpp_evt_q; - transport_connection_t *tc; + transport_endpoint_t tep; session_bound_msg_t *mp; app_worker_t *app_wrk; session_event_t *evt; @@ -420,10 +420,11 @@ mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context, ls = app_listener_get_session (al); else ls = app_listener_get_local_session (al); - tc = listen_session_get_transport (ls); - mp->lcl_port = tc->lcl_port; - mp->lcl_is_ip4 = tc->is_ip4; - clib_memcpy_fast (mp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip)); + + session_get_endpoint (ls, &tep, 1 /* is_lcl */ ); + mp->lcl_port = tep.port; + mp->lcl_is_ip4 = tep.is_ip4; + clib_memcpy_fast (mp->lcl_ip, &tep.ip, sizeof (tep.ip)); vpp_evt_q = session_main_get_vpp_event_queue (0); mp->vpp_evt_q = pointer_to_uword (vpp_evt_q); diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c index 4d042d6bc85..520ac7b7dda 100644 --- a/src/vnet/tls/tls.c +++ b/src/vnet/tls/tls.c @@ -731,6 +731,30 @@ format_tls_half_open (u8 * s, va_list * args) return s; } +static void +tls_transport_endpoint_get (u32 ctx_handle, u32 thread_index, + transport_endpoint_t * tep, u8 is_lcl) +{ + tls_ctx_t *ctx = tls_ctx_get_w_thread (ctx_handle, thread_index); + session_t *tcp_session; + + tcp_session = session_get_from_handle (ctx->tls_session_handle); + session_get_endpoint (tcp_session, tep, is_lcl); +} + +static void +tls_transport_listener_endpoint_get (u32 ctx_handle, + transport_endpoint_t * tep, u8 is_lcl) +{ + session_t *tls_listener; + app_listener_t *al; + tls_ctx_t *ctx = tls_listener_ctx_get (ctx_handle); + + al = app_listener_get_w_handle (ctx->tls_session_handle); + tls_listener = app_listener_get_session (al); + session_get_endpoint (tls_listener, tep, is_lcl); +} + /* *INDENT-OFF* */ const static transport_proto_vft_t tls_proto = { .connect = tls_connect, @@ -745,6 +769,8 @@ const static transport_proto_vft_t tls_proto = { .format_connection = format_tls_connection, .format_half_open = format_tls_half_open, .format_listener = format_tls_listener, + .get_transport_endpoint = tls_transport_endpoint_get, + .get_transport_listener_endpoint = tls_transport_listener_endpoint_get, }; /* *INDENT-ON* */ -- cgit 1.2.3-korg