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().
Useful when coap-client is used to send block transfers.
Without this, users have to run coap-client with `-v 7`
before they can see why coap-client ends earlier than expected.
Logging at warning level to match the default log level
set by coap-client source code.
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().
pdu->actual_token.length is a size_t, so use "%zu" format specifier.
session->max_token_size is a uint32_t, so use "%" PRIu32 format specifier.
This allows to correctly handle those in a cross platform way.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
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>
`in_port_t` might be hidden under `_GNU_SOURCE` feature test macro, which
is not defined at the top of the file. This happens with newlib build with
Zephyr SDK and with Zephyr RTOS. As a result following build error occurs:
/libcoap/src/coap_debug.c: In function 'coap_print_addr':
/libcoap/src/coap_debug.c:189:3: error: unknown type name 'in_port_t'; \
did you mean 'io_port_t'?
189 | in_port_t port;
| ^~~~~~~~~
| io_port_t
Workaround that issue by replacing `in_port_t` with `uint16_t`, as that is
the only place where former typedef was used.
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.
Stack variable errors can creep in when code jumps to a label that is
in an inner level block that defines and uses that variable. Most cases are
caught by the compiler, but some are only caught by valgrind.
Reorder code so that use of inner blocks is reduced and labels are in the
top level block.
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.
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.
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.
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.