Commit Graph
2531 Commits
Author SHA1 Message Date
Jon Shallow 1db3683cef github workflows: Support Ubuntu 22.04 images
Fix issues thrown up with ubuntu-latest moving to ubuntu-22.04.

clang 14+ generates dwarf-5 code which valgrind does not currently support
so downgrade to output dwarf-4.

Use ./autogen.sh for tinydtls builds rather than 'autorecond --force --install'

Remove some spurios } in the workflow
2022-11-22 21:30:18 +00:00
Jon Shallow c56ac32c86 cifuzz.yml: Run when code is pushed to develop or main etc.
Matches main.yml on: statement for push.

on: pull_request removed so that it is not run for every PR, just the
develop, main and release branches.
2022-11-22 14:17:25 +00:00
Jon Shallow 11018cc34c pdu.c: Correctly check for NUL termination space when outputting bad options 2022-11-22 09:58:36 +00:00
Jon Shallow 64de2ba4ea resource.c: Correctly handle observe delete by server application
If the request handler returns an error code to an observe request
then following the deletion of the observe, no longer refer to the
now deleted object.
2022-11-22 09:02:03 +00:00
Jon Shallow 96c774de36 coap-server.c: Fix async query updating delay 2022-11-22 08:59:22 +00:00
David Korczynski 74f1858cfb github workflow: add CIFuzz Github action
Signed-off-by: David Korczynski <david@adalogics.com>
2022-11-22 08:52:22 +00:00
Jon Shallow 3a2b10e20f coap-client.c: Clean up exit conditions
Clean up / simplify conditions for breaking out of the main coap_io_process()
loop. ready is no longer required here.

Handle mcast Observe requests by continuing to track the token

Make sure that all of the Observe (potentially blocked) response is received
before closing down.

Remove unecessary code.
2022-11-22 08:34:19 +00:00
Jon Shallow 070d34c744 coap_io.c: Update log level for outputting optional wakeup times 2022-11-07 09:43:07 +00:00
Jon Shallow 710a8b5288 coap_io_pending: Add in new function to check if there is any i/o pending
coap_io_pending() checks to see if there are any PDUs pending transmission,
whether there are any large (block) transmissions in progress, whether
there are still expected response packets(client) or expected request
packets(server), and whether the client is expecting further observe
responses.  If any of this is true, then it returns 1, else 0.

coap_io_pending() also invokes coap_io_process() to check that all that can
be transmitted is, as well as processes any impending input packets.

This takes coap_can_exit() a step further who only checks the transmit state.

coap_handle_response_get_block() has been updated to release the current
lg_crcv if all the fragmented body of a large transfer have been received.

Documentation updated.
2022-11-04 14:06:55 +00:00
Jon Shallow 3897d2334c Logging: Make logging consistent across (D)TLS libraries
Set up coap_log_t as an enum, using syslog variable names prefixed by
COAP_.

Add function coap_dtls_log() for logging information from (D)TLS libraries.

Update the log output to have use Lower-case variants for the logging levels to
indicate that output is from the (D)TLS library instead of the CoAP library.

(D)TLS libraries updated to be consistent in the usage of
coap_dtls_set_log_level()/coap_dtls_get_log_level().

Add in coap_log_emerg(), coap_log_alert() etc. as wrappers to reduce the line
length required for log entries.  Updating all the coap_log() functions to
no longer use syslog variants will be a part of a separate PR.

Added in the "-V" option to the examples, with an initial default of
COAP_LOG_ERR, separating out the CoAP and (D)TLS logging levels.

Note: TinyDTLS log output will be consistent when built against a TinyDTLS
version that contains support for an external logging handler.
2022-11-03 16:02:36 +00:00
Jon Shallow 458f2d5702 TinyDTLS: Support build with DTLS_PSK not defined.
As well as adding in the DTLS_PSK wrappers in the appropriate place. add in
coap_dtls_psk_is_supported(), coap_dtls_pki_is_supported(),
coap_dtls_pkcs11_is_supported() and coap_dtls_rpk_is_supported() functions
to support better granularity of what capabilities are available in the
(D)TLS libraries.

Update coap_string_tls_support() to use these new functions.

Uppdated documentation for these new functions.
2022-11-03 09:03:52 +00:00
Jon Shallow df4d475cc7 net.c: Report the node's retransmit timeout as actual timeout
If NSTART > 1, any retransmit timeouts are reported on the difference in
time with an earlier entry in the transmit queue, rather than the actual
delay before the node entry gets retransmitted.

This change reports on the actual delay for a node before it gets retransmitted,
which more accurately records when the node will get retransmitted.
2022-11-02 14:29:26 +00:00
Jon Shallow 496cef7da4 coap_openssl.c: Support OpenSSL 3.0+ client talking to legacy server
OpenSSL 3.0+ has removed the SSL_OP_LEGACY_SERVER_CONNECT option from the
default set list meaning that a OpenSSL 3.0+ client is unable to set up a
session with a TinyDTLS server.

This fix adds back in SSL_OP_LEGACY_SERVER_CONNECT to the set list of
options.

This removes the message that reports the failure
"unsafe legacy renegotiation disabled"
that causes the session set up to fail.

There is debate as to whether RFC 5746 is appropriate for DTLS sessions,
which is what OpenSSL 3.0+ now enforces unless SSL_OP_LEGACY_SERVER_CONNECT
is set.
2022-11-01 13:10:25 +01:00
Jon Shallow 47f3b505ee TLS: Updates for later TLS library versions 2022-10-31 08:37:50 +00:00
Jon Shallow 7b39908e82 LwIP: Add in TinyDTLS support
The dtls versions of the server and client are built as
server-dtls and client-dtls.

Add in flexible option support for server and client.  These are
a subset of the coap-server and coap-client options.
2022-10-29 13:26:43 +01:00
Jon Shallow ae74b27592 coap_openssl.c: Handle ERR_func_error_string() deprecated for OpenSSL 3.0 2022-10-29 13:10:13 +01:00
Jon Shallow 7a5b349121 coap_mbedtls.c: Handle extra error codes triggered by OpenSSL 3.1 2022-10-29 13:05:41 +01:00
Jon Shallow 8b7539f2bf block.c: Make sure ETAG option gets properly added
It is possible that there is, say, a Block2 option already in the PDU
so need to make sure ETAG option is always added in.
2022-10-27 13:05:05 +01:00
Jon Shallow f3b1d54519 coap_openssl.c: Ignore OpenSSL 3.0 deprecated warnings for now 2022-10-27 11:48:41 +01:00
Jon Shallow b39e7bb3fc coap_uri: Tidy up documentation 2022-10-26 14:37:41 +01:00
Jon Shallow c5867ccf77 tinydtls: Update submodule to the latest version of main branch 2022-10-26 12:33:35 +01:00
Jon Shallow 972eecf157 LwIP: Fix unused parameter compiler warnings 2022-10-21 20:45:04 +01:00
Jon Shallow 3126102d00 includes: Prefix more header files with coap_ to prevent name clashes
encode.h and str.h are not used in any open PRs and can safely be renamed
with a coap_ prefix.

Order the include lists alphabetically as if all the entries have a coap_
prefix, so when the include file gets renamed with a coap_ prefix, the
include order is not disturbed.

Rename (as these are all internal files) for clarity
coap_mutex.h to   coap_mutex_internal.h
coap_hashkey.h to coap_hashkey_internal.h
uthash.h to       coap_uthash_internal.h
utlist.h to       coap_utlist_internal.h
2022-10-20 17:00:44 +01:00
Jon Shallow bbf098a72a main.yml: Update actions/checkout to be v3 2022-10-19 17:24:03 +01:00
Nick Miller 312a0561e4 coap_event: Add COAP_EVENT_MSG_RETRANSMITTED
Apart from debug log messages, there is no way for a user to be
notified when a message retransmission happens.

This event can be useful for diagnosing issues related to
lossy networks or unresponsive CoAP servers (e.g. user can
track total retransmissions as an indicator for general link
quality).

Assigned event ID to 0x5002 to avoid creating a new 0x6000
event group, and because it's similar to COAP_EVENT_BAD_PACKET (0x5001).
2022-10-19 16:34:07 +01:00
Jon Shallow f5251e682c coap-client.c: Validate input block sizes 2022-10-18 15:02:38 +01:00
Jon Shallow 4ca66d5b3b Examples: Format function headers and else statements.
Update function headers and "} else {" in libcoap coding style.
2022-10-18 10:27:02 +01:00
Jon Shallow 70741f6417 coap-server.c: Handle ongoing proxy setup failure 2022-10-14 08:44:43 +02:00
Jon Shallow de369eb7c7 coap-client.c: Cleanup following observe cancellation
Delay exit briefly checking if there are any response packets following
observe cancellation and process as appropriate.

If multiple observes are outstanding, cancelling them using CON will
cause issues as NSTART limit is hit.  The server then does not know
about all of the cancellations.

Also, this can allow the server to properly shutdown observe
activity when blocks are used.
2022-10-14 08:44:21 +02:00
Jon Shallow d09d56860f coap.txt.in: Fix missing references and hyperlink RFC references
The RFC references appear without the hyperlink in the man pages,
but now appear as hyperlinked in the doxygen output.

SEE ALSO updated with missing references.
2022-10-12 21:38:42 +01:00
kkrentz dc66470a1a Simplifies a few preprocessor directives 2022-10-12 17:21:20 +01:00
Jon Shallow c5c4f9bf1d uri.c: Add coap_uri_into_options() function
Simplify code for applications by providing coap_uri_into_options()
which then adds the (optional) port and splits out the path / query
as CoAP options, adding them to the optlist_chain for subsequent use.

Added a new coap_delete_uri() for completeness.

Update documentation to include the uri based functions.

Update examples to use the new coap_uri_into_options() function.
2022-10-12 15:24:02 +01:00
Jon Shallow 3659e3c0cb LwIP: Support receiving ethernet MTU sized packets
Define PBUF_POOL_BUFSIZE appropriately in lwipopts.h
2022-10-12 14:37:20 +01:00
Jon Shallow 149fe74805 coap_openssl.c: Fix CA memory leak 2022-10-12 11:08:21 +01:00
Jon Shallow c0572443dc uri.c: Fix oss-fuzz issue 48362
Introduced by fix #818 Feb 7 2022.
2022-10-05 09:22:50 +02:00
Jon Shallow 6a633e3d49 CMake: Force all Warnings to Errors when doing github actions
Add new option WARNING_TO_ERROR for CMakeLists.txt

Includes cmake builds for Windows and macOS
[Fix coap-client S_ISDIR() duplication bug]
2022-09-30 17:25:00 +02:00
Jon Shallow 692c06d95f build: Fix client and server only builds
Also correct LwIP build directory.
2022-09-27 10:37:38 +01:00
Jon Shallow de1bc9f3cb LwIP: Add in support for client
New demo client app.

Update some of the memory sizes.
New coap_lwip_dump_memory_pools() to dump LwIP memory pool usage.

Add in logic to handle new client sessions.

New coap_io_process() to handle LwIP which can invoke a callback handler
to wait / timeout for the next input handler.
New coap_lwip_set_input_wait_handler() to define this handler.

Update coap_io_prepare_io() to handle LwIP.

Support re-use of pbuf for PDU re-transmissions.

Make sure that NSTART is correctly obeyed.

Build the client with client only libcoap code.

Build the server with server only libcoap code.

Update LwIP source to latest stable release.

Reserve memory for a response PDU.

New coap_lwip(3) man page.

Update directory structures for config files.

Update files contained in "make dist" and check lwip rebuilds
in the github workflows.
2022-09-22 10:14:48 +01:00
Jon Shallow da213380d9 coap_session.c: Make sure large block handling is cleaned up if network issue 2022-09-22 10:04:07 +01:00
Jon Shallow 2f25c950af net.c: Call nack handler for badly formatted response packet
If a response packet is received that is badly formatted, invoke the
nack handler (if defined) with COAP_NACK_BAD_RESPONSE so that the
requestor knows there is an issue, rather than timing out.

However, if the response packet is so badly formatted, or it is not
possible to find the requesting packet, then this nack event will not
trigger, but an event is triggered with COAP_EVENT_BAD_PACKET.
2022-09-20 15:12:29 +02:00
Olaf Bergmann 02b76470ab Merge branch 'release-4.3.1' 2022-09-02 13:45:57 +02:00
Olaf Bergmann c694baead2 Update version to release 4.3.1 v4.3.1 2022-09-02 13:42:24 +02:00
Jon Shallow ab9488559f Doxygen: Fix missing links for later versions of asciidoc
Fix the link for the last entry in the name list where asciidoc
converts the minus sign to an extended dash (em dash)

Remove the updating of navtree.js as it is done differently in later
versions of doxygen.

Add in the missing name entry for coap_attribute.
2022-09-02 13:00:51 +02:00
Jon Shallow 144f9c4381 Manual pages: Update NAME section to contain all of the alternative names
Update the NAME section with all of the alternative names.  All the different
files are already built.
2022-09-02 12:59:26 +02:00
Jon Shallow 707aed35d3 Doxygen: Hyperlink man page functions
Where functions are referred to in the man pages, hyperlink them for
easy cross reference.
2022-08-26 17:37:41 +01:00
Jon Shallow 46feac2455 Misc: Tidy up documentation and space usage 2022-08-24 17:55:43 +02:00
Jon Shallow d09204e24a Doxygen: Add in individual man pages for the ease of finding the functions
Add in a new index tag for all the functions defined within the man pages.

Highlight the occurrence of that function name in the appropriate displayed
page.

For the man pages that have been restructured to break out the individual
functions, jump to the function definition.
2022-08-23 14:21:45 +02:00
Olaf Bergmann 09aab40d14 Tag release candidate 2 for version 4.3.1 v4.3.1-rc2 2022-08-23 13:19:08 +02:00
Olaf Bergmann 2755af4d1a block.c: Clarify ignored result from coap_get_data()
Addresses CID 1520612.
2022-08-23 10:49:15 +02:00
Olaf Bergmann 5f0eea8dbb coap_session.c: Fix adding NULL pointer on error in coap_new_server_session()
When coap_make_session() fails, the local variable session will be
NULL, and the program continues at the error label. Because of
session == NULL, coap_session_free() will return immediately, leaving
a NULL entry in ep->sessions.

This fix is related to CID 1520613.
2022-08-23 08:43:38 +02:00