30 return (ip46_address->ip4.as_u32 == 0);
32 return (ip46_address->as_u64[0] == 0 && ip46_address->as_u64[1] == 0);
67 *thread_index = handle & 0xFFFFFFFF;
68 *session_index = handle >> 32;
70 if (*thread_index >=
vec_len (smm->sessions))
71 return VNET_API_ERROR_INVALID_VALUE;
73 pool = smm->sessions[*thread_index];
76 return VNET_API_ERROR_INVALID_VALUE_2;
93 clib_host_to_net_u16 (port_host_order),
97 return VNET_API_ERROR_ADDRESS_IN_USE;
102 return VNET_API_ERROR_ADDRESS_IN_USE;
105 is_ip4 = SESSION_TYPE_IP4_UDP == sst || SESSION_TYPE_IP4_TCP == sst;
107 return VNET_API_ERROR_INVALID_VALUE;
127 *len_seg_name =
vec_len (segment_name);
128 memcpy (seg_name, segment_name, *len_seg_name);
144 return VNET_API_ERROR_INVALID_VALUE_2;
155 ip46_address_t * ip46,
u16 port,
u64 * options,
void *mp,
165 clib_host_to_net_u16 (port),
176 return server->cb_fns.
184 app->api_context = api_context;
212 ip46_address_t *address = va_arg (*args, ip46_address_t *);
214 u16 *port = va_arg (*args,
u16 *);
219 *sst = SESSION_TYPE_IP4_TCP;
225 *sst = SESSION_TYPE_IP4_UDP;
231 *sst = SESSION_TYPE_IP6_UDP;
237 *sst = SESSION_TYPE_IP6_TCP;
246 u16 * port_number_host_byte_order)
251 uri = (
char *)
format (0,
"%s%c", uri, 0);
256 port_number_host_byte_order))
259 return VNET_API_ERROR_INVALID_VALUE;
275 memset (&ip46, 0,
sizeof (ip46));
276 rv =
parse_uri (a->uri, &sst, &ip46, &port_host_order);
280 if ((rv =
vnet_bind_i (a->api_client_index, &ip46, port_host_order, sst,
281 a->options, a->session_cb_vft, &server,
282 &a->segment_name_length, a->segment_name)))
285 a->server_event_queue_address = (
u64) server->event_queue;
295 return SESSION_TYPE_IP4_TCP;
297 return SESSION_TYPE_IP6_TCP;
302 return SESSION_TYPE_IP4_UDP;
304 return SESSION_TYPE_IP6_UDP;
313 u16 port_number_host_byte_order;
315 ip46_address_t ip46_address;
319 rv =
parse_uri (uri, &sst, &ip46_address, &port_number_host_byte_order);
326 (port_number_host_byte_order), sst);
329 return VNET_API_ERROR_ADDRESS_NOT_IN_USE;
332 if (api_client_index != ~0)
343 ip46_address_t ip46_address;
353 return VNET_API_ERROR_INVALID_VALUE_2;
357 rv =
parse_uri (a->uri, &sst, &ip46_address, &port);
362 &ip46_address, port, a->options, a->mp,
386 if ((rv =
vnet_bind_i (a->api_client_index, &a->tep.ip, a->tep.port, sst,
387 a->options, a->session_cb_vft, &server,
388 &a->segment_name_length, a->segment_name)))
391 a->server_event_queue_address = (
u64) server->event_queue;
392 a->handle = (
u64) a->tep.vrf << 32 | (
u64) server->session_index;
401 if (a->api_client_index != ~0)
408 ASSERT (server->session_index == (0xFFFFFFFF & a->handle));
424 return VNET_API_ERROR_INVALID_VALUE_2;
428 return vnet_connect_i (a->api_client_index, a->api_context, sst, &a->tep.ip,
429 a->tep.port, a->options, a->mp, a->session_cb_vft);
436 u32 session_index, thread_index;
fib_protocol_t fp_proto
protocol type
struct _vnet_connect_args vnet_connect_args_t
int vnet_bind_uri(vnet_bind_args_t *a)
int vnet_unbind_uri(char *uri, u32 api_client_index)
int vnet_disconnect_session(u32 session_index, u32 thread_index)
application_t * application_lookup(u32 api_client_index)
int stream_session_open(u8 sst, ip46_address_t *addr, u16 port_host_byte_order, u32 app_index)
struct _stream_session_t stream_session_t
static stream_session_t * stream_session_get(u64 si, u32 thread_index)
static u8 ip_is_local(ip46_address_t *ip46_address, u8 is_ip4)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
int vnet_bind(vnet_bind_args_t *a)
struct _stream_session_cb_vft session_cb_vft_t
struct _vnet_unbind_args_t vnet_unbind_args_t
Aggregrate type for a prefix.
u16 fp_len
The mask length.
fib_node_index_t fib_table_lookup(u32 fib_index, const fib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
static session_manager_main_t * vnet_get_session_manager_main()
enum _session_api_proto session_api_proto_t
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
application_t * application_new(application_type_t type, session_type_t sst, u32 api_client_index, u32 flags, session_cb_vft_t *cb_fns)
struct _session_manager_main session_manager_main_t
static u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
int parse_uri(char *uri, session_type_t *sst, ip46_address_t *addr, u16 *port_number_host_byte_order)
int vnet_disconnect(vnet_disconnect_args_t *a)
int stream_session_start_listen(u32 server_index, ip46_address_t *ip, u16 port)
#define clib_warning(format, args...)
static int redirect_connect_callback(u32 server_api_client_index, void *mp_arg)
Redirect a connect_uri message to the indicated server.
#define clib_memcpy(a, b, c)
u32 fib_node_index_t
A typedef of a node index.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
struct _application application_t
int api_parse_session_handle(u64 handle, u32 *session_index, u32 *thread_index)
enum fib_entry_flag_t_ fib_entry_flag_t
int vnet_unbind_i(u32 api_client_index)
void application_del(application_t *app)
void stream_session_disconnect(stream_session_t *s)
Disconnect session and propagate to transport.
#define SESSION_OPTIONS_FLAGS_USE_FIFO
Server can handle delegated connect requests from local clients.
uword unformat_vnet_uri(unformat_input_t *input, va_list *args)
unformat a vnet URI
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
application_t * application_get(u32 index)
int vnet_connect(vnet_connect_args_t *a)
int vnet_unbind(vnet_unbind_args_t *a)
void stream_session_stop_listen(u32 server_index)
int vnet_bind_i(u32 api_client_index, ip46_address_t *ip46, u16 port_host_order, session_type_t sst, u64 *options, session_cb_vft_t *cb_fns, application_t **app, u32 *len_seg_name, char *seg_name)
int vnet_connect_i(u32 api_client_index, u32 api_context, session_type_t sst, ip46_address_t *ip46, u16 port, u64 *options, void *mp, session_cb_vft_t *cb_fns)
int application_server_init(application_t *server, u32 segment_size, u32 add_segment_size, u32 rx_fifo_size, u32 tx_fifo_size, u8 **segment_name)
session_type_t session_type_from_proto_and_ip(session_api_proto_t proto, u8 is_ip4)
stream_session_t * stream_session_lookup_listener(ip46_address_t *lcl, u16 lcl_port, u8 proto)
int vnet_connect_uri(vnet_connect_args_t *a)
struct _vnet_bind_args_t vnet_bind_args_t
fib_entry_flag_t fib_entry_get_flags(fib_node_index_t fib_entry_index)