|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
Layer 4 (Transport) - the connection state every half of TCP reads. More...
#include "config/platform/platform.h"#include "memoria_anularis/memoria_anularis.h"#include "network_drivers/transport/tcp/evt/evt.h"#include "shared/ip/ip.h"#include <stdatomic.h>#include "protocore_config.h"Go to the source code of this file.
Classes | |
| struct | TcpConn |
| A single TCP connection context. More... | |
| struct | Listener |
| State for one TCP listening port. More... | |
Macros | |
| #define | PROTOCORE_PROTO_SLOT_NONE 0xFFu |
| Sentinel for TcpConn.proto_slot meaning "no per-protocol session bound". | |
| #define | PROTOCORE_DSCP_UNSET 0xFF |
| The row carries no code point of its own; accept() takes the server-wide default. | |
Typedefs | |
| typedef PROTOCORE_BEGIN_DECLS struct TcpConn | TcpConn |
| A single TCP connection context. | |
Variables | |
| uint32_t | protocore_ap_ip |
| Access-point IPv4 address (network byte order) for STA/AP interface tagging. | |
| TcpConn | conn_pool [CONN_POOL_SLOTS] |
| Static pool of connection contexts. Defined in protocol/protocol.c. Sized CONN_POOL_SLOTS: MAX_CONNS TCP slots plus any reserved internal dispatch slot(s) (HTTP/3); the TCP accept path only ever uses [0, MAX_CONNS). | |
| Listener | listener_pool [MAX_LISTENERS] |
| Static pool of listener contexts. Defined in server.c. | |
Layer 4 (Transport) - the connection state every half of TCP reads.
RFC 9293 sec 3.3.1 calls these the key connection state variables. Here that is the pool slot: its lifecycle state, its receive ring, and the identity fields the layers above filter on. The server (sec 3.9.1.1 passive OPEN), the client (active OPEN), the protocol engine (sec 3.10) and the lower-level seam (sec 3.9.2) all read this header and none of them declares its own copy.
The event record itself is in evt.h, which this includes: the slot state below is _Atomic, which is C11 and not C++, so the header that reaches the sketches has to be the smaller one.
Concurrency model
| Context | Reads | Writes |
|---|---|---|
| stack callbacks | anularis.vacant (to check) | anularis.put |
| main loop | anularis.available/read/peek | anularis.read/consume |
The receive ring is a memoria_anularis ring over the slot's own aligned rx_buffer: one producer (the stack callbacks) and one consumer (the owning worker), with the ordering inside the ring. state is _Atomic, read and written through PROTO_ATOMIC_LOAD / PROTO_ATOMIC_STORE.
Backpressure (lossless) When a whole inbound segment will not fit the free ring space, the recv callback refuses it without taking ownership of the segment; the stack holds it and redelivers once the main loop has drained the ring, so no received byte is dropped. Requires RX_BUF_SIZE > one TCP segment (TCP_MSS).
Definition in file common.h.
| #define PROTOCORE_PROTO_SLOT_NONE 0xFFu |
| #define PROTOCORE_DSCP_UNSET 0xFF |
The row carries no code point of its own; accept() takes the server-wide default.
Stated here rather than in diffserv.h because it is a value of Listener::dscp, which every build has: a port either names a code point or does not, and only whether the accept callback stamps one into the DS field depends on PROTOCORE_ENABLE_DIFFSERV.
| typedef PROTOCORE_BEGIN_DECLS struct TcpConn TcpConn |
A single TCP connection context.
Sized so that MAX_CONNS instances fit in a static array without fragmentation. All fields except the ring and the state may only be accessed from the main-loop task.
|
extern |
Access-point IPv4 address (network byte order) for STA/AP interface tagging.
Zero when no access point is configured. Set via set_ap_ip(); the accept callback tags each connection PROTOCORE_IF_WIFI_AP when its local IP equals this, else PROTOCORE_IF_WIFI_STA. Used by per-route interface filters.
|
extern |
Static pool of connection contexts. Defined in protocol/protocol.c. Sized CONN_POOL_SLOTS: MAX_CONNS TCP slots plus any reserved internal dispatch slot(s) (HTTP/3); the TCP accept path only ever uses [0, MAX_CONNS).
|
extern |
Static pool of listener contexts. Defined in server.c.