Skip to content

Commit

Permalink
Anjay 3.6.1
Browse files Browse the repository at this point in the history
Improvements:
- Optimized heap memory usage: SenML CBOR payloads for Send and Notify
  operations are no longer serialized in memory in their entirety unless their
  contents depend on the Access Control object state
- Added a public define for MSISDN string size
- Optimized "Out of memory" logs in favor of a smaller flash memory footprint

 Bugfixes:
- (commercial feature only) Fixes for various bugs that could cause invalid
  memory accesses when restoring data from corrupted core persistence data
  • Loading branch information
Kucmasz committed Nov 21, 2023
1 parent 67e0d5a commit 4f451c7
Show file tree
Hide file tree
Showing 57 changed files with 563 additions and 231 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 3.6.1 (November 21st, 2023)

### Improvements

- Optimized heap memory usage: SenML CBOR payloads for Send and Notify
operations are no longer serialized in memory in their entirety unless their
contents depend on the Access Control object state
- Added a public define for MSISDN string size
- Optimized "Out of memory" logs in favor of a smaller flash memory footprint

### Bugfixes

- (commercial feature only) Fixes for various bugs that could cause invalid
memory accesses when restoring data from corrupted core persistence data

## 3.6.0 (October 9th, 2023)

### Features
Expand All @@ -9,6 +24,7 @@
- Added `requirements.txt` file to manage Python dependencies more efficiently

### Improvements

- Clarified documentation on behavior of Firmware Update and Advanced Firmware
Update modules when ``anjay_fw_update_get_security_config_t`` and
``anjay_advanced_fw_update_perform_upgrade_t`` callbacks, respectively, are
Expand Down
2 changes: 1 addition & 1 deletion 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.6.0" CACHE STRING "Anjay library version")
set(ANJAY_VERSION "3.6.1" CACHE STRING "Anjay library version")
set(ANJAY_BINARY_VERSION 1.0.0)

set(ANJAY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
Expand Down
23 changes: 20 additions & 3 deletions deps/avs_coap/include_public/avsystem/coap/observe.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ avs_error_t avs_coap_observe_persist(avs_coap_ctx_t *ctx,
*
* @param handler_arg Opaque argument to pass to @p cancel_handler.
*
* @param out_id Pointer to a variable that (if not NULL) will be filled
* with the ID of the restored observation.
*
* @param persistence Persistence context to operate on.
*
* @returns
Expand All @@ -134,12 +137,26 @@ avs_error_t avs_coap_observe_persist(avs_coap_ctx_t *ctx,
* - <c>avs_errno(AVS_EINVAL)</c> if the CoAP context is already initialized
* - any I/O error forwarded from the underlying stream
*/
avs_error_t
avs_error_t avs_coap_observe_restore_with_id(
avs_coap_ctx_t *ctx,
avs_coap_observe_cancel_handler_t *cancel_handler,
void *handler_arg,
avs_coap_observe_id_t *out_id,
avs_persistence_context_t *persistence);

/**
* Restores single Observe entry from the specified @p persistence context. This
* is a version of @ref avs_coap_observe_restore_with_id without the
* <c>out_id</c> argument declared to maitain backwards compatibility.
*/
static inline avs_error_t
avs_coap_observe_restore(avs_coap_ctx_t *ctx,
avs_coap_observe_cancel_handler_t *cancel_handler,
void *handler_arg,
avs_persistence_context_t *persistence);

avs_persistence_context_t *persistence) {
return avs_coap_observe_restore_with_id(
ctx, cancel_handler, handler_arg, NULL, persistence);
}
#endif // WITH_AVS_COAP_OBSERVE_PERSISTENCE

#ifdef WITH_AVS_COAP_OBSERVE
Expand Down
42 changes: 9 additions & 33 deletions deps/avs_coap/src/avs_coap_observe.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,12 @@ avs_error_t avs_coap_observe_persist(avs_coap_ctx_t *ctx,
return err;
}

avs_error_t
avs_coap_observe_restore(avs_coap_ctx_t *ctx,
avs_coap_observe_cancel_handler_t *cancel_handler,
void *handler_arg,
avs_persistence_context_t *persistence) {
avs_error_t avs_coap_observe_restore_with_id(
avs_coap_ctx_t *ctx,
avs_coap_observe_cancel_handler_t *cancel_handler,
void *handler_arg,
avs_coap_observe_id_t *out_id,
avs_persistence_context_t *persistence) {
if (avs_persistence_direction(persistence) != AVS_PERSISTENCE_RESTORE) {
return avs_errno(AVS_EINVAL);
}
Expand Down Expand Up @@ -272,37 +273,12 @@ avs_coap_observe_restore(avs_coap_ctx_t *ctx,
LOG(DEBUG, _("Observe (restored) start: ") "%s",
AVS_COAP_TOKEN_HEX(&id.token));
AVS_LIST_INSERT(&coap_base->observes, observe);

if (out_id) {
*out_id = id;
}
return AVS_OK;
}

# else // WITH_AVS_COAP_OBSERVE_PERSISTENCE

avs_error_t avs_coap_observe_persist(avs_coap_ctx_t *ctx,
avs_coap_observe_id_t id,
avs_persistence_context_t *persistence) {
(void) ctx;
(void) id;
(void) persistence;

LOG(WARNING, _("observe persistence not compiled in"));
return _avs_coap_err(AVS_COAP_ERR_FEATURE_DISABLED);
}

avs_error_t
avs_coap_observe_restore(avs_coap_ctx_t *ctx,
avs_coap_observe_cancel_handler_t *cancel_handler,
void *handler_arg,
avs_persistence_context_t *persistence) {
(void) ctx;
(void) cancel_handler;
(void) handler_arg;
(void) persistence;

LOG(WARNING, _("observe persistence not compiled in"));
return _avs_coap_err(AVS_COAP_ERR_FEATURE_DISABLED);
}

# endif // WITH_AVS_COAP_OBSERVE_PERSISTENCE

#endif // WITH_AVS_COAP_OBSERVE
8 changes: 6 additions & 2 deletions deps/avs_coap/tests/udp/streaming_observe.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,12 @@ AVS_UNIT_TEST(observe_persistence, simple) {

avs_persistence_context_t persistence =
avs_persistence_restore_context_create(stream);
ASSERT_OK(avs_coap_observe_restore(env.coap_ctx, on_observe_cancel,
&env, &persistence));
avs_coap_observe_id_t restored_id;
ASSERT_OK(avs_coap_observe_restore_with_id(env.coap_ctx,
on_observe_cancel, &env,
&restored_id, &persistence));
ASSERT_TRUE(
avs_coap_token_equal(&observe_id.token, &restored_id.token));

avs_net_socket_t *socket = NULL;
avs_unit_mocksock_create_datagram(&socket);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ After populating the ``avs_net_psk_info_t`` structure, we may use:
avs_net_security_info_t
avs_net_security_info_from_psk(avs_net_psk_info_t psk);

to convert into into ``avs_net_security_info_t``, as in the following example:
to convert into ``avs_net_security_info_t``, as in the following example:

.. code-block:: c
Expand Down Expand Up @@ -310,7 +310,7 @@ by the user:
} anjay_fw_update_handlers_t;
Now, the ``anjay_fw_update_get_security_config_t`` job is to fill
``anjay_security_config_t`` properly. This structure consists of three fields:
``anjay_security_config_t`` properly. This structure consists of four fields:

.. highlight:: c
.. snippet-source:: include_public/anjay/core.h
Expand Down Expand Up @@ -348,7 +348,8 @@ Now, the ``anjay_fw_update_get_security_config_t`` job is to fill
We've already seen in previous sections how to configure
``security_info``. Also, for now there is no need to worry about
``dane_tlsa_record`` or ``tls_ciphersuites`` - they can be reset to zero.
``dane_tlsa_record``, ``tls_ciphersuites`` and ``server_name_indication`` - they can be
reset to zero.

Implementation
^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@
*/
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */

/**
* Enables use of the <c>psa_generate_random()</c> function as the default
* random number generator when using the Mbed TLS crypto backend, instead of
* CTR-DRBG seeded by the Mbed TLS entropy pool.
*
* It's meaningful only when @ref AVS_COMMONS_WITH_MBEDTLS is enabled. However,
* it is independent from the above PSA engine settings.
*/
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_RNG */

/**
* Is the <c>dlsym()</c> function available?
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@
*/
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */

/**
* Enables use of the <c>psa_generate_random()</c> function as the default
* random number generator when using the Mbed TLS crypto backend, instead of
* CTR-DRBG seeded by the Mbed TLS entropy pool.
*
* It's meaningful only when @ref AVS_COMMONS_WITH_MBEDTLS is enabled. However,
* it is independent from the above PSA engine settings.
*/
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_RNG */

/**
* Is the <c>dlsym()</c> function available?
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@
*/
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */

/**
* Enables use of the <c>psa_generate_random()</c> function as the default
* random number generator when using the Mbed TLS crypto backend, instead of
* CTR-DRBG seeded by the Mbed TLS entropy pool.
*
* It's meaningful only when @ref AVS_COMMONS_WITH_MBEDTLS is enabled. However,
* it is independent from the above PSA engine settings.
*/
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_RNG */

/**
* Is the <c>dlsym()</c> function available?
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@
*/
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */

/**
* Enables use of the <c>psa_generate_random()</c> function as the default
* random number generator when using the Mbed TLS crypto backend, instead of
* CTR-DRBG seeded by the Mbed TLS entropy pool.
*
* It's meaningful only when @ref AVS_COMMONS_WITH_MBEDTLS is enabled. However,
* it is independent from the above PSA engine settings.
*/
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_RNG */

/**
* Is the <c>dlsym()</c> function available?
*
Expand Down
5 changes: 5 additions & 0 deletions src/anjay_config_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,11 @@ static inline void _anjay_log_feature_list(void) {
#else // AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE
_anjay_log(anjay, TRACE, "AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE = OFF");
#endif // AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE
#ifdef AVS_COMMONS_WITH_MBEDTLS_PSA_RNG
_anjay_log(anjay, TRACE, "AVS_COMMONS_WITH_MBEDTLS_PSA_RNG = ON");
#else // AVS_COMMONS_WITH_MBEDTLS_PSA_RNG
_anjay_log(anjay, TRACE, "AVS_COMMONS_WITH_MBEDTLS_PSA_RNG = OFF");
#endif // AVS_COMMONS_WITH_MBEDTLS_PSA_RNG
#ifdef AVS_COMMONS_WITH_MICRO_LOGS
_anjay_log(anjay, TRACE, "AVS_COMMONS_WITH_MICRO_LOGS = ON");
#else // AVS_COMMONS_WITH_MICRO_LOGS
Expand Down
2 changes: 2 additions & 0 deletions src/anjay_modules/anjay_utils_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ bool _anjay_ongoing_registration_exists_unlocked(anjay_unlocked_t *anjay);

avs_sched_t *_anjay_get_scheduler_unlocked(anjay_unlocked_t *anjay);

void _anjay_log_oom(void);

VISIBILITY_PRIVATE_HEADER_END

#endif /* ANJAY_INCLUDE_ANJAY_MODULES_UTILS_CORE_H */
Loading

0 comments on commit 4f451c7

Please sign in to comment.