_(DISCONNECT_SOCK_REPLY, disconnect_sock_reply) \
_(ACCEPT_SOCK_REPLY, accept_sock_reply) \
_(RESET_SOCK_REPLY, reset_sock_reply) \
+_(SESSION_ENABLE_DISABLE, session_enable_disable) \
+
static int
send_add_segment_callback (u32 api_client_index, const u8 * segment_name,
vl_msg_api_send_shmem (q, (u8 *) & mp);
}
+static void
+send_session_reset_uri_callback (stream_session_t * s)
+{
+ vl_api_reset_session_t *mp;
+ unix_shared_memory_queue_t *q;
+ application_t *app = application_get (s->app_index);
+
+ q = vl_api_client_index_to_input_queue (app->api_client_index);
+
+ if (!q)
+ return;
+
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SESSION);
+
+ mp->session_thread_index = s->thread_index;
+ mp->session_index = s->session_index;
+ vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
static int
send_session_connected_uri_callback (u32 api_client_index,
stream_session_t * s, u8 is_fail)
mp = vl_msg_api_alloc (sizeof (*mp));
mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_URI_REPLY);
mp->context = app->api_context;
- mp->retval = is_fail;
if (!is_fail)
{
vpp_queue = session_manager_get_vpp_event_queue (s->thread_index);
mp->session_type = s->session_type;
mp->vpp_event_queue_address = (u64) vpp_queue;
mp->client_event_queue_address = (u64) app->event_queue;
+ mp->retval = 0;
session_manager_get_segment_info (s->server_segment_index, &seg_name,
&mp->segment_size);
if (mp->segment_name_length)
clib_memcpy (mp->segment_name, seg_name, mp->segment_name_length);
}
+ else
+ {
+ mp->retval = VNET_API_ERROR_SESSION_CONNECT_FAIL;
+ }
vl_msg_api_send_shmem (q, (u8 *) & mp);
/* Remove client if connect failed */
if (is_fail)
- application_del (app);
+ {
+ application_del (app);
+ }
+ else
+ {
+ s->session_state = SESSION_STATE_READY;
+ }
return 0;
}
vl_msg_api_send_shmem (q, (u8 *) & mp);
}
+static void
+send_session_reset_callback (stream_session_t * s)
+{
+ vl_api_reset_sock_t *mp;
+ unix_shared_memory_queue_t *q;
+ application_t *app = application_get (s->app_index);
+
+ q = vl_api_client_index_to_input_queue (app->api_client_index);
+
+ if (!q)
+ return;
+
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SOCK);
+
+ mp->handle = make_session_handle (s);
+ vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
/**
* Redirect a connect_uri message to the indicated server.
* Only sent if the server has bound the related port with
.session_accept_callback = send_session_accept_uri_callback,
.session_disconnect_callback = send_session_disconnect_uri_callback,
.session_connected_callback = send_session_connected_uri_callback,
+ .session_reset_callback = send_session_reset_uri_callback,
.add_segment_callback = send_add_segment_callback,
.redirect_connect_callback = redirect_connect_uri_callback
};
.session_accept_callback = send_session_accept_callback,
.session_disconnect_callback = send_session_disconnect_callback,
.session_connected_callback = send_session_connected_callback,
+ .session_reset_callback = send_session_reset_callback,
.add_segment_callback = send_add_segment_callback,
.redirect_connect_callback = redirect_connect_callback
};
return 0;
}
+static void
+vl_api_session_enable_disable_t_handler (vl_api_session_enable_disable_t * mp)
+{
+ vl_api_session_enable_disable_reply_t *rmp;
+ vlib_main_t *vm = vlib_get_main ();
+ int rv = 0;
+
+ vnet_session_enable_disable (vm, mp->is_enable);
+ REPLY_MACRO (VL_API_SESSION_ENABLE_DISABLE_REPLY);
+}
+
static void
vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp)
{
}
}));
/* *INDENT-ON* */
-
}
static void
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;
+ int rv;
a->uri = (char *) mp->uri;
a->api_client_index = mp->client_index;
a->options = mp->options;
a->session_cb_vft = &uri_session_cb_vft;
a->mp = mp;
- vnet_connect_uri (a);
+
+ rv = vnet_connect_uri (a);
+
+ if (rv == 0 || rv == VNET_CONNECT_REDIRECTED)
+ return;
+
+ /* Got some error, relay it */
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_CONNECT_URI_REPLY, ({
+ rmp->retval = rv;
+ }));
+ /* *INDENT-ON* */
}
static void
rv = api_session_not_valid (mp->session_index, mp->session_thread_index);
if (!rv)
- rv = vnet_disconnect_session (mp->client_index, mp->session_index,
- mp->session_thread_index);
+ rv =
+ vnet_disconnect_session (mp->session_index, mp->session_thread_index);
REPLY_MACRO (VL_API_DISCONNECT_SESSION_REPLY);
}
}
/* Disconnect has been confirmed. Confirm close to transport */
- vnet_disconnect_session (mp->client_index, mp->session_index,
- mp->session_thread_index);
+ vnet_disconnect_session (mp->session_index, mp->session_thread_index);
}
static void
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;
+ int rv;
clib_memcpy (&a->tep.ip, mp->ip,
(mp->is_ip4 ? sizeof (ip4_address_t) :
a->api_context = mp->context;
a->mp = mp;
- vnet_connect (a);
+ rv = vnet_connect (a);
+
+ if (rv == 0 || rv == VNET_CONNECT_REDIRECTED)
+ return;
+
+ /* Got some error, relay it */
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_CONNECT_URI_REPLY, ({
+ rmp->retval = rv;
+ }));
+ /* *INDENT-ON* */
}
static void