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 */
145#if !defined(CONFIG_UNICOAP_OPTIONS_FULL_SUPPORT) || defined(DOXYGEN)
146# define CONFIG_UNICOAP_OPTIONS_FULL_SUPPORT 1
147#endif
148
154#if !defined(CONFIG_UNICOAP_OPTIONS_MAX) || defined(DOXYGEN)
155# define CONFIG_UNICOAP_OPTIONS_MAX (16)
156#endif
157
167#if !defined(CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY) || defined(DOXYGEN)
168# define CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY (32)
169#endif
170
175#define UNICOAP_HEADER_SIZE_MAX (15)
176/* MARK: unicoap_driver_extension_point */
177/* Developer note: If you are adding another CoAP driver, you may need to increase this value. */
178
184#if !defined(CONFIG_UNICOAP_EXTERNAL_TOKEN_LENGTH_MAX) || defined(DOXYGEN)
185# define CONFIG_UNICOAP_EXTERNAL_TOKEN_LENGTH_MAX (8)
186#endif
187
189 "CONFIG_UNICOAP_EXTERNAL_TOKEN_LENGTH_MAX must not be zero");
190
196#if !defined(CONFIG_UNICOAP_GENERATED_TOKEN_LENGTH) || defined(DOXYGEN)
197# define CONFIG_UNICOAP_GENERATED_TOKEN_LENGTH (2)
198#endif
199
201 "CONFIG_UNICOAP_GENERATED_TOKEN_LENGTH must not be zero");
202
206#define UNICOAP_ETAG_LENGTH_FIXED_WIDTH 4
207
217#if !defined(CONFIG_UNICOAP_PDU_SIZE_MAX) || defined(DOXYGEN)
218# define CONFIG_UNICOAP_PDU_SIZE_MAX (128)
219#endif
220
228#if !defined(CONFIG_UNICOAP_WELL_KNOWN_CORE_SIZE_MAX) || defined(DOXYGEN)
229# define CONFIG_UNICOAP_WELL_KNOWN_CORE_SIZE_MAX (120)
230#endif
232
233/* MARK: - Timing */
241
245#define UNICOAP_NSTART (1)
246
250#define UNICOAP_DEFAULT_LEISURE (5)
252
253/* MARK: - Resource observation */
263#if !defined(CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH) || defined(DOXYGEN)
264# define CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH (3)
265#endif
266
270#if (CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH == 3)
271# define UNICOAP_OBSERVE_TICK_EXPONENT (0)
272#elif (CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH == 2)
273# define UNICOAP_OBSERVE_TICK_EXPONENT (6)
274#elif (CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH == 1)
275# define UNICOAP_OBSERVE_TICK_EXPONENT (14)
276#else
277# error CONFIG_UNICOAP_OBSERVE_VALUE_WIDTH must not exceed 3
278#endif
280
281/* MARK: - Server */
294#if !defined(CONFIG_UNICOAP_PREVENT_OPTIONAL_RESPONSES) || defined(DOXYGEN)
295# define CONFIG_UNICOAP_PREVENT_OPTIONAL_RESPONSES 0
296#endif
303#if !defined(CONFIG_UNICOAP_WELL_KNOWN_CORE) || defined(DOXYGEN)
304# define CONFIG_UNICOAP_WELL_KNOWN_CORE (1)
305#endif
307
308/* MARK: - RFC 7252 messaging */
325#if !defined(CONFIG_UNICOAP_RANDOM_FACTOR_1000) || defined(DOXYGEN)
326# define CONFIG_UNICOAP_RANDOM_FACTOR_1000 (1500)
327#endif
328
330#define UNICOAP_TIMEOUT_ACK_RANGE_UPPER \
331 ((uint32_t)CONFIG_UNICOAP_TIMEOUT_ACK_MS * CONFIG_UNICOAP_RANDOM_FACTOR_1000 / 1000)
332
345#if !defined(CONFIG_UNICOAP_TIMEOUT_ACK_MS) || DOXYGEN
346# define CONFIG_UNICOAP_TIMEOUT_ACK_MS (2000)
347#endif
348
354#if !defined(CONFIG_UNICOAP_RETRANSMISSIONS_MAX) || DOXYGEN
355# define CONFIG_UNICOAP_RETRANSMISSIONS_MAX (4)
356#endif
357
358static_assert(CONFIG_UNICOAP_RETRANSMISSIONS_MAX < 32,
359 "CONFIG_UNICOAP_RETRANSMISSIONS_MAX must not exceed 31");
360
367#if !defined(CONFIG_UNICOAP_RFC7252_TRANSMISSIONS_MAX) || defined(DOXYGEN)
368# define CONFIG_UNICOAP_RFC7252_TRANSMISSIONS_MAX 2
369#endif
370
371/* TODO: Client and advanced server features: Limit to exchange-layer state objects */
372
387#if !defined(CONFIG_UNICOAP_CARBON_COPIES_MAX) || defined(DOXYGEN)
388# define CONFIG_UNICOAP_CARBON_COPIES_MAX (2)
389#endif
391
392/* MARK: - DTLS */
407#if !defined(CONFIG_UNICOAP_DTLS_HANDSHAKE_TIMEOUT_MS) || defined(DOXYGEN)
408# define CONFIG_UNICOAP_DTLS_HANDSHAKE_TIMEOUT_MS (3 * MS_PER_SEC)
409#endif
410
418#if !defined(CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS) || defined(DOXYGEN)
419# define CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS (1)
420#endif
421
428#if !defined(CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS_TIMEOUT_MS) || defined(DOXYGEN)
429# define CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS_TIMEOUT_MS (15 * MS_PER_SEC)
430#endif
433
434/* MARK: - Stack sizes */
442#if !defined(UNICOAP_STACK_SIZE) || defined(DOXYGEN)
443
447# if IS_USED(MODULE_UNICOAP_DRIVER_DTLS)
448# define UNICOAP_DTLS_EXTRA_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
449# else
450# define UNICOAP_DTLS_EXTRA_STACKSIZE (0)
451# endif
452
458# define UNICOAP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE + \
459 CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY + UNICOAP_DTLS_EXTRA_STACKSIZE)
460#endif
462
463/* TODO: Put the following into the Automatic Block-wise Transfers Group once available */
464
470#if !defined(CONFIG_UNICOAP_BLOCK_SIZE) || defined(DOXYGEN)
471# define CONFIG_UNICOAP_BLOCK_SIZE (32)
472#endif
473
474#ifndef DOXYGEN
475# ifdef CONFIG_UNICOAP_BLOCK_SZX
476# error CONFIG_UNICOAP_BLOCK_SZX must not be configured manually.
477# endif
478# if CONFIG_UNICOAP_BLOCK_SIZE == 1024
479# define CONFIG_UNICOAP_BLOCK_SZX (6)
480# elif CONFIG_UNICOAP_BLOCK_SIZE == 512
481# define CONFIG_UNICOAP_BLOCK_SZX (5)
482# elif CONFIG_UNICOAP_BLOCK_SIZE == 256
483# define CONFIG_UNICOAP_BLOCK_SZX (4)
484# elif CONFIG_UNICOAP_BLOCK_SIZE == 128
485# define CONFIG_UNICOAP_BLOCK_SZX (3)
486# elif CONFIG_UNICOAP_BLOCK_SIZE == 64
487# define CONFIG_UNICOAP_BLOCK_SZX (2)
488# elif CONFIG_UNICOAP_BLOCK_SIZE == 32
489# define CONFIG_UNICOAP_BLOCK_SZX (1)
490# elif CONFIG_UNICOAP_BLOCK_SIZE == 16
491# define CONFIG_UNICOAP_BLOCK_SZX (0)
492# else
493# error CONFIG_UNICOAP_BLOCK_SIZE must be 1024, 512, 256, 128, 64, 32, or 16
494# endif
495#endif
496
497/* TODO: Add static_asserts once other Block-wise parameters are available */
498
499#ifdef __cplusplus
500extern "C" {
501}
502#endif
503
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:197
#define CONFIG_UNICOAP_RETRANSMISSIONS_MAX
Maximum number of retransmissions of a confirmable message.
Definition config.h:355
#define CONFIG_UNICOAP_EXTERNAL_TOKEN_LENGTH_MAX
Maximum length of a token received from a client.
Definition config.h:185
Common macros and compiler attributes/pragmas configuration.