Commit Graph
2871 Commits
Author SHA1 Message Date
Jon Shallow 15bf66c920 pre-commit: Add more trailing spaces and empty line at end of file checks 2024-05-15 16:04:08 +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 706201539b tinydtls: Update to latest version 2024-05-14 09:40:07 +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
Patryk Jarosz 5234f41c2d Fixed missing event for server session removal 2024-05-14 09:14:59 +01:00
Harshit Malpani c17f582dc9 Fix build failures with mbedtls 3.6.0 2024-05-14 09:08:34 +01:00
Jon Shallow 8e05e18511 coap_session.c: Invoke NACK handler in coap_session_disconnected()
Do this for all cases, not just for ICMP issue.
2024-05-14 09:00:54 +01:00
Jon Shallow b4a011a0e9 coap_uri.c: Fix support for app doing CoAP <> HTTP mapping 2024-05-14 08:55:59 +01:00
Jon Shallow e521eab58b coap_openssl.c: Revert out using SSL_use_certificate_chain_file()
Go back to using SSL_use_certificate_file().
Unexpected side effects with CA validation which needs further
troubleshooting to get to root cause.
2024-05-13 08:55:48 +01:00
Jon Shallow 5d77688f2d coap_block.c: Support 16 bit size_t in coap_context_set_max_block_size()
Allows RIOT to compile with 16 bit size_t processors.
2024-05-09 21:02:54 +01:00
Jon Shallow b14521d555 oscore_cbor.c: Fix bad scan-build fix 2024-05-09 21:01:23 +01:00
Jon Shallow e599e25d6e oss-fuzz: Fix issue in coap_pdu_parse_opt() 2024-05-09 13:33:06 +01:00
Jon Shallow dae064c7e8 scan-build: Add scan-build into the workflow testing 2024-05-09 10:57:16 +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 cd88fad218 coap_net.c: Silently drop incorrect CoAP version packets
As per https://datatracker.ietf.org/doc/html/rfc7252#section-3

Implementations of this specification MUST set this field to 1
(01 binary). Other values are reserved for future versions. Messages
with unknown version numbers MUST be silently ignored.
2024-05-09 09:58:40 +01:00
Jon Shallow 62a4934b6d coap_block.c: Use /.well-known/core when testing for Q-Block Support
It is possible the server does not support / resource, but does
support Q-Block - and responds with a 4.04, so Q-Block support
cannot be detected.
2024-05-06 10:50:30 +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 65f2f408be Build Tests: Fix Contiki build on macOS
Add libtool to the brew setup.
2024-04-25 14:46:07 +01:00
Jon Shallow ae438cb4bb man: Format examples as per CONTRIBUTION guidelines 2024-04-25 14:09:33 +01:00
Jon Shallow 749e16f6f6 Reporting: Encourage people to use github instead of mailing list 2024-04-23 16:43:17 +01:00
Jon Shallow c081bb6ffa doc: Tidy up documentation errors 2024-04-17 14:59:26 +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
Jon Shallow 04b239f55a main.yml: Fix node.js 16 warnings 2024-04-03 13:32:15 +01:00
Jon Shallow c88c783aea RIOT: Modify Kconfig / app.config to remove dep model 2024-04-02 21:28:57 +01:00
Jon Shallow 214665ac4b coap_pdu.c: Fix UndefinedBehaviorSanitizer: undefined-behavior
This fixes a reported error in coap_update_token() where a size_t
calculation is overflowed (but all ends up with the correct value).

Instead of adding an overflowed size_t, now subtract the reversed
size_t calculation as appropriate.

coap_update_option() and coap_insert_option() similarily updated.
2024-03-26 17:40:43 +00:00
Jon Shallow 0a39b6c03b versioning: Make current configure.ac version available in CMakeLists.txt
Create a CMakeLists.txt.in copy of CMakeLists.txt containing LIBCOAP_*
skeletons where appropriate. When ./configure is run, CMakeLists.txt then
gets updated with the latest versioning ready for distribution and using.

CMake unfortunately does not handle, for example, 4.3.5rc1 (the rc1 suffix)
for the "project (libcoap VERSION xxx)", so this has to end up as 4.3.5
in CMakeLists.txt.
2024-03-20 11:25:29 +00:00
Jon Shallow e3f7dbeec8 doc: Support hyper-linking to defined structures for man pages 2024-03-15 09:04:52 +00:00
Jon Shallow b332a188e5 Coverity: Fix 1584343
Reorganize code in the coap_lock_lock_func().
2024-03-15 09:02:19 +00:00
Jon Shallow d4beecbbc5 coap_tinydtls.c: Debug log unencrypted sent/received traffic sizes 2024-03-14 16:34:29 +00:00
Jon Shallow 1bde6f6ce6 coap_config.h*: Make the various OS coap_config.h more consistent
Add in coap_config.h.contiki.in to aid versioning updates.

Make the PACKAGE_ definitions consistent.
2024-03-14 16:30:26 +00:00
Jon Shallow be37ebb806 Coverity: Fix 1584357, 1584358 and 1584359 2024-03-14 16:27:11 +00:00
Jon Shallow 547379a4d0 coap_io_process: Handle COAP_IO_WAIT properly 2024-03-14 16:24:31 +00:00
Jon Shallow 79840df101 Coverity: Fix 1583538, 1583565 and 1583573
For the test suite, treat these tests as using the public API so locking
is handled by the underlying libcoap.

The only exception is for coap_delete_node() which is an internal function
and expects context to be locked on entry.
2024-03-14 08:53:29 +00:00
Jon Shallow a637024fa1 coap_io.c: Fix client only builds for coap_socket_bind_udp 2024-03-13 11:54:03 +00:00
Jon Shallow e25cf94d2a RIOT: Update to use SOCK i/f, not Posix
Remove all references to Posix functions, using Sock functions as appropriate.

Update coap_address_t to be RIOT specific when doing RIOT builds.
2024-03-12 17:15:01 +00:00
Jon Shallow 11d8e7cd72 coap_net.c: Response PDU not set to CON if reliable protocol
Fix generated response PDU in handle_request() to be of type CON
if reliable protocol (as a lot of code assumes it to be of pseudo
type CON) to stop a warning in coap_show_pdu().
2024-03-11 10:21:24 +00:00
Jon Shallow db6409bb80 QNX: Add in build support
Support compiling QNX 7 SDK.
2024-03-06 12:17:35 +00:00
Jon Shallow 1039f05294 SO_VERSION: Bump LT_LIBCOAP_REVISION to match release-4.3.4-patches
This is to make the SO Version 3.1.2, to match that that of branch
release-4.3.4-patches and tag v4.3.4a.
2024-03-06 12:15:09 +00:00
Jon Shallow 25e434d883 configure.ac: Correct libtool documentation 2024-03-06 12:10:34 +00:00
Mihaela-Madalina Nuta 3e4358844d ESP32: Add platform support 2024-03-04 11:29:16 +00:00
Jon Shallow 9f499ad42f coap_netif.c: Update incoming packet addresses earlier for any logging
Update session->addr_info from packet->addr_info before logging incoming
packet.  Only seen on the first incoming packet for a client as subsequent
packets likely to be the same address..
2024-02-29 11:22:49 +00:00
Jon Shallow e253183a5e coap_session.c: Fix token generation in coap_session_new_token()
Revert out change from #1276 and decrement token in coap_session_init_token() to
make sure starting token used is the same as that provided to
coap_session_init_token().
2024-02-29 11:15:28 +00:00
Jon Shallow a733325b16 multithread: Re-arrange lock checks for locked callbacks
Should fix CIDs
1583518-1583525
1583527-1583549
1583551-1583553
1583555-1583562
1583565-1583584
1583586-1583589
2024-02-21 16:54:32 +00:00