16 #ifndef SRC_VNET_SESSION_SESSION_TYPES_H_ 17 #define SRC_VNET_SESSION_SESSION_TYPES_H_ 22 #define SESSION_INVALID_INDEX ((u32)~0) 23 #define SESSION_INVALID_HANDLE ((u64)~0) 24 #define SESSION_CTRL_MSG_MAX_SIZE 86 26 #define foreach_session_endpoint_fields \ 27 foreach_transport_endpoint_cfg_fields \ 28 _(u8, transport_proto) \ 30 typedef struct _session_endpoint
32 #define _(type, name) type name; 37 typedef struct _session_endpoint_cfg
39 #define _(type, name) type name; 53 #define SESSION_IP46_ZERO \ 60 #define TRANSPORT_ENDPOINT_NULL \ 62 .sw_if_index = ENDPOINT_INVALID_INDEX, \ 63 .ip = SESSION_IP46_ZERO, \ 64 .fib_index = ENDPOINT_INVALID_INDEX, \ 68 #define SESSION_ENDPOINT_NULL \ 70 .sw_if_index = ENDPOINT_INVALID_INDEX, \ 71 .ip = SESSION_IP46_ZERO, \ 72 .fib_index = ENDPOINT_INVALID_INDEX, \ 75 .peer = TRANSPORT_ENDPOINT_NULL, \ 76 .transport_proto = 0, \ 78 #define SESSION_ENDPOINT_CFG_NULL \ 80 .sw_if_index = ENDPOINT_INVALID_INDEX, \ 81 .ip = SESSION_IP46_ZERO, \ 82 .fib_index = ENDPOINT_INVALID_INDEX, \ 85 .peer = TRANSPORT_ENDPOINT_NULL, \ 86 .transport_proto = 0, \ 87 .app_wrk_index = ENDPOINT_INVALID_INDEX, \ 88 .opaque = ENDPOINT_INVALID_INDEX, \ 90 .parent_handle = SESSION_INVALID_HANDLE, \ 94 #define session_endpoint_to_transport(_sep) ((transport_endpoint_t *)_sep) 95 #define session_endpoint_to_transport_cfg(_sep) \ 96 ((transport_endpoint_cfg_t *)_sep) 136 #define foreach_session_state \ 137 _(CREATED, "created") \ 138 _(LISTENING, "listening") \ 139 _(CONNECTING, "connecting") \ 140 _(ACCEPTING, "accepting") \ 142 _(OPENED, "opened") \ 143 _(TRANSPORT_CLOSING, "transport-closing") \ 144 _(CLOSING, "closing") \ 145 _(APP_CLOSED, "app-closed") \ 146 _(TRANSPORT_CLOSED, "transport-closed") \ 147 _(CLOSED, "closed") \ 148 _(TRANSPORT_DELETED, "transport-deleted") \ 152 #define _(sym, str) SESSION_STATE_ ## sym, 158 #define foreach_session_flag \ 159 _(RX_EVT, "rx-event") \ 161 _(CUSTOM_TX, "custom-tx") \ 162 _(IS_MIGRATING, "migrating") \ 163 _(UNIDIRECTIONAL, "unidirectional") \ 164 _(CUSTOM_FIFO_TUNING, "custom-fifo-tuning") \ 168 #define _(sym, str) SESSION_F_BIT_ ## sym, 176 #define _(sym, str) SESSION_F_ ## sym = 1 << SESSION_F_BIT_ ## sym, 229 return (proto << 1 | is_ip4);
294 return handle & 0xFFFFFFFF;
311 static inline session_handle_t
314 return (((
u64) data << 32) | (
u64) session_index);
320 return (ho_handle & 0xffffffff);
326 return (ho_handle >> 32);
364 #define foreach_session_ctrl_evt \ 366 _(LISTEN_URI, listen_uri) \ 368 _(UNLISTEN, unlisten) \ 369 _(UNLISTEN_REPLY, unlisten_reply) \ 370 _(ACCEPTED, accepted) \ 371 _(ACCEPTED_REPLY, accepted_reply) \ 372 _(CONNECT, connect) \ 373 _(CONNECT_URI, connect_uri) \ 374 _(CONNECTED, connected) \ 375 _(DISCONNECT, disconnect) \ 376 _(DISCONNECTED, disconnected) \ 377 _(DISCONNECTED_REPLY, disconnected_reply) \ 378 _(RESET_REPLY, reset_reply) \ 379 _(REQ_WORKER_UPDATE, req_worker_update) \ 380 _(WORKER_UPDATE, worker_update) \ 381 _(WORKER_UPDATE_REPLY, worker_update_reply) \ 382 _(APP_DETACH, app_detach) \ 383 _(APP_ADD_SEGMENT, app_add_segment) \ 384 _(APP_DEL_SEGMENT, app_del_segment) \ 385 _(MIGRATED, migrated) \ 386 _(CLEANUP, cleanup) \ 387 _(APP_WRK_RPC, app_wrk_rpc) \ 390 #define FIFO_EVENT_APP_RX SESSION_IO_EVT_RX 391 #define FIFO_EVENT_APP_TX SESSION_IO_EVT_TX 392 #define FIFO_EVENT_DISCONNECT SESSION_CTRL_EVT_CLOSE 393 #define FIFO_EVENT_BUILTIN_RX SESSION_IO_EVT_BUILTIN_RX 394 #define FIFO_EVENT_BUILTIN_TX SESSION_IO_EVT_BUILTIN_TX 424 } __clib_packed session_event_t;
426 #define SESSION_MSG_NULL { } 445 #define SESSION_CONN_ID_LEN 37 446 #define SESSION_CONN_HDR_LEN 45 449 "session conn id wrong length");
451 #define foreach_session_error \ 452 _(NONE, "no error") \ 453 _(UNKNOWN, "generic/unknown error") \ 454 _(REFUSED, "refused") \ 455 _(TIMEDOUT, "timedout") \ 456 _(ALLOC, "obj/memory allocation error") \ 457 _(OWNER, "object not owned by application") \ 458 _(NOROUTE, "no route") \ 459 _(NOINTF, "no resolving interface") \ 460 _(NOIP, "no ip for lcl interface") \ 461 _(NOPORT, "no lcl port") \ 462 _(NOSUPPORT, "not supported") \ 463 _(NOLISTEN, "not listening") \ 464 _(NOSESSION, "session does not exist") \ 465 _(NOAPP, "app not attached") \ 466 _(PORTINUSE, "lcl port in use") \ 467 _(IPINUSE, "ip in use") \ 468 _(ALREADY_LISTENING, "ip port pair already listened on") \ 469 _(INVALID_RMT_IP, "invalid remote ip") \ 470 _(INVALID_APPWRK, "invalid app worker") \ 471 _(INVALID_NS, "invalid namespace") \ 472 _(SEG_NO_SPACE, "Couldn't allocate a fifo pair") \ 473 _(SEG_NO_SPACE2, "Created segment, couldn't allocate a fifo pair") \ 474 _(SEG_CREATE, "Couldn't create a new segment") \ 475 _(FILTERED, "session filtered") \ 476 _(SCOPE, "scope not supported") \ 477 _(BAPI_NO_FD, "bapi doesn't have a socket fd") \ 478 _(BAPI_SEND_FD, "couldn't send fd over bapi socket fd") \ 479 _(BAPI_NO_REG, "app bapi registration not found") \ 480 _(MQ_MSG_ALLOC, "failed to alloc mq msg") \ 481 _(TLS_HANDSHAKE, "failed tls handshake") \ 485 #define _(sym, str) SESSION_EP_##sym, 493 #define _(sym, str) SESSION_E_##sym = -SESSION_EP_##sym, 499 #define SESSION_ERROR_SEG_CREATE SESSION_E_SEG_CREATE 500 #define SESSION_ERROR_NO_SPACE SESSION_E_SEG_NO_SPACE 501 #define SESSION_ERROR_NEW_SEG_NO_SPACE SESSION_E_SEG_NO_SPACE2
u32 al_index
App listener index in app's listener pool if a listener.
u32 connection_index
Index of the transport connection associated to the session.
u8 pad[3]
log2 (size of the packing page block)
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
struct session_ session_t
session_type_t session_type
Type built from transport and network protocol types.
vl_api_wireguard_peer_flags_t flags
static u8 session_tx_is_dgram(session_t *s)
u32 session_index
Index in thread pool where session was allocated.
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
static transport_proto_t session_get_transport_proto(session_t *s)
transport_tx_fn_type_t transport_protocol_tx_fn_type(transport_proto_t tp)
static u8 session_endpoint_fib_proto(session_endpoint_t *sep)
static u32 session_handle_data(session_handle_t ho_handle)
static void session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
static session_handle_t session_handle(session_t *s)
enum session_ft_action_ session_ft_action_t
struct _session_endpoint_cfg session_endpoint_cfg_t
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
static transport_tx_fn_type_t session_transport_tx_fn_type(session_t *s)
transport_service_type_t transport_protocol_service_type(transport_proto_t tp)
u32 app_index
Index of application that owns the listener.
#define SESSION_CONN_ID_LEN
enum session_flags_ session_flags_t
enum transport_service_type_ transport_service_type_t
session_handle_t listener_handle
Parent listener session index if the result of an accept.
enum session_error_p_ session_error_p_t
#define foreach_session_endpoint_fields
static transport_proto_t session_type_transport_proto(session_type_t st)
static u32 session_thread_from_handle(session_handle_t handle)
static u32 session_index_from_handle(session_handle_t handle)
#define foreach_session_flag
static fib_protocol_t session_get_fib_proto(session_t *s)
#define foreach_session_state
STATIC_ASSERT(sizeof(session_dgram_hdr_t)==(SESSION_CONN_ID_LEN+8), "session conn id wrong length")
enum _transport_proto transport_proto_t
static session_handle_t session_make_handle(u32 session_index, u32 data)
u8 thread_index
Index of the thread that allocated the session.
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
static u8 session_type_is_ip4(session_type_t st)
static u32 session_handle_index(session_handle_t ho_handle)
volatile u8 session_state
State in session layer state machine.
u32 opaque
Opaque, for general use.
#define foreach_session_error
static u8 session_endpoint_is_zero(session_endpoint_t *sep)
u8 ip_is_local_host(ip46_address_t *ip46_address, u8 is_ip4)
enum session_flags_bits_ session_flag_bits_t
static u8 session_has_transport(session_t *s)
enum session_error_ session_error_t
u32 app_wrk_index
Index of the app worker that owns the session.
static u8 session_endpoint_is_local(session_endpoint_t *sep)
struct _session_endpoint session_endpoint_t
struct session_dgram_pre_hdr_ session_dgram_pre_hdr_t
static transport_service_type_t session_transport_service_type(session_t *s)
struct _svm_fifo svm_fifo_t
enum transport_dequeue_type_ transport_tx_fn_type_t
struct session_dgram_header_ session_dgram_hdr_t