session: return connect session handle to app
App transports not supported for now. Will have to be updated individually. Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I75cb6c4e1c5af008af72858a9ee573016812abd4
This commit is contained in:

committed by
Damjan Marion

parent
106e24bd91
commit
89a9f61dfc
@ -1331,6 +1331,8 @@ vnet_connect (vnet_connect_args_t * a)
|
|||||||
session_endpoint_update_for_app (&a->sep_ext, client, 1 /* is_connect */ );
|
session_endpoint_update_for_app (&a->sep_ext, client, 1 /* is_connect */ );
|
||||||
client_wrk = application_get_worker (client, a->wrk_map_index);
|
client_wrk = application_get_worker (client, a->wrk_map_index);
|
||||||
|
|
||||||
|
a->sep_ext.opaque = a->api_context;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First check the local scope for locally attached destinations.
|
* First check the local scope for locally attached destinations.
|
||||||
* If we have local scope, we pass *all* connects through it since we may
|
* If we have local scope, we pass *all* connects through it since we may
|
||||||
@ -1342,7 +1344,7 @@ vnet_connect (vnet_connect_args_t * a)
|
|||||||
|
|
||||||
a->sep_ext.original_tp = a->sep_ext.transport_proto;
|
a->sep_ext.original_tp = a->sep_ext.transport_proto;
|
||||||
a->sep_ext.transport_proto = TRANSPORT_PROTO_NONE;
|
a->sep_ext.transport_proto = TRANSPORT_PROTO_NONE;
|
||||||
rv = app_worker_connect_session (client_wrk, &a->sep, a->api_context);
|
rv = app_worker_connect_session (client_wrk, &a->sep_ext, &a->sh);
|
||||||
if (rv <= 0)
|
if (rv <= 0)
|
||||||
return rv;
|
return rv;
|
||||||
a->sep_ext.transport_proto = a->sep_ext.original_tp;
|
a->sep_ext.transport_proto = a->sep_ext.original_tp;
|
||||||
@ -1350,7 +1352,7 @@ vnet_connect (vnet_connect_args_t * a)
|
|||||||
/*
|
/*
|
||||||
* Not connecting to a local server, propagate to transport
|
* Not connecting to a local server, propagate to transport
|
||||||
*/
|
*/
|
||||||
return app_worker_connect_session (client_wrk, &a->sep, a->api_context);
|
return app_worker_connect_session (client_wrk, &a->sep_ext, &a->sh);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -304,8 +304,8 @@ app_worker_t *app_worker_get_if_valid (u32 wrk_index);
|
|||||||
application_t *app_worker_get_app (u32 wrk_index);
|
application_t *app_worker_get_app (u32 wrk_index);
|
||||||
int app_worker_own_session (app_worker_t * app_wrk, session_t * s);
|
int app_worker_own_session (app_worker_t * app_wrk, session_t * s);
|
||||||
void app_worker_free (app_worker_t * app_wrk);
|
void app_worker_free (app_worker_t * app_wrk);
|
||||||
int app_worker_connect_session (app_worker_t * app, session_endpoint_t * tep,
|
int app_worker_connect_session (app_worker_t *app, session_endpoint_cfg_t *sep,
|
||||||
u32 api_context);
|
session_handle_t *rsh);
|
||||||
int app_worker_start_listen (app_worker_t * app_wrk, app_listener_t * lstnr);
|
int app_worker_start_listen (app_worker_t * app_wrk, app_listener_t * lstnr);
|
||||||
int app_worker_stop_listen (app_worker_t * app_wrk, app_listener_t * al);
|
int app_worker_stop_listen (app_worker_t * app_wrk, app_listener_t * al);
|
||||||
int app_worker_init_accepted (session_t * s);
|
int app_worker_init_accepted (session_t * s);
|
||||||
|
@ -139,6 +139,9 @@ typedef struct _vnet_connect_args
|
|||||||
u32 app_index;
|
u32 app_index;
|
||||||
u32 wrk_map_index;
|
u32 wrk_map_index;
|
||||||
u32 api_context;
|
u32 api_context;
|
||||||
|
|
||||||
|
/* Resulting session, or half-open session, if connect successful */
|
||||||
|
session_handle_t sh;
|
||||||
} vnet_connect_args_t;
|
} vnet_connect_args_t;
|
||||||
|
|
||||||
typedef struct _vnet_shutdown_args_t
|
typedef struct _vnet_shutdown_args_t
|
||||||
|
@ -500,15 +500,12 @@ app_worker_own_session (app_worker_t * app_wrk, session_t * s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
app_worker_connect_session (app_worker_t * app_wrk, session_endpoint_t * sep,
|
app_worker_connect_session (app_worker_t *app_wrk, session_endpoint_cfg_t *sep,
|
||||||
u32 api_context)
|
session_handle_t *rsh)
|
||||||
{
|
{
|
||||||
int rv;
|
sep->app_wrk_index = app_wrk->wrk_index;
|
||||||
|
|
||||||
if ((rv = session_open (app_wrk->wrk_index, sep, api_context)))
|
return session_open (sep, rsh);
|
||||||
return rv;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -314,7 +314,7 @@ session_half_open_delete_notify (transport_connection_t *tc)
|
|||||||
app_worker_t *app_wrk;
|
app_worker_t *app_wrk;
|
||||||
session_t *s;
|
session_t *s;
|
||||||
|
|
||||||
s = session_get (tc->s_index, tc->thread_index);
|
s = ho_session_get (tc->s_index);
|
||||||
app_wrk = app_worker_get (s->app_wrk_index);
|
app_wrk = app_worker_get (s->app_wrk_index);
|
||||||
app_worker_del_half_open (app_wrk, s->ho_index);
|
app_worker_del_half_open (app_wrk, s->ho_index);
|
||||||
session_free (s);
|
session_free (s);
|
||||||
@ -1225,7 +1225,7 @@ session_dgram_accept (transport_connection_t * tc, u32 listener_index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
session_open_cl (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
|
session_open_cl (session_endpoint_cfg_t *rmt, session_handle_t *rsh)
|
||||||
{
|
{
|
||||||
transport_connection_t *tc;
|
transport_connection_t *tc;
|
||||||
transport_endpoint_cfg_t *tep;
|
transport_endpoint_cfg_t *tep;
|
||||||
@ -1245,7 +1245,7 @@ session_open_cl (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
|
|||||||
tc = transport_get_half_open (rmt->transport_proto, (u32) rv);
|
tc = transport_get_half_open (rmt->transport_proto, (u32) rv);
|
||||||
|
|
||||||
/* For dgram type of service, allocate session and fifos now */
|
/* For dgram type of service, allocate session and fifos now */
|
||||||
app_wrk = app_worker_get (app_wrk_index);
|
app_wrk = app_worker_get (rmt->app_wrk_index);
|
||||||
s = session_alloc_for_connection (tc);
|
s = session_alloc_for_connection (tc);
|
||||||
s->app_wrk_index = app_wrk->wrk_index;
|
s->app_wrk_index = app_wrk->wrk_index;
|
||||||
s->session_state = SESSION_STATE_OPENED;
|
s->session_state = SESSION_STATE_OPENED;
|
||||||
@ -1256,17 +1256,19 @@ session_open_cl (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sh = session_handle (s);
|
sh = session_handle (s);
|
||||||
|
*rsh = sh;
|
||||||
|
|
||||||
session_lookup_add_connection (tc, sh);
|
session_lookup_add_connection (tc, sh);
|
||||||
return app_worker_connect_notify (app_wrk, s, SESSION_E_NONE, opaque);
|
return app_worker_connect_notify (app_wrk, s, SESSION_E_NONE, rmt->opaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
session_open_vc (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
|
session_open_vc (session_endpoint_cfg_t *rmt, session_handle_t *rsh)
|
||||||
{
|
{
|
||||||
transport_connection_t *tc;
|
transport_connection_t *tc;
|
||||||
transport_endpoint_cfg_t *tep;
|
transport_endpoint_cfg_t *tep;
|
||||||
app_worker_t *app_wrk;
|
app_worker_t *app_wrk;
|
||||||
session_t *s;
|
session_t *ho;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
tep = session_endpoint_to_transport_cfg (rmt);
|
tep = session_endpoint_to_transport_cfg (rmt);
|
||||||
@ -1279,7 +1281,7 @@ session_open_vc (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
|
|||||||
|
|
||||||
tc = transport_get_half_open (rmt->transport_proto, (u32) rv);
|
tc = transport_get_half_open (rmt->transport_proto, (u32) rv);
|
||||||
|
|
||||||
app_wrk = app_worker_get (app_wrk_index);
|
app_wrk = app_worker_get (rmt->app_wrk_index);
|
||||||
|
|
||||||
/* If transport offers a vc service, only allocate established
|
/* If transport offers a vc service, only allocate established
|
||||||
* session once the connection has been established.
|
* session once the connection has been established.
|
||||||
@ -1289,10 +1291,11 @@ session_open_vc (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
|
|||||||
* session on transport notification, and to cleanup the half-open
|
* session on transport notification, and to cleanup the half-open
|
||||||
* session if the app detaches before connection establishment.
|
* session if the app detaches before connection establishment.
|
||||||
*/
|
*/
|
||||||
s = session_alloc_for_half_open (tc);
|
ho = session_alloc_for_half_open (tc);
|
||||||
s->app_wrk_index = app_wrk->wrk_index;
|
ho->app_wrk_index = app_wrk->wrk_index;
|
||||||
s->ho_index = app_worker_add_half_open (app_wrk, session_handle (s));
|
ho->ho_index = app_worker_add_half_open (app_wrk, session_handle (ho));
|
||||||
s->opaque = opaque;
|
ho->opaque = rmt->opaque;
|
||||||
|
*rsh = session_handle (ho);
|
||||||
|
|
||||||
session_lookup_add_half_open (tc, tc->c_index);
|
session_lookup_add_half_open (tc, tc->c_index);
|
||||||
|
|
||||||
@ -1300,18 +1303,17 @@ session_open_vc (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
session_open_app (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
|
session_open_app (session_endpoint_cfg_t *rmt, session_handle_t *rsh)
|
||||||
{
|
{
|
||||||
session_endpoint_cfg_t *sep = (session_endpoint_cfg_t *) rmt;
|
transport_endpoint_cfg_t *tep_cfg = session_endpoint_to_transport_cfg (rmt);
|
||||||
transport_endpoint_cfg_t *tep_cfg = session_endpoint_to_transport_cfg (sep);
|
|
||||||
|
|
||||||
sep->app_wrk_index = app_wrk_index;
|
|
||||||
sep->opaque = opaque;
|
|
||||||
|
|
||||||
|
/* Not supported for now */
|
||||||
|
*rsh = SESSION_INVALID_HANDLE;
|
||||||
return transport_connect (rmt->transport_proto, tep_cfg);
|
return transport_connect (rmt->transport_proto, tep_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef int (*session_open_service_fn) (u32, session_endpoint_t *, u32);
|
typedef int (*session_open_service_fn) (session_endpoint_cfg_t *,
|
||||||
|
session_handle_t *);
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
static session_open_service_fn session_open_srv_fns[TRANSPORT_N_SERVICES] = {
|
static session_open_service_fn session_open_srv_fns[TRANSPORT_N_SERVICES] = {
|
||||||
@ -1335,11 +1337,11 @@ static session_open_service_fn session_open_srv_fns[TRANSPORT_N_SERVICES] = {
|
|||||||
* on open completion.
|
* on open completion.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
session_open (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
|
session_open (session_endpoint_cfg_t *rmt, session_handle_t *rsh)
|
||||||
{
|
{
|
||||||
transport_service_type_t tst;
|
transport_service_type_t tst;
|
||||||
tst = transport_protocol_service_type (rmt->transport_proto);
|
tst = transport_protocol_service_type (rmt->transport_proto);
|
||||||
return session_open_srv_fns[tst] (app_wrk_index, rmt, opaque);
|
return session_open_srv_fns[tst](rmt, rsh);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -452,7 +452,7 @@ session_clone_safe (u32 session_index, u32 thread_index)
|
|||||||
return new_s;
|
return new_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
int session_open (u32 app_index, session_endpoint_t * tep, u32 opaque);
|
int session_open (session_endpoint_cfg_t *sep, session_handle_t *rsh);
|
||||||
int session_listen (session_t * s, session_endpoint_cfg_t * sep);
|
int session_listen (session_t * s, session_endpoint_cfg_t * sep);
|
||||||
int session_stop_listen (session_t * s);
|
int session_stop_listen (session_t * s);
|
||||||
void session_half_close (session_t *s);
|
void session_half_close (session_t *s);
|
||||||
|
Reference in New Issue
Block a user