Create new options coap_uri_into_optlist(), coap_path_into_optlist() and
coap_query_into_optlist() to be used instead of coap_uri_into_options(),
coap_split_path() and coap_split_query() functions so the requirement
for a scratch buffer is not needed.
Getting the minimum size for a scratch buffer is not straight forward and
potential for unexpected boundary condition errors to occurif too small.
Correct parsing and stripping out of "%2E%2E" ("..") and "%2E" (".")
path segments. ".." now removes the previous segment (if it exists).
Update documentation and unit testcases.
Update examples to use new options.
Update the Public API equivalent of the libcoap functions that need to be
called when locked with a name suffix of _lkd.
Move matching Public API functions out of coap_threadsafe.c to be coded
just ahead of the newly renamed _lkd function.
Properly define the _lkd function in the appropriate _internal.h file for
documentation, removing the #defines from coap_threadsafe_internal.h.
Tag all the Public API functions that have a _lkd function with COAP_API.
COAP_API can then be defined as to what should be done for that function.
Check libcoap library does not call the original Public API function when
it should be calling the _lkd function by marking the Public API not _lkd
functions as deprecated during the libcoap library build.
[Done by the new COAP_API being defined as __attribute__((deprecated)).]
Work in progress for all the functions that need to be multi-thread safe.
Update libcoap functions that need to be called locked with a name
suffix of _locked.
Move matching functions out of coap_threadsafe.c to be coded just ahead
of the newly renamed _locked function.
Properly define the _locked function in the appropriate _internal.h file
for documentation, removing the #defines from coap_threadsafe_internal.h.
Work in progress for all the functions.
Remove coap_lock_* requirements for testdriver (coap_delete_node()).
For the test suite, treat these tests as using the public API so locking
is handled by the underlying libcoap.
The only exception is for coap_delete_node() which is an internal function
and expects context to be locked on entry.
Optional compile time thread safe code supported.
Locking is done at the coap_context_t level, and if enabled is primarily
done coap_threadsafe.c and coap_threadsafe_internal.h.
coap_threadsafe_internal.h causes coap_X() to get mapped to coap_X_locked()
throughout the libcoap library code with the exception of coap_threadsafe.c
if thread safe is enabled.
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.
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.
This removes a lot of code duplication by creating a pseudo resource
for .well-known/core that is not included in the .well-known/core output.
In particular specific Block2 option handling is no longer required.
Updated tests which now include checking that queries work.
The CoAP Proxy may not know how to handle a Critical option, but if it
is safe to forward it should be able to handle this.
RFRC7252 5.4.1
Critical/elective rules apply to non-proxying endpoints. A proxy
processes options based on Unsafe/Safe-to-Forward classes as defined
in Section 5.7.
If this is an incoming proxy type request special case any
critical options that are safe to forward.
Track ongoing sessions from an enabled proxy server so unknown critical
response options can be passed back to the originating requestor.
Update coap-server to handle Proxy-Scheme for proxying.
Update tests to use critical option 25 instead of 9.
When coap_pdu_parse() returns 0, the contents of pdu are undefined and
must not be processed. This change proceeds fuzzer tests only if parsing
succeeded.
Fixes OSS-Fuzz issue 44503 [1]
[1] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44503
Add in new ./configure options --enable-client-mode or
--enable-server-mode which by default are enabled.
If --disable-client-mode is set, then disable all the client specific code.
[ COAP_CLIENT_SUPPORT is not defined ]
If --disable-server-mode is set, then disable all the server specific code.
[ COAP_SERVER_SUPPORT is not defined ]
Functions and variables are only #ifdef'd out in the include/coap3/*_internal.h
files. They cannot be #ifdef'd out in the other include files as
COAP_CLIENT_SUPPORT and COAP_SERVER_SUPPORT are not available for application
compilations. The result of this is if, say, client only API functons are used
in a server application and COAP_CLIENT_SUPPORT is not defined, there will be
linking issues (missing functions). Providing stub functions unecessarily
increases the code size.
For coap-server, if it is able to provide proxy support, requires both
COAP_SERVER_SUPPORT and COAP_CLIENT_SUPPORT to set up the ongoing sessions.
So, the build environment deliberatly sets SERVER_CAN_PROXY=0 if
COAP_CLIENT_SUPPORT is not available to allow linking.
Some of the tests have to be disabled if COAP_SERVER_SUPPORT or
COAP_CLIENT_SUPPORT is not set.
Code size change indications
text data bss sum filename
155912 1728 12080 169720 libcoap-3-notls.a
138300 1728 12080 152108 libcoap-3-notls.a --disable-client-mode
106734 1632 10304 118670 libcoap-3-notls.a --disable-server-mode
180485 1733 12080 194298 libcoap-3-openssl.a
160306 1733 12080 174119 libcoap-3-openssl.a --disable-client-mode
125543 1637 10304 137484 libcoap-3-openssl.a --disable-server-mode
181755 1728 12080 195563 libcoap-3-gnutls.a
160972 1728 12080 174780 libcoap-3-gnutls.a --disable-client-mode
127178 1632 10304 139114 libcoap-3-gnutls.a --disable-server-mode
165879 1855 12128 179862 libcoap-3-tinydtls.a
147022 1855 12128 161005 libcoap-3-tinydtls.a --disable-client-mode
115618 1759 10352 127729 libcoap-3-tinydtls.a --disable-server-mode
171690 1728 13744 187162 libcoap-3-mbedtls.a
152099 1728 13712 167539 libcoap-3-mbedtls.a --disable-client-mode
118786 1632 11984 132402 libcoap-3-mbedtls.a --disable-server-mode
This change adds 'SPDX-License-Identifier: BSD-2-Clause' [1] to
the source code files that originate in the libcoap project.
Note that not all files are tagged because they are pulled in
from other sources and thus may fall under a different license.
More information about these is contained in the LICENSE file.
[1] https://spdx.org/licenses/BSD-2-Clause.html
Handle correctly the case when inserting before the last option and the last
option has a large delta and size that takes it over 5 bytes. Correctly
define the remainder of option space when calling coap_opt_parse().
Commit e4e067e5f has introduced a new type for PDU request and status
codes, coap_pdu_code_t. This change now uses proper enums values to
fix compiler warnings (-Wenum-conversion).
Move coap_pdu_t to coap_pdu_internal.h.
Move internal PDU based function definitions to coap_pdu_internal.h.
Replace most references to "struct coap_pdu_t" with "coap_pdu_t".
Create new enum coap_pdu_type_t, enum coap_pdu_code_t and coap_option_num_t,
using them where appropriate for clarity of documentation.
Provide new functions to allow applications to access/update parts of
coap_pdu_t as appropriate and document as appropriate.
Update examples to use these new access functions where appropriate.
Add in some new .in files, but still keep original files in distribution
files.
Essentially, use coap@LIBCOAP_API_VERSION@ (or equivalent) instead of
coap2. so resultant files have the correct value.
coap_config.h.lwip.in: (new)
coap_config.h.riot.in: (new)
include/coap2/coap.h.windows.in: (new)
As per https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html, many of the
coap2/ prefixes are not required for #include, so these have been removed.
Make sure that the test suite accesses the latest source version of
coap@LIBCOAP_API_VERSION@/coap.h by creating a tests/test_common.h.in that
makes the correct tests/test_common.h which is included in all of the test
suite files.
src/coap_tinydtls.c:
Replace UNUSED with COAP_UNUSED that got missed from a merge.
man/examples-code-check.c:
src/pdu.c:
tests/oss-fuzz/pdu_parse_target.c:
Fix trailing white space.
win32/libcoap.vcxproj:
win32/testdriver/testdriver.vcxproj:
Correct include/coap2 paths.
CoAP transaction id was formerly defined as a hash of the remote address and
message id of the CoAP PDU. It now only refers to, and is used as, the
message id.
Replace occurences of 'transaction id' with 'message id' to reflect naming in
RFC7252.
Correct the definition of coap_tid_t to what it actually represents.
Replace occurrences of coap_tid_t with coap_mid_t.
Replace uses of tid with mid
Remove unused function coap_find_transaction().
Remove the UNUSED and UNUSED_PARAM definitions and use a single definition
of COAP_UNUSED as defined in libcoap.h
Replace all UNUSED / UNUSED_PARAM usages with COAP_UNUSED.
Update coap_opt_filter_t to be a structure rather than a 16bit array that is
aliased with the real structure format.
Update code to use pointers where appropriate.
Refactor coap_pdu_parse_opt() to additionally output the block options in
hex for debugging if there is an error.
Fix the two tests that are now reported with the updated code.
[Other PDU test are reporting information, but only at LOG_DEBUG which is
not output]