31#ifndef DETERMINISTICESPASYNCWEBSERVER_LISTENER_H
32#define DETERMINISTICESPASYNCWEBSERVER_LISTENER_H
35#include "freertos/FreeRTOS.h"
36#include "freertos/queue.h"
139#if DETWS_WORKER_COUNT > 1
141void listener_worker_queues_init(
void);
144QueueHandle_t listener_worker_queue(
int worker_id);
User-facing configuration for DeterministicESPAsyncWebServer.
#define MAX_LISTENERS
Maximum number of simultaneously active listener ports.
ConnProto
Application protocol spoken on a listener port or connection slot.
#define EVT_QUEUE_DEPTH
Depth of the FreeRTOS event queue shared between lwIP callbacks and the main-loop task.
bool listener_enqueue(uint8_t listener_id, const TcpEvt *evt)
Post evt to the queue owned by listener listener_id.
bool listener_ip_allow_add(const DetIp *network, uint8_t prefix_len)
Add a CIDR rule to the source-IP allowlist.
void listener_stop_all()
Stop all active listeners.
bool listener_accept_allowed_ip(const DetIp *ip, uint32_t now_ms)
Fixed-window per-IP accept-rate gate (connection-flood defense, keyed by source address).
void listener_per_ip_throttle_reset(void)
Reset the per-IP throttle bucket table.
void listener_stop(uint8_t idx)
Stop listening on the port at idx and release its resources.
bool listener_ip_allowed(const DetIp *ip)
Test a source address against the allowlist (accept-time firewall).
int32_t listener_add(uint8_t idx, uint16_t port, ConnProto proto, bool tls=false)
Create a listening socket on port and register it at idx.
int32_t listener_add_dynamic(uint8_t idx, uint16_t port, ConnProto proto)
Add / stop a listener from a running task (thread-safe variant).
bool listener_accept_allowed(uint32_t now_ms)
Fixed-window global accept-rate gate (connection-flood defense).
bool listener_ip_allow_add_cidr(const char *cidr)
Add an allowlist rule from CIDR text (the ergonomic public entry point).
void listener_accept_throttle_reset(void)
Reset the accept-throttle window counters.
Listener listener_pool[MAX_LISTENERS]
Static pool of listener contexts. Defined in listener.cpp.
void listener_stop_dynamic(uint8_t idx)
void listener_ip_allowlist_reset(void)
Clear all allowlist rules (the allowlist becomes empty = allow all).
A v4 or v6 address in network (big-endian) byte order.
State for one TCP listening port.
QueueHandle_t queue
Handle returned by xQueueCreateStatic().
ConnProto proto
Application protocol for all connections accepted here.
bool tls
True when connections accepted here begin a TLS handshake.
uint8_t _queue_storage[EVT_QUEUE_DEPTH *sizeof(TcpEvt)]
Queue backing store.
uint16_t port
TCP port this listener binds.
bool active
True after listener_add(), false after listener_stop().
StaticQueue_t _queue_struct
FreeRTOS static queue descriptor.
struct tcp_pcb * listen_pcb
lwIP listen PCB; nullptr when inactive.
Event record posted from lwIP callbacks to the session layer.
Layer 4 (Transport) - TCP connection pool, ring buffers, and lwIP integration.