Commit Graph
2565 Commits
Author SHA1 Message Date
Olaf Bergmann 5e79c96882 Doxyfile.in: Adjust maximum value for graph nodes
This change increases DOT_GRAPH_MAX_NODES to 100. With the default
value 50, the following error message occured:

error: Included by graph for 'coap_internal.h' not generated, too many nodes (51), threshold is 50. Consider increasing DOT_GRAPH_MAX_NODES.
2023-01-20 18:05:14 +01:00
Jon Shallow 813de0e39f uri.c: Simplify coap_split_uri_sub()
Remove complexity from parsing and make it easier to add in new schemes.
2023-01-19 16:45:03 +00:00
Jon Shallow 7fab8aa6fb OSCORE Option: Check for off by one for kid 2023-01-14 15:16:26 +00:00
Jon Shallow 7623e0f085 OSCORE: Add in interopability tests
See https://core-wg.github.io/oscore/test-spec5.html

Add in new test server oscore-interop-server to provide the necessary
functionality.

Add in script and configuration files to run the tests locally.
2023-01-14 10:26:20 +00:00
Jon Shallow dac6bd3b60 RFC8613: Add in OSCORE support
Based on work done in https://gitlab.informatik.uni-bremen.de/obergman/libcoap

New directories with files
 include/oscore
 src/oscore

New files
 include/coap3/coap_oscore.h
 include/coap3/coap_crypto_internal.h
 include/coap3/coap_oscore_internal.h
 man/coap-oscore-conf.txt.in
 man/coap_oscore.txt.in
 src/coap_oscore.c
 tests/test_oscore.c
 tests/test_oscore.h

Supported by new option (enabled by default)
 ./configure --enable-oscore
 cmake .. -DENABLE_OSCORE=ON

Requires a TLS library configured to do the OSCORE encryption and hashing.
2023-01-14 10:26:20 +00:00
Jon Shallow 3552b53be4 Copyright: Update copyright date to end 2023 as appropriate 2023-01-02 11:45:10 +00:00
Jon Shallow 4882641b95 documentation: Tidy up / correct documentation 2022-12-30 10:55:29 +00:00
Richard Retanubun e1d33fd7c9 resource.c: Add COAP_RESOURCE_MAX_SUBSCRIBER to limit subscribers
If COAP_RESOURCE_MAX_SUBSCRIBER is > 0
coap_add_observer() now checks and returns NULL
if COAP_RESOURCE_MAX_SUBSCRIBER is exceeded.

net.c then detects this and respond.

Per RFC7641 4.1. Request:

  A server that is unable or unwilling to add a new entry to the list
  of observers of a resource MAY silently ignore the registration
  request and process the GET request as usual.  The resulting response
  MUST NOT include an Observe Option, the absence of which signals to
  the client that it will not be notified of changes to the resource
  and, e.g., needs to poll the resource for its state instead.

Useful for constrained systems that wants to support
observers but need to be mindful of memory usage.
2022-12-26 11:19:21 +00:00
Jon Shallow 088fff1a82 coap-client.c: Fix case when no host is specified in the URI
If the host has not been specified in the URI, do not add in an
empty Uri-Host option as that is illegal.
2022-12-26 10:49:20 +00:00
Jon Shallow 7aa003bbe7 RFC links: Provide consistency for links to RFCs
Use https://rfc-editor.org/rfc/rfc.... instead of
https://tools.ietf.org/html/rfc.... for the RFC links.

Use https://rfc-editor.org/rfc/rfc.... instead of
https://datatracker.ietf.org/doc/html/rfc.... for the RFC links.
2022-12-20 20:36:53 +00:00
Jon Shallow 4821daf366 documentation: Tidy up documentation
Provide consistency across all of the man pages as per :-

Provide missing function headers for functions.

Hyper link the function definitions.

Hyper link RFC references (except in code blocks).

Use https://rfc-editor.org/rfc/rfc.... instead of
https://tools.ietf.org/html/rfc.... for the RFC links.

Use https://rfc-editor.org/rfc/rfc.... instead of
https://datatracker.ietf.org/doc/html/rfc.... for the RFC links.
2022-12-20 20:34:37 +00:00
Jon Shallow 68f1a6eff3 log_levels: Replace usage of syslog LOG_ with COAP_LOG_
This removes the reliance of syslog definitions in libcoap by using libcoap's
version.
2022-12-17 12:38:31 +00:00
Jon Shallow b8c5638423 examples: Align exit codes with documentation
Exit code of -1 is not defined in example man pages - use a value of 1
2022-12-13 20:31:18 +00:00
Jon Shallow be40b1f9cd block.c: Fix missing coap_log() updates from a merge 2022-12-13 20:29:32 +00:00
Jon Shallow 19841c2369 NACK: make sure token is correct as presented to NACK handler
For clients, update the stateless token used for subsequent block
transmissions back to the token used for the coap_send() when
reporting NACK errors.
2022-12-13 08:42:43 +00:00
Jon Shallow 73c4466779 logging: Use the new logging macros for libcoap code
Drop the use of syslog LOG_DEBUG etc. for coap_log() and use the
coap_log_debug() etc. macros which make use of COAP_LOG_DEBUG etc.
2022-12-13 08:30:33 +00:00
Jon Shallow f6aebcbff7 mem: Use coap_malloc_type() and coap_free_type() in libcoap
The use of coap_malloc() and coap_free() does not work with environments
that have their own memory managers (e.g. LwIP).

Convert coap_malloc() to coap_malloc_type(COAP_STRING,) and coap_free()
to coap_free_type(COAP_STRING,) in the library.
2022-12-13 08:24:29 +00:00
Jon Shallow 48c8eb0b3c .gitignore: Ignore LwIP DTLS enabled executables 2022-12-10 15:16:52 +00:00
Jon Shallow 4b54c0d9ef logging: Use new logging macros for examples and man pages
Drop the use of syslog LOG_DEBUG etc. for coap_log() and use the
coap_log_debug() etc. macros which make use of COAP_LOG_DEBUG etc.

Application examples updated, as well as the man page examples.
2022-12-09 14:55:39 +00:00
Jon Shallow 2c61bf184e Reliable: Fix usage of PDU type and mid
Reliable code expects type to be CON and can get confused by NON.

Having random values for mid for reliable sessions makes no sense as
the mid is not in the packet..

Only send out RST if non-reliable session.
2022-12-09 14:53:20 +00:00
Jon Shallow 349a0db6da Modeline: Correct vim modline syntax for missing files
The modline entries for Vim were not correct, various options get
declared by a space in between, and also no special character at the end
of the line are allowed.
2022-12-01 20:29:35 +00:00
Carsten Schoenert dd84e5af34 Modeline: Correct vim modline syntax
The modline entries for Vim were not correct, various options get
declared by a space in between, and also no special character at the end
of the line are allowed.
2022-12-01 19:36:27 +00:00
Carsten Schoenert 89222d0cf1 Spelling: Fix typo resouce -> resource 2022-12-01 19:05:22 +00:00
Carsten Schoenert 1ef1cc2b4b Spelling: Fix typo interator -> iterator 2022-12-01 19:05:22 +00:00
Carsten Schoenert ea678ee5b3 Spelling: Fix typo determing -> determining 2022-12-01 19:05:22 +00:00
Carsten Schoenert 2221a53d9c Spelling: Fix typo compatability -> compatibility 2022-12-01 19:05:22 +00:00
Jon Shallow 73b59182fd FETCH Observe: Handle Observes when FETCH body is large
Assemble all the blocks before checking for Observe registration
or de-registration.

Track all the tokens used for the large FETCH registration and
re-use them for the de-registration as the server can elect to use
any of them when re-assembling the body for the registration Token.
2022-11-30 11:35:25 +00:00
Jon Shallow a152ca7cdb coap_mbedtls.c: Handle mbedtls_ssl_write() not sending all the data for TLS
Treat mbedtls_ssl_write() like any other send function that does not send
all the data and re-send the missing data.
2022-11-30 11:26:23 +00:00
Jon Shallow c9f40d7d09 request-tag: Add in support for sending Request-Tag option with every request
If multiple requests (apart from DELETE) are sent at the same time to
the same resource, and the responses need to make use of the Block2 option,
there is no way for the server to differentiate between which block set a
request (if there is a resource content change) is for unless a Request-Tag
is used.

Disable this functionality by setting COAP_BLOCK_NO_PREEMPTIVE_RTAG when
calling coap_context_set_block_mode().  Request-Tag will still be sent
with any request that includes Block1 option.
2022-11-26 12:47:21 +00:00
Jon Shallow 1b6498fab5 block.c: Handle duplicate responses in coap_handle_response_get_block()
Remove invoking going into block by block mode on detection of error or
duplicate response and so passing duplicate information to the app.
2022-11-26 12:31:00 +00:00
Jon Shallow 89b159b148 coap_io_process_with_fds: Move mutex protected variables into coap_context_t
coap_io_process_with_fds() can lock up a mutex for a long time for
stack constrained systems.

If 2 threads (in embedded system) provide client and server functionality
using separate coap_context_t, then there will be random delays on the other
thread while the first is waiting having called coap_io_process() or
coap_io_process_with_fds().

No thread should lock up a mutex for a long time.  Moved the (mutex protected)
variables into coap_context_t so there is no need to use a mutex.
2022-11-26 12:29:46 +00:00
Jon Shallow c0559e37b4 option checking: Do further option syntax checking for incoming PDUs
Extend coap_option_check_critical() for repeating options that are not
repeatable, so 4.02 error code can be returned.
https://www.rfc-editor.org/rfc/rfc7252#section-5.4.5

Check for option Proxy-Scheme and return 4.02 if option Uri-Host is
not present.

Clear M bit for option Block2 in a request as it must be ingnored on reception.
https://datatracker.ietf.org/doc/html/rfc7959#section-2.2

check_repeatable() now is coap_option_check_repeatable() (still internal).
2022-11-23 15:51:34 +00:00
Jon Shallow 8a40fcc4aa options: Update documentation and fix incorrect function usage
Correct documented return values from changes back in 2015 for option filter
checking (option numbers could only be 1 byte then).

Correct code in coap_option_next() that assumed one of the defunct return
values.
2022-11-23 15:42:47 +00:00
Jon Shallow d8d9101f9c pdu.c: Remove unnecessary logging code 2022-11-23 15:33:20 +00:00
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