Commit Graph
2932 Commits
Author SHA1 Message Date
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 f4094636ab Locking: Remove locking initialization from coap_new_context() 2024-07-18 08:39:40 +01:00
Jon Shallow d87af11903 coap_openssl.c: Fix libcoap shutdown restart issues 2024-07-17 15:38: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 bfdbdc3e25 coap_block.c: Replace usage of p with lg_xmit, lg_srcv, lg_crcv
To help debug block issues by replacing the over use of p-> with
the appropriate lg_xmit->, lg_srcv-> an lg_crcv->. No other code
changes.
2024-07-12 15:28:13 +01:00
Jon Shallow d84d863904 LwIP: Update to STABLE 2.2.0 2024-07-12 15:25:46 +01:00
Mario Kicherer aac5de9e55 enable HAVE_STRUCT_CMSGHDR when building with mingw 2024-07-12 09:49:01 +01:00
Jon Shallow 53e9333947 Locking: Make sure all app callbacks are properly locked.
Recursive lock issues happen for some of the app callbacks that then call a
libcoap public API that tries to lock up the CoAP context.

All libcoap callbacks into app code should now be fixed.
2024-07-11 13:13:33 +01:00
Jon Shallow aa46177e8e Coverity: Fix CID 1382579, CID 1502425, CID 1594471 and CID 1594475 2024-07-11 13:03:32 +01:00
Jon Shallow 7d5e5f3b8c coap-mbedtls.c: Support 3.6.0 Mbed TLS
TLS1.3 is enabled by default in 3.6.0. This PR fixes the supported
encryption algorithms as well as handling a new session ticket
indication for coaps+tcp://.

However, if client certificates are not defined, then MbedTLS fails with
no certificate CA, even if the CA Cert is presented along with the Server
Cert during the processing of the server certificate and fails with
"SSL - No CA Chain is set, but required to operate"
when coaps+tcp:// is used.

Workaround (with examples/coap-client) is to set the -R options (when the
-c option is not set), or to programmatically call
coap_context_set_pki_root_cas();
2024-07-11 12:51:58 +01:00
Hugo Hakim Damer 2ae46c9da2 configure.ac: use MbedTLS pkg-config if available
Additionally, this change allows overriding the MbedTLS compiler and
linker flags (just like with the other DTLS libraries).
2024-07-10 17:46:17 +01:00
Mario Kicherer 72045d89bd coap-debug.c: remove quotation when printing Unix domain socket paths, see #1460 2024-07-10 17:45:51 +01:00
kkrentz a1a16f3f5a Contiki-NG: Fix compilation error "unknown type name 'u_char'" 2024-07-04 10:59:01 +01:00
Jon Shallow cab876aa5d Zephyr: Support Mbed TLS 3.6.0 2024-07-02 21:29:40 +01:00
Jon Shallow f16e019e9d Zephyr: Support later Mbed TLS versions 2024-07-01 19:32:55 +01:00
Jon Shallow e5b7b98681 RIOT: Fix file name typo 2024-07-01 19:31:26 +01:00
Jon Shallow 15576ed6c3 RIOT: Pick up any uncommited changes when doing a local RIOT build 2024-06-29 08:16:03 +01:00
Jon Shallow 8157d0452f coap-client.c: Add in correct Uri-Host / Uri-Port for proxy 2024-06-29 08:11:09 +01:00
Jon Shallow 319ffb02c1 coap_net.c: Stop unnecessary coap_lg_crcv_t generation 2024-06-28 10:02:24 +01:00
Jon Shallow 3c720f232f release 4.3.5rc2: Release candidate 2 for 4.3.5 v4.3.5-rc2 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 63c5077cf0 coap_cleanup: Support multiple usage 2024-06-21 16:08:41 +01:00
Jon Shallow b1d305c842 dtls_writes: Handle write errors 2024-06-21 15:29:06 +01:00
Jon Shallow 5fbbd27765 coap_resource.c: Remove debug test statement. 2024-06-17 09:53:15 +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
kkrentz ea3d1ac17e OSCORE: Fix typo in comment 2024-06-12 09:54:25 +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 e095d5e03a RIOT: libcoap Release 4.3.5rc1 v4.3.5-rc1 2024-06-06 15:12:08 +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 ed178be577 coap-client: Correct Usage documentation 2024-06-06 10:04:42 +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 70469f24b0 examples-code-check.c: Report on missing defined function return types 2024-05-30 14:49:42 +01:00
Jon Shallow c830c15551 proxy: Handle Uri-Host correctly when using Proxy-Scheme
Updated documentation at the same time.
2024-05-29 10:20:57 +01:00
Jon Shallow 5171694d09 LwIP: NO_SYS == 0 support 2024-05-29 10:19:31 +01:00
kkrentz b7cbb64793 coap_net: Fix preprocessor guard 2024-05-28 14:20:13 +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 520f054b5b Coverity: Fix 1588815 and 1588818 2024-05-28 09:37:09 +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 e363d0a5c4 Binary PSK: Add in support for examples coap-client and coap-server
If the PSK is defined with a leading 0x, then the hex representation
of the following bytes is converted to a binary PSK.
2024-05-23 08:29:03 +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
Krzysztof Gongolewski 180e8220d4 fix lwip memory leak 2024-05-22 10:09:30 +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