ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
evt.h File Reference

What the stack callbacks post to a listener's queue: the event type and the record. More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  TcpEvt
 Event record posted from the stack callbacks to the session layer. More...
 

Macros

#define PROTOCORE_OBS_TRANSITION(slot, olds, news, reason)   ((void)0)
 
#define PROTOCORE_OBS_NOTICE(slot, st, reason)   ((void)0)
 

Typedefs

typedef enum PROTO_ENUM_PACKED ConnState
 Lifecycle state of a connection pool slot.
 
typedef enum PROTO_ENUM_PACKED EvtType
 Type of connection event posted to a listener's event queue.
 
typedef struct TcpEvt TcpEvt
 Event record posted from the stack callbacks to the session layer.
 

Enumerations

enum  PROTO_ENUM_PACKED {
  CONN_FREE , CONN_ACTIVE , CONN_CLOSING , EVT_CONNECT ,
  EVT_DATA , EVT_DISCONNECT , EVT_ERROR
}
 Lifecycle state of a connection pool slot. More...
 
enum  PROTO_ENUM_PACKED {
  CONN_FREE , CONN_ACTIVE , CONN_CLOSING , EVT_CONNECT ,
  EVT_DATA , EVT_DISCONNECT , EVT_ERROR
}
 Type of connection event posted to a listener's event queue. More...
 

Detailed Description

What the stack callbacks post to a listener's queue: the event type and the record.

Separate from common.h because this is all the layers above the transport need. A listener sizes its queue storage on TcpEvt, the session layer switches on EvtType, and the presentation layer names EVT_CONNECT; none of them touches a connection slot's fields. common.h carries those, and the ring cursors in them are _Atomic, which is C11 and not C++ - so a header that reaches the sketches through protocore.h cannot be the one that declares them.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file evt.h.

Macro Definition Documentation

◆ PROTOCORE_OBS_TRANSITION

#define PROTOCORE_OBS_TRANSITION (   slot,
  olds,
  news,
  reason 
)    ((void)0)

Definition at line 141 of file evt.h.

◆ PROTOCORE_OBS_NOTICE

#define PROTOCORE_OBS_NOTICE (   slot,
  st,
  reason 
)    ((void)0)

Definition at line 142 of file evt.h.

Typedef Documentation

◆ ConnState

Lifecycle state of a connection pool slot.

NOT the RFC 9293 sec 3.3.2 connection state machine. That machine (LISTEN, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1/2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT) belongs to the stack under this layer; these three name only whether the pool slot is available. A test mapping CONN_* to RFC state names 1:1 is testing the wrong thing.

Transitions, as the code performs them:

  • CONN_FREE -> CONN_ACTIVE accept callback fires.
  • CONN_ACTIVE -> CONN_CLOSING the dwell that precedes a close begins.
  • CONN_CLOSING -> CONN_FREE the peer ACKed the outbound data (snd_queuelen == 0), the dwell timed out, or data arrived that could no longer be delivered.
  • CONN_ACTIVE -> CONN_FREE local close, remote FIN, stack error, or the idle sweep.

Every terminal edge detaches the control block and frees the slot before handing it to the stack, so the slot's lifetime ends before the connection's does; the FIN and its retransmission are the stack's from that point (RFC 9293 sec 3.6).

Here rather than in common.h because the signaling layer reads a slot's state and reaches this layer through protocore.h; the enum is one packed byte and carries no _Atomic.

◆ EvtType

typedef enum PROTO_ENUM_PACKED EvtType

Type of connection event posted to a listener's event queue.

EVT_DISCONNECT and EVT_ERROR are the two a close is reported through, and they are distinct because RFC 9293 sec 3.6 MUST-12 requires the layer above to be told whether a connection closed normally or was aborted.

◆ TcpEvt

typedef struct TcpEvt TcpEvt

Event record posted from the stack callbacks to the session layer.

Copied into the queue by value, so nothing in it points at a slot whose lifetime ends before the record is drained.

Enumeration Type Documentation

◆ PROTO_ENUM_PACKED [1/2]

Lifecycle state of a connection pool slot.

NOT the RFC 9293 sec 3.3.2 connection state machine. That machine (LISTEN, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1/2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT) belongs to the stack under this layer; these three name only whether the pool slot is available. A test mapping CONN_* to RFC state names 1:1 is testing the wrong thing.

Transitions, as the code performs them:

  • CONN_FREE -> CONN_ACTIVE accept callback fires.
  • CONN_ACTIVE -> CONN_CLOSING the dwell that precedes a close begins.
  • CONN_CLOSING -> CONN_FREE the peer ACKed the outbound data (snd_queuelen == 0), the dwell timed out, or data arrived that could no longer be delivered.
  • CONN_ACTIVE -> CONN_FREE local close, remote FIN, stack error, or the idle sweep.

Every terminal edge detaches the control block and frees the slot before handing it to the stack, so the slot's lifetime ends before the connection's does; the FIN and its retransmission are the stack's from that point (RFC 9293 sec 3.6).

Here rather than in common.h because the signaling layer reads a slot's state and reaches this layer through protocore.h; the enum is one packed byte and carries no _Atomic.

Enumerator
CONN_FREE 

Slot is available; no control block is attached.

CONN_ACTIVE 

Live connection; the control block is valid.

CONN_CLOSING 

Transmit-drain dwell: holding the slot until the peer ACKs what was sent. No FIN has been emitted yet - it goes out as the slot is released.

EVT_CONNECT 

New connection accepted.

EVT_DATA 

Data received; bytes are already in the ring buffer.

EVT_DISCONNECT 

Remote peer closed the connection gracefully.

EVT_ERROR 

The stack reported an error (the control block may already be freed).

Definition at line 45 of file evt.h.

◆ PROTO_ENUM_PACKED [2/2]

Type of connection event posted to a listener's event queue.

EVT_DISCONNECT and EVT_ERROR are the two a close is reported through, and they are distinct because RFC 9293 sec 3.6 MUST-12 requires the layer above to be told whether a connection closed normally or was aborted.

Enumerator
CONN_FREE 

Slot is available; no control block is attached.

CONN_ACTIVE 

Live connection; the control block is valid.

CONN_CLOSING 

Transmit-drain dwell: holding the slot until the peer ACKs what was sent. No FIN has been emitted yet - it goes out as the slot is released.

EVT_CONNECT 

New connection accepted.

EVT_DATA 

Data received; bytes are already in the ring buffer.

EVT_DISCONNECT 

Remote peer closed the connection gracefully.

EVT_ERROR 

The stack reported an error (the control block may already be freed).

Definition at line 62 of file evt.h.