Commit Graph
623 Commits
Author SHA1 Message Date
Jon Shallow 0d240530b4 Release 4.3.5: Release 4.3.5 2024-09-06 09:47:22 +01:00
Mario Kicherer 1c97907f2f coap_net.h: add ifdef WITH_LWIP around lwip functions 2024-08-27 11:59:23 +01:00
Jon Shallow e220c371be coap.h: Remove need for different coap.h files for different OS
./autogen.sh and ./configure no longer need to be run prior to running
make for Contiki, LwIP or RIOT from the appropriate examples sub-directory.

scripts/fix_version.sh now handles updating coap.h for the different
LIBCOAP_ and PACKAGE_ definitions.
2024-08-23 10:39:37 +01:00
Mario Kicherer 8899063a4a coap_ws: accept longer header lines and specific header sent by firefox browser 2024-08-23 10:39:17 +01:00
Jon Shallow 3d790a5964 reverse-proxy: Provide dedicated reverse-proxy handler setup function 2024-08-16 13:33:31 +01:00
Jon Shallow 626d4632d1 multicast: Document coap_mcast_set_hops() 2024-08-16 13:30:30 +01:00
Jon Shallow 540fede1b9 release 4.3.5rc3: Release candidate 3 for 4.3.5 2024-08-07 14:14:07 +01:00
Jon Shallow 92198b00b3 Supported: Break out run-time checks and libcoap build #defines
Group together and document the run-time checks available for checking
the libcoap built-in functionality based on the ./cconfigure and / or
CMakeLists.txt options.

Create include/coap3/coap_defines.h file that contains a list of
COAP_ #defines created from the options defined when running ./configure
or cmake.

Add additional coap_*_is_supported() functions.
2024-08-07 10:23:19 +01:00
Jon Shallow 5f3d7eb244 reverse-proxy: Add in reverse proxy support to coap-server
Tidy up the general proxy logic by moving common functionality
into libcoap.

New functions coap_proxy_forward_request(), coap_proxy_forward_response()
and coap_proxy_is_supported() added.

New --enable-proxy-code support added to configure.

New ENABLE_PROXY_CODE support added to CMakeLists.txt.

Support for common shared connection to next hop.

Support for round-robin balancing across multiple next hops.
2024-08-07 09:33:46 +01:00
Jon Shallow af024f9138 Connection-ID: Only change source port when CID has been negotiated
Only support changing the client's source port if the DTLS library
has support / configured for CID.

Used when debugging server handling source address changes and CID
is in use.

Add in support for TinyDTLS (Client only) if TinyDTLS is patched
appropriately (not currently available on TinyDTLS main branch).

Add in new function coap_dtls_cid_is_supported().
2024-08-07 09:13:52 +01:00
Jon Shallow 83718a6d2f Cleanup building header files for different OS
'make distclean' removes header files built from the .in files, which
means that they are not available for different OS builds.

The same is true for CMakeLists.txt.

Remove the need for the .in files and update for libcoap revisions
by using a new script scripts/fix_version.sh created from
scripts/fix_version.sh.in.

CI has been updated to check revisions have been updated in the
appropriate places.

Do not remove libcoap-3.sym and libcoap-3.map when doing 'make distclean'
as they are git tracked files.
2024-08-06 16:56:19 +01:00
Jon Shallow 8b2fb390b8 Connection-ID: Support changing client IP addresses
Support of RFC9146. Currently only Mbed TLS supported.

New function coap_context_set_cid_tuple_change() for a client to
force periodic source port changes to test out CID.

Configurable support for the client to use Connection-ID
assuming underlying DTLS library is configured for or supports it.
2024-07-22 08:56:17 +01:00
Jon Shallow b75c784a20 Constrained Stack: No need for individual locks
If a proxy reads in a packet via coap_read_endpoint, which then
invokes an ongoing proxy TCP connection, while waiting for the CSM
response of the new session, coap_read_endpoint would get invoked
again if there is any data to read on any of the listening endpoints..

With a Constrained Stack, the read in data is protected by mutex
m_read_enpoint - which is still locked when trying to wait for the
CSM.

As the code is either single threaded, or protected by global_lock
if multi-threaded, there is no need to maintain mutexes such as
m_read_endpoint.  This PR removes these not needed mutexes.
2024-07-22 08:47:05 +01:00
Jon Shallow 48b56aa830 coap_prng: Provide global_lock protection 2024-07-19 10:28:05 +01:00
Jon Shallow bd32823746 client-coap.c: Fix client spin loop for NO_SYS == 0
Do not call coap_free_context() from within sigint handler.
Always call coap_io_process().
Use sys_arch_sem_wait() for timeouts while waiting for input.
2024-07-19 10:05:30 +01:00
Jon Shallow 62686555b2 Locking: Unlock global_lock after coap_free_context() call 2024-07-17 14:15:10 +01:00
Jon Shallow f9c7223ecd Locking: Use single global lock instead of context lock
When context is de-allocated, other threads can still access the
context lock held within context. Indicating being freed when
coap_free_context() was called worked in most cases, but not all.
2024-07-17 08:52:50 +01:00
Jon Shallow af7da4596a TLS: EC-JPAKE support (RFC8236)
Currently only supported by Mbed TLS if the optional
MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED is defined for the Mbed TLS
library build.
2024-07-17 08:51:31 +01:00
Jon Shallow 7551d2e147 block handling: Update lg_crcv->last_used when sending Block1
This prevents premature de-allocation of the lg_crcv when large
files are getting uploaded.
2024-07-16 11:11:33 +01:00
Jon Shallow 3c720f232f release 4.3.5rc2: Release candidate 2 for 4.3.5 2024-06-25 09:31:27 +01:00
Jon Shallow eff1f38f9f path_query parsing: Remove need to define scratch buffer
Create new options coap_uri_into_optlist(), coap_path_into_optlist() and
coap_query_into_optlist() to be used instead of coap_uri_into_options(),
coap_split_path() and coap_split_query() functions so the requirement
for a scratch buffer is not needed.

Getting the minimum size for a scratch buffer is not straight forward and
potential for unexpected boundary condition errors to occurif too small.

Correct parsing and stripping out of "%2E%2E" ("..") and "%2E" (".")
path segments.  ".." now removes the previous segment (if it exists).

Update documentation and unit testcases.

Update examples to use new options.
2024-06-25 08:23:33 +01:00
Jon Shallow 0fbe59fc55 block: Handle separate responses that then are followed with Block2
Set up lg_crcv if separate ACK response received for a coap_send() CON
request to be able to handle Block2 responses.

Handle Block1 request getting back a Block2 request that has an initial
separate response once the Block1 has completed by adjusting the stateless
token counter.

Separate response is typical for proxy support (OSCORE previously handled)..
2024-06-14 11:43:18 +01:00
Jon Shallow f54686039b coap-client.c: Fix SNI generation
Move requirements for client to determine how to set up the SNI for
PSK/PKI encrypted communications down into libcoap. The client just
needs to indicate the host to connect to in the client_sni field of
coap_dtls_cpsk_t or coap_dtls_pki_t.

New internal function coap_sanitize_client_sni() makes sure that
the SNI sent follows RFC 6066.  As per
https://datatracker.ietf.org/doc/html/rfc6066#section-3

  Literal IPv4 and IPv6 addresses are not permitted in "HostName".

all IPv4 and IPv6 addresses are dropped for the SNI, and so no SNI is
sent.  DNS hostnames will get transmitted as the SNI.
2024-06-10 09:18:25 +01:00
Jon Shallow 0392d02217 release 4.3.5rc1: Release candidate 1 for 4.3.5
LIBCOAP_VERSION and LIBCOAP_PACKAGE_BASE are unchanged until
4.3.5 is released.
2024-06-06 10:07:50 +01:00
Jon Shallow 0223c1a3d4 Block1: Handle large FETCH with large blocked request and Observe
Handle Observe cancellation with large blocked FETCH that needs to use
diffferent tokens when there is packet loss by checking the cache-key
if the token is not found (Q-Block1).

Let FETCH with Q-Block1 use NON now that cache-key is getting checked
if token mismatch.

Handle getting an unsolicited Observe response in the middle of
sending the FETCH blocks that ultimately will be doing the Observe
cancellation following re-assembly. (The unsolicited Observe token will
be the same token that is used to respond to the observe cancellation).
2024-06-06 09:44:15 +01:00
Jon Shallow dec13f94f1 locking: Add missing COAP_API 2024-06-05 08:33:39 +01:00
Jon Shallow 782e607879 reverse-proxy: Support for .well-known/core being passed
Move get_wkc_len() into hnd_get_wellknown_lkd() to simply document how
hnd_get_wellknown() should be done.

Revert out coap_register_print_wellknown_callback() changes as no
longer needed.
2024-06-05 07:43:37 +01:00
Mario Kicherer 7c33808271 enable application control over .well-known/core responses 2024-05-31 18:07:45 +01:00
Jon Shallow f00f13831a locking: app call-backs when coap_free_context() called
Attempt to simplify locking to prevent Coverity issues being
generated.
2024-05-28 10:01:31 +01:00
Jon Shallow cb20c482b2 locking: Simplify maintenance / debugging /documentation
Update the Public API equivalent of the libcoap functions that need to be
called when locked with a name suffix of _lkd.

Move matching Public API functions out of coap_threadsafe.c to be coded
just ahead of the newly renamed _lkd function.

Properly define the _lkd function in the appropriate _internal.h file for
documentation, removing the #defines from coap_threadsafe_internal.h.

Tag all the Public API functions that have a _lkd function with COAP_API.
COAP_API can then be defined as to what should be done for that function.

Check libcoap library does not call the original Public API function when
it should be calling the _lkd function by marking the Public API not _lkd
functions as deprecated during the libcoap library build.
[Done by the new COAP_API being defined as __attribute__((deprecated)).]

Work in progress for all the functions that need to be multi-thread safe.
2024-05-24 09:09:49 +01:00
Jon Shallow 948697e4b2 locking: Simplify maintenance / debugging /documentation
Update the Public API equivalent of the libcoap functions that need to be
called when locked with a name suffix of _lkd.

Move matching Public API functions out of coap_threadsafe.c to be coded
just ahead of the newly renamed _lkd function.

Properly define the _lkd function in the appropriate _internal.h file for
documentation, removing the #defines from coap_threadsafe_internal.h.

Tag all the Public API functions that have a _lkd function with COAP_API.
COAP_API can then be defined as to what should be done for that function.

Check libcoap library does not call the original Public API function when
it should be calling the _lkd function by marking the Public API not _lkd
functions as deprecated during the libcoap library build.
[Done by the new COAP_API being defined as __attribute__((deprecated)).]

Work in progress for all the functions that need to be multi-thread safe.
2024-05-23 08:30:11 +01:00
Jon Shallow 91d8fad663 locking: Simplify maintenance / debugging /documentation
Update the Public API equivalent of the libcoap functions that need to be
called when locked with a name suffix of _lkd.

Move matching Public API functions out of coap_threadsafe.c to be coded
just ahead of the newly renamed _lkd function.

Properly define the _lkd function in the appropriate _internal.h file for
documentation, removing the #defines from coap_threadsafe_internal.h.

Tag all the Public API functions that have a _lkd function with COAP_API.
COAP_API can then be defined as to what should be done for that function.

Check libcoap library does not call the original Public API function when
it should be calling the _lkd function by marking the Public API not _lkd
functions as deprecated during the libcoap library build.
[Done by the new COAP_API being defined as __attribute__((deprecated)).]

Work in progress for all the functions that need to be multi-thread safe.
2024-05-22 11:40:44 +01:00
Jon Shallow e8e44bf6aa esp-idf: Support multi-threading 2024-05-22 10:09:52 +01:00
Jon Shallow d2d4a81374 locking: Simplify maintenance / debugging /documentation
Update the Public API equivalent of the libcoap functions that need to be
called when locked with a name suffix of _lkd.

Move matching Public API functions out of coap_threadsafe.c to be coded
just ahead of the newly renamed _lkd function.

Properly define the _lkd function in the appropriate _internal.h file for
documentation, removing the #defines from coap_threadsafe_internal.h.

Tag all the Public API functions that have a _lkd function with COAP_API.
COAP_API can then be defined as to what should be done for that function.

Check libcoap library does not call the original Public API function when
it should be calling the _lkd function by marking the Public API not _lkd
functions as deprecated during the libcoap library build.
[Done by the new COAP_API being defined as __attribute__((deprecated)).]

Work in progress for all the functions that need to be multi-thread safe.
2024-05-21 14:51:51 +01:00
Jon Shallow 6e68baa0f7 coap_update_token: Make sure corrected PDU headers are presented to the app 2024-05-21 09:34:11 +01:00
Jon Shallow cbfb491b1d coap_libcoap_build.h: Add in specific library build header
Gives the ability to add in additional library build checks through
the use of #define etc. that is not available to applications or
other host o/s support.

Preparatory work for further locking checks.
2024-05-20 15:39:40 +01:00
Jon Shallow c029eedca1 nits: Tidy up documentation 2024-05-18 10:54:13 +01:00
kkrentz 280b723a73 Contiki-NG: Fix compilation error "implicit declaration of strncasecmp" 2024-05-17 11:47:12 +01:00
Jon Shallow 622050a957 locking: Simplify maintenance / debugging /documentation
Update libcoap functions that need to be called locked with a name
suffix of _locked.

Move matching functions out of coap_threadsafe.c to be coded just ahead
of the newly renamed _locked function.

Properly define the _locked function in the appropriate _internal.h file
for documentation, removing the #defines from coap_threadsafe_internal.h.

Work in progress for all the functions.

Remove coap_lock_* requirements for testdriver (coap_delete_node()).
2024-05-15 15:50:14 +01:00
Mario Kicherer 6673be3b43 coap_net: add coap_context_set/get_app_data and deprecate coap_set/get_app_data 2024-05-15 15:42:45 +01:00
Jon Shallow 41ed5aa787 Nits: Tidy up code
Add documentation for coap_get_resource_from_uri_path().

Remove duplicate coap_get_resource_from_uri_path() definition.

Better fix for scan-build issue.

Update RIOT libcoap base version.
2024-05-14 09:31:48 +01:00
Jon Shallow 4a94cc7c80 scan-build: Fix warnings 2024-05-09 10:57:16 +01:00
Jon Shallow d5a0d9c116 PKI: Add in coap_pki_key_define_t support to remaining TLS interfaces 2024-05-09 10:14:33 +01:00
Jon Shallow cec964e0b0 locking: Unlock context when calling request/response handlers
This is to reduce contention on the context lock when a request/response
handler takes time to get / update information.
2024-05-09 10:04:31 +01:00
Jon Shallow a67426c655 coap_net.c: Tidy up Observe cancellation in coap_send()
If Observe cancellation is detected in sending pdu in coap_send()
invoke coap_cancel_observe() to to the necessary work.
2024-05-06 09:46:13 +01:00
Jon Shallow 9f9129cca8 OpenSSL: Add in support for configuring an alternative TLS ENGINE
Two new functions added

coap_tls_engine_configure()
coap_tls_engine_remove()

Added in new PKI key type coap_pki_key_define_t which allows the CA, Public Cert
and Private Key to be different types (e.g. PEM, DER etc.).

Added a new key type ENGINE to make use of the configured tls_engine.

Added in a -q option to coap-server and coap-client for testing ENGINE.

Note: ENGINE is only supported by OpenSSL.
2024-05-06 09:09:58 +01:00
kkrentz 466463304b Contiki-NG: Fix compilation error "unknown type name 'fd_set'" 2024-05-02 12:21:12 +01:00
Jon Shallow 9f1418e87d coap_block.c: Handle Block1 packets with random order block numbers
Add in new COAP_BLOCK_NOT_RANDOM_BLOCK1 option for
coap_context_set_block_mode(). This disables receipt of any Block1
packet (but not Q-BLock1) if the block numbers are not sequentially
received starting with 0.  A 4.08 code is returned for every packet
out of order and its data is ignored.

If COAP_BLOCK_SINGLE_BODY is set in coap_context_set_block_mode(),
but not COAP_BLOCK_NOT_RANDOM_BLOCK1, then all Block1 packets are
assembled in the correct order before passing the body up to the
application.  The receive logic will timeout after MAX_TRANSMIT_WAIT
(93 seconds) if there are any missing blocks, or 10 seconds if the
last block is seen.

If COAP_BLOCK_SINGLE_BODY is not set in coap_context_set_block_mode(),
and not COAP_BLOCK_NOT_RANDOM_BLOCK1, then the random order packets
are passed up to the application layer where it is the application's
responsibility to decide what to do with the randomly ordered packets,
and what response code to send.
2024-04-26 14:41:00 +01:00
Jon Shallow 758a341546 doc: Update coap_session_set_type_client() documentation 2024-04-25 14:52:44 +01:00
Jon Shallow e3a662a934 wolfSSL: Set up initial port
Includes some porting ideas from qursa-uc3m libcoap-wolfssl work.

Some common ASN1 code moved from coap_gnutls.c to coap_asn1.c to support RPK.

WolfSSL build
$ ./configure --enable-all --enable-dtls13 CFLAGS="-DBUILD_TLS_PSK_WITH_AES_128_CCM -DHAVE_RPK"

Interoperability requirements

DTLS1.3 downgrade requires
https://github.com/eclipse/tinydtls/pull/230
https://github.com/wolfSSL/wolfssl/pull/7367

TLS1.3 downgrade requires
https://github.com/wolfSSL/wolfssl/pull/7367

(D)TLS1.2 use of RPK requires
https://github.com/wolfSSL/wolfssl/pull/7375

MbedTLS using TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 requires
https://github.com/wolfSSL/wolfssl/pull/7132

GnuTLS using PSK and TLS1.3 requires
https://github.com/wolfSSL/wolfssl/pull/7407
2024-04-16 11:03:24 +01:00