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)
#define PROTOCORE_OBS_NOTICE(slot, st, reason)

Typedefs

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

Functions

 EMBED_ENUM_BYTE (ConnState, CONN_FREE, CONN_ACTIVE, CONN_CLOSING)
 Lifecycle state of a connection pool slot.
 EMBED_ENUM_BYTE (EvtType, EVT_CONNECT, EVT_DATA, EVT_DISCONNECT, EVT_ERROR)
 Type of connection event posted to a listener's event queue.

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 fields and their atomic words, and the sketches do not need 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 )
Value:
((void)0)

Definition at line 137 of file evt.h.

◆ PROTOCORE_OBS_NOTICE

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

Definition at line 138 of file evt.h.

Typedef Documentation

◆ 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.

Function Documentation

◆ EMBED_ENUM_BYTE() [1/2]

EMBED_ENUM_BYTE ( ConnState ,
CONN_FREE ,
CONN_ACTIVE ,
CONN_CLOSING  )

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.

◆ EMBED_ENUM_BYTE() [2/2]

EMBED_ENUM_BYTE ( EvtType ,
EVT_CONNECT ,
EVT_DATA ,
EVT_DISCONNECT ,
EVT_ERROR  )

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.