-/* ### WILL BE DEPRECATED POST 20.01 ### */
-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);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp)
-{
- vl_api_bind_uri_reply_t *rmp;
- vnet_listen_args_t _a, *a = &_a;
- application_t *app = 0;
- 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:
-
- REPLY_MACRO (VL_API_BIND_URI_REPLY);
-
- if (app)
- {
- app_wrk = application_get_worker (app, 0);
- mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle,
- rv);
- }
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-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;
- a->wrk_map_index = 0;
- rv = vnet_unbind_uri (a);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }
-
-done:
- REPLY_MACRO (VL_API_UNBIND_URI_REPLY);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp)
-{
- vl_api_connect_uri_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:
- REPLY_MACRO (VL_API_CONNECT_URI_REPLY);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-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;
- }
-
-done:
- REPLY_MACRO2 (VL_API_DISCONNECT_SESSION_REPLY, rmp->handle = mp->handle);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_disconnect_session_reply_t_handler (vl_api_disconnect_session_reply_t *
- mp)
-{
- vnet_disconnect_args_t _a, *a = &_a;
- application_t *app;
-
- /* Client objected to disconnecting the session, log and continue */
- if (mp->retval)
- {
- clib_warning ("client retval %d", mp->retval);
- return;
- }
-
- /* Disconnect has been confirmed. Confirm close to transport */
- app = application_lookup (mp->context);
- if (app)
- {
- a->handle = mp->handle;
- a->app_index = app->app_index;
- vnet_disconnect_session (a);
- }
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_map_another_segment_reply_t_handler (vl_api_map_another_segment_reply_t
- * mp)
-{
- clib_warning ("not implemented");
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp)
-{
- vnet_listen_args_t _a, *a = &_a;
- vl_api_bind_sock_reply_t *rmp;
- application_t *app = 0;
- app_worker_t *app_wrk;
- 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)
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- goto done;
- }
-
- clib_memset (a, 0, sizeof (*a));
- ip_address_decode (&mp->ip, &a->sep.ip);
- a->sep.is_ip4 = ip46_address_is_ip4 (&a->sep.ip);
- a->sep.port = mp->port;
- a->sep.fib_index = mp->vrf;
- a->sep.sw_if_index = ENDPOINT_INVALID_INDEX;
- a->sep.transport_proto = api_session_transport_proto_decode (&mp->proto);
- a->app_index = app->app_index;
- a->wrk_map_index = mp->wrk_index;
-
- if ((rv = vnet_listen (a)))
- clib_warning ("listen returned: %d", rv);
-
-done:
- /* Actual reply sent only over mq */
- REPLY_MACRO (VL_API_BIND_SOCK_REPLY);
-
- if (app)
- {
- app_wrk = application_get_worker (app, mp->wrk_index);
- mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle,
- rv);
- }
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_unbind_sock_t_handler (vl_api_unbind_sock_t * mp)
-{
- vl_api_unbind_sock_reply_t *rmp;
- vnet_unlisten_args_t _a, *a = &_a;
- app_worker_t *app_wrk;
- application_t *app = 0;
- 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->app_index = app->app_index;
- a->handle = mp->handle;
- a->wrk_map_index = mp->wrk_index;
- if ((rv = vnet_unlisten (a)))
- clib_warning ("unlisten returned: %d", rv);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }
-
-done:
- REPLY_MACRO (VL_API_UNBIND_SOCK_REPLY);
-
- if (!app)
- return;
-
- app_wrk = application_get_worker (app, a->wrk_map_index);
- if (!app_wrk)
- return;
-
- mq_send_unlisten_reply (app_wrk, mp->handle, mp->context, rv);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_connect_sock_t_handler (vl_api_connect_sock_t * mp)
-{
- vl_api_connect_sock_reply_t *rmp;
- vnet_connect_args_t _a, *a = &_a;
- application_t *app = 0;
- 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)
- {
- svm_queue_t *client_q;
-
- clib_memset (a, 0, sizeof (*a));
- client_q = vl_api_client_index_to_input_queue (mp->client_index);
- mp->client_queue_address = pointer_to_uword (client_q);
- ip_address_decode (&mp->ip, &a->sep.ip);
- a->sep.is_ip4 = ip46_address_is_ip4 (&a->sep.ip);
- a->sep.port = mp->port;
- a->sep.transport_proto =
- api_session_transport_proto_decode (&mp->proto);
- a->sep.peer.fib_index = mp->vrf;
- a->sep.peer.sw_if_index = ENDPOINT_INVALID_INDEX;
- a->sep_ext.parent_handle = mp->parent_handle;
- a->sep_ext.hostname =
- (u8 *) vl_api_from_api_to_new_c_string (&mp->hostname);
- a->api_context = mp->context;
- a->app_index = app->app_index;
- a->wrk_map_index = mp->wrk_index;
- if ((rv = vnet_connect (a)))
- clib_warning ("connect returned: %U", format_vnet_api_errno, rv);
- vec_free (a->sep_ext.hostname);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }
-
- if (rv == 0)
- return;
-
- /* Got some error, relay it */
-
-done:
- REPLY_MACRO (VL_API_CONNECT_SOCK_REPLY);
-
- if (app)
- {
- app_worker_t *app_wrk = application_get_worker (app, mp->wrk_index);
- mq_send_session_connected_cb (app_wrk->wrk_index, mp->context, 0, 1);
- }
-}
-