15 #ifndef __included_uri_h__ 16 #define __included_uri_h__ 24 typedef struct _stream_session_cb_vft
27 int (*add_segment_callback) (
u32 api_client_index,
u64 segment_handle);
30 int (*del_segment_callback) (
u32 api_client_index,
u64 segment_handle);
33 int (*session_accept_callback) (
session_t * new_session);
36 int (*session_connected_callback) (
u32 app_wrk_index,
u32 opaque,
40 void (*session_disconnect_callback) (
session_t * s);
43 void (*session_reset_callback) (
session_t * s);
46 int (*builtin_app_rx_callback) (
session_t * session);
49 int (*builtin_app_tx_callback) (
session_t * session);
53 #define foreach_app_init_args \ 54 _(u32, api_client_index) \ 57 _(u8 *, namespace_id) \ 58 _(session_cb_vft_t *, session_cb_vft) \ 61 typedef struct _vnet_app_attach_args_t
63 #define _(_type, _name) _type _name; 71 typedef struct _vnet_app_detach_args_t
77 typedef struct _vnet_bind_args_t
93 u32 segment_name_length;
94 u64 server_event_queue_address;
98 typedef struct _vnet_unlisten_args_t
109 typedef struct _vnet_connect_args
124 typedef struct _vnet_disconnect_args_t
130 typedef struct _vnet_application_add_tls_cert_args_t
136 typedef struct _vnet_application_add_tls_key_args_t
169 #define foreach_app_options_flags \ 170 _(ACCEPT_REDIRECT, "Use FIFO with redirects") \ 171 _(ADD_SEGMENT, "Add segment and signal app if needed") \ 172 _(IS_BUILTIN, "Application is builtin") \ 173 _(IS_TRANSPORT_APP, "Application is a transport proto") \ 174 _(IS_PROXY, "Application is proxying") \ 175 _(USE_GLOBAL_SCOPE, "App can use global session scope") \ 176 _(USE_LOCAL_SCOPE, "App can use local session scope") \ 177 _(EVT_MQ_USE_EVENTFD, "Use eventfds for signaling") \ 179 typedef enum _app_options
181 #define _(sym, str) APP_OPTIONS_##sym, 186 typedef enum _app_options_flags
188 #define _(sym, str) APP_OPTIONS_FLAGS_##sym = 1 << APP_OPTIONS_##sym, 193 #define foreach_fd_type \ 194 _(VPP_MQ_SEGMENT, "Fd for vpp's event mq segment") \ 195 _(MEMFD_SEGMENT, "Fd for memfd segment") \ 196 _(MQ_EVENTFD, "Event fd used by message queue") \ 197 _(VPP_MQ_EVENTFD, "Event fd used by vpp's message queue") \ 201 #define _(sym, str) SESSION_FD_##sym, 209 #define _(sym, str) SESSION_FD_F_##sym = 1 << SESSION_FD_##sym, 237 #define foreach_app_session_field \ 238 _(svm_fifo_t, *rx_fifo) \ 239 _(svm_fifo_t, *tx_fifo) \ 240 _(session_type_t, session_type) \ 241 _(volatile u8, session_state) \ 242 _(u32, session_index) \ 243 _(app_session_transport_t, transport) \ 244 _(svm_msg_q_t, *vpp_evt_q) \ 249 #define _(type, name) type name; 266 u8 segment_name_length;
267 u8 segment_name[128];
315 u8 segment_name_length;
375 session_event_t *evt;
388 app_evt->
evt->event_type = evt_type;
413 session_event_t *evt;
432 evt->session_index = session_index;
433 evt->event_type = evt_type;
444 evt->session_index = session_index;
445 evt->event_type = evt_type;
456 u8 do_evt,
u8 noblock)
458 u32 max_enqueue, actual_write;
476 ASSERT (rv ==
sizeof (hdr));
#define foreach_app_session_field
flag for dgram mode
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
static u8 svm_msg_q_msg_is_invalid(svm_msg_q_msg_t *msg)
Check if message is invalid.
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
struct _vnet_connect_args vnet_connect_args_t
int vnet_listen(vnet_listen_args_t *a)
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 int app_send_stream(app_session_t *s, u8 *data, u32 len, u8 noblock)
void svm_fifo_overwrite_head(svm_fifo_t *f, u8 *data, u32 len)
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
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)
struct _svm_fifo svm_fifo_t
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
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)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
enum session_fd_type_ session_fd_type_t
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_enqueue_nowait(svm_fifo_t *f, u32 max_bytes, const u8 *copy_from_here)
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
static int app_recv(app_session_t *s, u8 *data, u32 len)
#define foreach_app_init_args
ip46_address_t rmt_ip
remote ip
static void svm_fifo_unset_event(svm_fifo_t *f)
Unsets fifo event flag.
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)
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)
Sets fifo event flag.
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 _stream_session_cb_vft session_cb_vft_t
struct app_session_transport_ app_session_transport_t
int svm_msg_q_add(svm_msg_q_t *mq, svm_msg_q_msg_t *msg, int nowait)
Producer enqueue one message to queue.
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
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
STATIC_ASSERT(sizeof(session_accepted_reply_msg_t)<=16, "accept reply")
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.
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
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 max_bytes)
struct session_bound_msg_ session_bound_msg_t
int vnet_connect_uri(vnet_connect_args_t *a)
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_endpoint session_endpoint_t
#define foreach_app_options_flags
enum tls_engine_type_ tls_engine_type_t
static int svm_msg_q_lock(svm_msg_q_t *mq)
Lock, or block trying, the message queue.
int svm_fifo_peek(svm_fifo_t *f, u32 relative_offset, u32 max_bytes, u8 *copy_here)
static u8 svm_msg_q_is_full(svm_msg_q_t *mq)
Check if message queue is full.
int svm_fifo_dequeue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_here)
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)