+
+ if (n_fds)
+ session_send_fds (reg, fds, n_fds);
+}
+
+static void
+vl_api_application_detach_t_handler (vl_api_application_detach_t * mp)
+{
+ vl_api_application_detach_reply_t *rmp;
+ int rv = VNET_API_ERROR_INVALID_VALUE_2;
+ vnet_app_detach_args_t _a, *a = &_a;
+ application_t *app;
+
+ if (session_manager_is_enabled () == 0)
+ {
+ rv = VNET_API_ERROR_FEATURE_DISABLED;
+ goto done;
+ }
+
+ app = application_lookup (mp->client_index);
+ if (app)
+ {
+ a->app_index = app->app_index;
+ a->api_client_index = mp->client_index;
+ rv = vnet_application_detach (a);
+ }
+
+done:
+ REPLY_MACRO (VL_API_APPLICATION_DETACH_REPLY);
+}
+
+static void
+vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp)
+{
+ transport_connection_t *tc = 0;
+ vnet_bind_args_t _a, *a = &_a;
+ vl_api_bind_uri_reply_t *rmp;
+ stream_session_t *s;
+ application_t *app = 0;
+ svm_msg_q_t *vpp_evt_q;
+ app_worker_t *app_wrk;
+ int rv;
+
+ if (session_manager_is_enabled () == 0)
+ {
+ rv = VNET_API_ERROR_FEATURE_DISABLED;
+ goto done;
+ }
+
+ app = application_lookup (mp->client_index);
+ if (app)
+ {
+ clib_memset (a, 0, sizeof (*a));
+ a->uri = (char *) mp->uri;
+ a->app_index = app->app_index;
+ rv = vnet_bind_uri (a);
+ }
+ else
+ {
+ rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
+ }
+
+done:
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_BIND_URI_REPLY, ({
+ if (!rv)
+ {
+ rmp->handle = a->handle;
+ if (app && application_has_global_scope (app))
+ {
+ s = listen_session_get_from_handle (a->handle);
+ tc = listen_session_get_transport (s);
+ rmp->lcl_is_ip4 = tc->is_ip4;
+ rmp->lcl_port = tc->lcl_port;
+ clib_memcpy_fast (rmp->lcl_ip, &tc->lcl_ip, sizeof(tc->lcl_ip));
+ if (session_transport_service_type (s) == TRANSPORT_SERVICE_CL)
+ {
+ rmp->rx_fifo = pointer_to_uword (s->server_rx_fifo);
+ rmp->tx_fifo = pointer_to_uword (s->server_tx_fifo);
+ vpp_evt_q = session_manager_get_vpp_event_queue (0);
+ rmp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
+ }
+ }
+ }
+ }));
+ /* *INDENT-ON* */
+
+ /* If app uses mq for control messages, send an mq message as well */
+ if (app && application_use_mq_for_ctrl (app))
+ {
+ app_wrk = application_get_worker (app, 0);
+ mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle,
+ rv);
+ }