Introduce new macro, which will be used for defining static mutex
objects, for use from COAP_CONSTRAINED_STACK enabled code. This macro
will automatically initialize mutex using platform/OS specific macro if
such exists.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Add in new function coap_context_set_max_token_size() to define
the maximum supported token size.
Track changes to PDU to support extended tokens.
Update documentation.
coap_resolve_address_info() emulates getaddrinfo() but has the extensibility to
support other socket types based on the address to resolve.
coap-client, coap-server and lwip/client updated to use this new functionality.
coap_address(3) updated to include the new functions.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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
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).
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.
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.
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.
Add in new event COAP_EVENT_XMIT_BLOCK_FAIL which gets triggered on
detecting transmission failure of large body using BlockX.
Track the last time a lg_xmit was sent, so it can be timed out on failure.
Correctly track the next lg_xmit timeout time (and lg_crcv, lg_srcv) so that
the lg_xmit can be expired.
Support for larger COAP_OBS_MAX_NON and COAP_OBS_MAX_FAIL definitions.
Change default for COAP_OBS_MAX_FAIL to 1 as there will already have
been MAX_RETRANSMIT(4) of the notification over a period of 93 seconds if
defaults are used.
Code and documentation clean up
Replace usage of hdr_size with max_hdr_size as appropriate as hdr_size
is not set until PDU is encoded. This should eliminate potential buffer
overruns.
Better checks for available space for the payload when using BlockX.
Clarify documentation.
A unique Request-Tag is added to any PUT/POST/FETCH request that contains
a large body. The server is then able to differentiate between concurrent
sending of large data using the same session.
If a server responds with a 4.01 and includes an Echo option, then the libcoap
client retransmits the request adding in the received Echo option with the same
value.
If the server responds normally with an Echo option, then the next request
from the libcoap client (internally added by libcoap) will contain that Echo
option.
It is the responsibility of the server application to add in the Echo
option if required and validate the next request unless the Echo is triggered
by OSCORE (RFC8613 Appendix B.1.2).
Add in new function coap_mcast_per_resource() to enable granularity of
handling multicast requests differently at the resource level.
The granularity is handled by how the flags variable is set up in
coap_resource_init(). These additional flags are ignored if
function coap_mcast_per_resource() has not been invoked.
Added 2 functions coap_resource_unknown_init2() and
coap_resource_proxy_uri_init2() that support defining the mcast flags as
per coap_resource_init().
Responses are now delayed rather than the request being delayed before being
passed to the request handler.
Update coap-server with the -r option to enable multicast on specific
resources.
Do not reset wait_ms in coap-client for Block2 transfers.
Sending off multiple CON requests with the same token without waiting for
any responses, causes the first one to be sent with the remainder ending
up in the delayqueue.
On receipt of ACK, coap_remove_from_queue() called in coap_dispatch(),
which returns the MID matching entry that was in the send queue, and then
the next entry on the delayqueue is removed from delayqueue and then sent
which puts the request on the sendqueue for any required re-transmissions.
coap_cancel_all_messages() should not be called in handle_response()
following the logic above if response is type ACK. If
coap_cancel_all_messages() is subsequently called with the same (possibly
empty) token as the next request that is being sent, then the next sendqueue
entry is inadvertantly deleted.
As there is now no sendqueue entry on receipt of the next ACK, the next
delayqueue entry is not sent off.
Only call coap_cancel_all_messages() if response is not of type ACK
(i.e. a separate response).
Report on tokens being the same as the previous one to encourage application
coders to use different tokens.