Skip to content
Permalink
Browse files

Anjay 1.14.1

Features:
- Added command line flag to the demo client that disables use of stdin

Improvements:
- Removed some code duplicated with avs_commons
- Fixed some minor issues found by scan-build 7
- Simplified flow of code for Register, Update and Request Bootstrap operations
- Reformatted example code

Bugfixes:
- Fixed a bug that prevented attempt to retry DTLS handshake after failed
  Request Bootstrap operation in some scenarios when Server-Initiated Bootstrap
  is enabled
- Fixed misleading, erroneous log message for when receiving CoAP messages time
  out
- Fixed the documentation URL test randomly failing on some machines
  • Loading branch information...
kFYatek committed Jan 22, 2019
1 parent 2466abe commit 0f76af19a1e2e5859d8d65e1cdc69a82a5bf8579
Showing 409 changed files with 964 additions and 945 deletions.
@@ -1,4 +1,4 @@
# Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
# Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
# Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
# Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
cmake_minimum_required(VERSION 2.8.12)

project(anjay C)
set(ANJAY_VERSION "1.14.0" CACHE STRING "Anjay library version")
set(ANJAY_VERSION "1.14.1" CACHE STRING "Anjay library version")
set(ANJAY_BINARY_VERSION 1.0.0)

set(ANJAY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -1,5 +1,5 @@
..
Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
2 NOTICE
@@ -1,5 +1,5 @@
Anjay
Copyright 2017-2018 AVSystem
Copyright 2017-2019 AVSystem

This product includes software developed at AVSystem (www.avsystem.com).

@@ -114,7 +114,6 @@ More details about OMA LwM2M: [Brief introduction to LwM2M](https://AVSystem.git
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 valgrind clang-tools
pip3 install grequests
```

#### CentOS 7
@@ -130,7 +129,7 @@ sudo yum install -y valgrind valgrind-devel openssl openssl-devel python35u pyth
# Use update-alternatives to create a /usr/bin/python3 symlink with priority 0
# (lowest possible)
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 0
sudo python3 -m pip install cryptography jinja2 requests grequests
sudo python3 -m pip install cryptography jinja2 requests
```

#### macOS Sierra with [Homebrew](https://brew.sh/)
@@ -139,7 +138,7 @@ sudo python3 -m pip install cryptography jinja2 requests grequests
brew install cmake mbedtls
# Optionally for tests:
brew install python3 openssl llvm
pip3 install cryptography sphinx sphinx_rtd_theme requests grequests
pip3 install cryptography sphinx sphinx_rtd_theme requests
```

#### Windows
@@ -1,4 +1,4 @@
# Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
# Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
# Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
# Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
# Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
# Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
# Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
# Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
# Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
# Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
# Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
# Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
# Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -303,17 +303,21 @@ static int demo_init(anjay_demo_t *demo, cmdline_args_t *cmdline_args) {
fw_security_info_ptr,
cmdline_args->fwu_tx_params_modified
? &cmdline_args->fwu_tx_params
: NULL)
: NULL)) {
return -1;
}

#ifndef _WIN32
|| !iosched_poll_entry_new(demo->iosched, STDIN_FILENO,
POLLIN | POLLHUP, demo_command_dispatch,
demo, NULL)
if (!cmdline_args->disable_stdin) {
if (!iosched_poll_entry_new(demo->iosched, STDIN_FILENO,
POLLIN | POLLHUP, demo_command_dispatch,
demo, NULL)) {
return -1;
}
}
#else // _WIN32
# warning "TODO: Support stdin somehow on Windows"
#endif // _WIN32
) {
return -1;
}

if (anjay_security_object_install(demo->anjay)
|| anjay_server_object_install(demo->anjay)
@@ -492,7 +496,7 @@ static void serve(anjay_demo_t *demo) {
/ 1000000));
demo_log(TRACE, "wait time: %d ms", waitms);

// +1 to prevent annoying annoying looping in case of
// +1 to prevent annoying looping in case of
// sub-millisecond delays
iosched_run(demo->iosched, waitms + 1);

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -142,6 +142,10 @@ static void print_option_help(const struct option *opt) {
{ 'e', "URN", DEFAULT_CMDLINE_ARGS.endpoint_name,
"endpoint name to use." },
{ 'h', NULL, NULL, "show this message and exit." },
#ifndef _WIN32
{ 't', NULL, NULL, "disables standard input. Useful for running the "
"client as a daemon." },
#endif // _WIN32
{ 'l', "SECONDS", "86400",
"set registration lifetime. If SECONDS <= 0, use default value and "
"don't send lifetime in Register/Update messages." },
@@ -298,6 +302,7 @@ static int parse_size(const char *str, size_t *out_value) {
}

static int parse_double(const char *str, double *out_value) {
assert(str);
errno = 0;
char *endptr = NULL;
*out_value = strtod(str, &endptr);
@@ -422,6 +427,9 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
{ "bootstrap-timeout", required_argument, 0, 'T' },
{ "endpoint-name", required_argument, 0, 'e' },
{ "help", no_argument, 0, 'h' },
#ifndef _WIN32
{ "disable-stdin", no_argument, 0, 't' },
#endif // _WIN32
{ "lifetime", required_argument, 0, 'l' },
{ "stored-notification-limit", required_argument, 0, 'L' },
{ "location-csv", required_argument, 0, 'c' },
@@ -554,6 +562,11 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
print_option_help(&options[i]);
}
goto finish;
#ifndef _WIN32
case 't':
parsed_args->disable_stdin = true;
break;
#endif // _WIN32
case 'l':
if (parse_i32(optarg, &parsed_args->connection_args.lifetime)) {
goto finish;
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,9 @@ typedef struct cmdline_args {
int32_t outbuf_size;
int32_t msg_cache_size;
bool confirmable_notifications;
#ifndef _WIN32
bool disable_stdin;
#endif // _WIN32
const char *fw_updated_marker_path;
avs_net_security_info_t fw_security_info;
const char *attr_storage_file;
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
#include <unistd.h>

#include <avsystem/commons/memory.h>
#include <avsystem/commons/utils.h>

#define DEV_RES_MANUFACTURER 0 // string
#define DEV_RES_MODEL_NUMBER 1 // string
@@ -373,6 +374,7 @@ static void extract_device_info(const char *endpoint_name,
size_t manufacturer_size,
char *out_serial,
size_t serial_size) {
int result = 0;
// skip everything up to (and including) last colon
// this throws away urn:dev:os: prefix, if any
const char *at = endpoint_name;
@@ -383,7 +385,9 @@ static void extract_device_info(const char *endpoint_name,
const char *dash = strchr(at, '-');
if (!dash || at == dash) {
demo_log(WARNING, "empty manufacturer part of endpoint name");
strncpy(out_manufacturer, "Anjay", sizeof("Anjay"));
result = avs_simple_snprintf(out_manufacturer, manufacturer_size,
"Anjay");
assert(result >= 0);
} else {
AVS_ASSERT((size_t) (dash - at) < manufacturer_size,
"manufacturer part of endpoint name too long");
@@ -396,7 +400,8 @@ static void extract_device_info(const char *endpoint_name,
size_t serial_length = strlen(at);
if (serial_length == 0) {
demo_log(WARNING, "empty serial number part of endpoint name");
strncpy(out_serial, "000001", sizeof("000001"));
result = avs_simple_snprintf(out_serial, serial_size, "000001");
assert(result >= 0);
} else {
AVS_ASSERT(serial_length < serial_size,
"serial number part of endpoint name too long");
@@ -406,6 +411,7 @@ static void extract_device_info(const char *endpoint_name,

demo_log(DEBUG, "manufacturer: %s; serial number: %s", out_manufacturer,
out_serial);
(void) result;
}

const anjay_dm_object_def_t **device_object_create(iosched_t *iosched,
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2018 AVSystem <avsystem@avsystem.com>
* Copyright 2017-2019 AVSystem <avsystem@avsystem.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Oops, something went wrong.

0 comments on commit 0f76af1

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