Permalink
Browse files

Anjay 1.11.0

Breaking changes:
- Removed ANJAY_BINDING_* constants. Whenever used, they should now be replaced
  with plain c-strings, as follows:
		* ANJAY_BINDING_U -> "U",
		* ANJAY_BINDING_S -> "S",
		* ANJAY_BINDING_US -> "US",
		* ANJAY_BINDING_UQ -> "UQ",
		* ANJAY_BINDING_SQ -> "SQ",
		* ANJAY_BINDING_UQS -> "UQS",
		* ANJAY_BINDING_NONE -> ""

Features:
- Implemented anjay_attr_storage_purge(), to allow cleaning up Attribute
  Storage data without recreating a whole client instance
- Implemented anjay_access_control_purge(), anjay_access_control_is_modified(),
  to allow better control over persistence
- Updated avs_commons to version 3.7.1

Bugfixes:
- Fixed implementation of bytes resources in demo test object code
- Added missing header in attr_storage.h

Improvements:
- Added support for multiple object versions in lwm2m_object_registry.py
  script
- Added some previously missing optional packages to README.md, required to run
  integration tests
- Improved performance of integration tests
- Improved documentation of internal server-related APIs
- Improved unit tests API, specifically added macros that help building CoAP
  messages without the knowledge of exact packet encoding
  • Loading branch information...
sznaider committed Sep 4, 2018
1 parent 8da8507 commit 0410f8f50ea3f7fd660f6fc9d1a0d3cae9f203a5
Showing with 3,603 additions and 3,455 deletions.
  1. +41 −26 CMakeLists.txt
  2. +2 −2 README.md
  3. +1 −1 avs_commons/git
  4. +6 −3 demo/CMakeLists.txt
  5. +6 −11 demo/demo_args.c
  6. +1 −1 demo/objects.h
  7. +35 −25 demo/objects/test.c
  8. +2 −0 doc/sphinx/source/AdvancedTutorial/AT1.rst
  9. +3 −3 doc/sphinx/source/AdvancedTutorial/AT4.rst
  10. +1 −1 doc/sphinx/source/BasicTutorial/BT2.rst
  11. +2 −2 doc/sphinx/source/Tools.rst
  12. +18 −18 examples/test_examples.md5
  13. +1 −1 examples/tutorial/AT1/src/main.c
  14. +1 −1 examples/tutorial/AT2/src/main.c
  15. +1 −1 examples/tutorial/AT3-cert/src/main.c
  16. +1 −1 examples/tutorial/AT3-psk/src/main.c
  17. +2 −1 examples/tutorial/AT4/CMakeLists.txt
  18. +2 −2 examples/tutorial/AT4/src/main.c
  19. +1 −1 examples/tutorial/BT2/src/main.c
  20. +1 −1 examples/tutorial/BT3/src/main.c
  21. +2 −1 examples/tutorial/custom-object/multi-instance-dynamic/CMakeLists.txt
  22. +1 −1 examples/tutorial/custom-object/multi-instance-dynamic/src/main.c
  23. +2 −1 examples/tutorial/custom-object/multi-instance-resources-dynamic/CMakeLists.txt
  24. +1 −1 examples/tutorial/custom-object/multi-instance-resources-dynamic/src/main.c
  25. +1 −1 examples/tutorial/custom-object/notifications/src/main.c
  26. +1 −1 examples/tutorial/custom-object/read-only-multiple-fixed/src/main.c
  27. +1 −1 examples/tutorial/custom-object/read-only-with-executable/src/main.c
  28. +1 −1 examples/tutorial/custom-object/read-only/src/main.c
  29. +1 −1 examples/tutorial/custom-object/writable-multiple-fixed-transactional/src/main.c
  30. +1 −1 examples/tutorial/custom-object/writable-multiple-fixed/src/main.c
  31. +9 −53 include_modules/anjay_modules/sched.h
  32. +14 −4 include_modules/anjay_modules/servers.h
  33. +11 −5 include_modules/anjay_modules/utils_core.h
  34. +10 −49 include_public/anjay/dm.h
  35. +5 −1 include_public/anjay/io.h
  36. +2 −2 modules/access_control/CMakeLists.txt
  37. +14 −0 modules/access_control/include_public/anjay/access_control.h
  38. +24 −0 modules/access_control/src/access_control_handlers.c
  39. +2 −0 modules/access_control/src/access_control_persistence.c
  40. +6 −0 modules/access_control/src/mod_access_control.c
  41. +10 −0 modules/access_control/src/mod_access_control.h
  42. +2 −2 modules/attr_storage/CMakeLists.txt
  43. +43 −3 modules/attr_storage/include_public/anjay/attr_storage.h
  44. +51 −34 modules/attr_storage/src/attr_storage_persistence.c
  45. +12 −2 modules/attr_storage/src/mod_attr_storage.c
  46. +5 −4 modules/attr_storage/src/mod_attr_storage.h
  47. +3 −3 modules/fw_update/src/fw_update.c
  48. +8 −3 modules/security/CMakeLists.txt
  49. +8 −8 modules/security/src/mod_security.c
  50. +2 −2 modules/security/src/mod_security.h
  51. +2 −2 modules/security/src/security_persistence.c
  52. +3 −3 modules/security/src/test/persistence.c
  53. +8 −3 modules/server/CMakeLists.txt
  54. +1 −1 modules/server/include_public/anjay/server.h
  55. +26 −12 modules/server/src/mod_server.c
  56. +3 −3 modules/server/src/mod_server.h
  57. +68 −12 modules/server/src/server_persistence.c
  58. +4 −4 modules/server/src/server_transaction.c
  59. +2 −4 modules/server/src/server_utils.c
  60. +2 −2 modules/server/src/test/api.c
  61. +7 −11 modules/server/src/test/persistence.c
  62. +17 −1 src/access_control_utils.c
  63. +4 −4 src/anjay_core.c
  64. +65 −82 src/coap/test/stream.c
  65. +42 −5 src/coap/test/utils.h
  66. +21 −17 src/downloader/coap.c
  67. +3 −2 src/downloader/downloader.c
  68. +4 −4 src/downloader/http.c
  69. +46 −35 src/interface/bootstrap_core.c
  70. +13 −15 src/interface/register.c
  71. +165 −298 src/interface/test/bootstrap.c
  72. +38 −41 src/io/tlv_out.c
  73. +4 −4 src/notify.c
  74. +13 −12 src/observe/observe_core.c
  75. +270 −350 src/observe/test/observe.c
  76. +31 −110 src/sched.c
  77. +2 −20 src/sched_internal.h
  78. +364 −44 src/servers.h
  79. +57 −17 src/servers/activate.c
  80. +0 −8 src/servers/activate.h
  81. +80 −455 src/servers/connection_info.c
  82. +67 −12 src/servers/connection_info.h
  83. +246 −0 src/servers/connection_udp.c
  84. +77 −0 src/servers/connections_internal.h
  85. +30 −12 src/servers/offline.c
  86. +102 −108 src/servers/register_internal.c
  87. +2 −5 src/servers/register_internal.h
  88. +43 −58 src/servers/reload.c
  89. +0 −2 src/servers/reload.h
  90. +96 −160 src/servers/servers_internal.c
  91. +161 −18 src/servers/servers_internal.h
  92. +233 −0 src/servers_utils.c
  93. +67 −0 src/servers_utils.h
  94. +34 −71 src/test/anjay.c
  95. +360 −734 src/test/dm.c
  96. +12 −190 src/test/sched.c
  97. +46 −96 src/test/utils.c
  98. +31 −46 src/utils_core.c
  99. +3 −3 src/utils_core.h
  100. +12 −2 test/include/anjay_test/dm.h
  101. +1 −1 test/integration/framework/nsh-lwm2m/lwm2m/coap/option.py
  102. +5 −1 test/integration/framework/nsh-lwm2m/lwm2m/coap/packet.py
  103. +7 −1 test/integration/framework/nsh-lwm2m/lwm2m/tlv.py
  104. +36 −17 test/integration/framework/test_suite.py
  105. +1 −0 test/integration/framework/test_utils.py
  106. +2 −2 test/integration/runtest.py
  107. +48 −10 test/integration/suites/default/block_write.py
  108. +1 −1 test/integration/suites/default/client_block_request.py
  109. +7 −11 test/integration/suites/default/downloader.py
  110. +7 −0 test/integration/suites/default/formats.py
  111. +4 −4 test/integration/suites/default/retransmissions.py
  112. +68 −1 test/integration/suites/default/test_object.py
  113. +3 −8 test/integration/suites/default/update.py
  114. +1 −0 test/src/dm.c
  115. +44 −13 tools/lwm2m_object_registry.py
View
@@ -15,7 +15,7 @@
cmake_minimum_required(VERSION 2.8.12)
project(anjay C)
set(ANJAY_VERSION "1.10.4" CACHE STRING "Anjay library version")
set(ANJAY_VERSION "1.11.0" CACHE STRING "Anjay library version")
set(ANJAY_BINARY_VERSION 1.0.0)
set(ANJAY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -158,6 +158,7 @@ endmacro()
################# CODE #########################################################
set(CORE_SOURCES
src/anjay_core.c
src/coap/id_source/auto.c
src/coap/id_source/static.c
src/coap/stream/client_internal.c
@@ -166,6 +167,12 @@ set(CORE_SOURCES
src/coap/stream/out.c
src/coap/stream/server_internal.c
src/coap/stream/stream_internal.c
src/dm/dm_attributes.c
src/dm/dm_execute.c
src/dm/dm_handlers.c
src/dm/modules.c
src/dm/query.c
src/dm_core.c
src/interface/register.c
src/io/base64_out.c
src/io/dynamic.c
@@ -174,24 +181,19 @@ set(CORE_SOURCES
src/io/text.c
src/io/tlv_in.c
src/io/tlv_out.c
src/dm_core.c
src/dm/dm_attributes.c
src/dm/dm_execute.c
src/dm/dm_handlers.c
src/dm/modules.c
src/dm/query.c
src/anjay_core.c
src/io_core.c
src/io_utils.c
src/notify.c
src/raw_buffer.c
src/sched.c
src/servers/activate.c
src/servers/connection_info.c
src/servers/connection_udp.c
src/servers/offline.c
src/servers/reload.c
src/servers/register_internal.c
src/servers/reload.c
src/servers/servers_internal.c
src/raw_buffer.c
src/sched.c
src/servers_utils.c
src/utils_core.c)
if(WITH_ACCESS_CONTROL)
set(CORE_SOURCES ${CORE_SOURCES} src/access_control_utils.c)
@@ -210,8 +212,8 @@ if(WITH_HTTP_DOWNLOAD)
endif()
if(WITH_BLOCK_SEND)
set(CORE_SOURCES ${CORE_SOURCES}
src/coap/block/response.c
src/coap/block/request.c
src/coap/block/response.c
src/coap/block/transfer.c)
endif()
if(WITH_BOOTSTRAP)
@@ -231,46 +233,55 @@ if(WITH_JSON)
endif()
set(CORE_PRIVATE_HEADERS
src/access_control_utils.h
src/anjay_core.h
src/coap/block/request.h
src/coap/block/response.h
src/coap/block/transfer.h
src/coap/block/transfer_impl.h
src/coap/id_source/id_source.h
src/coap/coap_log.h
src/coap/coap_stream.h
src/coap/content_format.h
src/coap/id_source/auto.h
src/coap/id_source/id_source.h
src/coap/id_source/static.h
src/coap/coap_stream.h
src/coap/stream/client_internal.h
src/coap/stream/common.h
src/coap/stream/in.h
src/coap/stream/out.h
src/coap/stream/server_internal.h
src/coap/stream/stream_internal.h
src/dm_core.h
src/dm/dm_attributes.h
src/dm/discover.h
src/dm/dm_attributes.h
src/dm/dm_execute.h
src/dm/query.h
src/anjay_core.h
src/dm_core.h
src/downloader.h
src/downloader/private.h
src/interface/bootstrap_core.h
src/interface/register.h
src/io_core.h
src/io/base64_out.h
src/io/tlv.h
src/io/vtable.h
src/io_core.h
src/observe/observe_core.h
src/observe/observe_internal.h
src/sched_internal.h
src/servers.h
src/servers/activate.h
src/servers/connection_info.h
src/servers/connections_internal.h
src/servers/register_internal.h
src/servers/reload.h
src/servers/servers_internal.h
src/servers_utils.h
src/utils_core.h)
set(CORE_MODULES_HEADERS
include_modules/anjay_modules/dm_utils.h
include_modules/anjay_modules/dm/attributes.h
include_modules/anjay_modules/dm/execute.h
include_modules/anjay_modules/dm/modules.h
include_modules/anjay_modules/dm_utils.h
include_modules/anjay_modules/downloader.h
include_modules/anjay_modules/interface/bootstrap.h
include_modules/anjay_modules/io_utils.h
include_modules/anjay_modules/notify.h
include_modules/anjay_modules/observe.h
@@ -298,22 +309,26 @@ make_absolute_sources(ABSOLUTE_SOURCES ${ALL_SOURCES})
set(TEST_SOURCES
${ALL_SOURCES}
src/coap/test/block_response.c
src/coap/test/servers.c
src/coap/test/servers.h
src/coap/test/stream.c
src/coap/test/block_response.c
src/coap/test/utils.h
src/downloader/test/downloader_mock.h
src/interface/test/bootstrap_mock.h
src/io/test/bigdata.h
src/observe/test/observe_mock.h
test/src/coap/stream.c
test/src/coap/socket.c
test/src/dm.c
test/src/mock_clock.c
test/src/mock_dm.c
test/include/anjay_test/coap/socket.h
test/include/anjay_test/coap/stream.h
test/include/anjay_test/dm.h
test/include/anjay_test/mock_clock.h
test/include/anjay_test/mock_dm.h)
test/include/anjay_test/mock_dm.h
test/include/anjay_test/utils.h
test/src/coap/socket.c
test/src/coap/stream.c
test/src/dm.c
test/src/mock_clock.c
test/src/mock_dm.c)
make_absolute_sources(ABSOLUTE_TEST_SOURCES ${TEST_SOURCES})
################# MODULES ######################################################
View
@@ -111,9 +111,9 @@ More details about OMA LwM2M: [Brief introduction to LwM2M](https://AVSystem.git
#### Ubuntu 16.04 LTS
``` sh
sudo apt-get install git build-essential cmake libmbedtls-dev
sudo apt-get install git build-essential cmake libmbedtls-dev zlib1g-dev
# Optionally for tests:
sudo apt-get install libpython3-dev libssl-dev python3 python3-cryptography python3-jinja2 python3-sphinx python3-requests clang
sudo apt-get install libpython3-dev libssl-dev python3 python3-cryptography python3-jinja2 python3-sphinx python3-requests clang valgrind clang-tools
```
#### CentOS 7
View
@@ -26,8 +26,8 @@ set(SOURCES
objects/cell_connectivity.c
objects/conn_monitoring.c
objects/conn_statistics.c
objects/download_diagnostics.c
objects/device.c
objects/download_diagnostics.c
objects/ext_dev_info.c
objects/geopoints.c
objects/location.c
@@ -39,10 +39,13 @@ if(NOT WIN32)
endif()
set(HEADERS
demo.h
demo_args.h
demo_cmds.h
demo_utils.h
firmware_update.h
iosched.h
objects.h
demo_utils.h)
objects.h)
set(ALL_SOURCES ${SOURCES} ${HEADERS})
View
@@ -39,7 +39,7 @@ static const cmdline_args_t DEFAULT_CMDLINE_ARGS = {
.bootstrap_holdoff_s = 0,
.bootstrap_timeout_s = 0,
.lifetime = 86400,
.binding_mode = ANJAY_BINDING_U,
.binding_mode = "U",
.security_mode = ANJAY_UDP_SECURITY_NOSEC,
},
.location_csv = NULL,
@@ -558,19 +558,14 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
key_path = optarg;
break;
case 'q':
{
anjay_binding_mode_t binding_mode = ANJAY_BINDING_NONE;
if (optarg && *optarg) {
binding_mode = anjay_binding_mode_from_str(optarg);
}
if (!optarg || !*optarg) {
// default to UQ if optional argument is not present
// for compatibility with legacy -q being --queue
if (binding_mode == ANJAY_BINDING_NONE) {
binding_mode = ANJAY_BINDING_UQ;
}
parsed_args->connection_args.binding_mode = binding_mode;
break;
parsed_args->connection_args.binding_mode = "UQ";
} else {
parsed_args->connection_args.binding_mode = optarg;
}
break;
case 'D': {
int idx = num_servers == 0 ? 0 : num_servers - 1;
if (parse_u16(optarg,
View
@@ -66,7 +66,7 @@ typedef struct {
int32_t bootstrap_holdoff_s;
int32_t bootstrap_timeout_s;
int32_t lifetime;
anjay_binding_mode_t binding_mode;
const char *binding_mode;
anjay_udp_security_mode_t security_mode;
uint8_t *public_cert_or_psk_identity;
size_t public_cert_or_psk_identity_size;
View
@@ -41,6 +41,7 @@
#define TEST_RES_FLOAT 14
#define TEST_RES_STRING 15
#define TEST_RES_OBJLNK 16
#define TEST_RES_BYTES_ZERO_BEGIN 17
typedef struct test_array_entry_struct {
anjay_riid_t index;
@@ -59,6 +60,7 @@ typedef struct test_instance_struct {
int32_t volatile_res_value;
int32_t bytes_size;
int32_t bytes_burst;
bool bytes_zero_begin;
void *raw_bytes;
size_t raw_bytes_size;
AVS_LIST(test_array_entry_t) array;
@@ -160,6 +162,7 @@ static int test_instance_create(anjay_t *anjay,
created->execute_counter = 0;
created->bytes_size = 0;
created->bytes_burst = 1000;
created->bytes_zero_begin = false;
AVS_LIST(test_instance_t) *ptr;
AVS_LIST_FOREACH_PTR(ptr, &test->instances) {
@@ -262,41 +265,43 @@ static int test_resource_read(anjay_t *anjay,
return anjay_ret_array_finish(array);
}
case TEST_RES_BYTES: {
if (!inst->bytes_size) {
int result = 0;
if (!inst->bytes_size && !inst->bytes_zero_begin) {
return 0;
}
anjay_ret_bytes_ctx_t *bytes_ctx =
anjay_ret_bytes_begin(ctx, (size_t) inst->bytes_size);
char *buffer = (char *) avs_malloc((size_t) inst->bytes_burst);
if (!buffer) {
demo_log(ERROR, "Out of memory");
return -1;
if (!bytes_ctx) {
return ANJAY_ERR_INTERNAL;
}
int result = 0;
int32_t counter = 0;
for (int32_t offset = 0;
offset < inst->bytes_size;
offset += inst->bytes_burst) {
int32_t bytes_to_write = inst->bytes_size - offset;
if (bytes_to_write > inst->bytes_burst) {
bytes_to_write = inst->bytes_burst;
}
for (int32_t i = 0; i < bytes_to_write; ++i) {
buffer[i] = (char) (counter++ % 128);
if (inst->bytes_size) {
char *buffer = (char *) avs_malloc((size_t) inst->bytes_burst);
if (!buffer) {
demo_log(ERROR, "Out of memory");
return -1;
}
result = anjay_ret_bytes_append(bytes_ctx, buffer,
(size_t) bytes_to_write);
if (result) {
break;
int32_t counter = 0;
for (int32_t offset = 0;
offset < inst->bytes_size;
offset += inst->bytes_burst) {
int32_t bytes_to_write = inst->bytes_size - offset;
if (bytes_to_write > inst->bytes_burst) {
bytes_to_write = inst->bytes_burst;
}
for (int32_t i = 0; i < bytes_to_write; ++i) {
buffer[i] = (char) (counter++ % 128);
}
result = anjay_ret_bytes_append(bytes_ctx, buffer,
(size_t) bytes_to_write);
if (result) {
break;
}
}
avs_free(buffer);
}
avs_free(buffer);
return result;
}
case TEST_RES_RAW_BYTES: {
if (!inst->raw_bytes_size) {
return 0;
}
anjay_ret_bytes_ctx_t *bytes_ctx =
anjay_ret_bytes_begin(ctx, inst->raw_bytes_size);
if (!bytes_ctx) {
@@ -347,6 +352,8 @@ static int test_resource_read(anjay_t *anjay,
case TEST_RES_INCREMENT_COUNTER:
case TEST_RES_INIT_INT_ARRAY:
return ANJAY_ERR_METHOD_NOT_ALLOWED;
case TEST_RES_BYTES_ZERO_BEGIN:
return anjay_ret_bool(ctx, inst->bytes_zero_begin);
default:
return ANJAY_ERR_NOT_FOUND;
}
@@ -456,6 +463,8 @@ static int test_resource_write(anjay_t *anjay,
case TEST_RES_OBJLNK:
return anjay_get_objlnk(ctx, &inst->test_res_objlnk.oid,
&inst->test_res_objlnk.iid);
case TEST_RES_BYTES_ZERO_BEGIN:
return anjay_get_bool(ctx, &inst->bytes_zero_begin);
case TEST_RES_TIMESTAMP:
case TEST_RES_INCREMENT_COUNTER:
case TEST_RES_LAST_EXEC_ARGS_ARRAY:
@@ -715,7 +724,8 @@ const anjay_dm_object_def_t TEST_OBJECT = {
TEST_RES_BOOL,
TEST_RES_FLOAT,
TEST_RES_STRING,
TEST_RES_OBJLNK),
TEST_RES_OBJLNK,
TEST_RES_BYTES_ZERO_BEGIN),
.handlers = {
.instance_it = test_instance_it,
.instance_present = test_instance_present,
@@ -95,9 +95,11 @@ These two functions can be used for this purpose:
.. snippet-source:: modules/attr_storage/include_public/anjay/attr_storage.h
// ...
int anjay_attr_storage_persist(anjay_t *anjay,
avs_stream_abstract_t *out_stream);
// ...
int anjay_attr_storage_restore(anjay_t *anjay,
avs_stream_abstract_t *in_stream);
Oops, something went wrong.

0 comments on commit 0410f8f

Please sign in to comment.