-}
-
-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_main_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_listen_args_t _a, *a = &_a;
- vl_api_bind_uri_reply_t *rmp;
- session_t *s;
- application_t *app = 0;
- svm_msg_q_t *vpp_evt_q;
- app_worker_t *app_wrk;
- int rv;
-
- if (session_main_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))
- {
- app_listener_t* al = app_listener_get_w_handle(a->handle);
- s = app_listener_get_session(al);
- 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->rx_fifo);
- rmp->tx_fifo = pointer_to_uword (s->tx_fifo);
- vpp_evt_q = session_main_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);
- }
-}
-
-static void
-vl_api_unbind_uri_t_handler (vl_api_unbind_uri_t * mp)
-{
- vl_api_unbind_uri_reply_t *rmp;
- application_t *app;
- vnet_unlisten_args_t _a, *a = &_a;
- int rv;
-
- if (session_main_is_enabled () == 0)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto done;
- }
-
- app = application_lookup (mp->client_index);
- if (app)
- {
- a->uri = (char *) mp->uri;
- a->app_index = app->app_index;
- rv = vnet_unbind_uri (a);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }
-
-done:
- REPLY_MACRO (VL_API_UNBIND_URI_REPLY);
-}
-
-static void
-vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp)
-{
- vl_api_connect_session_reply_t *rmp;
- vnet_connect_args_t _a, *a = &_a;
- application_t *app;
- int rv = 0;
-
- if (session_main_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->api_context = mp->context;
- a->app_index = app->app_index;
- if ((rv = vnet_connect_uri (a)))
- clib_warning ("connect_uri returned: %d", rv);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }
-
- /*
- * Don't reply to stream (tcp) connects. The reply will come once
- * the connection is established. In case of the redirects, the reply
- * will come from the server app.
- */
- if (rv == 0)
- return;
-
-done:
- /* *INDENT-OFF* */
- REPLY_MACRO (VL_API_CONNECT_SESSION_REPLY);
- /* *INDENT-ON* */
-}
-
-static void
-vl_api_disconnect_session_t_handler (vl_api_disconnect_session_t * mp)
-{
- vl_api_disconnect_session_reply_t *rmp;
- vnet_disconnect_args_t _a, *a = &_a;
- application_t *app;
- int rv = 0;
-
- if (session_main_is_enabled () == 0)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto done;
- }
-
- app = application_lookup (mp->client_index);
- if (app)
- {
- a->handle = mp->handle;
- a->app_index = app->app_index;
- rv = vnet_disconnect_session (a);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }