Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024-2026 Carl Seifert
3 * SPDX-FileCopyrightText: 2024-2026 TU Dresden
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#pragma once
8
9#include <assert.h>
10
11#include "modules.h"
12
20
26
27/* MARK: - Essentials */
42#if !defined(CONFIG_UNICOAP_CREATE_THREAD) || defined(DOXYGEN)
43# define CONFIG_UNICOAP_CREATE_THREAD 1
44#endif
45
53#if !defined(CONFIG_UNICOAP_DEBUG_LOGGING) || defined(DOXYGEN)
54# define CONFIG_UNICOAP_DEBUG_LOGGING 0
55#endif
56
68#if !defined(CONFIG_UNICOAP_ASSIST) || defined(DOXYGEN)
69# define CONFIG_UNICOAP_ASSIST CONFIG_UNICOAP_DEBUG_LOGGING
70#endif
71
72#if CONFIG_UNICOAP_DEBUG_LOGGING && !CONFIG_UNICOAP_ASSIST
73# warning Disabling CONFIG_UNICOAP_ASSIST when CONFIG_UNICOAP_DEBUG_LOGGING is enabled has no effect because debug logging implies emitting asstistance diagnostics.
74#endif
76
77/* MARK: - Ports and Sockets */
85#define UNICOAP_DEFAULT_COAP_PORT (5683)
86
90#define UNICOAP_DEFAULT_COAPS_PORT (5684)
91
96#if !defined(CONFIG_UNICOAP_UDP_PORT) || defined(DOXYGEN)
97# define CONFIG_UNICOAP_UDP_PORT UNICOAP_DEFAULT_COAP_PORT
98#endif
99
104#if !defined(CONFIG_UNICOAP_DTLS_PORT) || defined(DOXYGEN)
105# define CONFIG_UNICOAP_DTLS_PORT UNICOAP_DEFAULT_COAPS_PORT
106#endif
107
114#if !defined(CONFIG_UNICOAP_SOCK_ZERO_COPY_GUARANTEES) || defined(DOXYGEN)
115# define CONFIG_UNICOAP_SOCK_ZERO_COPY_GUARANTEES IS_USED(MODULE_GNRC_SOCK_UDP)
116#endif
117
123#if !defined(CONFIG_UNICOAP_GET_LOCAL_ENDPOINTS) || defined(DOXYGEN)
124# define CONFIG_UNICOAP_GET_LOCAL_ENDPOINTS 1
125#endif
127
128/* MARK: - Limits */
138#if !defined(CONFIG_UNICOAP_OPTIONS_MAX) || defined(DOXYGEN)
139# define CONFIG_UNICOAP_OPTIONS_MAX (16)
140#endif
141
151#if !defined(CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY) || defined(DOXYGEN)
152# define CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY (32)
153#endif
154
159#define UNICOAP_HEADER_SIZE_MAX (15)
160/* MARK: unicoap_driver_extension_point */
161/* Developer note: If you are adding another CoAP driver, you may need to increase this value. */
162
168#if !defined(CONFIG_UNICOAP_EXTERNAL_TOKEN_LENGTH_MAX) || defined(DOXYGEN)
169# define CONFIG_UNICOAP_EXTERNAL_TOKEN_LENGTH_MAX (8)
170#endif
171
173 "CONFIG_UNICOAP_EXTERNAL_TOKEN_LENGTH_MAX must not be zero");
174
180#if !defined(CONFIG_UNICOAP_GENERATED_TOKEN_LENGTH) || defined(DOXYGEN)
181# define CONFIG_UNICOAP_GENERATED_TOKEN_LENGTH (2)
182#endif
183
185 "CONFIG_UNICOAP_GENERATED_TOKEN_LENGTH must not be zero");
186
190#define UNICOAP_ETAG_LENGTH_FIXED_WIDTH 4
191
201#if !defined(CONFIG_UNICOAP_PDU_SIZE_MAX) || defined(DOXYGEN)
202# define CONFIG_UNICOAP_PDU_SIZE_MAX (128)
203#endif
204
212#if !defined(CONFIG_UNICOAP_WELL_KNOWN_CORE_SIZE_MAX) || defined(DOXYGEN)
213# define CONFIG_UNICOAP_WELL_KNOWN_CORE_SIZE_MAX (120)
214#endif
216
217/* MARK: - Timing */
225
229#define UNICOAP_NSTART (1)
230
234#define UNICOAP_DEFAULT_LEISURE (5)
236
237/* MARK: - Resource observation */
247#if !defined(CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH) || defined(DOXYGEN)
248# define CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH (3)
249#endif
250
254#if (CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH == 3)
255# define UNICOAP_OBSERVE_TICK_EXPONENT (0)
256#elif (CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH == 2)
257# define UNICOAP_OBSERVE_TICK_EXPONENT (6)
258#elif (CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH == 1)
259# define UNICOAP_OBSERVE_TICK_EXPONENT (14)
260#else
261# error CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH must not exceed 3
262#endif
264
265/* MARK: - Server */
278#if !defined(CONFIG_UNICOAP_PREVENT_OPTIONAL_RESPONSES) || defined(DOXYGEN)
279# define CONFIG_UNICOAP_PREVENT_OPTIONAL_RESPONSES 0
280#endif
287#if !defined(CONFIG_UNICOAP_WELL_KNOWN_CORE) || defined(DOXYGEN)
288# define CONFIG_UNICOAP_WELL_KNOWN_CORE (1)
289#endif
291
292/* MARK: - RFC 7252 messaging */
309#if !defined(CONFIG_UNICOAP_RANDOM_FACTOR_1000) || defined(DOXYGEN)
310# define CONFIG_UNICOAP_RANDOM_FACTOR_1000 (1500)
311#endif
312
314#define UNICOAP_TIMEOUT_ACK_RANGE_UPPER \
315 ((uint32_t)CONFIG_UNICOAP_TIMEOUT_ACK_MS * CONFIG_UNICOAP_RANDOM_FACTOR_1000 / 1000)
316
329#if !defined(CONFIG_UNICOAP_TIMEOUT_ACK_MS) || DOXYGEN
330# define CONFIG_UNICOAP_TIMEOUT_ACK_MS (2000)
331#endif
332
338#if !defined(CONFIG_UNICOAP_RETRANSMISSIONS_MAX) || DOXYGEN
339# define CONFIG_UNICOAP_RETRANSMISSIONS_MAX (4)
340#endif
341
342static_assert(CONFIG_UNICOAP_RETRANSMISSIONS_MAX < 32,
343 "CONFIG_UNICOAP_RETRANSMISSIONS_MAX must not exceed 31");
344
351#if !defined(CONFIG_UNICOAP_RFC7252_TRANSMISSIONS_MAX) || defined(DOXYGEN)
352# define CONFIG_UNICOAP_RFC7252_TRANSMISSIONS_MAX 2
353#endif
354
355/* TODO: Client and advanced server features: Limit to exchange-layer state objects */
356
371#if !defined(CONFIG_UNICOAP_CARBON_COPIES_MAX) || defined(DOXYGEN)
372# define CONFIG_UNICOAP_CARBON_COPIES_MAX (2)
373#endif
375
376/* MARK: - DTLS */
391#if !defined(CONFIG_UNICOAP_DTLS_HANDSHAKE_TIMEOUT_MS) || defined(DOXYGEN)
392# define CONFIG_UNICOAP_DTLS_HANDSHAKE_TIMEOUT_MS (3 * MS_PER_SEC)
393#endif
394
402#if !defined(CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS) || defined(DOXYGEN)
403# define CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS (1)
404#endif
405
412#if !defined(CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS_TIMEOUT_MS) || defined(DOXYGEN)
413# define CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS_TIMEOUT_MS (15 * MS_PER_SEC)
414#endif
417
418/* MARK: - Stack sizes */
426#if !defined(UNICOAP_STACK_SIZE) || defined(DOXYGEN)
427
431# if IS_USED(MODULE_UNICOAP_DRIVER_DTLS)
432# define UNICOAP_DTLS_EXTRA_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
433# else
434# define UNICOAP_DTLS_EXTRA_STACKSIZE (0)
435# endif
436
442# define UNICOAP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE + \
443 CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY + UNICOAP_DTLS_EXTRA_STACKSIZE)
444#endif
446
447/* TODO: Put the following into the Automatic Block-wise Transfers Group once available */
448
454#if !defined(CONFIG_UNICOAP_BLOCK_SIZE) || defined(DOXYGEN)
455# define CONFIG_UNICOAP_BLOCK_SIZE (32)
456#endif
457
458#ifndef DOXYGEN
459# ifdef CONFIG_UNICOAP_BLOCK_SZX
460# error CONFIG_UNICOAP_BLOCK_SZX must not be configured manually.
461# endif
462# if CONFIG_UNICOAP_BLOCK_SIZE == 1024
463# define CONFIG_UNICOAP_BLOCK_SZX (6)
464# elif CONFIG_UNICOAP_BLOCK_SIZE == 512
465# define CONFIG_UNICOAP_BLOCK_SZX (5)
466# elif CONFIG_UNICOAP_BLOCK_SIZE == 256
467# define CONFIG_UNICOAP_BLOCK_SZX (4)
468# elif CONFIG_UNICOAP_BLOCK_SIZE == 128
469# define CONFIG_UNICOAP_BLOCK_SZX (3)
470# elif CONFIG_UNICOAP_BLOCK_SIZE == 64
471# define CONFIG_UNICOAP_BLOCK_SZX (2)
472# elif CONFIG_UNICOAP_BLOCK_SIZE == 32
473# define CONFIG_UNICOAP_BLOCK_SZX (1)
474# elif CONFIG_UNICOAP_BLOCK_SIZE == 16
475# define CONFIG_UNICOAP_BLOCK_SZX (0)
476# else
477# error CONFIG_UNICOAP_BLOCK_SIZE must be 1024, 512, 256, 128, 64, 32, or 16
478# endif
479#endif
480
481/* TODO: Add static_asserts once other Block-wise parameters are available */
482
483#ifdef __cplusplus
484extern "C" {
485}
486#endif
487
POSIX.1-2008 compliant version of the assert macro.
#define CONFIG_UNICOAP_GENERATED_TOKEN_LENGTH
Length of tokens generated by the unicoap client API.
Definition config.h:181
#define CONFIG_UNICOAP_RETRANSMISSIONS_MAX
Maximum number of retransmissions of a confirmable message.
Definition config.h:339
#define CONFIG_UNICOAP_EXTERNAL_TOKEN_LENGTH_MAX
Maximum length of a token received from a client.
Definition config.h:169
Common macros and compiler attributes/pragmas configuration.