15 #ifndef __included_uri_h__ 16 #define __included_uri_h__ 24 typedef struct _vnet_app_attach_args_t
26 #define _(_type, _name) _type _name; 34 typedef struct _vnet_app_detach_args_t
40 typedef struct _vnet_bind_args_t
56 u32 segment_name_length;
57 u64 server_event_queue_address;
61 typedef struct _vnet_unbind_args_t
72 typedef struct _vnet_connect_args
87 typedef struct _vnet_disconnect_args_t
93 typedef struct _vnet_application_add_tls_cert_args_t
99 typedef struct _vnet_application_add_tls_key_args_t
124 #define foreach_app_options_flags \ 125 _(ACCEPT_REDIRECT, "Use FIFO with redirects") \ 126 _(ADD_SEGMENT, "Add segment and signal app if needed") \ 127 _(IS_BUILTIN, "Application is builtin") \ 128 _(IS_TRANSPORT_APP, "Application is a transport proto") \ 129 _(IS_PROXY, "Application is proxying") \ 130 _(USE_GLOBAL_SCOPE, "App can use global session scope") \ 131 _(USE_LOCAL_SCOPE, "App can use local session scope") \ 132 _(USE_MQ_FOR_CTRL_MSGS, "Use message queue for ctr msgs") \ 133 _(EVT_MQ_USE_EVENTFD, "Use eventfds for signaling") \ 135 typedef enum _app_options
137 #define _(sym, str) APP_OPTIONS_##sym, 142 typedef enum _app_options_flags
144 #define _(sym, str) APP_OPTIONS_FLAGS_##sym = 1 << APP_OPTIONS_##sym, 149 #define foreach_fd_type \ 150 _(VPP_MQ_SEGMENT, "Fd for vpp's event mq segment") \ 151 _(MEMFD_SEGMENT, "Fd for memfd segment") \ 152 _(MQ_EVENTFD, "Event fd used by message queue") \ 153 _(VPP_MQ_EVENTFD, "Event fd used by vpp's message queue") \ 157 #define _(sym, str) SESSION_FD_##sym, 165 #define _(sym, str) SESSION_FD_F_##sym = 1 << SESSION_FD_##sym, 198 #define foreach_app_session_field \ 199 _(svm_fifo_t, *rx_fifo) \ 200 _(svm_fifo_t, *tx_fifo) \ 201 _(session_type_t, session_type) \ 202 _(volatile u8, session_state) \ 203 _(u32, session_index) \ 204 _(app_session_transport_t, transport) \ 205 _(svm_msg_q_t, *vpp_evt_q) \ 210 #define _(type, name) type name; 227 u8 segment_name_length;
228 u8 segment_name[128];
270 u8 segment_name_length;
330 session_event_t *evt;
343 app_evt->
evt->event_type = evt_type;
368 session_event_t *evt;
388 evt->event_type = evt_type;
400 evt->event_type = evt_type;
413 u32 max_enqueue, actual_write;
414 session_dgram_hdr_t hdr;
418 if (max_enqueue <=
sizeof (session_dgram_hdr_t))
421 max_enqueue -=
sizeof (session_dgram_hdr_t);
423 hdr.data_length = actual_write;
431 ASSERT (rv ==
sizeof (hdr));
487 if (max_deq <
sizeof (session_dgram_hdr_t))
#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)
clib_error_t * vnet_connect_uri(vnet_connect_args_t *a)
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
#define SESSION_CONN_HDR_LEN
struct _vnet_connect_args vnet_connect_args_t
const char test_srv_key_rsa[]
const u32 test_srv_crt_rsa_len
#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
clib_error_t * vnet_unbind(vnet_unbind_args_t *a)
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)
static int app_send_io_evt_to_vpp(svm_msg_q_t *mq, svm_fifo_t *f, u8 evt_type, u8 noblock)
Send fifo io event to vpp worker thread.
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 _svm_fifo svm_fifo_t
clib_error_t * vnet_connect(vnet_connect_args_t *a)
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
struct _vnet_unbind_args_t vnet_unbind_args_t
int svm_fifo_enqueue_nowait(svm_fifo_t *f, u32 max_bytes, const u8 *copy_from_here)
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 noblock)
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
struct _session_endpoint_cfg session_endpoint_cfg_t
clib_error_t * vnet_app_add_tls_key(vnet_app_add_tls_key_args_t *a)
static int app_recv(app_session_t *s, u8 *data, u32 len)
int vnet_unbind_uri(vnet_unbind_args_t *a)
struct _session_endpoint session_endpoint_t
clib_error_t * vnet_bind(vnet_bind_args_t *a)
static session_handle_t session_handle(stream_session_t *s)
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_bind_uri(vnet_bind_args_t *)
const u32 test_srv_key_rsa_len
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.
static void svm_msg_q_unlock(svm_msg_q_t *mq)
Unlock message queue.
clib_error_t * vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
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 noblock)
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.
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
const char test_srv_crt_rsa[]
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
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
#define foreach_app_init_args
#define foreach_app_options_flags
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 _vnet_bind_args_t vnet_bind_args_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)