When I was fixing MSVC compilation incompatibility due to a dynamic
array on the stack in the coap_crypto_aead_decrypt() function,
I accidentally noticed an incorrect calculation of the array size in
the previous coap_crypto_aead_encrypt() function.
The current code uses a dynamic array on the stack, a relatively rare
compiler extension. For example, MSVC does not support it.
The proposed changes use a classic dynamic array on the heap, which
greatly improves code compatibility. This will also enable libcoap to be
compiled alongside tinyDTLS using the Microsoft compiler on Windows.
Using the Ninja generator with the MSVC compiler leads to errors due to
incorrect compiler call options. In CMake, the generator and the
compiler are different entities.
This fix replaces the incorrect CMake variable with the correct one that
describes the current MSVC-compatible compiler.
If we correctly determine the presence of the sys/time.h and time.h
files using the HAVE_TIME_H and HAVE_SYS_TIME_H macros, then the LWIP
compilation will result in a duplicate function error. Perhaps previous
versions of LWIP did not have these files, in which case everything
would have worked correctly.
These changes add the necessary ifdefs and keep the optimal timer
function for LWIP.
Adds missed #include <time.h> lines to examples and documentation.
Adds the detection of the sys/select.h header to the CMake and autoconf.
These changes add a basic implementation of the coap_resolve_address_info()
function when compiling LWIP with NO_SYS = 1. This implementation is
similar to those in CONTIKI and RIOT.
The function gai_strerror() was removed because it is not very important,
yet it is missing from many implementations.
A CONTIKI compilation bug has also been fixed.
In Windows, calling the connect function for a socket requires a valid
address. This causes the t_session6 test in the coap_new_client_session()
function in test_session.c to fail.
The fix replaces in6addr_any with in6addr_loopback, as in the adjacent
function call. This does not affect the functionality of the test.
As a result, the tests under Windows are completely successful.
Added a rules file for automatic detection of the CUnit library,
as well as support for running tests directly from CMake.
Updated distribution bundle rule.
It adds FindCUnit.cmake to the EXTRA_DIST rule in the Makefile.am file.
The CUnit tests run perfectly on both Windows and Debian.
The CMakeLists.txt file calls Doxygen and redirects its output to
/dev/null to suppress it. However, for Windows, you need to redirect it
to "NUL:" otherwise, a build error will occur.
For the libcoap COAP_ compile time options configured in coap_defines.h or
coap_config.h make sure that #ifdef, #ifndef or defined() are not used and
replaced with #if as appropriate so that if the COAP_ compile time option
is defined as 0, the correct code gets built.
Add #if wrappers to source files that are platform specific or OSCORE.
Host names larger than 255 bytes will cause an internal buffer overflow.
Hostnames provided to coap_resolve_address_info() now have their length validated.
Discovered by SecMate (https://secmate.dev).
Sanity check host lengths when parsing a CoAP URI when using the coap_split_uri()
function.
With a large boolean parameter value, (longer than "false"), memory
would be read past the "true" or "false" string boundaries in the ".rodata"
section when doing a memcmp(), potetially causing the application to crash
when calling coap_new_oscore_conf() with a specially crafted configuration
file.
It also can provide a mechanism to determine the byte values following the
"true" or "false" string boundaries which could lead to accessing sensitive
information. The standard libcoap library does not have defined keys or
certificates. This can only be done by a specially crafted local application.
Discovered by SecMate (https://secmate.dev).
Now fixed.
Some of the Zephyr include files need to be C++, not C based. The 'extern "C"'
wrapper in include/coap3/coap.h means that all #include are treated as being C.
Remove 'extern "C"' wrapper from include/coap3/coap.h and add wrapper to
include files after #include and before any function / structure definitions.
Add in a C++ build test for CI.
- Add wolfSSL detection and configuration in zephyr/CMakeLists.txt
- Set wolfSSL to take priority over mbedTLS when both are available
- Bypass find_package() call and link wolfSSL library directly
- Prevent system wolfSSL library conflicts with ZEPHYR_BASE checks
- Fix compiler warnings in coap_wolfssl.c for unused functions
Let libcoap do the necessary multi-thread locking during resource
generation, lookup and deletion.
Supported using a new handler set up by coap_register_dynamic_resource_handler().
Server to Client is already supported, this provides the reverse with
coap_session_set_type_server().
Add in call-home support to coap-client and coap-server for testing.
Addition of a new event COAP_EVENT_SERVER_SESSION_CONNECTED.
Changes:
- Remove duplicate OBSERVE_PERSIST configuration block
Improve example build:
- Make virtual environment activation optional in Makefile
- Remove --fresh flag unsupported in newer west versions
- Copy mbedTLS config header to workspace include directory
- Add TARGET check for mbedTLS before configuring include directories
- Add mbedTLS linking to coap-3 target
Add POSIX API support:
- Enable CONFIG_POSIX_API=y in examples/zephyr
- Replace direct Linux/Windows system calls with Zephyr POSIX API
equivalents
- Add Zephyr's sys_rand_get() to coap_prng_default()
- Define missing network macros (IN_MULTICAST, IN6_IS_ADDR_MULTICAST,
etc.)
- Add FIONBIO and OPTVAL_T/OPTVAL_GT macro definitions for Zephyr
- Add native Zephyr timing functions to replace missing mbedTLS timing
support
- Fix fd_set mapping using zephyr/net/socket_select.h
- Exclude strnlen redefinition conflicts for Zephyr
- Add proper IPv6 packet info and address mapped definitions
(Patch) Add DNS resolution and net setup to example client:
- Enable CONFIG_DNS_RESOLVER for hostname resolution
- Add Linux networking setup instructions for native_sim board
- Configure static IP gateway and DNS server (8.8.8.8)
- Add DHCP vs static IP configuration documentation
Co-authored-by: mrdeep1
Move the MinGW #if tests to after where mswsock.h is included.
Tidy up documentation.
Tested against MSYS2 UCRT64, CLANG64, MINGW32 and MINGW64 on Windows 11.
Fixed a couple of minor build issues found.