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

Layer 4 (Transport) - the TCP/lower-level interface (RFC 9293 sec 3.9.2). More...

Go to the source code of this file.

Classes

struct  TcpLowerVars
 
struct  TcpLowerNs
 The entries. More...
 

Macros

#define PROTOCORE_TCP_TTL   64
 The TTL outbound TCP segments carry.
 

Typedefs

typedef enum PROTO_ENUM_PACKED protocore_tcp_op
 Which call into the lower-level module a marshaled op performs.
 

Enumerations

enum  PROTO_ENUM_PACKED {
  PROTOCORE_OP_SEND , PROTOCORE_OP_OUTPUT , PROTOCORE_OP_CLOSE , PROTOCORE_OP_ABORT ,
  PROTOCORE_OP_DETACH , PROTOCORE_OP_RAWSEND , PROTOCORE_OP_CLOSE_CHECK , PROTOCORE_OP_RECVED ,
  PROTOCORE_OP_SET_TTL
}
 Which call into the lower-level module a marshaled op performs. More...
 

Functions

void protocore_tcp_lower_marshal (uint8_t *work)
 
void protocore_tcp_lower_detach (uint8_t *work)
 
void protocore_tcp_lower_abort (uint8_t *work)
 
void protocore_tcp_lower_set_ttl (uint8_t *work)
 
void protocore_tcp_lower_apply_ttl (uint8_t *work)
 
uint8_t * protocore_tcp_lower_span (void)
 The PROTOCORE_TCP_LOWER_BORROW bytes this module's state lives in.
 

Variables

TcpLowerVars TcpLowerV
 The operands and the outcome.
 

Detailed Description

Layer 4 (Transport) - the TCP/lower-level interface (RFC 9293 sec 3.9.2).

"The TCP endpoint calls on a lower-level protocol module to actually send and receive information over a network." Every such call this library makes goes through here: the write, the push, the close, the reset, the window update, and the DS field (sec 3.9.2 names the Diffserv value as one the user supplies to the lower layer).

The byte stream is the floor. Nothing below the platform's own TCP is modelled here; this module is the one place that names it, so no other file in the layer holds a raw stack call.

Why the ops are marshaled The raw stack API is not thread-safe: its callbacks run in the stack's own task, while this library issues writes and closes from a worker. Issuing one concurrently with the stack processing an inbound segment corrupts the connection state. The portable fix is the stack's own marshaling call, which runs a function inside the stack's context and blocks the caller until it completes. A raw callback already runs in that context and must NOT marshal again - it performs its op inline instead, or it would block on the very mailbox its own thread services.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file lower.h.

Macro Definition Documentation

◆ PROTOCORE_TCP_TTL

#define PROTOCORE_TCP_TTL   64

The TTL outbound TCP segments carry.

RFC 9293 sec 3.9.2 MUST-49: "The TTL value used to send TCP segments MUST be configurable." RFC 793 fixed it at one minute; RFC 1122 replaced that with this requirement. Overridable at build time; the running value is set through TcpLowerNs::set_ttl, which takes the candidate in len, and stamped onto a control block by TcpLowerNs::apply_ttl.

Definition at line 46 of file lower.h.

Typedef Documentation

◆ protocore_tcp_op

Which call into the lower-level module a marshaled op performs.

Enumeration Type Documentation

◆ PROTO_ENUM_PACKED

Which call into the lower-level module a marshaled op performs.

Enumerator
PROTOCORE_OP_SEND 
PROTOCORE_OP_OUTPUT 
PROTOCORE_OP_CLOSE 
PROTOCORE_OP_ABORT 
PROTOCORE_OP_DETACH 
PROTOCORE_OP_RAWSEND 
PROTOCORE_OP_CLOSE_CHECK 
PROTOCORE_OP_RECVED 
PROTOCORE_OP_SET_TTL 

Definition at line 50 of file lower.h.

Function Documentation

◆ protocore_tcp_lower_marshal()

void protocore_tcp_lower_marshal ( uint8_t *  work)

◆ protocore_tcp_lower_detach()

void protocore_tcp_lower_detach ( uint8_t *  work)

◆ protocore_tcp_lower_abort()

void protocore_tcp_lower_abort ( uint8_t *  work)

◆ protocore_tcp_lower_set_ttl()

void protocore_tcp_lower_set_ttl ( uint8_t *  work)

◆ protocore_tcp_lower_apply_ttl()

void protocore_tcp_lower_apply_ttl ( uint8_t *  work)

◆ protocore_tcp_lower_span()

uint8_t * protocore_tcp_lower_span ( void  )

The PROTOCORE_TCP_LOWER_BORROW bytes this module's state lives in.

Stated beside the namespace rather than on it: an entry takes a borrow, and this is where that borrow comes from. Taken once from the end of the pool, which no mark and no release walks, so the state lasts the life of the program.

Returns
the span.

Variable Documentation

◆ TcpLowerV

TcpLowerVars TcpLowerV
extern

The operands and the outcome.