Skip to content

Commit 4f451c7

Browse files
committed
Anjay 3.6.1
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
1 parent 67e0d5a commit 4f451c7

File tree

57 files changed

+563
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+563
-231
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## 3.6.1 (November 21st, 2023)
4+
5+
### Improvements
6+
7+
- Optimized heap memory usage: SenML CBOR payloads for Send and Notify
8+
operations are no longer serialized in memory in their entirety unless their
9+
contents depend on the Access Control object state
10+
- Added a public define for MSISDN string size
11+
- Optimized "Out of memory" logs in favor of a smaller flash memory footprint
12+
13+
### Bugfixes
14+
15+
- (commercial feature only) Fixes for various bugs that could cause invalid
16+
memory accesses when restoring data from corrupted core persistence data
17+
318
## 3.6.0 (October 9th, 2023)
419

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

1126
### Improvements
27+
1228
- Clarified documentation on behavior of Firmware Update and Advanced Firmware
1329
Update modules when ``anjay_fw_update_get_security_config_t`` and
1430
``anjay_advanced_fw_update_perform_upgrade_t`` callbacks, respectively, are

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
cmake_minimum_required(VERSION 3.6.0)
99

1010
project(anjay C)
11-
set(ANJAY_VERSION "3.6.0" CACHE STRING "Anjay library version")
11+
set(ANJAY_VERSION "3.6.1" CACHE STRING "Anjay library version")
1212
set(ANJAY_BINARY_VERSION 1.0.0)
1313

1414
set(ANJAY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")

deps/avs_coap/include_public/avsystem/coap/observe.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ avs_error_t avs_coap_observe_persist(avs_coap_ctx_t *ctx,
125125
*
126126
* @param handler_arg Opaque argument to pass to @p cancel_handler.
127127
*
128+
* @param out_id Pointer to a variable that (if not NULL) will be filled
129+
* with the ID of the restored observation.
130+
*
128131
* @param persistence Persistence context to operate on.
129132
*
130133
* @returns
@@ -134,12 +137,26 @@ avs_error_t avs_coap_observe_persist(avs_coap_ctx_t *ctx,
134137
* - <c>avs_errno(AVS_EINVAL)</c> if the CoAP context is already initialized
135138
* - any I/O error forwarded from the underlying stream
136139
*/
137-
avs_error_t
140+
avs_error_t avs_coap_observe_restore_with_id(
141+
avs_coap_ctx_t *ctx,
142+
avs_coap_observe_cancel_handler_t *cancel_handler,
143+
void *handler_arg,
144+
avs_coap_observe_id_t *out_id,
145+
avs_persistence_context_t *persistence);
146+
147+
/**
148+
* Restores single Observe entry from the specified @p persistence context. This
149+
* is a version of @ref avs_coap_observe_restore_with_id without the
150+
* <c>out_id</c> argument declared to maitain backwards compatibility.
151+
*/
152+
static inline avs_error_t
138153
avs_coap_observe_restore(avs_coap_ctx_t *ctx,
139154
avs_coap_observe_cancel_handler_t *cancel_handler,
140155
void *handler_arg,
141-
avs_persistence_context_t *persistence);
142-
156+
avs_persistence_context_t *persistence) {
157+
return avs_coap_observe_restore_with_id(
158+
ctx, cancel_handler, handler_arg, NULL, persistence);
159+
}
143160
#endif // WITH_AVS_COAP_OBSERVE_PERSISTENCE
144161

145162
#ifdef WITH_AVS_COAP_OBSERVE

deps/avs_coap/src/avs_coap_observe.c

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,12 @@ avs_error_t avs_coap_observe_persist(avs_coap_ctx_t *ctx,
213213
return err;
214214
}
215215

216-
avs_error_t
217-
avs_coap_observe_restore(avs_coap_ctx_t *ctx,
218-
avs_coap_observe_cancel_handler_t *cancel_handler,
219-
void *handler_arg,
220-
avs_persistence_context_t *persistence) {
216+
avs_error_t avs_coap_observe_restore_with_id(
217+
avs_coap_ctx_t *ctx,
218+
avs_coap_observe_cancel_handler_t *cancel_handler,
219+
void *handler_arg,
220+
avs_coap_observe_id_t *out_id,
221+
avs_persistence_context_t *persistence) {
221222
if (avs_persistence_direction(persistence) != AVS_PERSISTENCE_RESTORE) {
222223
return avs_errno(AVS_EINVAL);
223224
}
@@ -272,37 +273,12 @@ avs_coap_observe_restore(avs_coap_ctx_t *ctx,
272273
LOG(DEBUG, _("Observe (restored) start: ") "%s",
273274
AVS_COAP_TOKEN_HEX(&id.token));
274275
AVS_LIST_INSERT(&coap_base->observes, observe);
275-
276+
if (out_id) {
277+
*out_id = id;
278+
}
276279
return AVS_OK;
277280
}
278281

279-
# else // WITH_AVS_COAP_OBSERVE_PERSISTENCE
280-
281-
avs_error_t avs_coap_observe_persist(avs_coap_ctx_t *ctx,
282-
avs_coap_observe_id_t id,
283-
avs_persistence_context_t *persistence) {
284-
(void) ctx;
285-
(void) id;
286-
(void) persistence;
287-
288-
LOG(WARNING, _("observe persistence not compiled in"));
289-
return _avs_coap_err(AVS_COAP_ERR_FEATURE_DISABLED);
290-
}
291-
292-
avs_error_t
293-
avs_coap_observe_restore(avs_coap_ctx_t *ctx,
294-
avs_coap_observe_cancel_handler_t *cancel_handler,
295-
void *handler_arg,
296-
avs_persistence_context_t *persistence) {
297-
(void) ctx;
298-
(void) cancel_handler;
299-
(void) handler_arg;
300-
(void) persistence;
301-
302-
LOG(WARNING, _("observe persistence not compiled in"));
303-
return _avs_coap_err(AVS_COAP_ERR_FEATURE_DISABLED);
304-
}
305-
306282
# endif // WITH_AVS_COAP_OBSERVE_PERSISTENCE
307283

308284
#endif // WITH_AVS_COAP_OBSERVE

deps/avs_coap/tests/udp/streaming_observe.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,12 @@ AVS_UNIT_TEST(observe_persistence, simple) {
945945

946946
avs_persistence_context_t persistence =
947947
avs_persistence_restore_context_create(stream);
948-
ASSERT_OK(avs_coap_observe_restore(env.coap_ctx, on_observe_cancel,
949-
&env, &persistence));
948+
avs_coap_observe_id_t restored_id;
949+
ASSERT_OK(avs_coap_observe_restore_with_id(env.coap_ctx,
950+
on_observe_cancel, &env,
951+
&restored_id, &persistence));
952+
ASSERT_TRUE(
953+
avs_coap_token_equal(&observe_id.token, &restored_id.token));
950954

951955
avs_net_socket_t *socket = NULL;
952956
avs_unit_mocksock_create_datagram(&socket);

doc/sphinx/source/FirmwareUpdateTutorial/FU-SecureDownloads.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ After populating the ``avs_net_psk_info_t`` structure, we may use:
127127
avs_net_security_info_t
128128
avs_net_security_info_from_psk(avs_net_psk_info_t psk);
129129

130-
to convert into into ``avs_net_security_info_t``, as in the following example:
130+
to convert into ``avs_net_security_info_t``, as in the following example:
131131

132132
.. code-block:: c
133133
@@ -310,7 +310,7 @@ by the user:
310310
} anjay_fw_update_handlers_t;
311311
312312
Now, the ``anjay_fw_update_get_security_config_t`` job is to fill
313-
``anjay_security_config_t`` properly. This structure consists of three fields:
313+
``anjay_security_config_t`` properly. This structure consists of four fields:
314314

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

353354
Implementation
354355
^^^^^^^^^^^^^^

example_configs/embedded_lwm2m10/avsystem/commons/avs_commons_config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,16 @@
429429
*/
430430
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */
431431

432+
/**
433+
* Enables use of the <c>psa_generate_random()</c> function as the default
434+
* random number generator when using the Mbed TLS crypto backend, instead of
435+
* CTR-DRBG seeded by the Mbed TLS entropy pool.
436+
*
437+
* It's meaningful only when @ref AVS_COMMONS_WITH_MBEDTLS is enabled. However,
438+
* it is independent from the above PSA engine settings.
439+
*/
440+
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_RNG */
441+
432442
/**
433443
* Is the <c>dlsym()</c> function available?
434444
*

example_configs/embedded_lwm2m11/avsystem/commons/avs_commons_config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,16 @@
429429
*/
430430
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */
431431

432+
/**
433+
* Enables use of the <c>psa_generate_random()</c> function as the default
434+
* random number generator when using the Mbed TLS crypto backend, instead of
435+
* CTR-DRBG seeded by the Mbed TLS entropy pool.
436+
*
437+
* It's meaningful only when @ref AVS_COMMONS_WITH_MBEDTLS is enabled. However,
438+
* it is independent from the above PSA engine settings.
439+
*/
440+
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_RNG */
441+
432442
/**
433443
* Is the <c>dlsym()</c> function available?
434444
*

example_configs/linux_lwm2m10/avsystem/commons/avs_commons_config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,16 @@
429429
*/
430430
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */
431431

432+
/**
433+
* Enables use of the <c>psa_generate_random()</c> function as the default
434+
* random number generator when using the Mbed TLS crypto backend, instead of
435+
* CTR-DRBG seeded by the Mbed TLS entropy pool.
436+
*
437+
* It's meaningful only when @ref AVS_COMMONS_WITH_MBEDTLS is enabled. However,
438+
* it is independent from the above PSA engine settings.
439+
*/
440+
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_RNG */
441+
432442
/**
433443
* Is the <c>dlsym()</c> function available?
434444
*

0 commit comments

Comments
 (0)