15 #ifndef __included_uri_h__ 16 #define __included_uri_h__ 35 int (*add_segment_callback) (
u32 app_wrk_index,
u64 segment_handle);
38 int (*del_segment_callback) (
u32 app_wrk_index,
u64 segment_handle);
41 int (*session_accept_callback) (
session_t * new_session);
44 int (*session_connected_callback) (
u32 app_wrk_index,
u32 opaque,
48 void (*session_disconnect_callback) (
session_t * s);
51 void (*session_transport_closed_callback) (
session_t * s);
63 int (*builtin_app_rx_callback) (
session_t * session);
66 int (*builtin_app_tx_callback) (
session_t * session);
77 #define foreach_app_init_args \ 78 _(u32, api_client_index) \ 81 _(u8 *, namespace_id) \ 82 _(session_cb_vft_t *, session_cb_vft) \ 85 typedef struct _vnet_app_attach_args_t
87 #define _(_type, _name) _type _name; 95 typedef struct _vnet_app_detach_args_t
101 typedef struct _vnet_bind_args_t
117 u32 segment_name_length;
118 u64 server_event_queue_address;
122 typedef struct _vnet_unlisten_args_t
133 typedef struct _vnet_connect_args
148 typedef struct _vnet_disconnect_args_t
154 typedef struct _vnet_application_add_tls_cert_args_t
160 typedef struct _vnet_application_add_tls_key_args_t
176 typedef struct _vnet_app_add_cert_key_pair_args_
216 #define foreach_app_options_flags \ 217 _(ACCEPT_REDIRECT, "Use FIFO with redirects") \ 218 _(ADD_SEGMENT, "Add segment and signal app if needed") \ 219 _(IS_BUILTIN, "Application is builtin") \ 220 _(IS_TRANSPORT_APP, "Application is a transport proto") \ 221 _(IS_PROXY, "Application is proxying") \ 222 _(USE_GLOBAL_SCOPE, "App can use global session scope") \ 223 _(USE_LOCAL_SCOPE, "App can use local session scope") \ 224 _(EVT_MQ_USE_EVENTFD, "Use eventfds for signaling") \ 226 typedef enum _app_options
228 #define _(sym, str) APP_OPTIONS_##sym, 233 typedef enum _app_options_flags
235 #define _(sym, str) APP_OPTIONS_FLAGS_##sym = 1 << APP_OPTIONS_##sym, 240 #define foreach_fd_type \ 241 _(VPP_MQ_SEGMENT, "Fd for vpp's event mq segment") \ 242 _(MEMFD_SEGMENT, "Fd for memfd segment") \ 243 _(MQ_EVENTFD, "Event fd used by message queue") \ 244 _(VPP_MQ_EVENTFD, "Event fd used by vpp's message queue") \ 248 #define _(sym, str) SESSION_FD_##sym, 256 #define _(sym, str) SESSION_FD_F_##sym = 1 << SESSION_FD_##sym, 289 #define foreach_app_session_field \ 290 _(svm_fifo_t, *rx_fifo) \ 291 _(svm_fifo_t, *tx_fifo) \ 292 _(session_type_t, session_type) \ 293 _(volatile u8, session_state) \ 294 _(u32, session_index) \ 295 _(app_session_transport_t, transport) \ 296 _(svm_msg_q_t, *vpp_evt_q) \ 301 #define _(type, name) type name; 346 u8 segment_name_length;
347 u8 segment_name[128];
396 ip46_address_t lcl_ip;
431 u8 segment_name_length;
505 u8 segment_name[128];
533 session_event_t *evt;
545 app_evt->
evt->event_type = evt_type;
570 session_event_t *evt;
584 evt->session_index = session_index;
585 evt->event_type = evt_type;
597 evt->session_index = session_index;
598 evt->event_type = evt_type;
607 u8 do_evt,
u8 noblock)
609 u32 max_enqueue, actual_write;
618 actual_write =
clib_min (len, max_enqueue);
627 ASSERT (rv ==
sizeof (hdr));
699 ASSERT (ph.data_length >= ph.data_offset);
703 && len >= ph.data_length)
707 len =
clib_min (len, ph.data_length - ph.data_offset);
752 #define _(sym, str) str, 765 s =
format (s,
"invalid session err %u", -error);
#define foreach_app_session_field
flag for dgram mode
struct session_unlisten_msg_ session_unlisten_msg_t
static int app_recv_stream_raw(svm_fifo_t *f, u8 *buf, u32 len, u8 clear_evt, u8 peek)
struct app_session_event_ app_session_evt_t
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
static u8 svm_msg_q_ring_is_full(svm_msg_q_t *mq, u32 ring_index)
struct session_accepted_msg_ session_accepted_msg_t
u8 is_ip4
set if uses ip4 networking
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
struct _vnet_connect_args vnet_connect_args_t
int vnet_listen(vnet_listen_args_t *a)
int vnet_app_add_cert_key_interest(u32 index, u32 app_index)
Ask for app cb on pair deletion.
struct _vnet_unlisten_args_t vnet_unlisten_args_t
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
struct session_req_worker_update_msg_ session_req_worker_update_msg_t
static char * session_error_str[]
static int app_send_stream(app_session_t *s, u8 *data, u32 len, u8 noblock)
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
Peek data from fifo.
struct session_listen_msg_ session_listen_msg_t
struct session_disconnected_reply_msg_ session_disconnected_reply_msg_t
struct session_reset_msg_ session_reset_msg_t
struct _vnet_application_add_tls_cert_args_t vnet_app_add_tls_cert_args_t
struct session_worker_update_reply_msg_ session_worker_update_reply_msg_t
struct _vnet_bind_args_t vnet_listen_args_t
int vnet_bind_uri(vnet_listen_args_t *)
static session_handle_t session_handle(session_t *s)
u32 ctx_index
index in crypto context pool
int svm_msg_q_lock_and_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index, u8 noblock, svm_msg_q_msg_t *msg)
Lock message queue and allocate message buffer on ring.
struct session_reset_reply_msg_ session_reset_reply_msg_t
struct session_accepted_reply_msg_ session_accepted_reply_msg_t
enum session_ft_action_ session_ft_action_t
static void app_alloc_ctrl_evt_to_vpp(svm_msg_q_t *mq, app_session_evt_t *app_evt, u8 evt_type)
static int app_send(app_session_t *s, u8 *data, u32 len, u8 noblock)
void * data
protocol specific data
int vnet_app_del_cert_key_pair(u32 index)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
struct app_unmap_segment_msg_ session_app_del_segment_msg_t
struct session_disconnect_msg_ session_disconnect_msg_t
enum session_fd_type_ session_fd_type_t
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
static int app_send_io_evt_to_vpp(svm_msg_q_t *mq, u32 session_index, u8 evt_type, u8 noblock)
Send fifo io event to vpp worker thread.
int svm_fifo_dequeue(svm_fifo_t *f, u32 len, u8 *dst)
Dequeue data from fifo.
struct session_connect_uri_msg_ session_connect_uri_msg_t
static int app_recv_dgram_raw(svm_fifo_t *f, u8 *buf, u32 len, app_session_transport_t *at, u8 clear_evt, u8 peek)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
clib_error_t * vnet_app_add_tls_key(vnet_app_add_tls_key_args_t *a)
struct _session_endpoint_cfg session_endpoint_cfg_t
vl_api_fib_path_type_t type
static int app_recv(app_session_t *s, u8 *data, u32 len)
struct app_map_another_segment_msg_ session_app_add_segment_msg_t
#define foreach_app_init_args
struct certificate_ app_cert_key_pair_t
#define SESSION_CTRL_MSG_MAX_SIZE
int svm_fifo_enqueue(svm_fifo_t *f, u32 len, const u8 *src)
Enqueue data to fifo.
ip46_address_t rmt_ip
remote ip
static void svm_fifo_unset_event(svm_fifo_t *f)
Unset fifo event flag.
struct session_cb_vft_ session_cb_vft_t
int vnet_app_add_cert_key_pair(vnet_app_add_cert_key_pair_args_t *a)
static void svm_msg_q_wait(svm_msg_q_t *mq)
Wait for message queue event.
struct session_connected_msg_ session_connected_msg_t
int vnet_unbind_uri(vnet_unlisten_args_t *a)
u32 n_subscribers
refcount of sessions using said context
static int app_send_dgram_raw(svm_fifo_t *f, app_session_transport_t *at, svm_msg_q_t *vpp_evt_q, u8 *data, u32 len, u8 evt_type, u8 do_evt, u8 noblock)
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
enum session_fd_flag_ session_fd_flag_t
static void app_send_ctrl_evt_to_vpp(svm_msg_q_t *mq, app_session_evt_t *app_evt)
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
u32 ckpair_index
certificate & key
Unidirectional shared-memory multi-ring message queue.
static void svm_msg_q_unlock(svm_msg_q_t *mq)
Unlock message queue.
#define SESSION_CONN_HDR_LEN
struct app_session_transport_ app_session_transport_t
int vnet_unlisten(vnet_unlisten_args_t *a)
blocking call - best used in combination with condvars, for eventfds we don't yield the cpu ...
static int app_recv_stream(app_session_t *s, u8 *buf, u32 len)
static int svm_msg_q_try_lock(svm_msg_q_t *mq)
Try locking message queue.
enum _app_options_flags app_options_flags_t
int parse_uri(char *uri, session_endpoint_cfg_t *sep)
struct session_worker_update_msg_ session_worker_update_msg_t
clib_error_t * vnet_app_add_tls_cert(vnet_app_add_tls_cert_args_t *a)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
void svm_msg_q_add_and_unlock(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Producer enqueue one message to queue with mutex held.
enum _app_options app_options_t
app_attach_options_index_t
struct session_cleanup_msg_ session_cleanup_msg_t
static u8 * format_session_error(u8 *s, va_list *args)
static int app_send_dgram(app_session_t *s, u8 *data, u32 len, u8 noblock)
struct _vnet_application_add_tls_key_args_t vnet_app_add_tls_key_args_t
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
struct _vnet_app_add_cert_key_pair_args_ vnet_app_add_cert_key_pair_args_t
struct session_migrate_msg_ session_migrated_msg_t
u16 lcl_port
local port (network order)
struct _vnet_app_detach_args_t vnet_app_detach_args_t
ip46_address_t lcl_ip
local ip
int vnet_connect(vnet_connect_args_t *a)
struct session_disconnected_msg_ session_disconnected_msg_t
struct session_bound_msg_ session_bound_msg_t
int vnet_connect_uri(vnet_connect_args_t *a)
struct session_app_detach_msg_ session_app_detach_msg_t
static int app_send_stream_raw(svm_fifo_t *f, svm_msg_q_t *vpp_evt_q, u8 *data, u32 len, u8 evt_type, u8 do_evt, u8 noblock)
struct session_unlisten_reply_msg_ session_unlisten_reply_msg_t
struct session_connect_msg_ session_connect_msg_t
struct crypto_ctx_ crypto_context_t
enum session_error_ session_error_t
enum crypto_engine_type_ crypto_engine_type_t
struct _session_endpoint session_endpoint_t
#define foreach_app_options_flags
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
static int svm_msg_q_lock(svm_msg_q_t *mq)
Lock, or block trying, the message queue.
struct _svm_fifo svm_fifo_t
static u8 svm_msg_q_is_full(svm_msg_q_t *mq)
Check if message queue is full.
struct session_dgram_header_ session_dgram_hdr_t
svm_msg_q_msg_t svm_msg_q_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index)
Allocate message buffer on ring.
static int app_recv_dgram(app_session_t *s, u8 *buf, u32 len)
u16 rmt_port
remote port (network order)
STATIC_ASSERT(sizeof(session_listen_msg_t)<=SESSION_CTRL_MSG_MAX_SIZE, "msg too large")
struct session_listen_uri_msg_ session_listen_uri_msg_t