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_transport_closed_callback) (
session_t * s);
49 void (*session_reset_callback) (
session_t * s);
55 int (*builtin_app_rx_callback) (
session_t * session);
58 int (*builtin_app_tx_callback) (
session_t * session);
62 #define foreach_app_init_args \ 63 _(u32, api_client_index) \ 66 _(u8 *, namespace_id) \ 67 _(session_cb_vft_t *, session_cb_vft) \ 70 typedef struct _vnet_app_attach_args_t
72 #define _(_type, _name) _type _name; 80 typedef struct _vnet_app_detach_args_t
86 typedef struct _vnet_bind_args_t
102 u32 segment_name_length;
103 u64 server_event_queue_address;
107 typedef struct _vnet_unlisten_args_t
118 typedef struct _vnet_connect_args
133 typedef struct _vnet_disconnect_args_t
139 typedef struct _vnet_application_add_tls_cert_args_t
145 typedef struct _vnet_application_add_tls_key_args_t
178 #define foreach_app_options_flags \ 179 _(ACCEPT_REDIRECT, "Use FIFO with redirects") \ 180 _(ADD_SEGMENT, "Add segment and signal app if needed") \ 181 _(IS_BUILTIN, "Application is builtin") \ 182 _(IS_TRANSPORT_APP, "Application is a transport proto") \ 183 _(IS_PROXY, "Application is proxying") \ 184 _(USE_GLOBAL_SCOPE, "App can use global session scope") \ 185 _(USE_LOCAL_SCOPE, "App can use local session scope") \ 186 _(EVT_MQ_USE_EVENTFD, "Use eventfds for signaling") \ 188 typedef enum _app_options
190 #define _(sym, str) APP_OPTIONS_##sym, 195 typedef enum _app_options_flags
197 #define _(sym, str) APP_OPTIONS_FLAGS_##sym = 1 << APP_OPTIONS_##sym, 202 #define foreach_fd_type \ 203 _(VPP_MQ_SEGMENT, "Fd for vpp's event mq segment") \ 204 _(MEMFD_SEGMENT, "Fd for memfd segment") \ 205 _(MQ_EVENTFD, "Event fd used by message queue") \ 206 _(VPP_MQ_EVENTFD, "Event fd used by vpp's message queue") \ 210 #define _(sym, str) SESSION_FD_##sym, 218 #define _(sym, str) SESSION_FD_F_##sym = 1 << SESSION_FD_##sym, 247 #define foreach_app_session_field \ 248 _(svm_fifo_t, *rx_fifo) \ 249 _(svm_fifo_t, *tx_fifo) \ 250 _(session_type_t, session_type) \ 251 _(volatile u8, session_state) \ 252 _(u32, session_index) \ 253 _(app_session_transport_t, transport) \ 254 _(svm_msg_q_t, *vpp_evt_q) \ 259 #define _(type, name) type name; 301 u8 segment_name_length;
302 u8 segment_name[128];
349 ip46_address_t lcl_ip;
381 u8 segment_name_length;
452 session_event_t *evt;
464 app_evt->
evt->event_type = evt_type;
489 session_event_t *evt;
503 evt->session_index = session_index;
504 evt->event_type = evt_type;
516 evt->session_index = session_index;
517 evt->event_type = evt_type;
526 u8 do_evt,
u8 noblock)
528 u32 max_enqueue, actual_write;
537 actual_write =
clib_min (len, max_enqueue);
546 ASSERT (rv ==
sizeof (hdr));
618 ASSERT (ph.data_length >= ph.data_offset);
621 len =
clib_min (len, ph.data_length - ph.data_offset);
625 ph.data_offset += rv;
626 if (ph.data_offset == ph.data_length)
#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)
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)
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
void svm_fifo_overwrite_head(svm_fifo_t *f, u8 *src, u32 len)
Overwrite fifo head with new data.
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
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
static int app_recv(app_session_t *s, u8 *data, u32 len)
#define foreach_app_init_args
#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.
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)
Set 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 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
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
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 _session_endpoint session_endpoint_t
#define foreach_app_options_flags
enum tls_engine_type_ tls_engine_type_t
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.
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.
vl_api_fib_path_nh_proto_t proto
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