X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsession%2Fsession_api.c;h=16ff91d0e63522c1e2aaeae8fe74f17a37852d1c;hb=dcf55ce28d558ddeb1fd93904b54dbb843430a0f;hp=cd7541dcc70e35d7ae16e0f9dd91d34783238c8e;hpb=aa0d62a9adcb2deec6c247a4d2b8a1265356c625;p=vpp.git diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index cd7541dcc70..16ff91d0e63 100755 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -625,6 +625,9 @@ vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp) int rv = 0; clib_error_t *error; application_t *app; + stream_session_t *s; + transport_connection_t *tc = 0; + ip46_address_t *ip46; if (session_manager_is_enabled () == 0) { @@ -633,29 +636,43 @@ vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp) } app = application_lookup (mp->client_index); - if (app) + if (!app) { - ip46_address_t *ip46 = (ip46_address_t *) mp->ip; - memset (a, 0, sizeof (*a)); - a->sep.is_ip4 = mp->is_ip4; - a->sep.ip = *ip46; - a->sep.port = mp->port; - a->sep.fib_index = mp->vrf; - a->sep.sw_if_index = ENDPOINT_INVALID_INDEX; - a->sep.transport_proto = mp->proto; - a->app_index = app->index; + rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; + goto done; + } - if ((error = vnet_bind (a))) - { - rv = clib_error_get_code (error); - clib_error_report (error); - } + ip46 = (ip46_address_t *) mp->ip; + memset (a, 0, sizeof (*a)); + a->sep.is_ip4 = mp->is_ip4; + a->sep.ip = *ip46; + a->sep.port = mp->port; + a->sep.fib_index = mp->vrf; + a->sep.sw_if_index = ENDPOINT_INVALID_INDEX; + a->sep.transport_proto = mp->proto; + a->app_index = app->index; + + if ((error = vnet_bind (a))) + { + rv = clib_error_get_code (error); + clib_error_report (error); + } + else + { + s = listen_session_get_from_handle (a->handle); + tc = listen_session_get_transport (s); } + done: /* *INDENT-OFF* */ REPLY_MACRO2 (VL_API_BIND_SOCK_REPLY,({ if (!rv) - rmp->handle = a->handle; + { + rmp->handle = a->handle; + rmp->lcl_is_ip4 = tc->is_ip4; + clib_memcpy (rmp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip)); + rmp->lcl_port = tc->lcl_port; + } })); /* *INDENT-ON* */ }