Commit Graph
763 Commits
Author SHA1 Message Date
Magdalena Szumny c63c8f7cb7 Make max latency configurable 2026-09-29 13:35:41 +01:00
Jon Shallow 15bba8e9f7 coap_block.c: Limit the number of lg_srcv tracking (Q-)Block1 input
Reduce value of partial timeout if there are a lot of outstanding
large block receipts that are not active.

Add function coap_context_set_max_bodies_ram() to define an upper memory
limit usage across all active body receipts.
2026-09-28 15:24:18 +01:00
Jon Shallow 5ce12ab656 coap_block.c: Remove unnecessary uri_path memory allocation 2026-09-21 16:15:15 +01:00
Jon Shallow dd0c1e8c2c 32 bit build: Support building 32 bit executables
On a linux system

./configure --host=i386

Currently TLS support is not available.

Fix a 32 bit CBOR issue.
2026-09-21 11:14:01 +01:00
Jon Shallow 93694e6c24 RIOT: Add in TCP support
Need to make use of LwIP interface for TCP.
2026-09-16 15:03:45 +02:00
Jon Shallow 18df85af6d Nits: Fix documentation 2026-09-14 09:52:17 +02:00
Jon Shallow 68849057f1 Delayqueue: Add delayqueue_tail to coap_session to avoid scanning long queues 2026-09-11 12:30:08 +01:00
Jon Shallow 64211f744e Block1: Handle concurrent transfers over the same session 2026-09-09 14:12:28 +01:00
Michiel De Witte e61c8c8ef7 Preserve the observe request's local address for notifications
Packets from the same peer can overwrite a session's local address with a
multicast destination. Save the address when an observation is created or
renewed and restore it before generating notifications, so deferred responses
snapshot the correct address instead of being dropped as invalid multicast.

Add regression coverage for CON and NON observations, including renewals and
the local address captured by a notification's async response.

Validation: 215 unit tests passed (1712 assertions).
2026-09-07 15:58:29 +01:00
Jon Shallow fcbd803828 Q-Block: Better recovery for lossy networks
Following the principles laid out in RFC9177.
2026-09-02 08:50:49 +01:00
Michiel De WitteandClaude Fable 5 091f189e7a Restore the request's local address when a triggered async fires
Server sessions are keyed on (remote address, local port) only, and
session->addr_info.local is overwritten by the destination of every
received packet. When a unicast CON request is parked in a coap_async_t
for a separate response and a multicast packet from the same peer
arrives before the async fires, the re-invoked handle_request() sees a
multicast local address, drops the CON per RFC7252 8.1 ("Invalid
multicast packet received"), and coap_check_async() frees the async:
the response is silently never sent.

Snapshot the local address in coap_register_async() and restore it on
the session before the async fires, so the deferred request is handled
(and its response source selected) against the address it actually
arrived on.

Seen in the field with a CoAP remote control whose GET /endpoint was
answered via the async path while it also multicast periodic
announcements from the same source port: the device received the empty
ACK and then never got the response.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 16:35:51 +01:00
Jon Shallow ea841dd0c7 coap_mutex_internal.h: Fix LwIP coap_mutex_destroy 2026-08-20 10:31:27 +01:00
Jon Shallow 850748ca14 Recovery: Support dropping incoming packets for testing 2026-08-20 09:56:09 +01:00
Jon Shallow dfd55459d7 NoTLS: Use SHA1 for digest computations
Removed:
include/coap3/coap_hashkey_internal.h
src/coap_hashkey.c
2026-08-15 15:20:12 +01:00
Jon Shallow 7c456246c9 coap_resource.c: Make Observe deregistration more rigorous 2026-08-15 15:18:46 +01:00
Jon Shallow a5803ff733 OSCORE: Boundary check OSCORE option creation 2026-08-08 13:27:40 +01:00
Jon Shallow 98805f70a5 Documentation tidy up
Add in codespell to pre-commit to help fix documentation errors.
2026-08-08 12:05:03 +01:00
Jon Shallow d4f78cd560 ICMP: Treat genuine ICMP diagnostic PDU for UDP as failure
Posix support only for unicast client requests.

ICMP disgnostic messages are ignored on server sessions.
2026-07-28 16:42:41 +01:00
Jon Shallow 1122bf9fb9 Proxy: Report 5.04 on proxy gateway timeout
Timeout is set to MAX_TRANSMIT_WAIT for CON Non-Reliable requests.

If request is active, idle timeout is ignored.
2026-07-16 11:03:01 +01:00
Mario Kicherer 12b7e99225 add coap_endpoint_join_mcast_group_intf 2026-07-15 10:17:05 +01:00
Jon Shallow 94bacc8939 Duplicate MIDs: If repeat MID request, send back previous response
Clean up duplicate MID handling, and just send back last response if MID
matches.

Removed COAP_BLOCK_CACHE_RESPONSE as no longer required for duplicate MID
handling, and so no need to send an Empty ACK response for a subsequent
Separate response as a referenced copy of the last PDU respponse is now kept
for a session.

Note that if a request is sent by a proxy to an upstream server, this always
converts the upstream server's response into a Separate response back to the
client as the upstream server may take time to respond, do any error recovery
etc.
2026-07-14 09:56:34 +01:00
Jon Shallow 72978e9fc6 PKI: Add in PKI wildcard and multiple SANs support 2026-07-11 10:28:31 +01:00
Jon Shallow ce032db273 oscore_cbor.c: Fix handling large negative integers
Exclude OSS-FUZZ seed corpus files from pre-commit hooks.
2026-07-02 19:54:48 +01:00
Jon Shallow 6c5a0bcb4f TLS: Support client checking sent SNI to received server's PKI CN
For coap-client, if either -R or -C options are specified, then allowing
self-signed certificates is now disabled.
2026-06-27 12:20:00 +01:00
tlhc aa68d5f7e3 feat: add openHiTLS backend support
- Add openHiTLS DTLS/TLS backend
- Integrate openHiTLS crypto into libcoap (D)TLS and OSCORE paths.
- Extend TLS tests and add interop validation script.
2026-06-27 11:18:22 +01:00
Jon Shallow 2e995218f3 SendQueue: Match Mid and Token (if given) to remove entry from queue
For Empty ACK and RST do not do a token match.
2026-06-22 13:48:44 +01:00
Jon Shallow 46e34175b8 RIOT: Fix build against latest version 2026-06-12 17:21:21 +01:00
Jon Shallow 888ba34ece Q-Block: Better timing / recovering when rate limiting
Make use of an outstanding list of blocks to transmit to remove duplicates
and only send one at a time if rate-limiting.
2026-06-10 12:01:10 +01:00
Jon Shallow 193ec26ead Proxy: Check for non-safe options
Generally re-organize option handling, making use of enums etc.

This also updates critical options checks, and well as repeatable options.
2026-06-05 15:22:38 +01:00
Michiel De Witte b4de71ee24 Fix data race in coap_resolve_address_info() 2026-06-02 09:57:30 +01:00
Jon Shallow c4e651ae70 LwIP: Allocate semaphores per context for NO_SYS == 0
Each LwIP coap_context_t must now periodically call coap_io_process().
2026-06-01 09:55:31 +01:00
Jon Shallow d32d298333 coap_oscore.c: Fix replay protection 2026-06-01 09:18:10 +01:00
Jon Shallow 7370fcf6ad LwIP: Add in support for MEM_USE_POOLS for COAP_STRING malloc()s
If both MEMP_USE_CUSTOM_POOLS and MEM_USE_POOLS are defined in
lwipopts.h and there is a suitable
LWIP_MALLOC_MEMPOOL_START .. LWIP_MALLOC_MEMPOOL_END
definition in lwippools.h, then any coap_malloc_type(COAP_STRING, ..) will
make use of the defined pools.

A new src/coap_mem_lwip.c file has been added.
2026-05-27 06:32:11 +01:00
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