Commit Graph
592 Commits
Author SHA1 Message Date
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
Jon Shallow b332a188e5 Coverity: Fix 1584343
Reorganize code in the coap_lock_lock_func().
2024-03-15 09:02:19 +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 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
Denis Begun c7c3275e53 This fixes the issue of a client not ACKing a duplicate CON message from the server.
A duplicate CON message is sent by the server if the client's ACK to the original
confirmable message did not reach the server.
See issue #1306 for full description: https://github.com/obgm/libcoap/issues/1306
2024-01-06 14:51:30 +00:00
Jon Shallow 8237c1d801 Copyright: Update to 2024 2024-01-02 08:45:59 +00:00
Jon Shallow cc1cc1ad27 coap_net.c: Check for invalid PDU class codes 2023-12-27 11:31:26 +00:00
Jon Shallow e7105286f6 coap_threadsafe.c: Fix NPE in coap_delete_resource() 2023-12-20 10:54:54 +00:00
Jon Shallow 0f3ae5022d coap_block.c: Support server setting max block size for Block1/Block2 2023-11-30 16:48:10 +00:00
Jon Shallow c69c5d5af0 multi-thread: Add in thread safe support
Optional compile time thread safe code supported.

Locking is done at the coap_context_t level, and if enabled is primarily
done coap_threadsafe.c and coap_threadsafe_internal.h.

coap_threadsafe_internal.h causes coap_X() to get mapped to coap_X_locked()
throughout the libcoap library code with the exception of coap_threadsafe.c
if thread safe is enabled.
2023-11-25 11:41:26 +00:00
Jon Shallow 6b4fac968d PKI: Document intermediate CAs
Correct some typos
2023-11-20 11:27:58 +00:00
Jon Shallow 2e7cb35c01 WebSocket: Add support for noTLS and TinyDTLS
Use SHA1 code from RFC3174 sections 7.1 and 7.2.
2023-11-15 10:06:44 +00:00
Jon Shallow 805d148dd0 LwIP: Support TCP
If LWIP_TCP is set, then CoAP TCP support is compiled in.
2023-11-11 10:24:08 +00:00
kkrentz 3b246dfe73 OSCORE: Treat CoAP pings as requests 2023-11-07 16:18:07 +00:00
Jon Shallow 17e44c73df memory: Support debug tracking of memory usage
New function coap_dump_memory_type_counts().

Requires COAP_MEMORY_TYPE_TRACK to be defined as 1.
2023-10-24 12:43:13 +01:00
Jon Shallow 203d228638 RIOT: library fixes for different build types
coap_debug.h: Support logging level set to _COAP_LOG_EMERG
coap_pdu.h: handle small ints
coap_pdu_internal.h: handle small ints
coap_session_internal.h: handle small ints
coap_uthash_internal.h: handle small ints
coap_block.c: Handle small ints
coap_debug.c: Fix use of vsnprintf() and vfprintf()
coap_pdu.c: Handle small ints
coap_tinydtls.c: Handle small ints
coap_uri.c: Fix alignment issue in coap_new_uri()

uncrustify run on RIOT examples to conform to RIOT's coding standards/
2023-10-23 14:38:57 +01:00
Jon Shallow 05d02be7a9 coap_net.c: Fix CSM timeouts in coap_client_delay_first()
Reduce timeout to 1 second and enter established state for servers that
only partially implement RFC8323 for TCP support, but do not send a CSM.

Add new coap_context_set_csm_timeout_ms() to control the value of the timeout.
2023-10-23 14:32:46 +01:00
kkrentz 6addbef1b1 Suppress RST when the processing of a non-empty ACK fails 2023-10-19 15:00:24 +01:00
Jon Shallow 26302a076b coap-server.c: Add in support for output to syslog 2023-10-19 11:26:41 +01:00
Jon Shallow 48753b155b Stateless: Add in some stateless support
Client able to send data for every FETCH command to get next Block2 response.

Server able to not keep state while sending Block2 responses back.
2023-10-19 10:33:17 +01:00
kkrentz 38a726de37 Contiki-NG: Remove call to clock_init as Contiki-NG already does it 2023-10-19 10:19:32 +01:00
Jon Shallow ccf17f5914 coap.h: Tidy up coap.h.* files to make them consistent 2023-10-13 14:17:34 +01:00
kkrentz d61713d35d Contiki-NG: Renamings to avoid confusion 2023-10-13 14:12:06 +01:00
kkrentz 44cf0940c9 Contiki-NG: Re-schedule prepare timer in same occasions as the epoll timer 2023-10-13 14:12:06 +01:00
Jon Shallow 69e1784561 Update version to release 4.3.4
Update ABI to 3.1.1
2023-10-04 22:04:05 +01:00
Jon Shallow 342a2d0893 coap.h.windows: Correct sort order of includes 2023-10-04 22:03:36 +01:00
Jon Shallow 8683a3177c coap_cleanup: Allow coap_startup() to be called after coap_cleanup() 2023-10-04 22:02:31 +01:00
Jon Shallow 9cde7cdee1 Update version to release 4.3.3 2023-09-14 09:55:47 +01:00
Jon Shallow f67f44516a Update version to release 4.3.2 2023-09-07 11:51:24 +01:00
Daniel Mangum a9808ade42 Define coap_mutex_t as sys_mutex on Zephyr
Changes definition of coap_mutex_t as k_mutex to sys_mutex to build
properly with Zephyr.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-09-04 10:35:57 +01:00
Jon Shallow f176bf3c53 release 4.3.2rc2: Release candidate for 4.3.2 2023-08-14 09:37:23 +01:00
Jon Shallow cd7b5de109 Mutexes: Clean up / simplify use of mutexes
Not all OS implementations properly support static initializations.
2023-07-29 11:31:22 +01:00