Add in optional callbacks for when dynamic resources are setup and deleted.
Add in optional callbacks for when observe subscriptions start and stop.
Add in optional callbacks for when the observe counter is updated (can be
ratelimited) for a resource as well as track when a resource is deleted.
Add is support for new functions
Main functions with libcoap tracking support are
coap_persist_startup()
coap_persist_stop()
coap-server has -t option to track observe information.
UDP sessions supported, as well as OSCORE over UDP.
Documentation updated
libcoap tracking support (as opposed to application tracking) is configurable.
This allows for code reduction if not all logging levels are required.
Done by defining ./configure --enable-max-logging-level=X, where X can have
the value of 0 through 8 inclusive.
COAP_LOG_EMERG is always logged.
Can save up to 40k bytes.
Follows RFC6455, as specified in RFC8323.
Make support configurable.
Add in example support.
Update other code to be aware of WebSockets as a CoAP protocol.
syslog.h is no longer required for libcoap as all LOG_ usage has been replaced
with COAP_LOG_.
Added #include <stdio.h> to example code for code-client and coap-server as
a hint should application code be using LOG_.
Current stack:-
Application
CoAP
CoAP-Session
DTLS
Netif
Sockets
Network Stack
Depending on the CoAP protocol, indexing functions through coap_layers_coap[]
(in src/coap_io.c) will invoke the correct layer function when used at the
CoAP and DTLS layers.
It is then easy to add in another protocol layer by updating coap_layers_coap[].
Add in new file src/coap_dtls.c.
Add in coap_(d)tls_establish() functions which are called when netif
accept / connect take place.
Add in coap_session_establish() function which is called when (D)TLS
has established as well as at the session layer if there is no (D)TLS
in preparation for properly supporting protocol layers.
Add in coap_(d)tls_close() functions which are called prior to
coap_netif_close().
Replace coap_network_{send|read}() with coap_socket_{send|recv}().
Move coap_epoll_ctl_mod() into coap_io.c to be along with all the other epoll
specific functions for consistency.
Add in skeleton coap_netif.c coap_netif_internal.h files, populated with
coap_netif_dgrm_read(), coap_netif_dgrm_read_ep(), and coap_netif_dgrm_write()
functions that are called by the CoAP and (D)TLS code which in turn call
the appropriate coap_socket_*() functions.
The coap_dtls_send() function parameters are aligned with
coap_netif_dgrm_write().
Provide mutex implementation for Zephyr RTOS, so that libcoap inside Zephyr
can be used with COAP_CONSTRAINED_STACK enabled.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
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.