15 #ifndef __included_uri_h__ 16 #define __included_uri_h__ 24 typedef struct _vnet_app_attach_args_t
26 #define _(_type, _name) _type _name; 33 typedef struct _vnet_app_detach_args_t
38 typedef struct _vnet_bind_args_t
54 u32 segment_name_length;
55 u64 server_event_queue_address;
59 typedef struct _vnet_unbind_args_t
70 typedef struct _vnet_connect_args
85 typedef struct _vnet_disconnect_args_t
91 typedef struct _vnet_application_add_tls_cert_args_t
97 typedef struct _vnet_application_add_tls_key_args_t
122 #define foreach_app_options_flags \ 123 _(ACCEPT_REDIRECT, "Use FIFO with redirects") \ 124 _(ADD_SEGMENT, "Add segment and signal app if needed") \ 125 _(IS_BUILTIN, "Application is builtin") \ 126 _(IS_TRANSPORT_APP, "Application is a transport proto") \ 127 _(IS_PROXY, "Application is proxying") \ 128 _(USE_GLOBAL_SCOPE, "App can use global session scope") \ 129 _(USE_LOCAL_SCOPE, "App can use local session scope") \ 130 _(USE_MQ_FOR_CTRL_MSGS, "Use message queue for ctr msgs") \ 131 _(EVT_MQ_USE_EVENTFD, "Use eventfds for signaling") \ 133 typedef enum _app_options
135 #define _(sym, str) APP_OPTIONS_##sym, 140 typedef enum _app_options_flags
142 #define _(sym, str) APP_OPTIONS_FLAGS_##sym = 1 << APP_OPTIONS_##sym, 147 #define foreach_fd_type \ 148 _(VPP_MQ_SEGMENT, "Fd for vpp's event mq segment") \ 149 _(MEMFD_SEGMENT, "Fd for memfd segment") \ 150 _(MQ_EVENTFD, "Event fd used by message queue") \ 151 _(VPP_MQ_EVENTFD, "Event fd used by vpp's message queue") \ 155 #define _(sym, str) SESSION_FD_##sym, 163 #define _(sym, str) SESSION_FD_F_##sym = 1 << SESSION_FD_##sym, 196 #define foreach_app_session_field \ 197 _(svm_fifo_t, *rx_fifo) \ 198 _(svm_fifo_t, *tx_fifo) \ 199 _(session_type_t, session_type) \ 200 _(volatile u8, session_state) \ 201 _(u32, session_index) \ 202 _(app_session_transport_t, transport) \ 203 _(svm_msg_q_t, *vpp_evt_q) \ 208 #define _(type, name) type name; 225 u8 segment_name_length;
226 u8 segment_name[128];
236 u64 vpp_event_queue_address;
237 u64 server_event_queue_address;
238 u64 client_event_queue_address;
262 u64 vpp_event_queue_address;
263 u64 client_event_queue_address;
264 u64 server_event_queue_address;
266 u8 segment_name_length;
305 session_event_t *evt;
318 app_evt->
evt->event_type = evt_type;
343 session_event_t *evt;
363 evt->event_type = evt_type;
375 evt->event_type = evt_type;
388 u32 max_enqueue, actual_write;
389 session_dgram_hdr_t hdr;
393 if (max_enqueue <=
sizeof (session_dgram_hdr_t))
396 max_enqueue -=
sizeof (session_dgram_hdr_t);
397 actual_write =
clib_min (len, max_enqueue);
398 hdr.data_length = actual_write;
406 ASSERT (rv ==
sizeof (hdr));
462 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
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 _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
memset(h->entries, 0, sizeof(h->entries[0])*entries)
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_ASSERT(sizeof(session_accepted_reply_msg_t)<=16,"accept reply")
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)
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)
#define clib_memcpy(a, b, c)
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[]
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
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.
struct _session_endpoint_extended session_endpoint_extended_t
static int app_recv_dgram(app_session_t *s, u8 *buf, u32 len)
u16 rmt_port
remote port (network order)