Skip to content
Permalink
Browse files

Anjay 2.2.4

Bugfixes:
- Fixed bugs that caused problems with compilation on macOS and Travis
- avs_commons 4.0.2 include a fix to TLS backend data loader unit tests

Features:
- Added support for "micro logs", removing most of log strings to save space,
  while retaining all the information useful for debugging
- avs_commons 4.0.2 include support for proper RFC 6125-compliant validation of
  certificates against hostnames in the OpenSSL backend
  • Loading branch information
Mateusz Kwiatkowski
Mateusz Kwiatkowski committed Jan 30, 2020
1 parent 275e89d commit 92a5e4216e7fe2b9f1e15eb86598e2bbd92d8f21
Showing with 1,204 additions and 966 deletions.
  1. +0 −3 .travis.yml
  2. +3 −3 CMakeLists.txt
  3. +2 −0 config/anjay_config.h.in
  4. +1 −1 deps/avs_coap/CMakeLists.txt
  5. +24 −22 deps/avs_coap/src/async/async_client.c
  6. +36 −28 deps/avs_coap/src/async/async_server.c
  7. +14 −9 deps/avs_coap/src/async/exchange.c
  8. +2 −0 deps/avs_coap/src/avs_coap_config.h.in
  9. +7 −4 deps/avs_coap/src/common_utils.c
  10. +7 −4 deps/avs_coap/src/ctx.c
  11. +1 −1 deps/avs_coap/src/ctx.h
  12. +18 −15 deps/avs_coap/src/observe.c
  13. +3 −2 deps/avs_coap/src/options/option.c
  14. +38 −32 deps/avs_coap/src/options/options.c
  15. +17 −13 deps/avs_coap/src/streaming/streaming_client.c
  16. +21 −18 deps/avs_coap/src/streaming/streaming_server.c
  17. +8 −8 deps/avs_coap/src/udp/test/async_server.c
  18. +51 −40 deps/avs_coap/src/udp/udp_ctx.c
  19. +12 −8 deps/avs_coap/src/udp/udp_msg.c
  20. +13 −11 deps/avs_coap/src/udp/udp_msg_cache.c
  21. +1 −1 deps/avs_commons
  22. +6 −3 devconfig
  23. +11 −9 modules/access_control/src/access_control_handlers.c
  24. +9 −9 modules/access_control/src/access_control_persistence.c
  25. +22 −17 modules/access_control/src/mod_access_control.c
  26. +4 −4 modules/attr_storage/src/attr_storage_persistence.c
  27. +34 −28 modules/attr_storage/src/mod_attr_storage.c
  28. +10 −10 modules/fw_update/src/fw_dm_security.c
  29. +39 −34 modules/fw_update/src/fw_update.c
  30. +13 −9 modules/security/src/mod_security.c
  31. +6 −6 modules/security/src/security_persistence.c
  32. +15 −12 modules/security/src/security_utils.c
  33. +7 −7 modules/server/src/mod_server.c
  34. +10 −8 modules/server/src/server_persistence.c
  35. +9 −8 src/access_utils.c
  36. +38 −33 src/anjay_core.c
  37. +59 −45 src/bootstrap_core.c
  38. +4 −3 src/dm/dm_attributes.c
  39. +13 −11 src/dm/dm_create.c
  40. +2 −2 src/dm/dm_execute.c
  41. +41 −34 src/dm/dm_handlers.c
  42. +18 −13 src/dm/dm_read.c
  43. +7 −7 src/dm/dm_write.c
  44. +9 −8 src/dm/dm_write_attrs.c
  45. +3 −3 src/dm/modules.c
  46. +1 −1 src/dm/query.c
  47. +79 −61 src/dm_core.c
  48. +36 −32 src/downloader/coap.c
  49. +15 −11 src/downloader/downloader.c
  50. +17 −15 src/downloader/http.c
  51. +13 −11 src/io/batch_builder.c
  52. +2 −2 src/io/dynamic.c
  53. +2 −2 src/io/json_encoder.c
  54. +6 −6 src/io/senml_like_out.c
  55. +4 −3 src/io/tlv_in.c
  56. +9 −6 src/io_core.c
  57. +6 −6 src/notify.c
  58. +45 −42 src/observe/observe_core.c
  59. +7 −2 src/observe/test/observe.c
  60. +30 −21 src/servers/activate.c
  61. +11 −10 src/servers/connection_ip.c
  62. +10 −6 src/servers/connections.c
  63. +1 −1 src/servers/offline.c
  64. +59 −47 src/servers/register.c
  65. +16 −16 src/servers/reload.c
  66. +15 −11 src/servers/security_generic.c
  67. +20 −14 src/servers/server_connections.c
  68. +12 −8 src/servers/servers_internal.c
  69. +4 −4 src/servers_utils.c
  70. +14 −10 src/stats.c
  71. +5 −5 src/utils_core.c
  72. +37 −30 test/include/anjay_test/dm.h
  73. +1 −0 test/integration/framework/nsh-lwm2m/pymbedtls/src/context.hpp
  74. +23 −12 test/integration/framework/nsh-lwm2m/pymbedtls/src/socket.cpp
  75. +8 −1 test/integration/suites/default/connection_id.py
  76. +15 −10 test/integration/suites/default/register.py
  77. +10 −10 tools/generate-certs.sh
  78. +1 −1 travis/centos-7/Dockerfile
  79. +1 −1 travis/coverity/Dockerfile
  80. +0 −1 travis/run.sh
  81. +1 −1 travis/ubuntu-16.04/Dockerfile
@@ -38,23 +38,20 @@ matrix:
os: linux
env: ANJAY_CC=gcc-4.7
ANJAY_CXX=g++
PYMBEDTLS_CC=gcc
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=gcc-4.8
ANJAY_CXX=g++
PYMBEDTLS_CC=gcc
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=gcc-4.9
ANJAY_CXX=g++
PYMBEDTLS_CC=gcc
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

@@ -15,7 +15,7 @@
cmake_minimum_required(VERSION 3.4.0)

project(anjay C)
set(ANJAY_VERSION "2.2.3" CACHE STRING "Anjay library version")
set(ANJAY_VERSION "2.2.4" CACHE STRING "Anjay library version")
set(ANJAY_BINARY_VERSION 1.0.0)

set(ANJAY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -687,7 +687,7 @@ if(WITH_STATIC_ANALYSIS)
# let's try that
find_program(CLANG_BINARY clang)
if(CLANG_BINARY)
anjay_temp_name(_fname)
avs_temp_name(_fname)
file(WRITE ${_fname} "__clang_major__ __clang_minor__")
execute_process(COMMAND "${CLANG_BINARY}" -E -P -x c ${_fname}
OUTPUT_VARIABLE CLANG_VERSION_OUTPUT
@@ -708,7 +708,7 @@ if(WITH_STATIC_ANALYSIS)
endif()
endif()

cmake_dependent_option(WITH_FIND_UNUSED_CODE "Check for unused symbols on `make check`" ON WITH_TEST OFF)
cmake_dependent_option(WITH_FIND_UNUSED_CODE "Check for unused symbols on `make check`" ON "WITH_TEST;UNIX;NOT APPLE" OFF)
if(WITH_FIND_UNUSED_CODE)
add_custom_target(find_unused_code
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/find_unused_code.py"
@@ -69,3 +69,5 @@
#define ANJAY_MAX_URI_QUERY_SEGMENT_SIZE @MAX_URI_QUERY_SEGMENT_SIZE@

#define ANJAY_DTLS_SESSION_BUFFER_SIZE @DTLS_SESSION_BUFFER_SIZE@

#define _(Arg) AVS_DISPOSABLE_LOG(Arg)
@@ -301,7 +301,7 @@ if(WITH_TEST)
set(source_file "${CMAKE_CURRENT_BINARY_DIR}/ensure-no-warnings-from-headers-if-cpp.cpp")
add_custom_command(OUTPUT "${source_file}"
COMMAND /bin/echo > "${source_file}"
COMMAND for F in ${all_includes} \\; do /bin/echo -e "$$F" >> "${source_file}" \\; done)
COMMAND for F in ${all_includes} \\; do /bin/echo "$$F" >> "${source_file}" \\; done)
add_library("${HWC_TARGET}" OBJECT "${source_file}")
target_include_directories("${HWC_TARGET}" PRIVATE $<TARGET_PROPERTY:avs_coap,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options("${HWC_TARGET}" PRIVATE -std=c++11 -Wall -Wextra -pedantic -Werror)
@@ -117,7 +117,7 @@ client_exchange_start(avs_coap_ctx_t *ctx,

static inline bool request_header_valid(const avs_coap_request_header_t *req) {
if (!avs_coap_code_is_request(req->code)) {
LOG(WARNING, "non-request code %s used in request header",
LOG(WARNING, _("non-request code ") "%s" _(" used in request header"),
AVS_COAP_CODE_STRING(req->code));
return false;
}
@@ -182,7 +182,7 @@ call_exchange_response_handler(avs_coap_ctx_t *ctx,
assert(ctx);
assert(exchange);

LOG(TRACE, "exchange %" PRIu64 ": %s", exchange->id.value,
LOG(TRACE, _("exchange ") "%" PRIu64 _(": ") "%s", exchange->id.value,
request_state_string(request_state.state));

// TODO: T2243
@@ -256,15 +256,16 @@ static avs_error_t handle_request_block_size_renegotiation(

if (new_seq_num > AVS_COAP_BLOCK_MAX_SEQ_NUMBER) {
LOG(DEBUG,
"BLOCK%d size renegotiation impossible: seq_num "
"overflows (%" PRIu32 " >= %" PRIu32 " == 2^20), ignoring "
"size renegotiation request",
_("BLOCK") "%d" _(" size renegotiation impossible: seq_num "
"overflows (") "%" PRIu32 _(" >= ") "%" PRIu32
_(" == 2^20), ignoring size renegotiation request"),
request_block->type == AVS_COAP_BLOCK1 ? 1 : 2, new_seq_num,
(uint32_t) AVS_COAP_BLOCK_MAX_SEQ_NUMBER);
} else {
LOG(DEBUG,
"BLOCK%d size renegotiated: %" PRIu16 " -> %" PRIu16
"; seq_num %" PRIu32 " -> %" PRIu32,
_("BLOCK") "%d" _(" size renegotiated: ") "%" PRIu16
_(" -> ") "%" PRIu16 _("; seq_num ") "%" PRIu32 _(
" -> ") "%" PRIu32,
request_block->type == AVS_COAP_BLOCK1 ? 1 : 2,
request_block->size, response_block->size,
request_block->seq_num, new_seq_num);
@@ -276,8 +277,8 @@ static avs_error_t handle_request_block_size_renegotiation(
} else {
assert(request_block->size < response_block->size);
LOG(DEBUG,
"invalid BLOCK%d size increase requested (%" PRIu16 " -> %" PRIu16
"), ignoring",
_("invalid BLOCK") "%d" _(" size increase requested (") "%" PRIu16
_(" -> ") "%" PRIu16 _("), ignoring"),
request_block->type == AVS_COAP_BLOCK1 ? 1 : 2, request_block->size,
response_block->size);
return _avs_coap_err(AVS_COAP_ERR_BLOCK_SIZE_RENEGOTIATION_INVALID);
@@ -314,8 +315,8 @@ static avs_error_t update_exchange_for_next_request_block(

if (request_block1.seq_num > AVS_COAP_BLOCK_MAX_SEQ_NUMBER) {
LOG(ERROR,
"BLOCK1 sequence number (%" PRIu32
") exceeds maximum acceptable value (%" PRIu32 ")",
_("BLOCK1 sequence number (") "%" PRIu32 _(
") exceeds maximum acceptable value (") "%" PRIu32 _(")"),
request_block1.seq_num, (uint32_t) AVS_COAP_BLOCK_MAX_SEQ_NUMBER);
return _avs_coap_err(AVS_COAP_ERR_BLOCK_SEQ_NUM_OVERFLOW);
}
@@ -355,12 +356,12 @@ handle_continue_response(avs_coap_exchange_t *exchange,
}

case AVS_COAP_OPTION_MISSING:
LOG(DEBUG, "BLOCK1 option missing in %s response",
LOG(DEBUG, _("BLOCK1 option missing in ") "%s" _(" response"),
AVS_COAP_CODE_STRING(msg->code));
return failure_state(_avs_coap_err(AVS_COAP_ERR_MALFORMED_OPTIONS));

default:
LOG(DEBUG, "malformed BLOCK1 option in %s response",
LOG(DEBUG, _("malformed BLOCK1 option in ") "%s" _(" response"),
AVS_COAP_CODE_STRING(msg->code));
return failure_state(_avs_coap_err(AVS_COAP_ERR_MALFORMED_OPTIONS));
}
@@ -394,8 +395,8 @@ static avs_error_t update_request_for_next_response_block(

if (expected_offset != actual_offset) {
LOG(DEBUG,
"mismatched response block offset (expected %" PRIu32
", got %" PRIu32 ")",
_("mismatched response block offset (expected ") "%" PRIu32 _(
", got ") "%" PRIu32 _(")"),
expected_offset, actual_offset);
return _avs_coap_err(AVS_COAP_ERR_MALFORMED_OPTIONS);
}
@@ -453,7 +454,8 @@ static bool etag_matches(avs_coap_exchange_t *exchange,
return true;
}
if (!avs_coap_etag_equal(&etag, &exchange->by_type.client.etag)) {
LOG(WARNING, "Response ETag mismatch: previous: %s, current: %s",
LOG(WARNING,
_("Response ETag mismatch: previous: ") "%s" _(", current: ") "%s",
AVS_COAP_ETAG_HEX(&exchange->by_type.client.etag),
AVS_COAP_ETAG_HEX(&etag));
return false;
@@ -498,7 +500,7 @@ handle_final_response(avs_coap_exchange_t *exchange,
if (request_off != response_off) {
// We asked the server for one block of data, but it returned
// another one. This is clearly a server-side error.
LOG(WARNING, "expected %s, got %s",
LOG(WARNING, _("expected ") "%s" _(", got ") "%s",
_AVS_COAP_OPTION_BLOCK_STRING(&request_block2),
_AVS_COAP_OPTION_BLOCK_STRING(&response_block2));
return failure_state(_avs_coap_err(AVS_COAP_ERR_MALFORMED_OPTIONS));
@@ -507,7 +509,7 @@ handle_final_response(avs_coap_exchange_t *exchange,
// TODO T2123: check that all options other than BLOCK2 are identical
// across responses

LOG(TRACE, "exchange %" PRIu64 ": %s", exchange->id.value,
LOG(TRACE, _("exchange ") "%" PRIu64 _(": ") "%s", exchange->id.value,
_AVS_COAP_OPTION_BLOCK_STRING(&response_block2));

if (response_block2.has_more) {
@@ -529,7 +531,7 @@ handle_final_response(avs_coap_exchange_t *exchange,
// with a non-BLOCK response. This most likely indicates a server
// error.
if (request_has_block2) {
LOG(DEBUG, "expected %s, but BLOCK2 option not found",
LOG(DEBUG, _("expected ") "%s" _(", but BLOCK2 option not found"),
_AVS_COAP_OPTION_BLOCK_STRING(&request_block2));
return failure_state(_avs_coap_err(AVS_COAP_ERR_MALFORMED_OPTIONS));
}
@@ -538,7 +540,7 @@ handle_final_response(avs_coap_exchange_t *exchange,
return success_state(AVS_COAP_CLIENT_REQUEST_OK);

default:
LOG(DEBUG, "malformed BLOCK2 option");
LOG(DEBUG, _("malformed BLOCK2 option"));
return failure_state(_avs_coap_err(AVS_COAP_ERR_MALFORMED_OPTIONS));
}
}
@@ -566,15 +568,15 @@ handle_response(avs_coap_exchange_t *exchange,
case AVS_COAP_CODE_CONTINUE:
#ifdef WITH_AVS_COAP_BLOCK
if (!exchange_expects_continue_response(exchange)) {
LOG(DEBUG, "unexpected %s response",
LOG(DEBUG, _("unexpected ") "%s" _(" response"),
AVS_COAP_CODE_STRING(response->code));
return failure_state(
_avs_coap_err(AVS_COAP_ERR_UNEXPECTED_CONTINUE_RESPONSE));
}

return handle_continue_response(exchange, response);
#else // WITH_AVS_COAP_BLOCK
LOG(DEBUG, "unexpected %s response",
LOG(DEBUG, _("unexpected ") "%s" _(" response"),
AVS_COAP_CODE_STRING(response->code));
return failure_state(_avs_coap_err(AVS_COAP_ERR_FEATURE_DISABLED));
#endif // WITH_AVS_COAP_BLOCK

0 comments on commit 92a5e42

Please sign in to comment.
You can’t perform that action at this time.