Commit Graph
710 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 48559f0016 RIOT: Add help documentation
General documentation tidy up.
2026-05-20 10:20:22 +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 b1b60fe159 RIOT: Handle ints being 16 bits 2026-04-22 09:04:00 +01:00
Jon Shallow 86b778167a RIOT: Implement RIOT's coding standards 2026-04-20 21:28:45 +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
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 c50ea5bb37 RIOT: Update to latest 2026-04-16 12:27:38 +01:00
Jon Shallow e766f053c2 Debugging: Add examples support for causing network failures
Add -Z option to coap-client and coap-server.
2026-04-13 17:02:39 +01:00
Jon Shallow c46c64bca3 tinydtls: Update to latest version 2026-04-02 12:30:03 +01:00
Ernestas Kulik 4c6a8f10a4 examples: server: Fix builds without proxy support
d33b7fa571 adds a call to setup_cpsk(),
which is only defined with COAP_PROXY_SUPPORT defined. This commit
enables said function if COAP_CLIENT_SUPPORT is enabled as well.
2026-04-02 09:42:51 +01:00
Jon Shallow 80c37b7bc6 Coverity: Fix CID 1483550, 1670422-1670425
CID 1594475 is a false positive as multiple threads cannot execute in the same
code as global_lock is set.
2026-03-26 09:24:44 +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 9d5d063331 RIOT: Fix building against the latest RIOT code 2026-02-21 10:56:44 +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
Marco Casaroli a90916a4fe zephyr: mbedlts improvements
Add some improvements to make secure coap work on Zephyr 4.3.0
with mbedtls (not using Zephyr TLS protocol options).

We now set the build options to zephyr, so we make use of the
internal mbedtl in zephyr, so we do not require a specific header
file anymore.

In older versions of Zephyr, where mbedtls does not expose the
configuration, we can force-set the macro in the C flags, so that
mbedtls will have our required function.

This way, we do not need to change the mbedtls included in Zephyr,
while still supporting a few older versions.
2026-01-30 16:18:34 +00:00
Jon Shallow b7e538c4f3 Zephyr: Default to zephyr v4.3.0 for builds
Update to next version when the main branch becomes stable and a new release is out..
2026-01-30 10:08:57 +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 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
Jon Shallow bcee6f7149 Coverity: Fix reported errors
CID 1667634
CID 1667636
CID 1667638
CID 1667639
CID 1667641
CID 1667642
CID 1667644
CID 1667646
CID 1667647
CID 1667649
CID 1667650
CID 1667651
2025-12-19 16:57:45 +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 e1c5889faa LwIP: Fix TCP traffic timing windows
Use correct input function for netif_add() in examples.

Invoke coap_io_process() as soon as possibile following TCP input /
error.

Update rcvd window size after receipt of data.
2025-12-09 10:44:45 +00:00
Jon Shallow 1afe621cf5 Zephyr: tidy up / fix thread safe building 2025-12-05 16:02:54 +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 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 f9fd716025 ext/tinydtls: Update submodule to the latest 'main' version 2025-11-20 12:31:49 +00:00
Jon Shallow 523773baab Zephyr: Fix deprecated, now undefined, symbols when CI building 2025-11-17 11:16:41 +00: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
raspopov 5ca624642e Fix compiler warnings
Fixed warnings of unused variable
and possible use of initialized variable.
2025-10-06 09:37:00 +01:00
Jon Shallow 576b68e5db LwIP: Add in support for disabling IPv4 or IPv6
Note that TinyDTLS needs both IPv4 and IPv6 if DTLS is going to be used.
2025-10-02 18:48:17 +01:00
Jon Shallow 8f9a73e397 coap-client: Add in support for configuring Proxy-Scheme option 2025-09-29 20:38:06 +01:00
Jon Shallow 743dc928d8 LwIP: Support memory management other than Custom Memory Pools 2025-09-27 15:07:01 +01:00
Jon Shallow 32471d1439 coap-rd.c: Sanity check POST query lengths 2025-09-26 12:37:39 +01:00
Jon Shallow ea6a3c6f53 Platforms: Split out TCP and UDP socket functions on a platform basis
Currently supported types

Posix
LwIP
Contiki
RIOT

Zephyr and Windows are treated as Posix.

UDP
src/coap_dgrm_contiki.c      Datagram r/w/c functions from src/coap_io_contiki.c
src/coap_dgrm_lwip.c         Datagram r/w/c functions from src/coap_io_lwip.c
src/coap_dgrm_posix.c        Datagram r/w/c functions from src/coap_io.c
src/coap_dgrm_riot.c         Datagram r/w/c functions from src/coap_io_riot.c

TCP
src/coap_strm_contiki.c      Stub TCP entries
src/coap_strm_lwip.c         Stream r/w/c functions from src/coap_io_lwip.c
src/coap_strm_posix.c        Was src/coap_tcp.c with stream r/w/c functions from src/coap_io.c
src/coap_strm_riot.c         Stream r/w/c functions from src/coap_io_riot.c

I/O specific
src/coap_io_contiki.c        Datagram / Stream functions removed
src/coap_io_lwip.c           Datagram / Stream functions removed
src/coap_io_posix.c          Abstracted from src/coap_io.c
src/coap_io_riot.c           Datagram / Stream functions removed

Remaining common I/O functions
src/coap_io.c                With separated out code removed
2025-09-22 10:27:14 +01:00
Jon Shallow 30db3eaa1f coap_address.c: Validate length of provided host name
Host names larger than 255 bytes will cause an internal buffer overflow.

Hostnames provided to coap_resolve_address_info() now have their length validated.

Discovered by SecMate (https://secmate.dev).

Sanity check host lengths when parsing a CoAP URI when using the coap_split_uri()
function.
2025-09-12 13:28:22 +01:00
Jon Shallow ea01661faf Zephyr: Support C++ builds
Some of the Zephyr include files need to be C++, not C based. The 'extern "C"'
wrapper in include/coap3/coap.h means that all #include are treated as being C.

Remove 'extern "C"' wrapper from include/coap3/coap.h and add wrapper to
include files after #include and before any function / structure definitions.

Add in a C++ build test for CI.
2025-08-21 12:17:41 +01:00
Jon Shallow 79a041414c Zephyr: Enable CI builds
Fix a Zephyr unexpected success response for ioctl FIONBIO.
2025-07-19 12:17:38 +01:00
Jon Shallow b359512f8d coap_block.c: Fix ETag generation for CoAP responses
If the response code in the PDU was not set before calling
coap_add_data_large_response(), the ETag option was not getting
set.
2025-07-19 12:04:23 +01:00
Jon Shallow f62c836ece coap_resource.c: Make dynamic resource handling thread safe
Let libcoap do the necessary multi-thread locking during resource
generation, lookup and deletion.

Supported using a new handler set up by coap_register_dynamic_resource_handler().
2025-07-08 13:37:57 +01:00
Jon Shallow d33b7fa571 coap_session.c: Support converting a Client session to a Server session
Server to Client is already supported, this provides the reverse with
coap_session_set_type_server().

Add in call-home support to coap-client and coap-server for testing.

Addition of a new event COAP_EVENT_SERVER_SESSION_CONNECTED.
2025-07-02 17:41:07 +01:00
fj-blanco 4fa3dfa0c7 Zephyr: add POSIX API support
Changes:
- Remove duplicate OBSERVE_PERSIST configuration block

Improve example build:

- Make virtual environment activation optional in Makefile
- Remove --fresh flag unsupported in newer west versions
- Copy mbedTLS config header to workspace include directory
- Add TARGET check for mbedTLS before configuring include directories
- Add mbedTLS linking to coap-3 target

Add POSIX API support:

- Enable CONFIG_POSIX_API=y in examples/zephyr
- Replace direct Linux/Windows system calls with Zephyr POSIX API
equivalents
- Add Zephyr's sys_rand_get() to coap_prng_default()
- Define missing network macros (IN_MULTICAST, IN6_IS_ADDR_MULTICAST,
etc.)
- Add FIONBIO and OPTVAL_T/OPTVAL_GT macro definitions for Zephyr
- Add native Zephyr timing functions to replace missing mbedTLS timing
support
- Fix fd_set mapping using zephyr/net/socket_select.h
- Exclude strnlen redefinition conflicts for Zephyr
- Add proper IPv6 packet info and address mapped definitions

(Patch) Add DNS resolution and net setup to example client:
- Enable CONFIG_DNS_RESOLVER for hostname resolution
- Add Linux networking setup instructions for native_sim board
- Configure static IP gateway and DNS server (8.8.8.8)
- Add DHCP vs static IP configuration documentation
Co-authored-by: mrdeep1
2025-06-26 15:23:23 +01:00