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.
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.
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.
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.
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.
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.
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.