18#ifndef PROTOCORE_TCP_EVT_H
19#define PROTOCORE_TCP_EVT_H
53 "ConnState must stay one byte (PROTO_ENUM_PACKED); TcpConn and conn_pool[] size themselves on it");
69static_assert(
sizeof(
EvtType) == 1,
70 "EvtType must stay one byte (PROTO_ENUM_PACKED); every listener's queue storage sizes itself on TcpEvt");
88#if PROTOCORE_ENABLE_OBSERVABILITY
93 PROTOCORE_CONN_R_ACCEPT,
94 PROTOCORE_CONN_R_CLOSE_REMOTE,
95 PROTOCORE_CONN_R_CLOSE_LOCAL,
96 PROTOCORE_CONN_R_ERROR,
97 PROTOCORE_CONN_R_TIMEOUT,
98 PROTOCORE_CONN_R_ABORT,
99 PROTOCORE_CONN_R_DRAINED,
100 PROTOCORE_CONN_R_BACKPRESSURE,
101 PROTOCORE_CONN_R_DEFER_DROP
102} protocore_conn_reason;
103static_assert(
sizeof(protocore_conn_reason) == 1,
"protocore_conn_reason must stay one byte (PROTO_ENUM_PACKED)");
106typedef struct protocore_conn_counters
109 uint32_t closes_remote;
110 uint32_t closes_local;
111 uint32_t closes_error;
112 uint32_t closes_timeout;
113 uint32_t closes_abort;
114 uint32_t backpressure;
115 uint32_t defer_drops;
116 uint32_t closing_gauge;
117} protocore_conn_counters;
127typedef void (*protocore_conn_event_cb)(uint8_t slot,
ConnState old_state,
ConnState new_state,
128 protocore_conn_reason reason);
132void protocore_obs_transition(uint8_t slot,
ConnState olds,
ConnState news, protocore_conn_reason reason);
133void protocore_obs_notice(uint8_t slot,
ConnState st, protocore_conn_reason reason);
134#define PROTOCORE_OBS_TRANSITION(slot, olds, news, reason) protocore_obs_transition((slot), (olds), (news), (reason))
135#define PROTOCORE_OBS_NOTICE(slot, st, reason) protocore_obs_notice((slot), (st), (reason))
141#define PROTOCORE_OBS_TRANSITION(slot, olds, news, reason) ((void)0)
142#define PROTOCORE_OBS_NOTICE(slot, st, reason) ((void)0)
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
enum PROTO_ENUM_PACKED EvtType
Type of connection event posted to a listener's event queue.
enum PROTO_ENUM_PACKED ConnState
Lifecycle state of a connection pool slot.
@ EVT_CONNECT
New connection accepted.
@ CONN_FREE
Slot is available; no control block is attached.
@ EVT_DISCONNECT
Remote peer closed the connection gracefully.
@ CONN_ACTIVE
Live connection; the control block is valid.
@ EVT_ERROR
The stack reported an error (the control block may already be freed).
@ EVT_DATA
Data received; bytes are already in the ring buffer.
Event record posted from the stack callbacks to the session layer.
EvtType type
What happened.
size_t data_len
Bytes copied (EVT_DATA only); 0 for other types.
uint8_t slot_id
Which connection slot is affected.