- app = application_get (app_index);
- return application_open_session (app, sst, tep, api_context);
+ if (session_endpoint_is_local (sep))
+ return VNET_API_ERROR_SESSION_CONNECT;
+
+ if (!application_has_global_scope (client))
+ return VNET_API_ERROR_APP_CONNECT_SCOPE;
+
+ table_index = application_session_table (client,
+ session_endpoint_fib_proto (sep));
+ listener = session_lookup_listener (table_index, sep);
+ if (listener)
+ {
+ server = application_get (listener->app_index);
+ if (server)
+ return application_local_session_connect (table_index, client, server,
+ (local_session_t *)
+ listener, api_context);
+ }
+
+ /*
+ * Not connecting to a local server, propagate to transport
+ */
+ if (application_open_session (client, sep, api_context))
+ return VNET_API_ERROR_SESSION_CONNECT;
+ return 0;