DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
coaps.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file coaps.h
6 * @brief CoAP over DTLS (CoAPs, RFC 7252 §9) - the bridge between the DTLS 1.3 server and the CoAP
7 * request handler.
8 *
9 * CoAP secured with DTLS is the standard way to run CoAP over the open Internet (coaps://, UDP port
10 * 5684). This is the transport-neutral glue: it drives one @ref DtlsConn through its handshake and,
11 * once established, unwraps each encrypted application record, hands the CoAP request to
12 * coap_server_process(), and re-wraps the response. The socket / per-peer routing lives in a thin
13 * front-end (dtls_server) on top; this file has no sockets, so it is host-testable with an in-test
14 * DTLS client, exactly like dtls_conn itself.
15 *
16 * @author Douglas Quigg (dstroy0)
17 * @date 2026
18 */
19
20#ifndef DETERMINISTICESPASYNCWEBSERVER_COAPS_H
21#define DETERMINISTICESPASYNCWEBSERVER_COAPS_H
22
23#include "ServerConfig.h"
24
25#if DETWS_ENABLE_DTLS && DETWS_ENABLE_COAP
26
28#include <stddef.h>
29#include <stdint.h>
30
31/**
32 * @brief Process one inbound DTLS datagram for a CoAP-over-DTLS connection @p c.
33 *
34 * While the handshake is in progress the datagram is driven through @ref dtls_conn_process. Once the
35 * connection is established, an epoch-3 application record is decrypted, its CoAP request is answered
36 * by coap_server_process(), and the response is sealed as an epoch-3 record. A handshake record that
37 * arrives after establishment (a retransmitted client Finished whose ACK was lost) is routed back to
38 * the state machine so it is re-acknowledged (RFC 9147 §5.8.3).
39 *
40 * @return bytes written to @p out (0 if there is nothing to send), or -1 on a fatal handshake error
41 * (then @p c is FAILED and @ref dtls_conn_alert gives the reason).
42 */
43int coaps_process(DtlsConn *c, const uint8_t *dgram, size_t len, uint8_t *out, size_t out_cap);
44
45#endif // DETWS_ENABLE_DTLS && DETWS_ENABLE_COAP
46#endif // DETERMINISTICESPASYNCWEBSERVER_COAPS_H
User-facing configuration for DeterministicESPAsyncWebServer.
DTLS 1.3 server handshake state machine (RFC 9147 §5-6).