Commit Graph
730 Commits
Author SHA1 Message Date
Lucien Zuercher 855d53ef10 oscore: enable external credential storage and safe recipient cleanup
Add reference counting to recipient contexts so they can be safely removed
while still in use by active sessions. Expose callback hooks for credential
lookup, echo, and sequence storage to allow custom backends.
Expand example server to demonstrate the external storage via a simple
file based database. Expand coap_oscore_rcp_conf_t to enable settings
preconfigured echo value, sequence counter and window value as uint64
Enable temporary credentials returned by the find function and are destroyed
after use.
2026-05-20 13:09:24 +01:00
Jon Shallow 9f14450a7e coap_subscribe.c: Fix issue found by oss-fuzz 2026-05-14 15:51:32 +01:00
Jon Shallow 13139e7be9 Options: Check Uri-Path and Location-Path options for . or ..
Check incoming Uri-Path and Location-Path options for just . or .. (or %2e
hex encoded variants) and treat as being invalid.

Stop insertion of Uri-Path and Location-Path options that contain just
. or .. (or %2e hex encoded variants).
2026-05-11 19:41:17 +01:00
Jon Shallow df90dfd7b1 coap_subscribe.c: Sanity check persist startup logic 2026-05-11 18:08:55 +01:00
Magdalena Szumny a77c2c64fe Use Zephyr allocators for Zephyr targets 2026-05-06 13:52:06 +01:00
Jon Shallow de54053789 Q-Block: Reference track coap_lg_srcv_t and coap_lg_crcv_t 2026-05-04 17:46:59 +01:00
Jon Shallow 783b5317ca Uri-Path-Abbrev: Initial IETF Draft support
https://datatracker.ietf.org/doc/html/draft-ietf-core-uri-path-abbrev-04
2026-04-18 12:05:48 +01:00
Jon Shallow edc146d9f1 KeepAlive: Make sure sessions timeout after ping failures
Currently set to 3 concurrent ping failures.
2026-04-18 10:44:44 +01:00
Ernestas Kulik 766b852849 Implement support for LLC sockets
Useful in embedded contexts, where devices might only have a link-layer
connection, but still need to exchange information.
2026-04-18 09:11:19 +01:00
Jon Shallow 3f4d08f964 RateLimit: Support rate limiting NON packets
New coap_context_rate_limit_ppm() function added.

Useful for 6TiSCH type environments.
2026-04-16 13:11:27 +01:00
Jon Shallow 77929465d3 OSCORE: Support complex sender and recipient configurations
Also supports silent_server configuration for recipient definitions.
2026-04-14 10:42:41 +01:00
Jon Shallow 414900ecc3 coap_threadsafe.c: Support multiple use of coap_io_process_configure_threads()
Support for multiple libcoap contexts.
2026-04-08 16:00:01 +01:00
Jon Shallow 5010974814 coap_io_posix.c: Make coap_io_process_remove_threads() thread protected.
Don't report

WARN coap_socket_accept_tcp: accept: Resource temporarily unavailable

when multiple threads are trying to process the same incoming TCP connection.
2026-04-01 15:58:42 +01:00
Jon Shallow 84560ef825 Sanitizer: Fix issues raised by ASan and UBSan when testing 2026-03-24 14:22:45 +00:00
Jon Shallow 39b79e23b4 multi-threading: Lock resource structure when calling request handlers
If an app request call-back modifies any data associated with a resource,
then multiple threads can attempt to unsafely modify the data at the same time.

Lock the resource when calling the app request handler (as global_lock is
unlocked) to prevent concurrent changes to the resource information.

If the app request handler is definately known to not modify the resource
information, then COAP_RESOURCE_SAFE_REQUEST_HANDLER can be set in the flags
for coap_resource_init().  Usually if there is a PUT, POST, PATCH or IPATCH
handler it is unsafe to set this. Setting this will reduce lock contention.
2026-03-23 19:01:53 +00:00
Jon Shallow e817ec85dd coap_resource.c: Fix 2 threads doing a DELETE on the same resource 2026-03-20 13:47:55 +00:00
Jon Shallow 21b7a9a0eb Debugging: Add coap_debug_set_packet_fail() for testing network failures
This is similar to coap_debug_set_packet_loss() which drops packets that are
to be sent, but emulates network reported errors by reporting ECONNREFUSED.
2026-03-20 09:13:41 +00:00
Jon Shallow 40502ffebb oss-fuzz: Fix undefined-behavior
Analyzer run time does not like A -= B or A +=B even if A and B are uint32_t as there is potential
for overflow.

Analyzer run time does not like overflow when doing coap_tick_t - coap_tick_t.

Analyzer run time does not like (uint8_t << 24) as uint8_t is promoted as int, not u_int.

Analyzer run time does not like while(A--) {} even if A is uint32_t, as A is always decremented on
the test, even if the value of A is 0.

Fix potential overflow when analyzing an asn.1 tag.

Fix potential overflow when doing decode_segment() on a % hex value.
2026-03-10 11:09:10 +00:00
Jon Shallow 210cbf378a ASN1: Check for buffer overflows when determining tags and length
Include oss-fuzzer checks.
2026-03-03 10:36:46 +00:00
Florek, Bartlomiej a4d7c29313 fix(config): enhance Zephyr configuration for libcoap 2026-03-03 10:35:36 +00:00
Carl Elgstrom e24ce7a6b3 coap_mem: fix -Werror=return-type in coap_malloc() lwIP stub 2026-02-27 16:32:56 +00:00
Magdalena Szumny e80fe9edd2 API for checking session encryption 2026-02-17 09:57:28 +00:00
Magdalena Szumny f79eaba9b9 Add sorting of optlist 2026-02-16 10:34:48 +00:00
Jon Shallow 152f6a8a58 Includes: Remove unnecessary include files
Include common system header files in coap_internal.h based on HAVE_*H
definitions.

Remove these system header files from include/*/*.h.

Add in system header files where appropriate in various apps.
2026-02-02 10:09:17 +00:00
Jon Shallow c9a4b716c4 binary/strings: Check for size overflows when allocating
Includes a check in coap_block_build_body().
2026-02-02 09:52:55 +00:00
Jon Shallow 07c7a7aa57 body_size: Support configuration of max supported body size for RFC7959
Function coap_context_set_max_body_size() added.

For servers, if body size is too large, a 4.13 response is generated.

For clients, if the body size is too large, the server gets a RST and
no date is passed to the application.  A new event COAP_EVENT_BLOCK_ISSUE
is generated.
2026-01-29 09:53:52 +00:00
Jon Shallow 37334b120f Proxy: Add in support for previously set up upstream servers
Add in new coap_proxy_fwd_add_client_session() function to define the
upstream servers from previously set up sessions (i.e. from call-home).
2026-01-21 15:23:48 +00:00
Jon Shallow d80fa1497d Client: Remove (D)TLS / WebSocket startup call-back timing window
Add in new functions
  coap_new_client_session3()
  coap_new_client_session_pki3()
  coap_new_client_session_psk3()
  coap_new_client_session_oscore3()
  coap_new_client_session_oscore_pki3()
  coap_new_client_session_oscore_psk3()
which effectively does coap_session_set_app_data2() and
coap_ws_set_host_request() early on in the session set up cycle.
2026-01-08 17:51:10 +00:00
Jon Shallow c9135b6b26 Copyright: Update to 2026 2026-01-05 10:37:26 +00:00
Jon Shallow 08ae1a7c08 Multi-threading: Correctly lock all callbacks
Make sure all application callbacks are called with a coap_lock_callback*()
wrapper.

Rename callback variables within the internal structures with a _cb suffix for
ease of review.
2025-12-30 11:07:37 +00:00
Jon Shallow 6b33d18735 Doc: Fix typos 2025-12-27 11:57:19 +00:00
Jon Shallow 19f1d78848 coap_send: Do not block on first send when testing for additional support
The first coap_send(pdu) is held back until after the optional tests for
Extended Token or Q-Block support are complete with the return from coap_send()
containing the held back pdu's mid.

If there are any errors with this PDU when subsequentially sent, the
event COAP_EVENT_FIRST_PDU_FAIL gets raised.
2025-12-19 17:03:33 +00:00
Mario Kicherer 43bb86df92 coap_io_process_with_fds_lkd: use local fd_set to avoid conflicts when called in parallel for the same context 2025-12-19 14:30:50 +00:00
Jon Shallow 2c41299b4b size_t %zu format: Support compilers that do not support printf %zu
PRIdS or PRIuS need to be defined for a format specification that compilers /
libraries (e.g. nano) understand rather than the default of %zd and %zu.
2025-12-17 15:30:48 +00:00
Jon Shallow 5567e83dfd coap_mutex_internal.h: Fix typo in coap_thread_pid_t definition 2025-12-15 12:00:23 +00:00
Jon Shallow 5a5330d2be RIOT: Update code version and documentation 2025-12-13 18:07:25 +00:00
Jon Shallow 18bb1ff114 Call-Home: Fix Call-Home reconnecting should remote Client fail 2025-12-11 22:25:32 +00:00
Jon Shallow 0eff6a4ed7 FreeRTOS/LwIP: Support getting thread_id for locking 2025-12-09 10:16:16 +00:00
Jon Shallow f64d16919f multi-threading: Fix no_recursive_check issue 2025-12-06 10:01:58 +00:00
Jon Shallow 9f6e671894 Block Transfer: Support constrained memory clients
Add in new function coap_add_data_large_request_app() that provides a call-back
to get individual blocks rather than having a large buffer held in
(contrained) memory.
2025-12-04 14:42:18 +00:00
Jon Shallow aef27f2e68 coap_proxy.c: Support enabling multicast forwarding requests
Missed pushing a commit.
2025-11-20 17:01:20 +00:00
Jon Shallow 7039c70100 coap_proxy.c: Support enabling multicast forwarding requests
Now configurable, previously the multicast request was just forwarded.
2025-11-20 16:47:51 +00:00
Jon Shallow 763330cb61 LwIP: Fix locking for FreeRTOS environments
Handle recursive locking of LOCK_TCPIP_CORE().

Updated support for IPv4 only environments.
2025-11-20 12:33:24 +00:00
Jon Shallow 49668640a0 coap_session.c: Fix GCC array bounds warning for memcpy
Note assert() added from #1209 has now been removed as not needed by #1628,
and if NDEBUG is defined then the assert() would have been a noop anyway.
2025-10-24 09:56:54 +01:00
Jon Shallow e13dfda905 coap_block.c: Do not timeout lg_srcv if server app request handler is slow 2025-10-20 09:34:08 +01:00
Tobias Tefke 698b897570 coap_encode.h: Check BSD is defined before evaluating it 2025-10-20 09:33:54 +01:00
Tobias Tefke d437d9cabd coap_dgrm_internal.h, coap_subscribe_internal.h: Fix extern C guards 2025-10-20 09:33:20 +01:00
Mario Kicherer 673b2184ce add block data handler for single body block transmissions 2025-10-17 11:36:25 +01:00
Mario Kicherer da1be4b5ca add COAP_BLOCK_FORCE_Q_BLOCK 2025-10-09 16:31:50 +01:00
raspopov 245354f0ef Fix HAVE_TIME_H and HAVE_SYS_TIME_H ifdefs
If we correctly determine the presence of the sys/time.h and time.h
files using the HAVE_TIME_H and HAVE_SYS_TIME_H macros, then the LWIP
compilation will result in a duplicate function error. Perhaps previous
versions of LWIP did not have these files, in which case everything
would have worked correctly.

These changes add the necessary ifdefs and keep the optimal timer
function for LWIP.

Adds missed #include <time.h> lines to examples and documentation.

Adds the detection of the sys/select.h header to the CMake and autoconf.
2025-10-06 09:38:52 +01:00