Skip to content

Commit

Permalink
Anjay 1.5.0
Browse files Browse the repository at this point in the history
Features:
- Extracted Firmware Update logic to a separate module so that the end user
  have to implement device-specific firmware updating logic only
- Implemented API for firmware update resumption
- Implemented stub of the portfolio object (in demo client) required for the
  OMA TestFest 2017
- Added support for DTLS session resumption as well as register-after-reconnect
  semantics
- Added object versioning support
- Added support for LwM2M Server URIs with Uri-Path and Uri-Query

Bugfixes:
- Fixed travis builds on macOS
- Fixed a few misleading statements in the documentation
- Fixed anjay_codegen.py handling of Multiple Instance Resources
- Fixed Content-Format for responses on Bootstrap Discover request
- Fixed Write (replace) on Device object instance in demo client

Improvements:
- Added more tests covering OMA TestFest 2017 test cases
- Allowed configuring Security/Server IIDs from command line in demo
- Allowed Bootstrap Delete on "/"
- Added support for re-bootstrapping after failed registrations
- Added anjay_server/security_object_is_modified simiar to
  anjay_attr_storage_is_modified
- Updated porting guide
- Replaced Internal Server Error responses with more specific error
  codes in a few places

Other:
- Relaxed validator of Update location path, due to specification being
  unclear (see: OpenMobileAlliance/OMA_LwM2M_for_Developers#230)
  • Loading branch information
Mateusz Krawiec committed Nov 20, 2017
1 parent 5d82cdf commit 14fda85
Show file tree
Hide file tree
Showing 120 changed files with 7,661 additions and 3,667 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ nbproject
CMakeFiles/
CMakeTmp/
CMakeCache.txt
CMakeDoxyfile.in
CMakeDoxygenDefaults.cmake
cmake_install.cmake
install_manifest.txt
_CPack_Packages/
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if(WITH_FUZZ_TESTS)
endif()

project(anjay C)
set(ANJAY_VERSION "1.4.1" CACHE STRING "Anjay library version")
set(ANJAY_VERSION "1.5.0" CACHE STRING "Anjay library version")
set(ANJAY_BINARY_VERSION 1.0.0)

set(ANJAY_BUILD_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/output")
Expand Down Expand Up @@ -166,6 +166,7 @@ set(CORE_SOURCES
src/dm/query.c
src/anjay_core.c
src/io_core.c
src/io_utils.c
src/notify.c
src/servers/activate.c
src/servers/connection_info.c
Expand Down Expand Up @@ -240,7 +241,6 @@ set(CORE_PRIVATE_HEADERS
src/io/tlv.h
src/io/vtable.h
src/observe_core.h
src/sched.h
src/sched_internal.h
src/servers.h
src/servers/activate.h
Expand All @@ -253,9 +253,11 @@ set(CORE_MODULES_HEADERS
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/downloader.h
include_modules/anjay_modules/io_utils.h
include_modules/anjay_modules/notify.h
include_modules/anjay_modules/observe.h
include_modules/anjay_modules/sched.h
include_modules/anjay_modules/time_defs.h
include_modules/anjay_modules/raw_buffer.h)
set(CORE_PUBLIC_HEADERS
Expand Down Expand Up @@ -333,6 +335,9 @@ if(WITH_MODULE_persistence)
endif()
DEFINE_MODULE(security ON "Security object module")
DEFINE_MODULE(server ON "Server object module")
if(WITH_DOWNLOADER OR WITH_BLOCK_RECEIVE)
DEFINE_MODULE(fw_update ON "Firmware Update object module")
endif()

################# LIBRARIES ####################################################

Expand Down Expand Up @@ -558,6 +563,8 @@ if(WITH_AVS_UNIT)
target_link_libraries(${PROJECT_NAME}_test ${DEPS_LIBRARIES} ${DEPS_LIBRARIES_WEAK})
endif()

add_subdirectory(test/codegen)

cmake_dependent_option(WITH_INTEGRATION_TESTS "Enable integration tests" OFF WITH_DEMO OFF)
if(WITH_INTEGRATION_TESTS)
add_subdirectory(test/integration)
Expand Down
1 change: 1 addition & 0 deletions config/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#cmakedefine WITH_BLOCK_SEND
#cmakedefine WITH_BOOTSTRAP
#cmakedefine WITH_DISCOVER
#cmakedefine WITH_DOWNLOADER
#cmakedefine WITH_OBSERVE
#cmakedefine WITH_HTTP_DOWNLOAD
#cmakedefine WITH_JSON
Expand Down
4 changes: 3 additions & 1 deletion demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(SOURCES
demo_args.c
demo_cmds.c
demo_utils.c
firmware_update.c
iosched.c
objects/apn_conn_profile.c
objects/cell_connectivity.c
Expand All @@ -28,13 +29,14 @@ set(SOURCES
objects/download_diagnostics.c
objects/device.c
objects/ext_dev_info.c
objects/firmware_update.c
objects/geopoints.c
objects/ip_ping.c
objects/location.c
objects/portfolio.c
objects/test.c)

set(HEADERS
firmware_update.h
iosched.h
objects.h
demo_utils.h)
Expand Down
18 changes: 10 additions & 8 deletions demo/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@

#include <anjay/access_control.h>
#include <anjay/attr_storage.h>
#include <anjay/fw_update.h>
#include <anjay/security.h>
#include <anjay/server.h>

#include "demo.h"
#include "demo_args.h"
#include "demo_cmds.h"
#include "firmware_update.h"
#include "iosched.h"
#include "objects.h"
#include "demo_utils.h"
Expand Down Expand Up @@ -68,7 +70,7 @@ static int security_object_reload(const anjay_dm_object_def_t *const *sec_obj,
instance.server_public_key = args->server_public_key;
instance.server_public_key_size = args->server_public_key_size;

anjay_iid_t iid = (anjay_iid_t) server->id;
anjay_iid_t iid = server->security_iid;
if (anjay_security_object_add_instance(sec_obj, &instance, &iid)) {
demo_log(ERROR, "Cannot add Security Instance");
return -1;
Expand All @@ -95,7 +97,7 @@ static int server_object_reload(const anjay_dm_object_def_t *const *serv_obj,
.binding = args->binding_mode,
.notification_storing = true
};
anjay_iid_t iid = (anjay_iid_t) server->id;
anjay_iid_t iid = server->server_iid;
if (anjay_server_object_add_instance(serv_obj, &instance, &iid)) {
demo_log(ERROR, "Cannot add Server Instance");
return -1;
Expand Down Expand Up @@ -148,6 +150,7 @@ static void demo_delete(anjay_demo_t *demo) {
AVS_LIST_CLEAR(&demo->objects) {
demo->objects->release_func(demo->objects->obj_ptr);
}
firmware_update_destroy(&demo->fw_update);

iosched_release(demo->iosched);
AVS_LIST_CLEAR(&demo->allocated_strings);
Expand Down Expand Up @@ -289,6 +292,8 @@ static int demo_init(anjay_demo_t *demo,
|| !demo->iosched
|| anjay_attr_storage_install(demo->anjay)
|| anjay_access_control_install(demo->anjay)
|| firmware_update_install(demo->anjay, &demo->fw_update,
cmdline_args->fw_updated_marker_path)
|| !iosched_poll_entry_new(demo->iosched, STDIN_FILENO,
POLLIN | POLLHUP,
demo_command_dispatch, demo, NULL)) {
Expand Down Expand Up @@ -318,19 +323,16 @@ static int demo_init(anjay_demo_t *demo,
|| install_object(demo, ext_dev_info_object_create(),
ext_dev_info_notify_time_dependent,
ext_dev_info_object_release)
|| install_object(demo,
firmware_update_object_create(
demo->iosched,
cmdline_args->fw_updated_marker_path),
NULL, firmware_update_object_release)
|| install_object(demo, geopoints_object_create(demo),
geopoints_notify_time_dependent,
geopoints_object_release)
|| install_object(demo, ip_ping_object_create(demo->iosched), NULL,
ip_ping_object_release)
|| install_object(demo, test_object_create(),
test_notify_time_dependent,
test_object_release)) {
test_object_release)
|| install_object(demo, portfolio_object_create(),
NULL, portfolio_object_release)) {
return -1;
}

Expand Down
2 changes: 2 additions & 0 deletions demo/demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <poll.h>

#include "firmware_update.h"
#include "objects.h"

typedef struct {
Expand All @@ -49,6 +50,7 @@ struct anjay_demo_struct {
server_connection_args_t *connection_args;

iosched_t *iosched;
fw_update_logic_t fw_update;

AVS_LIST(anjay_demo_object_t) objects;
};
Expand Down
63 changes: 57 additions & 6 deletions demo/demo_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ static const cmdline_args_t DEFAULT_CMDLINE_ARGS = {
.endpoint_name = "urn:dev:os:0023C7-000001",
.connection_args = {
.servers[0] = {
.security_iid = ANJAY_IID_INVALID,
.server_iid = ANJAY_IID_INVALID,
.id = 1,
.uri = "coap://127.0.0.1:5683"
},
Expand Down Expand Up @@ -144,6 +146,11 @@ static void print_option_help(const struct option *opt) {
"server URI to use. Note: coap:// URIs require --security-mode nosec "
"to be set. N consecutive URIs will create N servers enumerated "
"from 1 to N." },
{ 'D', "IID", NULL, "enforce particular Security Instance IID for last "
"configured server." },
{ 'd', "IID", NULL, "enforce particular Server Instance IID for last "
"configured server. Ignored if last configured server is an LwM2M "
"Bootstrap Server." },
{ 'I', "SIZE", "4000", "Nonnegative integer representing maximum "
"size of an incoming CoAP packet the client "
"should be able to handle." },
Expand Down Expand Up @@ -206,6 +213,19 @@ static int parse_i32(const char *str, int32_t *out_value) {
return 0;
}

static int parse_u16(const char *str, uint16_t *out_value) {
long long_value;
if (demo_parse_long(optarg, &long_value)
|| long_value < 0
|| long_value > UINT16_MAX) {
demo_log(ERROR, "value out of range: %s", str);
return -1;
}

*out_value = (uint16_t) long_value;
return 0;
}

static int parse_hexstring(const char *str, uint8_t **out, size_t *out_size) {
if (!str) {
return -1;
Expand Down Expand Up @@ -335,7 +355,9 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
{ "key", required_argument, 0, 'k' },
{ "key-file", required_argument, 0, 'K' },
{ "binding", optional_argument, 0, 'q' },
{ "security-iid", required_argument, 0, 'D' },
{ "security-mode", required_argument, 0, 's' },
{ "server-iid", required_argument, 0, 'd' },
{ "server-uri", required_argument, 0, 'u' },
{ "inbuf-size", required_argument, 0, 'I' },
{ "outbuf-size", required_argument, 0, 'O' },
Expand Down Expand Up @@ -484,15 +506,38 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
parsed_args->connection_args.binding_mode = binding_mode;
break;
}
case 'D': {
int idx = num_servers == 0 ? 0 : num_servers - 1;
if (parse_u16(optarg,
&parsed_args->connection_args.servers[idx]
.security_iid)) {
goto error;
}
}
break;
case 's':
if (parse_security_mode(
optarg, &parsed_args->connection_args.security_mode)) {
goto error;
}
break;
case 'u':
assert(num_servers < MAX_SERVERS && "Too many servers");
parsed_args->connection_args.servers[num_servers++].uri = optarg;
case 'd': {
int idx = num_servers == 0 ? 0 : num_servers - 1;
if (parse_u16(optarg,
&parsed_args->connection_args.servers[idx]
.server_iid)) {
goto error;
}
}
break;
case 'u': {
assert(num_servers < MAX_SERVERS && "Too many servers");
server_entry_t *entry =
&parsed_args->connection_args.servers[num_servers++];
entry->uri = optarg;
entry->security_iid = ANJAY_IID_INVALID;
entry->server_iid = ANJAY_IID_INVALID;
}
break;
case 'I':
if (parse_i32(optarg, &parsed_args->inbuf_size)
Expand Down Expand Up @@ -523,9 +568,15 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
}
}
finish:
for (int i = 1; i < num_servers; ++i) {
// update IDs
parsed_args->connection_args.servers[i].id = (anjay_ssid_t) (i + 1);
for (int i = 0; i < AVS_MAX(num_servers, 1); ++i) {
server_entry_t *entry = &parsed_args->connection_args.servers[i];
entry->id = (anjay_ssid_t) (i + 1);
if (entry->security_iid == ANJAY_IID_INVALID) {
entry->security_iid = (anjay_iid_t) entry->id;
}
if (entry->server_iid == ANJAY_IID_INVALID) {
entry->server_iid = (anjay_iid_t) entry->id;
}
}
bool identity_set =
!!parsed_args->connection_args.public_cert_or_psk_identity_size;
Expand Down
23 changes: 9 additions & 14 deletions demo/demo_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "demo.h"
#include "demo_cmds.h"
#include "demo_utils.h"
#include "firmware_update.h"

#include <ctype.h>
#include <string.h>
Expand Down Expand Up @@ -65,20 +66,12 @@ static void cmd_reconnect(anjay_demo_t *demo,

static void cmd_set_fw_package_path(anjay_demo_t *demo,
const char *args_string) {
const anjay_dm_object_def_t **firmware_update_obj =
demo_find_object(demo, DEMO_OID_FIRMWARE_UPDATE);
if (!firmware_update_obj) {
demo_log(ERROR, "Firmware update object not registered");
return;
}

const char *path = args_string;
while (isspace(*path)) {
++path;
}

firmware_update_set_package_path(demo->anjay,
firmware_update_obj, path);
firmware_update_set_package_path(&demo->fw_update, path);
}

static void cmd_open_location_csv(anjay_demo_t *demo, const char *args_string) {
Expand Down Expand Up @@ -122,11 +115,13 @@ static int add_server(anjay_demo_t *demo, const char *uri) {
}
memcpy(copied_uri->data, uri, uri_size);
AVS_LIST_INSERT(&demo->allocated_strings, copied_uri);
demo->connection_args->servers[num_servers] =
demo->connection_args->servers[num_servers - 1];
demo->connection_args->servers[num_servers].id =
(anjay_ssid_t) (num_servers + 1);
demo->connection_args->servers[num_servers].uri = copied_uri->data;

server_entry_t *entry = &demo->connection_args->servers[num_servers];
*entry = demo->connection_args->servers[num_servers - 1];
entry->id = (anjay_ssid_t) (num_servers + 1);
entry->uri = copied_uri->data;
entry->security_iid = (anjay_iid_t) entry->id;
entry->server_iid = (anjay_iid_t) entry->id;
demo_log(INFO, "Added new server, ID == %d", (int) (num_servers + 1));
return 0;
}
Expand Down
Loading

0 comments on commit 14fda85

Please sign in to comment.