Skip to content

Commit

Permalink
Anjay 3.8.1
Browse files Browse the repository at this point in the history
Improvements
- Improved the coverage script and switched to lcov.
- In case when the LwM2M server answers with an RST message to a notification
  that is yielding an error value (e.g. failure to read), which effectively
  cancels the notification, Anjay is not infinitely trying to transmit that
  message with error value once again. New behavior is enabled by default, and
  controlled with `WITH_AVS_COAP_OBSERVE_FORCE_CANCEL_ON_UNACKED_ERROR` option
  of `avs_coap`. Existing projects have to opt-in explicitly.
- Added `--nobest` flag to `dnf update` in Rockylinux image preparation for
  tests to solve installation candidates conflicts.

 Bugfixes
- Actually fixed compatibility with Mbed TLS 3.6.
- Fixed compatibility of integration test framework with Mbed TLS versions that
  enabled TLS 1.3, but didn't use `MBEDTLS_USE_PSA_CRYPTO`.
- The -Wformat warning appearing in some compilers has been fixed.
- Fixed LwM2M CBOR parser incorrectly accepting inputs containing empty arrays
  as keys
- Prevent from generating non unique session tokens when the monotonic system
  clock granulation is not fine enough.
- Refactored how timeouts are handled in pymbedtls to be in line with use of
  mbedTLS in avs_commons.
  • Loading branch information
Kucmasz committed Nov 13, 2024
1 parent 3ba32ac commit 80189c4
Show file tree
Hide file tree
Showing 106 changed files with 2,682 additions and 1,003 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/anjay-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
- uses: actions/checkout@v1
with:
submodules: recursive
- run: dnf update -y
- run: dnf update -y --nobest
- run: dnf install -y $CC
# Solve issues with EPERM when running dumpcap
- run: setcap '' $(which dumpcap)
Expand Down Expand Up @@ -149,9 +149,13 @@ jobs:
with:
submodules: recursive
- run: brew update
# NOTE: latest known compatible versions are openssl@3--3.1.1 and mbedtls--3.4.0
# NOTE: try the brew install command twice to work around "brew link" errors
- run: INSTALL_CMD="brew install openssl mbedtls $COMPILER_VERSION"; $INSTALL_CMD || $INSTALL_CMD
- run: INSTALL_CMD="brew install openssl $COMPILER_VERSION"; $INSTALL_CMD || $INSTALL_CMD
# NOTE: Some tests don't pass on mbedTLS 3.6.2 now, so we need to install an older version
# Homebrew only specifiers major version of mbedTLS, so let's pin the version to 3.6.0 manually
- run: curl -f https://raw.githubusercontent.com/Homebrew/homebrew-core/219dabf6cab172fb8b62b4d8598e016e190c3c20/Formula/m/mbedtls.rb > /tmp/mbedtls.rb
- run: brew install --formula /tmp/mbedtls.rb
- run: brew pin mbedtls
# NOTE: The above command may have installed a new version of Python, that's why we launch it weirdly
- run: /usr/bin/env python3 -m pip install -r requirements.txt
- run: env JAVA_HOME="$JAVA_HOME_17_X64" ./devconfig --with-asan --without-analysis --no-examples -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DWITH_IPV6=OFF
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ nbproject

# build configuration autogenerated files
/build
/coverage
/output
*.swp
CMakeFiles/
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 3.8.1 (November 13th, 2024)

### Improvements

- Improved the coverage script and switched to lcov.
- In case when the LwM2M server answers with an RST message to a notification
that is yielding an error value (e.g. failure to read), which effectively
cancels the notification, Anjay is not infinitely trying to transmit that
message with error value once again. New behavior is enabled by default, and
controlled with `WITH_AVS_COAP_OBSERVE_FORCE_CANCEL_ON_UNACKED_ERROR` option
of `avs_coap`. Existing projects have to opt-in explicitly.
- Added `--nobest` flag to `dnf update` in Rockylinux image preparation for
tests to solve installation candidates conflicts.

### Bugfixes

- Actually fixed compatibility with Mbed TLS 3.6.
- Fixed compatibility of integration test framework with Mbed TLS versions that
enabled TLS 1.3, but didn't use `MBEDTLS_USE_PSA_CRYPTO`.
- The -Wformat warning appearing in some compilers has been fixed.
- Fixed LwM2M CBOR parser incorrectly accepting inputs containing empty arrays
as keys
- Prevent from generating non unique session tokens when the monotonic system
clock granulation is not fine enough.
- Refactored how timeouts are handled in pymbedtls to be in line with use of
mbedTLS in avs_commons.

## 3.8.0 (May 28th, 2024)

### BREAKING CHANGES
Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
cmake_minimum_required(VERSION 3.6.0)

project(anjay C)
set(ANJAY_VERSION "3.8.0" CACHE STRING "Anjay library version")
set(ANJAY_VERSION "3.8.1" CACHE STRING "Anjay library version")
set(ANJAY_BINARY_VERSION 1.0.0)

set(ANJAY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
Expand Down Expand Up @@ -433,6 +433,8 @@ add_library(anjay
src/core/io/anjay_cbor_out.c
src/core/io/anjay_common.c
src/core/io/anjay_common.h
src/core/io/anjay_corelnk.c
src/core/io/anjay_corelnk.h
src/core/io/anjay_dynamic.c
src/core/io/anjay_input_buf.c
src/core/io/anjay_json_encoder.c
Expand Down Expand Up @@ -617,7 +619,7 @@ if(WITH_TEST)
add_custom_target(check)
add_custom_target(anjay_unit_check)
add_dependencies(check anjay_unit_check)

# anjay_test
add_executable(anjay_test EXCLUDE_FROM_ALL
$<TARGET_PROPERTY:anjay,SOURCES>
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pip3 install -U -r requirements.txt

### Running the demo client

For initial development and testing of LwM2M clients, we recommend using the [Coiote IoT Device Management](https://www.avsystem.com/products/coiote-iot-device-management-platform/) where you can use the basic LwM2M server functionality for free.
For initial development and testing of LwM2M clients, we recommend using the [Coiote IoT Device Management](https://avsystem.com/coiote-iot-device-management-platform/) where you can use the basic LwM2M server functionality for free.

After setting up an account and adding the device entry, you can compile Anjay demo client and connect it to the platform by running:

Expand Down Expand Up @@ -322,11 +322,11 @@ See [LICENSE](LICENSE) file.

### Commercial support

Anjay LwM2M library comes with the option of [full commercial support, provided by AVSystem](https://www.avsystem.com/products/anjay/).
Anjay LwM2M library comes with the option of [full commercial support, provided by AVSystem](https://avsystem.com/anjay-iot-sdk/).

The list of features available commercially is [available here](https://AVSystem.github.io/Anjay-doc/CommercialFeatures.html).

If you're interested in LwM2M Server, be sure to check out the [Coiote IoT Device Management](https://www.avsystem.com/products/coiote-iot-dm/) platform by AVSystem. It also includes the [interoperability test module](https://www.avsystem.com/lwm2m-interoperability-test/) that you can use to test your LwM2M client implementation. Our automated tests and testing scenarios enable you to quickly check how interoperable your device is with LwM2M.
If you're interested in LwM2M Server, be sure to check out the [Coiote IoT Device Management](https://www.avsystem.com/products/coiote-iot-dm/) platform by AVSystem. It also includes the [interoperability test module](https://avsystem.com/coiote-iot-device-management-platform/lwm2m-interoperability-test/) that you can use to test your LwM2M client implementation. Our automated tests and testing scenarios enable you to quickly check how interoperable your device is with LwM2M.

## Contributing

Expand Down
10 changes: 0 additions & 10 deletions covconfig

This file was deleted.

2 changes: 2 additions & 0 deletions demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if (${ANJAY_WITH_MODULE_FW_UPDATE})
set(SOURCES ${SOURCES} firmware_update.c)
endif()


if (${ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE})
set(SOURCES ${SOURCES}
advanced_firmware_update.c
Expand All @@ -52,6 +53,7 @@ if (${ANJAY_WITH_MODULE_SW_MGMT})
set(SOURCES ${SOURCES} software_mgmt.c)
endif()


if(NOT WIN32)
set(SOURCES ${SOURCES} objects/ip_ping.c)
endif()
Expand Down
1 change: 1 addition & 0 deletions deps/avs_coap/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ _CPack_Packages/
Testing/
/cmake/avs_coap-config.cmake
/build*
/coverage/
/examples/build
/include_public/avsystem/coap/avs_coap_config.h
/tools/__pycache__
Expand Down
1 change: 1 addition & 0 deletions deps/avs_coap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ option(WITH_AVS_COAP_TCP "Enable CoAP over TCP support" ON)
option(WITH_AVS_COAP_STREAMING_API "Enable streaming API" ON)
option(WITH_AVS_COAP_OBSERVE "Enable support for observations" ON)
option(WITH_AVS_COAP_OBSERVE_CANCEL_ON_TIMEOUT "Turn on cancelling observation on a timeout " OFF)
option(WITH_AVS_COAP_OBSERVE_FORCE_CANCEL_ON_UNACKED_ERROR "Force cancelling observation on unacked error" ON)
cmake_dependent_option(WITH_AVS_COAP_OBSERVE_PERSISTENCE "Enable observations persistence" ON "WITH_AVS_COAP_OBSERVE" OFF)
option(WITH_AVS_COAP_BLOCK "Enable support for BLOCK/BERT transfers" ON)

Expand Down
12 changes: 12 additions & 0 deletions deps/avs_coap/include_public/avsystem/coap/avs_coap_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@
*/
#cmakedefine WITH_AVS_COAP_OBSERVE_CANCEL_ON_TIMEOUT

/**
* Force cancelling observation, even if a confirmable notification yielding
* an error response is not acknowledged or rejected with RST by the observer.
*
* This is a circumvention for some non-compliant servers that respond with an
* RST message to a confirmable notification yielding an error response. This
* setting makes the library cancel the observation in such cases, even though
* the notification is formally rejected. Additionally, it will also make the
* library cancel the observation if no response is received at all.
*/
#cmakedefine WITH_AVS_COAP_OBSERVE_FORCE_CANCEL_ON_UNACKED_ERROR

/**
* Enable support for observation persistence (<c>avs_coap_observe_persist()</c>
* and <c>avs_coap_observe_restore()</c> calls).
Expand Down
30 changes: 27 additions & 3 deletions deps/avs_coap/src/async/avs_coap_async_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,19 @@ send_result_handler(avs_coap_ctx_t *ctx,

server->delivery_handler(ctx, fail_err, server->delivery_handler_arg);

if (avs_is_ok(fail_err)) {
bool is_timeout = fail_err.category == AVS_COAP_ERR_CATEGORY
&& fail_err.code == AVS_COAP_ERR_TIMEOUT;
bool is_rst = fail_err.category == AVS_COAP_ERR_CATEGORY
&& fail_err.code == AVS_COAP_ERR_UDP_RESET_RECEIVED;
(void) is_timeout;
(void) is_rst;

bool do_cancel_on_error = avs_is_ok(fail_err);
#ifdef WITH_AVS_COAP_OBSERVE_FORCE_CANCEL_ON_UNACKED_ERROR
do_cancel_on_error = do_cancel_on_error || is_timeout || is_rst;
#endif // WITH_AVS_COAP_OBSERVE_FORCE_CANCEL_ON_UNACKED_ERROR

if (do_cancel_on_error) {
cancel_notification_on_error(ctx,
(avs_coap_observe_id_t) {
.token = token
Expand All @@ -316,8 +328,7 @@ send_result_handler(avs_coap_ctx_t *ctx,
}
#if defined(WITH_AVS_COAP_OBSERVE) \
&& defined(WITH_AVS_COAP_OBSERVE_CANCEL_ON_TIMEOUT)
else if (fail_err.category == AVS_COAP_ERR_CATEGORY
&& fail_err.code == AVS_COAP_ERR_TIMEOUT) {
else if (is_timeout) {
avs_coap_observe_cancel(ctx, (avs_coap_observe_id_t) {
.token = token
});
Expand Down Expand Up @@ -1334,6 +1345,19 @@ avs_coap_notify_async(avs_coap_ctx_t *ctx,
avs_errno(AVS_EINVAL);
}

// FIXME: Unsolicited non-confirmable notifications with an error code are
// currently broken, because of lack of the Observe option for error values,
// the lower, UDP layer assumes the message to be an ACK, not a NON.
//
// For reference, see assumptions in choose_msg_type() in avs_coap_udp_ctx.c
if (reliability_hint == AVS_COAP_NOTIFY_PREFER_NON_CONFIRMABLE
&& !avs_coap_code_is_success(response_header->code)) {
LOG(ERROR,
_("Unsolicited notifications with an error code are currently "
"broken"));
return avs_errno(AVS_EINVAL);
}

avs_coap_observe_notify_t notify;

avs_error_t err = _avs_coap_observe_setup_notify(ctx, &observe_id, &notify);
Expand Down
5 changes: 4 additions & 1 deletion deps/avs_coap/src/tcp/avs_coap_tcp_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* See the attached LICENSE file for details.
*/

#include <inttypes.h>

#include <avs_coap_init.h>

#ifdef WITH_AVS_COAP_TCP
Expand Down Expand Up @@ -59,7 +61,8 @@ static void log_tcp_msg_summary(const char *info,
# ifdef WITH_AVS_COAP_OBSERVE
uint32_t observe;
if (avs_coap_options_get_observe(&msg->options, &observe) == 0) {
snprintf(observe_str, sizeof(observe_str), ", Observe %u", observe);
snprintf(observe_str, sizeof(observe_str), ", Observe %" PRIu32,
observe);
}
# endif // WITH_AVS_COAP_OBSERVE

Expand Down
Loading

0 comments on commit 80189c4

Please sign in to comment.