45 clib_warning (
"sw_if_index %u not configured with ip %U",
50 return (is_zero ||
ip_is_local (sep->fib_index, &sep->ip, sep->is_ip4));
59 *thread_index = handle & 0xFFFFFFFF;
60 *session_index = handle >> 32;
62 if (*thread_index >=
vec_len (smm->sessions))
63 return VNET_API_ERROR_INVALID_VALUE;
65 pool = smm->sessions[*thread_index];
68 return VNET_API_ERROR_INVALID_VALUE_2;
85 sep->sw_if_index = app_ns->sw_if_index;
87 sep->is_ip4 ? app_ns->ip4_fib_index : app_ns->ip6_fib_index;
97 int rv, have_local = 0;
103 return VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
108 return VNET_API_ERROR_INVALID_VALUE_2;
114 return VNET_API_ERROR_ADDRESS_IN_USE;
125 return VNET_API_ERROR_ADDRESS_IN_USE;
132 return (have_local - 1);
140 if (rv && have_local)
155 return VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
200 return server->cb_fns.redirect_connect_callback (server->api_client_index,
209 u32 table_index, server_index;
213 return VNET_API_ERROR_INVALID_VALUE;
228 return VNET_API_ERROR_APP_CONNECT_FILTERED;
235 if (server_index != app_index)
242 if (server && (server->flags & APP_OPTIONS_FLAGS_ACCEPT_REDIRECT))
252 return VNET_API_ERROR_SESSION_CONNECT;
255 return VNET_API_ERROR_APP_CONNECT_SCOPE;
263 if (server && (server->flags & APP_OPTIONS_FLAGS_ACCEPT_REDIRECT))
271 return VNET_API_ERROR_SESSION_CONNECT;
301 sep->port = clib_host_to_net_u16 (sep->port);
309 sep->port = clib_host_to_net_u16 (sep->port);
317 sep->port = clib_host_to_net_u16 (sep->port);
325 sep->port = clib_host_to_net_u16 (sep->port);
348 uri = (
char *)
format (0,
"%s%c", uri, 0);
355 return VNET_API_ERROR_INVALID_VALUE;
373 if (
vec_len (namespace_id) == 0)
382 return VNET_API_ERROR_APP_INVALID_NS;
385 return VNET_API_ERROR_APP_INVALID_NS;
386 if (app_ns->ns_secret != secret)
387 return VNET_API_ERROR_APP_WRONG_NS_SECRET;
405 u32 app_ns_index = 0;
411 0,
"app already attached");
426 &seg_name, &a->segment_size);
431 a->segment_name_length =
vec_len (seg_name);
432 a->segment_name = seg_name;
434 a->app_index = app->index;
450 return VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
467 return vnet_bind_i (a->app_index, &sep, &a->handle);
484 return VNET_API_ERROR_ADDRESS_NOT_IN_USE;
500 if ((rv =
vnet_connect_i (a->app_index, a->api_context, &a->sep, a->mp)))
508 u32 index, thread_index;
514 if (!s || s->app_index != a->app_index)
515 return VNET_API_ERROR_INVALID_VALUE;
518 ASSERT (s->session_index == index);
529 if ((rv =
vnet_bind_i (a->app_index, &a->sep, &a->handle)))
547 if ((rv =
vnet_connect_i (a->app_index, a->api_context, &a->sep, a->mp)))
int application_open_session(application_t *app, session_endpoint_t *sep, u32 api_context)
u8 session_endpoint_in_ns(session_endpoint_t *sep)
#define APP_NAMESPACE_INVALID_INDEX
int application_stop_listen(application_t *srv, u64 handle)
Stop listening on session associated to handle.
static stream_session_t * listen_session_get_from_handle(u64 handle)
u64 session_lookup_endpoint_listener(u32 table_index, session_endpoint_t *sep, u8 use_rules)
Lookup listener for session endpoint in table.
static u8 session_endpoint_is_local(session_endpoint_t *sep)
u8 application_has_global_scope(application_t *app)
struct _vnet_connect_args vnet_connect_args_t
int vnet_bind_uri(vnet_bind_args_t *a)
u8 ip_is_local(u32 fib_index, ip46_address_t *ip46_address, u8 is_ip4)
Checks that an ip is local to the requested fib.
clib_error_t * vnet_unbind(vnet_unbind_args_t *a)
u8 ip_interface_has_address(u32 sw_if_index, ip46_address_t *ip, u8 is_ip4)
application_t * application_new()
application_t * application_lookup(u32 api_client_index)
static int vnet_bind_i(u32 app_index, session_endpoint_t *sep, u64 *handle)
stream_session_t * session_lookup_listener(u32 table_index, session_endpoint_t *sep)
#define SESSION_ENDPOINT_NULL
void segment_manager_get_segment_info(u32 index, u8 **name, u32 *size)
int application_is_proxy(application_t *app)
int vnet_unbind_uri(vnet_unbind_args_t *a)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
struct _vnet_unbind_args_t vnet_unbind_args_t
u32 app_namespace_index_from_id(const u8 *ns_id)
struct _stream_session_t stream_session_t
void session_send_session_evt_to_thread(u64 session_handle, fifo_event_type_t evt_type, u32 thread_index)
int parse_uri(char *uri, session_endpoint_t *sep)
static uword pointer_to_uword(const void *p)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
static void session_parse_handle(u64 handle, u32 *index, u32 *thread_index)
static session_manager_main_t * vnet_get_session_manager_main()
struct _session_endpoint session_endpoint_t
int application_start_listen(application_t *srv, session_endpoint_t *sep, u64 *res)
Start listening local transport endpoint for requested transport.
app_namespace_t * app_namespace_get(u32 index)
clib_error_t * vnet_connect(vnet_connect_args_t *a)
static stream_session_t * session_get_if_valid(u64 si, u32 thread_index)
u32 application_session_table(application_t *app, u8 fib_proto)
struct _session_manager_main session_manager_main_t
#define SESSION_DBG(_fmt, _args...)
u32 application_local_session_table(application_t *app)
static int app_connect_redirect(application_t *server, void *mp)
static session_endpoint_t * cache_sep
int session_lookup_local_listener_parse_handle(u64 handle, session_endpoint_t *sep)
#define vec_free(V)
Free vector's memory (no header).
#define ENDPOINT_INVALID_INDEX
int session_lookup_del_session_endpoint(u32 table_index, session_endpoint_t *sep)
#define clib_warning(format, args...)
#define SESSION_INVALID_HANDLE
u64 session_lookup_local_listener_make_handle(session_endpoint_t *sep)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
struct _application application_t
int vnet_disconnect_session(vnet_disconnect_args_t *a)
int api_parse_session_handle(u64 handle, u32 *session_index, u32 *thread_index)
int session_lookup_add_session_endpoint(u32 table_index, session_endpoint_t *sep, u64 value)
struct _app_namespace app_namespace_t
int vnet_connect_i(u32 app_index, u32 api_context, session_endpoint_t *sep, void *mp)
clib_error_t * vnet_bind(vnet_bind_args_t *a)
static void session_endpoint_update_for_app(session_endpoint_t *sep, application_t *app)
static u8 session_endpoint_fib_proto(session_endpoint_t *sep)
int application_init(application_t *app, u32 api_client_index, u64 *options, session_cb_vft_t *cb_fns)
static void clib_mem_free(void *p)
static u8 session_endpoint_is_zero(session_endpoint_t *sep)
int listen_session_get_local_session_endpoint(stream_session_t *listener, session_endpoint_t *sep)
void application_del(application_t *app)
struct _vnet_app_detach_args_t vnet_app_detach_args_t
static void * clib_mem_alloc(uword size)
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
uword unformat_vnet_uri(unformat_input_t *input, va_list *args)
unformat a vnet URI
clib_error_t * vnet_connect_uri(vnet_connect_args_t *a)
int vnet_unbind_i(u32 app_index, u64 handle)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
application_t * application_get(u32 index)
u8 ip_is_local_host(ip46_address_t *ip46_address, u8 is_ip4)
struct _segment_manager segment_manager_t
u8 session_lookup_local_is_handle(u64 handle)
#define clib_error_return_code(e, code, flags, args...)
u32 session_lookup_local_endpoint(u32 table_index, session_endpoint_t *sep)
Look up endpoint in local session table.
void application_setup_proxy(application_t *app)
static int session_validate_namespace(u8 *namespace_id, u64 secret, u32 *app_ns_index)
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
struct _vnet_bind_args_t vnet_bind_args_t
static segment_manager_t * segment_manager_get(u32 index)
static u64 listen_session_get_handle(stream_session_t *s)
application_t * application_get_if_valid(u32 index)
u8 application_has_local_scope(application_t *app)