ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
TcpConn Struct Reference

A single TCP connection context. More...

#include <tcp.h>

Public Attributes

uint8_t id
 Fixed slot index (0 … MAX_CONNS-1).
 
pc_atomic< ConnStatestate
 Lifecycle state; acquire/release for inter-task visibility.
 
struct tcp_pcb * pcb
 lwIP PCB; null when slot is free.
 
uint32_t last_activity_ms
 millis() timestamp of last TX/RX event.
 
uint32_t req_start_ms
 
uint8_t rx_buffer [RX_BUF_SIZE]
 Ring buffer storage.
 
pc_atomic< size_t > rx_head
 Producer write index (lwIP/tcpip context).
 
pc_atomic< size_t > rx_tail
 Consumer read index (worker context).
 
size_t rx_acked
 
uint8_t listener_id
 Index into listener_pool[]; set at accept time.
 
uint8_t owner
 Worker that owns this slot (round-robin at accept). Always 0 at N=1.
 
ConnProto proto
 Application protocol for this connection.
 
uint8_t proto_slot
 Per-protocol session/pool index (0xFF = none): the SSH session, an MQTT/Modbus session, etc.
 
pc_iface iface
 Interface this connection arrived on; set at accept time.
 
uint8_t tls
 Non-zero when this connection is TLS (set at accept time).
 

Detailed Description

A single TCP connection context.

Sized so that MAX_CONNS instances fit in a static array without fragmentation. All fields except the volatile ring-buffer indices may only be accessed from the Arduino main-loop task.

Definition at line 71 of file tcp.h.

Member Data Documentation

◆ id

◆ state

◆ pcb

◆ last_activity_ms

uint32_t TcpConn::last_activity_ms

millis() timestamp of last TX/RX event.

Definition at line 76 of file tcp.h.

Referenced by DeterministicAsyncTCP::check_timeouts(), listener_accept_cb(), lowlevel_recv_cb(), lowlevel_sent_cb(), pc_conn_begin_close(), and pc_conn_touch_active().

◆ req_start_ms

uint32_t TcpConn::req_start_ms

millis() at the first byte of the in-progress request (0 = none). The request-header deadline (PC_REQUEST_TIMEOUT_MS, slow-loris defense) measures against this; unlike last_activity_ms a trickle byte cannot reset it.

Definition at line 77 of file tcp.h.

Referenced by PC::http_poll_slot(), listener_accept_cb(), and lowlevel_recv_cb().

◆ rx_buffer

uint8_t TcpConn::rx_buffer[RX_BUF_SIZE]

Ring buffer storage.

Definition at line 81 of file tcp.h.

Referenced by lowlevel_recv_cb().

◆ rx_head

pc_atomic<size_t> TcpConn::rx_head

Producer write index (lwIP/tcpip context).

Definition at line 82 of file tcp.h.

Referenced by listener_accept_cb(), and lowlevel_recv_cb().

◆ rx_tail

pc_atomic<size_t> TcpConn::rx_tail

Consumer read index (worker context).

Definition at line 83 of file tcp.h.

Referenced by listener_accept_cb(), lowlevel_recv_cb(), and pc_conn_ack_consumed().

◆ rx_acked

size_t TcpConn::rx_acked

rx_tail position last ACKed to lwIP (tcp_recved). Worker-only: the window is reopened by exactly the bytes drained since, so it tracks ring occupancy (ack-on-consume) rather than copy.

Definition at line 84 of file tcp.h.

Referenced by listener_accept_cb(), and pc_conn_ack_consumed().

◆ listener_id

uint8_t TcpConn::listener_id

Index into listener_pool[]; set at accept time.

Definition at line 88 of file tcp.h.

Referenced by listener_accept_cb().

◆ owner

uint8_t TcpConn::owner

Worker that owns this slot (round-robin at accept). Always 0 at N=1.

Definition at line 89 of file tcp.h.

Referenced by DeterministicAsyncTCP::check_timeouts(), listener_accept_cb(), listener_enqueue(), and lowlevel_sent_cb().

◆ proto

ConnProto TcpConn::proto

Application protocol for this connection.

Definition at line 90 of file tcp.h.

Referenced by listener_accept_cb().

◆ proto_slot

uint8_t TcpConn::proto_slot

Per-protocol session/pool index (0xFF = none): the SSH session, an MQTT/Modbus session, etc.

Definition at line 92 of file tcp.h.

Referenced by pc_ssh_conn_accept(), pc_ssh_conn_close(), pc_ssh_conn_poll(), and pc_ssh_conn_rx().

◆ iface

pc_iface TcpConn::iface

Interface this connection arrived on; set at accept time.

Definition at line 93 of file tcp.h.

Referenced by listener_accept_cb().

◆ tls

uint8_t TcpConn::tls

Non-zero when this connection is TLS (set at accept time).

Definition at line 94 of file tcp.h.

Referenced by listener_accept_cb(), pc_conn_abort_slot(), and pc_conn_close().


The documentation for this struct was generated from the following file: