mirror of https://github.com/ARMmbed/mbed-os.git
Merge branch 'prepare_for_mbedos511' of ssh://github.com/artokin/mbed-os into rollup-b.1
commit
49b940c9a7
|
@ -0,0 +1 @@
|
||||||
|
test/*
|
|
@ -11,6 +11,7 @@ INCLUDE_DIRS =\
|
||||||
../../../..\
|
../../../..\
|
||||||
../../../../source\
|
../../../../source\
|
||||||
../../../../mbed-client-randlib\
|
../../../../mbed-client-randlib\
|
||||||
|
../../../../../../../libService/libService\
|
||||||
/usr/include\
|
/usr/include\
|
||||||
$(CPPUTEST_HOME)/include\
|
$(CPPUTEST_HOME)/include\
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
|
|
||||||
TEST_GROUP(randLIB)
|
TEST_GROUP(randLIB)
|
||||||
{
|
{
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown()
|
void teardown() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, ARM Limited, All Rights Reserved
|
* Copyright (c) 2016, ARM Limited, All Rights Reserved
|
||||||
*/
|
*/
|
||||||
#include "random_stub.h"
|
|
||||||
|
#include "ns_types.h"
|
||||||
|
|
||||||
static uint32_t seed_value = 4;
|
static uint32_t seed_value = 4;
|
||||||
static bool seed_inc = false;
|
static bool seed_inc = false;
|
||||||
|
|
|
@ -107,6 +107,43 @@ Set the output function, `printf` by default:
|
||||||
mbed_trace_print_function_set(printf)
|
mbed_trace_print_function_set(printf)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Tracing level
|
||||||
|
|
||||||
|
Run time tracing level is set using `mbed_trace_set_config()` function. Possible levels and examples how to set them is presented below.
|
||||||
|
|
||||||
|
```c
|
||||||
|
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL);
|
||||||
|
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_DEBUG); // (same as ALL)
|
||||||
|
mbed_trace_config_set(TRACE_ACTIVE_LEVEL_INFO);
|
||||||
|
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_WARN);
|
||||||
|
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ERROR);
|
||||||
|
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_CMD);
|
||||||
|
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_NONE);
|
||||||
|
```
|
||||||
|
|
||||||
|
Build time optimization can be done with `MBED_TRACE_MAX_LEVEL` definition. Setting max level to `TRACE_LEVEL_DEBUG` includes all traces to the build. Setting max level to `TRACE_LEVEL_INFO` includes all but `tr_debug()` traces to the build. Other maximum tracing levels follow the same behavior and no messages above the selected level are included in the build.
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_DEBUG
|
||||||
|
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO
|
||||||
|
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_WARN
|
||||||
|
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_ERROR
|
||||||
|
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_CMD
|
||||||
|
```
|
||||||
|
|
||||||
|
In Mbed OS, the build time maximum tracing level can be set through `mbed_app.json` as shown below.
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"target_overrides":{
|
||||||
|
"*":{
|
||||||
|
"mbed-trace.enable": true,
|
||||||
|
"mbed-trace.max-level": "TRACE_LEVEL_INFO"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Helping functions
|
### Helping functions
|
||||||
|
|
||||||
The purpose of the helping functions is to provide simple conversions, for example from an array to C string, so that you can print everything to single trace line. They must be called inside the actual trace calls, for example:
|
The purpose of the helping functions is to provide simple conversions, for example from an array to C string, so that you can print everything to single trace line. They must be called inside the actual trace calls, for example:
|
||||||
|
|
|
@ -5,6 +5,12 @@
|
||||||
"help": "Used to globally enable traces.",
|
"help": "Used to globally enable traces.",
|
||||||
"value": null
|
"value": null
|
||||||
},
|
},
|
||||||
|
"max-level": {
|
||||||
|
"help": "This flag is used to optimize the code size. For example, setting trace optimization level to TRACE_LEVEL_INFO will define all tr_debug() macros empty, which reduces the binary size. The possible optimization levels are TRACE_LEVEL_DEBUG, TRACE_LEVEL_INFO, TRACE_LEVEL_WARN, TRACE_LEVEL_ERROR and TRACE_LEVEL_CMD. To set the output tracing level, please use mbed_trace_config_set(TRACE_ACTIVE_LEVEL_INFO). The possible tracing levels for mbed_trace_config_set() are TRACE_ACTIVE_LEVEL_ALL, TRACE_ACTIVE_LEVEL_DEBUG (same as ALL), TRACE_ACTIVE_LEVEL_INFO, TRACE_ACTIVE_LEVEL_WARN, TRACE_ACTIVE_LEVEL_ERROR, TRACE_ACTIVE_LEVEL_CMD and TRACE_LEVEL_NONE.",
|
||||||
|
"value": null,
|
||||||
|
"macro_name": "MBED_TRACE_MAX_LEVEL"
|
||||||
|
|
||||||
|
},
|
||||||
"fea-ipv6": {
|
"fea-ipv6": {
|
||||||
"help": "Used to globally disable ipv6 tracing features.",
|
"help": "Used to globally disable ipv6 tracing features.",
|
||||||
"value": null
|
"value": null
|
||||||
|
|
|
@ -48,8 +48,7 @@ void myprint(const char* str)
|
||||||
}
|
}
|
||||||
TEST_GROUP(trace)
|
TEST_GROUP(trace)
|
||||||
{
|
{
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
|
|
||||||
mbed_trace_init();
|
mbed_trace_init();
|
||||||
mbed_trace_config_set(TRACE_MODE_PLAIN | TRACE_ACTIVE_LEVEL_ALL);
|
mbed_trace_config_set(TRACE_MODE_PLAIN | TRACE_ACTIVE_LEVEL_ALL);
|
||||||
|
@ -57,8 +56,7 @@ TEST_GROUP(trace)
|
||||||
mbed_trace_mutex_wait_function_set(my_mutex_wait);
|
mbed_trace_mutex_wait_function_set(my_mutex_wait);
|
||||||
mbed_trace_mutex_release_function_set(my_mutex_release);
|
mbed_trace_mutex_release_function_set(my_mutex_release);
|
||||||
}
|
}
|
||||||
void teardown()
|
void teardown() {
|
||||||
{
|
|
||||||
CHECK(mutex_wait_count == mutex_release_count); // Check the mutex count with every test
|
CHECK(mutex_wait_count == mutex_release_count); // Check the mutex count with every test
|
||||||
mbed_trace_free();
|
mbed_trace_free();
|
||||||
}
|
}
|
||||||
|
@ -87,7 +85,9 @@ TEST(trace, MutexNotSet)
|
||||||
TEST(trace, Array)
|
TEST(trace, Array)
|
||||||
{
|
{
|
||||||
unsigned char longStr[200] = {0x66};
|
unsigned char longStr[200] = {0x66};
|
||||||
for(int i=0;i<200;i++) {longStr[i] = 0x66; }
|
for (int i = 0; i < 200; i++) {
|
||||||
|
longStr[i] = 0x66;
|
||||||
|
}
|
||||||
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(longStr, 200));
|
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(longStr, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,9 @@ TEST(trace, Null0Array)
|
||||||
TEST(trace, LongString)
|
TEST(trace, LongString)
|
||||||
{
|
{
|
||||||
char longStr[1000] = {0x36};
|
char longStr[1000] = {0x36};
|
||||||
for(int i=0;i<999;i++) {longStr[i] = 0x36; }
|
for (int i = 0; i < 999; i++) {
|
||||||
|
longStr[i] = 0x36;
|
||||||
|
}
|
||||||
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", longStr);
|
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", longStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,13 +118,17 @@ TEST(trace, TooLong)
|
||||||
#define TOO_LONG_SIZE 9400
|
#define TOO_LONG_SIZE 9400
|
||||||
#define TRACE_LINE_SIZE 1024
|
#define TRACE_LINE_SIZE 1024
|
||||||
char longStr[TOO_LONG_SIZE] = {0};
|
char longStr[TOO_LONG_SIZE] = {0};
|
||||||
for(int i=0;i<TOO_LONG_SIZE;i++) { longStr[i] = 0x36; }
|
for (int i = 0; i < TOO_LONG_SIZE; i++) {
|
||||||
|
longStr[i] = 0x36;
|
||||||
|
}
|
||||||
|
|
||||||
mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL);
|
mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL);
|
||||||
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", longStr);
|
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", longStr);
|
||||||
|
|
||||||
char shouldStr[TRACE_LINE_SIZE] = "[DBG ][mygr]: ";
|
char shouldStr[TRACE_LINE_SIZE] = "[DBG ][mygr]: ";
|
||||||
for(int i=14;i<TRACE_LINE_SIZE;i++) { shouldStr[i] = 0x36; }
|
for (int i = 14; i < TRACE_LINE_SIZE; i++) {
|
||||||
|
shouldStr[i] = 0x36;
|
||||||
|
}
|
||||||
shouldStr[TRACE_LINE_SIZE - 1] = 0;
|
shouldStr[TRACE_LINE_SIZE - 1] = 0;
|
||||||
STRCMP_EQUAL(shouldStr, buf);
|
STRCMP_EQUAL(shouldStr, buf);
|
||||||
}
|
}
|
||||||
|
@ -239,6 +245,9 @@ TEST(trace, config_change)
|
||||||
TEST(trace, active_level_all_color)
|
TEST(trace, active_level_all_color)
|
||||||
{
|
{
|
||||||
mbed_trace_config_set(TRACE_MODE_COLOR | TRACE_ACTIVE_LEVEL_ALL);
|
mbed_trace_config_set(TRACE_MODE_COLOR | TRACE_ACTIVE_LEVEL_ALL);
|
||||||
|
// unknown debug level
|
||||||
|
mbed_tracef(TRACE_LEVEL_DEBUG + 1, "mygr", "hep");
|
||||||
|
STRCMP_EQUAL(" hep", buf);
|
||||||
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hello");
|
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hello");
|
||||||
STRCMP_EQUAL("\x1b[90m[DBG ][mygr]: hello\x1b[0m", buf);
|
STRCMP_EQUAL("\x1b[90m[DBG ][mygr]: hello\x1b[0m", buf);
|
||||||
mbed_tracef(TRACE_LEVEL_INFO, "mygr", "to one");
|
mbed_tracef(TRACE_LEVEL_INFO, "mygr", "to one");
|
||||||
|
@ -269,6 +278,10 @@ TEST(trace, active_level_debug)
|
||||||
{
|
{
|
||||||
mbed_trace_config_set(TRACE_ACTIVE_LEVEL_DEBUG);
|
mbed_trace_config_set(TRACE_ACTIVE_LEVEL_DEBUG);
|
||||||
|
|
||||||
|
// unknown debug level
|
||||||
|
mbed_tracef(TRACE_LEVEL_DEBUG + 1, "mygr", "hep");
|
||||||
|
STRCMP_EQUAL(" hep", buf);
|
||||||
|
|
||||||
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hep");
|
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hep");
|
||||||
STRCMP_EQUAL("[DBG ][mygr]: hep", buf);
|
STRCMP_EQUAL("[DBG ][mygr]: hep", buf);
|
||||||
|
|
||||||
|
@ -396,7 +409,8 @@ TEST(trace, active_level_all_array)
|
||||||
|
|
||||||
size_t time_length;
|
size_t time_length;
|
||||||
char trace_prefix_str[] = "[<TIME>]";
|
char trace_prefix_str[] = "[<TIME>]";
|
||||||
char* trace_prefix(size_t length){
|
char *trace_prefix(size_t length)
|
||||||
|
{
|
||||||
time_length = length;
|
time_length = length;
|
||||||
return trace_prefix_str;
|
return trace_prefix_str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,31 +186,31 @@ NS_INLINE uint16_t common_read_16_bit_inverse(const uint8_t data_buf[__static 2]
|
||||||
/*
|
/*
|
||||||
* Count bits in a byte
|
* Count bits in a byte
|
||||||
*
|
*
|
||||||
* \param byte byte to inspect
|
* \param value byte to inspect
|
||||||
*
|
*
|
||||||
* \return number of 1-bits in byte
|
* \return number of 1-bits in byte
|
||||||
*/
|
*/
|
||||||
NS_INLINE uint_fast8_t common_count_bits(uint8_t byte);
|
NS_INLINE uint_fast8_t common_count_bits(uint8_t value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Count leading zeros in a byte
|
* Count leading zeros in a byte
|
||||||
*
|
*
|
||||||
* \deprecated Use common_count_leading_zeros_8
|
* \deprecated Use common_count_leading_zeros_8
|
||||||
*
|
*
|
||||||
* \param byte byte to inspect
|
* \param value byte to inspect
|
||||||
*
|
*
|
||||||
* \return number of leading zeros in byte (0-8)
|
* \return number of leading zeros in byte (0-8)
|
||||||
*/
|
*/
|
||||||
NS_INLINE uint_fast8_t common_count_leading_zeros(uint8_t byte);
|
NS_INLINE uint_fast8_t common_count_leading_zeros(uint8_t value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Count leading zeros in a byte
|
* Count leading zeros in a byte
|
||||||
*
|
*
|
||||||
* \param byte byte to inspect
|
* \param value byte to inspect
|
||||||
*
|
*
|
||||||
* \return number of leading zeros in byte (0-8)
|
* \return number of leading zeros in byte (0-8)
|
||||||
*/
|
*/
|
||||||
NS_INLINE uint_fast8_t common_count_leading_zeros_8(uint8_t byte);
|
NS_INLINE uint_fast8_t common_count_leading_zeros_8(uint8_t value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Count leading zeros in a 16-bit value
|
* Count leading zeros in a 16-bit value
|
||||||
|
@ -490,11 +490,11 @@ COMMON_FUNCTIONS_FN uint16_t common_read_16_bit_inverse(const uint8_t data_buf[_
|
||||||
return temp_16;
|
return temp_16;
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMON_FUNCTIONS_FN uint_fast8_t common_count_bits(uint8_t byte)
|
COMMON_FUNCTIONS_FN uint_fast8_t common_count_bits(uint8_t value)
|
||||||
{
|
{
|
||||||
/* First step sets each bit pair to be count of bits (00,01,10) */
|
/* First step sets each bit pair to be count of bits (00,01,10) */
|
||||||
/* [00-00 = 00, 01-00 = 01, 10-01 = 01, 11-01 = 10] */
|
/* [00-00 = 00, 01-00 = 01, 10-01 = 01, 11-01 = 10] */
|
||||||
uint_fast8_t count = byte - ((byte >> 1) & 0x55);
|
uint_fast8_t count = value - ((value >> 1) & 0x55);
|
||||||
/* Add bit pairs to make each nibble contain count of bits (0-4) */
|
/* Add bit pairs to make each nibble contain count of bits (0-4) */
|
||||||
count = (count & 0x33) + ((count >> 2) & 0x33);
|
count = (count & 0x33) + ((count >> 2) & 0x33);
|
||||||
/* Final result is sum of nibbles (0-8) */
|
/* Final result is sum of nibbles (0-8) */
|
||||||
|
@ -502,31 +502,31 @@ COMMON_FUNCTIONS_FN uint_fast8_t common_count_bits(uint8_t byte)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMON_FUNCTIONS_FN uint_fast8_t common_count_leading_zeros(uint8_t byte)
|
COMMON_FUNCTIONS_FN uint_fast8_t common_count_leading_zeros(uint8_t value)
|
||||||
{
|
{
|
||||||
return common_count_leading_zeros_8(byte);
|
return common_count_leading_zeros_8(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMON_FUNCTIONS_FN uint_fast8_t common_count_leading_zeros_8(uint8_t byte)
|
COMMON_FUNCTIONS_FN uint_fast8_t common_count_leading_zeros_8(uint8_t value)
|
||||||
{
|
{
|
||||||
#ifdef __CC_ARM
|
#ifdef __CC_ARM
|
||||||
return byte ? __clz((unsigned int) byte << 24) : 8;
|
return value ? __clz((unsigned int) value << 24) : 8;
|
||||||
#elif defined __GNUC__
|
#elif defined __GNUC__
|
||||||
return byte ? __builtin_clz((unsigned int) byte << 24) : 8;
|
return value ? __builtin_clz((unsigned int) value << 24) : 8;
|
||||||
#else
|
#else
|
||||||
uint_fast8_t cnt = 0;
|
uint_fast8_t cnt = 0;
|
||||||
if (byte == 0) {
|
if (value == 0) {
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
if ((byte & 0xF0) == 0) {
|
if ((value & 0xF0) == 0) {
|
||||||
byte <<= 4;
|
value <<= 4;
|
||||||
cnt += 4;
|
cnt += 4;
|
||||||
}
|
}
|
||||||
if ((byte & 0xC0) == 0) {
|
if ((value & 0xC0) == 0) {
|
||||||
byte <<= 2;
|
value <<= 2;
|
||||||
cnt += 2;
|
cnt += 2;
|
||||||
}
|
}
|
||||||
if ((byte & 0x80) == 0) {
|
if ((value & 0x80) == 0) {
|
||||||
cnt += 1;
|
cnt += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ typedef int_fast32_t int_fast24_t;
|
||||||
#if defined __CC_ARM || defined __TASKING__
|
#if defined __CC_ARM || defined __TASKING__
|
||||||
#define alignas(n) __align(n)
|
#define alignas(n) __align(n)
|
||||||
#define __alignas_is_defined 1
|
#define __alignas_is_defined 1
|
||||||
#elif (__STDC_VERSION__ >= 201112L) || (defined __cplusplus && __cplusplus >= 201103L)
|
#elif (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) || (defined __cplusplus && __cplusplus >= 201103L)
|
||||||
#include <stdalign.h>
|
#include <stdalign.h>
|
||||||
#elif defined __GNUC__
|
#elif defined __GNUC__
|
||||||
#define alignas(n) __attribute__((__aligned__(n)))
|
#define alignas(n) __attribute__((__aligned__(n)))
|
||||||
|
|
|
@ -74,8 +74,7 @@ bool stoip6(const char *ip6addr, size_t len, void *dest)
|
||||||
coloncolon = field_no;
|
coloncolon = field_no;
|
||||||
q++;
|
q++;
|
||||||
len -= 2;
|
len -= 2;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
len -= 1;
|
len -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,11 +149,13 @@ int stoip6_prefix(const char *ip6addr, void *dest, int_fast16_t *prefix_len_out)
|
||||||
static bool is_hex(char c)
|
static bool is_hex(char c)
|
||||||
{
|
{
|
||||||
// 'A' (0x41) and 'a' (0x61) are mapped in the ASCII table in such a way that masking the 0x20 bit turn 'a' in 'A'
|
// 'A' (0x41) and 'a' (0x61) are mapped in the ASCII table in such a way that masking the 0x20 bit turn 'a' in 'A'
|
||||||
if ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F')
|
if ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F') {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9') {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,7 @@ TEST(ip6tos, ip6_prefix_tos_func)
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* Second test group for the old tests that were once lost */
|
/* Second test group for the old tests that were once lost */
|
||||||
|
|
||||||
const char string_addr[][40] =
|
const char string_addr[][40] = {
|
||||||
{
|
|
||||||
"2001:db8::1:0:0:1", // 1
|
"2001:db8::1:0:0:1", // 1
|
||||||
"2001:db8:aaaa:bbbb:cccc:dddd:eeee:1", // 2
|
"2001:db8:aaaa:bbbb:cccc:dddd:eeee:1", // 2
|
||||||
"2001:db8::1", // 3
|
"2001:db8::1", // 3
|
||||||
|
@ -81,8 +80,7 @@ const char string_addr[][40] =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const uint8_t hex_addr[][16] =
|
const uint8_t hex_addr[][16] = {
|
||||||
{
|
|
||||||
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 },
|
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 },
|
||||||
{ 0x20, 0x01, 0xd, 0xb8, 0xaa, 0xaa, 0xbb, 0xbb, 0xcc, 0xcc, 0xdd, 0xdd, 0xee, 0xee, 0x00, 0x01 },
|
{ 0x20, 0x01, 0xd, 0xb8, 0xaa, 0xaa, 0xbb, 0xbb, 0xcc, 0xcc, 0xdd, 0xdd, 0xee, 0xee, 0x00, 0x01 },
|
||||||
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||||||
|
@ -102,13 +100,11 @@ int i = 0;
|
||||||
|
|
||||||
TEST_GROUP(ip6tos_2)
|
TEST_GROUP(ip6tos_2)
|
||||||
{
|
{
|
||||||
void setUp(void)
|
void setUp(void) {
|
||||||
{
|
|
||||||
memset(buf, 0, 40);
|
memset(buf, 0, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tearDown(void)
|
void tearDown(void) {
|
||||||
{
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,7 +66,8 @@ TEST(dynmem, diff_alignment)
|
||||||
CHECK(NULL != heap);
|
CHECK(NULL != heap);
|
||||||
reset_heap_error();
|
reset_heap_error();
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
ptr++; size--;
|
ptr++;
|
||||||
|
size--;
|
||||||
ns_dyn_mem_init(ptr, size, &heap_fail_callback, &info);
|
ns_dyn_mem_init(ptr, size, &heap_fail_callback, &info);
|
||||||
CHECK(info.heap_sector_size >= (size - 72));
|
CHECK(info.heap_sector_size >= (size - 72));
|
||||||
CHECK(!heap_have_failed());
|
CHECK(!heap_have_failed());
|
||||||
|
@ -89,9 +90,10 @@ TEST(dynmem, ns_dyn_mem_alloc)
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
p[i] = ns_dyn_mem_alloc(block);
|
p[i] = ns_dyn_mem_alloc(block);
|
||||||
if (!p[i])
|
if (!p[i]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
CHECK(!heap_have_failed());
|
CHECK(!heap_have_failed());
|
||||||
CHECK(info.heap_alloc_fail_cnt == 1);
|
CHECK(info.heap_alloc_fail_cnt == 1);
|
||||||
CHECK(info.heap_sector_alloc_cnt == i);
|
CHECK(info.heap_sector_alloc_cnt == i);
|
||||||
|
@ -120,9 +122,10 @@ TEST(dynmem, ns_dyn_mem_temporary_alloc)
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
p[i] = ns_dyn_mem_temporary_alloc(block);
|
p[i] = ns_dyn_mem_temporary_alloc(block);
|
||||||
if (!p[i])
|
if (!p[i]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
CHECK(!heap_have_failed());
|
CHECK(!heap_have_failed());
|
||||||
CHECK(info.heap_alloc_fail_cnt == 1);
|
CHECK(info.heap_alloc_fail_cnt == 1);
|
||||||
CHECK(info.heap_sector_alloc_cnt == i);
|
CHECK(info.heap_sector_alloc_cnt == i);
|
||||||
|
@ -211,7 +214,8 @@ TEST(dynmem, ns_dyn_mem_temporary_alloc_with_heap_threshold)
|
||||||
free(heap);
|
free(heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(dynmem, test_both_allocs_with_hole_usage) {
|
TEST(dynmem, test_both_allocs_with_hole_usage)
|
||||||
|
{
|
||||||
uint16_t size = 112;
|
uint16_t size = 112;
|
||||||
mem_stat_t info;
|
mem_stat_t info;
|
||||||
void *p[size];
|
void *p[size];
|
||||||
|
@ -240,7 +244,8 @@ TEST(dynmem, test_both_allocs_with_hole_usage) {
|
||||||
free(heap);
|
free(heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(dynmem, test_temp_alloc_with_skipping_hole) {
|
TEST(dynmem, test_temp_alloc_with_skipping_hole)
|
||||||
|
{
|
||||||
uint16_t size = 1000;
|
uint16_t size = 1000;
|
||||||
mem_stat_t info;
|
mem_stat_t info;
|
||||||
void *p[size];
|
void *p[size];
|
||||||
|
@ -315,7 +320,8 @@ TEST(dynmem, corrupted_memory)
|
||||||
free(heap);
|
free(heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(dynmem, no_big_enough_sector) {
|
TEST(dynmem, no_big_enough_sector)
|
||||||
|
{
|
||||||
uint16_t size = 112;
|
uint16_t size = 112;
|
||||||
mem_stat_t info;
|
mem_stat_t info;
|
||||||
uint8_t *heap = (uint8_t *)malloc(size);
|
uint8_t *heap = (uint8_t *)malloc(size);
|
||||||
|
@ -487,7 +493,8 @@ TEST(dynmem, not_negative_stats)
|
||||||
free(heap);
|
free(heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(dynmem, test_invalid_pointer_freed) {
|
TEST(dynmem, test_invalid_pointer_freed)
|
||||||
|
{
|
||||||
uint16_t size = 92;
|
uint16_t size = 92;
|
||||||
uint8_t *heap = (uint8_t *)malloc(size);
|
uint8_t *heap = (uint8_t *)malloc(size);
|
||||||
CHECK(NULL != heap);
|
CHECK(NULL != heap);
|
||||||
|
@ -503,7 +510,8 @@ TEST(dynmem, test_invalid_pointer_freed) {
|
||||||
free(heap);
|
free(heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(dynmem, test_merge_corrupted_previous_block) {
|
TEST(dynmem, test_merge_corrupted_previous_block)
|
||||||
|
{
|
||||||
uint16_t size = 1000;
|
uint16_t size = 1000;
|
||||||
uint8_t *heap = (uint8_t *)malloc(size);
|
uint8_t *heap = (uint8_t *)malloc(size);
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
@ -524,7 +532,8 @@ TEST(dynmem, test_merge_corrupted_previous_block) {
|
||||||
free(heap);
|
free(heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(dynmem, test_free_corrupted_next_block) {
|
TEST(dynmem, test_free_corrupted_next_block)
|
||||||
|
{
|
||||||
uint16_t size = 1000;
|
uint16_t size = 1000;
|
||||||
uint8_t *heap = (uint8_t *)malloc(size);
|
uint8_t *heap = (uint8_t *)malloc(size);
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
@ -546,7 +555,8 @@ TEST(dynmem, test_free_corrupted_next_block) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE! This test must be last!
|
//NOTE! This test must be last!
|
||||||
TEST(dynmem, uninitialized_test){
|
TEST(dynmem, uninitialized_test)
|
||||||
|
{
|
||||||
void *p = ns_dyn_mem_alloc(4);
|
void *p = ns_dyn_mem_alloc(4);
|
||||||
ns_dyn_mem_free(p);
|
ns_dyn_mem_free(p);
|
||||||
CHECK(p == NULL);
|
CHECK(p == NULL);
|
||||||
|
|
|
@ -19,15 +19,18 @@
|
||||||
heap_fail_t current_heap_error;
|
heap_fail_t current_heap_error;
|
||||||
static bool failed;
|
static bool failed;
|
||||||
|
|
||||||
void heap_fail_callback(heap_fail_t err) {
|
void heap_fail_callback(heap_fail_t err)
|
||||||
|
{
|
||||||
current_heap_error = err;
|
current_heap_error = err;
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_heap_error() {
|
void reset_heap_error()
|
||||||
|
{
|
||||||
failed = false;
|
failed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool heap_have_failed() {
|
bool heap_have_failed()
|
||||||
|
{
|
||||||
return failed;
|
return failed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,8 +106,7 @@ TEST(stoip6, InvalidAddresses)
|
||||||
uint8_t ip[16];
|
uint8_t ip[16];
|
||||||
uint8_t correct[16] = {0};
|
uint8_t correct[16] = {0};
|
||||||
|
|
||||||
const char *invalidArray[] =
|
const char *invalidArray[] = {
|
||||||
{
|
|
||||||
"FFFF:FFFF::FFFF::FFFF", // Two ::
|
"FFFF:FFFF::FFFF::FFFF", // Two ::
|
||||||
"F:F:F:FqF:F:F:F:F", // Non-hex character
|
"F:F:F:FqF:F:F:F:F", // Non-hex character
|
||||||
"F:F:F:FFFFF:F:F:F:F" // >4 hex characters in a segment
|
"F:F:F:FFFFF:F:F:F:F" // >4 hex characters in a segment
|
||||||
|
@ -122,8 +121,7 @@ TEST(stoip6, InvalidAddresses)
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* Second test group for the old tests that were once lost */
|
/* Second test group for the old tests that were once lost */
|
||||||
|
|
||||||
const char string_addr[][40] =
|
const char string_addr[][40] = {
|
||||||
{
|
|
||||||
"2001:db8::1:0:0:1", // 1
|
"2001:db8::1:0:0:1", // 1
|
||||||
"2001:db8:aaaa:bbbb:cccc:dddd:eeee:1", // 2
|
"2001:db8:aaaa:bbbb:cccc:dddd:eeee:1", // 2
|
||||||
"2001:db8::1", // 3
|
"2001:db8::1", // 3
|
||||||
|
@ -139,8 +137,7 @@ const char string_addr[][40] =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const uint8_t hex_addr[][16] =
|
const uint8_t hex_addr[][16] = {
|
||||||
{
|
|
||||||
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 },
|
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 },
|
||||||
{ 0x20, 0x01, 0xd, 0xb8, 0xaa, 0xaa, 0xbb, 0xbb, 0xcc, 0xcc, 0xdd, 0xdd, 0xee, 0xee, 0x00, 0x01 },
|
{ 0x20, 0x01, 0xd, 0xb8, 0xaa, 0xaa, 0xbb, 0xbb, 0xcc, 0xcc, 0xdd, 0xdd, 0xee, 0xee, 0x00, 0x01 },
|
||||||
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||||||
|
@ -160,13 +157,11 @@ int i = 0;
|
||||||
|
|
||||||
TEST_GROUP(stoip6_2)
|
TEST_GROUP(stoip6_2)
|
||||||
{
|
{
|
||||||
void setUp(void)
|
void setUp(void) {
|
||||||
{
|
|
||||||
memset(buf, 0, 40);
|
memset(buf, 0, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tearDown(void)
|
void tearDown(void) {
|
||||||
{
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -240,8 +235,7 @@ TEST(stoip6_2, test_2_12)
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* Third test group for stoip6_prefix */
|
/* Third test group for stoip6_prefix */
|
||||||
|
|
||||||
const char string_prefix_addr[][40] =
|
const char string_prefix_addr[][40] = {
|
||||||
{
|
|
||||||
"2001:db8::1:0:0:1/64", // 1
|
"2001:db8::1:0:0:1/64", // 1
|
||||||
"2001::/60", // 2
|
"2001::/60", // 2
|
||||||
"::1/48", // 3
|
"::1/48", // 3
|
||||||
|
@ -254,8 +248,7 @@ const char string_prefix_addr[][40] =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const uint8_t hex_prefix_addr[][16] =
|
const uint8_t hex_prefix_addr[][16] = {
|
||||||
{
|
|
||||||
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, // 1
|
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, // 1
|
||||||
{ 0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 2
|
{ 0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 2
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, // 3
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, // 3
|
||||||
|
|
|
@ -31,26 +31,20 @@ void ns_dyn_mem_init(void *heap, ns_mem_heap_size_t h_size, void (*passed_fptr)(
|
||||||
|
|
||||||
void *ns_dyn_mem_alloc(ns_mem_block_size_t alloc_size)
|
void *ns_dyn_mem_alloc(ns_mem_block_size_t alloc_size)
|
||||||
{
|
{
|
||||||
if (nsdynmemlib_stub.returnCounter > 0)
|
if (nsdynmemlib_stub.returnCounter > 0) {
|
||||||
{
|
|
||||||
nsdynmemlib_stub.returnCounter--;
|
nsdynmemlib_stub.returnCounter--;
|
||||||
return malloc(alloc_size);
|
return malloc(alloc_size);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return (nsdynmemlib_stub.expectedPointer);
|
return (nsdynmemlib_stub.expectedPointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ns_dyn_mem_temporary_alloc(ns_mem_block_size_t alloc_size)
|
void *ns_dyn_mem_temporary_alloc(ns_mem_block_size_t alloc_size)
|
||||||
{
|
{
|
||||||
if (nsdynmemlib_stub.returnCounter > 0)
|
if (nsdynmemlib_stub.returnCounter > 0) {
|
||||||
{
|
|
||||||
nsdynmemlib_stub.returnCounter--;
|
nsdynmemlib_stub.returnCounter--;
|
||||||
return malloc(alloc_size);
|
return malloc(alloc_size);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return (nsdynmemlib_stub.expectedPointer);
|
return (nsdynmemlib_stub.expectedPointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,8 +282,6 @@ extern int8_t coap_service_response_send(int8_t service_id, uint8_t options, sn_
|
||||||
*/
|
*/
|
||||||
extern int8_t coap_service_response_send_by_msg_id(int8_t service_id, uint8_t options, uint16_t msg_id, sn_coap_msg_code_e message_code, sn_coap_content_format_e content_type, const uint8_t *payload_ptr, uint16_t payload_len);
|
extern int8_t coap_service_response_send_by_msg_id(int8_t service_id, uint8_t options, uint16_t msg_id, sn_coap_msg_code_e message_code, sn_coap_content_format_e content_type, const uint8_t *payload_ptr, uint16_t payload_len);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Delete CoAP request transaction
|
* \brief Delete CoAP request transaction
|
||||||
*
|
*
|
||||||
|
@ -297,6 +295,15 @@ extern int8_t coap_service_response_send_by_msg_id(int8_t service_id, uint8_t op
|
||||||
*/
|
*/
|
||||||
extern int8_t coap_service_request_delete(int8_t service_id, uint16_t msg_id);
|
extern int8_t coap_service_request_delete(int8_t service_id, uint16_t msg_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Delete CoAP requests from service id
|
||||||
|
*
|
||||||
|
* Removes pending CoAP requests from service specified by service_id.
|
||||||
|
*
|
||||||
|
* \param service_id Id number of the current service.
|
||||||
|
*/
|
||||||
|
extern void coap_service_request_delete_by_service_id(int8_t service_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set DTLS handshake timeout values
|
* \brief Set DTLS handshake timeout values
|
||||||
*
|
*
|
||||||
|
|
|
@ -230,7 +230,8 @@ static secure_session_t *secure_session_create(internal_socket_t *parent, const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void clear_secure_sessions(internal_socket_t *this){
|
static void clear_secure_sessions(internal_socket_t *this)
|
||||||
|
{
|
||||||
if (this) {
|
if (this) {
|
||||||
ns_list_foreach_safe(secure_session_t, cur_ptr, &secure_session_list) {
|
ns_list_foreach_safe(secure_session_t, cur_ptr, &secure_session_list) {
|
||||||
if (cur_ptr->parent == this) {
|
if (cur_ptr->parent == this) {
|
||||||
|
@ -316,13 +317,19 @@ static internal_socket_t *int_socket_create(uint16_t listen_port, bool use_ephem
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_LINK_LAYER_SECURITY, &(const int8_t) {bypassSec ? 0 : 1}, sizeof(int8_t));
|
socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_LINK_LAYER_SECURITY, &(const int8_t) {
|
||||||
|
bypassSec ? 0 : 1
|
||||||
|
}, sizeof(int8_t));
|
||||||
|
|
||||||
// XXX API for this? May want to get clever to do recommended first query = 1 hop, retries = whole PAN
|
// XXX API for this? May want to get clever to do recommended first query = 1 hop, retries = whole PAN
|
||||||
socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_MULTICAST_HOPS, &(const int16_t) {16}, sizeof(int16_t));
|
socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_MULTICAST_HOPS, &(const int16_t) {
|
||||||
|
16
|
||||||
|
}, sizeof(int16_t));
|
||||||
|
|
||||||
// Set socket option to receive packet info
|
// Set socket option to receive packet info
|
||||||
socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_RECVPKTINFO, &(const bool) {1}, sizeof(bool));
|
socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_RECVPKTINFO, &(const bool) {
|
||||||
|
1
|
||||||
|
}, sizeof(bool));
|
||||||
if (socket_interface_selection > 0) {
|
if (socket_interface_selection > 0) {
|
||||||
// Interface selection requested as socket_interface_selection set
|
// Interface selection requested as socket_interface_selection set
|
||||||
socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_INTERFACE_SELECT, &socket_interface_selection, sizeof(socket_interface_selection));
|
socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_INTERFACE_SELECT, &socket_interface_selection, sizeof(socket_interface_selection));
|
||||||
|
@ -430,8 +437,9 @@ static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf
|
||||||
if (!sock->real_socket) {
|
if (!sock->real_socket) {
|
||||||
// Send to virtual socket cb
|
// Send to virtual socket cb
|
||||||
int ret = sock->parent->_send_cb(sock->socket, session->remote_host.address, session->remote_host.identifier, buf, len);
|
int ret = sock->parent->_send_cb(sock->socket, session->remote_host.address, session->remote_host.identifier, buf, len);
|
||||||
if( ret < 0 )
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,12 +494,10 @@ static void timer_cb(void *param)
|
||||||
if (MBEDTLS_ERR_SSL_TIMEOUT == error) {
|
if (MBEDTLS_ERR_SSL_TIMEOUT == error) {
|
||||||
//TODO: How do we handle timeouts?
|
//TODO: How do we handle timeouts?
|
||||||
secure_session_delete(sec);
|
secure_session_delete(sec);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
sec->timer.timer = eventOS_timeout_ms(timer_cb, sec->timer.int_ms, (void *)sec);
|
sec->timer.timer = eventOS_timeout_ms(timer_cb, sec->timer.int_ms, (void *)sec);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
/* We have counted the number of cycles - finish */
|
/* We have counted the number of cycles - finish */
|
||||||
eventOS_timeout_cancel(sec->timer.timer);
|
eventOS_timeout_cancel(sec->timer.timer);
|
||||||
sec->timer.fin_ms = 0;
|
sec->timer.fin_ms = 0;
|
||||||
|
@ -776,8 +782,7 @@ int coap_connection_handler_virtual_recv(coap_conn_handler_t *handler, uint8_t a
|
||||||
(void *)coap_security_handler_keyblock(session->sec_handler));
|
(void *)coap_security_handler_keyblock(session->sec_handler));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (ret < 0) {
|
||||||
else if (ret < 0) {
|
|
||||||
// error handling
|
// error handling
|
||||||
// TODO: here we also should clear CoAP retransmission buffer and inform that CoAP request sending is failed.
|
// TODO: here we also should clear CoAP retransmission buffer and inform that CoAP request sending is failed.
|
||||||
secure_session_delete(session);
|
secure_session_delete(session);
|
||||||
|
@ -1001,7 +1006,7 @@ void coap_connection_handler_exec(uint32_t time)
|
||||||
{
|
{
|
||||||
if (ns_list_count(&secure_session_list)) {
|
if (ns_list_count(&secure_session_list)) {
|
||||||
// Seek & destroy old sessions where close notify have been sent
|
// Seek & destroy old sessions where close notify have been sent
|
||||||
ns_list_foreach(secure_session_t, cur_ptr, &secure_session_list) {
|
ns_list_foreach_safe(secure_session_t, cur_ptr, &secure_session_list) {
|
||||||
if (cur_ptr->session_state == SECURE_SESSION_CLOSED) {
|
if (cur_ptr->session_state == SECURE_SESSION_CLOSED) {
|
||||||
if ((cur_ptr->last_contact_time + CLOSED_SECURE_SESSION_TIMEOUT) <= time) {
|
if ((cur_ptr->last_contact_time + CLOSED_SECURE_SESSION_TIMEOUT) <= time) {
|
||||||
secure_session_delete(cur_ptr);
|
secure_session_delete(cur_ptr);
|
||||||
|
|
|
@ -98,6 +98,18 @@ static coap_transaction_t *transaction_find_by_address(uint8_t *address_ptr, uin
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static coap_transaction_t *transaction_find_by_service_id(int8_t service_id)
|
||||||
|
{
|
||||||
|
coap_transaction_t *this = NULL;
|
||||||
|
ns_list_foreach(coap_transaction_t, cur_ptr, &request_list) {
|
||||||
|
if (cur_ptr->service_id == service_id) {
|
||||||
|
this = cur_ptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/* retransmission valid time is calculated to be max. time that CoAP message sending can take: */
|
/* retransmission valid time is calculated to be max. time that CoAP message sending can take: */
|
||||||
/* Number of retransmisisons, each retransmission is 2 * previous retransmisison time */
|
/* Number of retransmisisons, each retransmission is 2 * previous retransmisison time */
|
||||||
/* + random factor (max. 1.5) */
|
/* + random factor (max. 1.5) */
|
||||||
|
@ -160,6 +172,21 @@ void transactions_delete_all(uint8_t *address_ptr, uint16_t port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void transactions_delete_all_by_service_id(int8_t service_id)
|
||||||
|
{
|
||||||
|
coap_transaction_t *transaction = transaction_find_by_service_id(service_id);
|
||||||
|
|
||||||
|
while (transaction) {
|
||||||
|
ns_list_remove(&request_list, transaction);
|
||||||
|
if (transaction->resp_cb) {
|
||||||
|
transaction->resp_cb(transaction->service_id, transaction->remote_address, transaction->remote_port, NULL);
|
||||||
|
}
|
||||||
|
sn_coap_protocol_delete_retransmission(coap_service_handle->coap, transaction->msg_id);
|
||||||
|
transaction_free(transaction);
|
||||||
|
transaction = transaction_find_by_service_id(service_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int8_t coap_rx_function(sn_coap_hdr_s *resp_ptr, sn_nsdl_addr_s *address_ptr, void *param)
|
static int8_t coap_rx_function(sn_coap_hdr_s *resp_ptr, sn_nsdl_addr_s *address_ptr, void *param)
|
||||||
{
|
{
|
||||||
coap_transaction_t *this = NULL;
|
coap_transaction_t *this = NULL;
|
||||||
|
@ -189,7 +216,8 @@ static int8_t coap_rx_function(sn_coap_hdr_s *resp_ptr, sn_nsdl_addr_s *address_
|
||||||
}
|
}
|
||||||
|
|
||||||
coap_msg_handler_t *coap_message_handler_init(void *(*used_malloc_func_ptr)(uint16_t), void (*used_free_func_ptr)(void *),
|
coap_msg_handler_t *coap_message_handler_init(void *(*used_malloc_func_ptr)(uint16_t), void (*used_free_func_ptr)(void *),
|
||||||
uint8_t (*used_tx_callback_ptr)(uint8_t *, uint16_t, sn_nsdl_addr_s *, void *)){
|
uint8_t (*used_tx_callback_ptr)(uint8_t *, uint16_t, sn_nsdl_addr_s *, void *))
|
||||||
|
{
|
||||||
|
|
||||||
if ((used_malloc_func_ptr == NULL) || (used_free_func_ptr == NULL) || (used_tx_callback_ptr == NULL)) {
|
if ((used_malloc_func_ptr == NULL) || (used_free_func_ptr == NULL) || (used_tx_callback_ptr == NULL)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -226,7 +254,8 @@ coap_msg_handler_t *coap_message_handler_init(void *(*used_malloc_func_ptr)(uint
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t coap_message_handler_destroy(coap_msg_handler_t *handle){
|
int8_t coap_message_handler_destroy(coap_msg_handler_t *handle)
|
||||||
|
{
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -258,8 +287,9 @@ coap_transaction_t *coap_message_handler_transaction_valid(coap_transaction_t *t
|
||||||
|
|
||||||
coap_transaction_t *coap_message_handler_find_transaction(uint8_t *address_ptr, uint16_t port)
|
coap_transaction_t *coap_message_handler_find_transaction(uint8_t *address_ptr, uint16_t port)
|
||||||
{
|
{
|
||||||
if( !address_ptr )
|
if (!address_ptr) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
return transaction_find_by_address(address_ptr, port);
|
return transaction_find_by_address(address_ptr, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +352,7 @@ int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t
|
||||||
goto exit;
|
goto exit;
|
||||||
/* Response received */
|
/* Response received */
|
||||||
} else {
|
} else {
|
||||||
|
transaction_delete(transaction_ptr); // transaction_ptr not needed in response
|
||||||
if (coap_message->token_ptr) {
|
if (coap_message->token_ptr) {
|
||||||
this = transaction_find_client_by_token(coap_message->token_ptr, coap_message->token_len, source_addr_ptr, port);
|
this = transaction_find_client_by_token(coap_message->token_ptr, coap_message->token_len, source_addr_ptr, port);
|
||||||
}
|
}
|
||||||
|
@ -551,6 +582,7 @@ int8_t coap_message_handler_request_delete(coap_msg_handler_t *handle, int8_t se
|
||||||
tr_error("invalid params");
|
tr_error("invalid params");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sn_coap_protocol_delete_retransmission(handle->coap, msg_id);
|
sn_coap_protocol_delete_retransmission(handle->coap, msg_id);
|
||||||
|
|
||||||
transaction_ptr = transaction_find_client(msg_id);
|
transaction_ptr = transaction_find_client(msg_id);
|
||||||
|
@ -558,11 +590,30 @@ int8_t coap_message_handler_request_delete(coap_msg_handler_t *handle, int8_t se
|
||||||
tr_error("response transaction not found");
|
tr_error("response transaction not found");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (transaction_ptr->resp_cb) {
|
||||||
|
transaction_ptr->resp_cb(transaction_ptr->service_id, transaction_ptr->remote_address, transaction_ptr->remote_port, NULL);
|
||||||
|
}
|
||||||
transaction_delete(transaction_ptr);
|
transaction_delete(transaction_ptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t current_time){
|
int8_t coap_message_handler_request_delete_by_service_id(coap_msg_handler_t *handle, int8_t service_id)
|
||||||
|
{
|
||||||
|
tr_debug("Service %d, delete all CoAP requests", service_id);
|
||||||
|
|
||||||
|
if (!handle) {
|
||||||
|
tr_error("invalid params");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions_delete_all_by_service_id(service_id);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t current_time)
|
||||||
|
{
|
||||||
|
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -93,7 +93,8 @@ int entropy_poll( void *data, unsigned char *output, size_t len, size_t *olen );
|
||||||
int f_send(void *ctx, const unsigned char *buf, size_t len);
|
int f_send(void *ctx, const unsigned char *buf, size_t len);
|
||||||
int f_recv(void *ctx, unsigned char *buf, size_t len);
|
int f_recv(void *ctx, unsigned char *buf, size_t len);
|
||||||
|
|
||||||
static int coap_security_handler_init(coap_security_t *sec){
|
static int coap_security_handler_init(coap_security_t *sec)
|
||||||
|
{
|
||||||
const char *pers = "dtls_client";
|
const char *pers = "dtls_client";
|
||||||
#ifdef COAP_SERVICE_PROVIDE_STRONG_ENTROPY_SOURCE
|
#ifdef COAP_SERVICE_PROVIDE_STRONG_ENTROPY_SOURCE
|
||||||
const int entropy_source_type = MBEDTLS_ENTROPY_SOURCE_STRONG;
|
const int entropy_source_type = MBEDTLS_ENTROPY_SOURCE_STRONG;
|
||||||
|
@ -124,8 +125,7 @@ static int coap_security_handler_init(coap_security_t *sec){
|
||||||
|
|
||||||
if ((mbedtls_ctr_drbg_seed(&sec->_ctr_drbg, mbedtls_entropy_func, &sec->_entropy,
|
if ((mbedtls_ctr_drbg_seed(&sec->_ctr_drbg, mbedtls_entropy_func, &sec->_entropy,
|
||||||
(const unsigned char *) pers,
|
(const unsigned char *) pers,
|
||||||
strlen( pers ) ) ) != 0 )
|
strlen(pers))) != 0) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -141,7 +141,8 @@ const void *coap_security_handler_keyblock(const coap_security_t *sec)
|
||||||
return sec->_keyblk.value;
|
return sec->_keyblk.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void coap_security_handler_reset(coap_security_t *sec){
|
static void coap_security_handler_reset(coap_security_t *sec)
|
||||||
|
{
|
||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
mbedtls_x509_crt_free(&sec->_cacert);
|
mbedtls_x509_crt_free(&sec->_cacert);
|
||||||
mbedtls_x509_crt_free(&sec->_owncert);
|
mbedtls_x509_crt_free(&sec->_owncert);
|
||||||
|
@ -187,7 +188,8 @@ coap_security_t *coap_security_create(int8_t socket_id, int8_t timer_id, void *h
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void coap_security_destroy(coap_security_t *sec){
|
void coap_security_destroy(coap_security_t *sec)
|
||||||
|
{
|
||||||
if (sec) {
|
if (sec) {
|
||||||
coap_security_handler_reset(sec);
|
coap_security_handler_reset(sec);
|
||||||
ns_dyn_mem_free(sec);
|
ns_dyn_mem_free(sec);
|
||||||
|
@ -367,22 +369,19 @@ int coap_security_handler_connect_non_blocking(coap_security_t *sec, bool is_ser
|
||||||
|
|
||||||
if ((mbedtls_ssl_config_defaults(&sec->_conf,
|
if ((mbedtls_ssl_config_defaults(&sec->_conf,
|
||||||
endpoint,
|
endpoint,
|
||||||
mode, 0 ) ) != 0 )
|
mode, 0)) != 0) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!timeout_max && !timeout_min) {
|
if (!timeout_max && !timeout_min) {
|
||||||
mbedtls_ssl_conf_handshake_timeout(&sec->_conf, DTLS_HANDSHAKE_TIMEOUT_MIN, DTLS_HANDSHAKE_TIMEOUT_MAX);
|
mbedtls_ssl_conf_handshake_timeout(&sec->_conf, DTLS_HANDSHAKE_TIMEOUT_MIN, DTLS_HANDSHAKE_TIMEOUT_MAX);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
mbedtls_ssl_conf_handshake_timeout(&sec->_conf, timeout_min, timeout_max);
|
mbedtls_ssl_conf_handshake_timeout(&sec->_conf, timeout_min, timeout_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_ssl_conf_rng(&sec->_conf, mbedtls_ctr_drbg_random, &sec->_ctr_drbg);
|
mbedtls_ssl_conf_rng(&sec->_conf, mbedtls_ctr_drbg_random, &sec->_ctr_drbg);
|
||||||
|
|
||||||
if( ( mbedtls_ssl_setup( &sec->_ssl, &sec->_conf ) ) != 0 )
|
if ((mbedtls_ssl_setup(&sec->_ssl, &sec->_conf)) != 0) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +432,8 @@ int coap_security_handler_connect_non_blocking(coap_security_t *sec, bool is_ser
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int coap_security_handler_continue_connecting(coap_security_t *sec){
|
int coap_security_handler_continue_connecting(coap_security_t *sec)
|
||||||
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
while (ret != MBEDTLS_ERR_SSL_WANT_READ) {
|
while (ret != MBEDTLS_ERR_SSL_WANT_READ) {
|
||||||
|
@ -446,8 +446,7 @@ int coap_security_handler_continue_connecting(coap_security_t *sec){
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
} else if (ret && (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE)) {
|
||||||
else if(ret && (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE)){
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,12 +463,14 @@ int coap_security_handler_continue_connecting(coap_security_t *sec){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int coap_security_handler_send_message(coap_security_t *sec, unsigned char *message, size_t len){
|
int coap_security_handler_send_message(coap_security_t *sec, unsigned char *message, size_t len)
|
||||||
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (sec) {
|
if (sec) {
|
||||||
do ret = mbedtls_ssl_write( &sec->_ssl, (unsigned char *) message, len );
|
do {
|
||||||
while( ret == MBEDTLS_ERR_SSL_WANT_READ ||
|
ret = mbedtls_ssl_write(&sec->_ssl, (unsigned char *) message, len);
|
||||||
|
} while (ret == MBEDTLS_ERR_SSL_WANT_READ ||
|
||||||
ret == MBEDTLS_ERR_SSL_WANT_WRITE);
|
ret == MBEDTLS_ERR_SSL_WANT_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +489,8 @@ int coap_security_send_close_alert(coap_security_t *sec)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int coap_security_handler_read(coap_security_t *sec, unsigned char* buffer, size_t len){
|
int coap_security_handler_read(coap_security_t *sec, unsigned char *buffer, size_t len)
|
||||||
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int max_loops = 100;
|
int max_loops = 100;
|
||||||
|
|
||||||
|
@ -537,12 +539,14 @@ static int get_timer(void *sec_obj)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int f_send( void *ctx, const unsigned char *buf, size_t len){
|
int f_send(void *ctx, const unsigned char *buf, size_t len)
|
||||||
|
{
|
||||||
coap_security_t *sec = (coap_security_t *)ctx;
|
coap_security_t *sec = (coap_security_t *)ctx;
|
||||||
return sec->_send_cb(sec->_socket_id, sec->_handle, buf, len);
|
return sec->_send_cb(sec->_socket_id, sec->_handle, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int f_recv(void *ctx, unsigned char *buf, size_t len){
|
int f_recv(void *ctx, unsigned char *buf, size_t len)
|
||||||
|
{
|
||||||
coap_security_t *sec = (coap_security_t *)ctx;
|
coap_security_t *sec = (coap_security_t *)ctx;
|
||||||
return sec->_receive_cb(sec->_socket_id, buf, len);
|
return sec->_receive_cb(sec->_socket_id, buf, len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,9 +201,10 @@ static void service_event_handler(arm_event_s *event)
|
||||||
tr_debug("service tasklet initialised");
|
tr_debug("service tasklet initialised");
|
||||||
/*initialize coap service and listen socket*/
|
/*initialize coap service and listen socket*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->event_type == ARM_LIB_SYSTEM_TIMER_EVENT && event->event_id == COAP_TICK_TIMER) {
|
if (event->event_type == ARM_LIB_SYSTEM_TIMER_EVENT && event->event_id == COAP_TICK_TIMER) {
|
||||||
coap_message_handler_exec(coap_service_handle, coap_ticks++);
|
coap_message_handler_exec(coap_service_handle, coap_ticks++);
|
||||||
if(coap_ticks && !coap_ticks % SECURE_SESSION_CLEAN_INTERVAL){
|
if (coap_ticks && !(coap_ticks % SECURE_SESSION_CLEAN_INTERVAL)) {
|
||||||
coap_connection_handler_exec(coap_ticks);
|
coap_connection_handler_exec(coap_ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -522,17 +523,20 @@ int8_t coap_service_unregister_uri(int8_t service_id, const char *uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t coap_service_request_send(int8_t service_id, uint8_t options, const uint8_t destination_addr[static 16], uint16_t destination_port, sn_coap_msg_type_e msg_type, sn_coap_msg_code_e msg_code, const char *uri,
|
uint16_t coap_service_request_send(int8_t service_id, uint8_t options, const uint8_t destination_addr[static 16], uint16_t destination_port, sn_coap_msg_type_e msg_type, sn_coap_msg_code_e msg_code, const char *uri,
|
||||||
sn_coap_content_format_e cont_type, const uint8_t *payload_ptr, uint16_t payload_len, coap_service_response_recv *request_response_cb){
|
sn_coap_content_format_e cont_type, const uint8_t *payload_ptr, uint16_t payload_len, coap_service_response_recv *request_response_cb)
|
||||||
|
{
|
||||||
//TODO: coap_service_response_recv is an ugly cast, this should be refactored away + sn_coap_hdr_s MUST NOT be exposed to users of coap-service!
|
//TODO: coap_service_response_recv is an ugly cast, this should be refactored away + sn_coap_hdr_s MUST NOT be exposed to users of coap-service!
|
||||||
//Callback would be still needed, but where to store callback?
|
//Callback would be still needed, but where to store callback?
|
||||||
return coap_message_handler_request_send(coap_service_handle, service_id, options, destination_addr, destination_port, msg_type, msg_code, uri, cont_type, payload_ptr, payload_len, request_response_cb);
|
return coap_message_handler_request_send(coap_service_handle, service_id, options, destination_addr, destination_port, msg_type, msg_code, uri, cont_type, payload_ptr, payload_len, request_response_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t coap_service_response_send(int8_t service_id, uint8_t options, sn_coap_hdr_s *request_ptr, sn_coap_msg_code_e message_code, sn_coap_content_format_e content_type, const uint8_t *payload_ptr,uint16_t payload_len){
|
int8_t coap_service_response_send(int8_t service_id, uint8_t options, sn_coap_hdr_s *request_ptr, sn_coap_msg_code_e message_code, sn_coap_content_format_e content_type, const uint8_t *payload_ptr, uint16_t payload_len)
|
||||||
|
{
|
||||||
return coap_message_handler_response_send(coap_service_handle, service_id, options, request_ptr, message_code, content_type, payload_ptr, payload_len);
|
return coap_message_handler_response_send(coap_service_handle, service_id, options, request_ptr, message_code, content_type, payload_ptr, payload_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t coap_service_response_send_by_msg_id(int8_t service_id, uint8_t options, uint16_t msg_id, sn_coap_msg_code_e message_code, sn_coap_content_format_e content_type, const uint8_t *payload_ptr,uint16_t payload_len) {
|
int8_t coap_service_response_send_by_msg_id(int8_t service_id, uint8_t options, uint16_t msg_id, sn_coap_msg_code_e message_code, sn_coap_content_format_e content_type, const uint8_t *payload_ptr, uint16_t payload_len)
|
||||||
|
{
|
||||||
return coap_message_handler_response_send_by_msg_id(coap_service_handle, service_id, options, msg_id, message_code, content_type, payload_ptr, payload_len);
|
return coap_message_handler_response_send_by_msg_id(coap_service_handle, service_id, options, msg_id, message_code, content_type, payload_ptr, payload_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,6 +545,11 @@ int8_t coap_service_request_delete(int8_t service_id, uint16_t msg_id)
|
||||||
return coap_message_handler_request_delete(coap_service_handle, service_id, msg_id);
|
return coap_message_handler_request_delete(coap_service_handle, service_id, msg_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void coap_service_request_delete_by_service_id(int8_t service_id)
|
||||||
|
{
|
||||||
|
coap_message_handler_request_delete_by_service_id(coap_service_handle, service_id);
|
||||||
|
}
|
||||||
|
|
||||||
int8_t coap_service_set_handshake_timeout(int8_t service_id, uint32_t min, uint32_t max)
|
int8_t coap_service_set_handshake_timeout(int8_t service_id, uint32_t min, uint32_t max)
|
||||||
{
|
{
|
||||||
coap_service_t *this = service_find(service_id);
|
coap_service_t *this = service_find(service_id);
|
||||||
|
|
|
@ -96,6 +96,8 @@ extern int8_t coap_message_handler_response_send(coap_msg_handler_t *handle, int
|
||||||
|
|
||||||
extern int8_t coap_message_handler_request_delete(coap_msg_handler_t *handle, int8_t service_id, uint16_t msg_id);
|
extern int8_t coap_message_handler_request_delete(coap_msg_handler_t *handle, int8_t service_id, uint16_t msg_id);
|
||||||
|
|
||||||
|
extern int8_t coap_message_handler_request_delete_by_service_id(coap_msg_handler_t *handle, int8_t service_id);
|
||||||
|
|
||||||
extern int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t current_time);
|
extern int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t current_time);
|
||||||
|
|
||||||
extern void transaction_delete(coap_transaction_t *this);
|
extern void transaction_delete(coap_transaction_t *this);
|
||||||
|
|
|
@ -19,12 +19,10 @@
|
||||||
|
|
||||||
TEST_GROUP(coap_connection_handler)
|
TEST_GROUP(coap_connection_handler)
|
||||||
{
|
{
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown()
|
void teardown() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,16 +50,19 @@ void sec_done_cb_test(int8_t socket_id, uint8_t address[static 16], uint16_t por
|
||||||
bool test_connection_handler_create()
|
bool test_connection_handler_create()
|
||||||
{
|
{
|
||||||
coap_security_handler_stub.counter = -1;
|
coap_security_handler_stub.counter = -1;
|
||||||
if( NULL != connection_handler_create(NULL, NULL, NULL, NULL) )
|
if (NULL != connection_handler_create(NULL, NULL, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( NULL != connection_handler_create(&receive_from_sock_cb, NULL, NULL, NULL) )
|
if (NULL != connection_handler_create(&receive_from_sock_cb, NULL, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, NULL, NULL, NULL);
|
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, NULL, NULL, NULL);
|
||||||
if( NULL == handler )
|
if (NULL == handler) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
ns_dyn_mem_free(handler);
|
ns_dyn_mem_free(handler);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -80,35 +83,42 @@ bool test_coap_connection_handler_open_connection()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, NULL, NULL, NULL);
|
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, NULL, NULL, NULL);
|
||||||
|
|
||||||
if( -1 != coap_connection_handler_open_connection(NULL, 0,false,false,false,false) )
|
if (-1 != coap_connection_handler_open_connection(NULL, 0, false, false, false, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -1 != coap_connection_handler_open_connection(handler, 0,false,false,false,false) )
|
if (-1 != coap_connection_handler_open_connection(handler, 0, false, false, false, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ns_dyn_mem_free(handler);
|
ns_dyn_mem_free(handler);
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
if( -1 != coap_connection_handler_open_connection(handler, 0,true,true,true,false) )
|
if (-1 != coap_connection_handler_open_connection(handler, 0, true, true, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 0,true,true,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 0, true, true, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,true,true,true) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, true, true, true)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//open second one
|
//open second one
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler2 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
coap_conn_handler_t *handler2 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler2, 22,false,true,true,true) )
|
if (0 != coap_connection_handler_open_connection(handler2, 22, false, true, true, true)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 23,false,false,false,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 23, false, false, false, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
connection_handler_destroy(handler2, false);
|
connection_handler_destroy(handler2, false);
|
||||||
connection_handler_destroy(handler, false);
|
connection_handler_destroy(handler, false);
|
||||||
|
@ -118,8 +128,9 @@ bool test_coap_connection_handler_open_connection()
|
||||||
bool test_coap_connection_handler_send_data()
|
bool test_coap_connection_handler_send_data()
|
||||||
{
|
{
|
||||||
coap_security_handler_stub.counter = -1;
|
coap_security_handler_stub.counter = -1;
|
||||||
if( -1 != coap_connection_handler_send_data(NULL, NULL, ns_in6addr_any, NULL, 0, false))
|
if (-1 != coap_connection_handler_send_data(NULL, NULL, ns_in6addr_any, NULL, 0, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ns_address_t addr;
|
ns_address_t addr;
|
||||||
memset(addr.address, 1, 16);
|
memset(addr.address, 1, 16);
|
||||||
|
@ -128,11 +139,13 @@ bool test_coap_connection_handler_send_data()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,true,false,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, true, false, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
|
if (-1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
connection_handler_destroy(handler, false);
|
connection_handler_destroy(handler, false);
|
||||||
|
|
||||||
|
@ -141,14 +154,17 @@ bool test_coap_connection_handler_send_data()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 4;
|
nsdynmemlib_stub.returnCounter = 4;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,true,false,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, true, false, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
|
if (-1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
|
if (-1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
connection_handler_destroy(handler, false);
|
connection_handler_destroy(handler, false);
|
||||||
|
|
||||||
|
@ -159,23 +175,27 @@ bool test_coap_connection_handler_send_data()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,false,false,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, false, false, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if( 1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
|
if (1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
connection_handler_destroy(handler, false);
|
connection_handler_destroy(handler, false);
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,false,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, false, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
socket_api_stub.int8_value = 7;
|
socket_api_stub.int8_value = 7;
|
||||||
if( 1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
|
if (1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
connection_handler_destroy(handler, false);
|
connection_handler_destroy(handler, false);
|
||||||
|
|
||||||
//<-- NON SECURE HERE
|
//<-- NON SECURE HERE
|
||||||
|
@ -188,65 +208,77 @@ bool test_coap_connection_handler_virtual_recv()
|
||||||
coap_security_handler_stub.counter = -1;
|
coap_security_handler_stub.counter = -1;
|
||||||
uint8_t buf[16];
|
uint8_t buf[16];
|
||||||
memset(&buf, 1, 16);
|
memset(&buf, 1, 16);
|
||||||
if( -1 != coap_connection_handler_virtual_recv(NULL,buf, 12, NULL, 0) )
|
if (-1 != coap_connection_handler_virtual_recv(NULL, buf, 12, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,true,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, true, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -1 != coap_connection_handler_virtual_recv(handler,buf, 12, NULL, 0) )
|
if (-1 != coap_connection_handler_virtual_recv(handler, buf, 12, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( -1 != coap_connection_handler_virtual_recv(handler,buf, 12, NULL, 0) )
|
if (-1 != coap_connection_handler_virtual_recv(handler, buf, 12, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ns_timer_stub.int8_value = 0;
|
ns_timer_stub.int8_value = 0;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( -1 != coap_connection_handler_virtual_recv(handler,buf, 12, &buf, 1) )
|
if (-1 != coap_connection_handler_virtual_recv(handler, buf, 12, &buf, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//handler->socket->data still in memory
|
//handler->socket->data still in memory
|
||||||
coap_security_handler_stub.sec_obj = coap_security_handler_stub_alloc();
|
coap_security_handler_stub.sec_obj = coap_security_handler_stub_alloc();
|
||||||
|
|
||||||
ns_timer_stub.int8_value = -1;
|
ns_timer_stub.int8_value = -1;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( -1 != coap_connection_handler_virtual_recv(handler,buf, 12, &buf, 1) )
|
if (-1 != coap_connection_handler_virtual_recv(handler, buf, 12, &buf, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ns_timer_stub.int8_value = 0;
|
ns_timer_stub.int8_value = 0;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( -1 != coap_connection_handler_virtual_recv(handler,buf, 12, &buf, 1) )
|
if (-1 != coap_connection_handler_virtual_recv(handler, buf, 12, &buf, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
connection_handler_destroy(handler, false);
|
connection_handler_destroy(handler, false);
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler2 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, &get_passwd_cb, &sec_done_cb_test);
|
coap_conn_handler_t *handler2 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, &get_passwd_cb, &sec_done_cb_test);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler2, 24,false,true,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler2, 24, false, true, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 0 != coap_connection_handler_virtual_recv(handler2,buf, 12, &buf, 1) )
|
if (0 != coap_connection_handler_virtual_recv(handler2, buf, 12, &buf, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_security_handler_stub.int_value = 0;
|
coap_security_handler_stub.int_value = 0;
|
||||||
if( 0 != coap_connection_handler_virtual_recv(handler2,buf, 12, &buf, 1) )
|
if (0 != coap_connection_handler_virtual_recv(handler2, buf, 12, &buf, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 0 != coap_connection_handler_virtual_recv(handler2,buf, 12, &buf, 1) )
|
if (0 != coap_connection_handler_virtual_recv(handler2, buf, 12, &buf, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_security_handler_stub.int_value = MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY;
|
coap_security_handler_stub.int_value = MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY;
|
||||||
if( 0 != coap_connection_handler_virtual_recv(handler2,buf, 12, &buf, 1) )
|
if (0 != coap_connection_handler_virtual_recv(handler2, buf, 12, &buf, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
connection_handler_destroy(handler2, false);
|
connection_handler_destroy(handler2, false);
|
||||||
|
|
||||||
|
@ -256,12 +288,14 @@ bool test_coap_connection_handler_virtual_recv()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler3 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, &get_passwd_cb, &sec_done_cb_test);
|
coap_conn_handler_t *handler3 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, &get_passwd_cb, &sec_done_cb_test);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler3, 26,false,false,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler3, 26, false, false, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 0 != coap_connection_handler_virtual_recv(handler3,buf, 12, &buf, 1) )
|
if (0 != coap_connection_handler_virtual_recv(handler3, buf, 12, &buf, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
connection_handler_destroy(handler3, false);
|
connection_handler_destroy(handler3, false);
|
||||||
|
|
||||||
|
@ -271,21 +305,25 @@ bool test_coap_connection_handler_virtual_recv()
|
||||||
bool test_coap_connection_handler_socket_belongs_to()
|
bool test_coap_connection_handler_socket_belongs_to()
|
||||||
{
|
{
|
||||||
coap_security_handler_stub.counter = -1;
|
coap_security_handler_stub.counter = -1;
|
||||||
if( false != coap_connection_handler_socket_belongs_to(NULL, 2) )
|
if (false != coap_connection_handler_socket_belongs_to(NULL, 2)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
socket_api_stub.int8_value = 0;
|
socket_api_stub.int8_value = 0;
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,true,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, true, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( true != coap_connection_handler_socket_belongs_to(handler, 0) )
|
if (true != coap_connection_handler_socket_belongs_to(handler, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( false != coap_connection_handler_socket_belongs_to(handler, 3) )
|
if (false != coap_connection_handler_socket_belongs_to(handler, 3)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
connection_handler_destroy(handler, false);
|
connection_handler_destroy(handler, false);
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 0;
|
nsdynmemlib_stub.returnCounter = 0;
|
||||||
|
@ -301,8 +339,9 @@ bool test_timer_callbacks()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,true,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, true, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//handler->socket->data still in memory
|
//handler->socket->data still in memory
|
||||||
coap_security_handler_stub.sec_obj = coap_security_handler_stub_alloc();
|
coap_security_handler_stub.sec_obj = coap_security_handler_stub_alloc();
|
||||||
|
@ -310,8 +349,9 @@ bool test_timer_callbacks()
|
||||||
ns_timer_stub.int8_value = 0;
|
ns_timer_stub.int8_value = 0;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
ns_timer_stub.int8_value = 5;
|
ns_timer_stub.int8_value = 5;
|
||||||
if( -1 != coap_connection_handler_virtual_recv(handler,buf, 12, &buf, 1) )
|
if (-1 != coap_connection_handler_virtual_recv(handler, buf, 12, &buf, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//Note next tests will affect ns_timer test (cycle & cycle_count
|
//Note next tests will affect ns_timer test (cycle & cycle_count
|
||||||
if (coap_security_handler_stub.start_timer_cb) {
|
if (coap_security_handler_stub.start_timer_cb) {
|
||||||
|
@ -321,12 +361,14 @@ bool test_timer_callbacks()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coap_security_handler_stub.timer_status_cb) {
|
if (coap_security_handler_stub.timer_status_cb) {
|
||||||
if( -1 != coap_security_handler_stub.timer_status_cb(4) )
|
if (-1 != coap_security_handler_stub.timer_status_cb(4)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( 0 != coap_security_handler_stub.timer_status_cb(1) )
|
if (0 != coap_security_handler_stub.timer_status_cb(1)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ns_timer_stub.cb) {
|
if (ns_timer_stub.cb) {
|
||||||
ns_timer_stub.cb(4, 0);
|
ns_timer_stub.cb(4, 0);
|
||||||
|
@ -360,8 +402,9 @@ bool test_socket_api_callbacks()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,false,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, false, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (socket_api_stub.recv_cb) {
|
if (socket_api_stub.recv_cb) {
|
||||||
sckt_data->event_type = SOCKET_DATA;
|
sckt_data->event_type = SOCKET_DATA;
|
||||||
|
@ -382,8 +425,9 @@ bool test_socket_api_callbacks()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler2 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, &get_passwd_cb, &sec_done_cb_test);
|
coap_conn_handler_t *handler2 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, &get_passwd_cb, &sec_done_cb_test);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler2, 22,false,true,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler2, 22, false, true, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (socket_api_stub.recv_cb) {
|
if (socket_api_stub.recv_cb) {
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
|
@ -438,8 +482,9 @@ bool test_security_callbacks()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_connection_handler_open_connection(handler, 22,false,true,true,false) )
|
if (0 != coap_connection_handler_open_connection(handler, 22, false, true, true, false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (socket_api_stub.recv_cb) {
|
if (socket_api_stub.recv_cb) {
|
||||||
sckt_data->event_type = SOCKET_DATA;
|
sckt_data->event_type = SOCKET_DATA;
|
||||||
|
|
|
@ -19,12 +19,10 @@
|
||||||
|
|
||||||
TEST_GROUP(coap_message_handler)
|
TEST_GROUP(coap_message_handler)
|
||||||
{
|
{
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown()
|
void teardown() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,6 +61,11 @@ TEST(coap_message_handler, test_coap_message_handler_request_delete)
|
||||||
CHECK(test_coap_message_handler_request_delete());
|
CHECK(test_coap_message_handler_request_delete());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(coap_message_handler, test_coap_message_handler_request_delete_by_service_id)
|
||||||
|
{
|
||||||
|
CHECK(test_coap_message_handler_request_delete_by_service_id());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(coap_message_handler, test_coap_message_handler_exec)
|
TEST(coap_message_handler, test_coap_message_handler_exec)
|
||||||
{
|
{
|
||||||
CHECK(test_coap_message_handler_exec());
|
CHECK(test_coap_message_handler_exec());
|
||||||
|
|
|
@ -49,7 +49,8 @@ static uint8_t coap_tx_function(uint8_t *data_ptr, uint16_t data_len, sn_nsdl_ad
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int resp_recv(int8_t service_id, uint16_t msg_id, sn_coap_hdr_s *response_ptr){
|
int resp_recv(int8_t service_id, uint16_t msg_id, sn_coap_hdr_s *response_ptr)
|
||||||
|
{
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,25 +67,31 @@ static int transaction_recv_cb(int8_t service_id, uint8_t source_address[static
|
||||||
|
|
||||||
bool test_coap_message_handler_init()
|
bool test_coap_message_handler_init()
|
||||||
{
|
{
|
||||||
if( NULL != coap_message_handler_init(NULL, NULL, NULL) )
|
if (NULL != coap_message_handler_init(NULL, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
if( NULL != coap_message_handler_init(&test_own_alloc, NULL, NULL) )
|
}
|
||||||
|
if (NULL != coap_message_handler_init(&test_own_alloc, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
if( NULL != coap_message_handler_init(&test_own_alloc, &test_own_free, NULL) )
|
}
|
||||||
|
if (NULL != coap_message_handler_init(&test_own_alloc, &test_own_free, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
if( NULL != coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function) )
|
}
|
||||||
|
if (NULL != coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
retCounter = 1;
|
retCounter = 1;
|
||||||
sn_coap_protocol_stub.expectedCoap = NULL;
|
sn_coap_protocol_stub.expectedCoap = NULL;
|
||||||
if( NULL != coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function) )
|
if (NULL != coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
retCounter = 1;
|
retCounter = 1;
|
||||||
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
||||||
memset(sn_coap_protocol_stub.expectedCoap, 0, sizeof(struct coap_s));
|
memset(sn_coap_protocol_stub.expectedCoap, 0, sizeof(struct coap_s));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_msg_handler_t *handle = coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function);
|
coap_msg_handler_t *handle = coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function);
|
||||||
if( NULL == handle )
|
if (NULL == handle) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
free(sn_coap_protocol_stub.expectedCoap);
|
free(sn_coap_protocol_stub.expectedCoap);
|
||||||
sn_coap_protocol_stub.expectedCoap = NULL;
|
sn_coap_protocol_stub.expectedCoap = NULL;
|
||||||
free(handle);
|
free(handle);
|
||||||
|
@ -93,16 +100,18 @@ bool test_coap_message_handler_init()
|
||||||
|
|
||||||
bool test_coap_message_handler_destroy()
|
bool test_coap_message_handler_destroy()
|
||||||
{
|
{
|
||||||
if( -1 != coap_message_handler_destroy(NULL) )
|
if (-1 != coap_message_handler_destroy(NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
retCounter = 1;
|
retCounter = 1;
|
||||||
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
||||||
memset(sn_coap_protocol_stub.expectedCoap, 0, sizeof(struct coap_s));
|
memset(sn_coap_protocol_stub.expectedCoap, 0, sizeof(struct coap_s));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_msg_handler_t *handle = coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function);
|
coap_msg_handler_t *handle = coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function);
|
||||||
|
|
||||||
if( 0 != coap_message_handler_destroy(handle) )
|
if (0 != coap_message_handler_destroy(handle)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
free(sn_coap_protocol_stub.expectedCoap);
|
free(sn_coap_protocol_stub.expectedCoap);
|
||||||
return true;
|
return true;
|
||||||
|
@ -110,8 +119,9 @@ bool test_coap_message_handler_destroy()
|
||||||
|
|
||||||
bool test_coap_message_handler_find_transaction()
|
bool test_coap_message_handler_find_transaction()
|
||||||
{
|
{
|
||||||
if( NULL != coap_message_handler_find_transaction(NULL, 0))
|
if (NULL != coap_message_handler_find_transaction(NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
retCounter = 1;
|
retCounter = 1;
|
||||||
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
||||||
memset(sn_coap_protocol_stub.expectedCoap, 0, sizeof(struct coap_s));
|
memset(sn_coap_protocol_stub.expectedCoap, 0, sizeof(struct coap_s));
|
||||||
|
@ -127,11 +137,13 @@ bool test_coap_message_handler_find_transaction()
|
||||||
|
|
||||||
sn_coap_builder_stub.expectedUint16 = 1;
|
sn_coap_builder_stub.expectedUint16 = 1;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv))
|
if (2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( NULL == coap_message_handler_find_transaction(&buf, 24))
|
if (NULL == coap_message_handler_find_transaction(&buf, 24)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
free(sn_coap_protocol_stub.expectedCoap);
|
free(sn_coap_protocol_stub.expectedCoap);
|
||||||
sn_coap_protocol_stub.expectedCoap = NULL;
|
sn_coap_protocol_stub.expectedCoap = NULL;
|
||||||
|
@ -145,8 +157,9 @@ bool test_coap_message_handler_coap_msg_process()
|
||||||
memset(&buf, 1, 16);
|
memset(&buf, 1, 16);
|
||||||
bool ret_val = false;
|
bool ret_val = false;
|
||||||
/*Handler is null*/
|
/*Handler is null*/
|
||||||
if( -1 != coap_message_handler_coap_msg_process(NULL, 0, buf, 22, ns_in6addr_any, NULL, 0, NULL))
|
if (-1 != coap_message_handler_coap_msg_process(NULL, 0, buf, 22, ns_in6addr_any, NULL, 0, NULL)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
retCounter = 1;
|
retCounter = 1;
|
||||||
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
||||||
|
@ -156,16 +169,18 @@ bool test_coap_message_handler_coap_msg_process()
|
||||||
|
|
||||||
sn_coap_protocol_stub.expectedHeader = NULL;
|
sn_coap_protocol_stub.expectedHeader = NULL;
|
||||||
/* Coap parse returns null */
|
/* Coap parse returns null */
|
||||||
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
|
if (-1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
||||||
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
||||||
sn_coap_protocol_stub.expectedHeader->coap_status = 66;
|
sn_coap_protocol_stub.expectedHeader->coap_status = 66;
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
/* Coap library responds */
|
/* Coap library responds */
|
||||||
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
|
if (-1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
||||||
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
||||||
|
@ -174,8 +189,9 @@ bool test_coap_message_handler_coap_msg_process()
|
||||||
retValue = 0;
|
retValue = 0;
|
||||||
/* request received */
|
/* request received */
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 0 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
|
if (0 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
||||||
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
||||||
|
@ -183,8 +199,9 @@ bool test_coap_message_handler_coap_msg_process()
|
||||||
sn_coap_protocol_stub.expectedHeader->msg_code = 1;
|
sn_coap_protocol_stub.expectedHeader->msg_code = 1;
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
retValue = -1;
|
retValue = -1;
|
||||||
if( 0 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
|
if (0 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
||||||
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
||||||
|
@ -192,8 +209,9 @@ bool test_coap_message_handler_coap_msg_process()
|
||||||
sn_coap_protocol_stub.expectedHeader->msg_code = 333;
|
sn_coap_protocol_stub.expectedHeader->msg_code = 333;
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
|
|
||||||
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
|
if (-1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
||||||
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
||||||
|
@ -207,13 +225,15 @@ bool test_coap_message_handler_coap_msg_process()
|
||||||
|
|
||||||
sn_coap_builder_stub.expectedUint16 = 1;
|
sn_coap_builder_stub.expectedUint16 = 1;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv))
|
if (2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_protocol_stub.expectedHeader->msg_id = 2;
|
sn_coap_protocol_stub.expectedHeader->msg_id = 2;
|
||||||
|
|
||||||
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
|
if (-1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
ret_val = true;
|
ret_val = true;
|
||||||
exit:
|
exit:
|
||||||
|
@ -233,61 +253,70 @@ bool test_coap_message_handler_request_send()
|
||||||
|
|
||||||
uint8_t buf[16];
|
uint8_t buf[16];
|
||||||
memset(&buf, 1, 16);
|
memset(&buf, 1, 16);
|
||||||
char uri[3];
|
char uri[3] = "rs";
|
||||||
uri[0] = "r";
|
|
||||||
uri[1] = "s";
|
if (0 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, NULL)) {
|
||||||
uri[2] = "\0";
|
|
||||||
if( 0 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, NULL))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_builder_stub.expectedUint16 = 1;
|
sn_coap_builder_stub.expectedUint16 = 1;
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 0 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, NULL))
|
if (0 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_builder_stub.expectedUint16 = 1;
|
sn_coap_builder_stub.expectedUint16 = 1;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 0 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, NULL))
|
if (0 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_builder_stub.expectedUint16 = 1;
|
sn_coap_builder_stub.expectedUint16 = 1;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 0 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, NULL))
|
if (0 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_builder_stub.expectedUint16 = 1;
|
sn_coap_builder_stub.expectedUint16 = 1;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv))
|
if (2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear all transactions */
|
/* Clear all transactions */
|
||||||
if( 0 != coap_message_handler_exec(handle, 0xffffffff))
|
if (0 != coap_message_handler_exec(handle, 0xffffffff)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_protocol_stub.expectedInt16 = -4;
|
sn_coap_protocol_stub.expectedInt16 = -4;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &transaction_recv_cb))
|
if (2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &transaction_recv_cb)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
transaction_cb = 0;
|
transaction_cb = 0;
|
||||||
sn_coap_protocol_stub.expectedInt8 = 0;
|
sn_coap_protocol_stub.expectedInt8 = 0;
|
||||||
if( 0 != coap_message_handler_exec(handle, 12))
|
if (0 != coap_message_handler_exec(handle, 12)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (transaction_cb != 1)
|
if (transaction_cb != 1) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_protocol_stub.expectedInt16 = -2;
|
sn_coap_protocol_stub.expectedInt16 = -2;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &transaction_recv_cb))
|
if (2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &transaction_recv_cb)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
transaction_cb = 0;
|
transaction_cb = 0;
|
||||||
if (0 != coap_message_handler_exec(handle, 2)) {
|
if (0 != coap_message_handler_exec(handle, 2)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (transaction_cb != 1)
|
if (transaction_cb != 1) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
free(sn_coap_protocol_stub.expectedCoap);
|
free(sn_coap_protocol_stub.expectedCoap);
|
||||||
|
@ -310,19 +339,23 @@ bool test_coap_message_handler_request_delete()
|
||||||
uri[0] = "r";
|
uri[0] = "r";
|
||||||
uri[1] = "s";
|
uri[1] = "s";
|
||||||
uri[2] = "\0";
|
uri[2] = "\0";
|
||||||
if( 0 == coap_message_handler_request_delete(NULL, 1, 1))
|
if (0 == coap_message_handler_request_delete(NULL, 1, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( 0 == coap_message_handler_request_delete(handle, 1, 1))
|
if (0 == coap_message_handler_request_delete(handle, 1, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_builder_stub.expectedUint16 = 1;
|
sn_coap_builder_stub.expectedUint16 = 1;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv))
|
if (2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( 0 != coap_message_handler_request_delete(handle, 1, 2))
|
if (0 != coap_message_handler_request_delete(handle, 1, 2)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
free(sn_coap_protocol_stub.expectedCoap);
|
free(sn_coap_protocol_stub.expectedCoap);
|
||||||
sn_coap_protocol_stub.expectedCoap = NULL;
|
sn_coap_protocol_stub.expectedCoap = NULL;
|
||||||
|
@ -330,10 +363,49 @@ bool test_coap_message_handler_request_delete()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool test_coap_message_handler_request_delete_by_service_id()
|
||||||
|
{
|
||||||
|
retCounter = 1;
|
||||||
|
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
||||||
|
memset(sn_coap_protocol_stub.expectedCoap, 0, sizeof(struct coap_s));
|
||||||
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
|
coap_msg_handler_t *handle = coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function);
|
||||||
|
coap_service_handle = handle;
|
||||||
|
|
||||||
|
uint8_t buf[16];
|
||||||
|
memset(&buf, 1, 16);
|
||||||
|
char uri[3] = "rs";
|
||||||
|
|
||||||
|
if (0 == coap_message_handler_request_delete_by_service_id(NULL, 1)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 != coap_message_handler_request_delete_by_service_id(handle, 1)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sn_coap_builder_stub.expectedUint16 = 1;
|
||||||
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
|
if (2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 != coap_message_handler_request_delete_by_service_id(handle, 3)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(sn_coap_protocol_stub.expectedCoap);
|
||||||
|
sn_coap_protocol_stub.expectedCoap = NULL;
|
||||||
|
coap_message_handler_destroy(handle);
|
||||||
|
coap_service_handle = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool test_coap_message_handler_response_send()
|
bool test_coap_message_handler_response_send()
|
||||||
{
|
{
|
||||||
if( -1 != coap_message_handler_response_send(NULL, 2, 0, NULL, 1,3,NULL, 0))
|
if (-1 != coap_message_handler_response_send(NULL, 2, 0, NULL, 1, 3, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
retCounter = 1;
|
retCounter = 1;
|
||||||
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
||||||
|
@ -343,8 +415,9 @@ bool test_coap_message_handler_response_send()
|
||||||
sn_coap_hdr_s *header = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
sn_coap_hdr_s *header = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
||||||
memset(header, 0, sizeof(sn_coap_hdr_s));
|
memset(header, 0, sizeof(sn_coap_hdr_s));
|
||||||
|
|
||||||
if( -2 != coap_message_handler_response_send(handle, 2, 0, header, 1,3,NULL, 0))
|
if (-2 != coap_message_handler_response_send(handle, 2, 0, header, 1, 3, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t buf[16];
|
uint8_t buf[16];
|
||||||
memset(&buf, 1, 16);
|
memset(&buf, 1, 16);
|
||||||
|
@ -354,8 +427,9 @@ bool test_coap_message_handler_response_send()
|
||||||
uri[2] = "\0";
|
uri[2] = "\0";
|
||||||
sn_coap_builder_stub.expectedUint16 = 1;
|
sn_coap_builder_stub.expectedUint16 = 1;
|
||||||
nsdynmemlib_stub.returnCounter = 3;
|
nsdynmemlib_stub.returnCounter = 3;
|
||||||
if( 2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv))
|
if (2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
header->msg_id = 2;
|
header->msg_id = 2;
|
||||||
sn_coap_builder_stub.expectedUint16 = 2;
|
sn_coap_builder_stub.expectedUint16 = 2;
|
||||||
|
@ -364,20 +438,23 @@ bool test_coap_message_handler_response_send()
|
||||||
tx->client_request = false;
|
tx->client_request = false;
|
||||||
}
|
}
|
||||||
sn_coap_builder_stub.expectedHeader = NULL;
|
sn_coap_builder_stub.expectedHeader = NULL;
|
||||||
if( -1 != coap_message_handler_response_send(handle, 2, 0, header, 1,3,NULL, 0))
|
if (-1 != coap_message_handler_response_send(handle, 2, 0, header, 1, 3, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
||||||
memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
||||||
nsdynmemlib_stub.returnCounter = 0;
|
nsdynmemlib_stub.returnCounter = 0;
|
||||||
if( -1 != coap_message_handler_response_send(handle, 2, 0, header, 1,3,NULL, 0))
|
if (-1 != coap_message_handler_response_send(handle, 2, 0, header, 1, 3, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
||||||
memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 0 != coap_message_handler_response_send(handle, 2, 0, header, 1,3,NULL, 0))
|
if (0 != coap_message_handler_response_send(handle, 2, 0, header, 1, 3, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
free(header);
|
free(header);
|
||||||
free(sn_coap_protocol_stub.expectedCoap);
|
free(sn_coap_protocol_stub.expectedCoap);
|
||||||
|
@ -389,8 +466,9 @@ bool test_coap_message_handler_response_send()
|
||||||
bool test_coap_message_handler_exec()
|
bool test_coap_message_handler_exec()
|
||||||
{
|
{
|
||||||
/* Null as a parameter */
|
/* Null as a parameter */
|
||||||
if( -1 != coap_message_handler_exec(NULL, 0))
|
if (-1 != coap_message_handler_exec(NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
retCounter = 1;
|
retCounter = 1;
|
||||||
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
sn_coap_protocol_stub.expectedCoap = (struct coap_s *)malloc(sizeof(struct coap_s));
|
||||||
|
@ -398,43 +476,52 @@ bool test_coap_message_handler_exec()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_msg_handler_t *handle = coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function);
|
coap_msg_handler_t *handle = coap_message_handler_init(&test_own_alloc, &test_own_free, &coap_tx_function);
|
||||||
|
|
||||||
if( 0 != coap_message_handler_exec(handle, 0))
|
if (0 != coap_message_handler_exec(handle, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_transaction_t *transact_ptr = transaction_create();
|
coap_transaction_t *transact_ptr = transaction_create();
|
||||||
|
|
||||||
/* Transaction not timed out*/
|
/* Transaction not timed out*/
|
||||||
if( 0 != coap_message_handler_exec(handle, 0))
|
if (0 != coap_message_handler_exec(handle, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (transaction_cb != 0)
|
if (transaction_cb != 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Timed out, no CB */
|
/* Timed out, no CB */
|
||||||
if( 0 != coap_message_handler_exec(handle, 300))
|
if (0 != coap_message_handler_exec(handle, 300)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (transaction_cb != 0)
|
if (transaction_cb != 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
transact_ptr = transaction_create();
|
transact_ptr = transaction_create();
|
||||||
transact_ptr->resp_cb = transaction_recv_cb;
|
transact_ptr->resp_cb = transaction_recv_cb;
|
||||||
|
|
||||||
/* Transaction not timed out */
|
/* Transaction not timed out */
|
||||||
if( 0 != coap_message_handler_exec(handle, 0))
|
if (0 != coap_message_handler_exec(handle, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (transaction_cb != 0)
|
if (transaction_cb != 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Transaction timed out */
|
/* Transaction timed out */
|
||||||
if( 0 != coap_message_handler_exec(handle, 300))
|
if (0 != coap_message_handler_exec(handle, 300)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (transaction_cb == 0)
|
if (transaction_cb == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Teardown */
|
/* Teardown */
|
||||||
free(sn_coap_protocol_stub.expectedCoap);
|
free(sn_coap_protocol_stub.expectedCoap);
|
||||||
|
|
|
@ -30,6 +30,7 @@ bool test_coap_message_handler_coap_msg_process();
|
||||||
bool test_coap_message_handler_request_send();
|
bool test_coap_message_handler_request_send();
|
||||||
bool test_coap_message_handler_response_send();
|
bool test_coap_message_handler_response_send();
|
||||||
bool test_coap_message_handler_request_delete();
|
bool test_coap_message_handler_request_delete();
|
||||||
|
bool test_coap_message_handler_request_delete_by_service_id();
|
||||||
bool test_coap_message_handler_exec();
|
bool test_coap_message_handler_exec();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -21,14 +21,12 @@
|
||||||
|
|
||||||
TEST_GROUP(coap_security_handler)
|
TEST_GROUP(coap_security_handler)
|
||||||
{
|
{
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
nsdynmemlib_stub.returnCounter = 0;
|
nsdynmemlib_stub.returnCounter = 0;
|
||||||
mbedtls_stub.useCounter = false;
|
mbedtls_stub.useCounter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown()
|
void teardown() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -43,28 +43,33 @@ static int timer_status_callback(int8_t timer_id)
|
||||||
|
|
||||||
bool test_thread_security_create()
|
bool test_thread_security_create()
|
||||||
{
|
{
|
||||||
if( NULL != coap_security_create(1,2,NULL,ECJPAKE,&send_to_socket, &receive_from_socket, &start_timer_callback, NULL) )
|
if (NULL != coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( NULL != coap_security_create(1,2,NULL,ECJPAKE,&send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback) )
|
if (NULL != coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
mbedtls_stub.expected_int = -1;
|
mbedtls_stub.expected_int = -1;
|
||||||
if( NULL != coap_security_create(1,2,NULL,ECJPAKE,&send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback) )
|
if (NULL != coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.expected_int = 0;
|
mbedtls_stub.expected_int = 0;
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
mbedtls_stub.crt_expected_int = -1;
|
mbedtls_stub.crt_expected_int = -1;
|
||||||
if( NULL != coap_security_create(1,2,NULL,ECJPAKE,&send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback) )
|
if (NULL != coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
mbedtls_stub.crt_expected_int = 0;
|
mbedtls_stub.crt_expected_int = 0;
|
||||||
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
||||||
if( NULL == handle )
|
if (NULL == handle) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_security_destroy(handle);
|
coap_security_destroy(handle);
|
||||||
|
|
||||||
|
@ -76,8 +81,9 @@ bool test_thread_security_destroy()
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
mbedtls_stub.crt_expected_int = 0;
|
mbedtls_stub.crt_expected_int = 0;
|
||||||
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
||||||
if( NULL == handle )
|
if (NULL == handle) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_security_destroy(handle);
|
coap_security_destroy(handle);
|
||||||
return true;
|
return true;
|
||||||
|
@ -88,15 +94,17 @@ bool test_coap_security_handler_connect()
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
mbedtls_stub.crt_expected_int = 0;
|
mbedtls_stub.crt_expected_int = 0;
|
||||||
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
||||||
if( NULL == handle )
|
if (NULL == handle) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char pw = "pwd";
|
unsigned char pw = "pwd";
|
||||||
coap_security_keys_t keys;
|
coap_security_keys_t keys;
|
||||||
keys._key = &pw;
|
keys._key = &pw;
|
||||||
keys._key_len = 3;
|
keys._key_len = 3;
|
||||||
if( -1 != coap_security_handler_connect_non_blocking(NULL, true, DTLS, keys, 0, 1) )
|
if (-1 != coap_security_handler_connect_non_blocking(NULL, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
mbedtls_stub.useCounter = true;
|
mbedtls_stub.useCounter = true;
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
mbedtls_stub.retArray[0] = -1;
|
mbedtls_stub.retArray[0] = -1;
|
||||||
|
@ -108,19 +116,22 @@ bool test_coap_security_handler_connect()
|
||||||
mbedtls_stub.retArray[6] = -1;
|
mbedtls_stub.retArray[6] = -1;
|
||||||
mbedtls_stub.retArray[7] = -1;
|
mbedtls_stub.retArray[7] = -1;
|
||||||
|
|
||||||
if( -1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1) )
|
if (-1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
mbedtls_stub.retArray[0] = 0;
|
mbedtls_stub.retArray[0] = 0;
|
||||||
if( -1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1) )
|
if (-1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
// mbedtls_stub.retArray[0] = 0;
|
// mbedtls_stub.retArray[0] = 0;
|
||||||
mbedtls_stub.retArray[1] = 0;
|
mbedtls_stub.retArray[1] = 0;
|
||||||
if( -1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1) )
|
if (-1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
simple_cookie_t c;
|
simple_cookie_t c;
|
||||||
memset(&c, 0, sizeof(simple_cookie_t));
|
memset(&c, 0, sizeof(simple_cookie_t));
|
||||||
|
@ -131,8 +142,9 @@ bool test_coap_security_handler_connect()
|
||||||
// mbedtls_stub.retArray[0] = 0;
|
// mbedtls_stub.retArray[0] = 0;
|
||||||
// mbedtls_stub.retArray[1] = 0;
|
// mbedtls_stub.retArray[1] = 0;
|
||||||
mbedtls_stub.retArray[2] = 0;
|
mbedtls_stub.retArray[2] = 0;
|
||||||
if( -1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1) )
|
if (-1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
c.len = 8;
|
c.len = 8;
|
||||||
memset(&c.value, 1, 8);
|
memset(&c.value, 1, 8);
|
||||||
|
@ -145,8 +157,9 @@ bool test_coap_security_handler_connect()
|
||||||
// mbedtls_stub.retArray[1] = 0;
|
// mbedtls_stub.retArray[1] = 0;
|
||||||
// mbedtls_stub.retArray[2] = 0;
|
// mbedtls_stub.retArray[2] = 0;
|
||||||
mbedtls_stub.retArray[3] = 0;
|
mbedtls_stub.retArray[3] = 0;
|
||||||
if( -1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1) )
|
if (-1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
// mbedtls_stub.retArray[0] = 0;
|
// mbedtls_stub.retArray[0] = 0;
|
||||||
|
@ -154,8 +167,9 @@ bool test_coap_security_handler_connect()
|
||||||
// mbedtls_stub.retArray[2] = 0;
|
// mbedtls_stub.retArray[2] = 0;
|
||||||
// mbedtls_stub.retArray[3] = 0;
|
// mbedtls_stub.retArray[3] = 0;
|
||||||
mbedtls_stub.retArray[4] = 0;
|
mbedtls_stub.retArray[4] = 0;
|
||||||
if( -1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1) )
|
if (-1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
// mbedtls_stub.retArray[0] = 0;
|
// mbedtls_stub.retArray[0] = 0;
|
||||||
|
@ -165,20 +179,23 @@ bool test_coap_security_handler_connect()
|
||||||
// mbedtls_stub.retArray[4] = 0;
|
// mbedtls_stub.retArray[4] = 0;
|
||||||
mbedtls_stub.retArray[6] = 0;
|
mbedtls_stub.retArray[6] = 0;
|
||||||
mbedtls_stub.retArray[7] = 0;
|
mbedtls_stub.retArray[7] = 0;
|
||||||
if( 1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1) )
|
if (1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
mbedtls_stub.retArray[5] = MBEDTLS_ERR_SSL_BAD_HS_FINISHED;
|
mbedtls_stub.retArray[5] = MBEDTLS_ERR_SSL_BAD_HS_FINISHED;
|
||||||
|
|
||||||
if( -1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1) )
|
if (-1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
mbedtls_stub.retArray[5] = HANDSHAKE_FINISHED_VALUE;
|
mbedtls_stub.retArray[5] = HANDSHAKE_FINISHED_VALUE;
|
||||||
|
|
||||||
if( 1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1) )
|
if (1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_security_destroy(handle);
|
coap_security_destroy(handle);
|
||||||
return true;
|
return true;
|
||||||
|
@ -189,8 +206,9 @@ bool test_coap_security_handler_continue_connecting()
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
mbedtls_stub.crt_expected_int = 0;
|
mbedtls_stub.crt_expected_int = 0;
|
||||||
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
||||||
if( NULL == handle )
|
if (NULL == handle) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.useCounter = true;
|
mbedtls_stub.useCounter = true;
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
|
@ -198,34 +216,39 @@ bool test_coap_security_handler_continue_connecting()
|
||||||
mbedtls_stub.retArray[1] = -1;
|
mbedtls_stub.retArray[1] = -1;
|
||||||
mbedtls_stub.retArray[2] = -1;
|
mbedtls_stub.retArray[2] = -1;
|
||||||
|
|
||||||
if( -1 != coap_security_handler_continue_connecting(handle) )
|
if (-1 != coap_security_handler_continue_connecting(handle)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
mbedtls_stub.retArray[0] = MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED;
|
mbedtls_stub.retArray[0] = MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED;
|
||||||
mbedtls_stub.retArray[1] = 0;
|
mbedtls_stub.retArray[1] = 0;
|
||||||
mbedtls_stub.retArray[2] = 0;
|
mbedtls_stub.retArray[2] = 0;
|
||||||
|
|
||||||
if( 1 != coap_security_handler_continue_connecting(handle) )
|
if (1 != coap_security_handler_continue_connecting(handle)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
mbedtls_stub.retArray[0] = MBEDTLS_ERR_SSL_BAD_HS_FINISHED;
|
mbedtls_stub.retArray[0] = MBEDTLS_ERR_SSL_BAD_HS_FINISHED;
|
||||||
|
|
||||||
if( MBEDTLS_ERR_SSL_BAD_HS_FINISHED != coap_security_handler_continue_connecting(handle) )
|
if (MBEDTLS_ERR_SSL_BAD_HS_FINISHED != coap_security_handler_continue_connecting(handle)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
mbedtls_stub.retArray[0] = MBEDTLS_ERR_SSL_WANT_READ;
|
mbedtls_stub.retArray[0] = MBEDTLS_ERR_SSL_WANT_READ;
|
||||||
|
|
||||||
if( 1 != coap_security_handler_continue_connecting(handle) )
|
if (1 != coap_security_handler_continue_connecting(handle)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.counter = 0;
|
mbedtls_stub.counter = 0;
|
||||||
mbedtls_stub.retArray[0] = HANDSHAKE_FINISHED_VALUE_RETURN_ZERO;
|
mbedtls_stub.retArray[0] = HANDSHAKE_FINISHED_VALUE_RETURN_ZERO;
|
||||||
|
|
||||||
if( 0 != coap_security_handler_continue_connecting(handle) )
|
if (0 != coap_security_handler_continue_connecting(handle)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_security_destroy(handle);
|
coap_security_destroy(handle);
|
||||||
return true;
|
return true;
|
||||||
|
@ -236,16 +259,19 @@ bool test_coap_security_handler_send_message()
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
mbedtls_stub.crt_expected_int = 0;
|
mbedtls_stub.crt_expected_int = 0;
|
||||||
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
||||||
if( NULL == handle )
|
if (NULL == handle) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -1 != coap_security_handler_send_message(NULL, NULL, 0))
|
if (-1 != coap_security_handler_send_message(NULL, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.expected_int = 6;
|
mbedtls_stub.expected_int = 6;
|
||||||
unsigned char cbuf[6];
|
unsigned char cbuf[6];
|
||||||
if( 6 != coap_security_handler_send_message(handle, &cbuf, 6))
|
if (6 != coap_security_handler_send_message(handle, &cbuf, 6)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_security_destroy(handle);
|
coap_security_destroy(handle);
|
||||||
return true;
|
return true;
|
||||||
|
@ -256,15 +282,18 @@ bool test_thread_security_send_close_alert()
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
mbedtls_stub.crt_expected_int = 0;
|
mbedtls_stub.crt_expected_int = 0;
|
||||||
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
||||||
if( NULL == handle )
|
if (NULL == handle) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -1 != coap_security_send_close_alert(NULL))
|
if (-1 != coap_security_send_close_alert(NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.expected_int = 0;
|
mbedtls_stub.expected_int = 0;
|
||||||
if( 0 != coap_security_send_close_alert(handle))
|
if (0 != coap_security_send_close_alert(handle)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_security_destroy(handle);
|
coap_security_destroy(handle);
|
||||||
return true;
|
return true;
|
||||||
|
@ -275,16 +304,19 @@ bool test_coap_security_handler_read()
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
mbedtls_stub.crt_expected_int = 0;
|
mbedtls_stub.crt_expected_int = 0;
|
||||||
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
coap_security_t *handle = coap_security_create(1, 2, NULL, ECJPAKE, &send_to_socket, &receive_from_socket, &start_timer_callback, &timer_status_callback);
|
||||||
if( NULL == handle )
|
if (NULL == handle) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -1 != coap_security_handler_read(NULL, NULL, 0))
|
if (-1 != coap_security_handler_read(NULL, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_stub.expected_int = 6;
|
mbedtls_stub.expected_int = 6;
|
||||||
unsigned char cbuf[6];
|
unsigned char cbuf[6];
|
||||||
if( 6 != coap_security_handler_read(handle, &cbuf, 6))
|
if (6 != coap_security_handler_read(handle, &cbuf, 6)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_security_destroy(handle);
|
coap_security_destroy(handle);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -19,12 +19,10 @@
|
||||||
|
|
||||||
TEST_GROUP(coap_service_api)
|
TEST_GROUP(coap_service_api)
|
||||||
{
|
{
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown()
|
void teardown() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,6 +66,11 @@ TEST(coap_service_api, test_coap_service_request_delete)
|
||||||
CHECK(test_coap_service_request_delete());
|
CHECK(test_coap_service_request_delete());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(coap_service_api, test_coap_service_request_delete_by_service_id)
|
||||||
|
{
|
||||||
|
CHECK(test_coap_service_request_delete_by_service_id());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(coap_service_api, test_coap_service_response_send)
|
TEST(coap_service_api, test_coap_service_response_send)
|
||||||
{
|
{
|
||||||
CHECK(test_coap_service_response_send());
|
CHECK(test_coap_service_response_send());
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
#include "net_interface.h"
|
#include "net_interface.h"
|
||||||
#include "coap_service_api.c"
|
#include "coap_service_api.c"
|
||||||
|
|
||||||
int sec_done_cb_test(int8_t service_id, uint8_t address[static 16], uint8_t keyblock[static 40]){
|
int sec_done_cb_test(int8_t service_id, uint8_t address[static 16], uint8_t keyblock[static 40])
|
||||||
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,14 +47,16 @@ int virtual_sock_send_cb(int8_t service_id, uint8_t destination_addr_ptr[static
|
||||||
|
|
||||||
bool test_coap_service_initialize()
|
bool test_coap_service_initialize()
|
||||||
{
|
{
|
||||||
if( -1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (-1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
thread_conn_handler_stub.handler_obj = NULL;
|
thread_conn_handler_stub.handler_obj = NULL;
|
||||||
if( -1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (-1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
|
@ -61,20 +64,23 @@ bool test_coap_service_initialize()
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
thread_conn_handler_stub.int_value = -1;
|
thread_conn_handler_stub.int_value = -1;
|
||||||
if( -1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (-1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
thread_conn_handler_stub.int_value = 0;
|
thread_conn_handler_stub.int_value = 0;
|
||||||
|
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 2 != coap_service_initialize(3, 4, 0, NULL, NULL ))
|
if (2 != coap_service_initialize(3, 4, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_service_delete(2);
|
coap_service_delete(2);
|
||||||
coap_service_delete(1);
|
coap_service_delete(1);
|
||||||
|
@ -93,8 +99,9 @@ bool test_coap_service_delete()
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_message_handler_stub.coap_ptr = NULL;
|
coap_message_handler_stub.coap_ptr = NULL;
|
||||||
|
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_service_delete(1);
|
coap_service_delete(1);
|
||||||
|
|
||||||
|
@ -107,20 +114,23 @@ bool test_coap_service_delete()
|
||||||
bool test_coap_service_virtual_socket_recv()
|
bool test_coap_service_virtual_socket_recv()
|
||||||
{
|
{
|
||||||
uint8_t buf[16];
|
uint8_t buf[16];
|
||||||
if( -1 != coap_service_virtual_socket_recv(1, &buf, 10, NULL, 0) )
|
if (-1 != coap_service_virtual_socket_recv(1, &buf, 10, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_message_handler_stub.coap_ptr = NULL;
|
coap_message_handler_stub.coap_ptr = NULL;
|
||||||
|
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
thread_conn_handler_stub.int_value = 5;
|
thread_conn_handler_stub.int_value = 5;
|
||||||
if( 5 != coap_service_virtual_socket_recv(1, &buf, 10, NULL, 0) )
|
if (5 != coap_service_virtual_socket_recv(1, &buf, 10, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_service_delete(1);
|
coap_service_delete(1);
|
||||||
|
|
||||||
|
@ -134,19 +144,22 @@ bool test_coap_service_virtual_socket_recv()
|
||||||
|
|
||||||
bool test_coap_service_virtual_socket_set_cb()
|
bool test_coap_service_virtual_socket_set_cb()
|
||||||
{
|
{
|
||||||
if( -1 != coap_service_virtual_socket_set_cb(1, NULL) )
|
if (-1 != coap_service_virtual_socket_set_cb(1, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_message_handler_stub.coap_ptr = NULL;
|
coap_message_handler_stub.coap_ptr = NULL;
|
||||||
|
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( 0 != coap_service_virtual_socket_set_cb(1, NULL) )
|
if (0 != coap_service_virtual_socket_set_cb(1, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_service_delete(1);
|
coap_service_delete(1);
|
||||||
|
|
||||||
|
@ -158,27 +171,32 @@ bool test_coap_service_virtual_socket_set_cb()
|
||||||
|
|
||||||
bool test_coap_service_register_uri()
|
bool test_coap_service_register_uri()
|
||||||
{
|
{
|
||||||
if( -1 != coap_service_register_uri(1, "as", 1, &request_recv_cb))
|
if (-1 != coap_service_register_uri(1, "as", 1, &request_recv_cb)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_message_handler_stub.coap_ptr = NULL;
|
coap_message_handler_stub.coap_ptr = NULL;
|
||||||
|
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -2 != coap_service_register_uri(1, "as", 1, &request_recv_cb) )
|
if (-2 != coap_service_register_uri(1, "as", 1, &request_recv_cb)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( -2 != coap_service_register_uri(1, "as", 1, &request_recv_cb) )
|
if (-2 != coap_service_register_uri(1, "as", 1, &request_recv_cb)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_service_register_uri(1, "as", 1, &request_recv_cb) )
|
if (0 != coap_service_register_uri(1, "as", 1, &request_recv_cb)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_service_delete(1);
|
coap_service_delete(1);
|
||||||
|
|
||||||
|
@ -190,8 +208,9 @@ bool test_coap_service_register_uri()
|
||||||
|
|
||||||
bool test_coap_service_unregister_uri()
|
bool test_coap_service_unregister_uri()
|
||||||
{
|
{
|
||||||
if( -1 != coap_service_unregister_uri(1, "as"))
|
if (-1 != coap_service_unregister_uri(1, "as")) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
|
@ -199,18 +218,22 @@ bool test_coap_service_unregister_uri()
|
||||||
coap_message_handler_stub.coap_ptr = NULL;
|
coap_message_handler_stub.coap_ptr = NULL;
|
||||||
thread_conn_handler_stub.int_value = 0;
|
thread_conn_handler_stub.int_value = 0;
|
||||||
|
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_service_register_uri(1, "as", 1, &request_recv_cb) )
|
if (0 != coap_service_register_uri(1, "as", 1, &request_recv_cb)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -2 != coap_service_unregister_uri(1, "ts") )
|
if (-2 != coap_service_unregister_uri(1, "ts")) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( 0 != coap_service_unregister_uri(1, "as") )
|
if (0 != coap_service_unregister_uri(1, "as")) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_service_delete(1);
|
coap_service_delete(1);
|
||||||
|
|
||||||
|
@ -224,15 +247,23 @@ bool test_coap_service_request_send()
|
||||||
{
|
{
|
||||||
uint8_t buf[16];
|
uint8_t buf[16];
|
||||||
coap_message_handler_stub.uint16_value = 6;
|
coap_message_handler_stub.uint16_value = 6;
|
||||||
if( 6 != coap_service_request_send(0,0,&buf,0,0,0,NULL, 0,NULL,0,NULL))
|
if (6 != coap_service_request_send(0, 0, &buf, 0, 0, 0, NULL, 0, NULL, 0, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool test_coap_service_request_delete()
|
bool test_coap_service_request_delete()
|
||||||
{
|
{
|
||||||
if( 0 != coap_service_request_delete(NULL,0))
|
if (0 != coap_service_request_delete(NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool test_coap_service_request_delete_by_service_id()
|
||||||
|
{
|
||||||
|
coap_service_request_delete_by_service_id(0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,8 +271,9 @@ bool test_coap_service_response_send()
|
||||||
{
|
{
|
||||||
uint8_t buf[16];
|
uint8_t buf[16];
|
||||||
coap_message_handler_stub.int8_value = 6;
|
coap_message_handler_stub.int8_value = 6;
|
||||||
if( 6 != coap_service_response_send(0,0,NULL, 65, 0,NULL, 0))
|
if (6 != coap_service_response_send(0, 0, NULL, 65, 0, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,16 +285,19 @@ bool test_coap_callbacks()
|
||||||
coap_message_handler_stub.coap_ptr = (coap_msg_handler_t *)malloc(sizeof(coap_msg_handler_t));
|
coap_message_handler_stub.coap_ptr = (coap_msg_handler_t *)malloc(sizeof(coap_msg_handler_t));
|
||||||
memset(coap_message_handler_stub.coap_ptr, 0, sizeof(coap_msg_handler_t));
|
memset(coap_message_handler_stub.coap_ptr, 0, sizeof(coap_msg_handler_t));
|
||||||
|
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( 0 != coap_message_handler_stub.coap_ptr->sn_coap_service_malloc(0))
|
if (0 != coap_message_handler_stub.coap_ptr->sn_coap_service_malloc(0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
void *handle = coap_message_handler_stub.coap_ptr->sn_coap_service_malloc(5);
|
void *handle = coap_message_handler_stub.coap_ptr->sn_coap_service_malloc(5);
|
||||||
if( 0 == handle )
|
if (0 == handle) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_message_handler_stub.coap_ptr->sn_coap_service_free(handle);
|
coap_message_handler_stub.coap_ptr->sn_coap_service_free(handle);
|
||||||
|
|
||||||
|
@ -273,23 +308,27 @@ bool test_coap_callbacks()
|
||||||
addr.addr_len = 2;
|
addr.addr_len = 2;
|
||||||
addr.port = 4;
|
addr.port = 4;
|
||||||
addr.addr_ptr = &data;
|
addr.addr_ptr = &data;
|
||||||
if( 0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(NULL, 0, &addr, NULL))
|
if (0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(NULL, 0, &addr, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_transaction_t *tr = (coap_transaction_t *)malloc(sizeof(coap_transaction_t));
|
coap_transaction_t *tr = (coap_transaction_t *)malloc(sizeof(coap_transaction_t));
|
||||||
memset(tr, 0, sizeof(coap_transaction_t));
|
memset(tr, 0, sizeof(coap_transaction_t));
|
||||||
|
|
||||||
if( 0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 0, &addr, tr))
|
if (0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 0, &addr, tr)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
tr->service_id = 1;
|
tr->service_id = 1;
|
||||||
thread_conn_handler_stub.int_value = -2;
|
thread_conn_handler_stub.int_value = -2;
|
||||||
if( 0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 0, &addr, tr))
|
if (0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 0, &addr, tr)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 2, &addr, tr))
|
if (0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 2, &addr, tr)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
free(tr->data_ptr);
|
free(tr->data_ptr);
|
||||||
free(tr);
|
free(tr);
|
||||||
|
@ -312,8 +351,9 @@ bool test_eventOS_callbacks()
|
||||||
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (eventOs_event_stub.event_ptr) {
|
if (eventOs_event_stub.event_ptr) {
|
||||||
arm_event_s event;
|
arm_event_s event;
|
||||||
|
@ -337,38 +377,44 @@ bool test_conn_handler_callbacks()
|
||||||
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t *)malloc(sizeof(coap_conn_handler_t));
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 1 != coap_service_initialize(1, 2, COAP_SERVICE_OPTIONS_SECURE_BYPASS, &sec_start_cb, &sec_done_cb_test ))
|
if (1 != coap_service_initialize(1, 2, COAP_SERVICE_OPTIONS_SECURE_BYPASS, &sec_start_cb, &sec_done_cb_test)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (thread_conn_handler_stub.send_to_sock_cb) {
|
if (thread_conn_handler_stub.send_to_sock_cb) {
|
||||||
thread_conn_handler_stub.bool_value = true;
|
thread_conn_handler_stub.bool_value = true;
|
||||||
coap_service_virtual_socket_set_cb(1, &virtual_sock_send_cb);
|
coap_service_virtual_socket_set_cb(1, &virtual_sock_send_cb);
|
||||||
if( 2 != thread_conn_handler_stub.send_to_sock_cb(1, buf, 12, NULL, 0))
|
if (2 != thread_conn_handler_stub.send_to_sock_cb(1, buf, 12, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
thread_conn_handler_stub.bool_value = false;
|
thread_conn_handler_stub.bool_value = false;
|
||||||
if( -1 != thread_conn_handler_stub.send_to_sock_cb(1, buf, 12, NULL, 0))
|
if (-1 != thread_conn_handler_stub.send_to_sock_cb(1, buf, 12, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (thread_conn_handler_stub.receive_from_sock_cb) {
|
if (thread_conn_handler_stub.receive_from_sock_cb) {
|
||||||
coap_message_handler_stub.int16_value = 2;
|
coap_message_handler_stub.int16_value = 2;
|
||||||
if( -1 != thread_conn_handler_stub.receive_from_sock_cb(1, buf, 12, NULL, NULL, 0))
|
if (-1 != thread_conn_handler_stub.receive_from_sock_cb(1, buf, 12, NULL, NULL, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
uint8_t *ptr = ns_dyn_mem_alloc(5);
|
uint8_t *ptr = ns_dyn_mem_alloc(5);
|
||||||
memset(ptr, 3, 5);
|
memset(ptr, 3, 5);
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 2 != thread_conn_handler_stub.receive_from_sock_cb(1, buf, 12, NULL, ptr, 5))
|
if (2 != thread_conn_handler_stub.receive_from_sock_cb(1, buf, 12, NULL, ptr, 5)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
ns_dyn_mem_free(ptr);
|
ns_dyn_mem_free(ptr);
|
||||||
coap_message_handler_stub.int16_value = 0;
|
coap_message_handler_stub.int16_value = 0;
|
||||||
|
|
||||||
//This could be moved to own test function,
|
//This could be moved to own test function,
|
||||||
//but thread_conn_handler_stub.receive_from_sock_cb must be called successfully
|
//but thread_conn_handler_stub.receive_from_sock_cb must be called successfully
|
||||||
if (coap_message_handler_stub.cb) {
|
if (coap_message_handler_stub.cb) {
|
||||||
if( -1 != coap_message_handler_stub.cb(1, NULL, NULL) )
|
if (-1 != coap_message_handler_stub.cb(1, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sn_coap_hdr_s *coap = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
sn_coap_hdr_s *coap = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
|
||||||
memset(coap, 0, sizeof(sn_coap_hdr_s));
|
memset(coap, 0, sizeof(sn_coap_hdr_s));
|
||||||
|
@ -377,22 +423,26 @@ bool test_conn_handler_callbacks()
|
||||||
coap->uri_path_ptr = &uri;
|
coap->uri_path_ptr = &uri;
|
||||||
coap->uri_path_len = 2;
|
coap->uri_path_len = 2;
|
||||||
|
|
||||||
if( -1 != coap_message_handler_stub.cb(1, coap, NULL) )
|
if (-1 != coap_message_handler_stub.cb(1, coap, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
thread_conn_handler_stub.bool_value = true;
|
thread_conn_handler_stub.bool_value = true;
|
||||||
nsdynmemlib_stub.returnCounter = 2;
|
nsdynmemlib_stub.returnCounter = 2;
|
||||||
if( 0 != coap_service_register_uri(1, "as", 1, &request_recv_cb) )
|
if (0 != coap_service_register_uri(1, "as", 1, &request_recv_cb)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( -1 != coap_message_handler_stub.cb(1, coap, NULL) )
|
if (-1 != coap_message_handler_stub.cb(1, coap, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
coap_transaction_t *tr = (coap_transaction_t *)malloc(sizeof(coap_transaction_t));
|
coap_transaction_t *tr = (coap_transaction_t *)malloc(sizeof(coap_transaction_t));
|
||||||
memset(tr, 0, sizeof(coap_transaction_t));
|
memset(tr, 0, sizeof(coap_transaction_t));
|
||||||
|
|
||||||
if( 2 != coap_message_handler_stub.cb(1, coap, tr) )
|
if (2 != coap_message_handler_stub.cb(1, coap, tr)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
free(tr);
|
free(tr);
|
||||||
tr = NULL;
|
tr = NULL;
|
||||||
|
@ -408,13 +458,15 @@ bool test_conn_handler_callbacks()
|
||||||
memset(&security_ptr, 0, sizeof(coap_security_keys_t));
|
memset(&security_ptr, 0, sizeof(coap_security_keys_t));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
thread_conn_handler_stub.bool_value = true;
|
thread_conn_handler_stub.bool_value = true;
|
||||||
if( 0 != thread_conn_handler_stub.get_passwd_cb(1, buf, 12, &security_ptr))
|
if (0 != thread_conn_handler_stub.get_passwd_cb(1, buf, 12, &security_ptr)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
free(security_ptr._key);
|
free(security_ptr._key);
|
||||||
thread_conn_handler_stub.bool_value = false;
|
thread_conn_handler_stub.bool_value = false;
|
||||||
if( -1 != thread_conn_handler_stub.get_passwd_cb(1, buf, 12, NULL))
|
if (-1 != thread_conn_handler_stub.get_passwd_cb(1, buf, 12, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (thread_conn_handler_stub.sec_done_cb) {
|
if (thread_conn_handler_stub.sec_done_cb) {
|
||||||
uint8_t block[40];
|
uint8_t block[40];
|
||||||
|
@ -455,8 +507,9 @@ bool test_certificate_set()
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocation fails */
|
/* Allocation fails */
|
||||||
if (-1 != coap_service_certificate_set(1, NULL, 0, NULL, 0)) {
|
if (-1 != coap_service_certificate_set(1, NULL, 0, NULL, 0)) {
|
||||||
|
@ -489,8 +542,9 @@ bool test_handshake_timeout_set()
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* All OK */
|
/* All OK */
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
|
@ -521,8 +575,9 @@ bool test_coap_duplcate_msg_buffer_set()
|
||||||
memset(coap_message_handler_stub.coap_ptr, 0, sizeof(coap_msg_handler_t));
|
memset(coap_message_handler_stub.coap_ptr, 0, sizeof(coap_msg_handler_t));
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
ret = false;
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
/* All OK */
|
/* All OK */
|
||||||
if (0 != coap_service_set_duplicate_message_buffer(0, 0)) {
|
if (0 != coap_service_set_duplicate_message_buffer(0, 0)) {
|
||||||
|
@ -559,8 +614,9 @@ bool test_coap_service_if_find_by_socket()
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
thread_conn_handler_stub.bool_value = 0;
|
thread_conn_handler_stub.bool_value = 0;
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if (1 != coap_service_initialize(1, 2, 0, NULL, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* No matching service ID - return false */
|
/* No matching service ID - return false */
|
||||||
if (0 != coap_service_id_find_by_socket(1)) {
|
if (0 != coap_service_id_find_by_socket(1)) {
|
||||||
|
|
|
@ -39,6 +39,8 @@ bool test_coap_service_request_send();
|
||||||
|
|
||||||
bool test_coap_service_request_delete();
|
bool test_coap_service_request_delete();
|
||||||
|
|
||||||
|
bool test_coap_service_request_delete_by_service_id();
|
||||||
|
|
||||||
bool test_coap_service_response_send();
|
bool test_coap_service_response_send();
|
||||||
|
|
||||||
bool test_coap_callbacks();
|
bool test_coap_callbacks();
|
||||||
|
|
|
@ -39,6 +39,7 @@ void transactions_delete_all(uint8_t *address_ptr, uint16_t port)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t coap_message_handler_destroy(coap_msg_handler_t *handle)
|
int8_t coap_message_handler_destroy(coap_msg_handler_t *handle)
|
||||||
{
|
{
|
||||||
return coap_message_handler_stub.int8_value;
|
return coap_message_handler_stub.int8_value;
|
||||||
|
@ -78,6 +79,11 @@ int8_t coap_message_handler_request_delete(coap_msg_handler_t *handle, int8_t se
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t coap_message_handler_request_delete_by_service_id(coap_msg_handler_t *handle, int8_t service_id)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t current_time)
|
int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t current_time)
|
||||||
{
|
{
|
||||||
return coap_message_handler_stub.int8_value;
|
return coap_message_handler_stub.int8_value;
|
||||||
|
|
|
@ -28,9 +28,10 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl )
|
||||||
mbedtls_stub.retArray[mbedtls_stub.counter] == HANDSHAKE_FINISHED_VALUE_RETURN_ZERO) {
|
mbedtls_stub.retArray[mbedtls_stub.counter] == HANDSHAKE_FINISHED_VALUE_RETURN_ZERO) {
|
||||||
|
|
||||||
ssl->state = MBEDTLS_SSL_HANDSHAKE_OVER;
|
ssl->state = MBEDTLS_SSL_HANDSHAKE_OVER;
|
||||||
if(mbedtls_stub.retArray[mbedtls_stub.counter] == HANDSHAKE_FINISHED_VALUE_RETURN_ZERO)
|
if (mbedtls_stub.retArray[mbedtls_stub.counter] == HANDSHAKE_FINISHED_VALUE_RETURN_ZERO) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
return mbedtls_stub.expected_int;
|
return mbedtls_stub.expected_int;
|
||||||
|
@ -44,18 +45,22 @@ int mbedtls_ssl_close_notify( mbedtls_ssl_context *a )
|
||||||
return mbedtls_stub.expected_int;
|
return mbedtls_stub.expected_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_ssl_init( mbedtls_ssl_context *a ){
|
void mbedtls_ssl_init(mbedtls_ssl_context *a)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void mbedtls_ssl_conf_min_version( mbedtls_ssl_config *conf, int major, int minor ){
|
void mbedtls_ssl_conf_min_version(mbedtls_ssl_config *conf, int major, int minor)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_ssl_conf_max_version( mbedtls_ssl_config *conf, int major, int minor ){
|
void mbedtls_ssl_conf_max_version(mbedtls_ssl_config *conf, int major, int minor)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_ssl_config_init( mbedtls_ssl_config *a ){
|
void mbedtls_ssl_config_init(mbedtls_ssl_config *a)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,32 +69,37 @@ void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *a, uint32_t b, uint
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_ssl_free( mbedtls_ssl_context *a ){
|
void mbedtls_ssl_free(mbedtls_ssl_context *a)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_ssl_conf_own_cert(mbedtls_ssl_config *a,
|
int mbedtls_ssl_conf_own_cert(mbedtls_ssl_config *a,
|
||||||
mbedtls_x509_crt *b,
|
mbedtls_x509_crt *b,
|
||||||
mbedtls_pk_context *c ){
|
mbedtls_pk_context *c)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
return mbedtls_stub.expected_int;
|
return mbedtls_stub.expected_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *a, int c ){
|
void mbedtls_ssl_conf_authmode(mbedtls_ssl_config *a, int c)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_ssl_conf_ca_chain(mbedtls_ssl_config *a,
|
void mbedtls_ssl_conf_ca_chain(mbedtls_ssl_config *a,
|
||||||
mbedtls_x509_crt *b,
|
mbedtls_x509_crt *b,
|
||||||
mbedtls_x509_crl *c ){
|
mbedtls_x509_crl *c)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_ssl_conf_psk(mbedtls_ssl_config *a,
|
int mbedtls_ssl_conf_psk(mbedtls_ssl_config *a,
|
||||||
const unsigned char *b, size_t c,
|
const unsigned char *b, size_t c,
|
||||||
const unsigned char *d, size_t e ){
|
const unsigned char *d, size_t e)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
|
@ -97,7 +107,8 @@ int mbedtls_ssl_conf_psk( mbedtls_ssl_config *a,
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_ssl_config_defaults(mbedtls_ssl_config *a,
|
int mbedtls_ssl_config_defaults(mbedtls_ssl_config *a,
|
||||||
int b, int c, int d){
|
int b, int c, int d)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
|
@ -106,7 +117,8 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *a,
|
||||||
|
|
||||||
void mbedtls_ssl_conf_rng(mbedtls_ssl_config *a,
|
void mbedtls_ssl_conf_rng(mbedtls_ssl_config *a,
|
||||||
int (*f_rng)(void *, unsigned char *, size_t),
|
int (*f_rng)(void *, unsigned char *, size_t),
|
||||||
void *b ){
|
void *b)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +129,8 @@ void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *a,
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_ssl_setup(mbedtls_ssl_context *a,
|
int mbedtls_ssl_setup(mbedtls_ssl_context *a,
|
||||||
const mbedtls_ssl_config *b ){
|
const mbedtls_ssl_config *b)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
|
@ -128,21 +141,26 @@ void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl,
|
||||||
void *p_bio,
|
void *p_bio,
|
||||||
int (*f_send)(void *, const unsigned char *, size_t),
|
int (*f_send)(void *, const unsigned char *, size_t),
|
||||||
int (*f_recv)(void *, unsigned char *, size_t),
|
int (*f_recv)(void *, unsigned char *, size_t),
|
||||||
int (*f_recv_timeout)(void *, unsigned char *, size_t, uint32_t) ){
|
int (*f_recv_timeout)(void *, unsigned char *, size_t, uint32_t))
|
||||||
|
{
|
||||||
if (p_bio != NULL) {
|
if (p_bio != NULL) {
|
||||||
if( f_send )
|
if (f_send) {
|
||||||
f_send(p_bio, NULL, 0);
|
f_send(p_bio, NULL, 0);
|
||||||
if( f_recv )
|
}
|
||||||
|
if (f_recv) {
|
||||||
f_recv(p_bio, NULL, 0);
|
f_recv(p_bio, NULL, 0);
|
||||||
if( f_recv_timeout )
|
}
|
||||||
|
if (f_recv_timeout) {
|
||||||
f_recv_timeout(p_bio, NULL, 0, 0);
|
f_recv_timeout(p_bio, NULL, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void mbedtls_ssl_set_timer_cb(mbedtls_ssl_context *a,
|
void mbedtls_ssl_set_timer_cb(mbedtls_ssl_context *a,
|
||||||
void *ctx,
|
void *ctx,
|
||||||
void (*f_set_timer)(void *, uint32_t int_ms, uint32_t fin_ms),
|
void (*f_set_timer)(void *, uint32_t int_ms, uint32_t fin_ms),
|
||||||
int (*f_get_timer)(void *) ){
|
int (*f_get_timer)(void *))
|
||||||
|
{
|
||||||
f_set_timer(ctx, 1, 2);
|
f_set_timer(ctx, 1, 2);
|
||||||
f_get_timer(ctx);
|
f_get_timer(ctx);
|
||||||
if (mbedtls_stub.invalidate_timer) {
|
if (mbedtls_stub.invalidate_timer) {
|
||||||
|
@ -151,25 +169,29 @@ void mbedtls_ssl_set_timer_cb( mbedtls_ssl_context *a,
|
||||||
f_get_timer(ctx);
|
f_get_timer(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl ){
|
int mbedtls_ssl_handshake(mbedtls_ssl_context *ssl)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
return mbedtls_stub.expected_int;
|
return mbedtls_stub.expected_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *a ){
|
uint32_t mbedtls_ssl_get_verify_result(const mbedtls_ssl_context *a)
|
||||||
|
{
|
||||||
return mbedtls_stub.uint32_value;
|
return mbedtls_stub.uint32_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_ssl_read( mbedtls_ssl_context *a, unsigned char *b, size_t c){
|
int mbedtls_ssl_read(mbedtls_ssl_context *a, unsigned char *b, size_t c)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
return mbedtls_stub.expected_int;
|
return mbedtls_stub.expected_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_ssl_write( mbedtls_ssl_context *a, const unsigned char *b, size_t c ){
|
int mbedtls_ssl_write(mbedtls_ssl_context *a, const unsigned char *b, size_t c)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
|
@ -183,39 +205,47 @@ int mbedtls_ctr_drbg_seed( mbedtls_ctr_drbg_context *a,
|
||||||
int (*f_entropy)(void *, unsigned char *, size_t),
|
int (*f_entropy)(void *, unsigned char *, size_t),
|
||||||
void *b,
|
void *b,
|
||||||
const unsigned char *c,
|
const unsigned char *c,
|
||||||
size_t d ){
|
size_t d)
|
||||||
|
{
|
||||||
return mbedtls_stub.crt_expected_int;
|
return mbedtls_stub.crt_expected_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *a ){
|
void mbedtls_ctr_drbg_init(mbedtls_ctr_drbg_context *a)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_ctr_drbg_free( mbedtls_ctr_drbg_context *a ){
|
void mbedtls_ctr_drbg_free(mbedtls_ctr_drbg_context *a)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_ctr_drbg_random_with_add(void *a,
|
int mbedtls_ctr_drbg_random_with_add(void *a,
|
||||||
unsigned char *b, size_t c,
|
unsigned char *b, size_t c,
|
||||||
const unsigned char *d, size_t e ){
|
const unsigned char *d, size_t e)
|
||||||
|
{
|
||||||
return mbedtls_stub.crt_expected_int;
|
return mbedtls_stub.crt_expected_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_ctr_drbg_random(void *p_rng,
|
int mbedtls_ctr_drbg_random(void *p_rng,
|
||||||
unsigned char *output, size_t output_len ){
|
unsigned char *output, size_t output_len)
|
||||||
|
{
|
||||||
return mbedtls_stub.crt_expected_int;
|
return mbedtls_stub.crt_expected_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
//From x509_crt.h
|
//From x509_crt.h
|
||||||
void mbedtls_x509_crt_init( mbedtls_x509_crt *a ){
|
void mbedtls_x509_crt_init(mbedtls_x509_crt *a)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_x509_crt_free( mbedtls_x509_crt *a ){
|
void mbedtls_x509_crt_free(mbedtls_x509_crt *a)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_x509_crt_parse( mbedtls_x509_crt *a, const unsigned char *b, size_t c ){
|
int mbedtls_x509_crt_parse(mbedtls_x509_crt *a, const unsigned char *b, size_t c)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
|
@ -223,15 +253,18 @@ int mbedtls_x509_crt_parse( mbedtls_x509_crt *a, const unsigned char *b, size_t
|
||||||
}
|
}
|
||||||
|
|
||||||
//From entropy.h
|
//From entropy.h
|
||||||
void mbedtls_entropy_init( mbedtls_entropy_context *a ){
|
void mbedtls_entropy_init(mbedtls_entropy_context *a)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_entropy_free( mbedtls_entropy_context *ctx ){
|
void mbedtls_entropy_free(mbedtls_entropy_context *ctx)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_entropy_func( void *a, unsigned char *b, size_t c ){
|
int mbedtls_entropy_func(void *a, unsigned char *b, size_t c)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
|
@ -240,7 +273,8 @@ int mbedtls_entropy_func( void *a, unsigned char *b, size_t c ){
|
||||||
|
|
||||||
int mbedtls_entropy_add_source(mbedtls_entropy_context *a,
|
int mbedtls_entropy_add_source(mbedtls_entropy_context *a,
|
||||||
mbedtls_entropy_f_source_ptr f_source, void *b,
|
mbedtls_entropy_f_source_ptr f_source, void *b,
|
||||||
size_t c, int d ){
|
size_t c, int d)
|
||||||
|
{
|
||||||
unsigned char buf[2];
|
unsigned char buf[2];
|
||||||
size_t len;
|
size_t len;
|
||||||
f_source(NULL, buf, 1, &len);
|
f_source(NULL, buf, 1, &len);
|
||||||
|
@ -254,7 +288,8 @@ int mbedtls_entropy_add_source( mbedtls_entropy_context *a,
|
||||||
//From pk.h
|
//From pk.h
|
||||||
int mbedtls_pk_parse_key(mbedtls_pk_context *a,
|
int mbedtls_pk_parse_key(mbedtls_pk_context *a,
|
||||||
const unsigned char *b, size_t c,
|
const unsigned char *b, size_t c,
|
||||||
const unsigned char *d, size_t e ){
|
const unsigned char *d, size_t e)
|
||||||
|
{
|
||||||
if (mbedtls_stub.useCounter) {
|
if (mbedtls_stub.useCounter) {
|
||||||
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
return mbedtls_stub.retArray[mbedtls_stub.counter++];
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,26 +37,20 @@ void ns_dyn_mem_init(void *heap, ns_mem_heap_size_t h_size, void (*passed_fptr)(
|
||||||
|
|
||||||
void *ns_dyn_mem_alloc(ns_mem_block_size_t alloc_size)
|
void *ns_dyn_mem_alloc(ns_mem_block_size_t alloc_size)
|
||||||
{
|
{
|
||||||
if (nsdynmemlib_stub.returnCounter > 0)
|
if (nsdynmemlib_stub.returnCounter > 0) {
|
||||||
{
|
|
||||||
nsdynmemlib_stub.returnCounter--;
|
nsdynmemlib_stub.returnCounter--;
|
||||||
return malloc(alloc_size);
|
return malloc(alloc_size);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return (nsdynmemlib_stub.expectedPointer);
|
return (nsdynmemlib_stub.expectedPointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ns_dyn_mem_temporary_alloc(ns_mem_block_size_t alloc_size)
|
void *ns_dyn_mem_temporary_alloc(ns_mem_block_size_t alloc_size)
|
||||||
{
|
{
|
||||||
if (nsdynmemlib_stub.returnCounter > 0)
|
if (nsdynmemlib_stub.returnCounter > 0) {
|
||||||
{
|
|
||||||
nsdynmemlib_stub.returnCounter--;
|
nsdynmemlib_stub.returnCounter--;
|
||||||
return malloc(alloc_size);
|
return malloc(alloc_size);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return (nsdynmemlib_stub.expectedPointer);
|
return (nsdynmemlib_stub.expectedPointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,10 @@
|
||||||
* /enum dhcp_instance_type
|
* /enum dhcp_instance_type
|
||||||
* /brief DHCP instance types.
|
* /brief DHCP instance types.
|
||||||
*/
|
*/
|
||||||
typedef enum dhcp_instance_type
|
typedef enum dhcp_instance_type {
|
||||||
{
|
|
||||||
DHCP_INSTANCE_CLIENT,
|
DHCP_INSTANCE_CLIENT,
|
||||||
DHCP_INSTANCE_SERVER
|
DHCP_INSTANCE_SERVER,
|
||||||
|
DHCP_INTANCE_RELAY_AGENT
|
||||||
} dhcp_instance_type_e;
|
} dhcp_instance_type_e;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,6 +124,16 @@ typedef int (dhcp_service_receive_resp_cb)(uint16_t instance_id, void *ptr, uint
|
||||||
|
|
||||||
uint16_t dhcp_service_init(int8_t interface_id, dhcp_instance_type_e instance_type, dhcp_service_receive_req_cb *receive_req_cb);
|
uint16_t dhcp_service_init(int8_t interface_id, dhcp_instance_type_e instance_type, dhcp_service_receive_req_cb *receive_req_cb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Enable DHCPv6 Relay Agent to server.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \param instance The instance ID of the registered server.
|
||||||
|
* \param server_address global server IPv6 address
|
||||||
|
*/
|
||||||
|
void dhcp_service_relay_instance_enable(uint16_t instance, uint8_t *server_address);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Deletes a server instance.
|
* \brief Deletes a server instance.
|
||||||
*
|
*
|
||||||
|
|
|
@ -46,8 +46,7 @@ typedef struct fhss_callback fhss_callback_t;
|
||||||
/**
|
/**
|
||||||
* @brief FHSS states.
|
* @brief FHSS states.
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
FHSS_UNSYNCHRONIZED,
|
FHSS_UNSYNCHRONIZED,
|
||||||
FHSS_SYNCHRONIZED,
|
FHSS_SYNCHRONIZED,
|
||||||
} fhss_states;
|
} fhss_states;
|
||||||
|
@ -132,8 +131,9 @@ typedef bool fhss_data_tx_fail(const fhss_api_t *api, uint8_t handle, int frame_
|
||||||
* @param api FHSS instance.
|
* @param api FHSS instance.
|
||||||
* @param fhss_state FHSS state (FHSS states are defined by FHSS api).
|
* @param fhss_state FHSS state (FHSS states are defined by FHSS api).
|
||||||
* @param pan_id PAN id of the network FHSS synchronizes with.
|
* @param pan_id PAN id of the network FHSS synchronizes with.
|
||||||
|
* @return -1 when failed, otherwise current MAC channel.
|
||||||
*/
|
*/
|
||||||
typedef void fhss_synch_state_set(const fhss_api_t *api, fhss_states fhss_state, uint16_t pan_id);
|
typedef int16_t fhss_synch_state_set(const fhss_api_t *api, fhss_states fhss_state, uint16_t pan_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read timestamp.
|
* @brief Read timestamp.
|
||||||
|
@ -215,6 +215,13 @@ typedef int mac_read_mac_address(const fhss_api_t *fhss_api, uint8_t *mac_addres
|
||||||
*/
|
*/
|
||||||
typedef uint32_t mac_read_datarate(const fhss_api_t *fhss_api);
|
typedef uint32_t mac_read_datarate(const fhss_api_t *fhss_api);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read 32-bit timestamp.
|
||||||
|
* @param fhss_api FHSS instance.
|
||||||
|
* @return Timestamp.
|
||||||
|
*/
|
||||||
|
typedef uint32_t mac_read_timestamp(const fhss_api_t *fhss_api);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Change channel.
|
* @brief Change channel.
|
||||||
* @param fhss_api FHSS instance.
|
* @param fhss_api FHSS instance.
|
||||||
|
@ -287,6 +294,7 @@ struct fhss_callback {
|
||||||
mac_read_tx_queue_size *read_tx_queue_size; /**< Read MAC TX queue size. */
|
mac_read_tx_queue_size *read_tx_queue_size; /**< Read MAC TX queue size. */
|
||||||
mac_read_mac_address *read_mac_address; /**< Read MAC address. */
|
mac_read_mac_address *read_mac_address; /**< Read MAC address. */
|
||||||
mac_read_datarate *read_datarate; /**< Read PHY datarate. */
|
mac_read_datarate *read_datarate; /**< Read PHY datarate. */
|
||||||
|
mac_read_timestamp *read_timestamp; /**< Read timestamp. */
|
||||||
mac_change_channel *change_channel; /**< Change channel. */
|
mac_change_channel *change_channel; /**< Change channel. */
|
||||||
mac_send_fhss_frame *send_fhss_frame; /**< Send FHSS frame. */
|
mac_send_fhss_frame *send_fhss_frame; /**< Send FHSS frame. */
|
||||||
mac_synch_lost_notification *synch_lost_notification; /**< Send notification when FHSS synchronization is lost. */
|
mac_synch_lost_notification *synch_lost_notification; /**< Send notification when FHSS synchronization is lost. */
|
||||||
|
|
|
@ -33,8 +33,7 @@ extern "C" {
|
||||||
/**
|
/**
|
||||||
* @brief WS channel functions.
|
* @brief WS channel functions.
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
/** Fixed channel. */
|
/** Fixed channel. */
|
||||||
WS_FIXED_CHANNEL,
|
WS_FIXED_CHANNEL,
|
||||||
/** TR51 channel function. */
|
/** TR51 channel function. */
|
||||||
|
@ -49,8 +48,7 @@ typedef enum
|
||||||
* \brief Struct fhss_tuning_parameter defines FHSS tuning parameters.
|
* \brief Struct fhss_tuning_parameter defines FHSS tuning parameters.
|
||||||
* All delays are given in microseconds.
|
* All delays are given in microseconds.
|
||||||
*/
|
*/
|
||||||
typedef struct fhss_tuning_parameter
|
typedef struct fhss_tuning_parameter {
|
||||||
{
|
|
||||||
/** Delay between data pushed to PHY TX function and TX started (Contains CSMA-CA maximum random period). */
|
/** Delay between data pushed to PHY TX function and TX started (Contains CSMA-CA maximum random period). */
|
||||||
uint32_t tx_processing_delay;
|
uint32_t tx_processing_delay;
|
||||||
|
|
||||||
|
@ -64,8 +62,7 @@ typedef struct fhss_tuning_parameter
|
||||||
/**
|
/**
|
||||||
* \brief Struct fhss_configuration defines basic configuration of FHSS.
|
* \brief Struct fhss_configuration defines basic configuration of FHSS.
|
||||||
*/
|
*/
|
||||||
typedef struct fhss_configuration
|
typedef struct fhss_configuration {
|
||||||
{
|
|
||||||
/** Tuning parameters can be used to enhance synchronization accuracy*/
|
/** Tuning parameters can be used to enhance synchronization accuracy*/
|
||||||
fhss_tuning_parameter_t fhss_tuning_parameters;
|
fhss_tuning_parameter_t fhss_tuning_parameters;
|
||||||
|
|
||||||
|
@ -94,10 +91,12 @@ typedef int32_t fhss_vendor_defined_cf(const fhss_api_t *api, uint16_t slot, uin
|
||||||
/**
|
/**
|
||||||
* \brief Struct fhss_ws_configuration defines configuration of WS FHSS.
|
* \brief Struct fhss_ws_configuration defines configuration of WS FHSS.
|
||||||
*/
|
*/
|
||||||
typedef struct fhss_ws_configuration
|
typedef struct fhss_ws_configuration {
|
||||||
{
|
/** WS unicast channel function. */
|
||||||
/** WS channel function. */
|
fhss_ws_channel_functions ws_uc_channel_function;
|
||||||
fhss_ws_channel_functions ws_channel_function;
|
|
||||||
|
/** WS broadcast channel function. */
|
||||||
|
fhss_ws_channel_functions ws_bc_channel_function;
|
||||||
|
|
||||||
/** Broadcast schedule identifier. */
|
/** Broadcast schedule identifier. */
|
||||||
uint16_t bsi;
|
uint16_t bsi;
|
||||||
|
@ -111,6 +110,12 @@ typedef struct fhss_ws_configuration
|
||||||
/** Broadcast dwell interval. Range: 15-250 milliseconds. */
|
/** Broadcast dwell interval. Range: 15-250 milliseconds. */
|
||||||
uint8_t fhss_bc_dwell_interval;
|
uint8_t fhss_bc_dwell_interval;
|
||||||
|
|
||||||
|
/** Unicast fixed channel */
|
||||||
|
uint8_t unicast_fixed_channel;
|
||||||
|
|
||||||
|
/** Broadcast fixed channel */
|
||||||
|
uint8_t broadcast_fixed_channel;
|
||||||
|
|
||||||
/** Channel mask. */
|
/** Channel mask. */
|
||||||
uint32_t channel_mask[8];
|
uint32_t channel_mask[8];
|
||||||
|
|
||||||
|
@ -123,8 +128,7 @@ typedef struct fhss_ws_configuration
|
||||||
* \brief Struct fhss_timer defines interface between FHSS and FHSS platform timer.
|
* \brief Struct fhss_timer defines interface between FHSS and FHSS platform timer.
|
||||||
* Application must implement FHSS timer driver which is then used by FHSS with this interface.
|
* Application must implement FHSS timer driver which is then used by FHSS with this interface.
|
||||||
*/
|
*/
|
||||||
typedef struct fhss_timer
|
typedef struct fhss_timer {
|
||||||
{
|
|
||||||
/** Start timeout (1us). Timer must support multiple simultaneous timeouts */
|
/** Start timeout (1us). Timer must support multiple simultaneous timeouts */
|
||||||
int (*fhss_timer_start)(uint32_t, void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t), const fhss_api_t *fhss_api);
|
int (*fhss_timer_start)(uint32_t, void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t), const fhss_api_t *fhss_api);
|
||||||
|
|
||||||
|
@ -145,8 +149,7 @@ typedef struct fhss_timer
|
||||||
* \brief Struct fhss_synch_configuration defines the synchronization time configurations.
|
* \brief Struct fhss_synch_configuration defines the synchronization time configurations.
|
||||||
* Border router application must define and set these configuration for FHSS network.
|
* Border router application must define and set these configuration for FHSS network.
|
||||||
*/
|
*/
|
||||||
typedef struct fhss_synch_configuration
|
typedef struct fhss_synch_configuration {
|
||||||
{
|
|
||||||
/** Number of broadcast channels. */
|
/** Number of broadcast channels. */
|
||||||
uint8_t fhss_number_of_bc_channels;
|
uint8_t fhss_number_of_bc_channels;
|
||||||
|
|
||||||
|
@ -165,8 +168,7 @@ typedef struct fhss_synch_configuration
|
||||||
/**
|
/**
|
||||||
* \brief Struct fhss_statistics defines the available FHSS statistics.
|
* \brief Struct fhss_statistics defines the available FHSS statistics.
|
||||||
*/
|
*/
|
||||||
typedef struct fhss_statistics
|
typedef struct fhss_statistics {
|
||||||
{
|
|
||||||
/** FHSS synchronization drift compensation (us/channel). */
|
/** FHSS synchronization drift compensation (us/channel). */
|
||||||
int16_t fhss_drift_compensation;
|
int16_t fhss_drift_compensation;
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ typedef struct unicast_timing_info {
|
||||||
unsigned unicast_channel_function: 3; /**< Unicast schedule channel function */
|
unsigned unicast_channel_function: 3; /**< Unicast schedule channel function */
|
||||||
uint8_t unicast_dwell_interval; /**< Unicast dwell interval */
|
uint8_t unicast_dwell_interval; /**< Unicast dwell interval */
|
||||||
uint16_t unicast_number_of_channels; /**< Unicast number of channels */
|
uint16_t unicast_number_of_channels; /**< Unicast number of channels */
|
||||||
|
uint16_t fixed_channel; /**< Unicast fixed channel*/
|
||||||
uint_fast24_t ufsi; /**< Unicast fractional sequence interval */
|
uint_fast24_t ufsi; /**< Unicast fractional sequence interval */
|
||||||
uint32_t utt_rx_timestamp; /**< UTT-IE reception timestamp */
|
uint32_t utt_rx_timestamp; /**< UTT-IE reception timestamp */
|
||||||
} unicast_timing_info_t;
|
} unicast_timing_info_t;
|
||||||
|
@ -47,6 +48,7 @@ typedef struct unicast_timing_info {
|
||||||
typedef struct broadcast_timing_info {
|
typedef struct broadcast_timing_info {
|
||||||
unsigned broadcast_channel_function: 3; /**< Broadcast schedule channel function */
|
unsigned broadcast_channel_function: 3; /**< Broadcast schedule channel function */
|
||||||
uint8_t broadcast_dwell_interval; /**< Broadcast dwell interval */
|
uint8_t broadcast_dwell_interval; /**< Broadcast dwell interval */
|
||||||
|
uint16_t fixed_channel; /**< Broadcast fixed channel*/
|
||||||
uint16_t broadcast_slot; /**< Broadcast slot number */
|
uint16_t broadcast_slot; /**< Broadcast slot number */
|
||||||
uint16_t broadcast_schedule_id; /**< Broadcast schedule identifier */
|
uint16_t broadcast_schedule_id; /**< Broadcast schedule identifier */
|
||||||
uint_fast24_t broadcast_interval_offset; /**< Broadcast interval offset */
|
uint_fast24_t broadcast_interval_offset; /**< Broadcast interval offset */
|
||||||
|
@ -78,9 +80,10 @@ typedef fhss_ws_neighbor_timing_info_t *fhss_get_neighbor_info(const fhss_api_t
|
||||||
* @param fhss_api FHSS instance.
|
* @param fhss_api FHSS instance.
|
||||||
* @param eui64 EUI-64 address of parent.
|
* @param eui64 EUI-64 address of parent.
|
||||||
* @param bc_timing_info Pointer to parent broadcast timing/hopping schedule info.
|
* @param bc_timing_info Pointer to parent broadcast timing/hopping schedule info.
|
||||||
|
* @param force_synch If false, synchronization is done only if minimum (internal) synchronization interval is exceed.
|
||||||
* @return 0 on success, -1 on fail.
|
* @return 0 on success, -1 on fail.
|
||||||
*/
|
*/
|
||||||
extern int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info);
|
extern int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info, const bool force_synch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Remove parent which was set by ns_fhss_ws_set_parent function.
|
* @brief Remove parent which was set by ns_fhss_ws_set_parent function.
|
||||||
|
|
|
@ -137,8 +137,9 @@ typedef void mcps_data_request_ext(const mac_api_t* api, const mcps_data_req_t *
|
||||||
* @brief mcps_purge_request MCPS_PURGE request call
|
* @brief mcps_purge_request MCPS_PURGE request call
|
||||||
* @param api API to handle the request
|
* @param api API to handle the request
|
||||||
* @param data MCPS-PURGE.request specific values
|
* @param data MCPS-PURGE.request specific values
|
||||||
|
* @return 0 in case of success, non-zero otherwise
|
||||||
*/
|
*/
|
||||||
typedef void mcps_purge_request(const mac_api_t* api, const mcps_purge_t *data);
|
typedef uint8_t mcps_purge_request(const mac_api_t *api, const mcps_purge_t *data);
|
||||||
|
|
||||||
//Upper layer specific callback functions (will also be set by Upper layer after mac_api_t has been created and given to it)
|
//Upper layer specific callback functions (will also be set by Upper layer after mac_api_t has been created and given to it)
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,9 @@ extern "C" {
|
||||||
extern fhss_api_t *ns_fhss_create(const fhss_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer, fhss_statistics_t *fhss_statistics);
|
extern fhss_api_t *ns_fhss_create(const fhss_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer, fhss_statistics_t *fhss_statistics);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TODO: description.
|
* @brief Creates FHSS WS API instance which will be registered to software MAC.
|
||||||
* @param fhss_configuration Basic FHSS configuration.
|
* @param fhss_configuration Basic FHSS configuration.
|
||||||
* @param fhss_timer FHSS platform timer interface and configuration.
|
* @param fhss_timer FHSS platform timer interface and configuration.
|
||||||
* @param fhss_statistics FHSS statistics storage.
|
|
||||||
* @return New FHSS instance if successful, NULL otherwise.
|
* @return New FHSS instance if successful, NULL otherwise.
|
||||||
*/
|
*/
|
||||||
extern fhss_api_t *ns_fhss_ws_create(const fhss_ws_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer);
|
extern fhss_api_t *ns_fhss_ws_create(const fhss_ws_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer);
|
||||||
|
|
|
@ -257,8 +257,7 @@ typedef struct {
|
||||||
} border_router_setup_s;
|
} border_router_setup_s;
|
||||||
|
|
||||||
/** Channel list */
|
/** Channel list */
|
||||||
typedef struct channel_list_s
|
typedef struct channel_list_s {
|
||||||
{
|
|
||||||
channel_page_e channel_page; /**< Channel page */
|
channel_page_e channel_page; /**< Channel page */
|
||||||
uint32_t channel_mask[8]; /**< Channel mask. Each bit defining one channel */
|
uint32_t channel_mask[8]; /**< Channel mask. Each bit defining one channel */
|
||||||
} channel_list_s;
|
} channel_list_s;
|
||||||
|
|
|
@ -39,8 +39,7 @@ typedef struct ns_mdns_service *ns_mdns_service_t; /**< Service instance */
|
||||||
* \struct ns_mdns_service_param_t
|
* \struct ns_mdns_service_param_t
|
||||||
* \brief Structure for mDNS service parameters
|
* \brief Structure for mDNS service parameters
|
||||||
*/
|
*/
|
||||||
typedef struct ns_mdns_service_param
|
typedef struct ns_mdns_service_param {
|
||||||
{
|
|
||||||
const char *service_type; /**< Null-terminated string owned by the caller */
|
const char *service_type; /**< Null-terminated string owned by the caller */
|
||||||
uint16_t service_port; /**< Service Port number */
|
uint16_t service_port; /**< Service Port number */
|
||||||
const uint8_t *(*service_get_txt)(void); /**< Call-back function, which returns a pointer to the service TXT record (null-terminated).
|
const uint8_t *(*service_get_txt)(void); /**< Call-back function, which returns a pointer to the service TXT record (null-terminated).
|
||||||
|
|
|
@ -112,8 +112,7 @@ static inline void ns_sha256_nbits(const void *input, size_t ilen, void *output,
|
||||||
/**
|
/**
|
||||||
* \brief SHA-256 context structure
|
* \brief SHA-256 context structure
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32_t total[2]; /*!< number of bytes processed */
|
uint32_t total[2]; /*!< number of bytes processed */
|
||||||
uint32_t state[8]; /*!< intermediate digest state */
|
uint32_t state[8]; /*!< intermediate digest state */
|
||||||
unsigned char buffer[64]; /*!< data block being processed */
|
unsigned char buffer[64]; /*!< data block being processed */
|
||||||
|
|
|
@ -125,8 +125,7 @@ typedef struct phy_csma_params {
|
||||||
} phy_csma_params_t;
|
} phy_csma_params_t;
|
||||||
|
|
||||||
/** PHY modulation scheme */
|
/** PHY modulation scheme */
|
||||||
typedef enum phy_modulation_e
|
typedef enum phy_modulation_e {
|
||||||
{
|
|
||||||
M_OFDM, ///< QFDM
|
M_OFDM, ///< QFDM
|
||||||
M_OQPSK, ///< OQPSK
|
M_OQPSK, ///< OQPSK
|
||||||
M_BPSK, ///< BPSK
|
M_BPSK, ///< BPSK
|
||||||
|
@ -135,8 +134,7 @@ typedef enum phy_modulation_e
|
||||||
} phy_modulation_e;
|
} phy_modulation_e;
|
||||||
|
|
||||||
/** Channel page numbers */
|
/** Channel page numbers */
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
CHANNEL_PAGE_0 = 0, ///< Page 0
|
CHANNEL_PAGE_0 = 0, ///< Page 0
|
||||||
CHANNEL_PAGE_1 = 1, ///< Page 1
|
CHANNEL_PAGE_1 = 1, ///< Page 1
|
||||||
CHANNEL_PAGE_2 = 2, ///< Page 2
|
CHANNEL_PAGE_2 = 2, ///< Page 2
|
||||||
|
@ -149,8 +147,7 @@ typedef enum
|
||||||
} channel_page_e;
|
} channel_page_e;
|
||||||
|
|
||||||
/** Channel configuration */
|
/** Channel configuration */
|
||||||
typedef struct phy_rf_channel_configuration_s
|
typedef struct phy_rf_channel_configuration_s {
|
||||||
{
|
|
||||||
uint32_t channel_0_center_frequency; ///< Center frequency
|
uint32_t channel_0_center_frequency; ///< Center frequency
|
||||||
uint32_t channel_spacing; ///< Channel spacing
|
uint32_t channel_spacing; ///< Channel spacing
|
||||||
uint32_t datarate; ///< Data rate
|
uint32_t datarate; ///< Data rate
|
||||||
|
@ -159,8 +156,7 @@ typedef struct phy_rf_channel_configuration_s
|
||||||
} phy_rf_channel_configuration_s;
|
} phy_rf_channel_configuration_s;
|
||||||
|
|
||||||
/** Channel page configuration */
|
/** Channel page configuration */
|
||||||
typedef struct phy_device_channel_page_s
|
typedef struct phy_device_channel_page_s {
|
||||||
{
|
|
||||||
channel_page_e channel_page; ///< Channel page
|
channel_page_e channel_page; ///< Channel page
|
||||||
const phy_rf_channel_configuration_s *rf_channel_configuration; ///< Pointer to channel configuration
|
const phy_rf_channel_configuration_s *rf_channel_configuration; ///< Pointer to channel configuration
|
||||||
} phy_device_channel_page_s;
|
} phy_device_channel_page_s;
|
||||||
|
@ -240,8 +236,7 @@ typedef int8_t arm_net_virtual_config_tx_fn(int8_t driver_id, const uint8_t *dat
|
||||||
typedef int8_t arm_net_virtual_confirmation_rx_fn(int8_t driver_id, const uint8_t *data, uint16_t length);
|
typedef int8_t arm_net_virtual_confirmation_rx_fn(int8_t driver_id, const uint8_t *data, uint16_t length);
|
||||||
|
|
||||||
/** Device driver structure */
|
/** Device driver structure */
|
||||||
typedef struct phy_device_driver_s
|
typedef struct phy_device_driver_s {
|
||||||
{
|
|
||||||
phy_link_type_e link_type; /**< Define driver types. */
|
phy_link_type_e link_type; /**< Define driver types. */
|
||||||
driver_data_request_e data_request_layer; /**< Define interface data OUT protocol. */
|
driver_data_request_e data_request_layer; /**< Define interface data OUT protocol. */
|
||||||
uint8_t *PHY_MAC; /**< Pointer to 64-bit or 48-bit MAC address. */
|
uint8_t *PHY_MAC; /**< Pointer to 64-bit or 48-bit MAC address. */
|
||||||
|
|
|
@ -75,6 +75,7 @@ int thread_bbr_start(int8_t interface_id, int8_t backbone_interface_id);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int thread_bbr_timeout_set(int8_t interface_id, uint32_t timeout_a, uint32_t timeout_b, uint32_t delay);
|
int thread_bbr_timeout_set(int8_t interface_id, uint32_t timeout_a, uint32_t timeout_b, uint32_t delay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set prefix to be used as combining multiple thread networks on backbone.
|
* Set prefix to be used as combining multiple thread networks on backbone.
|
||||||
*
|
*
|
||||||
|
@ -89,6 +90,20 @@ int thread_bbr_timeout_set(int8_t interface_id, uint32_t timeout_a, uint32_t tim
|
||||||
*/
|
*/
|
||||||
int thread_bbr_prefix_set(int8_t interface_id, uint8_t *prefix);
|
int thread_bbr_prefix_set(int8_t interface_id, uint8_t *prefix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set sequence number to be used by bbr
|
||||||
|
*
|
||||||
|
* update sequence number value
|
||||||
|
*
|
||||||
|
* \param interface_id interface ID of the Thread network.
|
||||||
|
* \param sequence_number value that needs to be set on bbr
|
||||||
|
*
|
||||||
|
* \return 0 on success
|
||||||
|
* \return <0 in case of errors
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int thread_bbr_sequence_number_set(int8_t interface_id, uint8_t sequence_number);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Thread validation interface destination address.
|
* Set the Thread validation interface destination address.
|
||||||
*
|
*
|
||||||
|
|
|
@ -189,8 +189,10 @@ void *thread_commission_device_get_next(void *ptr, int8_t interface_id, bool *sh
|
||||||
|
|
||||||
typedef struct thread_commissioning_link_configuration {
|
typedef struct thread_commissioning_link_configuration {
|
||||||
uint8_t name[16]; /**< Name of the Thread network. utf8 string nul terminated if shorter than 16. */
|
uint8_t name[16]; /**< Name of the Thread network. utf8 string nul terminated if shorter than 16. */
|
||||||
|
uint8_t destination_address[16]; /**<Border router destination address*/
|
||||||
uint8_t extented_pan_id[8]; /**< Extended PAN ID. */
|
uint8_t extented_pan_id[8]; /**< Extended PAN ID. */
|
||||||
uint16_t panId; /**< Network ID. */
|
uint16_t panId; /**< Network ID. */
|
||||||
|
uint16_t destination_port; /**<destination port for commissioning*/
|
||||||
uint8_t Protocol_id; /**< Current protocol ID. */
|
uint8_t Protocol_id; /**< Current protocol ID. */
|
||||||
uint8_t version; /**< Current protocol version. */
|
uint8_t version; /**< Current protocol version. */
|
||||||
uint8_t rfChannel; /**< Current RF channel. */
|
uint8_t rfChannel; /**< Current RF channel. */
|
||||||
|
@ -271,6 +273,18 @@ int thread_commissioning_native_commissioner_get_connection_info(int8_t interfac
|
||||||
*/
|
*/
|
||||||
int8_t thread_commissioning_get_management_id(int8_t interface_id);
|
int8_t thread_commissioning_get_management_id(int8_t interface_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Attach native commissioner to destination address and port.
|
||||||
|
*
|
||||||
|
* \param interface_id Network interface ID.
|
||||||
|
* \param destination_address Destination address pointer.
|
||||||
|
* \param destination_port Commissioning port.
|
||||||
|
*
|
||||||
|
* \return 0 attach OK.
|
||||||
|
* \return < 0 fail.
|
||||||
|
*/
|
||||||
|
int thread_commissioning_attach(int8_t interface_id, uint8_t *destination_address, uint16_t destination_port);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,7 +55,8 @@
|
||||||
#define DIAGCOP_TLV_SUPPLY_VOLTAGE 15 /**< Can not reset*/
|
#define DIAGCOP_TLV_SUPPLY_VOLTAGE 15 /**< Can not reset*/
|
||||||
#define DIAGCOP_TLV_CHILD_TABLE 16 /**< Can not reset*/
|
#define DIAGCOP_TLV_CHILD_TABLE 16 /**< Can not reset*/
|
||||||
#define DIAGCOP_TLV_CHANNEL_PAGES 17 /**< Can not reset*/
|
#define DIAGCOP_TLV_CHANNEL_PAGES 17 /**< Can not reset*/
|
||||||
#define DIAGCOP_TLV_TYPE_LIST 18 /**< List type*/
|
#define DIAGCOP_TLV_TYPE_LIST 18 /**< Cannot reset*/
|
||||||
|
#define DIAGCOP_TLV_MAX_CHILD_TIMEOUT 19 /**< Cannot reset*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Write array TLV.
|
* \brief Write array TLV.
|
||||||
|
|
|
@ -131,8 +131,7 @@ buffer_t *nwk_udp_rx_security_check(buffer_t *buf)
|
||||||
}
|
}
|
||||||
if (buf->socket && buf->socket->inet_pcb->link_layer_security == 0) {
|
if (buf->socket && buf->socket->inet_pcb->link_layer_security == 0) {
|
||||||
// non-secure okay if it's for a socket whose security flag is clear.
|
// non-secure okay if it's for a socket whose security flag is clear.
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
drop_unsecured = 1;
|
drop_unsecured = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
#include "6LoWPAN/Fragmentation/cipv6_fragmenter.h"
|
#include "6LoWPAN/Fragmentation/cipv6_fragmenter.h"
|
||||||
#include "Service_Libs/etx/etx.h"
|
#include "Service_Libs/etx/etx.h"
|
||||||
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
|
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
|
||||||
|
#include "6LoWPAN/ws/ws_bootstrap.h"
|
||||||
|
|
||||||
|
|
||||||
#define TRACE_GROUP_LOWPAN "6lo"
|
#define TRACE_GROUP_LOWPAN "6lo"
|
||||||
|
@ -365,7 +366,8 @@ void protocol_6lowpan_router_init(protocol_interface_info_entry_t *cur)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void protocol_6lowpan_configure_core(protocol_interface_info_entry_t *cur) {
|
void protocol_6lowpan_configure_core(protocol_interface_info_entry_t *cur)
|
||||||
|
{
|
||||||
cur->dup_addr_detect_transmits = 0;
|
cur->dup_addr_detect_transmits = 0;
|
||||||
cur->ipv6_neighbour_cache.max_ll_len = 2 + 8;
|
cur->ipv6_neighbour_cache.max_ll_len = 2 + 8;
|
||||||
cur->ipv6_neighbour_cache.link_mtu = LOWPAN_MTU;
|
cur->ipv6_neighbour_cache.link_mtu = LOWPAN_MTU;
|
||||||
|
@ -473,7 +475,6 @@ void protocol_6lowpan_neighbor_priority_update(protocol_interface_info_entry_t *
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_RPL
|
#ifdef HAVE_RPL
|
||||||
#ifndef NO_MLE
|
|
||||||
|
|
||||||
uint16_t protocol_6lowpan_neighbor_priority_set(int8_t interface_id, addrtype_t addr_type, const uint8_t *addr_ptr)
|
uint16_t protocol_6lowpan_neighbor_priority_set(int8_t interface_id, addrtype_t addr_type, const uint8_t *addr_ptr)
|
||||||
{
|
{
|
||||||
|
@ -486,9 +487,12 @@ uint16_t protocol_6lowpan_neighbor_priority_set(int8_t interface_id, addrtype_t
|
||||||
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);
|
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
|
|
||||||
|
bool new_primary = false;
|
||||||
etx_storage_t *etx_entry = etx_storage_entry_get(interface_id, entry->index);
|
etx_storage_t *etx_entry = etx_storage_entry_get(interface_id, entry->index);
|
||||||
// If primary parent has changed clears priority from previous parent
|
// If primary parent has changed clears priority from previous parent
|
||||||
if (entry->link_role != PRIORITY_PARENT_NEIGHBOUR) {
|
if (entry->link_role != PRIORITY_PARENT_NEIGHBOUR) {
|
||||||
|
new_primary = true;
|
||||||
protocol_6lowpan_neighbor_priority_clear_all(interface_id, PRIORITY_1ST);
|
protocol_6lowpan_neighbor_priority_clear_all(interface_id, PRIORITY_1ST);
|
||||||
}
|
}
|
||||||
entry->link_role = PRIORITY_PARENT_NEIGHBOUR;
|
entry->link_role = PRIORITY_PARENT_NEIGHBOUR;
|
||||||
|
@ -501,6 +505,10 @@ uint16_t protocol_6lowpan_neighbor_priority_set(int8_t interface_id, addrtype_t
|
||||||
if (etx_entry) {
|
if (etx_entry) {
|
||||||
protocol_stats_update(STATS_ETX_1ST_PARENT, etx_entry->etx >> 4);
|
protocol_stats_update(STATS_ETX_1ST_PARENT, etx_entry->etx >> 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (new_primary) {
|
||||||
|
ws_primary_parent_update(cur, entry);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -519,9 +527,11 @@ uint16_t protocol_6lowpan_neighbor_second_priority_set(int8_t interface_id, addr
|
||||||
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);
|
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
|
bool new_secondary = false;
|
||||||
etx_storage_t *etx_entry = etx_storage_entry_get(interface_id, entry->index);
|
etx_storage_t *etx_entry = etx_storage_entry_get(interface_id, entry->index);
|
||||||
// If secondary parent has changed clears priority from previous parent
|
// If secondary parent has changed clears priority from previous parent
|
||||||
if (entry->link_role != SECONDARY_PARENT_NEIGHBOUR) {
|
if (entry->link_role != SECONDARY_PARENT_NEIGHBOUR) {
|
||||||
|
new_secondary = true;
|
||||||
protocol_6lowpan_neighbor_priority_clear_all(interface_id, PRIORITY_2ND);
|
protocol_6lowpan_neighbor_priority_clear_all(interface_id, PRIORITY_2ND);
|
||||||
}
|
}
|
||||||
entry->link_role = SECONDARY_PARENT_NEIGHBOUR;
|
entry->link_role = SECONDARY_PARENT_NEIGHBOUR;
|
||||||
|
@ -529,6 +539,9 @@ uint16_t protocol_6lowpan_neighbor_second_priority_set(int8_t interface_id, addr
|
||||||
if (etx_entry) {
|
if (etx_entry) {
|
||||||
protocol_stats_update(STATS_ETX_2ND_PARENT, etx_entry->etx >> 4);
|
protocol_stats_update(STATS_ETX_2ND_PARENT, etx_entry->etx >> 4);
|
||||||
}
|
}
|
||||||
|
if (new_secondary) {
|
||||||
|
ws_secondary_parent_update(cur);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -557,7 +570,6 @@ void protocol_6lowpan_neighbor_priority_clear_all(int8_t interface_id, neighbor_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -322,7 +322,8 @@ static bool protocol_6lowpan_router_challenge(protocol_interface_info_entry_t *c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint8_t mle_advert_neigh_cnt(protocol_interface_info_entry_t *cur_interface, bool short_adr) {
|
static uint8_t mle_advert_neigh_cnt(protocol_interface_info_entry_t *cur_interface, bool short_adr)
|
||||||
|
{
|
||||||
|
|
||||||
uint8_t advert_neigh_cnt;
|
uint8_t advert_neigh_cnt;
|
||||||
uint8_t neighb_max;
|
uint8_t neighb_max;
|
||||||
|
@ -428,8 +429,7 @@ static uint8_t *mle_table_set_neighbours(protocol_interface_info_entry_t *cur, u
|
||||||
neigh_count_max = mle_advert_neigh_cnt(cur, use_short_address_compression);
|
neigh_count_max = mle_advert_neigh_cnt(cur, use_short_address_compression);
|
||||||
|
|
||||||
bool clean_entries = false;
|
bool clean_entries = false;
|
||||||
ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, neigh_list)
|
ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, neigh_list) {
|
||||||
{
|
|
||||||
|
|
||||||
if ((cur_entry->connected_device) && (cur_entry->advertisment == false)) {
|
if ((cur_entry->connected_device) && (cur_entry->advertisment == false)) {
|
||||||
|
|
||||||
|
@ -1179,8 +1179,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml
|
||||||
uint8_t link_flags;
|
uint8_t link_flags;
|
||||||
if (mle_tlv_info.tlvLen > 0) {
|
if (mle_tlv_info.tlvLen > 0) {
|
||||||
link_flags = *(mle_tlv_info.dataPtr);
|
link_flags = *(mle_tlv_info.dataPtr);
|
||||||
if (mle_link_quality_tlv_parse(cur->mac,mac_helper_mac16_address_get(cur) , mle_tlv_info.dataPtr, mle_tlv_info.tlvLen, NULL, NULL))
|
if (mle_link_quality_tlv_parse(cur->mac, mac_helper_mac16_address_get(cur), mle_tlv_info.dataPtr, mle_tlv_info.tlvLen, NULL, NULL)) {
|
||||||
{
|
|
||||||
drop_advertisment = 0;
|
drop_advertisment = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1786,7 +1785,7 @@ int8_t arm_6lowpan_bootstarp_bootstrap_set(int8_t interface_id, net_6lowpan_mode
|
||||||
*/
|
*/
|
||||||
if (cur->lowpan_info & INTERFACE_NWK_ROUTER_DEVICE) {
|
if (cur->lowpan_info & INTERFACE_NWK_ROUTER_DEVICE) {
|
||||||
//rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, true);
|
//rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, true);
|
||||||
//rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, cur);
|
//rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, cur);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
cur->configure_flags |= INTERFACE_BOOTSTRAP_DEFINED;
|
cur->configure_flags |= INTERFACE_BOOTSTRAP_DEFINED;
|
||||||
|
@ -2073,6 +2072,8 @@ static void protocol_6lowpan_bootstrap_rpl_callback(rpl_event_t event, void *han
|
||||||
tr_error("RPL Local repair fail-->interface to idle");
|
tr_error("RPL Local repair fail-->interface to idle");
|
||||||
nwk_bootsrap_state_update(ARM_NWK_NWK_CONNECTION_DOWN, cur);
|
nwk_bootsrap_state_update(ARM_NWK_NWK_CONNECTION_DOWN, cur);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2179,7 +2180,7 @@ void nwk_6lowpan_nd_address_registartion_ready(protocol_interface_info_entry_t *
|
||||||
// arm_nwk_6lowpan_rpl_dodag_poison from a previous connection may have left force_leaf set
|
// arm_nwk_6lowpan_rpl_dodag_poison from a previous connection may have left force_leaf set
|
||||||
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, false);
|
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, false);
|
||||||
rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, true);
|
rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, true);
|
||||||
rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, cur);
|
rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, cur);
|
||||||
}
|
}
|
||||||
// Send unicast DIS to coordinator
|
// Send unicast DIS to coordinator
|
||||||
nwk_bootstrap_icmp_rpl_dis_coord_msg_tx(cur);
|
nwk_bootstrap_icmp_rpl_dis_coord_msg_tx(cur);
|
||||||
|
|
|
@ -273,7 +273,8 @@ static bool beacon_join_priority_tlv_add(uint8_t len, uint8_t *ptr, uint8_t offs
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static nwk_pan_descriptor_t * get_local_description(uint16_t payload_length, uint8_t *payload_ptr) {
|
static nwk_pan_descriptor_t *get_local_description(uint16_t payload_length, uint8_t *payload_ptr)
|
||||||
|
{
|
||||||
nwk_pan_descriptor_t *description = ns_dyn_mem_temporary_alloc(sizeof(nwk_pan_descriptor_t));
|
nwk_pan_descriptor_t *description = ns_dyn_mem_temporary_alloc(sizeof(nwk_pan_descriptor_t));
|
||||||
if (description) {
|
if (description) {
|
||||||
memset(description, 0, sizeof(nwk_pan_descriptor_t));
|
memset(description, 0, sizeof(nwk_pan_descriptor_t));
|
||||||
|
|
|
@ -280,7 +280,8 @@ static void mac_helper_key_lookup_set(mlme_key_id_lookup_descriptor_t *lookup, u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void mac_helper_keytable_descriptor_set(struct mac_api_s *api, const uint8_t *key, uint8_t id, uint8_t attribute_id) {
|
static void mac_helper_keytable_descriptor_set(struct mac_api_s *api, const uint8_t *key, uint8_t id, uint8_t attribute_id)
|
||||||
|
{
|
||||||
mlme_set_t set_req;
|
mlme_set_t set_req;
|
||||||
mlme_key_id_lookup_descriptor_t lookup_description;
|
mlme_key_id_lookup_descriptor_t lookup_description;
|
||||||
mlme_key_descriptor_entry_t key_description;
|
mlme_key_descriptor_entry_t key_description;
|
||||||
|
@ -301,7 +302,8 @@ static void mac_helper_keytable_descriptor_set(struct mac_api_s *api, const uint
|
||||||
api->mlme_req(api, MLME_SET, &set_req);
|
api->mlme_req(api, MLME_SET, &set_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mac_helper_keytable_pairwise_descriptor_set(struct mac_api_s *api, const uint8_t *key, const uint8_t *mac64, uint8_t attribute_id) {
|
static void mac_helper_keytable_pairwise_descriptor_set(struct mac_api_s *api, const uint8_t *key, const uint8_t *mac64, uint8_t attribute_id)
|
||||||
|
{
|
||||||
mlme_set_t set_req;
|
mlme_set_t set_req;
|
||||||
mlme_key_id_lookup_descriptor_t lookup_description;
|
mlme_key_id_lookup_descriptor_t lookup_description;
|
||||||
mlme_key_descriptor_entry_t key_description;
|
mlme_key_descriptor_entry_t key_description;
|
||||||
|
@ -402,7 +404,8 @@ void mac_helper_security_key_swap_next_to_default(protocol_interface_info_entry_
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mac_helper_security_key_clean(protocol_interface_info_entry_t *interface) {
|
void mac_helper_security_key_clean(protocol_interface_info_entry_t *interface)
|
||||||
|
{
|
||||||
if (interface->mac_api) {
|
if (interface->mac_api) {
|
||||||
mlme_set_t set_req;
|
mlme_set_t set_req;
|
||||||
mlme_key_descriptor_entry_t key_description;
|
mlme_key_descriptor_entry_t key_description;
|
||||||
|
@ -736,7 +739,8 @@ uint_fast8_t mac_helper_frame_overhead(protocol_interface_info_entry_t *cur, con
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t mac_helper_security_mic_length_get(uint8_t security_level) {
|
static uint8_t mac_helper_security_mic_length_get(uint8_t security_level)
|
||||||
|
{
|
||||||
uint8_t mic_length;
|
uint8_t mic_length;
|
||||||
switch (security_level) {
|
switch (security_level) {
|
||||||
case SEC_MIC32:
|
case SEC_MIC32:
|
||||||
|
@ -761,7 +765,8 @@ static uint8_t mac_helper_security_mic_length_get(uint8_t security_level) {
|
||||||
return mic_length;
|
return mic_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t mac_helper_header_security_aux_header_length(uint8_t keyIdmode) {
|
static uint8_t mac_helper_header_security_aux_header_length(uint8_t keyIdmode)
|
||||||
|
{
|
||||||
|
|
||||||
uint8_t header_length = 5; //Header + 32-bit counter
|
uint8_t header_length = 5; //Header + 32-bit counter
|
||||||
switch (keyIdmode) {
|
switch (keyIdmode) {
|
||||||
|
|
|
@ -76,7 +76,8 @@ static mac_pairwise_interface_entry_t *mac_pairwise_key_list_allocate(uint8_t li
|
||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mac_pairwise_key_deacriptro_attribute_get(mac_pairwise_interface_entry_t *main_list, uint8_t key_attribute) {
|
static bool mac_pairwise_key_deacriptro_attribute_get(mac_pairwise_interface_entry_t *main_list, uint8_t key_attribute)
|
||||||
|
{
|
||||||
mac_pairwise_key_info_t *key_table = main_list->mac_pairwise_key_table;
|
mac_pairwise_key_info_t *key_table = main_list->mac_pairwise_key_table;
|
||||||
for (uint8_t i = 0; i < main_list->key_table_size; i++) {
|
for (uint8_t i = 0; i < main_list->key_table_size; i++) {
|
||||||
if (key_table->key_decriptor_attribute == key_attribute) {
|
if (key_table->key_decriptor_attribute == key_attribute) {
|
||||||
|
@ -88,7 +89,8 @@ static bool mac_pairwise_key_deacriptro_attribute_get(mac_pairwise_interface_ent
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mac_pairwise_key_info_t *mac_pairwise_key_info_get(mac_pairwise_interface_entry_t *main_list, uint8_t device_id) {
|
mac_pairwise_key_info_t *mac_pairwise_key_info_get(mac_pairwise_interface_entry_t *main_list, uint8_t device_id)
|
||||||
|
{
|
||||||
mac_pairwise_key_info_t *key_table = main_list->mac_pairwise_key_table;
|
mac_pairwise_key_info_t *key_table = main_list->mac_pairwise_key_table;
|
||||||
for (uint8_t i = 0; i < main_list->key_table_size; i++) {
|
for (uint8_t i = 0; i < main_list->key_table_size; i++) {
|
||||||
if (key_table->device_descriptor_attribute == device_id) {
|
if (key_table->device_descriptor_attribute == device_id) {
|
||||||
|
@ -118,7 +120,8 @@ mac_pairwise_key_info_t *mac_pairwise_key_info_get(mac_pairwise_interface_entry_
|
||||||
return new_entry;
|
return new_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mac_pairwise_key_info_delete(mac_pairwise_interface_entry_t *main_list, uint8_t device_id, uint8_t *key_attribute) {
|
static bool mac_pairwise_key_info_delete(mac_pairwise_interface_entry_t *main_list, uint8_t device_id, uint8_t *key_attribute)
|
||||||
|
{
|
||||||
bool removed_entry = false;
|
bool removed_entry = false;
|
||||||
|
|
||||||
mac_pairwise_key_info_t *cur = main_list->mac_pairwise_key_table;
|
mac_pairwise_key_info_t *cur = main_list->mac_pairwise_key_table;
|
||||||
|
@ -170,7 +173,8 @@ static mac_pairwise_interface_entry_t *mac_pairwise_key_main_class(uint8_t key_l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void mac_pairwise_key_list_free(protocol_interface_info_entry_t *interface, mac_pairwise_interface_entry_t *main_list) {
|
static void mac_pairwise_key_list_free(protocol_interface_info_entry_t *interface, mac_pairwise_interface_entry_t *main_list)
|
||||||
|
{
|
||||||
//Delete mle entries & Keys
|
//Delete mle entries & Keys
|
||||||
mac_neighbor_table_entry_t *cur_entry;
|
mac_neighbor_table_entry_t *cur_entry;
|
||||||
mac_pairwise_key_info_t *cur = main_list->mac_pairwise_key_table;
|
mac_pairwise_key_info_t *cur = main_list->mac_pairwise_key_table;
|
||||||
|
|
|
@ -38,7 +38,8 @@
|
||||||
#define TRACE_GROUP "MRsH"
|
#define TRACE_GROUP "MRsH"
|
||||||
|
|
||||||
|
|
||||||
static void mac_mlme_device_table_confirmation_handle(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation) {
|
static void mac_mlme_device_table_confirmation_handle(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation)
|
||||||
|
{
|
||||||
if (confirmation->value_size != sizeof(mlme_device_descriptor_t)) {
|
if (confirmation->value_size != sizeof(mlme_device_descriptor_t)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +72,8 @@ static void mac_mlme_device_table_confirmation_handle(protocol_interface_info_en
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mac_mlme_frame_counter_confirmation_handle(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation) {
|
static void mac_mlme_frame_counter_confirmation_handle(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation)
|
||||||
|
{
|
||||||
if (confirmation->value_size != 4) {
|
if (confirmation->value_size != 4) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +81,8 @@ static void mac_mlme_frame_counter_confirmation_handle(protocol_interface_info_e
|
||||||
info_entry->mac_parameters->security_frame_counter = *temp_ptr;
|
info_entry->mac_parameters->security_frame_counter = *temp_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mac_mlme_get_confirmation_handler(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation) {
|
static void mac_mlme_get_confirmation_handler(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation)
|
||||||
|
{
|
||||||
|
|
||||||
if (!confirmation) {
|
if (!confirmation) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,9 +39,10 @@ typedef void mpx_data_request(const mpx_api_t *api, const struct mcps_data_req_s
|
||||||
* @param api API to handle the request
|
* @param api API to handle the request
|
||||||
* @param purge MCPS-purge request
|
* @param purge MCPS-purge request
|
||||||
* @param user_id MPX user ID
|
* @param user_id MPX user ID
|
||||||
|
* @return 0 if purge requst was OK, non-zero otherwise
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef void mpx_data_purge_request(const mpx_api_t *api, struct mcps_purge_s *purge, uint16_t user_id);
|
typedef uint8_t mpx_data_purge_request(const mpx_api_t *api, struct mcps_purge_s *purge, uint16_t user_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief mpx_data_confirm MPX-DATA confirm is called as a response to MPX-DATA request
|
* @brief mpx_data_confirm MPX-DATA confirm is called as a response to MPX-DATA request
|
||||||
|
|
|
@ -720,8 +720,7 @@ void nd_ns_build(nd_router_t *cur, protocol_interface_info_entry_t *cur_interfac
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(router, route->info.next_hop_addr, 16);
|
memcpy(router, route->info.next_hop_addr, 16);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
icmp_nd_set_nd_def_router_address(router, cur);
|
icmp_nd_set_nd_def_router_address(router, cur);
|
||||||
|
@ -873,8 +872,7 @@ static void nd_update_registration(protocol_interface_info_entry_t *cur_interfac
|
||||||
void nd_remove_registration(protocol_interface_info_entry_t *cur_interface, addrtype_t ll_type, const uint8_t *ll_address)
|
void nd_remove_registration(protocol_interface_info_entry_t *cur_interface, addrtype_t ll_type, const uint8_t *ll_address)
|
||||||
{
|
{
|
||||||
|
|
||||||
ns_list_foreach_safe(ipv6_neighbour_t, cur, &cur_interface->ipv6_neighbour_cache.list)
|
ns_list_foreach_safe(ipv6_neighbour_t, cur, &cur_interface->ipv6_neighbour_cache.list) {
|
||||||
{
|
|
||||||
if ((cur->type == IP_NEIGHBOUR_REGISTERED
|
if ((cur->type == IP_NEIGHBOUR_REGISTERED
|
||||||
|| cur->type == IP_NEIGHBOUR_TENTATIVE)
|
|| cur->type == IP_NEIGHBOUR_TENTATIVE)
|
||||||
&& ipv6_neighbour_ll_addr_match(cur, ll_type, ll_address)) {
|
&& ipv6_neighbour_ll_addr_match(cur, ll_type, ll_address)) {
|
||||||
|
@ -1094,10 +1092,8 @@ bool nd_ra_process_abro(protocol_interface_info_entry_t *cur, buffer_t *buf, con
|
||||||
dptr += 4;
|
dptr += 4;
|
||||||
//If Border Router boot is state
|
//If Border Router boot is state
|
||||||
|
|
||||||
if(cur->border_router_setup)
|
if (cur->border_router_setup) {
|
||||||
{
|
if (memcmp(dptr, cur->border_router_setup->border_router_gp_adr, 16) == 0) {
|
||||||
if(memcmp(dptr, cur->border_router_setup->border_router_gp_adr, 16) == 0)
|
|
||||||
{
|
|
||||||
if (cur->border_router_setup->initActive) {
|
if (cur->border_router_setup->initActive) {
|
||||||
//save New Context
|
//save New Context
|
||||||
if (common_serial_number_greater_32(abro_ver_num, cur->border_router_setup->nd_border_router_configure->abro_version_num)) {
|
if (common_serial_number_greater_32(abro_ver_num, cur->border_router_setup->nd_border_router_configure->abro_version_num)) {
|
||||||
|
@ -1163,8 +1159,7 @@ bool nd_ra_process_abro(protocol_interface_info_entry_t *cur, buffer_t *buf, con
|
||||||
uptodate = true;
|
uptodate = true;
|
||||||
|
|
||||||
//uprouter_info=1;
|
//uprouter_info=1;
|
||||||
if(diff_update >= 0x00010000)
|
if (diff_update >= 0x00010000) {
|
||||||
{
|
|
||||||
tr_debug("Border Router Boot Trig NS");
|
tr_debug("Border Router Boot Trig NS");
|
||||||
router->trig_address_reg = true;
|
router->trig_address_reg = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1258,8 +1253,7 @@ bool nd_ra_process_abro(protocol_interface_info_entry_t *cur, buffer_t *buf, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(uptodate)
|
if (uptodate) {
|
||||||
{
|
|
||||||
router->abro_version_num = abro_ver_num;
|
router->abro_version_num = abro_ver_num;
|
||||||
router->life_time = router_lifetime;
|
router->life_time = router_lifetime;
|
||||||
}
|
}
|
||||||
|
@ -1536,8 +1530,7 @@ static uint8_t nd_router_ready_timer(nd_router_t *cur, protocol_interface_info_e
|
||||||
mac_data_poll_init_protocol_poll(cur_interface);
|
mac_data_poll_init_protocol_poll(cur_interface);
|
||||||
}
|
}
|
||||||
nd_router_bootstrap_timer(cur, cur_interface, 1);
|
nd_router_bootstrap_timer(cur, cur_interface, 1);
|
||||||
}
|
} else { /* ND_BR_READY */
|
||||||
else { /* ND_BR_READY */
|
|
||||||
nd_border_router_setup_refresh(cur->nwk_id, true);
|
nd_border_router_setup_refresh(cur->nwk_id, true);
|
||||||
tr_debug("ND BR refresh ABRO");
|
tr_debug("ND BR refresh ABRO");
|
||||||
cur->nd_re_validate = (cur->life_time / 4) * 3;
|
cur->nd_re_validate = (cur->life_time / 4) * 3;
|
||||||
|
|
|
@ -40,12 +40,16 @@
|
||||||
#include "common_functions.h"
|
#include "common_functions.h"
|
||||||
#include "thread_border_router_api.h"
|
#include "thread_border_router_api.h"
|
||||||
#include "thread_bbr_api.h"
|
#include "thread_bbr_api.h"
|
||||||
|
#include "net_ipv6_api.h"
|
||||||
|
#include "NWK_INTERFACE/Include/protocol.h"
|
||||||
#include "Common_Protocols/ipv6_constants.h"
|
#include "Common_Protocols/ipv6_constants.h"
|
||||||
#include "DHCPv6_Server/DHCPv6_server_service.h"
|
#include "DHCPv6_Server/DHCPv6_server_service.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_dhcpv6_server.h"
|
||||||
#include "thread_management_if.h"
|
#include "thread_management_if.h"
|
||||||
#include "6LoWPAN/Thread/thread_config.h"
|
#include "6LoWPAN/Thread/thread_config.h"
|
||||||
#include "6LoWPAN/Thread/thread_constants.h"
|
#include "6LoWPAN/Thread/thread_constants.h"
|
||||||
#include "6LoWPAN/Thread/thread_common.h"
|
#include "6LoWPAN/Thread/thread_common.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_bootstrap.h"
|
||||||
#include "6LoWPAN/Thread/thread_joiner_application.h"
|
#include "6LoWPAN/Thread/thread_joiner_application.h"
|
||||||
#include "6LoWPAN/Thread/thread_extension.h"
|
#include "6LoWPAN/Thread/thread_extension.h"
|
||||||
#include "6LoWPAN/Thread/thread_extension_bbr.h"
|
#include "6LoWPAN/Thread/thread_extension_bbr.h"
|
||||||
|
@ -96,7 +100,6 @@ typedef struct {
|
||||||
#define RFC6106_DNS_SEARCH_LIST_OPTION 31
|
#define RFC6106_DNS_SEARCH_LIST_OPTION 31
|
||||||
static NS_LIST_DEFINE(bbr_instance_list, thread_bbr_t, link);
|
static NS_LIST_DEFINE(bbr_instance_list, thread_bbr_t, link);
|
||||||
|
|
||||||
|
|
||||||
static thread_bbr_t *thread_bbr_find_by_interface(int8_t interface_id)
|
static thread_bbr_t *thread_bbr_find_by_interface(int8_t interface_id)
|
||||||
{
|
{
|
||||||
thread_bbr_t *this = NULL;
|
thread_bbr_t *this = NULL;
|
||||||
|
@ -221,8 +224,9 @@ static int thread_border_router_relay_receive_cb(int8_t service_id, uint8_t sour
|
||||||
(void) source_port;
|
(void) source_port;
|
||||||
tr_debug("border router relay receive");
|
tr_debug("border router relay receive");
|
||||||
thci_trace("brCommissionerDataRelayedOutbound");
|
thci_trace("brCommissionerDataRelayedOutbound");
|
||||||
if (!this)
|
if (!this) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
coap_service_request_send(this->br_service_id, COAP_REQUEST_OPTIONS_NONE, this->commissioner_address, this->commissioner_port,
|
coap_service_request_send(this->br_service_id, COAP_REQUEST_OPTIONS_NONE, this->commissioner_address, this->commissioner_port,
|
||||||
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_RELAY_RECEIVE, COAP_CT_OCTET_STREAM, request_ptr->payload_ptr, request_ptr->payload_len, NULL);
|
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_RELAY_RECEIVE, COAP_CT_OCTET_STREAM, request_ptr->payload_ptr, request_ptr->payload_len, NULL);
|
||||||
|
@ -579,7 +583,7 @@ static void thread_bbr_network_data_send(thread_bbr_t *this, uint8_t prefix[8],
|
||||||
// delete old prefix
|
// delete old prefix
|
||||||
memset(this->bbr_prefix, 0, 8);
|
memset(this->bbr_prefix, 0, 8);
|
||||||
// create new prefix
|
// create new prefix
|
||||||
if (DHCPv6_server_service_init(this->interface_id, prefix, eui64, DHCPV6_DUID_HARDWARE_EUI64_TYPE) != 0) {
|
if (thread_dhcp6_server_init(this->interface_id, prefix, eui64, THREAD_MIN_PREFIX_LIFETIME) != 0) {
|
||||||
tr_warn("DHCP server alloc fail");
|
tr_warn("DHCP server alloc fail");
|
||||||
// set 20 seconds delay before next process
|
// set 20 seconds delay before next process
|
||||||
this->br_delay_timer = 20;
|
this->br_delay_timer = 20;
|
||||||
|
@ -587,8 +591,6 @@ static void thread_bbr_network_data_send(thread_bbr_t *this, uint8_t prefix[8],
|
||||||
}
|
}
|
||||||
memcpy(this->bbr_prefix, prefix, 8);
|
memcpy(this->bbr_prefix, prefix, 8);
|
||||||
|
|
||||||
DHCPv6_server_service_set_address_validlifetime(this->interface_id, this->bbr_prefix, THREAD_MIN_PREFIX_LIFETIME);
|
|
||||||
|
|
||||||
br_info.P_default_route = true;
|
br_info.P_default_route = true;
|
||||||
br_info.P_dhcp = true;
|
br_info.P_dhcp = true;
|
||||||
br_info.P_on_mesh = true;
|
br_info.P_on_mesh = true;
|
||||||
|
@ -724,7 +726,7 @@ static bool thread_bbr_activated(thread_bbr_t *this, uint32_t seconds)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur->thread_info->routerIdReqCoapID) {
|
if (cur->thread_info->routerIdRequested) {
|
||||||
// Router id reguest pending we need to wait for response
|
// Router id reguest pending we need to wait for response
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -978,18 +980,18 @@ int thread_bbr_nd_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
|
||||||
int thread_bbr_dua_entry_add(int8_t interface_id, const uint8_t *addr_data_ptr, uint32_t lifetime, const uint8_t *mleid_ptr)
|
int thread_bbr_dua_entry_add(int8_t interface_id, const uint8_t *addr_data_ptr, uint32_t lifetime, const uint8_t *mleid_ptr)
|
||||||
{
|
{
|
||||||
thread_bbr_t *this = thread_bbr_find_by_interface(interface_id);
|
thread_bbr_t *this = thread_bbr_find_by_interface(interface_id);
|
||||||
|
thread_pbbr_dua_info_t *map;
|
||||||
if (!this || this->backbone_interface_id < 0) {
|
if (!this || this->backbone_interface_id < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
thread_pbbr_dua_info_t *map = ns_dyn_mem_alloc(sizeof(thread_pbbr_dua_info_t));
|
ipv6_route_t *route = ipv6_route_lookup_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0);
|
||||||
|
if (!route) {
|
||||||
|
map = ns_dyn_mem_alloc(sizeof(thread_pbbr_dua_info_t));
|
||||||
if (!map) {
|
if (!map) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
memcpy(map->mleid_ptr, mleid_ptr, 8);
|
|
||||||
map->last_contact_time = protocol_core_monotonic_time;
|
|
||||||
|
|
||||||
// We are using route info field to store BBR MLEID map
|
// We are using route info field to store BBR MLEID map
|
||||||
ipv6_route_t *route = ipv6_route_add_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, map, 0, lifetime, 0);
|
route = ipv6_route_add_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, map, 0, lifetime, 0);
|
||||||
if (!route) {
|
if (!route) {
|
||||||
// Direct route to host allows ND proxying to work
|
// Direct route to host allows ND proxying to work
|
||||||
ns_dyn_mem_free(map);
|
ns_dyn_mem_free(map);
|
||||||
|
@ -997,6 +999,12 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
|
||||||
}
|
}
|
||||||
// Route info autofreed
|
// Route info autofreed
|
||||||
route->info_autofree = true;
|
route->info_autofree = true;
|
||||||
|
}
|
||||||
|
map = route->info.info;
|
||||||
|
memcpy(map->mleid_ptr, mleid_ptr, 8);
|
||||||
|
map->last_contact_time = protocol_core_monotonic_time;
|
||||||
|
route->info.info = map;
|
||||||
|
|
||||||
// send NA
|
// send NA
|
||||||
thread_bbr_na_send(this->backbone_interface_id, addr_data_ptr);
|
thread_bbr_na_send(this->backbone_interface_id, addr_data_ptr);
|
||||||
|
|
||||||
|
@ -1006,15 +1014,6 @@ error:
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ipv6_route *thread_bbr_dua_entry_find(int8_t interface_id, const uint8_t *addr_data_ptr) {
|
|
||||||
ipv6_route_t *route = ipv6_route_choose_next_hop(addr_data_ptr, interface_id, NULL);
|
|
||||||
if (!route || route->prefix_len < 128 || !route->on_link || route->info.source != ROUTE_THREAD_PROXIED_DUA_HOST ) {
|
|
||||||
//Not found
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return route;
|
|
||||||
}
|
|
||||||
|
|
||||||
int thread_bbr_proxy_state_update(int8_t caller_interface_id, int8_t handler_interface_id, bool status)
|
int thread_bbr_proxy_state_update(int8_t caller_interface_id, int8_t handler_interface_id, bool status)
|
||||||
{
|
{
|
||||||
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(handler_interface_id);
|
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(handler_interface_id);
|
||||||
|
@ -1099,7 +1098,11 @@ int thread_bbr_start(int8_t interface_id, int8_t backbone_interface_id)
|
||||||
// By default multicast forwarding is not enabled as it causes multicast loops
|
// By default multicast forwarding is not enabled as it causes multicast loops
|
||||||
multicast_fwd_set_forwarding(this->interface_id, false);
|
multicast_fwd_set_forwarding(this->interface_id, false);
|
||||||
|
|
||||||
|
// Adjust BBR neighbor and destination cache size
|
||||||
|
arm_nwk_ipv6_max_cache_entries(THREAD_BBR_IPV6_DESTINATION_CACHE_SIZE);
|
||||||
|
|
||||||
thread_extension_bbr_init(interface_id, backbone_interface_id);
|
thread_extension_bbr_init(interface_id, backbone_interface_id);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1131,6 +1134,17 @@ int thread_bbr_prefix_set(int8_t interface_id, uint8_t *prefix)
|
||||||
#endif // HAVE_THREAD_BORDER_ROUTER
|
#endif // HAVE_THREAD_BORDER_ROUTER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int thread_bbr_sequence_number_set(int8_t interface_id, uint8_t sequence_number)
|
||||||
|
{
|
||||||
|
(void) interface_id;
|
||||||
|
(void) sequence_number;
|
||||||
|
#ifdef HAVE_THREAD_BORDER_ROUTER
|
||||||
|
return thread_extension_bbr_sequence_number_set(interface_id, sequence_number);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif // HAVE_THREAD_BORDER_ROUTER
|
||||||
|
}
|
||||||
|
|
||||||
int thread_bbr_validation_interface_address_set(int8_t interface_id, const uint8_t *addr_ptr, uint16_t port)
|
int thread_bbr_validation_interface_address_set(int8_t interface_id, const uint8_t *addr_ptr, uint16_t port)
|
||||||
{
|
{
|
||||||
(void) interface_id;
|
(void) interface_id;
|
||||||
|
|
|
@ -67,7 +67,6 @@ void thread_bbr_seconds_timer(int8_t interface_id, uint32_t tics);
|
||||||
*/
|
*/
|
||||||
int thread_bbr_commissioner_proxy_service_update(int8_t interface_id);
|
int thread_bbr_commissioner_proxy_service_update(int8_t interface_id);
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define thread_bbr_init(interface_id, external_commisssioner_port)
|
#define thread_bbr_init(interface_id, external_commisssioner_port)
|
||||||
#define thread_bbr_delete(interface_id)
|
#define thread_bbr_delete(interface_id)
|
||||||
|
@ -118,12 +117,6 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
|
||||||
*/
|
*/
|
||||||
int thread_bbr_na_send(int8_t interface_id, const uint8_t target[static 16]);
|
int thread_bbr_na_send(int8_t interface_id, const uint8_t target[static 16]);
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Find if bbr has dua entry
|
|
||||||
*
|
|
||||||
* \param interface_id addr_data_ptr
|
|
||||||
*/
|
|
||||||
struct ipv6_route *thread_bbr_dua_entry_find(int8_t interface_id, const uint8_t *addr_data_ptr);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define thread_bbr_proxy_state_update(caller_interface_id , handler_interface_id, status) (NULL)
|
#define thread_bbr_proxy_state_update(caller_interface_id , handler_interface_id, status) (NULL)
|
||||||
|
@ -131,7 +124,6 @@ struct ipv6_route *thread_bbr_dua_entry_find(int8_t interface_id, const uint8_t
|
||||||
#define thread_bbr_network_data_update_notify(cur)
|
#define thread_bbr_network_data_update_notify(cur)
|
||||||
#define thread_bbr_nd_entry_add(interface_id, addr_data_ptr, lifetime, info) (0)
|
#define thread_bbr_nd_entry_add(interface_id, addr_data_ptr, lifetime, info) (0)
|
||||||
#define thread_bbr_dua_entry_add(interface_id, addr_data_ptr, lifetime, mleid_ptr) (0)
|
#define thread_bbr_dua_entry_add(interface_id, addr_data_ptr, lifetime, mleid_ptr) (0)
|
||||||
#define thread_bbr_dua_entry_find(interface_id, addr_data_ptr) (NULL)
|
|
||||||
#define thread_bbr_na_send(interface_id, target) (0)
|
#define thread_bbr_na_send(interface_id, target) (0)
|
||||||
#endif //HAVE_THREAD_BORDER_ROUTER
|
#endif //HAVE_THREAD_BORDER_ROUTER
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
#include "MPL/mpl.h"
|
#include "MPL/mpl.h"
|
||||||
#include "MLE/mle.h"
|
#include "MLE/mle.h"
|
||||||
#include "MLE/mle_tlv.h"
|
#include "MLE/mle_tlv.h"
|
||||||
#include "thread_dhcpv6_client.h"
|
#include "DHCPv6_client/dhcpv6_client_api.h"
|
||||||
#include "thread_config.h"
|
#include "thread_config.h"
|
||||||
#include "thread_meshcop_lib.h"
|
#include "thread_meshcop_lib.h"
|
||||||
#include "multicast_api.h"
|
#include "multicast_api.h"
|
||||||
|
@ -136,8 +136,6 @@ static void thread_neighbor_remove(mac_neighbor_table_entry_t *entry_ptr, void *
|
||||||
|
|
||||||
static bool thread_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data)
|
static bool thread_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Sleepy host
|
|
||||||
protocol_interface_info_entry_t *cur_interface = user_data;
|
protocol_interface_info_entry_t *cur_interface = user_data;
|
||||||
|
|
||||||
if (thread_am_router(cur_interface)) {
|
if (thread_am_router(cur_interface)) {
|
||||||
|
@ -298,8 +296,7 @@ bool thread_bootstrap_request_network_data(protocol_interface_info_entry_t *cur,
|
||||||
tr_debug("Learn new Network Data");
|
tr_debug("Learn new Network Data");
|
||||||
requestNetworkdata = true;
|
requestNetworkdata = true;
|
||||||
thread_partition_info_update(cur, leaderData);
|
thread_partition_info_update(cur, leaderData);
|
||||||
}
|
} else if (common_serial_number_greater_8(leaderData->dataVersion, leaderInfo->dataVersion)) {
|
||||||
else if (common_serial_number_greater_8(leaderData->dataVersion, leaderInfo->dataVersion)) {
|
|
||||||
requestNetworkdata = true;
|
requestNetworkdata = true;
|
||||||
|
|
||||||
} else if (common_serial_number_greater_8(leaderData->stableDataVersion, leaderInfo->stableDataVersion)) {
|
} else if (common_serial_number_greater_8(leaderData->stableDataVersion, leaderInfo->stableDataVersion)) {
|
||||||
|
@ -324,8 +321,7 @@ static int thread_router_check_previous_partition_info(protocol_interface_info_e
|
||||||
(routeTlv->dataPtr[0] == cur->thread_info->previous_partition_info.idSequence)) {
|
(routeTlv->dataPtr[0] == cur->thread_info->previous_partition_info.idSequence)) {
|
||||||
//drop the advertisement from previuos partition
|
//drop the advertisement from previuos partition
|
||||||
return 1;
|
return 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//do not drop the advertisement
|
//do not drop the advertisement
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -676,8 +672,6 @@ static void thread_bootstrap_ml_address_update(protocol_interface_info_entry_t *
|
||||||
|
|
||||||
// Generate new ML64 address
|
// Generate new ML64 address
|
||||||
thread_generate_ml64_address(cur);
|
thread_generate_ml64_address(cur);
|
||||||
// Generate new domain address
|
|
||||||
thread_extension_address_generate(cur);
|
|
||||||
|
|
||||||
// Register multicast addresses
|
// Register multicast addresses
|
||||||
thread_bootstrap_all_nodes_multicast_register(cur);
|
thread_bootstrap_all_nodes_multicast_register(cur);
|
||||||
|
@ -698,8 +692,6 @@ int thread_configuration_thread_activate(protocol_interface_info_entry_t *cur, l
|
||||||
//Define Default Contexts
|
//Define Default Contexts
|
||||||
lowpan_context_update(&cur->lowpan_contexts, LOWPAN_CONTEXT_C, 0xFFFF, linkConfiguration->mesh_local_ula_prefix, 64, true);
|
lowpan_context_update(&cur->lowpan_contexts, LOWPAN_CONTEXT_C, 0xFFFF, linkConfiguration->mesh_local_ula_prefix, 64, true);
|
||||||
|
|
||||||
thread_extension_activate(cur);
|
|
||||||
|
|
||||||
thread_extension_bbr_route_update(cur);
|
thread_extension_bbr_route_update(cur);
|
||||||
|
|
||||||
blacklist_clear();
|
blacklist_clear();
|
||||||
|
@ -800,8 +792,9 @@ int thread_bootstrap_announce_send(protocol_interface_info_entry_t *cur, uint8_t
|
||||||
}
|
}
|
||||||
static void thread_announce_ntf_cb(void *arg)
|
static void thread_announce_ntf_cb(void *arg)
|
||||||
{
|
{
|
||||||
if(!arg)
|
if (!arg) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
protocol_interface_info_entry_t *cur = arg;
|
protocol_interface_info_entry_t *cur = arg;
|
||||||
cur->thread_info->announcement_info->timer = NULL;
|
cur->thread_info->announcement_info->timer = NULL;
|
||||||
thread_bootsrap_event_trig(THREAD_ANNOUNCE_ACTIVE, cur->bootStrapId, ARM_LIB_HIGH_PRIORITY_EVENT);
|
thread_bootsrap_event_trig(THREAD_ANNOUNCE_ACTIVE, cur->bootStrapId, ARM_LIB_HIGH_PRIORITY_EVENT);
|
||||||
|
@ -876,16 +869,14 @@ void thread_bootstrap_temporary_attach(protocol_interface_info_entry_t *cur, uin
|
||||||
thread_bootstrap_reset_restart(cur->id);
|
thread_bootstrap_reset_restart(cur->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const trickle_params_t thread_mpl_data_trickle_params =
|
static const trickle_params_t thread_mpl_data_trickle_params = {
|
||||||
{
|
|
||||||
.Imin = 1, /* 50ms */
|
.Imin = 1, /* 50ms */
|
||||||
.Imax = 2, /* 100ms */
|
.Imax = 2, /* 100ms */
|
||||||
.k = 0,
|
.k = 0,
|
||||||
.TimerExpirations = 2 /* MPL core knows to suppress to 0 for non-routers */
|
.TimerExpirations = 2 /* MPL core knows to suppress to 0 for non-routers */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const trickle_params_t thread_mpl_control_trickle_params =
|
static const trickle_params_t thread_mpl_control_trickle_params = {
|
||||||
{
|
|
||||||
.Imin = 11,
|
.Imin = 11,
|
||||||
.Imax = 5 * 60 * 20,
|
.Imax = 5 * 60 * 20,
|
||||||
.k = 0,
|
.k = 0,
|
||||||
|
@ -896,7 +887,7 @@ void thread_interface_init(protocol_interface_info_entry_t *cur)
|
||||||
{
|
{
|
||||||
thread_discovery_reset(cur->id);
|
thread_discovery_reset(cur->id);
|
||||||
thread_routing_set_mesh_callbacks(cur);
|
thread_routing_set_mesh_callbacks(cur);
|
||||||
thread_dhcp_client_init(cur->id);
|
dhcp_client_init(cur->id);
|
||||||
thread_management_client_init(cur->id);
|
thread_management_client_init(cur->id);
|
||||||
thread_address_registration_init();
|
thread_address_registration_init();
|
||||||
cur->mpl_seed_id_mode = MULTICAST_MPL_SEED_ID_MAC_SHORT;
|
cur->mpl_seed_id_mode = MULTICAST_MPL_SEED_ID_MAC_SHORT;
|
||||||
|
@ -1069,9 +1060,7 @@ void thread_tasklet(arm_event_s *event)
|
||||||
|
|
||||||
case THREAD_CHILD_UPDATE:
|
case THREAD_CHILD_UPDATE:
|
||||||
tr_debug_extra("Thread SM THREAD_CHILD_UPDATE");
|
tr_debug_extra("Thread SM THREAD_CHILD_UPDATE");
|
||||||
if (thread_info(cur)->thread_endnode_parent) {
|
|
||||||
thread_host_bootstrap_child_update(cur, cur->thread_info->thread_endnode_parent->mac64);
|
thread_host_bootstrap_child_update(cur, cur->thread_info->thread_endnode_parent->mac64);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case THREAD_ANNOUNCE_ACTIVE: {
|
case THREAD_ANNOUNCE_ACTIVE: {
|
||||||
tr_debug_extra("Thread SM THREAD_ANNOUNCE_ACTIVE");
|
tr_debug_extra("Thread SM THREAD_ANNOUNCE_ACTIVE");
|
||||||
|
@ -1178,6 +1167,10 @@ void thread_bootstrap_ready(protocol_interface_info_entry_t *cur)
|
||||||
thread_leader_service_generate_network_data(cur);
|
thread_leader_service_generate_network_data(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (thread_addresses_needs_to_be_registered(cur)) {
|
||||||
|
thread_info(cur)->childUpdateReqTimer = 1;
|
||||||
|
}
|
||||||
|
|
||||||
cur->bootsrap_state_machine_cnt = 0;
|
cur->bootsrap_state_machine_cnt = 0;
|
||||||
mac_data_poll_protocol_poll_mode_decrement(cur);
|
mac_data_poll_protocol_poll_mode_decrement(cur);
|
||||||
}
|
}
|
||||||
|
@ -1194,6 +1187,31 @@ void thread_neighbor_list_clean(struct protocol_interface_info_entry *cur)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void thread_reed_fed_neighbour_links_clean(struct protocol_interface_info_entry *cur)
|
||||||
|
{
|
||||||
|
mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list;
|
||||||
|
|
||||||
|
if (thread_i_am_router(cur)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE ||
|
||||||
|
thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!thread_info(cur)->thread_endnode_parent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ns_list_foreach_safe(mac_neighbor_table_entry_t, cur_entry, mac_table_list) {
|
||||||
|
// do not remove parent entry
|
||||||
|
if (memcmp(cur_entry->mac64, thread_info(cur)->thread_endnode_parent->mac64, 8) != 0) {
|
||||||
|
tr_debug("Free short addr: %x", cur_entry->mac16);
|
||||||
|
mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), cur_entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void thread_clean_old_16_bit_address_based_addresses(protocol_interface_info_entry_t *cur)
|
void thread_clean_old_16_bit_address_based_addresses(protocol_interface_info_entry_t *cur)
|
||||||
{
|
{
|
||||||
uint8_t static_address[16];
|
uint8_t static_address[16];
|
||||||
|
@ -1271,7 +1289,9 @@ static void thread_bootsrap_network_discovery_failure(int8_t interface_id)
|
||||||
}
|
}
|
||||||
//TODO we should send 3 in burst of 0.1 - 0.6 seconds and then do the exponential backup of 5s -- 80s
|
//TODO we should send 3 in burst of 0.1 - 0.6 seconds and then do the exponential backup of 5s -- 80s
|
||||||
uint32_t backof_delay = cur->nwk_nd_re_scan_count * 2;
|
uint32_t backof_delay = cur->nwk_nd_re_scan_count * 2;
|
||||||
if (backof_delay > 600) backof_delay = 600; //TODO test this and check guess this is 100ms ticks
|
if (backof_delay > 600) {
|
||||||
|
backof_delay = 600; //TODO test this and check guess this is 100ms ticks
|
||||||
|
}
|
||||||
|
|
||||||
tr_debug("Continue network scan");
|
tr_debug("Continue network scan");
|
||||||
cur->nwk_bootstrap_state = ER_ACTIVE_SCAN;
|
cur->nwk_bootstrap_state = ER_ACTIVE_SCAN;
|
||||||
|
@ -1284,8 +1304,7 @@ static void thread_bootstrap_generate_leader_and_link(protocol_interface_info_en
|
||||||
tr_debug("ReAttach Fail - retry");
|
tr_debug("ReAttach Fail - retry");
|
||||||
thread_bootstrap_attach_start(cur->id, THREAD_REATTACH);
|
thread_bootstrap_attach_start(cur->id, THREAD_REATTACH);
|
||||||
cur->thread_info->thread_attached_state = THREAD_STATE_REATTACH_RETRY;
|
cur->thread_info->thread_attached_state = THREAD_STATE_REATTACH_RETRY;
|
||||||
}
|
} else if (cur->thread_info->thread_attached_state == THREAD_STATE_REATTACH_RETRY) {
|
||||||
else if (cur->thread_info->thread_attached_state == THREAD_STATE_REATTACH_RETRY) {
|
|
||||||
tr_warn("ReAttach Fail");
|
tr_warn("ReAttach Fail");
|
||||||
thread_bootstrap_attach_start(cur->id, THREAD_ANY_ATTACH);
|
thread_bootstrap_attach_start(cur->id, THREAD_ANY_ATTACH);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1316,15 +1335,15 @@ static int8_t thread_bootstrap_attempt_attach_with_pending_set(protocol_interfac
|
||||||
thread_joiner_application_old_config_activate(cur->id);
|
thread_joiner_application_old_config_activate(cur->id);
|
||||||
thread_joiner_application_old_config_delete(cur->id);
|
thread_joiner_application_old_config_delete(cur->id);
|
||||||
thread_joiner_application_pending_config_enable(cur->id, 20000);
|
thread_joiner_application_pending_config_enable(cur->id, 20000);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
thread_joiner_pending_config_activate(cur->id);
|
thread_joiner_pending_config_activate(cur->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void thread_bootstrap_orphan_scan_ready_cb(struct protocol_interface_info_entry *cur_interface, announce_discovery_response_t *discover_response) {
|
static void thread_bootstrap_orphan_scan_ready_cb(struct protocol_interface_info_entry *cur_interface, announce_discovery_response_t *discover_response)
|
||||||
|
{
|
||||||
|
|
||||||
if (!discover_response) {
|
if (!discover_response) {
|
||||||
thread_bootstrap_orphan_scan_start(cur_interface);
|
thread_bootstrap_orphan_scan_start(cur_interface);
|
||||||
|
@ -1428,8 +1447,7 @@ void thread_bootstrap_connection_error(int8_t interface_id, nwk_connect_error_ty
|
||||||
} else {
|
} else {
|
||||||
thread_bootstrap_generate_leader_and_link(cur);
|
thread_bootstrap_generate_leader_and_link(cur);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
thread_bootstrap_orphan_scan_start(cur);
|
thread_bootstrap_orphan_scan_start(cur);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1612,7 +1630,6 @@ void thread_bootstrap_routing_activate(protocol_interface_info_entry_t *cur)
|
||||||
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_FULL_END_DEVICE ||
|
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_FULL_END_DEVICE ||
|
||||||
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_ROUTER) {
|
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_ROUTER) {
|
||||||
thread_meshlocal_route_set(cur);
|
thread_meshlocal_route_set(cur);
|
||||||
thread_extension_route_set(cur);
|
|
||||||
// FEDs and routers (REEDs) perform their own address resolution
|
// FEDs and routers (REEDs) perform their own address resolution
|
||||||
thread_nd_service_activate(cur->id);
|
thread_nd_service_activate(cur->id);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1627,7 +1644,7 @@ void thread_bootstrap_attached_finish(protocol_interface_info_entry_t *cur)
|
||||||
cur->lowpan_info |= INTERFACE_NWK_BOOTSRAP_ADDRESS_REGISTER_READY;
|
cur->lowpan_info |= INTERFACE_NWK_BOOTSRAP_ADDRESS_REGISTER_READY;
|
||||||
cur->lowpan_info &= ~INTERFACE_NWK_ROUTER_DEVICE;
|
cur->lowpan_info &= ~INTERFACE_NWK_ROUTER_DEVICE;
|
||||||
cur->bootsrap_state_machine_cnt = 10;
|
cur->bootsrap_state_machine_cnt = 10;
|
||||||
cur->thread_info->routerIdReqCoapID = 0;
|
cur->thread_info->routerIdRequested = false;
|
||||||
cur->thread_info->networkDataRequested = false;
|
cur->thread_info->networkDataRequested = false;
|
||||||
clear_power_state(ICMP_ACTIVE);
|
clear_power_state(ICMP_ACTIVE);
|
||||||
|
|
||||||
|
@ -1644,8 +1661,6 @@ void thread_bootstrap_attached_finish(protocol_interface_info_entry_t *cur)
|
||||||
thread_generate_ml16_address(cur);
|
thread_generate_ml16_address(cur);
|
||||||
//GENERATE ML-EID64
|
//GENERATE ML-EID64
|
||||||
thread_generate_ml64_address(cur);
|
thread_generate_ml64_address(cur);
|
||||||
// Generate new domain address
|
|
||||||
thread_extension_address_generate(cur);
|
|
||||||
thread_bootstrap_routing_activate(cur);
|
thread_bootstrap_routing_activate(cur);
|
||||||
thread_bootstrap_network_data_update(cur);
|
thread_bootstrap_network_data_update(cur);
|
||||||
// After successful attach if there is announcement info present, send announcement back to previous channel
|
// After successful attach if there is announcement info present, send announcement back to previous channel
|
||||||
|
@ -1791,10 +1806,8 @@ static int compare_steering_and_joiner_bloom(uint8_t *steering_bloom, uint8_t *j
|
||||||
int loop_iterator;
|
int loop_iterator;
|
||||||
tr_debug("joiner bloom : %s", trace_array(joiner_bloom, steering_tlv_length));
|
tr_debug("joiner bloom : %s", trace_array(joiner_bloom, steering_tlv_length));
|
||||||
tr_debug("steering bloom : %s", trace_array(steering_bloom, steering_tlv_length));
|
tr_debug("steering bloom : %s", trace_array(steering_bloom, steering_tlv_length));
|
||||||
for (loop_iterator = 0; loop_iterator < steering_tlv_length; loop_iterator++)
|
for (loop_iterator = 0; loop_iterator < steering_tlv_length; loop_iterator++) {
|
||||||
{
|
if ((joiner_bloom[loop_iterator] != (joiner_bloom[loop_iterator] & steering_bloom[loop_iterator]))) {
|
||||||
if ((joiner_bloom[loop_iterator] != (joiner_bloom[loop_iterator] & steering_bloom[loop_iterator])))
|
|
||||||
{
|
|
||||||
thci_trace("joinerDiscoveryFailedFiltered");
|
thci_trace("joinerDiscoveryFailedFiltered");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1823,8 +1836,7 @@ static void thread_dhcp_client_gua_error_cb(int8_t interface, uint8_t dhcp_addr[
|
||||||
tr_warn("Address Get fail: %s from: %s", trace_ipv6(prefix), trace_ipv6(dhcp_addr));
|
tr_warn("Address Get fail: %s from: %s", trace_ipv6(prefix), trace_ipv6(dhcp_addr));
|
||||||
if (prefix && dhcp_addr) {
|
if (prefix && dhcp_addr) {
|
||||||
tr_debug("Delete Current Server data");
|
tr_debug("Delete Current Server data");
|
||||||
thread_dhcp_client_global_address_delete(interface, dhcp_addr, prefix);
|
dhcp_client_global_address_delete(interface, dhcp_addr, prefix);
|
||||||
//TODO shuold we try again or select new Server
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1964,6 +1976,10 @@ void thread_discover_native_commissioner_response(protocol_interface_info_entry_
|
||||||
config_ptr[n].rfChannel = cur_class->channel;
|
config_ptr[n].rfChannel = cur_class->channel;
|
||||||
memcpy(config_ptr[n].name, cur_class->network_name, 16);
|
memcpy(config_ptr[n].name, cur_class->network_name, 16);
|
||||||
memcpy(config_ptr[n].extented_pan_id, cur_class->extented_pan_id, 8);
|
memcpy(config_ptr[n].extented_pan_id, cur_class->extented_pan_id, 8);
|
||||||
|
memcpy(config_ptr[n].destination_address, ADDR_LINK_LOCAL_PREFIX, 8);
|
||||||
|
memcpy(&config_ptr[n].destination_address[8], cur_class->extented_mac, 8);
|
||||||
|
config_ptr[n].destination_address[8] ^= 2;
|
||||||
|
config_ptr[n].destination_port = cur_class->commissioner_port;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2023,7 +2039,7 @@ void thread_discover_native_commissioner_response(protocol_interface_info_entry_
|
||||||
interface->lowpan_info |= INTERFACE_NWK_BOOTSRAP_ADDRESS_REGISTER_READY;
|
interface->lowpan_info |= INTERFACE_NWK_BOOTSRAP_ADDRESS_REGISTER_READY;
|
||||||
interface->lowpan_info &= ~INTERFACE_NWK_ROUTER_DEVICE;
|
interface->lowpan_info &= ~INTERFACE_NWK_ROUTER_DEVICE;
|
||||||
|
|
||||||
interface->thread_info->routerIdReqCoapID = 0;
|
interface->thread_info->routerIdRequested = false;
|
||||||
interface->thread_info->networkDataRequested = false;
|
interface->thread_info->networkDataRequested = false;
|
||||||
|
|
||||||
interface->bootsrap_state_machine_cnt = 10;
|
interface->bootsrap_state_machine_cnt = 10;
|
||||||
|
@ -2128,6 +2144,12 @@ static bool thread_bootstrap_sync_after_reset_start(protocol_interface_info_entr
|
||||||
uint16_t my_short_address;
|
uint16_t my_short_address;
|
||||||
uint8_t parent_mac64[8];
|
uint8_t parent_mac64[8];
|
||||||
|
|
||||||
|
// link sync is allowed only once in bootstrap start and we might get here in other cases also
|
||||||
|
if (!cur->thread_info->link_sync_allowed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cur->thread_info->link_sync_allowed = false;
|
||||||
|
|
||||||
int link_info_err = thread_nvm_store_link_info_get(parent_mac64, &my_short_address);
|
int link_info_err = thread_nvm_store_link_info_get(parent_mac64, &my_short_address);
|
||||||
if (link_info_err != THREAD_NVM_FILE_SUCCESS) {
|
if (link_info_err != THREAD_NVM_FILE_SUCCESS) {
|
||||||
tr_warning("thread_nvm_store_link_info_get returned %d", link_info_err);
|
tr_warning("thread_nvm_store_link_info_get returned %d", link_info_err);
|
||||||
|
@ -2278,7 +2300,7 @@ void thread_bootstrap_stop(protocol_interface_info_entry_t *cur)
|
||||||
thread_leader_service_leader_data_free(cur->thread_info);
|
thread_leader_service_leader_data_free(cur->thread_info);
|
||||||
thread_bootstrap_all_nodes_multicast_unregister(cur);
|
thread_bootstrap_all_nodes_multicast_unregister(cur);
|
||||||
thread_data_base_init(cur->thread_info, cur->id);
|
thread_data_base_init(cur->thread_info, cur->id);
|
||||||
thread_dhcp_client_delete(cur->id);
|
dhcp_client_delete(cur->id);
|
||||||
thread_nd_service_delete(cur->id);
|
thread_nd_service_delete(cur->id);
|
||||||
thread_child_id_request_entry_clean(cur);
|
thread_child_id_request_entry_clean(cur);
|
||||||
thread_registered_mcast_addr_entry_clean(cur);
|
thread_registered_mcast_addr_entry_clean(cur);
|
||||||
|
@ -2356,6 +2378,7 @@ static int thread_nd_prefix_context_allocate(protocol_interface_info_entry_t *cu
|
||||||
if (cid == 16) {
|
if (cid == 16) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.cid = cid;
|
context.cid = cid;
|
||||||
context.compression = true;
|
context.compression = true;
|
||||||
context.stableData = stableData;
|
context.stableData = stableData;
|
||||||
|
@ -2499,6 +2522,7 @@ int thread_bootstrap_network_data_process(protocol_interface_info_entry_t *cur,
|
||||||
genericService.P_slaac = ((flags >> THREAD_P_SLAAC_BIT_MOVE) & 1);
|
genericService.P_slaac = ((flags >> THREAD_P_SLAAC_BIT_MOVE) & 1);
|
||||||
genericService.P_on_mesh = ((flags >> THREAD_P_ON_MESH_BIT_MOVE) & 1);
|
genericService.P_on_mesh = ((flags >> THREAD_P_ON_MESH_BIT_MOVE) & 1);
|
||||||
genericService.P_nd_dns = ((flags >> THREAD_P_ND_DNS_BIT_MOVE) & 1);
|
genericService.P_nd_dns = ((flags >> THREAD_P_ND_DNS_BIT_MOVE) & 1);
|
||||||
|
genericService.P_res1 = ((flags >> THREAD_P_ND_RES_BIT_MOVE) & 1);
|
||||||
if (thread_nd_local_list_add_on_mesh_prefix(networkDataStorage, &prefixTlv, &genericService) == 0) {
|
if (thread_nd_local_list_add_on_mesh_prefix(networkDataStorage, &prefixTlv, &genericService) == 0) {
|
||||||
if (networkDataStorage->stableUpdatePushed || networkDataStorage->temporaryUpdatePushed) {
|
if (networkDataStorage->stableUpdatePushed || networkDataStorage->temporaryUpdatePushed) {
|
||||||
if (!genericService.P_slaac) {
|
if (!genericService.P_slaac) {
|
||||||
|
@ -2525,7 +2549,7 @@ int thread_bootstrap_network_data_process(protocol_interface_info_entry_t *cur,
|
||||||
memcpy(&addr[8], ADDR_SHORT_ADR_SUFFIC, 6);
|
memcpy(&addr[8], ADDR_SHORT_ADR_SUFFIC, 6);
|
||||||
common_write_16_bit(genericService.routerID, &addr[14]);
|
common_write_16_bit(genericService.routerID, &addr[14]);
|
||||||
tr_debug("Delete DHCPv6 given address");
|
tr_debug("Delete DHCPv6 given address");
|
||||||
thread_dhcp_client_global_address_delete(cur->id, addr, prefixTlv.Prefix);
|
dhcp_client_global_address_delete(cur->id, addr, prefixTlv.Prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2581,9 +2605,9 @@ int thread_bootstrap_network_data_process(protocol_interface_info_entry_t *cur,
|
||||||
length -= subLength;
|
length -= subLength;
|
||||||
|
|
||||||
data_changed = thread_commission_data_tlv_parse(cur, type, subLength, dptr);
|
data_changed = thread_commission_data_tlv_parse(cur, type, subLength, dptr);
|
||||||
if (data_changed < 0)
|
if (data_changed < 0) {
|
||||||
tr_debug("Fail");
|
tr_debug("Fail");
|
||||||
else {
|
} else {
|
||||||
if (data_changed == 1) {
|
if (data_changed == 1) {
|
||||||
update_data = true;
|
update_data = true;
|
||||||
tr_debug("Changed");
|
tr_debug("Changed");
|
||||||
|
@ -2702,6 +2726,8 @@ int thread_bootstrap_network_data_activate(protocol_interface_info_entry_t *cur)
|
||||||
thread_border_router_network_data_update_notify(cur);
|
thread_border_router_network_data_update_notify(cur);
|
||||||
thread_bbr_network_data_update_notify(cur);
|
thread_bbr_network_data_update_notify(cur);
|
||||||
|
|
||||||
|
thread_maintenance_timer_set(cur, THREAD_MAINTENANCE_TIMER_INTERVAL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2744,7 +2770,6 @@ int thread_bootstrap_network_data_save(protocol_interface_info_entry_t *cur, thr
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *cur)
|
void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *cur)
|
||||||
{
|
{
|
||||||
// Route prefix is variable-length, so need to zero pad for ip6tos
|
// Route prefix is variable-length, so need to zero pad for ip6tos
|
||||||
|
@ -2794,6 +2819,8 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
|
||||||
if (curBorderRouter->P_dhcp && weHostService && nd_proxy_enabled_for_upstream(cur->id) && nd_proxy_upstream_route_onlink(cur->id, curPrefix->servicesPrefix)) {
|
if (curBorderRouter->P_dhcp && weHostService && nd_proxy_enabled_for_upstream(cur->id) && nd_proxy_upstream_route_onlink(cur->id, curPrefix->servicesPrefix)) {
|
||||||
// don't add
|
// don't add
|
||||||
tr_debug("Suppressing onlink %s for proxy", trace_ipv6_prefix(curPrefix->servicesPrefix, curPrefix->servicesPrefixLen));
|
tr_debug("Suppressing onlink %s for proxy", trace_ipv6_prefix(curPrefix->servicesPrefix, curPrefix->servicesPrefixLen));
|
||||||
|
} else if (curBorderRouter->P_res1) {
|
||||||
|
ipv6_route_add(curPrefix->servicesPrefix, curPrefix->servicesPrefixLen, cur->id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, 0xffffffff, 0);
|
||||||
} else {
|
} else {
|
||||||
//add
|
//add
|
||||||
tr_debug("Adding onlink %s", trace_ipv6_prefix(curPrefix->servicesPrefix, curPrefix->servicesPrefixLen));
|
tr_debug("Adding onlink %s", trace_ipv6_prefix(curPrefix->servicesPrefix, curPrefix->servicesPrefixLen));
|
||||||
|
@ -2818,8 +2845,8 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
|
||||||
if (!thread_dhcpv6_address_entry_available(curPrefix->servicesPrefix, &cur->ip_addresses)) {
|
if (!thread_dhcpv6_address_entry_available(curPrefix->servicesPrefix, &cur->ip_addresses)) {
|
||||||
thread_addr_write_mesh_local_16(addr, curBorderRouter->routerID, cur->thread_info);
|
thread_addr_write_mesh_local_16(addr, curBorderRouter->routerID, cur->thread_info);
|
||||||
/* Do not allow multiple DHCP solicits from one prefix => delete previous */
|
/* Do not allow multiple DHCP solicits from one prefix => delete previous */
|
||||||
thread_dhcp_client_global_address_delete(cur->id, NULL, curPrefix->servicesPrefix);
|
dhcp_client_global_address_delete(cur->id, NULL, curPrefix->servicesPrefix);
|
||||||
if (thread_dhcp_client_get_global_address(cur->id, addr, curPrefix->servicesPrefix, cur->mac, thread_dhcp_client_gua_error_cb) == 0) {
|
if (dhcp_client_get_global_address(cur->id, addr, curPrefix->servicesPrefix, cur->mac, thread_dhcp_client_gua_error_cb) == 0) {
|
||||||
tr_debug("GP Address Requested");
|
tr_debug("GP Address Requested");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2839,6 +2866,10 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
|
||||||
icmpv6_slaac_address_add(cur, curPrefix->servicesPrefix, curPrefix->servicesPrefixLen, 0xffffffff, 0xffffffff, true, SLAAC_IID_DEFAULT);
|
icmpv6_slaac_address_add(cur, curPrefix->servicesPrefix, curPrefix->servicesPrefixLen, 0xffffffff, 0xffffffff, true, SLAAC_IID_DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// generate address based on res1 bit
|
||||||
|
if (curBorderRouter->P_res1) {
|
||||||
|
thread_extension_dua_address_generate(cur, curPrefix->servicesPrefix, 64);
|
||||||
|
}
|
||||||
|
|
||||||
} // for each borderRouterList
|
} // for each borderRouterList
|
||||||
|
|
||||||
|
@ -2913,8 +2944,7 @@ void thread_bootstrap_dynamic_configuration_save(protocol_interface_info_entry_t
|
||||||
uint32_t mle_frame_counter = mle_service_security_get_frame_counter(cur->id);
|
uint32_t mle_frame_counter = mle_service_security_get_frame_counter(cur->id);
|
||||||
if (linkConfiguration) {
|
if (linkConfiguration) {
|
||||||
thread_nvm_store_fast_data_check_and_write(mac_frame_counter, mle_frame_counter, linkConfiguration->key_sequence);
|
thread_nvm_store_fast_data_check_and_write(mac_frame_counter, mle_frame_counter, linkConfiguration->key_sequence);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
thread_nvm_store_frame_counters_check_and_write(mac_frame_counter, mle_frame_counter);
|
thread_nvm_store_frame_counters_check_and_write(mac_frame_counter, mle_frame_counter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,9 @@ void thread_general_mle_receive_cb(int8_t interface_id, mle_message_t *mle_msg,
|
||||||
void thread_bootstrap_ready(struct protocol_interface_info_entry *cur);
|
void thread_bootstrap_ready(struct protocol_interface_info_entry *cur);
|
||||||
int thread_bootstrap_reset(struct protocol_interface_info_entry *cur);
|
int thread_bootstrap_reset(struct protocol_interface_info_entry *cur);
|
||||||
void thread_neighbor_list_clean(struct protocol_interface_info_entry *cur);
|
void thread_neighbor_list_clean(struct protocol_interface_info_entry *cur);
|
||||||
|
|
||||||
|
/* Function to remove linked neighbours for REEDs and FEDs */
|
||||||
|
void thread_reed_fed_neighbour_links_clean(struct protocol_interface_info_entry *cur);
|
||||||
bool thread_bootstrap_request_network_data(struct protocol_interface_info_entry *cur, struct thread_leader_data_s *leaderData, uint16_t short_address);
|
bool thread_bootstrap_request_network_data(struct protocol_interface_info_entry *cur, struct thread_leader_data_s *leaderData, uint16_t short_address);
|
||||||
bool thread_check_is_this_my_parent(struct protocol_interface_info_entry *cur, struct mac_neighbor_table_entry *entry_temp);
|
bool thread_check_is_this_my_parent(struct protocol_interface_info_entry *cur, struct mac_neighbor_table_entry *entry_temp);
|
||||||
void thread_clean_old_16_bit_address_based_addresses(struct protocol_interface_info_entry *cur);
|
void thread_clean_old_16_bit_address_based_addresses(struct protocol_interface_info_entry *cur);
|
||||||
|
@ -191,7 +194,6 @@ int thread_bootstrap_announce_send(protocol_interface_info_entry_t *cur, uint8_t
|
||||||
void thread_bootstrap_announcement_start(protocol_interface_info_entry_t *cur, uint8_t channel_page, uint16_t channel, uint8_t count, uint16_t period);
|
void thread_bootstrap_announcement_start(protocol_interface_info_entry_t *cur, uint8_t channel_page, uint16_t channel, uint8_t count, uint16_t period);
|
||||||
void thread_bootstrap_temporary_attach(protocol_interface_info_entry_t *cur, uint8_t channel_page, uint16_t channel, uint16_t panid, uint64_t timestamp);
|
void thread_bootstrap_temporary_attach(protocol_interface_info_entry_t *cur, uint8_t channel_page, uint16_t channel, uint16_t panid, uint64_t timestamp);
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define thread_interface_up(cur) ((void) 0)
|
#define thread_interface_up(cur) ((void) 0)
|
||||||
#define thread_bootstrap_state_machine(cur) ((void)0)
|
#define thread_bootstrap_state_machine(cur) ((void)0)
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "NWK_INTERFACE/Include/protocol.h"
|
#include "NWK_INTERFACE/Include/protocol.h"
|
||||||
#include "6LoWPAN/Thread/thread_config.h"
|
#include "6LoWPAN/Thread/thread_config.h"
|
||||||
#include "6LoWPAN/Thread/thread_common.h"
|
#include "6LoWPAN/Thread/thread_common.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_extension_bbr.h"
|
||||||
#include "6LoWPAN/Thread/thread_network_data_lib.h"
|
#include "6LoWPAN/Thread/thread_network_data_lib.h"
|
||||||
#include "6LoWPAN/Thread/thread_network_data_storage.h"
|
#include "6LoWPAN/Thread/thread_network_data_storage.h"
|
||||||
#include "6LoWPAN/Thread/thread_management_client.h"
|
#include "6LoWPAN/Thread/thread_management_client.h"
|
||||||
|
@ -591,6 +592,15 @@ void thread_border_router_network_data_update_notify(protocol_interface_info_ent
|
||||||
|
|
||||||
thread_border_router_network_data_appl_callback(cur);
|
thread_border_router_network_data_appl_callback(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void thread_border_router_old_partition_data_clean(int8_t interface_id)
|
||||||
|
{
|
||||||
|
thread_border_router_t *this = thread_border_router_find_by_interface(interface_id);
|
||||||
|
if (this) {
|
||||||
|
coap_service_request_delete_by_service_id(this->coap_service_id);
|
||||||
|
}
|
||||||
|
thread_extension_bbr_old_partition_data_clean(interface_id);
|
||||||
|
}
|
||||||
#endif // HAVE_THREAD_ROUTER
|
#endif // HAVE_THREAD_ROUTER
|
||||||
|
|
||||||
/*External APIs*/
|
/*External APIs*/
|
||||||
|
@ -837,7 +847,6 @@ int thread_border_router_dns_search_list_option_set(int8_t interface_id, uint8_t
|
||||||
static void thread_tmf_client_network_data_set_cb(int8_t interface_id, int8_t status, uint8_t *data_ptr, uint16_t data_len)
|
static void thread_tmf_client_network_data_set_cb(int8_t interface_id, int8_t status, uint8_t *data_ptr, uint16_t data_len)
|
||||||
{
|
{
|
||||||
protocol_interface_info_entry_t *cur;
|
protocol_interface_info_entry_t *cur;
|
||||||
(void) status;
|
|
||||||
(void) data_len;
|
(void) data_len;
|
||||||
(void) data_ptr;
|
(void) data_ptr;
|
||||||
|
|
||||||
|
@ -846,7 +855,7 @@ static void thread_tmf_client_network_data_set_cb(int8_t interface_id, int8_t st
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur->thread_info->localServerDataBase.publish_active = false;
|
cur->thread_info->localServerDataBase.publish_coap_req_id = 0;
|
||||||
|
|
||||||
tr_debug("BR a/sd response status: %s, addr: %x", status ? "Fail" : "OK", cur->thread_info->localServerDataBase.registered_rloc16);
|
tr_debug("BR a/sd response status: %s, addr: %x", status ? "Fail" : "OK", cur->thread_info->localServerDataBase.registered_rloc16);
|
||||||
|
|
||||||
|
@ -855,10 +864,12 @@ static void thread_tmf_client_network_data_set_cb(int8_t interface_id, int8_t st
|
||||||
thread_border_router_publish(cur->id);
|
thread_border_router_publish(cur->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// always update RLOC to new one. If COAP response fails then resubmit timer will trigger new a/sd
|
if (status == 0) {
|
||||||
|
// If request was successful, then update RLOC to new one.
|
||||||
cur->thread_info->localServerDataBase.registered_rloc16 = mac_helper_mac16_address_get(cur);
|
cur->thread_info->localServerDataBase.registered_rloc16 = mac_helper_mac16_address_get(cur);
|
||||||
cur->thread_info->localServerDataBase.release_old_address = false;
|
cur->thread_info->localServerDataBase.release_old_address = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int thread_border_router_publish(int8_t interface_id)
|
int thread_border_router_publish(int8_t interface_id)
|
||||||
|
@ -884,21 +895,20 @@ int thread_border_router_publish(int8_t interface_id)
|
||||||
rloc16 = mac_helper_mac16_address_get(cur);
|
rloc16 = mac_helper_mac16_address_get(cur);
|
||||||
tr_debug("Border router old: %x, new: %x", cur->thread_info->localServerDataBase.registered_rloc16, rloc16);
|
tr_debug("Border router old: %x, new: %x", cur->thread_info->localServerDataBase.registered_rloc16, rloc16);
|
||||||
|
|
||||||
if (cur->thread_info->localServerDataBase.publish_active) {
|
if (cur->thread_info->localServerDataBase.publish_coap_req_id) {
|
||||||
if (rloc16 != cur->thread_info->localServerDataBase.registered_rloc16) {
|
if (rloc16 != cur->thread_info->localServerDataBase.registered_rloc16) {
|
||||||
/*
|
/*
|
||||||
* Device short address has changed, cancel previous a/sd and a/as requests
|
* Device short address has changed, cancel previous a/sd requests
|
||||||
* and start resubmit timer
|
* and start resubmit timer
|
||||||
* */
|
* */
|
||||||
tr_debug("address changed, kill pending reuqests");
|
tr_debug("RLOC changed, kill pending a/sd request");
|
||||||
thread_management_client_pending_coap_request_kill(cur->id);
|
thread_management_client_coap_message_delete(cur->id, cur->thread_info->localServerDataBase.publish_coap_req_id);
|
||||||
thread_border_router_resubmit_timer_set(interface_id, 5);
|
thread_border_router_resubmit_timer_set(interface_id, 5);
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
cur->thread_info->localServerDataBase.publish_pending = true;
|
cur->thread_info->localServerDataBase.publish_pending = true;
|
||||||
tr_debug("Activate pending status for publish");
|
tr_debug("Activate pending status for publish");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Allocate Memory for Data
|
//Allocate Memory for Data
|
||||||
|
@ -926,8 +936,10 @@ int thread_border_router_publish(int8_t interface_id)
|
||||||
if (payload_ptr) {
|
if (payload_ptr) {
|
||||||
ns_dyn_mem_free(payload_ptr);
|
ns_dyn_mem_free(payload_ptr);
|
||||||
}
|
}
|
||||||
if (ret_val == 0) {
|
if (ret_val > 0) {
|
||||||
cur->thread_info->localServerDataBase.publish_active = true;
|
// a/sd request successful, save coap request id
|
||||||
|
cur->thread_info->localServerDataBase.publish_coap_req_id = (uint16_t)ret_val;
|
||||||
|
ret_val = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_border_router_resubmit_timer_set(interface_id, -1);
|
thread_border_router_resubmit_timer_set(interface_id, -1);
|
||||||
|
|
|
@ -85,6 +85,14 @@ void thread_border_router_network_data_appl_callback(protocol_interface_info_ent
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void thread_border_router_network_data_update_notify(protocol_interface_info_entry_t *cur);
|
void thread_border_router_network_data_update_notify(protocol_interface_info_entry_t *cur);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Clear data related to old partition.
|
||||||
|
*
|
||||||
|
* \param interface_id Network interface ID.
|
||||||
|
*/
|
||||||
|
void thread_border_router_old_partition_data_clean(int8_t interface_id);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define thread_border_router_init(interface_id)
|
#define thread_border_router_init(interface_id)
|
||||||
#define thread_border_router_delete(interface_id)
|
#define thread_border_router_delete(interface_id)
|
||||||
|
@ -92,6 +100,7 @@ void thread_border_router_network_data_update_notify(protocol_interface_info_ent
|
||||||
#define thread_border_router_resubmit_timer_set(interface_id, seconds)
|
#define thread_border_router_resubmit_timer_set(interface_id, seconds)
|
||||||
#define thread_border_router_network_data_appl_callback(cur)
|
#define thread_border_router_network_data_appl_callback(cur)
|
||||||
#define thread_border_router_network_data_update_notify(cur)
|
#define thread_border_router_network_data_update_notify(cur)
|
||||||
|
#define thread_border_router_old_partition_data_clean(interface_id)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* THREAD_BORDER_ROUTER_API_INTERNAL_H_ */
|
#endif /* THREAD_BORDER_ROUTER_API_INTERNAL_H_ */
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "ns_list.h"
|
#include "ns_list.h"
|
||||||
#include "ns_trace.h"
|
#include "ns_trace.h"
|
||||||
#include "nsdynmemLIB.h"
|
#include "nsdynmemLIB.h"
|
||||||
|
#include "randLIB.h"
|
||||||
#include "common_functions.h"
|
#include "common_functions.h"
|
||||||
#include "ns_sha256.h"
|
#include "ns_sha256.h"
|
||||||
|
|
||||||
|
@ -74,6 +75,8 @@ typedef NS_LIST_HEAD(device_t, link) device_list_t;
|
||||||
typedef struct commissioner_entry {
|
typedef struct commissioner_entry {
|
||||||
device_list_t device_list;
|
device_list_t device_list;
|
||||||
uint8_t destination_address[16];
|
uint8_t destination_address[16];
|
||||||
|
uint8_t final_dest_address[16]; // Relay message final destination
|
||||||
|
uint8_t leader_address[16]; // leader ALOC for contacting the leader
|
||||||
uint8_t PSKc_ptr[16];
|
uint8_t PSKc_ptr[16];
|
||||||
thread_commissioning_status_cb *status_cb_ptr;
|
thread_commissioning_status_cb *status_cb_ptr;
|
||||||
uint16_t destination_port;
|
uint16_t destination_port;
|
||||||
|
@ -82,7 +85,8 @@ typedef struct commissioner_entry {
|
||||||
int8_t interface_id;
|
int8_t interface_id;
|
||||||
int8_t coap_service_id;
|
int8_t coap_service_id;
|
||||||
int8_t coap_secure_service_id;
|
int8_t coap_secure_service_id;
|
||||||
int8_t coap_virtual_service_id;
|
int8_t coap_secure_virtual_service_id;
|
||||||
|
int8_t coap_udp_proxy_service_id;
|
||||||
bool registered: 1;
|
bool registered: 1;
|
||||||
bool native_commissioner: 1;
|
bool native_commissioner: 1;
|
||||||
|
|
||||||
|
@ -167,7 +171,7 @@ static commissioner_t *commissioner_find_by_service(int8_t service_id)
|
||||||
{
|
{
|
||||||
commissioner_t *this = NULL;
|
commissioner_t *this = NULL;
|
||||||
ns_list_foreach(commissioner_t, cur_ptr, &instance_list) {
|
ns_list_foreach(commissioner_t, cur_ptr, &instance_list) {
|
||||||
if (cur_ptr->coap_service_id == service_id || cur_ptr->coap_virtual_service_id == service_id || cur_ptr->coap_secure_service_id == service_id) {
|
if (cur_ptr->coap_service_id == service_id || cur_ptr->coap_secure_virtual_service_id == service_id || cur_ptr->coap_secure_service_id == service_id || cur_ptr->coap_udp_proxy_service_id == service_id) {
|
||||||
this = cur_ptr;
|
this = cur_ptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -237,12 +241,46 @@ static int commission_finalisation_resp_send(int8_t coap_service_id, device_t *d
|
||||||
* Callback functions
|
* Callback functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static int thread_commissioning_active_get_cb(int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *response_ptr)
|
||||||
|
{
|
||||||
|
commissioner_t *this = commissioner_find_by_service(service_id);
|
||||||
|
commissioning_state_e state = COMMISSIONING_STATE_REJECT;// Default is accept if we get error it is rejected
|
||||||
|
uint8_t *ptr;
|
||||||
|
uint16_t len;
|
||||||
|
(void) source_address;
|
||||||
|
(void) source_port;
|
||||||
|
|
||||||
|
/* Transaction failed */
|
||||||
|
if (!response_ptr) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr_debug("management get response from comm module");
|
||||||
|
if (!this) {
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((len = thread_meshcop_tlv_find(response_ptr->payload_ptr, response_ptr->payload_len, MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA, &ptr)) > 0) {
|
||||||
|
state = COMMISSIONING_STATE_ACCEPT;
|
||||||
|
tr_debug(" TLV ml prefix=%s\r\n", trace_array(ptr, len));
|
||||||
|
memcpy(this->leader_address, ptr, 8);
|
||||||
|
memcpy(this->leader_address + 8, ADDR_SHORT_ADR_SUFFIC, 6);
|
||||||
|
common_write_16_bit(0xfc00, this->leader_address + 14);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->status_cb_ptr) {
|
||||||
|
this->status_cb_ptr(this->interface_id, this->session_id, state);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int commissioning_leader_petition_recv_cb(int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *response_ptr)
|
static int commissioning_leader_petition_recv_cb(int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *response_ptr)
|
||||||
{
|
{
|
||||||
commissioner_t *this = commissioner_find_by_service(service_id);
|
commissioner_t *this = commissioner_find_by_service(service_id);
|
||||||
commissioning_state_e state = COMMISSIONING_STATE_REJECT;
|
commissioning_state_e state = COMMISSIONING_STATE_REJECT;
|
||||||
uint16_t session_id = 0;
|
uint16_t session_id = 0;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr = NULL;
|
||||||
|
char *uri_ptr = THREAD_URI_ACTIVE_GET;
|
||||||
(void) source_address;
|
(void) source_address;
|
||||||
(void) source_port;
|
(void) source_port;
|
||||||
|
|
||||||
|
@ -267,6 +305,16 @@ static int commissioning_leader_petition_recv_cb(int8_t service_id, uint8_t sour
|
||||||
}
|
}
|
||||||
tr_debug("petition response session_id: %d state:%d", session_id, state);
|
tr_debug("petition response session_id: %d state:%d", session_id, state);
|
||||||
|
|
||||||
|
// if registered and native commissioner send ACTIVE_GET to BBR to get mesh parameters
|
||||||
|
// if not native set leader ALOC from stack
|
||||||
|
if (this->native_commissioner) {
|
||||||
|
coap_service_request_send(service_id, COAP_REQUEST_OPTIONS_NONE, this->destination_address, this->destination_port,
|
||||||
|
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, uri_ptr, COAP_CT_OCTET_STREAM, NULL, 0, thread_commissioning_active_get_cb);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
thread_management_get_leader_aloc(this->interface_id, this->leader_address);
|
||||||
|
}
|
||||||
|
|
||||||
user_response:
|
user_response:
|
||||||
if (state == COMMISSIONING_STATE_REJECT) {
|
if (state == COMMISSIONING_STATE_REJECT) {
|
||||||
thci_trace("commissionerPetitionRejected");
|
thci_trace("commissionerPetitionRejected");
|
||||||
|
@ -376,25 +424,65 @@ static int commission_dataset_changed_notify_recv_cb(int8_t service_id, uint8_t
|
||||||
(void)source_port;
|
(void)source_port;
|
||||||
|
|
||||||
tr_debug("Dataset changed - notification received from: %s", trace_ipv6(source_address));
|
tr_debug("Dataset changed - notification received from: %s", trace_ipv6(source_address));
|
||||||
|
commissioner_t *this = commissioner_find_by_service(service_id);
|
||||||
|
|
||||||
|
if (!this) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
coap_service_request_send(service_id, COAP_REQUEST_OPTIONS_NONE, this->destination_address, this->destination_port,
|
||||||
|
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_ACTIVE_GET, COAP_CT_OCTET_STREAM, NULL, 0, thread_commissioning_active_get_cb);
|
||||||
|
|
||||||
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_NONE, NULL, 0);
|
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_NONE, NULL, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static int thread_commission_udp_proxy_receive_cb(int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *request_ptr)
|
||||||
|
{
|
||||||
|
tr_debug("Recv UDP_RX.ntf");
|
||||||
|
|
||||||
|
commissioner_t *this = commissioner_find_by_service(service_id);
|
||||||
|
uint8_t *udp_encapsulation_ptr, *udp_tmf_ptr;
|
||||||
|
uint16_t udp_encapsulation_len, udp_tmf_len;
|
||||||
|
uint8_t *ipv6_addr_ptr;
|
||||||
|
uint16_t ipv6_addr_len;
|
||||||
|
uint16_t dest_port;
|
||||||
|
|
||||||
|
(void) source_port;
|
||||||
|
|
||||||
|
if (!this || !source_address || !request_ptr) {
|
||||||
|
return -1; // goto error response
|
||||||
|
}
|
||||||
|
|
||||||
|
udp_encapsulation_len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_UDP_ENCAPSULATION, &udp_encapsulation_ptr);
|
||||||
|
ipv6_addr_len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_IPV6_ADDRESS, &ipv6_addr_ptr);
|
||||||
|
|
||||||
|
if (udp_encapsulation_len == 0 || ipv6_addr_len < 16) {
|
||||||
|
tr_warn("Corrupted UDP_RX.ntf received (%d, %d)", udp_encapsulation_len, ipv6_addr_len);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dest_port = common_read_16_bit(udp_encapsulation_ptr + 2);
|
||||||
|
udp_tmf_len = udp_encapsulation_len - 4;
|
||||||
|
udp_tmf_ptr = udp_encapsulation_ptr + 4;
|
||||||
|
|
||||||
|
tr_debug("UDP_RX tmf: %s", trace_array(udp_tmf_ptr, udp_tmf_len));
|
||||||
|
|
||||||
|
coap_service_virtual_socket_recv(this->coap_udp_proxy_service_id, ipv6_addr_ptr, dest_port, udp_tmf_ptr, udp_tmf_len);
|
||||||
|
|
||||||
|
return -1; // no response sent
|
||||||
|
}
|
||||||
|
|
||||||
static uint8_t *bloom_filter_calculate(uint8_t *bloom_filter_ptr, device_list_t device_list, int *steering_tlv_max_length)
|
static uint8_t *bloom_filter_calculate(uint8_t *bloom_filter_ptr, device_list_t device_list, int *steering_tlv_max_length)
|
||||||
{
|
{
|
||||||
memset(bloom_filter_ptr, 0, *steering_tlv_max_length);
|
memset(bloom_filter_ptr, 0, *steering_tlv_max_length);
|
||||||
ns_list_foreach(device_t, cur_ptr, &device_list)
|
ns_list_foreach(device_t, cur_ptr, &device_list) {
|
||||||
{
|
if (memcmp(cur_ptr->EUI64, any_device, 8) != 0) {
|
||||||
if (memcmp(cur_ptr->EUI64, any_device, 8) != 0)
|
|
||||||
{
|
|
||||||
tr_debug("eui64 used on commissioning side = %s", trace_array(cur_ptr->EUI64, 8));
|
tr_debug("eui64 used on commissioning side = %s", trace_array(cur_ptr->EUI64, 8));
|
||||||
cur_ptr->IID[0] |= 2; //Changed IID to MAC extended address for bloom filter calculation
|
cur_ptr->IID[0] |= 2; //Changed IID to MAC extended address for bloom filter calculation
|
||||||
thread_beacon_calculate_bloom_filter(bloom_filter_ptr, *steering_tlv_max_length, cur_ptr->IID, 8);
|
thread_beacon_calculate_bloom_filter(bloom_filter_ptr, *steering_tlv_max_length, cur_ptr->IID, 8);
|
||||||
cur_ptr->IID[0] &= ~2;//Restore IID
|
cur_ptr->IID[0] &= ~2;//Restore IID
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
bloom_filter_ptr[0] = 0xff;
|
bloom_filter_ptr[0] = 0xff;
|
||||||
*steering_tlv_max_length = 1;
|
*steering_tlv_max_length = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -403,6 +491,35 @@ static uint8_t *bloom_filter_calculate(uint8_t *bloom_filter_ptr,device_list_t d
|
||||||
|
|
||||||
return bloom_filter_ptr;
|
return bloom_filter_ptr;
|
||||||
}
|
}
|
||||||
|
static int thread_commissioner_set_steering_data(commissioner_t *this, uint16_t session_id, uint8_t *steering_data_ptr, uint8_t steering_data_len)
|
||||||
|
{
|
||||||
|
uint8_t payload[24];/* 4 + 16 + 4*/
|
||||||
|
uint8_t *ptr;
|
||||||
|
int8_t coap_service_id;
|
||||||
|
if (!this || steering_data_len > 16) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = payload;
|
||||||
|
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_STEERING_DATA, steering_data_len, steering_data_ptr);
|
||||||
|
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_COMMISSIONER_SESSION_ID, session_id);
|
||||||
|
|
||||||
|
tr_debug("thread commissioner set steering data %s", trace_array(steering_data_ptr, steering_data_len));
|
||||||
|
memcpy(this->final_dest_address, this->leader_address, 16);
|
||||||
|
//default uri for thread version 1.1
|
||||||
|
char *uri = THREAD_URI_COMMISSIONER_SET;
|
||||||
|
|
||||||
|
if (this->native_commissioner) {
|
||||||
|
coap_service_id = this->coap_udp_proxy_service_id;
|
||||||
|
} else {
|
||||||
|
coap_service_id = this->coap_service_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
coap_service_request_send(coap_service_id, COAP_REQUEST_OPTIONS_NONE, this->destination_address, this->destination_port,
|
||||||
|
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, uri, COAP_CT_OCTET_STREAM, payload, ptr - payload, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int commission_steering_data_update(commissioner_t *this)
|
static int commission_steering_data_update(commissioner_t *this)
|
||||||
{
|
{
|
||||||
|
@ -414,7 +531,7 @@ static int commission_steering_data_update(commissioner_t *this)
|
||||||
//bloom filter calculation function call
|
//bloom filter calculation function call
|
||||||
bloom_filter_calculate(bloom_filter_ptr, this->device_list, &steering_tlv_length);
|
bloom_filter_calculate(bloom_filter_ptr, this->device_list, &steering_tlv_length);
|
||||||
tr_debug("Steering bloom set :%s", trace_array(bloom_filter_ptr, 16));
|
tr_debug("Steering bloom set :%s", trace_array(bloom_filter_ptr, 16));
|
||||||
ret = thread_management_set_steering_data(this->management_instance, this->session_id,bloom_filter_ptr, steering_tlv_length, NULL);
|
ret = thread_commissioner_set_steering_data(this, this->session_id, bloom_filter_ptr, steering_tlv_length);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
tr_warn("Steering data set failed %d", ret);
|
tr_warn("Steering data set failed %d", ret);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -475,7 +592,7 @@ static int commission_relay_rx_recv_cb(int8_t service_id, uint8_t source_address
|
||||||
tr_warn("catching device for iid:%s", trace_array(&joiner_address[8], 8));
|
tr_warn("catching device for iid:%s", trace_array(&joiner_address[8], 8));
|
||||||
}
|
}
|
||||||
device_ptr->joiner_router_rloc = joiner_router_rloc;
|
device_ptr->joiner_router_rloc = joiner_router_rloc;
|
||||||
coap_service_virtual_socket_recv(this->coap_virtual_service_id, joiner_address, joiner_port, udp_ptr, udp_len);
|
coap_service_virtual_socket_recv(this->coap_secure_virtual_service_id, joiner_address, joiner_port, udp_ptr, udp_len);
|
||||||
return -1; // no response sent
|
return -1; // no response sent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,20 +733,55 @@ static int commissioner_br_security_done_cb(int8_t service_id, uint8_t address[1
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int thread_commissioning_remote_addr_set(commissioner_t *this)
|
static int thread_commission_udp_proxy_virtual_socket_send_cb(int8_t service_id, uint8_t destination_addr_ptr[static 16], uint16_t port, const uint8_t *data_ptr, uint16_t data_len)
|
||||||
{
|
{
|
||||||
if (0 == thread_management_get_leader_address(this->interface_id, this->destination_address)) {
|
(void) port;
|
||||||
tr_debug("on-mesh commissioner");
|
uint8_t *payload_ptr;
|
||||||
this->destination_port = THREAD_MANAGEMENT_PORT;
|
uint8_t *ptr;
|
||||||
this->native_commissioner = false;
|
uint16_t payload_len;
|
||||||
} else if (0 == thread_commissioning_native_commissioner_get_connection_info(this->interface_id,
|
uint16_t source_port;
|
||||||
this->destination_address, &this->destination_port)) {
|
|
||||||
tr_debug("native commissioner");
|
commissioner_t *this = commissioner_find_by_service(service_id);
|
||||||
this->native_commissioner = true;
|
if (!this) {
|
||||||
} else {
|
|
||||||
tr_error("No remote address");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr_debug("UDP_TX.ntf tmf: %s", trace_array(data_ptr, data_len));
|
||||||
|
if (!this || !destination_addr_ptr || !data_ptr) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
payload_len = 2 + THREAD_IPV6_ADDRESS_TLV_LENGTH + 4 + 4 + data_len; // MESHCOP_TLV_IPV6_ADDRESS + MESHCOP_TLV_UDP_ENCAPSULATION
|
||||||
|
|
||||||
|
payload_ptr = ns_dyn_mem_alloc(payload_len);
|
||||||
|
if (!payload_ptr) {
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = payload_ptr;
|
||||||
|
|
||||||
|
tr_debug("br_address %s final dest_address %s and port %d", trace_ipv6(this->destination_address),
|
||||||
|
trace_ipv6(this->final_dest_address), this->destination_port);
|
||||||
|
|
||||||
|
/* MESHCOP_TLV_IPV6_ADDRESS */
|
||||||
|
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_IPV6_ADDRESS, THREAD_IPV6_ADDRESS_TLV_LENGTH, this->final_dest_address);
|
||||||
|
|
||||||
|
/* MESHCOP_TLV_UDP_ENCAPSULATION */
|
||||||
|
*ptr++ = MESHCOP_TLV_UDP_ENCAPSULATION;
|
||||||
|
*ptr++ = 0xff;
|
||||||
|
ptr = common_write_16_bit(2 + 2 + data_len, ptr); // length (Port x 2 + TMF message)
|
||||||
|
source_port = randLIB_get_16bit(); // ephemeral port, 16-bit number
|
||||||
|
ptr = common_write_16_bit(source_port, ptr); // source port,
|
||||||
|
ptr = common_write_16_bit(THREAD_MANAGEMENT_PORT, ptr); // destination port
|
||||||
|
memcpy(ptr, data_ptr, data_len);
|
||||||
|
ptr += data_len;
|
||||||
|
|
||||||
|
/* Send UDP_TX.ntf */
|
||||||
|
coap_service_request_send(this->coap_secure_service_id, COAP_REQUEST_OPTIONS_NONE, this->destination_address, this->destination_port,
|
||||||
|
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_UDP_TRANSMIT_NOTIFICATION, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr, NULL);
|
||||||
|
|
||||||
|
ns_dyn_mem_free(payload_ptr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,16 +790,17 @@ Public api functions
|
||||||
*/
|
*/
|
||||||
int thread_commissioning_register(int8_t interface_id, uint8_t PSKc[static 16])
|
int thread_commissioning_register(int8_t interface_id, uint8_t PSKc[static 16])
|
||||||
{
|
{
|
||||||
if (commissioner_find(interface_id)) {
|
commissioner_t *this = commissioner_find(interface_id);
|
||||||
return -1;
|
if (!this) {
|
||||||
|
this = commissioner_create(interface_id);
|
||||||
}
|
}
|
||||||
commissioner_t *this = commissioner_create(interface_id);
|
|
||||||
if (!this) {
|
if (!this) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
memcpy(this->PSKc_ptr, PSKc, 16);
|
memcpy(this->PSKc_ptr, PSKc, 16);
|
||||||
|
if (this->registered) {
|
||||||
this->management_instance = thread_management_register(interface_id);
|
return 0;
|
||||||
|
}
|
||||||
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_NONE, NULL, NULL);
|
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_NONE, NULL, NULL);
|
||||||
coap_service_register_uri(this->coap_service_id, THREAD_URI_RELAY_RECEIVE, COAP_SERVICE_ACCESS_POST_ALLOWED, commission_relay_rx_recv_cb);
|
coap_service_register_uri(this->coap_service_id, THREAD_URI_RELAY_RECEIVE, COAP_SERVICE_ACCESS_POST_ALLOWED, commission_relay_rx_recv_cb);
|
||||||
coap_service_register_uri(this->coap_service_id, THREAD_URI_JOINER_APPLICATION_REQUEST, COAP_SERVICE_ACCESS_POST_ALLOWED, commission_application_provision_req_recv_cb);
|
coap_service_register_uri(this->coap_service_id, THREAD_URI_JOINER_APPLICATION_REQUEST, COAP_SERVICE_ACCESS_POST_ALLOWED, commission_application_provision_req_recv_cb);
|
||||||
|
@ -655,10 +808,15 @@ int thread_commissioning_register(int8_t interface_id, uint8_t PSKc[static 16])
|
||||||
|
|
||||||
this->coap_secure_service_id = coap_service_initialize(this->interface_id, THREAD_COMMISSIONING_PORT, COAP_SERVICE_OPTIONS_SECURE | COAP_SERVICE_OPTIONS_SECURE_BYPASS, commissioner_br_security_start_cb, commissioner_br_security_done_cb);
|
this->coap_secure_service_id = coap_service_initialize(this->interface_id, THREAD_COMMISSIONING_PORT, COAP_SERVICE_OPTIONS_SECURE | COAP_SERVICE_OPTIONS_SECURE_BYPASS, commissioner_br_security_start_cb, commissioner_br_security_done_cb);
|
||||||
coap_service_register_uri(this->coap_secure_service_id, THREAD_URI_RELAY_RECEIVE, COAP_SERVICE_ACCESS_POST_ALLOWED, commission_relay_rx_recv_cb);
|
coap_service_register_uri(this->coap_secure_service_id, THREAD_URI_RELAY_RECEIVE, COAP_SERVICE_ACCESS_POST_ALLOWED, commission_relay_rx_recv_cb);
|
||||||
|
coap_service_register_uri(this->coap_secure_service_id, THREAD_URI_UDP_RECVEIVE_NOTIFICATION, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_commission_udp_proxy_receive_cb);
|
||||||
|
|
||||||
|
this->coap_secure_virtual_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_SECURE | COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET, joiner_commissioner_security_start_cb, commissioning_security_done_cb);
|
||||||
|
coap_service_register_uri(this->coap_secure_virtual_service_id, THREAD_URI_JOINER_FINALIZATION, COAP_SERVICE_ACCESS_POST_ALLOWED, commission_finalisation_req_recv_cb);
|
||||||
|
coap_service_virtual_socket_set_cb(this->coap_secure_virtual_service_id, commission_virtual_socket_send_cb);
|
||||||
|
|
||||||
|
this->coap_udp_proxy_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET, NULL, NULL);
|
||||||
|
coap_service_virtual_socket_set_cb(this->coap_udp_proxy_service_id, thread_commission_udp_proxy_virtual_socket_send_cb);
|
||||||
|
|
||||||
this->coap_virtual_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_SECURE | COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET, joiner_commissioner_security_start_cb, commissioning_security_done_cb);
|
|
||||||
coap_service_register_uri(this->coap_virtual_service_id, THREAD_URI_JOINER_FINALIZATION, COAP_SERVICE_ACCESS_POST_ALLOWED, commission_finalisation_req_recv_cb);
|
|
||||||
coap_service_virtual_socket_set_cb(this->coap_virtual_service_id, commission_virtual_socket_send_cb);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,11 +830,11 @@ int thread_commissioning_unregister(int8_t interface_id)
|
||||||
// Unregister the commissioner
|
// Unregister the commissioner
|
||||||
thread_commissioning_petition_keep_alive(this->interface_id, COMMISSIONING_STATE_REJECT);
|
thread_commissioning_petition_keep_alive(this->interface_id, COMMISSIONING_STATE_REJECT);
|
||||||
}
|
}
|
||||||
thread_management_unregister(this->management_instance);
|
|
||||||
|
|
||||||
coap_service_delete(this->coap_service_id);
|
coap_service_delete(this->coap_service_id);
|
||||||
coap_service_delete(this->coap_secure_service_id);
|
coap_service_delete(this->coap_secure_service_id);
|
||||||
coap_service_delete(this->coap_virtual_service_id);
|
coap_service_delete(this->coap_secure_virtual_service_id);
|
||||||
|
coap_service_delete(this->coap_udp_proxy_service_id);
|
||||||
|
|
||||||
commissioner_delete(this);
|
commissioner_delete(this);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -690,7 +848,6 @@ int thread_commissioning_petition_start(int8_t interface_id, char *commissioner_
|
||||||
uint8_t service_id;
|
uint8_t service_id;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
char *uri_ptr;
|
char *uri_ptr;
|
||||||
|
|
||||||
this = commissioner_find(interface_id);
|
this = commissioner_find(interface_id);
|
||||||
|
|
||||||
if (!this) {
|
if (!this) {
|
||||||
|
@ -705,16 +862,14 @@ int thread_commissioning_petition_start(int8_t interface_id, char *commissioner_
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thread_commissioning_remote_addr_set(this)) {
|
|
||||||
return -4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->native_commissioner) {
|
if (this->native_commissioner) {
|
||||||
uri_ptr = THREAD_URI_COMMISSIONER_PETITION;
|
uri_ptr = THREAD_URI_COMMISSIONER_PETITION;
|
||||||
service_id = this->coap_secure_service_id;
|
service_id = this->coap_secure_service_id;
|
||||||
} else {
|
} else {
|
||||||
uri_ptr = THREAD_URI_LEADER_PETITION;
|
uri_ptr = THREAD_URI_LEADER_PETITION;
|
||||||
service_id = this->coap_service_id;
|
service_id = this->coap_service_id;
|
||||||
|
thread_management_get_leader_aloc(this->interface_id, this->destination_address);
|
||||||
|
this->destination_port = THREAD_MANAGEMENT_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->status_cb_ptr = status_cb_ptr;
|
this->status_cb_ptr = status_cb_ptr;
|
||||||
|
@ -747,16 +902,13 @@ int thread_commissioning_petition_keep_alive(int8_t interface_id, commissioning_
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thread_commissioning_remote_addr_set(this)) {
|
|
||||||
return -4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->native_commissioner) {
|
if (this->native_commissioner) {
|
||||||
uri_ptr = THREAD_URI_COMMISSIONER_KEEP_ALIVE;
|
uri_ptr = THREAD_URI_COMMISSIONER_KEEP_ALIVE;
|
||||||
service_id = this->coap_secure_service_id;
|
service_id = this->coap_secure_service_id;
|
||||||
} else {
|
} else {
|
||||||
uri_ptr = THREAD_URI_LEADER_KEEP_ALIVE;
|
uri_ptr = THREAD_URI_LEADER_KEEP_ALIVE;
|
||||||
service_id = this->coap_service_id;
|
service_id = this->coap_service_id;
|
||||||
|
thread_management_get_leader_aloc(this->interface_id, this->destination_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = payload;
|
ptr = payload;
|
||||||
|
@ -858,15 +1010,39 @@ void *thread_commission_device_get_next(void *ptr, int8_t interface_id, bool *sh
|
||||||
} else {
|
} else {
|
||||||
cur_ptr = (device_t *)ns_list_get_next(&this->device_list, cur_ptr);
|
cur_ptr = (device_t *)ns_list_get_next(&this->device_list, cur_ptr);
|
||||||
}
|
}
|
||||||
if(!cur_ptr) return NULL;
|
if (!cur_ptr) {
|
||||||
if(short_eui64) *short_eui64 = cur_ptr->short_eui64;
|
return NULL;
|
||||||
if(EUI64) memcpy(EUI64, cur_ptr->EUI64, 8);
|
}
|
||||||
if(PSKd) memcpy(PSKd, cur_ptr->PSKd, 32);
|
if (short_eui64) {
|
||||||
if(PSKd_len) *PSKd_len = cur_ptr->PSKd_len;
|
*short_eui64 = cur_ptr->short_eui64;
|
||||||
|
}
|
||||||
|
if (EUI64) {
|
||||||
|
memcpy(EUI64, cur_ptr->EUI64, 8);
|
||||||
|
}
|
||||||
|
if (PSKd) {
|
||||||
|
memcpy(PSKd, cur_ptr->PSKd, 32);
|
||||||
|
}
|
||||||
|
if (PSKd_len) {
|
||||||
|
*PSKd_len = cur_ptr->PSKd_len;
|
||||||
|
}
|
||||||
|
|
||||||
return cur_ptr;
|
return cur_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int thread_commissioning_attach(int8_t interface_id, uint8_t *destination_address, uint16_t destination_port)
|
||||||
|
{
|
||||||
|
tr_debug("start ethernet commissioner attach");
|
||||||
|
commissioner_t *this = commissioner_find(interface_id);
|
||||||
|
if (!this) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memcpy(this->destination_address, destination_address, 16);
|
||||||
|
this->destination_port = destination_port;
|
||||||
|
this->native_commissioner = true;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int thread_commissioning_native_commissioner_start(int8_t interface_id, thread_commissioning_native_select_cb *cb_ptr)
|
int thread_commissioning_native_commissioner_start(int8_t interface_id, thread_commissioning_native_select_cb *cb_ptr)
|
||||||
{
|
{
|
||||||
protocol_interface_info_entry_t *cur;
|
protocol_interface_info_entry_t *cur;
|
||||||
|
@ -909,6 +1085,18 @@ int thread_commissioning_native_commissioner_connect(int8_t interface_id, thread
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
*cur->thread_info->native_commissioner_link = *link_ptr;
|
*cur->thread_info->native_commissioner_link = *link_ptr;
|
||||||
|
|
||||||
|
commissioner_t *this = commissioner_find(interface_id);
|
||||||
|
if (!this) {
|
||||||
|
this = commissioner_create(interface_id);
|
||||||
|
}
|
||||||
|
if (!this) {
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->native_commissioner = true;
|
||||||
|
memcpy(this->destination_address, link_ptr->destination_address, 16);
|
||||||
|
this->destination_port = link_ptr->destination_port;
|
||||||
//TODO check that we are scanning for networks and reset backup timers
|
//TODO check that we are scanning for networks and reset backup timers
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -916,22 +1104,15 @@ int thread_commissioning_native_commissioner_connect(int8_t interface_id, thread
|
||||||
|
|
||||||
int thread_commissioning_native_commissioner_get_connection_info(int8_t interface_id, uint8_t *address_ptr, uint16_t *port)
|
int thread_commissioning_native_commissioner_get_connection_info(int8_t interface_id, uint8_t *address_ptr, uint16_t *port)
|
||||||
{
|
{
|
||||||
protocol_interface_info_entry_t *cur;
|
commissioner_t *this = commissioner_find(interface_id);
|
||||||
cur = protocol_stack_interface_info_get_by_id(interface_id);
|
|
||||||
tr_debug("get native connection info");
|
tr_debug("get native connection info");
|
||||||
if(!cur || !cur->thread_info) {
|
if (!this) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thread_attach_ready(cur) != 0) {
|
memcpy(address_ptr, this->destination_address, 16);
|
||||||
return -2;
|
|
||||||
}
|
*port = this->destination_port;
|
||||||
if (protocol_6lowpan_interface_get_link_local_cordinator_address(cur, address_ptr) != 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (port) {
|
|
||||||
*port = cur->thread_info->native_commissioner_port;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,7 +1128,8 @@ int8_t thread_commissioning_get_management_id(int8_t interface_id)
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
int thread_commissioning_register(int8_t interface_id, uint8_t PSKc[static 16]) {
|
int thread_commissioning_register(int8_t interface_id, uint8_t PSKc[static 16])
|
||||||
|
{
|
||||||
(void)interface_id;
|
(void)interface_id;
|
||||||
(void)PSKc;
|
(void)PSKc;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1002,33 +1184,46 @@ int thread_commissioning_petition_start(int8_t interface_id, char *commissioner_
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_commissioning_native_commissioner_get_connection_info(int8_t interface_id, uint8_t *address_ptr, uint16_t *port) {
|
int thread_commissioning_native_commissioner_get_connection_info(int8_t interface_id, uint8_t *address_ptr, uint16_t *port)
|
||||||
|
{
|
||||||
(void)interface_id;
|
(void)interface_id;
|
||||||
(void)address_ptr;
|
(void)address_ptr;
|
||||||
(void)port;
|
(void)port;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t thread_commissioning_get_management_id(int8_t interface_id) {
|
int8_t thread_commissioning_get_management_id(int8_t interface_id)
|
||||||
|
{
|
||||||
(void)interface_id;
|
(void)interface_id;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_commissioning_native_commissioner_start(int8_t interface_id, thread_commissioning_native_select_cb *cb_ptr) {
|
int thread_commissioning_native_commissioner_start(int8_t interface_id, thread_commissioning_native_select_cb *cb_ptr)
|
||||||
|
{
|
||||||
(void)interface_id;
|
(void)interface_id;
|
||||||
(void)cb_ptr;
|
(void)cb_ptr;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_commissioning_native_commissioner_stop(int8_t interface_id) {
|
int thread_commissioning_native_commissioner_stop(int8_t interface_id)
|
||||||
|
{
|
||||||
(void)interface_id;
|
(void)interface_id;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_commissioning_native_commissioner_connect(int8_t interface_id, thread_commissioning_link_configuration_s *link_ptr) {
|
int thread_commissioning_native_commissioner_connect(int8_t interface_id, thread_commissioning_link_configuration_s *link_ptr)
|
||||||
|
{
|
||||||
(void)interface_id;
|
(void)interface_id;
|
||||||
(void)link_ptr;
|
(void)link_ptr;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int thread_commissioning_attach(int8_t interface_id, uint8_t *destination_address, uint16_t destination_port)
|
||||||
|
{
|
||||||
|
(void)interface_id;
|
||||||
|
(void)destination_address;
|
||||||
|
(void)destination_port;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -44,9 +44,11 @@
|
||||||
#include "6LoWPAN/Bootstraps/protocol_6lowpan_interface.h"
|
#include "6LoWPAN/Bootstraps/protocol_6lowpan_interface.h"
|
||||||
#include "6LoWPAN/Thread/thread_common.h"
|
#include "6LoWPAN/Thread/thread_common.h"
|
||||||
#include "6LoWPAN/Thread/thread_beacon.h"
|
#include "6LoWPAN/Thread/thread_beacon.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_diagnostic.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_extension_bbr.h"
|
||||||
#include "6LoWPAN/Thread/thread_leader_service.h"
|
#include "6LoWPAN/Thread/thread_leader_service.h"
|
||||||
#include "6LoWPAN/Thread/thread_routing.h"
|
#include "6LoWPAN/Thread/thread_routing.h"
|
||||||
#include "6LoWPAN/Thread/thread_dhcpv6_client.h"
|
#include "DHCPv6_client/dhcpv6_client_api.h"
|
||||||
#include "6LoWPAN/Thread/thread_discovery.h"
|
#include "6LoWPAN/Thread/thread_discovery.h"
|
||||||
#include "6LoWPAN/Thread/thread_bootstrap.h"
|
#include "6LoWPAN/Thread/thread_bootstrap.h"
|
||||||
#include "6LoWPAN/Thread/thread_router_bootstrap.h"
|
#include "6LoWPAN/Thread/thread_router_bootstrap.h"
|
||||||
|
@ -60,6 +62,7 @@
|
||||||
#include "6LoWPAN/Thread/thread_management_internal.h"
|
#include "6LoWPAN/Thread/thread_management_internal.h"
|
||||||
#include "6LoWPAN/Thread/thread_management_client.h"
|
#include "6LoWPAN/Thread/thread_management_client.h"
|
||||||
#include "6LoWPAN/Thread/thread_management_server.h"
|
#include "6LoWPAN/Thread/thread_management_server.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_resolution_server.h"
|
||||||
#include "6LoWPAN/Thread/thread_resolution_client.h"
|
#include "6LoWPAN/Thread/thread_resolution_client.h"
|
||||||
#include "6LoWPAN/Thread/thread_address_registration_client.h"
|
#include "6LoWPAN/Thread/thread_address_registration_client.h"
|
||||||
#include "6LoWPAN/Thread/thread_resolution_client.h"
|
#include "6LoWPAN/Thread/thread_resolution_client.h"
|
||||||
|
@ -226,6 +229,7 @@ int8_t thread_bootstrap_up(protocol_interface_info_entry_t *cur)
|
||||||
ret_val = nwk_6lowpan_up(cur);
|
ret_val = nwk_6lowpan_up(cur);
|
||||||
|
|
||||||
cur->nwk_nd_re_scan_count = 0;
|
cur->nwk_nd_re_scan_count = 0;
|
||||||
|
cur->thread_info->link_sync_allowed = true;
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
@ -258,9 +262,11 @@ int8_t thread_bootstrap_down(protocol_interface_info_entry_t *cur)
|
||||||
thread_leader_mleid_rloc_map_to_nvm_write(cur);
|
thread_leader_mleid_rloc_map_to_nvm_write(cur);
|
||||||
thread_bootstrap_stop(cur);
|
thread_bootstrap_stop(cur);
|
||||||
mle_service_interface_unregister(cur->id);
|
mle_service_interface_unregister(cur->id);
|
||||||
|
thread_diagnostic_delete(cur->id); // delete before thread_management_server_delete as they share same coap_service id
|
||||||
|
thread_management_client_delete(cur->id); // delete before thread_management_server_delete as they share same coap_service id
|
||||||
|
thread_nd_service_disable(cur->id); // delete before thread_management_server_delete as they share same coap_service id
|
||||||
thread_management_server_delete(cur->id);
|
thread_management_server_delete(cur->id);
|
||||||
thread_joiner_application_deinit(cur->id);
|
thread_joiner_application_deinit(cur->id);
|
||||||
thread_management_client_delete(cur->id);
|
|
||||||
//free network Data
|
//free network Data
|
||||||
thread_network_data_free_and_clean(&cur->thread_info->networkDataStorage);
|
thread_network_data_free_and_clean(&cur->thread_info->networkDataStorage);
|
||||||
//free local also here
|
//free local also here
|
||||||
|
@ -451,7 +457,7 @@ void thread_data_base_init(thread_info_t *thread_info, int8_t interfaceId)
|
||||||
thread_leader_commissioner_create(thread_info);
|
thread_leader_commissioner_create(thread_info);
|
||||||
thread_info->rfc6775 = false;
|
thread_info->rfc6775 = false;
|
||||||
thread_info->threadPrivatePrefixInfo.ulaValid = false;
|
thread_info->threadPrivatePrefixInfo.ulaValid = false;
|
||||||
thread_info->routerIdReqCoapID = 0;
|
thread_info->routerIdRequested = false;
|
||||||
thread_info->networkDataRequested = false;
|
thread_info->networkDataRequested = false;
|
||||||
thread_info->proactive_an_timer = 0;
|
thread_info->proactive_an_timer = 0;
|
||||||
|
|
||||||
|
@ -905,6 +911,7 @@ static void thread_child_update_req_timer(protocol_interface_info_entry_t *cur,
|
||||||
if (cur->thread_info->childUpdateReqTimer == -1) {
|
if (cur->thread_info->childUpdateReqTimer == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur->thread_info->childUpdateReqTimer > seconds) {
|
if (cur->thread_info->childUpdateReqTimer > seconds) {
|
||||||
cur->thread_info->childUpdateReqTimer -= seconds;
|
cur->thread_info->childUpdateReqTimer -= seconds;
|
||||||
} else {
|
} else {
|
||||||
|
@ -945,6 +952,20 @@ static void thread_key_switch_timer(protocol_interface_info_entry_t *cur, uint16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void thread_maintenance_timer(protocol_interface_info_entry_t *cur, uint32_t seconds)
|
||||||
|
{
|
||||||
|
if (thread_info(cur)->thread_maintenance_timer) {
|
||||||
|
if (thread_info(cur)->thread_maintenance_timer > seconds) {
|
||||||
|
thread_info(cur)->thread_maintenance_timer -= seconds;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
thread_info(cur)->thread_maintenance_timer = THREAD_MAINTENANCE_TIMER_INTERVAL ;
|
||||||
|
|
||||||
|
thread_bootstrap_network_data_activate(cur);
|
||||||
|
}
|
||||||
|
|
||||||
void thread_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t ticks)
|
void thread_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t ticks)
|
||||||
{
|
{
|
||||||
uint8_t leader_address[16];
|
uint8_t leader_address[16];
|
||||||
|
@ -1003,6 +1024,7 @@ void thread_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t ticks)
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_router_bootstrap_timer(cur, ticks);
|
thread_router_bootstrap_timer(cur, ticks);
|
||||||
|
thread_maintenance_timer(cur, ticks);
|
||||||
thread_border_router_seconds_timer(cur->id, ticks);
|
thread_border_router_seconds_timer(cur->id, ticks);
|
||||||
thread_bbr_seconds_timer(cur->id, ticks);
|
thread_bbr_seconds_timer(cur->id, ticks);
|
||||||
thread_lowpower_timer(cur, ticks);
|
thread_lowpower_timer(cur, ticks);
|
||||||
|
@ -1201,7 +1223,8 @@ uint8_t *thread_route_option_write(protocol_interface_info_entry_t *cur, uint8_t
|
||||||
ptr, /* ptr to ID sequence (1 byte) */
|
ptr, /* ptr to ID sequence (1 byte) */
|
||||||
ptr + 1, /* ptr to ID mask (MLE_ROUTE_ID_MASK_SIZE bytes) */
|
ptr + 1, /* ptr to ID mask (MLE_ROUTE_ID_MASK_SIZE bytes) */
|
||||||
ptr + MLE_ROUTE_MIN_OPTION_LEN, /* ptr to router table data */
|
ptr + MLE_ROUTE_MIN_OPTION_LEN, /* ptr to router table data */
|
||||||
len_ptr) != 0) /* ptr to length */ { /* 0 -> SUCCESS */
|
len_ptr) != 0) { /* ptr to length */
|
||||||
|
/* 0 -> SUCCESS */
|
||||||
/* Point to beginning of buffer again */
|
/* Point to beginning of buffer again */
|
||||||
ptr = saved_ptr;
|
ptr = saved_ptr;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1720,9 +1743,104 @@ uint8_t *thread_leader_data_tlv_write(uint8_t *ptr, protocol_interface_info_entr
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool thread_addresses_needs_to_be_registered(protocol_interface_info_entry_t *cur)
|
||||||
|
{
|
||||||
|
lowpan_context_t *ctx;
|
||||||
|
uint8_t thread_realm_local_mcast_addr[16];
|
||||||
|
uint8_t thread_ll_unicast_prefix_based_mcast_addr[16];
|
||||||
|
if (thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_SLEEPY_END_DEVICE &&
|
||||||
|
thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_END_DEVICE) {
|
||||||
|
// No address registration for others than MED or SED
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for addresses
|
||||||
|
ns_list_foreach(if_address_entry_t, e, &cur->ip_addresses) {
|
||||||
|
if (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_GLOBAL || (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_REALM_LOCAL
|
||||||
|
&& !thread_addr_is_mesh_local_16(e->address, cur))) {
|
||||||
|
ctx = lowpan_context_get_by_address(&cur->lowpan_contexts, e->address);
|
||||||
|
if (!ctx) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (ctx->cid != 0) {
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for multicast groups
|
||||||
|
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
|
||||||
|
thread_bootstrap_all_nodes_address_generate(thread_ll_unicast_prefix_based_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
|
||||||
|
ns_list_foreach(if_group_entry_t, entry, &cur->ip_groups) {
|
||||||
|
if (!memcmp((entry->group), ADDR_MULTICAST_SOLICITED, 13)) {
|
||||||
|
/* Skip solicited node multicast address */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (addr_ipv6_equal(entry->group, thread_realm_local_mcast_addr)) {
|
||||||
|
/* Skip well-known realm-local all Thread nodes multicast address */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (addr_ipv6_equal(entry->group, thread_ll_unicast_prefix_based_mcast_addr)) {
|
||||||
|
/* Skip well-known link-local all Thread nodes multicast address */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (addr_ipv6_equal(entry->group, ADDR_ALL_MPL_FORWARDERS)) {
|
||||||
|
/* Skip All MPL Forwarders address */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (addr_ipv6_equal(entry->group, ADDR_REALM_LOCAL_ALL_NODES)) {
|
||||||
|
/* Skip Mesh local all nodes */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (addr_ipv6_equal(entry->group, ADDR_REALM_LOCAL_ALL_ROUTERS)) {
|
||||||
|
/* Skip Mesh local all routers */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *thread_ml_address_tlv_write(uint8_t *ptr, protocol_interface_info_entry_t *cur)
|
||||||
|
{
|
||||||
|
lowpan_context_t *ctx;
|
||||||
|
uint8_t *address_len_ptr;
|
||||||
|
|
||||||
|
if (thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_SLEEPY_END_DEVICE &&
|
||||||
|
thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_END_DEVICE) {
|
||||||
|
// No address registration for others than MED or SED
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
*ptr++ = MLE_TYPE_ADDRESS_REGISTRATION;
|
||||||
|
address_len_ptr = ptr++;
|
||||||
|
|
||||||
|
*address_len_ptr = 0;
|
||||||
|
|
||||||
|
ns_list_foreach(if_address_entry_t, e, &cur->ip_addresses) {
|
||||||
|
|
||||||
|
if (*address_len_ptr > 148) {
|
||||||
|
// Maximum length of address registrations
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!thread_addr_is_mesh_local_16(e->address, cur)) {
|
||||||
|
ctx = lowpan_context_get_by_address(&cur->lowpan_contexts, e->address);
|
||||||
|
if (ctx && ctx->cid == 0) {
|
||||||
|
//Write TLV to list
|
||||||
|
*ptr++ = (ctx->cid | 0x80);
|
||||||
|
memcpy(ptr, e->address + 8, 8);
|
||||||
|
ptr += 8;
|
||||||
|
*address_len_ptr += 9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_info_entry_t *cur)
|
uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_info_entry_t *cur)
|
||||||
{
|
{
|
||||||
uint8_t thread_realm_local_mcast_addr[16];
|
uint8_t thread_realm_local_mcast_addr[16];
|
||||||
|
uint8_t thread_ll_unicast_prefix_based_mcast_addr[16];
|
||||||
lowpan_context_t *ctx;
|
lowpan_context_t *ctx;
|
||||||
uint8_t *address_len_ptr;
|
uint8_t *address_len_ptr;
|
||||||
|
|
||||||
|
@ -1738,7 +1856,6 @@ uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_
|
||||||
|
|
||||||
// Register all global addressess
|
// Register all global addressess
|
||||||
ns_list_foreach(if_address_entry_t, e, &cur->ip_addresses) {
|
ns_list_foreach(if_address_entry_t, e, &cur->ip_addresses) {
|
||||||
|
|
||||||
if (*address_len_ptr > 148) {
|
if (*address_len_ptr > 148) {
|
||||||
// Maximum length of address registrations
|
// Maximum length of address registrations
|
||||||
continue;
|
continue;
|
||||||
|
@ -1762,23 +1879,26 @@ uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Registers multicast addresses to the parent */
|
/* Registers multicast addresses to the parent */
|
||||||
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 3);
|
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
|
||||||
|
thread_bootstrap_all_nodes_address_generate(thread_ll_unicast_prefix_based_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
|
||||||
ns_list_foreach(if_group_entry_t, entry, &cur->ip_groups)
|
ns_list_foreach(if_group_entry_t, entry, &cur->ip_groups) {
|
||||||
{
|
|
||||||
if (*address_len_ptr > 148) {
|
if (*address_len_ptr > 148) {
|
||||||
// Maximum length of address registrations
|
// Maximum length of address registrations
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (addr_ipv6_multicast_scope(entry->group) < IPV6_SCOPE_REALM_LOCAL) {
|
|
||||||
/* Skip Link Local multicast address */
|
if (!memcmp((entry->group), ADDR_MULTICAST_SOLICITED, 13)) {
|
||||||
|
/* Skip solicited node multicast address */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr_ipv6_equal(entry->group, thread_realm_local_mcast_addr)) {
|
if (addr_ipv6_equal(entry->group, thread_realm_local_mcast_addr)) {
|
||||||
/* Skip well-known realm-local all Thread nodes multicast address */
|
/* Skip well-known realm-local all Thread nodes multicast address */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (addr_ipv6_equal(entry->group, thread_ll_unicast_prefix_based_mcast_addr)) {
|
||||||
|
/* Skip well-known link-local all Thread nodes multicast address */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (addr_ipv6_equal(entry->group, ADDR_ALL_MPL_FORWARDERS)) {
|
if (addr_ipv6_equal(entry->group, ADDR_ALL_MPL_FORWARDERS)) {
|
||||||
/* Skip All MPL Forwarders address */
|
/* Skip All MPL Forwarders address */
|
||||||
continue;
|
continue;
|
||||||
|
@ -1899,14 +2019,17 @@ void thread_reset_neighbour_info(protocol_interface_info_entry_t *cur, mac_neigh
|
||||||
|
|
||||||
uint8_t thread_get_router_count_from_route_tlv(mle_tlv_info_t *routeTlv)
|
uint8_t thread_get_router_count_from_route_tlv(mle_tlv_info_t *routeTlv)
|
||||||
{
|
{
|
||||||
if (!routeTlv)
|
if (!routeTlv) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (routeTlv->tlvLen < (MLE_ROUTE_ID_MASK_SIZE + 1))
|
if (routeTlv->tlvLen < (MLE_ROUTE_ID_MASK_SIZE + 1)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!routeTlv->dataPtr)
|
if (!routeTlv->dataPtr) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return routeTlv->tlvLen - MLE_ROUTE_ID_MASK_SIZE - 1;
|
return routeTlv->tlvLen - MLE_ROUTE_ID_MASK_SIZE - 1;
|
||||||
}
|
}
|
||||||
|
@ -1935,9 +2058,35 @@ static void thread_address_notification_cb(struct protocol_interface_info_entry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool thread_mcast_should_register_address(struct protocol_interface_info_entry *cur, uint8_t *addr)
|
||||||
|
{
|
||||||
|
uint8_t thread_realm_local_mcast_addr[16];
|
||||||
|
uint8_t thread_ll_unicast_prefix_based_mcast_addr[16];
|
||||||
|
if (addr_ipv6_multicast_scope(addr) < IPV6_SCOPE_LINK_LOCAL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (memcmp(addr, ADDR_MULTICAST_SOLICITED, 13) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (memcmp(addr, ADDR_LINK_LOCAL_ALL_NODES, 16) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (memcmp(addr, ADDR_LINK_LOCAL_ALL_ROUTERS, 16) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
|
||||||
|
if (memcmp(addr, thread_realm_local_mcast_addr, 16) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
thread_bootstrap_all_nodes_address_generate(thread_ll_unicast_prefix_based_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
|
||||||
|
if (memcmp(addr, thread_ll_unicast_prefix_based_mcast_addr, 16) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void thread_mcast_group_change(struct protocol_interface_info_entry *interface, if_group_entry_t *group, bool addr_added)
|
void thread_mcast_group_change(struct protocol_interface_info_entry *interface, if_group_entry_t *group, bool addr_added)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (thread_attach_ready(interface) != 0) {
|
if (thread_attach_ready(interface) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1946,7 +2095,7 @@ void thread_mcast_group_change(struct protocol_interface_info_entry *interface,
|
||||||
|
|
||||||
if (thread_bootstrap_should_register_address(interface)) {
|
if (thread_bootstrap_should_register_address(interface)) {
|
||||||
/* Trigger Child Update Request only if MTD child's multicast address change */
|
/* Trigger Child Update Request only if MTD child's multicast address change */
|
||||||
if (addr_ipv6_multicast_scope(group->group) > IPV6_SCOPE_LINK_LOCAL) {
|
if (thread_mcast_should_register_address(interface, group->group)) {
|
||||||
interface->thread_info->childUpdateReqTimer = 1;
|
interface->thread_info->childUpdateReqTimer = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1956,10 +2105,16 @@ void thread_mcast_group_change(struct protocol_interface_info_entry *interface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void thread_old_partition_data_clean(int8_t interface_id)
|
||||||
|
{
|
||||||
|
thread_management_client_old_partition_data_clean(interface_id);
|
||||||
|
thread_border_router_old_partition_data_clean(interface_id);
|
||||||
|
}
|
||||||
|
|
||||||
void thread_partition_data_purge(protocol_interface_info_entry_t *cur)
|
void thread_partition_data_purge(protocol_interface_info_entry_t *cur)
|
||||||
{
|
{
|
||||||
/* Partition has been changed. Wipe out data related to old partition */
|
/* Partition has been changed. Wipe out data related to old partition */
|
||||||
thread_management_client_pending_coap_request_kill(cur->id);
|
thread_old_partition_data_clean(cur->id);
|
||||||
|
|
||||||
/* Reset previous routing information */
|
/* Reset previous routing information */
|
||||||
thread_routing_reset(&cur->thread_info->routing);
|
thread_routing_reset(&cur->thread_info->routing);
|
||||||
|
@ -1967,6 +2122,9 @@ void thread_partition_data_purge(protocol_interface_info_entry_t *cur)
|
||||||
/* Flush address cache */
|
/* Flush address cache */
|
||||||
ipv6_neighbour_cache_flush(&cur->ipv6_neighbour_cache);
|
ipv6_neighbour_cache_flush(&cur->ipv6_neighbour_cache);
|
||||||
|
|
||||||
|
/* Remove linked neighbours for REEDs and FEDs */
|
||||||
|
thread_reed_fed_neighbour_links_clean(cur);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool thread_partition_match(protocol_interface_info_entry_t *cur, thread_leader_data_t *leaderData)
|
bool thread_partition_match(protocol_interface_info_entry_t *cur, thread_leader_data_t *leaderData)
|
||||||
|
@ -1997,5 +2155,10 @@ void thread_neighbor_communication_update(protocol_interface_info_entry_t *cur,
|
||||||
thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, neighbor_attribute_index);
|
thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, neighbor_attribute_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void thread_maintenance_timer_set(protocol_interface_info_entry_t *cur, uint16_t delay)
|
||||||
|
{
|
||||||
|
thread_info(cur)->thread_maintenance_timer = delay;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -309,10 +309,10 @@ typedef struct thread_info_s {
|
||||||
uint16_t routerShortAddress;
|
uint16_t routerShortAddress;
|
||||||
uint16_t reedJitterTimer;
|
uint16_t reedJitterTimer;
|
||||||
uint16_t reedMergeAdvTimer;
|
uint16_t reedMergeAdvTimer;
|
||||||
uint16_t routerIdReqCoapID; // COAP msg id of RouterID request
|
|
||||||
int16_t childUpdateReqTimer;
|
int16_t childUpdateReqTimer;
|
||||||
uint16_t childUpdateReqMsgId;
|
uint16_t childUpdateReqMsgId;
|
||||||
uint16_t proactive_an_timer;
|
uint16_t proactive_an_timer;
|
||||||
|
uint16_t thread_maintenance_timer;
|
||||||
//uint8_t lastValidRouteMask[8];
|
//uint8_t lastValidRouteMask[8];
|
||||||
int8_t interface_id; //Thread Interface ID
|
int8_t interface_id; //Thread Interface ID
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
|
@ -322,11 +322,13 @@ typedef struct thread_info_s {
|
||||||
bool rfc6775: 1;
|
bool rfc6775: 1;
|
||||||
bool requestFullNetworkData: 1;
|
bool requestFullNetworkData: 1;
|
||||||
bool leaderCab: 1;
|
bool leaderCab: 1;
|
||||||
|
bool routerIdRequested: 1;
|
||||||
bool releaseRouterId: 1;
|
bool releaseRouterId: 1;
|
||||||
bool networkSynch: 1;
|
bool networkSynch: 1;
|
||||||
bool networkDataRequested: 1;
|
bool networkDataRequested: 1;
|
||||||
bool end_device_link_synch: 1;
|
bool end_device_link_synch: 1;
|
||||||
bool router_mc_addrs_registered: 1;
|
bool router_mc_addrs_registered: 1;
|
||||||
|
bool link_sync_allowed: 1;
|
||||||
bool leader_synced: 1; // flag used by leader after restart
|
bool leader_synced: 1; // flag used by leader after restart
|
||||||
} thread_info_t;
|
} thread_info_t;
|
||||||
|
|
||||||
|
@ -397,6 +399,11 @@ void thread_child_mcast_entries_remove(protocol_interface_info_entry_t *cur, con
|
||||||
uint8_t thread_leader_data_tlv_size(protocol_interface_info_entry_t *cur);
|
uint8_t thread_leader_data_tlv_size(protocol_interface_info_entry_t *cur);
|
||||||
uint8_t *thread_leader_data_tlv_write(uint8_t *ptr, protocol_interface_info_entry_t *cur);
|
uint8_t *thread_leader_data_tlv_write(uint8_t *ptr, protocol_interface_info_entry_t *cur);
|
||||||
uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_info_entry_t *cur);
|
uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_info_entry_t *cur);
|
||||||
|
|
||||||
|
// returns true if SED/MED needs to register additional address to parent
|
||||||
|
bool thread_addresses_needs_to_be_registered(protocol_interface_info_entry_t *cur);
|
||||||
|
// write mesh local address tlv
|
||||||
|
uint8_t *thread_ml_address_tlv_write(uint8_t *ptr, protocol_interface_info_entry_t *cur);
|
||||||
int thread_link_reject_send(protocol_interface_info_entry_t *interface, const uint8_t *ll64);
|
int thread_link_reject_send(protocol_interface_info_entry_t *interface, const uint8_t *ll64);
|
||||||
thread_leader_info_t *thread_allocate_and_init_leader_private_data(void);
|
thread_leader_info_t *thread_allocate_and_init_leader_private_data(void);
|
||||||
thread_route_cost_t thread_link_quality_to_cost(thread_link_quality_e quality);
|
thread_route_cost_t thread_link_quality_to_cost(thread_link_quality_e quality);
|
||||||
|
@ -441,6 +448,7 @@ bool thread_partition_match(protocol_interface_info_entry_t *cur, thread_leader_
|
||||||
void thread_partition_info_update(protocol_interface_info_entry_t *cur, thread_leader_data_t *leaderData);
|
void thread_partition_info_update(protocol_interface_info_entry_t *cur, thread_leader_data_t *leaderData);
|
||||||
void thread_neighbor_communication_update(protocol_interface_info_entry_t *cur, uint8_t neighbor_attribute_index);
|
void thread_neighbor_communication_update(protocol_interface_info_entry_t *cur, uint8_t neighbor_attribute_index);
|
||||||
bool thread_stable_context_check(protocol_interface_info_entry_t *cur, buffer_t *buf);
|
bool thread_stable_context_check(protocol_interface_info_entry_t *cur, buffer_t *buf);
|
||||||
|
void thread_maintenance_timer_set(protocol_interface_info_entry_t *cur, uint16_t delay);
|
||||||
#else // HAVE_THREAD
|
#else // HAVE_THREAD
|
||||||
|
|
||||||
NS_DUMMY_DEFINITIONS_OK
|
NS_DUMMY_DEFINITIONS_OK
|
||||||
|
|
|
@ -326,6 +326,17 @@
|
||||||
*/
|
*/
|
||||||
#define THREAD_BBR_ROUTER_ID_REQUEST_STATUS THREAD_COAP_STATUS_TLV_HAVE_CHILD_ID_REQUEST
|
#define THREAD_BBR_ROUTER_ID_REQUEST_STATUS THREAD_COAP_STATUS_TLV_HAVE_CHILD_ID_REQUEST
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Number of destination and neighbor cache entries assuming 250 thread devices (worst case) connecting to cloud service.
|
||||||
|
* Six entries reserved for backbone devices.
|
||||||
|
*/
|
||||||
|
#define THREAD_BBR_IPV6_DESTINATION_CACHE_SIZE 256
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Timeout to solicit address from DHCP if previous request fails.
|
||||||
|
*/
|
||||||
|
#define THREAD_MAINTENANCE_TIMER_INTERVAL 300
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build time flag to enable THCI special traces for test harness purposes
|
* Build time flag to enable THCI special traces for test harness purposes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -145,6 +145,7 @@
|
||||||
#define THREAD_DEFAULT_KEY_SWITCH_GUARD_TIME 624 // Hours
|
#define THREAD_DEFAULT_KEY_SWITCH_GUARD_TIME 624 // Hours
|
||||||
#define THREAD_DEFAULT_KEY_ROTATION 672 // Hours
|
#define THREAD_DEFAULT_KEY_ROTATION 672 // Hours
|
||||||
#define THREAD_COMMISSIONER_KEEP_ALIVE_INTERVAL 50000 // Default thread commissioner keep-alive message interval (milliseconds)
|
#define THREAD_COMMISSIONER_KEEP_ALIVE_INTERVAL 50000 // Default thread commissioner keep-alive message interval (milliseconds)
|
||||||
|
#define THREAD_DELAY_JOIN_ENT 50 // Minimum delay for Joiner router before sending joiner entrust (milliseconds)
|
||||||
|
|
||||||
#define THREAD_FAILED_CHILD_TRANSMISSIONS 4
|
#define THREAD_FAILED_CHILD_TRANSMISSIONS 4
|
||||||
#define THREAD_FAILED_ROUTER_TRANSMISSIONS 4
|
#define THREAD_FAILED_ROUTER_TRANSMISSIONS 4
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2014-2015, 2017, Arm Limited and affiliates.
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the copyright holder nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef SOURCE_6LOWPAN_THREAD_THREAD_DHCPV6_CLIENT_H_
|
|
||||||
#define SOURCE_6LOWPAN_THREAD_THREAD_DHCPV6_CLIENT_H_
|
|
||||||
|
|
||||||
#include <ns_types.h>
|
|
||||||
|
|
||||||
/* Thread DHCP client implementation.
|
|
||||||
*
|
|
||||||
* Responsibilities of this module are:
|
|
||||||
* - send router id address request and receive new router address and inform it to thread bootstrap.
|
|
||||||
* - handle Global address queries and refresh inside thread network.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Initialize dhcp thread dhcp client.
|
|
||||||
*
|
|
||||||
* This instance needs to bee initialized once for each thread network interface.
|
|
||||||
* if only one thread instance is supported this is needed to call only once.
|
|
||||||
*
|
|
||||||
* /param interface interface id of this thread instance.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
void thread_dhcp_client_init(int8_t interface);
|
|
||||||
|
|
||||||
/* Delete dhcp thread dhcp client.
|
|
||||||
*
|
|
||||||
* When this is called all addressed assigned by this module are removed from stack.
|
|
||||||
*/
|
|
||||||
void thread_dhcp_client_delete(int8_t interface);
|
|
||||||
|
|
||||||
/* Global address handler.
|
|
||||||
*
|
|
||||||
* This module updates the addresses from dhcp server and sets them in stack.
|
|
||||||
* this module makes refresh of address when needed.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* give dhcp server and prefix for global address assignment
|
|
||||||
*
|
|
||||||
* /param interface interface where address is got
|
|
||||||
* /param dhcp_addr dhcp server ML16 address where address is registered.
|
|
||||||
* /param prefix dhcp server ML16 address where address is registered.
|
|
||||||
* /param mac64 64 bit mac address for identifieng client.
|
|
||||||
* /param error_cb error callback that is called if address cannot be created or becomes invalid.
|
|
||||||
* /param register_status true if address registered.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
typedef void (thread_dhcp_client_global_adress_cb)(int8_t interface, uint8_t dhcp_addr[static 16], uint8_t prefix[static 16], bool register_status);
|
|
||||||
|
|
||||||
int thread_dhcp_client_get_global_address(int8_t interface, uint8_t dhcp_addr[static 16], uint8_t prefix[static 16], uint8_t mac64[static 8], thread_dhcp_client_global_adress_cb *error_cb);
|
|
||||||
|
|
||||||
/* Renew all leased adddresses might be used when short address changes
|
|
||||||
*
|
|
||||||
* /param interface interface where address is got
|
|
||||||
*/
|
|
||||||
void thread_dhcp_client_global_address_renew(int8_t interface);
|
|
||||||
|
|
||||||
/* Delete address from device
|
|
||||||
* if prefix is NULL all are deleted
|
|
||||||
*
|
|
||||||
* /param interface interface where address is got
|
|
||||||
* /param prefix dhcp server ML16 address where address is registered.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void thread_dhcp_client_global_address_delete(int8_t interface, uint8_t dhcp_addr[static 16], uint8_t prefix[static 16]);
|
|
||||||
|
|
||||||
#endif /* SOURCE_6LOWPAN_THREAD_THREAD_DHCPV6_CLIENT_H_ */
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the copyright holder nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "nsconfig.h"
|
||||||
|
#if defined(HAVE_THREAD) && defined(HAVE_DHCPV6_SERVER)
|
||||||
|
#include <string.h>
|
||||||
|
#include <ns_types.h>
|
||||||
|
#include "eventOS_event.h"
|
||||||
|
#include "eventOS_event_timer.h"
|
||||||
|
#include "common_functions.h"
|
||||||
|
#include "ns_trace.h"
|
||||||
|
#include "NWK_INTERFACE/Include/protocol.h"
|
||||||
|
#include "ipv6_stack/protocol_ipv6.h"
|
||||||
|
#include "Common_Protocols/ipv6_constants.h"
|
||||||
|
#include "Common_Protocols/ipv6.h"
|
||||||
|
#include "DHCPv6_Server/DHCPv6_server_service.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_bbr_api_internal.h"
|
||||||
|
|
||||||
|
#define TRACE_GROUP "thds"
|
||||||
|
|
||||||
|
static void thread_service_remove_GUA_from_neighcache(protocol_interface_info_entry_t *cur, uint8_t *targetAddress)
|
||||||
|
{
|
||||||
|
ipv6_neighbour_t *neighbour_entry;
|
||||||
|
|
||||||
|
neighbour_entry = ipv6_neighbour_lookup(&cur->ipv6_neighbour_cache, targetAddress);
|
||||||
|
if (neighbour_entry) {
|
||||||
|
tr_debug("Remove from neigh Cache: %s", tr_ipv6(targetAddress));
|
||||||
|
ipv6_neighbour_entry_remove(&cur->ipv6_neighbour_cache, neighbour_entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void thread_dhcp_address_prefer_remove_cb(int8_t interfaceId, uint8_t *targetAddress, void *prefix_info)
|
||||||
|
{
|
||||||
|
protocol_interface_info_entry_t *curPtr = protocol_stack_interface_info_get_by_id(interfaceId);
|
||||||
|
if (!curPtr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!targetAddress) {
|
||||||
|
//Clear All targets routes
|
||||||
|
ipv6_route_table_remove_info(interfaceId, ROUTE_THREAD_PROXIED_HOST, prefix_info);
|
||||||
|
} else {
|
||||||
|
tr_debug("Address Preferred Timeout");
|
||||||
|
ipv6_route_delete(targetAddress, 128, interfaceId, NULL, ROUTE_THREAD_PROXIED_HOST);
|
||||||
|
thread_service_remove_GUA_from_neighcache(curPtr, targetAddress);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool thread_dhcp_address_add_cb(int8_t interfaceId, dhcp_address_cache_update_t *address_info, void *route_src)
|
||||||
|
{
|
||||||
|
protocol_interface_info_entry_t *curPtr = protocol_stack_interface_info_get_by_id(interfaceId);
|
||||||
|
if (!curPtr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is solicit from existing address, flush ND cache.
|
||||||
|
if (address_info->allocatedNewAddress) {
|
||||||
|
// coverity[returned_null] for ignoring protocol_stack_interface_info_get_by_id NULL return
|
||||||
|
thread_service_remove_GUA_from_neighcache(curPtr, address_info->allocatedAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thread_bbr_nd_entry_add(interfaceId, address_info->allocatedAddress, address_info->validLifeTime, route_src) == -1) {
|
||||||
|
// No nanostack BBR present we will put entry for application implemented BBR
|
||||||
|
ipv6_route_t *route = ipv6_route_add_with_info(address_info->allocatedAddress, 128, interfaceId, NULL, ROUTE_THREAD_PROXIED_HOST, route_src, 0, address_info->validLifeTime, 0);
|
||||||
|
if (!route) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int thread_dhcp6_server_init(int8_t interface_id, uint8_t prefix[8], uint8_t eui64[8], uint32_t validLifeTimne)
|
||||||
|
{
|
||||||
|
if (DHCPv6_server_service_init(interface_id, prefix, eui64, DHCPV6_DUID_HARDWARE_EUI64_TYPE) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
//Register Callbacks
|
||||||
|
DHCPv6_server_service_callback_set(interface_id, prefix, thread_dhcp_address_prefer_remove_cb, thread_dhcp_address_add_cb);
|
||||||
|
//SET Timeout
|
||||||
|
DHCPv6_server_service_set_address_validlifetime(interface_id, prefix, validLifeTimne);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the copyright holder nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef THREAD_DHCPV6_SERVER_H_
|
||||||
|
#define THREAD_DHCPV6_SERVER_H_
|
||||||
|
#if defined(HAVE_THREAD) && defined(HAVE_DHCPV6_SERVER)
|
||||||
|
int thread_dhcp6_server_init(int8_t interface_id, uint8_t prefix[8], uint8_t eui64[8], uint32_t validLifeTimne);
|
||||||
|
#else
|
||||||
|
#define thread_dhcp6_server_init(interface_id, prefix, eui64, validLifeTimne) (-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* THREAD_DHCPV6_SERVER_H_ */
|
|
@ -35,6 +35,7 @@
|
||||||
#include "nsdynmemLIB.h"
|
#include "nsdynmemLIB.h"
|
||||||
#include "net_interface.h"
|
#include "net_interface.h"
|
||||||
#include "thread_management_if.h"
|
#include "thread_management_if.h"
|
||||||
|
#include "thread_management_server.h"
|
||||||
#include "thread_common.h"
|
#include "thread_common.h"
|
||||||
#include "thread_joiner_application.h"
|
#include "thread_joiner_application.h"
|
||||||
#include "thread_leader_service.h"
|
#include "thread_leader_service.h"
|
||||||
|
@ -229,6 +230,10 @@ static int thread_diagnostic_configuration_calc(protocol_interface_info_entry_t
|
||||||
payload_len += 2 + 1;
|
payload_len += 2 + 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DIAGCOP_TLV_MAX_CHILD_TIMEOUT:
|
||||||
|
payload_len += 2 + 4;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// todo: Other TLV's not supported atm
|
// todo: Other TLV's not supported atm
|
||||||
break;
|
break;
|
||||||
|
@ -254,6 +259,7 @@ static uint8_t *thread_diagnostic_get_build(protocol_interface_info_entry_t *cur
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
int written_address_count = 0;
|
int written_address_count = 0;
|
||||||
uint16_t ipv6_address_count = 0;
|
uint16_t ipv6_address_count = 0;
|
||||||
|
uint32_t max_child_timeout = 0;
|
||||||
uint8_t extended_address[8] = {0};
|
uint8_t extended_address[8] = {0};
|
||||||
|
|
||||||
arm_net_interface_address_list_size(cur->id, &ipv6_address_count);
|
arm_net_interface_address_list_size(cur->id, &ipv6_address_count);
|
||||||
|
@ -352,6 +358,12 @@ static uint8_t *thread_diagnostic_get_build(protocol_interface_info_entry_t *cur
|
||||||
response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_CHANNEL_PAGES, 0);
|
response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_CHANNEL_PAGES, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DIAGCOP_TLV_MAX_CHILD_TIMEOUT:
|
||||||
|
if (thread_router_bootstrap_child_max_timeout_get(cur, &max_child_timeout) == 0) {
|
||||||
|
response_ptr = thread_diagcop_tlv_data_write_uint32(response_ptr, DIAGCOP_TLV_MAX_CHILD_TIMEOUT, max_child_timeout);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -532,7 +544,7 @@ int thread_diagnostic_init(int8_t interface_id)
|
||||||
|
|
||||||
this->interface_id = interface_id;
|
this->interface_id = interface_id;
|
||||||
|
|
||||||
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_NONE, NULL, NULL);
|
this->coap_service_id = thread_management_server_service_id_get(interface_id);
|
||||||
if (this->coap_service_id < 0) {
|
if (this->coap_service_id < 0) {
|
||||||
tr_error("Thread diagnostic init failed");
|
tr_error("Thread diagnostic init failed");
|
||||||
ns_dyn_mem_free(this);
|
ns_dyn_mem_free(this);
|
||||||
|
@ -556,8 +568,9 @@ int thread_diagnostic_delete(int8_t interface_id)
|
||||||
if (!this) {
|
if (!this) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_DIAGNOSTIC_REQUEST);
|
||||||
coap_service_delete(this->coap_service_id);
|
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_DIAGNOSTIC_RESET);
|
||||||
|
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_DIAGNOSTIC_QUERY);
|
||||||
ns_list_remove(&instance_list, this);
|
ns_list_remove(&instance_list, this);
|
||||||
ns_dyn_mem_free(this);
|
ns_dyn_mem_free(this);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -339,16 +339,15 @@ static void thread_announce_discovery_prepare(protocol_interface_info_entry_t *i
|
||||||
thread_discover_timer_trig();
|
thread_discover_timer_trig();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool thread_discovery_proces_ready(thread_discovery_request_info_t *discovery) {
|
static bool thread_discovery_proces_ready(thread_discovery_request_info_t *discovery)
|
||||||
|
{
|
||||||
|
|
||||||
//Get next free channel
|
//Get next free channel
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint32_t mask = 1;
|
uint32_t mask = 1;
|
||||||
|
|
||||||
for (i=0; i<32; i++)
|
for (i = 0; i < 32; i++) {
|
||||||
{
|
if (discovery->channel_mask & mask) {
|
||||||
if (discovery->channel_mask & mask)
|
|
||||||
{
|
|
||||||
discovery->channel_mask &= ~mask;
|
discovery->channel_mask &= ~mask;
|
||||||
discovery->active_channel = i;
|
discovery->active_channel = i;
|
||||||
discovery->channel_page = 0; //Support only chnnel page 0
|
discovery->channel_page = 0; //Support only chnnel page 0
|
||||||
|
@ -359,16 +358,15 @@ static bool thread_discovery_proces_ready(thread_discovery_request_info_t *disco
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool thread_announce_discovery_process_ready(thread_announce_request_info_t *discovery) {
|
static bool thread_announce_discovery_process_ready(thread_announce_request_info_t *discovery)
|
||||||
|
{
|
||||||
|
|
||||||
//Get next free channel
|
//Get next free channel
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint32_t mask = 0x80000000;
|
uint32_t mask = 0x80000000;
|
||||||
|
|
||||||
for (i=0; i<32; i++)
|
for (i = 0; i < 32; i++) {
|
||||||
{
|
if (discovery->channel_mask & mask) {
|
||||||
if (discovery->channel_mask & mask)
|
|
||||||
{
|
|
||||||
discovery->channel_mask &= ~mask;
|
discovery->channel_mask &= ~mask;
|
||||||
discovery->active_channel = i;
|
discovery->active_channel = i;
|
||||||
return false;
|
return false;
|
||||||
|
@ -876,7 +874,8 @@ static bool thread_seering_data_accept_any(uint8_t length, uint8_t *data)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void thread_discovery_nwk_push_to_list_by_lqi(thread_nwk_discovery_response_list_t *result_list, discovery_response_list_t *nwk_info) {
|
static void thread_discovery_nwk_push_to_list_by_lqi(thread_nwk_discovery_response_list_t *result_list, discovery_response_list_t *nwk_info)
|
||||||
|
{
|
||||||
if (ns_list_count(result_list)) {
|
if (ns_list_count(result_list)) {
|
||||||
ns_list_foreach_safe(discovery_response_list_t, cur_entry, result_list) {
|
ns_list_foreach_safe(discovery_response_list_t, cur_entry, result_list) {
|
||||||
if (nwk_info->dbm > cur_entry->dbm) {
|
if (nwk_info->dbm > cur_entry->dbm) {
|
||||||
|
@ -891,7 +890,8 @@ static void thread_discovery_nwk_push_to_list_by_lqi(thread_nwk_discovery_respon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void thread_discovery_joiner_set(thread_nwk_discovery_response_list_t *result_list, discovery_response_list_t *nwk_info, bool new_accept_any) {
|
static void thread_discovery_joiner_set(thread_nwk_discovery_response_list_t *result_list, discovery_response_list_t *nwk_info, bool new_accept_any)
|
||||||
|
{
|
||||||
if (ns_list_count(result_list)) {
|
if (ns_list_count(result_list)) {
|
||||||
|
|
||||||
bool cur_acept_any;
|
bool cur_acept_any;
|
||||||
|
|
|
@ -46,19 +46,15 @@ void thread_extension_allocate(protocol_interface_info_entry_t *cur);
|
||||||
void thread_extension_free(protocol_interface_info_entry_t *cur);
|
void thread_extension_free(protocol_interface_info_entry_t *cur);
|
||||||
void thread_extension_init(int8_t interface_id, int8_t coap_service_id);
|
void thread_extension_init(int8_t interface_id, int8_t coap_service_id);
|
||||||
void thread_extension_mtd_service_register(protocol_interface_info_entry_t *cur);
|
void thread_extension_mtd_service_register(protocol_interface_info_entry_t *cur);
|
||||||
int thread_extension_network_prefix_get(int8_t interface_id, uint8_t *options_ptr, uint8_t *prefix_ptr, uint8_t *prefix_len);
|
|
||||||
void thread_extension_network_data_process(struct protocol_interface_info_entry *cur);
|
void thread_extension_network_data_process(struct protocol_interface_info_entry *cur);
|
||||||
int thread_extension_primary_bbr_get(struct protocol_interface_info_entry *cur, uint8_t *addr_ptr, uint8_t *seq_ptr, uint32_t *timer1_ptr, uint32_t *timer2_ptr);
|
int thread_extension_primary_bbr_get(struct protocol_interface_info_entry *cur, uint8_t *addr_ptr, uint8_t *seq_ptr, uint32_t *timer1_ptr, uint32_t *timer2_ptr);
|
||||||
void thread_extension_address_registration(struct protocol_interface_info_entry *interface, const uint8_t *addr, const uint8_t *child_mac64, bool refresh_child_entry, bool duplicate_child_detected);
|
void thread_extension_address_registration(struct protocol_interface_info_entry *interface, const uint8_t *addr, const uint8_t *child_mac64, bool refresh_child_entry, bool duplicate_child_detected);
|
||||||
void thread_extension_address_generate(protocol_interface_info_entry_t *cur);
|
void thread_extension_dua_address_generate(protocol_interface_info_entry_t *cur, const uint8_t *domain_prefix, uint8_t domain_prefix_len);
|
||||||
void thread_extension_aloc_generate(struct protocol_interface_info_entry *cur);
|
void thread_extension_aloc_generate(struct protocol_interface_info_entry *cur);
|
||||||
bool thread_extension_aloc_map(protocol_interface_info_entry_t *cur, uint16_t *addr16);
|
bool thread_extension_aloc_map(protocol_interface_info_entry_t *cur, uint16_t *addr16);
|
||||||
void thread_extension_mcast_subscrition_change(protocol_interface_info_entry_t *interface);
|
void thread_extension_mcast_subscrition_change(protocol_interface_info_entry_t *interface);
|
||||||
void thread_extension_address_registration_trigger(protocol_interface_info_entry_t *interface);
|
void thread_extension_address_registration_trigger(protocol_interface_info_entry_t *interface);
|
||||||
void thread_extension_route_set(protocol_interface_info_entry_t *cur);
|
|
||||||
void thread_extension_activate(protocol_interface_info_entry_t *cur);
|
|
||||||
bool thread_extension_enabled(protocol_interface_info_entry_t *cur);
|
bool thread_extension_enabled(protocol_interface_info_entry_t *cur);
|
||||||
bool thread_extension_context_can_delete(int8_t id, uint8_t servicesPrefix[16], uint8_t context_prefix_length);
|
|
||||||
bool thread_extension_version_check(uint8_t version);
|
bool thread_extension_version_check(uint8_t version);
|
||||||
void thread_extension_discover_response_read(struct discovery_response_list *nwk_info, uint16_t discover_response_tlv, uint8_t *data_ptr, uint16_t data_len);
|
void thread_extension_discover_response_read(struct discovery_response_list *nwk_info, uint16_t discover_response_tlv, uint8_t *data_ptr, uint16_t data_len);
|
||||||
void thread_extension_discover_response_tlv_write(uint16_t *data, uint8_t version, uint16_t securityPolicy);
|
void thread_extension_discover_response_tlv_write(uint16_t *data, uint8_t version, uint16_t securityPolicy);
|
||||||
|
@ -70,35 +66,31 @@ uint8_t thread_extension_discover_response_len(protocol_interface_info_entry_t *
|
||||||
uint8_t *thread_extension_discover_response_write(protocol_interface_info_entry_t *cur, uint8_t *ptr);
|
uint8_t *thread_extension_discover_response_write(protocol_interface_info_entry_t *cur, uint8_t *ptr);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define thread_extension_joining_enabled(interface_id) false
|
#define thread_extension_joining_enabled(interface_id) (false)
|
||||||
#define thread_extension_discover_response_len(cur) 0
|
#define thread_extension_discover_response_len(cur) (0)
|
||||||
#define thread_extension_discover_response_write(cur, ptr) (ptr)
|
#define thread_extension_discover_response_write(cur, ptr) (ptr)
|
||||||
#endif //HAVE_THREAD_ROUTER
|
#endif //HAVE_THREAD_ROUTER
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define thread_extension_allocate(cur)
|
#define thread_extension_allocate(cur) ((void) 0)
|
||||||
#define thread_extension_free(cur)
|
#define thread_extension_free(cur) ((void) 0)
|
||||||
#define thread_extension_init(interface_id,coap_service_id)
|
#define thread_extension_init(interface_id,coap_service_id) ((void) 0)
|
||||||
#define thread_extension_network_prefix_get(interface_id,options_ptr,prefix_ptr,prefix_len) (-1)
|
#define thread_extension_network_data_process(cur) ((void) 0)
|
||||||
#define thread_extension_network_data_process(cur)
|
|
||||||
#define thread_extension_primary_bbr_get(cur,addr_ptr,seq_ptr,timer1_ptr, timer2_ptr) (-1)
|
#define thread_extension_primary_bbr_get(cur,addr_ptr,seq_ptr,timer1_ptr, timer2_ptr) (-1)
|
||||||
#define thread_extension_address_registration(interface,addr,child_mac64,refresh_child_entry,duplicate_child_detected)
|
#define thread_extension_address_registration(interface,addr,child_mac64,refresh_child_entry,duplicate_child_detected) ((void) 0)
|
||||||
#define thread_extension_address_generate(cur)
|
#define thread_extension_aloc_generate(cur) ((void) 0)
|
||||||
#define thread_extension_aloc_generate(cur)
|
#define thread_extension_aloc_map(cur, addr16) (false)
|
||||||
#define thread_extension_aloc_map(cur, addr16) false
|
#define thread_extension_mcast_subscrition_change(interface) ((void) 0)
|
||||||
#define thread_extension_mcast_subscrition_change(interface)
|
|
||||||
#define thread_extension_route_set(cur)
|
|
||||||
#define thread_extension_activate(cur)
|
|
||||||
#define thread_extension_enabled(cur) (false)
|
#define thread_extension_enabled(cur) (false)
|
||||||
#define thread_extension_version_check(version) (false)
|
#define thread_extension_version_check(version) (false)
|
||||||
#define thread_extension_discover_response_read(nwk_info, discover_response_tlv, data_ptr, data_len)
|
#define thread_extension_discover_response_read(nwk_info, discover_response_tlv, data_ptr, data_len) ((void) 0)
|
||||||
#define thread_extension_discover_response_tlv_write(data, version, extension_bit) (data)
|
#define thread_extension_discover_response_tlv_write(data, version, securityPolicy) ((void) 0)
|
||||||
#define thread_extension_service_init(cur) 0
|
#define thread_extension_service_init(cur) (0)
|
||||||
#define thread_extension_joining_enabled(interface_id) false
|
#define thread_extension_joining_enabled(interface_id) (false)
|
||||||
#define thread_extension_discover_response_len(cur) 0
|
#define thread_extension_discover_response_len(cur) (0)
|
||||||
#define thread_extension_discover_response_write(cur, ptr) (ptr)
|
#define thread_extension_discover_response_write(cur, ptr) (ptr)
|
||||||
#define thread_extension_addr_ntf_send(cur,destination_address,addr_data_ptr,bbr_status)
|
#define thread_extension_addr_ntf_send(cur,destination_address,addr_data_ptr,bbr_status) ((void) 0)
|
||||||
#define thread_extension_context_can_delete(id, servicesPrefix, context_prefix_length) false
|
#define thread_extension_dua_address_generate(cur, domain_prefix, domain_prefix_len) ((void) 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -52,10 +52,12 @@ int8_t thread_extension_bbr_init(int8_t interface_id, int8_t backbone_interface_
|
||||||
void thread_extension_bbr_delete(int8_t interface_id);
|
void thread_extension_bbr_delete(int8_t interface_id);
|
||||||
bool thread_extension_bbr_nd_query_process(protocol_interface_info_entry_t *cur, const uint8_t *target_addr, uint16_t rloc);
|
bool thread_extension_bbr_nd_query_process(protocol_interface_info_entry_t *cur, const uint8_t *target_addr, uint16_t rloc);
|
||||||
void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds);
|
void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds);
|
||||||
|
int thread_extension_bbr_sequence_number_set(int8_t interface_id, uint8_t seq_number);
|
||||||
int thread_extension_bbr_timeout_set(int8_t interface_id, uint32_t timeout_a, uint32_t timeout_b, uint32_t delay);
|
int thread_extension_bbr_timeout_set(int8_t interface_id, uint32_t timeout_a, uint32_t timeout_b, uint32_t delay);
|
||||||
int thread_extension_bbr_address_set(int8_t interface_id, const uint8_t *addr_ptr, uint16_t port);
|
int thread_extension_bbr_address_set(int8_t interface_id, const uint8_t *addr_ptr, uint16_t port);
|
||||||
void thread_extension_bbr_route_update(protocol_interface_info_entry_t *cur);
|
void thread_extension_bbr_route_update(protocol_interface_info_entry_t *cur);
|
||||||
int thread_extension_bbr_prefix_set(int8_t interface_id, uint8_t *prefix);
|
int thread_extension_bbr_prefix_set(int8_t interface_id, uint8_t *prefix);
|
||||||
|
void thread_extension_bbr_old_partition_data_clean(int8_t interface_id);
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -67,7 +69,9 @@ int thread_extension_bbr_prefix_set(int8_t interface_id, uint8_t *prefix);
|
||||||
#define thread_extension_bbr_timeout_set(interface_id, timeout_a, timeout_b, delay)
|
#define thread_extension_bbr_timeout_set(interface_id, timeout_a, timeout_b, delay)
|
||||||
#define thread_extension_bbr_address_set(interface_id, addr_ptr, port) (-1)
|
#define thread_extension_bbr_address_set(interface_id, addr_ptr, port) (-1)
|
||||||
#define thread_extension_bbr_route_update(cur)
|
#define thread_extension_bbr_route_update(cur)
|
||||||
|
#define thread_extension_bbr_sequence_number_set(interface_id, seq_number) (-1)
|
||||||
#define thread_extension_bbr_prefix_set(interface_id, prefix) 0
|
#define thread_extension_bbr_prefix_set(interface_id, prefix) 0
|
||||||
|
#define thread_extension_bbr_old_partition_data_clean(interface_id)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -45,6 +45,8 @@ extern "C" {
|
||||||
#define thread_extension_bootstrap_thread_name_length_get(cur) (0)
|
#define thread_extension_bootstrap_thread_name_length_get(cur) (0)
|
||||||
#define thread_extension_bootstrap_thread_name_ptr_get(cur) (NULL)
|
#define thread_extension_bootstrap_thread_name_ptr_get(cur) (NULL)
|
||||||
#define thread_extension_bootstrap_network_certificate_enable(cur, coap_service_id) (NULL)
|
#define thread_extension_bootstrap_network_certificate_enable(cur, coap_service_id) (NULL)
|
||||||
|
#define thread_extension_bootstrap_reenrollment_start(cur, service_id, pbbr_addr) (-1)
|
||||||
|
#define thread_extension_bootstrap_network_reattach(interface_id, timeout) (-1)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,11 +121,11 @@ static void thread_network_data_clean(protocol_interface_info_entry_t *cur)
|
||||||
|
|
||||||
static void thread_merge_prepare(protocol_interface_info_entry_t *cur)
|
static void thread_merge_prepare(protocol_interface_info_entry_t *cur)
|
||||||
{
|
{
|
||||||
|
thread_partition_data_purge(cur);
|
||||||
thread_clean_old_16_bit_address_based_addresses(cur);
|
thread_clean_old_16_bit_address_based_addresses(cur);
|
||||||
mpl_clear_realm_scope_seeds(cur);
|
mpl_clear_realm_scope_seeds(cur);
|
||||||
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_PROXIED_HOST, NULL);
|
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_PROXIED_HOST, NULL);
|
||||||
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_PROXIED_DUA_HOST, NULL);
|
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_PROXIED_DUA_HOST, NULL);
|
||||||
thread_partition_data_purge(cur);
|
|
||||||
thread_network_data_clean(cur);
|
thread_network_data_clean(cur);
|
||||||
cur->nwk_mode = ARM_NWK_GP_IP_MODE;
|
cur->nwk_mode = ARM_NWK_GP_IP_MODE;
|
||||||
}
|
}
|
||||||
|
@ -305,6 +305,7 @@ static int thread_end_device_synch_response_validate(protocol_interface_info_ent
|
||||||
uint16_t address16;
|
uint16_t address16;
|
||||||
uint32_t llFrameCounter;
|
uint32_t llFrameCounter;
|
||||||
thread_leader_data_t leaderData;
|
thread_leader_data_t leaderData;
|
||||||
|
mle_tlv_info_t addressRegisteredTlv;
|
||||||
mac_neighbor_table_entry_t *entry_temp;
|
mac_neighbor_table_entry_t *entry_temp;
|
||||||
bool new_entry_created;
|
bool new_entry_created;
|
||||||
|
|
||||||
|
@ -320,6 +321,7 @@ static int thread_end_device_synch_response_validate(protocol_interface_info_ent
|
||||||
// Address
|
// Address
|
||||||
// MLE_TYPE_SRC_ADDRESS
|
// MLE_TYPE_SRC_ADDRESS
|
||||||
// MLE_TYPE_LEADER_DATA
|
// MLE_TYPE_LEADER_DATA
|
||||||
|
// MLE_TYPE_ADDRESS_REGISTRATION
|
||||||
if (!mle_tlv_read_8_bit_tlv(MLE_TYPE_MODE, ptr, data_length, &mode) ||
|
if (!mle_tlv_read_8_bit_tlv(MLE_TYPE_MODE, ptr, data_length, &mode) ||
|
||||||
!mle_tlv_read_16_bit_tlv(MLE_TYPE_SRC_ADDRESS, ptr, data_length, &srcAddress) ||
|
!mle_tlv_read_16_bit_tlv(MLE_TYPE_SRC_ADDRESS, ptr, data_length, &srcAddress) ||
|
||||||
!mle_tlv_read_16_bit_tlv(MLE_TYPE_ADDRESS16, ptr, data_length, &address16) ||
|
!mle_tlv_read_16_bit_tlv(MLE_TYPE_ADDRESS16, ptr, data_length, &address16) ||
|
||||||
|
@ -329,6 +331,25 @@ static int thread_end_device_synch_response_validate(protocol_interface_info_ent
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(mode & THREAD_DEVICE_FED)) {
|
||||||
|
// check for presence of Address registration TLV for MTDs
|
||||||
|
if (!mle_tlv_read_tlv(MLE_TYPE_ADDRESS_REGISTRATION, ptr, data_length, &addressRegisteredTlv) ||
|
||||||
|
(addressRegisteredTlv.tlvLen == 0)) {
|
||||||
|
tr_debug("MTD missed address registration TLV - reattach");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the source address is a router address
|
||||||
|
if (!thread_is_router_addr(srcAddress)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the address16 is a valid child address
|
||||||
|
if (!thread_addr_is_child(srcAddress, address16)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (securityHeader->KeyIdMode == MAC_KEY_ID_MODE_SRC4_IDX) {
|
if (securityHeader->KeyIdMode == MAC_KEY_ID_MODE_SRC4_IDX) {
|
||||||
thread_management_key_synch_req(cur->id, common_read_32_bit(securityHeader->Keysource));
|
thread_management_key_synch_req(cur->id, common_read_32_bit(securityHeader->Keysource));
|
||||||
// if learning key sequence from link sync actual guard timer value is not known
|
// if learning key sequence from link sync actual guard timer value is not known
|
||||||
|
@ -631,8 +652,7 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
|
||||||
// New partition is Higher
|
// New partition is Higher
|
||||||
scan_result = thread_info(cur)->thread_attach_scanned_parent;
|
scan_result = thread_info(cur)->thread_attach_scanned_parent;
|
||||||
}
|
}
|
||||||
}
|
} else if (leaderData.partitionId == currentPartitionId) {
|
||||||
else if (leaderData.partitionId == currentPartitionId) {
|
|
||||||
thread_link_quality_e currentLqi;
|
thread_link_quality_e currentLqi;
|
||||||
//Calculate Current summed LQI
|
//Calculate Current summed LQI
|
||||||
scan_result = thread_info(cur)->thread_attach_scanned_parent;
|
scan_result = thread_info(cur)->thread_attach_scanned_parent;
|
||||||
|
@ -1103,7 +1123,7 @@ static int thread_attach_child_id_request_build(protocol_interface_info_entry_t
|
||||||
|
|
||||||
//Add ML-EID
|
//Add ML-EID
|
||||||
if ((mode & MLE_FFD_DEV) == 0) {
|
if ((mode & MLE_FFD_DEV) == 0) {
|
||||||
ptr = thread_address_registration_tlv_write(ptr, cur);
|
ptr = thread_ml_address_tlv_write(ptr, cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
reqTlvCnt = 2;
|
reqTlvCnt = 2;
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#include "thread_management_if.h"
|
#include "thread_management_if.h"
|
||||||
#include "thread_common.h"
|
#include "thread_common.h"
|
||||||
#include "thread_bootstrap.h"
|
#include "thread_bootstrap.h"
|
||||||
|
#include "thread_router_bootstrap.h"
|
||||||
#include "thread_network_synch.h"
|
#include "thread_network_synch.h"
|
||||||
#include "thread_network_data_lib.h"
|
#include "thread_network_data_lib.h"
|
||||||
#include "thread_joiner_application.h"
|
#include "thread_joiner_application.h"
|
||||||
|
@ -76,7 +77,8 @@ const uint8_t mle_pending_configuration_dataset_tlvs[] = {
|
||||||
MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA,
|
MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA,
|
||||||
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
||||||
MESHCOP_TLV_PSKC,
|
MESHCOP_TLV_PSKC,
|
||||||
MESHCOP_TLV_SECURITY_POLICY};
|
MESHCOP_TLV_SECURITY_POLICY
|
||||||
|
};
|
||||||
|
|
||||||
const uint8_t pending_configuration_dataset_tlvs[] = {
|
const uint8_t pending_configuration_dataset_tlvs[] = {
|
||||||
MESHCOP_TLV_PENDING_TIMESTAMP,
|
MESHCOP_TLV_PENDING_TIMESTAMP,
|
||||||
|
@ -89,7 +91,8 @@ const uint8_t pending_configuration_dataset_tlvs[] = {
|
||||||
MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA,
|
MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA,
|
||||||
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
||||||
MESHCOP_TLV_PSKC,
|
MESHCOP_TLV_PSKC,
|
||||||
MESHCOP_TLV_SECURITY_POLICY};
|
MESHCOP_TLV_SECURITY_POLICY
|
||||||
|
};
|
||||||
|
|
||||||
const uint8_t active_configuration_dataset_tlvs[] = {
|
const uint8_t active_configuration_dataset_tlvs[] = {
|
||||||
MESHCOP_TLV_ACTIVE_TIME_STAMP,
|
MESHCOP_TLV_ACTIVE_TIME_STAMP,
|
||||||
|
@ -101,7 +104,8 @@ const uint8_t active_configuration_dataset_tlvs[] = {
|
||||||
MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA,
|
MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA,
|
||||||
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
||||||
MESHCOP_TLV_PSKC,
|
MESHCOP_TLV_PSKC,
|
||||||
MESHCOP_TLV_SECURITY_POLICY};
|
MESHCOP_TLV_SECURITY_POLICY
|
||||||
|
};
|
||||||
|
|
||||||
const uint8_t mle_active_configuration_dataset_tlvs[] = {
|
const uint8_t mle_active_configuration_dataset_tlvs[] = {
|
||||||
MESHCOP_TLV_NETWORK_NAME,
|
MESHCOP_TLV_NETWORK_NAME,
|
||||||
|
@ -112,7 +116,8 @@ const uint8_t mle_active_configuration_dataset_tlvs[] = {
|
||||||
MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA,
|
MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA,
|
||||||
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
||||||
MESHCOP_TLV_PSKC,
|
MESHCOP_TLV_PSKC,
|
||||||
MESHCOP_TLV_SECURITY_POLICY};
|
MESHCOP_TLV_SECURITY_POLICY
|
||||||
|
};
|
||||||
|
|
||||||
const uint8_t entrust_dataset_tlvs[] = {
|
const uint8_t entrust_dataset_tlvs[] = {
|
||||||
MESHCOP_TLV_ACTIVE_TIME_STAMP,
|
MESHCOP_TLV_ACTIVE_TIME_STAMP,
|
||||||
|
@ -123,7 +128,8 @@ const uint8_t entrust_dataset_tlvs[] = {
|
||||||
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
MESHCOP_TLV_NETWORK_MASTER_KEY,
|
||||||
MESHCOP_TLV_PSKC,
|
MESHCOP_TLV_PSKC,
|
||||||
MESHCOP_TLV_SECURITY_POLICY,
|
MESHCOP_TLV_SECURITY_POLICY,
|
||||||
MESHCOP_TLV_NETWORK_KEY_SEQUENCE};
|
MESHCOP_TLV_NETWORK_KEY_SEQUENCE
|
||||||
|
};
|
||||||
|
|
||||||
const uint8_t meshcop_pending_set_ignore[] = {
|
const uint8_t meshcop_pending_set_ignore[] = {
|
||||||
MESHCOP_TLV_BORDER_ROUTER_LOCATOR,
|
MESHCOP_TLV_BORDER_ROUTER_LOCATOR,
|
||||||
|
@ -530,8 +536,7 @@ static configuration_set_t *configuration_set_copy(configuration_set_t *source_p
|
||||||
|
|
||||||
static bool configuration_set_tlv_required(uint8_t tlv_id, const uint8_t *tlv_ptr, uint8_t tlv_len)
|
static bool configuration_set_tlv_required(uint8_t tlv_id, const uint8_t *tlv_ptr, uint8_t tlv_len)
|
||||||
{
|
{
|
||||||
while(tlv_len)
|
while (tlv_len) {
|
||||||
{
|
|
||||||
if (tlv_ptr[tlv_len-- -1] == tlv_id) {
|
if (tlv_ptr[tlv_len-- -1] == tlv_id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -926,7 +931,8 @@ uint8_t *thread_joiner_application_network_name_get(int8_t interface_id)
|
||||||
return this->configuration_ptr->name;
|
return this->configuration_ptr->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int thread_joiner_application_nvm_link_config_read(thread_joiner_t *this) {
|
static int thread_joiner_application_nvm_link_config_read(thread_joiner_t *this)
|
||||||
|
{
|
||||||
|
|
||||||
// read config from NVM, in case of failure current settings are unchanged.
|
// read config from NVM, in case of failure current settings are unchanged.
|
||||||
int nvm_read_status = thread_nvm_store_active_configuration_read(this->active_configuration_ptr, sizeof(configuration_set_t));
|
int nvm_read_status = thread_nvm_store_active_configuration_read(this->active_configuration_ptr, sizeof(configuration_set_t));
|
||||||
|
@ -980,8 +986,7 @@ static int thread_joiner_application_nvm_link_config_read(thread_joiner_t *this)
|
||||||
// this saves all configurations
|
// this saves all configurations
|
||||||
if (THREAD_NVM_FILE_SUCCESS != nvm_read_status) {
|
if (THREAD_NVM_FILE_SUCCESS != nvm_read_status) {
|
||||||
thread_joiner_application_configuration_nvm_save(this->interface_id);
|
thread_joiner_application_configuration_nvm_save(this->interface_id);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
tr_info("Reading pending set");
|
tr_info("Reading pending set");
|
||||||
configuration_set_t *pend_conf_ptr = ns_dyn_mem_alloc(sizeof(configuration_set_t));
|
configuration_set_t *pend_conf_ptr = ns_dyn_mem_alloc(sizeof(configuration_set_t));
|
||||||
if (pend_conf_ptr) {
|
if (pend_conf_ptr) {
|
||||||
|
@ -994,8 +999,7 @@ static int thread_joiner_application_nvm_link_config_read(thread_joiner_t *this)
|
||||||
this->pending_configuration_ptr = pend_conf_ptr;
|
this->pending_configuration_ptr = pend_conf_ptr;
|
||||||
this->pending_configuration_ptr->timeout_in_ms = 0;
|
this->pending_configuration_ptr->timeout_in_ms = 0;
|
||||||
this->pending_set_in_sync = false;
|
this->pending_set_in_sync = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
tr_info("Reading pending from NVM error:%d", pending_ret);
|
tr_info("Reading pending from NVM error:%d", pending_ret);
|
||||||
ns_dyn_mem_free(pend_conf_ptr);
|
ns_dyn_mem_free(pend_conf_ptr);
|
||||||
}
|
}
|
||||||
|
@ -1140,7 +1144,7 @@ void thread_joiner_pending_config_activate(int8_t interface_id)
|
||||||
this->active_configuration_ptr->timestamp = pending_active_timestamp;
|
this->active_configuration_ptr->timestamp = pending_active_timestamp;
|
||||||
// All information is copied from old configuration so if configuration is corrupt we dont change anything.
|
// All information is copied from old configuration so if configuration is corrupt we dont change anything.
|
||||||
this->pending_configuration_ptr = NULL;
|
this->pending_configuration_ptr = NULL;
|
||||||
(void)thread_nvm_store_pending_configuration_remove();
|
thread_nvm_store_pending_configuration_remove();
|
||||||
configuration_set_copy_mandatory(this->active_configuration_ptr, this->old_active_configuration_ptr);
|
configuration_set_copy_mandatory(this->active_configuration_ptr, this->old_active_configuration_ptr);
|
||||||
link_configuration_update(this->configuration_ptr, this->active_configuration_ptr->data, this->active_configuration_ptr->length);
|
link_configuration_update(this->configuration_ptr, this->active_configuration_ptr->data, this->active_configuration_ptr->length);
|
||||||
link_configuration_trace(this->configuration_ptr);
|
link_configuration_trace(this->configuration_ptr);
|
||||||
|
@ -1922,6 +1926,8 @@ int thread_joiner_application_update_configuration(uint8_t interface_id, uint8_t
|
||||||
}
|
}
|
||||||
thread_meshcop_tlv_data_get_uint64(msg_ptr, msg_len, MESHCOP_TLV_ACTIVE_TIME_STAMP, &this->active_configuration_ptr->timestamp);
|
thread_meshcop_tlv_data_get_uint64(msg_ptr, msg_len, MESHCOP_TLV_ACTIVE_TIME_STAMP, &this->active_configuration_ptr->timestamp);
|
||||||
link_configuration_update(this->configuration_ptr, msg_ptr, msg_len);
|
link_configuration_update(this->configuration_ptr, msg_ptr, msg_len);
|
||||||
|
// allow 5 seconds delay before state change for data response propagation
|
||||||
|
thread_router_bootstrap_delay_reed_jitter(interface_id, 5);
|
||||||
ns_dyn_mem_free(configuration_ptr);
|
ns_dyn_mem_free(configuration_ptr);
|
||||||
thread_joiner_application_configuration_nvm_save(interface_id);
|
thread_joiner_application_configuration_nvm_save(interface_id);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include "6LoWPAN/Thread/thread_config.h"
|
#include "6LoWPAN/Thread/thread_config.h"
|
||||||
#include "6LoWPAN/Thread/thread_common.h"
|
#include "6LoWPAN/Thread/thread_common.h"
|
||||||
#include "6LoWPAN/Thread/thread_bootstrap.h"
|
#include "6LoWPAN/Thread/thread_bootstrap.h"
|
||||||
#include "6LoWPAN/Thread/thread_dhcpv6_client.h"
|
#include "DHCPv6_client/dhcpv6_client_api.h"
|
||||||
#include "6LoWPAN/Thread/thread_discovery.h"
|
#include "6LoWPAN/Thread/thread_discovery.h"
|
||||||
#include "6LoWPAN/Thread/thread_joiner_application.h"
|
#include "6LoWPAN/Thread/thread_joiner_application.h"
|
||||||
#include "6LoWPAN/Thread/thread_network_data_lib.h"
|
#include "6LoWPAN/Thread/thread_network_data_lib.h"
|
||||||
|
@ -192,12 +192,14 @@ static bool thread_leader_service_commissioner_unregister(int8_t interface_id, u
|
||||||
link_configuration_s *linkConfiguration;
|
link_configuration_s *linkConfiguration;
|
||||||
|
|
||||||
linkConfiguration = thread_joiner_application_get_config(interface_id);
|
linkConfiguration = thread_joiner_application_get_config(interface_id);
|
||||||
if(!linkConfiguration)
|
if (!linkConfiguration) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cur = protocol_stack_interface_info_get_by_id(interface_id);
|
cur = protocol_stack_interface_info_get_by_id(interface_id);
|
||||||
if (!cur || !cur->thread_info || !cur->thread_info->leader_private_data)
|
if (!cur || !cur->thread_info || !cur->thread_info->leader_private_data) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (cur->thread_info->registered_commissioner.session_id != session_id) {
|
if (cur->thread_info->registered_commissioner.session_id != session_id) {
|
||||||
tr_debug("Commissioner session id not valid - unregister failed");
|
tr_debug("Commissioner session id not valid - unregister failed");
|
||||||
|
@ -266,14 +268,12 @@ static void thread_leader_service_commissioner_timeout_cb(void* arg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(thread_ptr->registered_commissioner.commissioner_registration)
|
switch (thread_ptr->registered_commissioner.commissioner_registration) {
|
||||||
{
|
|
||||||
case THREAD_COMMISSIONER_REGISTRATION_OBSOLETE:
|
case THREAD_COMMISSIONER_REGISTRATION_OBSOLETE:
|
||||||
thread_ptr->registered_commissioner.commissioner_registration = THREAD_COMMISSIONER_NOT_REGISTERED;
|
thread_ptr->registered_commissioner.commissioner_registration = THREAD_COMMISSIONER_NOT_REGISTERED;
|
||||||
if (false == thread_leader_service_commissioner_unregister(thread_ptr->interface_id, thread_ptr->registered_commissioner.session_id)) {
|
if (false == thread_leader_service_commissioner_unregister(thread_ptr->interface_id, thread_ptr->registered_commissioner.session_id)) {
|
||||||
tr_debug("Commissioner registration remove failed");
|
tr_debug("Commissioner registration remove failed");
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
tr_debug("Commissioner registration removed");
|
tr_debug("Commissioner registration removed");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -305,7 +305,6 @@ static int thread_leader_service_commissioner_register(int8_t interface_id, uint
|
||||||
protocol_interface_info_entry_t *cur;
|
protocol_interface_info_entry_t *cur;
|
||||||
link_configuration_s *linkConfiguration;
|
link_configuration_s *linkConfiguration;
|
||||||
|
|
||||||
tr_debug("Register interface %d commissioner: %s", interface_id, trace_ipv6(border_router_address));
|
|
||||||
|
|
||||||
linkConfiguration = thread_joiner_application_get_config(interface_id);
|
linkConfiguration = thread_joiner_application_get_config(interface_id);
|
||||||
if (!linkConfiguration) {
|
if (!linkConfiguration) {
|
||||||
|
@ -341,6 +340,13 @@ static int thread_leader_service_commissioner_register(int8_t interface_id, uint
|
||||||
*session_id = cur->thread_info->registered_commissioner.session_id;
|
*session_id = cur->thread_info->registered_commissioner.session_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (memcmp(border_router_address, linkConfiguration->mesh_local_ula_prefix, 8) == 0 &&
|
||||||
|
memcmp(border_router_address + 8, ADDR_SHORT_ADR_SUFFIC, 6) == 0 &&
|
||||||
|
border_router_address[14] == 0xfc) {
|
||||||
|
// source address is ALOC
|
||||||
|
common_write_16_bit(cur->thread_info->routerShortAddress, &border_router_address[14]);
|
||||||
|
}
|
||||||
|
tr_debug("Register interface %d commissioner: %s", interface_id, trace_ipv6(border_router_address));
|
||||||
//SET Border Router Locator
|
//SET Border Router Locator
|
||||||
memcpy(cur->thread_info->registered_commissioner.border_router_address, border_router_address, 16);
|
memcpy(cur->thread_info->registered_commissioner.border_router_address, border_router_address, 16);
|
||||||
cur->thread_info->registered_commissioner.commissioner_valid = true;
|
cur->thread_info->registered_commissioner.commissioner_valid = true;
|
||||||
|
@ -1082,10 +1088,10 @@ static int thread_leader_service_petition_cb(int8_t service_id, uint8_t source_a
|
||||||
// Commissioner already registered - reject and send commissioner ID
|
// Commissioner already registered - reject and send commissioner ID
|
||||||
ptr = thread_meshcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_STATE, 0xff);
|
ptr = thread_meshcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_STATE, 0xff);
|
||||||
commissioner_id_ptr = thread_commissioning_if_commissioner_id_get(this->interface_id);
|
commissioner_id_ptr = thread_commissioning_if_commissioner_id_get(this->interface_id);
|
||||||
if(commissioner_id_ptr)
|
if (commissioner_id_ptr) {
|
||||||
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_COMMISSIONER_ID, strlen(commissioner_id_ptr), (uint8_t *)commissioner_id_ptr);
|
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_COMMISSIONER_ID, strlen(commissioner_id_ptr), (uint8_t *)commissioner_id_ptr);
|
||||||
}
|
}
|
||||||
else{
|
} else {
|
||||||
// Reject, anyhow, no commissioner registered - no commissioner ID
|
// Reject, anyhow, no commissioner registered - no commissioner ID
|
||||||
ptr = thread_meshcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_STATE, 0xff);
|
ptr = thread_meshcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_STATE, 0xff);
|
||||||
}
|
}
|
||||||
|
@ -1128,8 +1134,7 @@ static int thread_leader_service_petition_ka_cb(int8_t service_id, uint8_t sourc
|
||||||
if (2 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_COMMISSIONER_SESSION_ID, &ptr)) {
|
if (2 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_COMMISSIONER_SESSION_ID, &ptr)) {
|
||||||
session_id = common_read_16_bit(ptr);
|
session_id = common_read_16_bit(ptr);
|
||||||
}
|
}
|
||||||
if (1 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_STATE, &ptr))
|
if (1 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_STATE, &ptr)) {
|
||||||
{
|
|
||||||
if (*ptr == 0x01) {
|
if (*ptr == 0x01) {
|
||||||
state = thread_leader_service_commissioner_session_refresh(this->interface_id, session_id);
|
state = thread_leader_service_commissioner_session_refresh(this->interface_id, session_id);
|
||||||
} else if (*ptr == 0xff) {
|
} else if (*ptr == 0xff) {
|
||||||
|
@ -1295,7 +1300,7 @@ static int thread_leader_service_leader_init(protocol_interface_info_entry_t *cu
|
||||||
thread_routing_free(&thread_info->routing);
|
thread_routing_free(&thread_info->routing);
|
||||||
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD, NULL);
|
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD, NULL);
|
||||||
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_BORDER_ROUTER, NULL);
|
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_BORDER_ROUTER, NULL);
|
||||||
thread_dhcp_client_delete(cur->id);
|
dhcp_client_delete(cur->id);
|
||||||
thread_nd_service_delete(cur->id);
|
thread_nd_service_delete(cur->id);
|
||||||
mpl_clear_realm_scope_seeds(cur);
|
mpl_clear_realm_scope_seeds(cur);
|
||||||
ipv6_neighbour_cache_flush(&cur->ipv6_neighbour_cache);
|
ipv6_neighbour_cache_flush(&cur->ipv6_neighbour_cache);
|
||||||
|
@ -1352,7 +1357,6 @@ static void thread_leader_service_interface_setup_activate(protocol_interface_in
|
||||||
cur->lowpan_address_mode = NET_6LOWPAN_GP16_ADDRESS;
|
cur->lowpan_address_mode = NET_6LOWPAN_GP16_ADDRESS;
|
||||||
thread_bootstrap_update_ml16_address(cur, cur->thread_info->routerShortAddress);
|
thread_bootstrap_update_ml16_address(cur, cur->thread_info->routerShortAddress);
|
||||||
thread_generate_ml64_address(cur);
|
thread_generate_ml64_address(cur);
|
||||||
thread_extension_address_generate(cur);
|
|
||||||
thread_bootstrap_routing_activate(cur);
|
thread_bootstrap_routing_activate(cur);
|
||||||
thread_routing_update_id_set(cur, private->maskSeq, private->master_router_id_mask);
|
thread_routing_update_id_set(cur, private->maskSeq, private->master_router_id_mask);
|
||||||
thread_routing_activate(&cur->thread_info->routing);
|
thread_routing_activate(&cur->thread_info->routing);
|
||||||
|
@ -1534,8 +1538,7 @@ void thread_leader_service_timer(protocol_interface_info_entry_t *cur, uint32_t
|
||||||
if (cur->thread_info->leader_private_data->leader_nvm_sync_timer) {
|
if (cur->thread_info->leader_private_data->leader_nvm_sync_timer) {
|
||||||
if ((cur->thread_info->leader_private_data->leader_nvm_sync_timer) > ticks) {
|
if ((cur->thread_info->leader_private_data->leader_nvm_sync_timer) > ticks) {
|
||||||
cur->thread_info->leader_private_data->leader_nvm_sync_timer -= ticks;
|
cur->thread_info->leader_private_data->leader_nvm_sync_timer -= ticks;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cur->thread_info->leader_private_data->leader_nvm_sync_timer = 0;
|
cur->thread_info->leader_private_data->leader_nvm_sync_timer = 0;
|
||||||
thread_leader_mleid_rloc_map_to_nvm_write(cur);
|
thread_leader_mleid_rloc_map_to_nvm_write(cur);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
* Dummy implementation for thread_lowpower_api.
|
* Dummy implementation for thread_lowpower_api.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int thread_lowpower_test_probe_send(int8_t interface_id, uint8_t *address, uint8_t *metrics_ptr, uint8_t metrics_len, thread_lowpower_resp_cb response_cb) {
|
int thread_lowpower_test_probe_send(int8_t interface_id, uint8_t *address, uint8_t *metrics_ptr, uint8_t metrics_len, thread_lowpower_resp_cb response_cb)
|
||||||
|
{
|
||||||
(void)interface_id;
|
(void)interface_id;
|
||||||
(void)address;
|
(void)address;
|
||||||
(void)metrics_ptr;
|
(void)metrics_ptr;
|
||||||
|
@ -44,7 +45,8 @@ int thread_lowpower_test_probe_send(int8_t interface_id, uint8_t *address, uint8
|
||||||
(void)response_cb;
|
(void)response_cb;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int thread_lowpower_metrics_management_request_send(int8_t interface_id, uint8_t *address, uint8_t series_id, uint8_t series_flags, uint16_t timeout, uint8_t *metrics_ptr, uint8_t metrics_len, thread_lowpower_resp_cb response_cb) {
|
int thread_lowpower_metrics_management_request_send(int8_t interface_id, uint8_t *address, uint8_t series_id, uint8_t series_flags, uint16_t timeout, uint8_t *metrics_ptr, uint8_t metrics_len, thread_lowpower_resp_cb response_cb)
|
||||||
|
{
|
||||||
|
|
||||||
(void)interface_id;
|
(void)interface_id;
|
||||||
(void)address;
|
(void)address;
|
||||||
|
|
|
@ -287,7 +287,6 @@ int thread_management_register(int8_t interface_id)
|
||||||
this->get_response_cb_ptr = NULL;
|
this->get_response_cb_ptr = NULL;
|
||||||
|
|
||||||
if (thread_management_get_remote_addr(this)) {
|
if (thread_management_get_remote_addr(this)) {
|
||||||
ns_dyn_mem_free(this);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,8 +425,7 @@ int thread_management_get(int8_t instance_id, uint8_t dst_addr[static 16], char
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
memcpy(this->final_dest_address, this->destination_address, 16);
|
memcpy(this->final_dest_address, this->destination_address, 16);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (this->native_interface) {
|
if (this->native_interface) {
|
||||||
memcpy(this->final_dest_address, dst_addr, 16);
|
memcpy(this->final_dest_address, dst_addr, 16);
|
||||||
wrap_to_udp_tx = true;
|
wrap_to_udp_tx = true;
|
||||||
|
@ -475,8 +473,7 @@ int thread_management_set(int8_t instance_id, uint8_t dst_addr[static 16], char
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
memcpy(this->final_dest_address, this->destination_address, 16);
|
memcpy(this->final_dest_address, this->destination_address, 16);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (this->native_interface) {
|
if (this->native_interface) {
|
||||||
// native commissioner sending to address, need to encapsulate
|
// native commissioner sending to address, need to encapsulate
|
||||||
memcpy(this->final_dest_address, dst_addr, 16);
|
memcpy(this->final_dest_address, dst_addr, 16);
|
||||||
|
@ -504,17 +501,20 @@ int thread_management_set(int8_t instance_id, uint8_t dst_addr[static 16], char
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int thread_management_register(int8_t interface_id) {
|
int thread_management_register(int8_t interface_id)
|
||||||
|
{
|
||||||
(void)interface_id;
|
(void)interface_id;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_management_unregister(int8_t instance_id) {
|
int thread_management_unregister(int8_t instance_id)
|
||||||
|
{
|
||||||
(void)instance_id;
|
(void)instance_id;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_management_set_security_policy(int8_t instance_id, uint8_t options, uint16_t rotation_time, management_set_response_cb *cb_ptr) {
|
int thread_management_set_security_policy(int8_t instance_id, uint8_t options, uint16_t rotation_time, management_set_response_cb *cb_ptr)
|
||||||
|
{
|
||||||
(void)instance_id;
|
(void)instance_id;
|
||||||
(void) options;
|
(void) options;
|
||||||
(void)rotation_time;
|
(void)rotation_time;
|
||||||
|
@ -522,7 +522,8 @@ int thread_management_set_security_policy(int8_t instance_id, uint8_t options, u
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_management_set_steering_data(int8_t instance_id, uint16_t session_id, uint8_t *steering_data_ptr, uint8_t steering_data_len, management_set_response_cb *cb_ptr) {
|
int thread_management_set_steering_data(int8_t instance_id, uint16_t session_id, uint8_t *steering_data_ptr, uint8_t steering_data_len, management_set_response_cb *cb_ptr)
|
||||||
|
{
|
||||||
(void)instance_id;
|
(void)instance_id;
|
||||||
(void) session_id;
|
(void) session_id;
|
||||||
(void) steering_data_ptr;
|
(void) steering_data_ptr;
|
||||||
|
@ -531,7 +532,8 @@ int thread_management_set_steering_data(int8_t instance_id, uint16_t session_id,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_management_set_commissioning_data_timestamp(int8_t instance_id, uint64_t time, management_set_response_cb *cb_ptr) {
|
int thread_management_set_commissioning_data_timestamp(int8_t instance_id, uint64_t time, management_set_response_cb *cb_ptr)
|
||||||
|
{
|
||||||
(void)instance_id;
|
(void)instance_id;
|
||||||
(void) time;
|
(void) time;
|
||||||
(void)cb_ptr;
|
(void)cb_ptr;
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "6LoWPAN/Thread/thread_constants.h"
|
#include "6LoWPAN/Thread/thread_constants.h"
|
||||||
#include "6LoWPAN/Thread/thread_tmfcop_lib.h"
|
#include "6LoWPAN/Thread/thread_tmfcop_lib.h"
|
||||||
#include "6LoWPAN/Thread/thread_management_internal.h"
|
#include "6LoWPAN/Thread/thread_management_internal.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_management_server.h"
|
||||||
#include "6LoWPAN/Thread/thread_joiner_application.h"
|
#include "6LoWPAN/Thread/thread_joiner_application.h"
|
||||||
#include "6LoWPAN/Thread/thread_network_data_lib.h"
|
#include "6LoWPAN/Thread/thread_network_data_lib.h"
|
||||||
#include "6LoWPAN/Thread/thread_bootstrap.h"
|
#include "6LoWPAN/Thread/thread_bootstrap.h"
|
||||||
|
@ -58,9 +59,8 @@ typedef struct thread_management {
|
||||||
thread_management_client_router_id_cb *router_id_release_cb_ptr;
|
thread_management_client_router_id_cb *router_id_release_cb_ptr;
|
||||||
thread_management_client_network_data_set_cb *network_data_set_cb_ptr;
|
thread_management_client_network_data_set_cb *network_data_set_cb_ptr;
|
||||||
thread_management_client_network_data_set_cb *neighbor_discovery_cb_ptr;
|
thread_management_client_network_data_set_cb *neighbor_discovery_cb_ptr;
|
||||||
uint16_t coap_asd_msg_id; // COAP msg id for a/sd
|
|
||||||
int8_t interface_id;
|
int8_t interface_id;
|
||||||
int8_t coap_service_id;
|
int8_t coap_service_id; // COAP service ID from Management server
|
||||||
ns_list_link_t link;
|
ns_list_link_t link;
|
||||||
} thread_management_t;
|
} thread_management_t;
|
||||||
|
|
||||||
|
@ -150,9 +150,12 @@ void thread_management_client_init(int8_t interface_id)
|
||||||
this->neighbor_discovery_cb_ptr = NULL;
|
this->neighbor_discovery_cb_ptr = NULL;
|
||||||
this->router_id_cb_ptr = NULL;
|
this->router_id_cb_ptr = NULL;
|
||||||
this->interface_id = interface_id;
|
this->interface_id = interface_id;
|
||||||
this->coap_asd_msg_id = 0;
|
|
||||||
//TODO: Check if to use ephemeral port here
|
//TODO: Check if to use ephemeral port here
|
||||||
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_NONE, NULL, NULL);
|
|
||||||
|
this->coap_service_id = thread_management_server_service_id_get(interface_id);
|
||||||
|
if (this->coap_service_id < 0) {
|
||||||
|
tr_error("Failed to init COAP service");
|
||||||
|
}
|
||||||
ns_list_add_to_start(&instance_list, this);
|
ns_list_add_to_start(&instance_list, this);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -165,19 +168,10 @@ void thread_management_client_delete(int8_t interface_id)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
coap_service_delete(this->coap_service_id);
|
|
||||||
ns_list_remove(&instance_list, this);
|
ns_list_remove(&instance_list, this);
|
||||||
ns_dyn_mem_free(this);
|
ns_dyn_mem_free(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int8_t thread_management_client_service_id_get(int8_t interface_id)
|
|
||||||
{
|
|
||||||
thread_management_t *this = thread_management_find(interface_id);
|
|
||||||
if (!this) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return this->coap_service_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
int thread_management_client_router_id_get(int8_t interface_id, uint8_t mac[8], uint16_t router_id, thread_management_client_router_id_cb *id_cb, uint8_t status)
|
int thread_management_client_router_id_get(int8_t interface_id, uint8_t mac[8], uint16_t router_id, thread_management_client_router_id_cb *id_cb, uint8_t status)
|
||||||
{
|
{
|
||||||
|
@ -251,8 +245,6 @@ static int thread_management_client_register_cb(int8_t service_id, uint8_t sourc
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->coap_asd_msg_id = 0; //clear the coap message id
|
|
||||||
|
|
||||||
if (this->network_data_set_cb_ptr) {
|
if (this->network_data_set_cb_ptr) {
|
||||||
if (response_ptr) {
|
if (response_ptr) {
|
||||||
// If we get response status is OK
|
// If we get response status is OK
|
||||||
|
@ -281,10 +273,8 @@ int thread_management_client_network_data_register(int8_t interface_id, uint8_t
|
||||||
this->network_data_set_cb_ptr = set_cb;
|
this->network_data_set_cb_ptr = set_cb;
|
||||||
tr_debug("thread network data send to %s", trace_ipv6(destination));
|
tr_debug("thread network data send to %s", trace_ipv6(destination));
|
||||||
|
|
||||||
this->coap_asd_msg_id = coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination, THREAD_MANAGEMENT_PORT,
|
return coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination, THREAD_MANAGEMENT_PORT,
|
||||||
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_NETWORK_DATA, COAP_CT_OCTET_STREAM, data_ptr, data_len, thread_management_client_register_cb);
|
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_NETWORK_DATA, COAP_CT_OCTET_STREAM, data_ptr, data_len, thread_management_client_register_cb);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_management_client_network_data_unregister(int8_t interface_id, uint16_t rloc16)
|
int thread_management_client_network_data_unregister(int8_t interface_id, uint16_t rloc16)
|
||||||
|
@ -306,7 +296,7 @@ int thread_management_client_network_data_unregister(int8_t interface_id, uint16
|
||||||
|
|
||||||
tr_debug("thread network data unregister");
|
tr_debug("thread network data unregister");
|
||||||
|
|
||||||
this->coap_asd_msg_id = coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination, THREAD_MANAGEMENT_PORT,
|
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination, THREAD_MANAGEMENT_PORT,
|
||||||
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_NETWORK_DATA, COAP_CT_OCTET_STREAM, payload, ptr - payload, thread_management_client_register_cb);
|
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_NETWORK_DATA, COAP_CT_OCTET_STREAM, payload, ptr - payload, thread_management_client_register_cb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -616,7 +606,18 @@ void thread_management_client_proactive_an(int8_t interface_id, const uint8_t ad
|
||||||
payload, ptr - payload, thread_management_client_proactive_an_cb);
|
payload, ptr - payload, thread_management_client_proactive_an_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void thread_management_client_pending_coap_request_kill(int8_t interface_id)
|
void thread_management_client_coap_message_delete(int8_t interface_id, uint16_t coap_message_id)
|
||||||
|
{
|
||||||
|
thread_management_t *this = thread_management_find(interface_id);
|
||||||
|
|
||||||
|
if (!this) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
coap_service_request_delete(this->coap_service_id, coap_message_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void thread_management_client_old_partition_data_clean(int8_t interface_id)
|
||||||
{
|
{
|
||||||
thread_management_t *this = thread_management_find(interface_id);
|
thread_management_t *this = thread_management_find(interface_id);
|
||||||
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
|
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
|
||||||
|
@ -625,17 +626,9 @@ void thread_management_client_pending_coap_request_kill(int8_t interface_id)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur->thread_info->localServerDataBase.publish_active = false;
|
cur->thread_info->localServerDataBase.publish_coap_req_id = 0;
|
||||||
|
cur->thread_info->routerIdRequested = false;
|
||||||
if (this->coap_asd_msg_id != 0) {
|
coap_service_request_delete_by_service_id(this->coap_service_id);
|
||||||
coap_service_request_delete(this->coap_service_id, this->coap_asd_msg_id);
|
|
||||||
this->coap_asd_msg_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cur->thread_info->routerIdReqCoapID != 0) {
|
|
||||||
coap_service_request_delete(this->coap_service_id, cur->thread_info->routerIdReqCoapID);
|
|
||||||
cur->thread_info->routerIdReqCoapID = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -65,12 +65,6 @@ void thread_management_client_init(int8_t interface_id);
|
||||||
*/
|
*/
|
||||||
void thread_management_client_delete(int8_t interface_id);
|
void thread_management_client_delete(int8_t interface_id);
|
||||||
|
|
||||||
/** Get service id of management service.
|
|
||||||
*
|
|
||||||
* When using Coap Management port service this service is the only instance used to make client transactions.
|
|
||||||
*/
|
|
||||||
int8_t thread_management_client_service_id_get(int8_t interface_id);
|
|
||||||
|
|
||||||
/** Router id handler callback.
|
/** Router id handler callback.
|
||||||
*
|
*
|
||||||
* callback to inform when new router id is received from leader.
|
* callback to inform when new router id is received from leader.
|
||||||
|
@ -213,9 +207,20 @@ int thread_management_client_provision_request(int8_t interface_id, uint8_t *dst
|
||||||
*/
|
*/
|
||||||
void thread_management_client_proactive_an(int8_t interface_id, const uint8_t address[16], const uint16_t rloc, const uint8_t ml_eid[8], const uint8_t dst_addr[16]);
|
void thread_management_client_proactive_an(int8_t interface_id, const uint8_t address[16], const uint16_t rloc, const uint8_t ml_eid[8], const uint8_t dst_addr[16]);
|
||||||
|
|
||||||
/** Kill pending COAP requests.
|
/** Delete COAP message .
|
||||||
|
*
|
||||||
|
* Delete COAP message that is sent to COAP service.
|
||||||
|
*
|
||||||
|
* \param interface_id interface id of this Thread instance.
|
||||||
|
* \param coap_message_id COAP message to be deleted.
|
||||||
|
*/
|
||||||
|
void thread_management_client_coap_message_delete(int8_t interface_id, uint16_t coap_message_id);
|
||||||
|
|
||||||
|
/** Clear old partition data.
|
||||||
|
*
|
||||||
|
* Clear data related to old partition, like pending COAP transactions.
|
||||||
*
|
*
|
||||||
* \param interface_id interface id of this Thread instance.
|
* \param interface_id interface id of this Thread instance.
|
||||||
*/
|
*/
|
||||||
void thread_management_client_pending_coap_request_kill(int8_t interface_id);
|
void thread_management_client_old_partition_data_clean(int8_t interface_id);
|
||||||
#endif /* THREAD_MANAGEMENT_CLIENT_H_ */
|
#endif /* THREAD_MANAGEMENT_CLIENT_H_ */
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
#include "6LoWPAN/Thread/thread_leader_service.h"
|
#include "6LoWPAN/Thread/thread_leader_service.h"
|
||||||
#include "6LoWPAN/Thread/thread_nd.h"
|
#include "6LoWPAN/Thread/thread_nd.h"
|
||||||
#include "thread_diagnostic.h"
|
#include "thread_diagnostic.h"
|
||||||
#include "6LoWPAN/Thread/thread_dhcpv6_client.h"
|
#include "DHCPv6_client/dhcpv6_client_api.h"
|
||||||
#include "6LoWPAN/Thread/thread_discovery.h"
|
#include "6LoWPAN/Thread/thread_discovery.h"
|
||||||
#include "6LoWPAN/Thread/thread_network_synch.h"
|
#include "6LoWPAN/Thread/thread_network_synch.h"
|
||||||
#include "6LoWPAN/Thread/thread_management_internal.h"
|
#include "6LoWPAN/Thread/thread_management_internal.h"
|
||||||
|
@ -63,6 +63,7 @@
|
||||||
#include "6LoWPAN/Thread/thread_constants.h"
|
#include "6LoWPAN/Thread/thread_constants.h"
|
||||||
#include "6LoWPAN/Thread/thread_extension_bootstrap.h"
|
#include "6LoWPAN/Thread/thread_extension_bootstrap.h"
|
||||||
#include "6LoWPAN/Thread/thread_extension.h"
|
#include "6LoWPAN/Thread/thread_extension.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_bbr_api_internal.h"
|
||||||
#include "6LoWPAN/Bootstraps/protocol_6lowpan.h"
|
#include "6LoWPAN/Bootstraps/protocol_6lowpan.h"
|
||||||
#include "RPL/rpl_control.h" // insanity - bootstraps shouldn't be doing each others' clean-up
|
#include "RPL/rpl_control.h" // insanity - bootstraps shouldn't be doing each others' clean-up
|
||||||
#include "MLE/mle.h"
|
#include "MLE/mle.h"
|
||||||
|
@ -71,9 +72,8 @@
|
||||||
#include "thread_commissioning_if.h"
|
#include "thread_commissioning_if.h"
|
||||||
#include "shalib.h"
|
#include "shalib.h"
|
||||||
#include "Common_Protocols/icmpv6.h"
|
#include "Common_Protocols/icmpv6.h"
|
||||||
#include "libDHCPv6/libDHCPv6.h"
|
|
||||||
#include "libDHCPv6/libDHCPv6_server.h"
|
|
||||||
#include "DHCPv6_Server/DHCPv6_server_service.h"
|
#include "DHCPv6_Server/DHCPv6_server_service.h"
|
||||||
|
#include "6LoWPAN/Thread/thread_dhcpv6_server.h"
|
||||||
#include "Service_Libs/mle_service/mle_service_api.h"
|
#include "Service_Libs/mle_service/mle_service_api.h"
|
||||||
#include "Service_Libs/blacklist/blacklist.h"
|
#include "Service_Libs/blacklist/blacklist.h"
|
||||||
#include "6LoWPAN/MAC/mac_helper.h"
|
#include "6LoWPAN/MAC/mac_helper.h"
|
||||||
|
@ -99,7 +99,8 @@ uint16_t thread_joiner_port = THREAD_DEFAULT_JOINER_PORT;
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void thread_discover_key_descriptor_set(struct mac_api_s *api, const uint8_t *key, uint8_t id, uint32_t key32_bit_src, uint8_t attribute_index) {
|
static void thread_discover_key_descriptor_set(struct mac_api_s *api, const uint8_t *key, uint8_t id, uint32_t key32_bit_src, uint8_t attribute_index)
|
||||||
|
{
|
||||||
mlme_set_t set_req;
|
mlme_set_t set_req;
|
||||||
mlme_key_id_lookup_descriptor_t lookup_description;
|
mlme_key_id_lookup_descriptor_t lookup_description;
|
||||||
mlme_key_descriptor_entry_t key_description;
|
mlme_key_descriptor_entry_t key_description;
|
||||||
|
@ -538,7 +539,8 @@ int thread_management_increment_key_sequence_counter(int8_t interface_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_management_get_ml_prefix(int8_t interface_id, uint8_t *prefix_ptr)
|
int thread_management_get_ml_prefix(int8_t interface_id, uint8_t *prefix_ptr)
|
||||||
{// TODO get from static configuration
|
{
|
||||||
|
// TODO get from static configuration
|
||||||
protocol_interface_info_entry_t *cur;
|
protocol_interface_info_entry_t *cur;
|
||||||
cur = protocol_stack_interface_info_get_by_id(interface_id);
|
cur = protocol_stack_interface_info_get_by_id(interface_id);
|
||||||
if (!cur || !prefix_ptr) {
|
if (!cur || !prefix_ptr) {
|
||||||
|
@ -606,7 +608,7 @@ int thread_management_get_ml_prefix_112(int8_t interface_id, uint8_t *prefix_ptr
|
||||||
*/
|
*/
|
||||||
int thread_dhcpv6_server_add(int8_t interface_id, uint8_t *prefix_ptr, uint32_t max_client_cnt, bool stableData)
|
int thread_dhcpv6_server_add(int8_t interface_id, uint8_t *prefix_ptr, uint32_t max_client_cnt, bool stableData)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DHCPV6_SERVER
|
#if defined(HAVE_THREAD) && defined(HAVE_DHCPV6_SERVER)
|
||||||
protocol_interface_info_entry_t *cur;
|
protocol_interface_info_entry_t *cur;
|
||||||
thread_prefix_tlv_t prefixTlv;
|
thread_prefix_tlv_t prefixTlv;
|
||||||
thread_border_router_tlv_entry_t service;
|
thread_border_router_tlv_entry_t service;
|
||||||
|
@ -622,7 +624,7 @@ int thread_dhcpv6_server_add(int8_t interface_id, uint8_t *prefix_ptr, uint32_t
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DHCPv6_server_service_init(interface_id, prefix_ptr, cur->mac, DHCPV6_DUID_HARDWARE_EUI64_TYPE) != 0) {
|
if (thread_dhcp6_server_init(interface_id, prefix_ptr, cur->mac, THREAD_MIN_PREFIX_LIFETIME) != 0) {
|
||||||
tr_warn("SerVER alloc fail");
|
tr_warn("SerVER alloc fail");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -637,14 +639,9 @@ int thread_dhcpv6_server_add(int8_t interface_id, uint8_t *prefix_ptr, uint32_t
|
||||||
service.P_on_mesh = true;
|
service.P_on_mesh = true;
|
||||||
service.stableData = stableData;
|
service.stableData = stableData;
|
||||||
|
|
||||||
//SET Timeout
|
|
||||||
DHCPv6_server_service_set_address_validlifetime(interface_id, prefix_ptr, THREAD_MIN_PREFIX_LIFETIME);
|
|
||||||
|
|
||||||
// SET maximum number of accepted clients
|
// SET maximum number of accepted clients
|
||||||
DHCPv6_server_service_set_max_clients_accepts_count(interface_id, prefix_ptr, max_client_cnt);
|
DHCPv6_server_service_set_max_clients_accepts_count(interface_id, prefix_ptr, max_client_cnt);
|
||||||
|
|
||||||
//Enable Mapping
|
|
||||||
//DHCPv6_server_service_set_gua_address_mapping(interface_id,prefix_ptr, true, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix);
|
|
||||||
tr_debug("GUA server Generate OK");
|
tr_debug("GUA server Generate OK");
|
||||||
memcpy(ptr, prefix_ptr, 8);
|
memcpy(ptr, prefix_ptr, 8);
|
||||||
memset(ptr + 8, 0, 8);
|
memset(ptr + 8, 0, 8);
|
||||||
|
@ -665,7 +662,7 @@ int thread_dhcpv6_server_add(int8_t interface_id, uint8_t *prefix_ptr, uint32_t
|
||||||
|
|
||||||
int thread_dhcpv6_server_set_lifetime(int8_t interface_id, uint8_t *prefix_ptr, uint32_t valid_lifetime)
|
int thread_dhcpv6_server_set_lifetime(int8_t interface_id, uint8_t *prefix_ptr, uint32_t valid_lifetime)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DHCPV6_SERVER
|
#if defined(HAVE_THREAD) && defined(HAVE_DHCPV6_SERVER)
|
||||||
if (!prefix_ptr) {
|
if (!prefix_ptr) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -681,7 +678,7 @@ int thread_dhcpv6_server_set_lifetime(int8_t interface_id, uint8_t *prefix_ptr,
|
||||||
|
|
||||||
int thread_dhcpv6_server_set_max_client(int8_t interface_id, uint8_t *prefix_ptr, uint32_t max_client_count)
|
int thread_dhcpv6_server_set_max_client(int8_t interface_id, uint8_t *prefix_ptr, uint32_t max_client_count)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DHCPV6_SERVER
|
#if defined(HAVE_THREAD) && defined(HAVE_DHCPV6_SERVER)
|
||||||
if (!prefix_ptr) {
|
if (!prefix_ptr) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -697,7 +694,7 @@ int thread_dhcpv6_server_set_max_client(int8_t interface_id, uint8_t *prefix_ptr
|
||||||
|
|
||||||
int thread_dhcpv6_server_set_anonymous_addressing(int8_t interface_id, uint8_t *prefix_ptr, bool anonymous)
|
int thread_dhcpv6_server_set_anonymous_addressing(int8_t interface_id, uint8_t *prefix_ptr, bool anonymous)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DHCPV6_SERVER
|
#if defined(HAVE_THREAD) && defined(HAVE_DHCPV6_SERVER)
|
||||||
if (!prefix_ptr) {
|
if (!prefix_ptr) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -715,7 +712,7 @@ int thread_dhcpv6_server_set_anonymous_addressing(int8_t interface_id, uint8_t *
|
||||||
|
|
||||||
int thread_dhcpv6_server_delete(int8_t interface_id, uint8_t *prefix_ptr)
|
int thread_dhcpv6_server_delete(int8_t interface_id, uint8_t *prefix_ptr)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DHCPV6_SERVER
|
#if defined(HAVE_THREAD) && defined(HAVE_DHCPV6_SERVER)
|
||||||
uint8_t temp[16];
|
uint8_t temp[16];
|
||||||
protocol_interface_info_entry_t *cur;
|
protocol_interface_info_entry_t *cur;
|
||||||
thread_prefix_tlv_t prefixTlv;
|
thread_prefix_tlv_t prefixTlv;
|
||||||
|
@ -931,17 +928,14 @@ int thread_management_device_type_set(int8_t interface_id, thread_device_type_e
|
||||||
if (device_type == THREAD_DEVICE_REED) {
|
if (device_type == THREAD_DEVICE_REED) {
|
||||||
// Change mode to router
|
// Change mode to router
|
||||||
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_ROUTER;
|
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_ROUTER;
|
||||||
}
|
} else if (device_type == THREAD_DEVICE_FED) {
|
||||||
else if (device_type == THREAD_DEVICE_FED) {
|
|
||||||
//FED devices makes links and makes address resolutions
|
//FED devices makes links and makes address resolutions
|
||||||
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_HOST;
|
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_HOST;
|
||||||
cur->thread_info->end_device_link_synch = true;
|
cur->thread_info->end_device_link_synch = true;
|
||||||
}
|
} else if (device_type == THREAD_DEVICE_MED) {
|
||||||
else if (device_type == THREAD_DEVICE_MED) {
|
|
||||||
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_HOST;
|
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_HOST;
|
||||||
cur->thread_info->end_device_link_synch = false;
|
cur->thread_info->end_device_link_synch = false;
|
||||||
}
|
} else if (device_type == THREAD_DEVICE_SED) {
|
||||||
else if (device_type == THREAD_DEVICE_SED) {
|
|
||||||
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_SLEEPY_HOST;
|
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_SLEEPY_HOST;
|
||||||
cur->thread_info->end_device_link_synch = false;
|
cur->thread_info->end_device_link_synch = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,9 @@ typedef struct announce {
|
||||||
typedef struct thread_management_server {
|
typedef struct thread_management_server {
|
||||||
scan_query_t *scan_ptr;
|
scan_query_t *scan_ptr;
|
||||||
announce_t *announce_ptr;
|
announce_t *announce_ptr;
|
||||||
|
timeout_t *join_ent_timer;
|
||||||
|
uint8_t destination_address[16];
|
||||||
|
uint8_t one_time_key[16];
|
||||||
uint16_t relay_port_joiner;
|
uint16_t relay_port_joiner;
|
||||||
uint16_t external_commissioner_port;
|
uint16_t external_commissioner_port;
|
||||||
int8_t interface_id;
|
int8_t interface_id;
|
||||||
|
@ -120,10 +123,12 @@ static bool thread_channel_mask_is_channel_set(uint8_t *mask_ptr, uint8_t channe
|
||||||
n = (channel) / 8;
|
n = (channel) / 8;
|
||||||
bit = 1 << (7 - (channel) % 8);
|
bit = 1 << (7 - (channel) % 8);
|
||||||
|
|
||||||
if (n > 5 || channel > 27)
|
if (n > 5 || channel > 27) {
|
||||||
return false;
|
return false;
|
||||||
if( mask_ptr[n+2] & bit )
|
}
|
||||||
|
if (mask_ptr[n + 2] & bit) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,8 +142,9 @@ static uint8_t thread_channel_mask_count(uint8_t *mask_ptr)
|
||||||
bits = common_read_32_bit(mask_ptr + 2);
|
bits = common_read_32_bit(mask_ptr + 2);
|
||||||
bits = bits >> 5;// five lover bits are not used
|
bits = bits >> 5;// five lover bits are not used
|
||||||
for (n = 0; n < 27; n++) {
|
for (n = 0; n < 27; n++) {
|
||||||
if((bits & 1)== 1)
|
if ((bits & 1) == 1) {
|
||||||
result++;
|
result++;
|
||||||
|
}
|
||||||
bits = bits >> 1;
|
bits = bits >> 1;
|
||||||
}
|
}
|
||||||
tr_debug("Channel mask count = %d ", result);
|
tr_debug("Channel mask count = %d ", result);
|
||||||
|
@ -210,9 +216,10 @@ static bool tlv_is_requested(uint8_t *tlv_list, uint16_t list_len, uint8_t tlv)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (uint16_t n = 0; n < list_len; n++) {
|
for (uint16_t n = 0; n < list_len; n++) {
|
||||||
if (tlv_list[n] == tlv )
|
if (tlv_list[n] == tlv) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,14 +446,17 @@ static int thread_management_server_commissioner_get_cb(int8_t service_id, uint8
|
||||||
uint16_t border_router_locator = common_read_16_bit(&cur->thread_info->registered_commissioner.border_router_address[14]);
|
uint16_t border_router_locator = common_read_16_bit(&cur->thread_info->registered_commissioner.border_router_address[14]);
|
||||||
request_tlv_len = thread_tmfcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_GET, &request_tlv_ptr);
|
request_tlv_len = thread_tmfcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_GET, &request_tlv_ptr);
|
||||||
|
|
||||||
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_BORDER_ROUTER_LOCATOR))
|
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_BORDER_ROUTER_LOCATOR)) {
|
||||||
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_BORDER_ROUTER_LOCATOR, border_router_locator);
|
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_BORDER_ROUTER_LOCATOR, border_router_locator);
|
||||||
|
}
|
||||||
|
|
||||||
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_COMMISSIONER_SESSION_ID))
|
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_COMMISSIONER_SESSION_ID)) {
|
||||||
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_COMMISSIONER_SESSION_ID, cur->thread_info->registered_commissioner.session_id);
|
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_COMMISSIONER_SESSION_ID, cur->thread_info->registered_commissioner.session_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_STEERING_DATA))
|
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_STEERING_DATA)) {
|
||||||
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_STEERING_DATA, cur->thread_info->registered_commissioner.steering_data_len, cur->thread_info->registered_commissioner.steering_data);
|
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_STEERING_DATA, cur->thread_info->registered_commissioner.steering_data_len, cur->thread_info->registered_commissioner.steering_data);
|
||||||
|
}
|
||||||
|
|
||||||
if (payload_ptr == ptr) {
|
if (payload_ptr == ptr) {
|
||||||
tr_warn("No TLVs found");
|
tr_warn("No TLVs found");
|
||||||
|
@ -502,8 +512,7 @@ static void thread_panid_conflict_timeout_cb(void* arg)
|
||||||
uint8_t payload[12];// 2+6 + 2+2
|
uint8_t payload[12];// 2+6 + 2+2
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
thread_management_server_t *this = arg;
|
thread_management_server_t *this = arg;
|
||||||
if(!this || !this->scan_ptr)
|
if (!this || !this->scan_ptr) {
|
||||||
{
|
|
||||||
tr_error("panid conflict scan ptr missing");
|
tr_error("panid conflict scan ptr missing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -531,8 +540,7 @@ static void set_channel_mask(uint8_t *channel_mask,uint8_t channel_number, uint8
|
||||||
bit_position = 7 - (channel_number % 8);
|
bit_position = 7 - (channel_number % 8);
|
||||||
channel_mask[byte_position + 2] |= (1 << bit_position);
|
channel_mask[byte_position + 2] |= (1 << bit_position);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
byte_position = 3 - (channel_number / 8);
|
byte_position = 3 - (channel_number / 8);
|
||||||
bit_position = channel_number % 8;
|
bit_position = channel_number % 8;
|
||||||
channel_mask[byte_position + 2] |= (1 << bit_position);
|
channel_mask[byte_position + 2] |= (1 << bit_position);
|
||||||
|
@ -545,9 +553,10 @@ static uint32_t reverse_bits(uint32_t num)
|
||||||
uint32_t reversed_value = 0, i, temp;
|
uint32_t reversed_value = 0, i, temp;
|
||||||
for (i = 0; i < NO_OF_BITS; i++) {
|
for (i = 0; i < NO_OF_BITS; i++) {
|
||||||
temp = (num & (1 << i));
|
temp = (num & (1 << i));
|
||||||
if(temp)
|
if (temp) {
|
||||||
reversed_value |= (1 << ((NO_OF_BITS - 1) - i));
|
reversed_value |= (1 << ((NO_OF_BITS - 1) - i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return reversed_value;
|
return reversed_value;
|
||||||
}
|
}
|
||||||
static void thread_panid_scan_response(int8_t if_id, const mlme_scan_conf_t *conf)
|
static void thread_panid_scan_response(int8_t if_id, const mlme_scan_conf_t *conf)
|
||||||
|
@ -704,8 +713,7 @@ static void energy_scan_confirm_cb(int8_t if_id, const mlme_scan_conf_t* conf)
|
||||||
if (this->scan_ptr->scan_count == 0) {
|
if (this->scan_ptr->scan_count == 0) {
|
||||||
this->scan_ptr->energy_list_ptr -= this->scan_ptr->energy_list_length;
|
this->scan_ptr->energy_list_ptr -= this->scan_ptr->energy_list_length;
|
||||||
thread_energy_scan_coap(this);
|
thread_energy_scan_coap(this);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
// if all scans have not been completed, enable RF, wait for scan period and call energy scan method again
|
// if all scans have not been completed, enable RF, wait for scan period and call energy scan method again
|
||||||
thread_start_mac_with_link_configuration(interface, linkConfiguration);
|
thread_start_mac_with_link_configuration(interface, linkConfiguration);
|
||||||
if (this->scan_ptr->timer) {
|
if (this->scan_ptr->timer) {
|
||||||
|
@ -774,8 +782,9 @@ void thread_energy_scan_timeout_cb(void* arg)
|
||||||
static void thread_panid_scan_timeout_cb(void *arg)
|
static void thread_panid_scan_timeout_cb(void *arg)
|
||||||
{
|
{
|
||||||
thread_management_server_t *this = arg;
|
thread_management_server_t *this = arg;
|
||||||
if(!this || !this->scan_ptr)
|
if (!this || !this->scan_ptr) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->scan_ptr->timer = NULL;
|
this->scan_ptr->timer = NULL;
|
||||||
|
|
||||||
|
@ -994,7 +1003,6 @@ error_exit:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void thread_announce_timeout_cb(void *arg)
|
static void thread_announce_timeout_cb(void *arg)
|
||||||
{
|
{
|
||||||
link_configuration_s *linkConfiguration;
|
link_configuration_s *linkConfiguration;
|
||||||
|
@ -1132,6 +1140,9 @@ int thread_management_server_init(int8_t interface_id)
|
||||||
this->relay_port_joiner = 0;
|
this->relay_port_joiner = 0;
|
||||||
this->scan_ptr = NULL;
|
this->scan_ptr = NULL;
|
||||||
this->announce_ptr = NULL;
|
this->announce_ptr = NULL;
|
||||||
|
this->join_ent_timer = NULL;
|
||||||
|
memset(this->destination_address, 0, 16);
|
||||||
|
memset(this->one_time_key, 0, 16);
|
||||||
this->external_commissioner_port = THREAD_COMMISSIONING_PORT;
|
this->external_commissioner_port = THREAD_COMMISSIONING_PORT;
|
||||||
|
|
||||||
#ifdef HAVE_THREAD_ROUTER
|
#ifdef HAVE_THREAD_ROUTER
|
||||||
|
@ -1147,13 +1158,13 @@ int thread_management_server_init(int8_t interface_id)
|
||||||
#endif
|
#endif
|
||||||
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_NONE, NULL, NULL);
|
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_NONE, NULL, NULL);
|
||||||
if (this->coap_service_id < 0) {
|
if (this->coap_service_id < 0) {
|
||||||
tr_warn("Thread management init failed");
|
tr_error("Thread management init failed");
|
||||||
ns_dyn_mem_free(this);
|
ns_dyn_mem_free(this);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_THREAD_ROUTER
|
#ifdef HAVE_THREAD_ROUTER
|
||||||
if (thread_leader_service_init(interface_id, this->coap_service_id) != 0) {
|
if (thread_leader_service_init(interface_id, this->coap_service_id) != 0) {
|
||||||
tr_warn("Thread leader service init failed");
|
tr_error("Thread leader service init failed");
|
||||||
ns_dyn_mem_free(this);
|
ns_dyn_mem_free(this);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
@ -1191,6 +1202,7 @@ void thread_management_server_delete(int8_t interface_id)
|
||||||
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_MANAGEMENT_GET);
|
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_MANAGEMENT_GET);
|
||||||
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_MANAGEMENT_SET);
|
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_MANAGEMENT_SET);
|
||||||
coap_service_delete(this->coap_service_id);
|
coap_service_delete(this->coap_service_id);
|
||||||
|
|
||||||
ns_list_remove(&instance_list, this);
|
ns_list_remove(&instance_list, this);
|
||||||
if (this->announce_ptr) {
|
if (this->announce_ptr) {
|
||||||
if (this->announce_ptr->timer) {
|
if (this->announce_ptr->timer) {
|
||||||
|
@ -1215,6 +1227,15 @@ void thread_management_server_delete(int8_t interface_id)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t thread_management_server_service_id_get(int8_t interface_id)
|
||||||
|
{
|
||||||
|
thread_management_server_t *this = thread_management_server_find(interface_id);
|
||||||
|
if (!this) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return this->coap_service_id;
|
||||||
|
}
|
||||||
|
|
||||||
int8_t thread_management_server_interface_id_get(int8_t coap_service_id)
|
int8_t thread_management_server_interface_id_get(int8_t coap_service_id)
|
||||||
{
|
{
|
||||||
thread_management_server_t *this = thread_management_find_by_service(coap_service_id);
|
thread_management_server_t *this = thread_management_find_by_service(coap_service_id);
|
||||||
|
@ -1312,6 +1333,19 @@ static int thread_management_server_entrust_send(thread_management_server_t *thi
|
||||||
ns_dyn_mem_free(response_ptr);
|
ns_dyn_mem_free(response_ptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void thread_join_ent_timeout_cb(void *arg)
|
||||||
|
{
|
||||||
|
thread_management_server_t *this = arg;
|
||||||
|
if (!this || !this->join_ent_timer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->join_ent_timer = NULL;
|
||||||
|
thread_management_server_entrust_send(this, this->destination_address, this->one_time_key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void joiner_router_recv_commission_msg(void *cb_res)
|
void joiner_router_recv_commission_msg(void *cb_res)
|
||||||
{
|
{
|
||||||
socket_callback_t *sckt_data = 0;
|
socket_callback_t *sckt_data = 0;
|
||||||
|
@ -1412,7 +1446,13 @@ static int thread_management_server_relay_tx_cb(int8_t service_id, uint8_t sourc
|
||||||
if (0 < thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_JOINER_ROUTER_KEK, &kek_ptr)) {
|
if (0 < thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_JOINER_ROUTER_KEK, &kek_ptr)) {
|
||||||
// KEK present in relay set pairwise key and send entrust
|
// KEK present in relay set pairwise key and send entrust
|
||||||
tr_debug("Kek received");
|
tr_debug("Kek received");
|
||||||
thread_management_server_entrust_send(this, destination_address.address, kek_ptr);
|
if (this->join_ent_timer) {
|
||||||
|
eventOS_timeout_cancel(this->join_ent_timer);
|
||||||
|
thread_management_server_entrust_send(this, this->destination_address, this->one_time_key);
|
||||||
|
}
|
||||||
|
memcpy(this->destination_address, destination_address.address, 16);
|
||||||
|
memcpy(this->one_time_key, kek_ptr, 16);
|
||||||
|
this->join_ent_timer = eventOS_timeout_ms(thread_join_ent_timeout_cb, THREAD_DELAY_JOIN_ENT, this);
|
||||||
}
|
}
|
||||||
tr_debug("Relay TX sendto addr:%s port:%d, length:%d", trace_ipv6(destination_address.address), port, udp_data_len);
|
tr_debug("Relay TX sendto addr:%s port:%d, length:%d", trace_ipv6(destination_address.address), port, udp_data_len);
|
||||||
thci_trace("joinerrouterJoinerDataRelayedOutbound");
|
thci_trace("joinerrouterJoinerDataRelayedOutbound");
|
||||||
|
|
|
@ -99,6 +99,13 @@ int thread_management_server_joiner_router_init(int8_t interface_id);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void thread_management_server_joiner_router_deinit(int8_t interface_id);
|
void thread_management_server_joiner_router_deinit(int8_t interface_id);
|
||||||
|
|
||||||
|
/** Get service id of management service.
|
||||||
|
*
|
||||||
|
* When using Coap Management port service this service is the only instance used to make client transactions.
|
||||||
|
*/
|
||||||
|
int8_t thread_management_server_service_id_get(int8_t interface_id);
|
||||||
|
|
||||||
int8_t thread_management_server_interface_id_get(int8_t coap_service_id);
|
int8_t thread_management_server_interface_id_get(int8_t coap_service_id);
|
||||||
|
|
||||||
int thread_management_server_commisoner_data_get(int8_t interface_id, thread_management_server_data_t *server_data);
|
int thread_management_server_commisoner_data_get(int8_t interface_id, thread_management_server_data_t *server_data);
|
||||||
|
|
|
@ -395,7 +395,8 @@ uint8_t thread_meshcop_tlv_data_get_uint64(const uint8_t *ptr, uint16_t length,
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
uint16_t thread_meshcop_tlv_find(const uint8_t *ptr, uint16_t length, uint8_t type, uint8_t **result_ptr) {
|
uint16_t thread_meshcop_tlv_find(const uint8_t *ptr, uint16_t length, uint8_t type, uint8_t **result_ptr)
|
||||||
|
{
|
||||||
(void)ptr;
|
(void)ptr;
|
||||||
(void)length;
|
(void)length;
|
||||||
(void)type;
|
(void)type;
|
||||||
|
@ -403,7 +404,8 @@ uint16_t thread_meshcop_tlv_find(const uint8_t *ptr, uint16_t length, uint8_t ty
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *thread_meshcop_tlv_data_write(uint8_t *ptr, uint8_t type, uint16_t length, const uint8_t *data) {
|
uint8_t *thread_meshcop_tlv_data_write(uint8_t *ptr, uint8_t type, uint16_t length, const uint8_t *data)
|
||||||
|
{
|
||||||
(void)ptr;
|
(void)ptr;
|
||||||
(void)type;
|
(void)type;
|
||||||
(void)length;
|
(void)length;
|
||||||
|
@ -435,7 +437,8 @@ uint8_t *thread_meshcop_tlv_data_write_uint32(uint8_t *ptr, uint8_t type, uint32
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *thread_meshcop_tlv_data_write_uint64(uint8_t *ptr, uint8_t type, uint64_t data) {
|
uint8_t *thread_meshcop_tlv_data_write_uint64(uint8_t *ptr, uint8_t type, uint64_t data)
|
||||||
|
{
|
||||||
(void) ptr;
|
(void) ptr;
|
||||||
(void)type;
|
(void)type;
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#ifdef HAVE_THREAD
|
#ifdef HAVE_THREAD
|
||||||
|
|
||||||
#include "ns_trace.h"
|
#include "ns_trace.h"
|
||||||
|
#include "string.h"
|
||||||
#include "common_functions.h"
|
#include "common_functions.h"
|
||||||
#include "NWK_INTERFACE/Include/protocol.h"
|
#include "NWK_INTERFACE/Include/protocol.h"
|
||||||
#include <nsdynmemLIB.h>
|
#include <nsdynmemLIB.h>
|
||||||
|
@ -53,6 +54,7 @@
|
||||||
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
|
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
|
||||||
#include "6LoWPAN/MAC/mac_helper.h"
|
#include "6LoWPAN/MAC/mac_helper.h"
|
||||||
#include "6LoWPAN/MAC/mac_data_poll.h"
|
#include "6LoWPAN/MAC/mac_data_poll.h"
|
||||||
|
#include "Common_Protocols/ipv6.h"
|
||||||
#include "MLE/mle.h"
|
#include "MLE/mle.h"
|
||||||
#include "mac_api.h"
|
#include "mac_api.h"
|
||||||
#define TRACE_GROUP "thmh"
|
#define TRACE_GROUP "thmh"
|
||||||
|
@ -123,8 +125,7 @@ void thread_general_mle_receive_cb(int8_t interface_id, mle_message_t *mle_msg,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MLE_COMMAND_CHILD_UPDATE_RESPONSE:
|
case MLE_COMMAND_CHILD_UPDATE_RESPONSE: {
|
||||||
{
|
|
||||||
thread_parse_child_update_response(cur, mle_msg, security_headers, linkMargin);
|
thread_parse_child_update_response(cur, mle_msg, security_headers, linkMargin);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -699,6 +700,54 @@ static int thread_host_child_update_response_send(protocol_interface_info_entry_
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool thread_address_registration_tlv_search(if_address_entry_t *entry, mle_tlv_info_t *tlv_info)
|
||||||
|
{
|
||||||
|
uint8_t context;
|
||||||
|
uint16_t length = tlv_info->tlvLen;
|
||||||
|
uint8_t *ptr = tlv_info->dataPtr;
|
||||||
|
|
||||||
|
while (length) {
|
||||||
|
context = *ptr++;
|
||||||
|
if (context & 0x80) {
|
||||||
|
if (memcmp(ptr, entry->address + 8, 8) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ptr += 8;
|
||||||
|
length -= 9;
|
||||||
|
} else {
|
||||||
|
if (memcmp(ptr, entry->address, 16) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ptr += 16;
|
||||||
|
length -= 17;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool thread_address_registration_tlv_check(protocol_interface_info_entry_t *cur, mle_tlv_info_t *tlv_info)
|
||||||
|
{
|
||||||
|
bool ret_val = true;
|
||||||
|
|
||||||
|
ns_list_foreach_safe(if_address_entry_t, e, &cur->ip_addresses) {
|
||||||
|
if (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_GLOBAL || (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_REALM_LOCAL &&
|
||||||
|
!thread_addr_is_mesh_local_16(e->address, cur))) {
|
||||||
|
|
||||||
|
if (thread_address_registration_tlv_search(e, tlv_info) == false) {
|
||||||
|
tr_debug("Address %s registration to parent failed", trace_ipv6(e->address));
|
||||||
|
addr_set_preferred_lifetime(cur, e, 0); // deprecate address
|
||||||
|
ret_val = false;
|
||||||
|
} else if (e->preferred_lifetime == 0) {
|
||||||
|
addr_set_preferred_lifetime(cur, e, 0xffffffff); // set preferred lifetime to infinite
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
static void thread_host_child_update_request_process(protocol_interface_info_entry_t *cur, mle_message_t *mle_msg, uint8_t linkMargin)
|
static void thread_host_child_update_request_process(protocol_interface_info_entry_t *cur, mle_message_t *mle_msg, uint8_t linkMargin)
|
||||||
{
|
{
|
||||||
thread_leader_data_t leaderData;
|
thread_leader_data_t leaderData;
|
||||||
|
@ -710,6 +759,7 @@ static void thread_host_child_update_request_process(protocol_interface_info_ent
|
||||||
uint64_t pending_timestamp = 0;// means no pending timestamp
|
uint64_t pending_timestamp = 0;// means no pending timestamp
|
||||||
mac_neighbor_table_entry_t *entry_temp;
|
mac_neighbor_table_entry_t *entry_temp;
|
||||||
bool data_request_needed = false;
|
bool data_request_needed = false;
|
||||||
|
mle_tlv_info_t tlv_info = {0};
|
||||||
|
|
||||||
tr_debug("Child update request");
|
tr_debug("Child update request");
|
||||||
entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL);
|
entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL);
|
||||||
|
@ -738,6 +788,11 @@ static void thread_host_child_update_request_process(protocol_interface_info_ent
|
||||||
thread_bootstrap_network_data_update(cur);
|
thread_bootstrap_network_data_update(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check Address Registration TLV
|
||||||
|
if (true == mle_tlv_read_tlv(MLE_TYPE_ADDRESS_REGISTRATION, mle_msg->data_ptr, mle_msg->data_length, &tlv_info)) {
|
||||||
|
thread_address_registration_tlv_check(cur, &tlv_info);
|
||||||
|
}
|
||||||
|
|
||||||
if (thread_info(cur)->thread_leader_data->stableDataVersion != leaderData.stableDataVersion ||
|
if (thread_info(cur)->thread_leader_data->stableDataVersion != leaderData.stableDataVersion ||
|
||||||
thread_info(cur)->thread_leader_data->dataVersion != leaderData.dataVersion) {
|
thread_info(cur)->thread_leader_data->dataVersion != leaderData.dataVersion) {
|
||||||
// version numbers not in sync need to send data request
|
// version numbers not in sync need to send data request
|
||||||
|
@ -776,6 +831,7 @@ static void thread_parse_child_update_response(protocol_interface_info_entry_t *
|
||||||
thread_leader_data_t leaderData = {0};
|
thread_leader_data_t leaderData = {0};
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
bool leader_data_received;
|
bool leader_data_received;
|
||||||
|
mle_tlv_info_t tlv_info = {0};
|
||||||
|
|
||||||
if (cur->thread_info->thread_endnode_parent == NULL) {
|
if (cur->thread_info->thread_endnode_parent == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -822,6 +878,10 @@ static void thread_parse_child_update_response(protocol_interface_info_entry_t *
|
||||||
tr_debug("Setting child timeout, value=%"PRIu32, timeout);
|
tr_debug("Setting child timeout, value=%"PRIu32, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (true == mle_tlv_read_tlv(MLE_TYPE_ADDRESS_REGISTRATION, mle_msg->data_ptr, mle_msg->data_length, &tlv_info)) {
|
||||||
|
thread_address_registration_tlv_check(cur, &tlv_info);
|
||||||
|
}
|
||||||
|
|
||||||
tr_debug("Keep-Alive -->Respond from Parent");
|
tr_debug("Keep-Alive -->Respond from Parent");
|
||||||
mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, timeout);
|
mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, timeout);
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ static void thread_nd_address_error(int8_t interface_id, const uint8_t ip_addr[1
|
||||||
if_address_entry_t *addr_entry = addr_get_entry(cur, ip_addr);
|
if_address_entry_t *addr_entry = addr_get_entry(cur, ip_addr);
|
||||||
if (addr_entry && memcmp(ml_eid, cur->iid_slaac, 8)) {
|
if (addr_entry && memcmp(ml_eid, cur->iid_slaac, 8)) {
|
||||||
addr_duplicate_detected(cur, ip_addr);
|
addr_duplicate_detected(cur, ip_addr);
|
||||||
thread_extension_address_generate(cur);
|
thread_extension_dua_address_generate(cur, ip_addr, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scan IPv6 neighbour cache for registered entries of children */
|
/* Scan IPv6 neighbour cache for registered entries of children */
|
||||||
|
@ -547,8 +547,7 @@ int thread_nd_address_registration(protocol_interface_info_entry_t *cur, const u
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *nce_eui64 = ipv6_neighbour_eui64(&cur->ipv6_neighbour_cache, neigh);
|
uint8_t *nce_eui64 = ipv6_neighbour_eui64(&cur->ipv6_neighbour_cache, neigh);
|
||||||
if (neigh->state != IP_NEIGHBOUR_NEW && memcmp(nce_eui64, mac64, 8) != 0)
|
if (neigh->type == IP_NEIGHBOUR_REGISTERED && memcmp(nce_eui64, mac64, 8) != 0) {
|
||||||
{
|
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
#include "6LoWPAN/Thread/thread_joiner_application.h"
|
#include "6LoWPAN/Thread/thread_joiner_application.h"
|
||||||
#include "6LoWPAN/Thread/thread_network_data_lib.h"
|
#include "6LoWPAN/Thread/thread_network_data_lib.h"
|
||||||
#include "6LoWPAN/Thread/thread_network_data_storage.h"
|
#include "6LoWPAN/Thread/thread_network_data_storage.h"
|
||||||
#include "6LoWPAN/Thread/thread_dhcpv6_client.h"
|
#include "DHCPv6_client/dhcpv6_client_api.h"
|
||||||
#include "6LoWPAN/MAC/mac_helper.h"
|
#include "6LoWPAN/MAC/mac_helper.h"
|
||||||
#include "thread_management_if.h"
|
#include "thread_management_if.h"
|
||||||
#include "thread_meshcop_lib.h"
|
#include "thread_meshcop_lib.h"
|
||||||
|
@ -193,6 +193,7 @@ static uint16_t thread_nd_service_border_router_flags_read(thread_network_server
|
||||||
flags |= (cur->P_default_route << THREAD_P_DEF_ROUTE_BIT_MOVE);
|
flags |= (cur->P_default_route << THREAD_P_DEF_ROUTE_BIT_MOVE);
|
||||||
flags |= (cur->P_on_mesh << THREAD_P_ON_MESH_BIT_MOVE);
|
flags |= (cur->P_on_mesh << THREAD_P_ON_MESH_BIT_MOVE);
|
||||||
flags |= (cur->P_nd_dns << THREAD_P_ND_DNS_BIT_MOVE);
|
flags |= (cur->P_nd_dns << THREAD_P_ND_DNS_BIT_MOVE);
|
||||||
|
flags |= (cur->P_res1 << THREAD_P_ND_RES_BIT_MOVE);
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,8 +710,7 @@ thread_network_server_data_entry_t *thread_server_entry_get(thread_network_serve
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tr_info("New server entry made");
|
tr_info("New server entry made");
|
||||||
ns_list_foreach(thread_network_server_data_entry_t, cur, list)
|
ns_list_foreach(thread_network_server_data_entry_t, cur, list) {
|
||||||
{
|
|
||||||
if (service->routerID < cur->routerID) { //Add always longer or same length to before last one
|
if (service->routerID < cur->routerID) { //Add always longer or same length to before last one
|
||||||
//add before new
|
//add before new
|
||||||
tr_debug("Add smaller id");
|
tr_debug("Add smaller id");
|
||||||
|
@ -872,6 +872,7 @@ static int thread_service_data_delete_mark_by_router_id(thread_network_data_serv
|
||||||
|
|
||||||
static int thread_server_context_clean(int8_t id, thread_network_data_cache_entry_t *cachePtr, thread_data_context_list_t *listPtr, thread_network_data_prefix_cache_entry_t *prefixEntry, lowpan_context_list_t *context_list)
|
static int thread_server_context_clean(int8_t id, thread_network_data_cache_entry_t *cachePtr, thread_data_context_list_t *listPtr, thread_network_data_prefix_cache_entry_t *prefixEntry, lowpan_context_list_t *context_list)
|
||||||
{
|
{
|
||||||
|
(void) id;
|
||||||
int retVal = -1;
|
int retVal = -1;
|
||||||
(void) prefixEntry;
|
(void) prefixEntry;
|
||||||
ns_list_foreach_safe(thread_network_data_context_entry_t, cur, listPtr) {
|
ns_list_foreach_safe(thread_network_data_context_entry_t, cur, listPtr) {
|
||||||
|
@ -881,9 +882,7 @@ static int thread_server_context_clean(int8_t id, thread_network_data_cache_entr
|
||||||
cachePtr->stableUpdatePushed = true;
|
cachePtr->stableUpdatePushed = true;
|
||||||
}
|
}
|
||||||
// Set context lifetime to 0 to delete
|
// Set context lifetime to 0 to delete
|
||||||
if (thread_extension_context_can_delete(id, prefixEntry->servicesPrefix, cur->contextPrefixLength)) {
|
|
||||||
lowpan_context_update(context_list, cur->cid, 0, NULL, 0, true);
|
lowpan_context_update(context_list, cur->cid, 0, NULL, 0, true);
|
||||||
}
|
|
||||||
ns_list_remove(listPtr, cur);
|
ns_list_remove(listPtr, cur);
|
||||||
ns_dyn_mem_free(cur);
|
ns_dyn_mem_free(cur);
|
||||||
retVal = 0;
|
retVal = 0;
|
||||||
|
@ -930,11 +929,18 @@ static bool thread_server_data_clean_by_router_id(thread_network_data_cache_entr
|
||||||
|
|
||||||
if (cur->P_dhcp) {
|
if (cur->P_dhcp) {
|
||||||
tr_debug("Delete DHCPv6 given address");
|
tr_debug("Delete DHCPv6 given address");
|
||||||
thread_dhcp_client_global_address_delete(curInterface->id, addr, prefixEntry->servicesPrefix);
|
dhcp_client_global_address_delete(curInterface->id, addr, prefixEntry->servicesPrefix);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (cur->P_slaac) {
|
||||||
tr_debug("Delete SLAAC address");
|
tr_debug("Delete SLAAC address");
|
||||||
addr_delete_matching(curInterface, prefixEntry->servicesPrefix, 64, ADDR_SOURCE_SLAAC);
|
addr_delete_matching(curInterface, prefixEntry->servicesPrefix, 64, ADDR_SOURCE_SLAAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cur->P_res1) {
|
||||||
|
tr_debug("Delete thread domain address");
|
||||||
|
addr_delete_matching(curInterface, prefixEntry->servicesPrefix, 64, ADDR_SOURCE_THREAD_DOMAIN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ns_list_remove(listPtr, cur);
|
ns_list_remove(listPtr, cur);
|
||||||
|
@ -995,7 +1001,7 @@ void thread_network_local_server_data_base_init(thread_network_local_data_cache_
|
||||||
ns_list_init(&cachePtr->service_list);
|
ns_list_init(&cachePtr->service_list);
|
||||||
cachePtr->registered_rloc16 = 0xffff;
|
cachePtr->registered_rloc16 = 0xffff;
|
||||||
cachePtr->release_old_address = false;
|
cachePtr->release_old_address = false;
|
||||||
cachePtr->publish_active = false;
|
cachePtr->publish_coap_req_id = 0;
|
||||||
cachePtr->publish_pending = false;
|
cachePtr->publish_pending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1077,6 +1083,7 @@ bool thread_network_data_router_id_free(thread_network_data_cache_entry_t *cache
|
||||||
|
|
||||||
void thread_network_data_context_re_use_timer_update(int8_t id, thread_network_data_cache_entry_t *cachePtr, uint32_t ticks, lowpan_context_list_t *context_list)
|
void thread_network_data_context_re_use_timer_update(int8_t id, thread_network_data_cache_entry_t *cachePtr, uint32_t ticks, lowpan_context_list_t *context_list)
|
||||||
{
|
{
|
||||||
|
(void) id;
|
||||||
ns_list_foreach_safe(thread_network_data_prefix_cache_entry_t, cur, &cachePtr->localPrefixList) {
|
ns_list_foreach_safe(thread_network_data_prefix_cache_entry_t, cur, &cachePtr->localPrefixList) {
|
||||||
ns_list_foreach_safe(thread_network_data_context_entry_t, curContext, &cur->contextList) {
|
ns_list_foreach_safe(thread_network_data_context_entry_t, curContext, &cur->contextList) {
|
||||||
if (!curContext->compression) {
|
if (!curContext->compression) {
|
||||||
|
@ -1090,9 +1097,7 @@ void thread_network_data_context_re_use_timer_update(int8_t id, thread_network_d
|
||||||
cachePtr->temporaryUpdatePushed = true;
|
cachePtr->temporaryUpdatePushed = true;
|
||||||
}
|
}
|
||||||
// Set context lifetime to 0 to delete
|
// Set context lifetime to 0 to delete
|
||||||
if (thread_extension_context_can_delete(id, cur->servicesPrefix,curContext->contextPrefixLength)) {
|
|
||||||
lowpan_context_update(context_list, curContext->cid, 0, NULL, 0, true);
|
lowpan_context_update(context_list, curContext->cid, 0, NULL, 0, true);
|
||||||
}
|
|
||||||
ns_dyn_mem_free(curContext);
|
ns_dyn_mem_free(curContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1162,7 +1167,7 @@ void thread_network_local_data_free_and_clean(thread_network_local_data_cache_en
|
||||||
}
|
}
|
||||||
|
|
||||||
cachePtr->publish_pending = false;
|
cachePtr->publish_pending = false;
|
||||||
cachePtr->publish_active = false;
|
cachePtr->publish_coap_req_id = 0;
|
||||||
cachePtr->release_old_address = false;
|
cachePtr->release_old_address = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1628,6 +1633,7 @@ int thread_nd_local_list_add_on_mesh_prefix(thread_network_data_cache_entry_t *n
|
||||||
server_entry->P_nd_dns = service->P_nd_dns;
|
server_entry->P_nd_dns = service->P_nd_dns;
|
||||||
trigDataPropagate = true;
|
trigDataPropagate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trigDataPropagate) {
|
if (trigDataPropagate) {
|
||||||
|
@ -1707,9 +1713,9 @@ int thread_nd_local_list_del_on_mesh_server(thread_network_data_cache_entry_t *n
|
||||||
int thread_local_server_list_add_on_mesh_server(thread_network_local_data_cache_entry_t *networkDataList, thread_prefix_tlv_t *prefixTlv, thread_border_router_tlv_entry_t *service)
|
int thread_local_server_list_add_on_mesh_server(thread_network_local_data_cache_entry_t *networkDataList, thread_prefix_tlv_t *prefixTlv, thread_border_router_tlv_entry_t *service)
|
||||||
{
|
{
|
||||||
int retVal = -1;
|
int retVal = -1;
|
||||||
tr_debug("Add prefix: %s prf:%d %s%s%s%s%s", trace_ipv6_prefix(prefixTlv->Prefix, prefixTlv->PrefixLen), service->Prf,
|
tr_debug("Add prefix: %s prf:%d %s%s%s%s%s%s", trace_ipv6_prefix(prefixTlv->Prefix, prefixTlv->PrefixLen), service->Prf,
|
||||||
service->P_default_route ? "Default Route " : "", service->P_dhcp ? "DHCPv6 Server " : "", service->P_configure ? "DHCPv6 Configuration " : "",
|
service->P_default_route ? "Default Route " : "", service->P_dhcp ? "DHCPv6 Server " : "", service->P_configure ? "DHCPv6 Configuration " : "",
|
||||||
service->P_slaac?"SLAAC ":"",service->P_preferred?"Preferred ":"");
|
service->P_slaac ? "SLAAC " : "", service->P_preferred ? "Preferred " : "", service->P_res1 ? "P_res1 " : "");
|
||||||
|
|
||||||
if (networkDataList) {
|
if (networkDataList) {
|
||||||
thread_network_local_data_entry_t *prefix_entry = thread_local_prefix_entry_get(&networkDataList->prefix_list, prefixTlv);
|
thread_network_local_data_entry_t *prefix_entry = thread_local_prefix_entry_get(&networkDataList->prefix_list, prefixTlv);
|
||||||
|
@ -2341,7 +2347,9 @@ bool thread_nd_service_anycast_address_mapping_from_network_data(thread_network_
|
||||||
if (curService->S_id != S_id) {
|
if (curService->S_id != S_id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ns_list_foreach(thread_network_data_service_server_entry_t, curServiceServer, &curService->server_list) {
|
/* any server will do - take first from the list */
|
||||||
|
thread_network_data_service_server_entry_t *curServiceServer = ns_list_get_first(&curService->server_list);
|
||||||
|
if (curServiceServer) {
|
||||||
*rlocAddress = curServiceServer->router_id;
|
*rlocAddress = curServiceServer->router_id;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2352,7 +2360,7 @@ bool thread_nd_service_anycast_address_mapping_from_network_data(thread_network_
|
||||||
bool thread_nd_on_mesh_address_valid(thread_network_server_data_entry_t *curRoute)
|
bool thread_nd_on_mesh_address_valid(thread_network_server_data_entry_t *curRoute)
|
||||||
{
|
{
|
||||||
bool onMeshActive = false;
|
bool onMeshActive = false;
|
||||||
if (curRoute->P_dhcp || curRoute->P_slaac || curRoute->P_preferred) {
|
if (curRoute->P_dhcp || curRoute->P_slaac || curRoute->P_preferred || curRoute->P_on_mesh) {
|
||||||
onMeshActive = true;
|
onMeshActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,8 +187,8 @@ typedef struct thread_network_local_data_cache_entry_s {
|
||||||
thread_network_data_prefix_list_t prefix_list; /*!< Local parsed or generated service list */
|
thread_network_data_prefix_list_t prefix_list; /*!< Local parsed or generated service list */
|
||||||
thread_network_data_service_list_t service_list;
|
thread_network_data_service_list_t service_list;
|
||||||
uint16_t registered_rloc16;/*!< Address used for latest registration */
|
uint16_t registered_rloc16;/*!< Address used for latest registration */
|
||||||
|
uint16_t publish_coap_req_id;/*!< Non-zero when publish is active */
|
||||||
bool release_old_address: 1; /*!< true if network data can be released from old address */
|
bool release_old_address: 1; /*!< true if network data can be released from old address */
|
||||||
bool publish_active:1;/*!< true when publish is active */
|
|
||||||
bool publish_pending: 1; /*!< true when publish attempt made during active publish */
|
bool publish_pending: 1; /*!< true when publish attempt made during active publish */
|
||||||
} thread_network_local_data_cache_entry_t;
|
} thread_network_local_data_cache_entry_t;
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ uint8_t *thread_network_data_prefix_set_write(thread_network_data_cache_entry_t
|
||||||
uint8_t *thread_network_data_service_set_write(thread_network_data_cache_entry_t *networkDataList, uint8_t *ptr);
|
uint8_t *thread_network_data_service_set_write(thread_network_data_cache_entry_t *networkDataList, uint8_t *ptr);
|
||||||
bool thread_network_data_service_hosted_by_this_router_id(thread_network_data_service_cache_entry_t *dataList, uint16_t router_id);
|
bool thread_network_data_service_hosted_by_this_router_id(thread_network_data_service_cache_entry_t *dataList, uint16_t router_id);
|
||||||
uint16_t thread_network_data_service_child_id_from_networkdata_get(thread_network_data_cache_entry_t *networkDataList, uint16_t router_short_addr);
|
uint16_t thread_network_data_service_child_id_from_networkdata_get(thread_network_data_cache_entry_t *networkDataList, uint16_t router_short_addr);
|
||||||
|
thread_network_data_prefix_cache_entry_t *thread_prefix_entry_find(thread_network_prefix_list_t *list, thread_prefix_tlv_t *prefixTlv);
|
||||||
uint8_t *thread_nd_own_service_list_data_write(thread_network_local_data_cache_entry_t *serverDataList, uint8_t *ptr, uint16_t routerID);
|
uint8_t *thread_nd_own_service_list_data_write(thread_network_local_data_cache_entry_t *serverDataList, uint8_t *ptr, uint16_t routerID);
|
||||||
|
|
||||||
uint16_t thread_nd_own_service_list_data_size(thread_network_local_data_cache_entry_t *serverDataList);
|
uint16_t thread_nd_own_service_list_data_size(thread_network_local_data_cache_entry_t *serverDataList);
|
||||||
|
|
|
@ -113,8 +113,9 @@ static const char* thread_nvm_store_get_root_path(void)
|
||||||
|
|
||||||
static int root_path_valid(void)
|
static int root_path_valid(void)
|
||||||
{
|
{
|
||||||
if (NULL==ns_file_system_get_root_path())
|
if (NULL == ns_file_system_get_root_path()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
int path_len = strlen(thread_nvm_store_get_root_path());
|
int path_len = strlen(thread_nvm_store_get_root_path());
|
||||||
if (path_len == 0 || path_len > MAX_ROOT_PATH_LEN) {
|
if (path_len == 0 || path_len > MAX_ROOT_PATH_LEN) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -209,8 +210,7 @@ int thread_nvm_store_device_configuration_read(uint8_t *mac_ptr, uint8_t *mleid_
|
||||||
if (THREAD_NVM_FILE_SUCCESS == ret && DEVICE_CONF_VERSION != version) {
|
if (THREAD_NVM_FILE_SUCCESS == ret && DEVICE_CONF_VERSION != version) {
|
||||||
tr_info("fast data version mismatch %"PRIu32, version);
|
tr_info("fast data version mismatch %"PRIu32, version);
|
||||||
ret = THREAD_NVM_FILE_VERSION_WRONG;
|
ret = THREAD_NVM_FILE_VERSION_WRONG;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
memcpy(mac_ptr, d_c.mac, sizeof(d_c.mac));
|
memcpy(mac_ptr, d_c.mac, sizeof(d_c.mac));
|
||||||
memcpy(mleid_ptr, d_c.mle_id, sizeof(d_c.mle_id));
|
memcpy(mleid_ptr, d_c.mle_id, sizeof(d_c.mle_id));
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,11 @@ int thread_nvm_store_active_configuration_remove(void)
|
||||||
}
|
}
|
||||||
char ac_data_path[ACTIVE_CONF_STRING_LEN];
|
char ac_data_path[ACTIVE_CONF_STRING_LEN];
|
||||||
thread_nvm_store_create_path(ac_data_path, THREAD_NVM_ACTIVE_CONF_FILE);
|
thread_nvm_store_create_path(ac_data_path, THREAD_NVM_ACTIVE_CONF_FILE);
|
||||||
return remove(ac_data_path);
|
int status = remove(ac_data_path);
|
||||||
|
if (status != 0) {
|
||||||
|
return THREAD_NVM_FILE_REMOVE_ERROR;
|
||||||
|
}
|
||||||
|
return THREAD_NVM_FILE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_nvm_store_pending_configuration_remove(void)
|
int thread_nvm_store_pending_configuration_remove(void)
|
||||||
|
@ -302,7 +306,11 @@ int thread_nvm_store_pending_configuration_remove(void)
|
||||||
}
|
}
|
||||||
char ac_data_path[PENDING_CONF_STRING_LEN];
|
char ac_data_path[PENDING_CONF_STRING_LEN];
|
||||||
thread_nvm_store_create_path(ac_data_path, THREAD_NVM_PENDING_CONF_FILE);
|
thread_nvm_store_create_path(ac_data_path, THREAD_NVM_PENDING_CONF_FILE);
|
||||||
return remove(ac_data_path);
|
int status = remove(ac_data_path);
|
||||||
|
if (status != 0) {
|
||||||
|
return THREAD_NVM_FILE_REMOVE_ERROR;
|
||||||
|
}
|
||||||
|
return THREAD_NVM_FILE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -360,8 +368,7 @@ static int thread_nvm_store_all_counters_store(uint32_t mac_frame_counter, uint3
|
||||||
fast_data.seq_counter = network_seq_counter;
|
fast_data.seq_counter = network_seq_counter;
|
||||||
if (root_path_valid()) {
|
if (root_path_valid()) {
|
||||||
return thread_nvm_store_fast_data_save(&fast_data);
|
return thread_nvm_store_fast_data_save(&fast_data);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return THREAD_NVM_FILE_ROOT_PATH_INVALID;
|
return THREAD_NVM_FILE_ROOT_PATH_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,8 +381,7 @@ int thread_nvm_store_fast_data_write(thread_nvm_fast_data_t* fast_data)
|
||||||
|
|
||||||
if (root_path_valid()) {
|
if (root_path_valid()) {
|
||||||
return thread_nvm_store_fast_data_save(fast_data);
|
return thread_nvm_store_fast_data_save(fast_data);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return THREAD_NVM_FILE_ROOT_PATH_INVALID;
|
return THREAD_NVM_FILE_ROOT_PATH_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,8 +405,7 @@ int thread_nvm_store_fast_data_read(thread_nvm_fast_data_t* fast_data)
|
||||||
tr_info("fast data version mismatch %"PRIu32, version);
|
tr_info("fast data version mismatch %"PRIu32, version);
|
||||||
return THREAD_NVM_FILE_VERSION_WRONG;
|
return THREAD_NVM_FILE_VERSION_WRONG;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fast_data->mac_frame_counter = cached_fast_data.mac_frame_counter;
|
fast_data->mac_frame_counter = cached_fast_data.mac_frame_counter;
|
||||||
fast_data->mle_frame_counter = cached_fast_data.mle_frame_counter;
|
fast_data->mle_frame_counter = cached_fast_data.mle_frame_counter;
|
||||||
fast_data->seq_counter = cached_fast_data.seq_counter;
|
fast_data->seq_counter = cached_fast_data.seq_counter;
|
||||||
|
@ -435,8 +440,7 @@ static int thread_nvm_store_write(const char *file_name, void *data, uint32_t da
|
||||||
if (n_bytes != data_size) {
|
if (n_bytes != data_size) {
|
||||||
tr_error("NVM write error %s", file_name);
|
tr_error("NVM write error %s", file_name);
|
||||||
return THREAD_NVM_FILE_WRITE_ERROR;
|
return THREAD_NVM_FILE_WRITE_ERROR;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return THREAD_NVM_FILE_SUCCESS;
|
return THREAD_NVM_FILE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -462,8 +466,7 @@ static int thread_nvm_store_read(const char *file_name, void *data, uint32_t dat
|
||||||
if (n_bytes != data_size) {
|
if (n_bytes != data_size) {
|
||||||
tr_error("NVM read error %s", file_name);
|
tr_error("NVM read error %s", file_name);
|
||||||
return THREAD_NVM_FILE_READ_ERROR;
|
return THREAD_NVM_FILE_READ_ERROR;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return THREAD_NVM_FILE_SUCCESS; // return how many bytes was written.
|
return THREAD_NVM_FILE_SUCCESS; // return how many bytes was written.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,8 +499,7 @@ int thread_nvm_store_link_info_read(void)
|
||||||
return THREAD_NVM_FILE_READ_ERROR;
|
return THREAD_NVM_FILE_READ_ERROR;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
} else if (ACTIVE_CONF_DATA_VERSION != version) {
|
||||||
else if (ACTIVE_CONF_DATA_VERSION != version) {
|
|
||||||
tr_info("link info version mismatch %"PRIu32, version);
|
tr_info("link info version mismatch %"PRIu32, version);
|
||||||
return THREAD_NVM_FILE_VERSION_WRONG;
|
return THREAD_NVM_FILE_VERSION_WRONG;
|
||||||
}
|
}
|
||||||
|
@ -581,8 +583,7 @@ static void thread_nvm_store_link_info_delayed_write(uint32_t seconds)
|
||||||
{
|
{
|
||||||
if (cached_link_info.write_delay == LINK_INFO_WRITE_DONE) {
|
if (cached_link_info.write_delay == LINK_INFO_WRITE_DONE) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (cached_link_info.write_delay > seconds) {
|
||||||
else if (cached_link_info.write_delay > seconds) {
|
|
||||||
cached_link_info.write_delay -= seconds;
|
cached_link_info.write_delay -= seconds;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "coap_service_api.h"
|
#include "coap_service_api.h"
|
||||||
|
|
||||||
#include "thread_config.h"
|
#include "thread_config.h"
|
||||||
|
#include "thread_management_server.h"
|
||||||
#include "thread_resolution_client.h"
|
#include "thread_resolution_client.h"
|
||||||
|
|
||||||
#define TRACE_GROUP TRACE_GROUP_THREAD_RESOLUTION_CLIENT
|
#define TRACE_GROUP TRACE_GROUP_THREAD_RESOLUTION_CLIENT
|
||||||
|
@ -294,7 +295,7 @@ void thread_resolution_client_init(int8_t interface_id)
|
||||||
this->error_cb_ptr = NULL;
|
this->error_cb_ptr = NULL;
|
||||||
ns_list_init(&this->queries);
|
ns_list_init(&this->queries);
|
||||||
//TODO: Check if to use ephemeral port here
|
//TODO: Check if to use ephemeral port here
|
||||||
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_NONE, NULL, NULL);
|
this->coap_service_id = thread_management_server_service_id_get(interface_id);
|
||||||
ns_list_add_to_start(&instance_list, this);
|
ns_list_add_to_start(&instance_list, this);
|
||||||
|
|
||||||
coap_service_register_uri(this->coap_service_id, THREAD_URI_ADDRESS_NOTIFICATION, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_resolution_client_notification_post_cb);
|
coap_service_register_uri(this->coap_service_id, THREAD_URI_ADDRESS_NOTIFICATION, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_resolution_client_notification_post_cb);
|
||||||
|
@ -309,7 +310,7 @@ void thread_resolution_client_delete(int8_t interface_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_ADDRESS_NOTIFICATION);
|
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_ADDRESS_NOTIFICATION);
|
||||||
coap_service_delete(this->coap_service_id);
|
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_ADDRESS_ERROR);
|
||||||
ns_list_foreach_safe(address_query_t, query, &this->queries) {
|
ns_list_foreach_safe(address_query_t, query, &this->queries) {
|
||||||
ns_list_remove(&this->queries, query);
|
ns_list_remove(&this->queries, query);
|
||||||
ns_dyn_mem_free(query);
|
ns_dyn_mem_free(query);
|
||||||
|
@ -465,6 +466,7 @@ void thread_resolution_client_timer(int8_t interface_id, uint16_t seconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAVE_THREAD_NEIGHBOR_DISCOVERY
|
#endif // HAVE_THREAD_NEIGHBOR_DISCOVERY
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "thread_config.h"
|
#include "thread_config.h"
|
||||||
#include "thread_tmfcop_lib.h"
|
#include "thread_tmfcop_lib.h"
|
||||||
#include "thread_management_if.h"
|
#include "thread_management_if.h"
|
||||||
|
#include "thread_management_server.h"
|
||||||
#include "thread_commissioning_if.h"
|
#include "thread_commissioning_if.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,9 +171,9 @@ int thread_resolution_server_init(int8_t interface_id, thread_resolution_server_
|
||||||
}
|
}
|
||||||
|
|
||||||
this->interface_id = interface_id;
|
this->interface_id = interface_id;
|
||||||
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_NONE, NULL, NULL);
|
this->coap_service_id = thread_management_server_service_id_get(interface_id);
|
||||||
if (this->coap_service_id < 0) {
|
if (this->coap_service_id < 0) {
|
||||||
tr_warn("Thread resolution init failed");
|
tr_warn("Thread resolution srv init failed");
|
||||||
ns_dyn_mem_free(this);
|
ns_dyn_mem_free(this);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +194,6 @@ void thread_resolution_server_delete(int8_t interface_id)
|
||||||
|
|
||||||
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_ADDRESS_QUERY_REQUEST);
|
coap_service_unregister_uri(this->coap_service_id, THREAD_URI_ADDRESS_QUERY_REQUEST);
|
||||||
|
|
||||||
coap_service_delete(this->coap_service_id);
|
|
||||||
ns_list_remove(&instance_list, this);
|
ns_list_remove(&instance_list, this);
|
||||||
ns_dyn_mem_free(this);
|
ns_dyn_mem_free(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
#include "Service_Libs/nd_proxy/nd_proxy.h"
|
#include "Service_Libs/nd_proxy/nd_proxy.h"
|
||||||
#include "Service_Libs/mle_service/mle_service_api.h"
|
#include "Service_Libs/mle_service/mle_service_api.h"
|
||||||
#include "Service_Libs/blacklist/blacklist.h"
|
#include "Service_Libs/blacklist/blacklist.h"
|
||||||
#include "thread_dhcpv6_client.h"
|
#include "DHCPv6_client/dhcpv6_client_api.h"
|
||||||
#include "6LoWPAN/MAC/mac_helper.h"
|
#include "6LoWPAN/MAC/mac_helper.h"
|
||||||
#include "mac_api.h"
|
#include "mac_api.h"
|
||||||
#include "6LoWPAN/MAC/mac_data_poll.h"
|
#include "6LoWPAN/MAC/mac_data_poll.h"
|
||||||
|
@ -602,7 +602,8 @@ static int thread_router_accept_request_build(protocol_interface_info_entry_t *c
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t thread_tlv_len(protocol_interface_info_entry_t *cur, uint8_t *tlv_ptr, uint16_t tlv_len, uint8_t mode)
|
static uint16_t thread_tlv_len(protocol_interface_info_entry_t *cur, uint8_t *tlv_ptr, uint16_t tlv_len, uint8_t mode)
|
||||||
{// Calculates the extra length for bigger TLVs it is assumed that smaller ones fit in extra reserved space
|
{
|
||||||
|
// Calculates the extra length for bigger TLVs it is assumed that smaller ones fit in extra reserved space
|
||||||
uint16_t len = 0;
|
uint16_t len = 0;
|
||||||
for (uint16_t i = 0; i < tlv_len; i++) {
|
for (uint16_t i = 0; i < tlv_len; i++) {
|
||||||
if (*tlv_ptr == MLE_TYPE_ROUTE) {
|
if (*tlv_ptr == MLE_TYPE_ROUTE) {
|
||||||
|
@ -1027,10 +1028,10 @@ static void thread_bootstrap_client_router_id_cb(int8_t interface_id, int8_t sta
|
||||||
if (!cur) {
|
if (!cur) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!cur->thread_info->routerIdReqCoapID) {
|
if (!cur->thread_info->routerIdRequested) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur->thread_info->routerIdReqCoapID = 0;
|
cur->thread_info->routerIdRequested = false;
|
||||||
|
|
||||||
if (cur->thread_info->thread_device_mode != THREAD_DEVICE_MODE_ROUTER ||
|
if (cur->thread_info->thread_device_mode != THREAD_DEVICE_MODE_ROUTER ||
|
||||||
cur->thread_info->leader_private_data) {
|
cur->thread_info->leader_private_data) {
|
||||||
|
@ -1088,15 +1089,15 @@ void thread_router_bootstrap_router_id_request(protocol_interface_info_entry_t *
|
||||||
{
|
{
|
||||||
int router_id_req_status;
|
int router_id_req_status;
|
||||||
tr_debug("Router ID Request");
|
tr_debug("Router ID Request");
|
||||||
if (cur->thread_info->routerIdReqCoapID) {
|
if (cur->thread_info->routerIdRequested) {
|
||||||
tr_warn("Router ID already requested");
|
tr_warn("Router ID already requested");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
router_id_req_status = thread_management_client_router_id_get(cur->id, cur->mac, cur->thread_info->routerShortAddress, thread_bootstrap_client_router_id_cb, status);
|
router_id_req_status = thread_management_client_router_id_get(cur->id, cur->mac, cur->thread_info->routerShortAddress, thread_bootstrap_client_router_id_cb, status);
|
||||||
tr_debug("Coap address req, ID=%d", router_id_req_status);
|
tr_debug("RouterIDReq COAP ID=%d", router_id_req_status);
|
||||||
if (router_id_req_status > 0) {
|
if (router_id_req_status > 0) {
|
||||||
cur->thread_info->routerIdReqCoapID = (uint16_t)router_id_req_status;
|
cur->thread_info->routerIdRequested = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1196,6 +1197,32 @@ static int mle_attach_child_id_response_build(protocol_interface_info_entry_t *c
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int thread_router_bootstrap_child_max_timeout_get(protocol_interface_info_entry_t *cur, uint32_t *max_child_timeout)
|
||||||
|
{
|
||||||
|
uint16_t router_address = thread_info(cur)->routerShortAddress;
|
||||||
|
uint32_t max_timeout = 0;
|
||||||
|
if (router_address >= 0xfffe) {
|
||||||
|
router_address = mac_helper_mac16_address_get(cur);
|
||||||
|
}
|
||||||
|
if (router_address & THREAD_CHILD_MASK) {
|
||||||
|
return -1; //I am child
|
||||||
|
}
|
||||||
|
if (router_address >= 0xfffe) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list;
|
||||||
|
|
||||||
|
ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, mac_table_list) {
|
||||||
|
if (thread_router_addr_from_addr(cur_entry->mac16) == router_address &&
|
||||||
|
!cur_entry->ffd_device && cur_entry->lifetime > max_timeout) {
|
||||||
|
max_timeout = cur_entry->lifetime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*max_child_timeout = max_timeout;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t *cur)
|
uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t *cur)
|
||||||
{
|
{
|
||||||
uint16_t child_count = 0;
|
uint16_t child_count = 0;
|
||||||
|
@ -1277,7 +1304,7 @@ void thread_router_bootstrap_child_id_handler(protocol_interface_info_entry_t *c
|
||||||
bool new_neigbour = false;
|
bool new_neigbour = false;
|
||||||
|
|
||||||
if (cur->thread_info->thread_attached_state == THREAD_STATE_CONNECTED) {
|
if (cur->thread_info->thread_attached_state == THREAD_STATE_CONNECTED) {
|
||||||
if (!cur->thread_info->routerIdReqCoapID) {
|
if (!cur->thread_info->routerIdRequested) {
|
||||||
tr_info("Upgrade REED to Router");
|
tr_info("Upgrade REED to Router");
|
||||||
thread_router_bootstrap_router_id_request(cur, THREAD_COAP_STATUS_TLV_HAVE_CHILD_ID_REQUEST);
|
thread_router_bootstrap_router_id_request(cur, THREAD_COAP_STATUS_TLV_HAVE_CHILD_ID_REQUEST);
|
||||||
}
|
}
|
||||||
|
@ -1366,7 +1393,7 @@ static void thread_address_registration_tlv_parse(uint8_t *ptr, uint16_t data_le
|
||||||
uint8_t tempIPv6Address[16];
|
uint8_t tempIPv6Address[16];
|
||||||
uint8_t ctxId;
|
uint8_t ctxId;
|
||||||
bool new_neighbour_created;
|
bool new_neighbour_created;
|
||||||
|
thread_child_mcast_entries_remove(cur, mac64);
|
||||||
while (data_length) {
|
while (data_length) {
|
||||||
//Read
|
//Read
|
||||||
ctxId = *ptr++;
|
ctxId = *ptr++;
|
||||||
|
@ -1389,8 +1416,8 @@ static void thread_address_registration_tlv_parse(uint8_t *ptr, uint16_t data_le
|
||||||
tr_debug("Register %s", trace_ipv6(ptr));
|
tr_debug("Register %s", trace_ipv6(ptr));
|
||||||
|
|
||||||
if (addr_is_ipv6_multicast(ptr)) {
|
if (addr_is_ipv6_multicast(ptr)) {
|
||||||
// Register multicast address (higher scope than link-local)
|
// Register multicast address (link-local & higher)
|
||||||
if (addr_ipv6_multicast_scope(ptr) > IPV6_SCOPE_LINK_LOCAL) {
|
if (addr_ipv6_multicast_scope(ptr) >= IPV6_SCOPE_LINK_LOCAL) {
|
||||||
addr_add_group(cur, ptr);
|
addr_add_group(cur, ptr);
|
||||||
if (thread_child_mcast_entry_get(cur, ptr, mac64)) {
|
if (thread_child_mcast_entry_get(cur, ptr, mac64)) {
|
||||||
tr_debug("Added sleepy multicast registration entry.");
|
tr_debug("Added sleepy multicast registration entry.");
|
||||||
|
@ -1665,6 +1692,11 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(id_req->mode & MLE_FFD_DEV) && addressRegisteredTlv.tlvLen == 0) {
|
||||||
|
tr_debug("No address registration TLV in MTD child id request");
|
||||||
|
thread_child_id_request_entry_remove(cur, id_req);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
id_req->keyId = security_headers->KeyIndex;
|
id_req->keyId = security_headers->KeyIndex;
|
||||||
id_req->keySeq = common_read_32_bit(security_headers->Keysource);
|
id_req->keySeq = common_read_32_bit(security_headers->Keysource);
|
||||||
|
@ -1991,10 +2023,22 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t *
|
||||||
if (!entry_temp || !mle_tlv_read_tlv(MLE_TYPE_TLV_REQUEST, mle_msg->data_ptr, mle_msg->data_length, &requestTlv)) {
|
if (!entry_temp || !mle_tlv_read_tlv(MLE_TYPE_TLV_REQUEST, mle_msg->data_ptr, mle_msg->data_length, &requestTlv)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t mode = mle_mode_write_from_mac_entry(entry_temp);
|
||||||
|
/* check if thread neighbor class is not initialized */
|
||||||
|
if ((thread_neighbor_entry_linkmargin_get(&cur->thread_info->neighbor_class, entry_temp->index) == 0) &&
|
||||||
|
(thread_neighbor_last_communication_time_get(&cur->thread_info->neighbor_class, entry_temp->index) == 0)) {
|
||||||
|
/*
|
||||||
|
* Thread neighbor class is not yet initialized and we receive data_request from such child.
|
||||||
|
* Always send full network data in this case
|
||||||
|
*/
|
||||||
|
mode |= MLE_THREAD_REQ_FULL_DATA_SET | MLE_THREAD_SECURED_DATA_REQUEST;
|
||||||
|
} else {
|
||||||
|
mode |= thread_neighbor_class_mode_write_from_entry(&cur->thread_info->neighbor_class, entry_temp->index);
|
||||||
|
}
|
||||||
|
|
||||||
thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index, linkMargin, false);
|
thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index, linkMargin, false);
|
||||||
thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index);
|
thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index);
|
||||||
uint8_t mode = mle_mode_write_from_mac_entry(entry_temp);
|
|
||||||
mode |= thread_neighbor_class_mode_write_from_entry(&cur->thread_info->neighbor_class, entry_temp->index);
|
|
||||||
mle_build_and_send_data_response_msg(cur, mle_msg->packet_src_address, mle_msg->data_ptr, mle_msg->data_length, &requestTlv, mode);
|
mle_build_and_send_data_response_msg(cur, mle_msg->packet_src_address, mle_msg->data_ptr, mle_msg->data_length, &requestTlv, mode);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2026,8 +2070,9 @@ static int8_t thread_router_bootstrap_synch_request_send(protocol_interface_info
|
||||||
tr_debug("Buffer overflow at message write");
|
tr_debug("Buffer overflow at message write");
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout.retrans_max = THREAD_REQUEST_MAX_RETRY_CNT;
|
// timeout set to two seconds, no retries
|
||||||
timeout.timeout_init = 1;
|
timeout.retrans_max = 1;
|
||||||
|
timeout.timeout_init = 2;
|
||||||
timeout.timeout_max = 3;
|
timeout.timeout_max = 3;
|
||||||
timeout.delay = MLE_NO_DELAY;
|
timeout.delay = MLE_NO_DELAY;
|
||||||
|
|
||||||
|
@ -2325,7 +2370,6 @@ static uint32_t thread_reed_timeout_calculate(thread_router_select_t *routerSele
|
||||||
static int thread_reed_advertise(protocol_interface_info_entry_t *cur)
|
static int thread_reed_advertise(protocol_interface_info_entry_t *cur)
|
||||||
{
|
{
|
||||||
uint32_t keySequence;
|
uint32_t keySequence;
|
||||||
tr_debug("MLE REED ADVERTISEMENT STARTED");
|
|
||||||
struct link_configuration *linkConfiguration;
|
struct link_configuration *linkConfiguration;
|
||||||
linkConfiguration = thread_joiner_application_get_config(cur->id);
|
linkConfiguration = thread_joiner_application_get_config(cur->id);
|
||||||
if (!linkConfiguration) {
|
if (!linkConfiguration) {
|
||||||
|
@ -2336,11 +2380,17 @@ static int thread_reed_advertise (protocol_interface_info_entry_t *cur)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FED not allowed to send advertisements
|
||||||
|
if (thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_FULL_END_DEVICE) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t bufId = mle_service_msg_allocate(cur->id, 16, false, MLE_COMMAND_ADVERTISEMENT);
|
uint16_t bufId = mle_service_msg_allocate(cur->id, 16, false, MLE_COMMAND_ADVERTISEMENT);
|
||||||
if (bufId == 0) {
|
if (bufId == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr_debug("MLE REED ADVERTISEMENT STARTED");
|
||||||
thread_management_get_current_keysequence(cur->id, &keySequence);
|
thread_management_get_current_keysequence(cur->id, &keySequence);
|
||||||
mle_service_msg_update_security_params(bufId, 5, 2, keySequence);
|
mle_service_msg_update_security_params(bufId, 5, 2, keySequence);
|
||||||
|
|
||||||
|
@ -2360,8 +2410,9 @@ static int thread_reed_advertise (protocol_interface_info_entry_t *cur)
|
||||||
|
|
||||||
static void thread_reed_advertisements_cb(void *arg)
|
static void thread_reed_advertisements_cb(void *arg)
|
||||||
{
|
{
|
||||||
if(!arg)
|
if (!arg) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
protocol_interface_info_entry_t *cur = arg;
|
protocol_interface_info_entry_t *cur = arg;
|
||||||
|
|
||||||
cur->thread_info->routerSelectParameters.reedAdvertisementTimeout = NULL;
|
cur->thread_info->routerSelectParameters.reedAdvertisementTimeout = NULL;
|
||||||
|
@ -2383,8 +2434,9 @@ static void thread_reed_advertisements_cb(void* arg)
|
||||||
void thread_router_bootstrap_reed_advertisements_start(protocol_interface_info_entry_t *cur)
|
void thread_router_bootstrap_reed_advertisements_start(protocol_interface_info_entry_t *cur)
|
||||||
{
|
{
|
||||||
uint32_t timeout = THREAD_REED_ADVERTISEMENT_DELAY;
|
uint32_t timeout = THREAD_REED_ADVERTISEMENT_DELAY;
|
||||||
if(!cur)
|
if (!cur) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
eventOS_timeout_cancel(cur->thread_info->routerSelectParameters.reedAdvertisementTimeout);
|
eventOS_timeout_cancel(cur->thread_info->routerSelectParameters.reedAdvertisementTimeout);
|
||||||
cur->thread_info->routerSelectParameters.reedAdvertisementTimeout = NULL;
|
cur->thread_info->routerSelectParameters.reedAdvertisementTimeout = NULL;
|
||||||
|
|
||||||
|
@ -2734,4 +2786,18 @@ void thread_router_bootstrap_address_change_notify_send(protocol_interface_info_
|
||||||
thread_info(cur)->proactive_an_timer = THREAD_PROACTIVE_AN_SEND_DELAY;
|
thread_info(cur)->proactive_an_timer = THREAD_PROACTIVE_AN_SEND_DELAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void thread_router_bootstrap_delay_reed_jitter(int8_t interface_id, uint16_t delay)
|
||||||
|
{
|
||||||
|
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
|
||||||
|
if (!cur) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cur->thread_info->thread_device_mode != THREAD_DEVICE_MODE_ROUTER) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// delay reed jitter timer to allow for settings changes to distribute
|
||||||
|
thread_info(cur)->reedJitterTimer += delay;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_THREAD_ROUTER */
|
#endif /* HAVE_THREAD_ROUTER */
|
||||||
|
|
|
@ -52,6 +52,9 @@ int thread_router_bootstrap_mle_advertise(struct protocol_interface_info_entry *
|
||||||
void thread_router_bootstrap_child_information_clear(protocol_interface_info_entry_t *cur);
|
void thread_router_bootstrap_child_information_clear(protocol_interface_info_entry_t *cur);
|
||||||
int thread_router_bootstrap_reset_child_info(protocol_interface_info_entry_t *cur, struct mac_neighbor_table_entry *child);
|
int thread_router_bootstrap_reset_child_info(protocol_interface_info_entry_t *cur, struct mac_neighbor_table_entry *child);
|
||||||
uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t *cur);
|
uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t *cur);
|
||||||
|
|
||||||
|
// max_child_timeout is longest MLE Timeout a router has registered for all of its active MTD children
|
||||||
|
int thread_router_bootstrap_child_max_timeout_get(protocol_interface_info_entry_t *cur, uint32_t *max_child_timeout);
|
||||||
void thread_router_bootstrap_child_id_handler(struct protocol_interface_info_entry *cur);
|
void thread_router_bootstrap_child_id_handler(struct protocol_interface_info_entry *cur);
|
||||||
void thread_router_bootstrap_child_id_reject(struct protocol_interface_info_entry *cur);
|
void thread_router_bootstrap_child_id_reject(struct protocol_interface_info_entry *cur);
|
||||||
void thread_router_bootstrap_router_id_request(struct protocol_interface_info_entry *cur, uint8_t status);
|
void thread_router_bootstrap_router_id_request(struct protocol_interface_info_entry *cur, uint8_t status);
|
||||||
|
@ -73,6 +76,7 @@ void thread_router_bootstrap_anycast_address_register(protocol_interface_info_en
|
||||||
void thread_router_bootstrap_network_data_distribute(protocol_interface_info_entry_t *cur);
|
void thread_router_bootstrap_network_data_distribute(protocol_interface_info_entry_t *cur);
|
||||||
bool thread_router_bootstrap_routing_allowed(struct protocol_interface_info_entry *cur);
|
bool thread_router_bootstrap_routing_allowed(struct protocol_interface_info_entry *cur);
|
||||||
void thread_router_bootstrap_address_change_notify_send(protocol_interface_info_entry_t *cur);
|
void thread_router_bootstrap_address_change_notify_send(protocol_interface_info_entry_t *cur);
|
||||||
|
void thread_router_bootstrap_delay_reed_jitter(int8_t interface_id, uint16_t delay);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -81,6 +85,7 @@ void thread_router_bootstrap_address_change_notify_send(protocol_interface_info_
|
||||||
|
|
||||||
#define thread_router_bootstrap_child_information_clear(cur)
|
#define thread_router_bootstrap_child_information_clear(cur)
|
||||||
#define thread_router_bootstrap_child_count_get(cur) 0
|
#define thread_router_bootstrap_child_count_get(cur) 0
|
||||||
|
#define thread_router_bootstrap_child_max_timeout_get(cur, max_child_timeout) 0
|
||||||
#define thread_router_bootstrap_child_id_handler(cur)
|
#define thread_router_bootstrap_child_id_handler(cur)
|
||||||
#define thread_router_bootstrap_child_id_reject(cur)
|
#define thread_router_bootstrap_child_id_reject(cur)
|
||||||
#define thread_router_bootstrap_router_id_request(cur, status)
|
#define thread_router_bootstrap_router_id_request(cur, status)
|
||||||
|
@ -104,7 +109,7 @@ void thread_router_bootstrap_address_change_notify_send(protocol_interface_info_
|
||||||
#define thread_router_bootstrap_routing_allowed(cur) false
|
#define thread_router_bootstrap_routing_allowed(cur) false
|
||||||
#define thread_router_bootstrap_address_change_notify_send(cur)
|
#define thread_router_bootstrap_address_change_notify_send(cur)
|
||||||
#define thread_router_bootstrap_reed_merge_advertisement(cur)
|
#define thread_router_bootstrap_reed_merge_advertisement(cur)
|
||||||
|
#define thread_router_bootstrap_delay_reed_jitter(interface_id, delay)
|
||||||
#endif/*HAVE_THREAD_ROUTER*/
|
#endif/*HAVE_THREAD_ROUTER*/
|
||||||
|
|
||||||
#endif /* THREAD_ROUTER_BOOTSTRAP_H_ */
|
#endif /* THREAD_ROUTER_BOOTSTRAP_H_ */
|
||||||
|
|
|
@ -81,10 +81,12 @@ typedef enum {
|
||||||
/* The draft-kelsey-thread-routing-00 Link Set */
|
/* The draft-kelsey-thread-routing-00 Link Set */
|
||||||
/* XXX - probably don't need this - put it into mle_neigh_table? */
|
/* XXX - probably don't need this - put it into mle_neigh_table? */
|
||||||
typedef struct thread_router_link_s {
|
typedef struct thread_router_link_s {
|
||||||
|
// *INDENT-OFF* astyle
|
||||||
unsigned router_id : THREAD_ROUTER_ID_BITS;
|
unsigned router_id : THREAD_ROUTER_ID_BITS;
|
||||||
unsigned incoming_quality : THREAD_QUALITY_BITS;
|
unsigned incoming_quality : THREAD_QUALITY_BITS;
|
||||||
unsigned outgoing_quality : THREAD_QUALITY_BITS;
|
unsigned outgoing_quality : THREAD_QUALITY_BITS;
|
||||||
unsigned link_margin : THREAD_LINK_MARGIN_BITS;
|
unsigned link_margin : THREAD_LINK_MARGIN_BITS;
|
||||||
|
// *INDENT-ON*
|
||||||
unsigned age : 12; /* 100ms ticks, so good for ~2 hours */
|
unsigned age : 12; /* 100ms ticks, so good for ~2 hours */
|
||||||
bool outgoing_quality_known : 1;
|
bool outgoing_quality_known : 1;
|
||||||
bool as_good : 1;
|
bool as_good : 1;
|
||||||
|
@ -93,9 +95,11 @@ typedef struct thread_router_link_s {
|
||||||
|
|
||||||
/* The draft-kelsey-thread-routing-00 Route Set */
|
/* The draft-kelsey-thread-routing-00 Route Set */
|
||||||
typedef struct thread_route_s {
|
typedef struct thread_route_s {
|
||||||
|
// *INDENT-OFF* astyle
|
||||||
unsigned destination : THREAD_ROUTER_ID_BITS;
|
unsigned destination : THREAD_ROUTER_ID_BITS;
|
||||||
unsigned next_hop : THREAD_ROUTER_ID_BITS;
|
unsigned next_hop : THREAD_ROUTER_ID_BITS;
|
||||||
unsigned route_cost : THREAD_COST_BITS; /* Cost according to next_hop - doesn't include our cost to next_hop */
|
unsigned route_cost : THREAD_COST_BITS; /* Cost according to next_hop - doesn't include our cost to next_hop */
|
||||||
|
// *INDENT-ON* astyle
|
||||||
ns_list_link_t link;
|
ns_list_link_t link;
|
||||||
} thread_route_t;
|
} thread_route_t;
|
||||||
|
|
||||||
|
|
|
@ -738,8 +738,9 @@ static int thread_test_response_cb(int8_t service_id, uint8_t source_address[sta
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Call callback function when receiving response, but do not call when receiving message code "empty" (Just ACK - not piggybacked response) */
|
/* Call callback function when receiving response, but do not call when receiving message code "empty" (Just ACK - not piggybacked response) */
|
||||||
if (generic_response_cb_ptr && (response_ptr->msg_code != COAP_MSG_CODE_EMPTY))
|
if (generic_response_cb_ptr && (response_ptr->msg_code != COAP_MSG_CODE_EMPTY)) {
|
||||||
generic_response_cb_ptr(service_id, response_ptr->payload_ptr, response_ptr->payload_len);
|
generic_response_cb_ptr(service_id, response_ptr->payload_ptr, response_ptr->payload_len);
|
||||||
|
}
|
||||||
|
|
||||||
if (response_ptr->uri_path_ptr && (!memcmp(response_ptr->uri_path_ptr, THREAD_URI_DIAGNOSTIC_ANSWER, strlen(THREAD_URI_DIAGNOSTIC_ANSWER)))) {
|
if (response_ptr->uri_path_ptr && (!memcmp(response_ptr->uri_path_ptr, THREAD_URI_DIAGNOSTIC_ANSWER, strlen(THREAD_URI_DIAGNOSTIC_ANSWER)))) {
|
||||||
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, response_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, NULL, 0);
|
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, response_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, NULL, 0);
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#ifdef HAVE_RPL
|
#ifdef HAVE_RPL
|
||||||
#include "RPL/rpl_data.h"
|
#include "RPL/rpl_data.h"
|
||||||
#endif
|
#endif
|
||||||
#include "6LoWPAN/ws/ws_common.h"
|
|
||||||
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
|
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
|
||||||
#include "6LoWPAN/Thread/thread_common.h"
|
#include "6LoWPAN/Thread/thread_common.h"
|
||||||
#include "6LoWPAN/ws/ws_common.h"
|
#include "6LoWPAN/ws/ws_common.h"
|
||||||
|
@ -72,7 +71,7 @@ typedef struct {
|
||||||
bool fragmented_data: 1;
|
bool fragmented_data: 1;
|
||||||
bool first_fragment: 1;
|
bool first_fragment: 1;
|
||||||
bool indirect_data: 1;
|
bool indirect_data: 1;
|
||||||
bool indirect_data_cached:1; /* Data cached for delayed transmission as mac request is already active */
|
bool indirect_data_cached: 1; /*!< Data cached for delayed transmission as mac request is already active */
|
||||||
buffer_t *buf;
|
buffer_t *buf;
|
||||||
uint8_t *fragmenter_buf;
|
uint8_t *fragmenter_buf;
|
||||||
ns_list_link_t link; /*!< List link entry */
|
ns_list_link_t link; /*!< List link entry */
|
||||||
|
@ -132,7 +131,7 @@ static bool lowpan_adaptation_tx_process_ready(fragmenter_tx_entry_t *tx_ptr);
|
||||||
/* Fragmentation local functions */
|
/* Fragmentation local functions */
|
||||||
static int8_t lowpan_message_fragmentation_init(buffer_t *buf, fragmenter_tx_entry_t *frag_entry, protocol_interface_info_entry_t *cur, fragmenter_interface_t *interface_ptr);
|
static int8_t lowpan_message_fragmentation_init(buffer_t *buf, fragmenter_tx_entry_t *frag_entry, protocol_interface_info_entry_t *cur, fragmenter_interface_t *interface_ptr);
|
||||||
static bool lowpan_message_fragmentation_message_write(const fragmenter_tx_entry_t *frag_entry, mcps_data_req_t *dataReq);
|
static bool lowpan_message_fragmentation_message_write(const fragmenter_tx_entry_t *frag_entry, mcps_data_req_t *dataReq);
|
||||||
static void lowpan_adaptation_indirect_queue_free_message(struct protocol_interface_info_entry *cur, fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr);
|
static bool lowpan_adaptation_indirect_queue_free_message(struct protocol_interface_info_entry *cur, fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr);
|
||||||
|
|
||||||
static fragmenter_tx_entry_t *lowpan_adaptation_indirect_mac_data_request_active(fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr);
|
static fragmenter_tx_entry_t *lowpan_adaptation_indirect_mac_data_request_active(fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr);
|
||||||
|
|
||||||
|
@ -613,18 +612,21 @@ buffer_t * lowpan_adaptation_data_process_tx_preprocess(protocol_interface_info_
|
||||||
{
|
{
|
||||||
mac_neighbor_table_entry_t *neigh_entry_ptr = NULL;
|
mac_neighbor_table_entry_t *neigh_entry_ptr = NULL;
|
||||||
|
|
||||||
|
|
||||||
//Validate is link known and set indirect, datareq and security key id mode
|
//Validate is link known and set indirect, datareq and security key id mode
|
||||||
if (buf->dst_sa.addr_type == ADDR_NONE) {
|
if (buf->dst_sa.addr_type == ADDR_NONE) {
|
||||||
goto tx_error_handler;
|
goto tx_error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If MLE is enabled, we will talk if we have an MLE association */
|
if (addr_check_broadcast(buf->dst_sa.address, buf->dst_sa.addr_type) == eOK) {
|
||||||
if (buf->dst_sa.addr_type == ADDR_802_15_4_LONG ) {
|
buf->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||||
neigh_entry_ptr = mac_neighbor_table_address_discover(mac_neighbor_info(cur), buf->dst_sa.address + 2, buf->dst_sa.addr_type);
|
buf->dst_sa.address[2] = 0xff;
|
||||||
|
buf->dst_sa.address[3] = 0xff;
|
||||||
|
buf->link_specific.ieee802_15_4.indirectTxProcess = false;
|
||||||
|
buf->link_specific.ieee802_15_4.requestAck = false;
|
||||||
|
} else {
|
||||||
|
|
||||||
} else if(buf->dst_sa.addr_type == ADDR_802_15_4_SHORT && (common_read_16_bit(buf->dst_sa.address + 2)) != 0xffff) {
|
|
||||||
neigh_entry_ptr = mac_neighbor_table_address_discover(mac_neighbor_info(cur), buf->dst_sa.address + 2, buf->dst_sa.addr_type);
|
neigh_entry_ptr = mac_neighbor_table_address_discover(mac_neighbor_info(cur), buf->dst_sa.address + 2, buf->dst_sa.addr_type);
|
||||||
}
|
|
||||||
|
|
||||||
//Validate neighbour
|
//Validate neighbour
|
||||||
if (!buf->options.ll_security_bypass_tx && neigh_entry_ptr) {
|
if (!buf->options.ll_security_bypass_tx && neigh_entry_ptr) {
|
||||||
|
@ -635,18 +637,10 @@ buffer_t * lowpan_adaptation_data_process_tx_preprocess(protocol_interface_info_
|
||||||
//tr_warn("Drop TX to unassociated %s", trace_sockaddr(&buf->dst_sa, true));
|
//tr_warn("Drop TX to unassociated %s", trace_sockaddr(&buf->dst_sa, true));
|
||||||
goto tx_error_handler;
|
goto tx_error_handler;
|
||||||
}
|
}
|
||||||
|
} else if (ws_info(cur) && !neigh_entry_ptr) {
|
||||||
|
//Do not accept to send unknow device
|
||||||
|
goto tx_error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check indirect
|
|
||||||
|
|
||||||
|
|
||||||
if (addr_check_broadcast(buf->dst_sa.address, buf->dst_sa.addr_type) == eOK) {
|
|
||||||
buf->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
|
||||||
buf->dst_sa.address[2] = 0xff;
|
|
||||||
buf->dst_sa.address[3] = 0xff;
|
|
||||||
buf->link_specific.ieee802_15_4.indirectTxProcess = false;
|
|
||||||
buf->link_specific.ieee802_15_4.requestAck = false;
|
|
||||||
} else {
|
|
||||||
buf->link_specific.ieee802_15_4.requestAck = true;
|
buf->link_specific.ieee802_15_4.requestAck = true;
|
||||||
buf->link_specific.ieee802_15_4.indirectTxProcess = lowpan_adaptation_indirect_data_request(neigh_entry_ptr);
|
buf->link_specific.ieee802_15_4.indirectTxProcess = lowpan_adaptation_indirect_data_request(neigh_entry_ptr);
|
||||||
}
|
}
|
||||||
|
@ -755,7 +749,7 @@ static bool lowpan_adaptation_indirect_cache_trigger(protocol_interface_info_ent
|
||||||
ns_list_foreach(fragmenter_tx_entry_t, fragmenter_tx_entry, &interface_ptr->indirect_tx_queue) {
|
ns_list_foreach(fragmenter_tx_entry_t, fragmenter_tx_entry, &interface_ptr->indirect_tx_queue) {
|
||||||
if (fragmenter_tx_entry->indirect_data_cached) {
|
if (fragmenter_tx_entry->indirect_data_cached) {
|
||||||
if (addr_ipv6_equal(tx_ptr->buf->dst_sa.address, fragmenter_tx_entry->buf->dst_sa.address)) {
|
if (addr_ipv6_equal(tx_ptr->buf->dst_sa.address, fragmenter_tx_entry->buf->dst_sa.address)) {
|
||||||
tr_debug_extra("pushing seq %d to addr %s", fragmenter_tx_entry->buf->seq, trace_ipv6(fragmenter_tx_entry->buf->dst_sa.address));
|
tr_debug_extra("Pushing seq %d to addr %s", fragmenter_tx_entry->buf->seq, trace_ipv6(fragmenter_tx_entry->buf->dst_sa.address));
|
||||||
fragmenter_tx_entry->indirect_data_cached = false;
|
fragmenter_tx_entry->indirect_data_cached = false;
|
||||||
lowpan_data_request_to_mac(cur, fragmenter_tx_entry->buf, fragmenter_tx_entry, interface_ptr);
|
lowpan_data_request_to_mac(cur, fragmenter_tx_entry->buf, fragmenter_tx_entry, interface_ptr);
|
||||||
return true;
|
return true;
|
||||||
|
@ -805,7 +799,12 @@ static void lowpan_adaptation_make_room_for_small_packet(protocol_interface_info
|
||||||
mac_neighbor_table_entry_t *tx_neighbour = mac_neighbor_table_address_discover(mac_neighbor_info(cur), tx_entry->buf->dst_sa.address + 2, tx_entry->buf->dst_sa.addr_type);
|
mac_neighbor_table_entry_t *tx_neighbour = mac_neighbor_table_address_discover(mac_neighbor_info(cur), tx_entry->buf->dst_sa.address + 2, tx_entry->buf->dst_sa.addr_type);
|
||||||
if (tx_neighbour == neighbour_to_count && buffer_data_length(tx_entry->buf) <= interface_ptr->indirect_big_packet_threshold) {
|
if (tx_neighbour == neighbour_to_count && buffer_data_length(tx_entry->buf) <= interface_ptr->indirect_big_packet_threshold) {
|
||||||
if (++count >= interface_ptr->max_indirect_small_packets_per_child) {
|
if (++count >= interface_ptr->max_indirect_small_packets_per_child) {
|
||||||
lowpan_adaptation_indirect_queue_free_message(cur, interface_ptr, tx_entry);
|
tr_debug_extra("Purge seq: %d", tx_entry->buf->seq);
|
||||||
|
if (lowpan_adaptation_indirect_queue_free_message(cur, interface_ptr, tx_entry) == false) {
|
||||||
|
/* entry could not be purged from mac, try next entry */
|
||||||
|
tr_debug_extra("Purge failed, try next");
|
||||||
|
count--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -822,8 +821,12 @@ static void lowpan_adaptation_make_room_for_big_packet(struct protocol_interface
|
||||||
ns_list_foreach_reverse_safe(fragmenter_tx_entry_t, tx_entry, &interface_ptr->indirect_tx_queue) {
|
ns_list_foreach_reverse_safe(fragmenter_tx_entry_t, tx_entry, &interface_ptr->indirect_tx_queue) {
|
||||||
if (buffer_data_length(tx_entry->buf) > interface_ptr->indirect_big_packet_threshold) {
|
if (buffer_data_length(tx_entry->buf) > interface_ptr->indirect_big_packet_threshold) {
|
||||||
if (++count >= interface_ptr->max_indirect_big_packets_total) {
|
if (++count >= interface_ptr->max_indirect_big_packets_total) {
|
||||||
tr_debug_extra("free seq: %d", tx_entry->buf->seq);
|
tr_debug_extra("Purge seq: %d", tx_entry->buf->seq);
|
||||||
lowpan_adaptation_indirect_queue_free_message(cur, interface_ptr, tx_entry);
|
if (lowpan_adaptation_indirect_queue_free_message(cur, interface_ptr, tx_entry) == false) {
|
||||||
|
tr_debug("Purge failed, try next entry");
|
||||||
|
/* entry could not be purged from mac, try next entry */
|
||||||
|
count--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -911,6 +914,8 @@ int8_t lowpan_adaptation_interface_tx(protocol_interface_info_entry_t *cur, buff
|
||||||
if (indirect) {
|
if (indirect) {
|
||||||
ns_dyn_mem_free(tx_ptr->fragmenter_buf);
|
ns_dyn_mem_free(tx_ptr->fragmenter_buf);
|
||||||
ns_dyn_mem_free(tx_ptr);
|
ns_dyn_mem_free(tx_ptr);
|
||||||
|
} else {
|
||||||
|
tx_ptr->buf = NULL;
|
||||||
}
|
}
|
||||||
goto tx_error_handler;
|
goto tx_error_handler;
|
||||||
}
|
}
|
||||||
|
@ -1071,8 +1076,7 @@ int8_t lowpan_adaptation_interface_tx_confirm(protocol_interface_info_entry_t *c
|
||||||
|
|
||||||
//Indirect data expiration
|
//Indirect data expiration
|
||||||
if (confirm->status == MLME_TRANSACTION_EXPIRED && !active_direct_confirm) {
|
if (confirm->status == MLME_TRANSACTION_EXPIRED && !active_direct_confirm) {
|
||||||
if (buf->link_specific.ieee802_15_4.indirectTTL > 7000)
|
if (buf->link_specific.ieee802_15_4.indirectTTL > 7000) {
|
||||||
{
|
|
||||||
buf->link_specific.ieee802_15_4.indirectTTL -= 7000;
|
buf->link_specific.ieee802_15_4.indirectTTL -= 7000;
|
||||||
//Push Back to MAC
|
//Push Back to MAC
|
||||||
lowpan_data_request_to_mac(cur, buf, tx_ptr, interface_ptr);
|
lowpan_data_request_to_mac(cur, buf, tx_ptr, interface_ptr);
|
||||||
|
@ -1281,29 +1285,44 @@ static bool lowpan_tx_buffer_address_compare(sockaddr_t *dst_sa, uint8_t *addres
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lowpan_adaptation_purge_from_mac(struct protocol_interface_info_entry *cur, fragmenter_interface_t *interface_ptr, uint8_t msduhandle)
|
static bool lowpan_adaptation_purge_from_mac(struct protocol_interface_info_entry *cur, fragmenter_interface_t *interface_ptr, uint8_t msduhandle)
|
||||||
{
|
{
|
||||||
mcps_purge_t purge_req;
|
mcps_purge_t purge_req;
|
||||||
purge_req.msduHandle = msduhandle;
|
purge_req.msduHandle = msduhandle;
|
||||||
|
bool mac_purge_success = false;
|
||||||
if (interface_ptr->mpx_api) {
|
if (interface_ptr->mpx_api) {
|
||||||
interface_ptr->mpx_api->mpx_data_purge(interface_ptr->mpx_api, &purge_req, interface_ptr->mpx_user_id);
|
if (interface_ptr->mpx_api->mpx_data_purge(interface_ptr->mpx_api, &purge_req, interface_ptr->mpx_user_id) == 0) {
|
||||||
|
mac_purge_success = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cur->mac_api->mcps_purge_req) {
|
if (cur->mac_api->mcps_purge_req) {
|
||||||
cur->mac_api->mcps_purge_req(cur->mac_api, &purge_req);
|
if (cur->mac_api->mcps_purge_req(cur->mac_api, &purge_req) == 0) {
|
||||||
|
mac_purge_success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lowpan_adaptation_indirect_queue_free_message(struct protocol_interface_info_entry *cur, fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr)
|
return mac_purge_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool lowpan_adaptation_indirect_queue_free_message(struct protocol_interface_info_entry *cur, fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr)
|
||||||
{
|
{
|
||||||
tr_debug("Purge from indirect handle %u", tx_ptr->buf->seq);
|
tr_debug("Purge from indirect handle %u, cached %d", tx_ptr->buf->seq, tx_ptr->indirect_data_cached);
|
||||||
lowpan_adaptation_purge_from_mac(cur, interface_ptr, tx_ptr->buf->seq);
|
if (tx_ptr->indirect_data_cached == false) {
|
||||||
|
if (lowpan_adaptation_purge_from_mac(cur, interface_ptr, tx_ptr->buf->seq) == false) {
|
||||||
|
// MAC purge failed
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lowpan_adaptation_data_process_clean(interface_ptr, tx_ptr, SOCKET_TX_FAIL);
|
lowpan_adaptation_data_process_clean(interface_ptr, tx_ptr, SOCKET_TX_FAIL);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lowpan_adaptation_remove_free_indirect_table(protocol_interface_info_entry_t *cur_interface, mac_neighbor_table_entry_t *entry_ptr)
|
void lowpan_adaptation_remove_free_indirect_table(protocol_interface_info_entry_t *cur_interface, mac_neighbor_table_entry_t *entry_ptr)
|
||||||
{
|
{
|
||||||
//Free firts by defined short address
|
//Free first by defined short address
|
||||||
if (entry_ptr->mac16 < 0xfffe) {
|
if (entry_ptr->mac16 < 0xfffe) {
|
||||||
uint8_t temp_address[2];
|
uint8_t temp_address[2];
|
||||||
common_write_16_bit(entry_ptr->mac16, temp_address);
|
common_write_16_bit(entry_ptr->mac16, temp_address);
|
||||||
|
@ -1323,7 +1342,6 @@ int8_t lowpan_adaptation_indirect_free_messages_from_queues_by_address(struct pr
|
||||||
|
|
||||||
//Check first indirect queue
|
//Check first indirect queue
|
||||||
ns_list_foreach_safe(fragmenter_tx_entry_t, entry, &interface_ptr->indirect_tx_queue) {
|
ns_list_foreach_safe(fragmenter_tx_entry_t, entry, &interface_ptr->indirect_tx_queue) {
|
||||||
|
|
||||||
if (lowpan_tx_buffer_address_compare(&entry->buf->dst_sa, address_ptr, adr_type)) {
|
if (lowpan_tx_buffer_address_compare(&entry->buf->dst_sa, address_ptr, adr_type)) {
|
||||||
//Purge from mac
|
//Purge from mac
|
||||||
lowpan_adaptation_indirect_queue_free_message(cur, interface_ptr, entry);
|
lowpan_adaptation_indirect_queue_free_message(cur, interface_ptr, entry);
|
||||||
|
@ -1331,7 +1349,6 @@ int8_t lowpan_adaptation_indirect_free_messages_from_queues_by_address(struct pr
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t lowpan_adaptation_indirect_queue_params_set(struct protocol_interface_info_entry *cur, uint16_t indirect_big_packet_threshold, uint16_t max_indirect_big_packets_total, uint16_t max_indirect_small_packets_per_child)
|
int8_t lowpan_adaptation_indirect_queue_params_set(struct protocol_interface_info_entry *cur, uint16_t indirect_big_packet_threshold, uint16_t max_indirect_big_packets_total, uint16_t max_indirect_small_packets_per_child)
|
||||||
|
|
|
@ -35,6 +35,8 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode);
|
||||||
|
|
||||||
void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur);
|
void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur);
|
||||||
|
|
||||||
|
int ws_bootstrap_restart(int8_t interface_id);
|
||||||
|
|
||||||
/*State machine transactions*/
|
/*State machine transactions*/
|
||||||
void ws_bootstrap_event_discovery_start(protocol_interface_info_entry_t *cur);
|
void ws_bootstrap_event_discovery_start(protocol_interface_info_entry_t *cur);
|
||||||
|
|
||||||
|
@ -50,12 +52,27 @@ void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *c
|
||||||
|
|
||||||
void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds);
|
void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds);
|
||||||
|
|
||||||
void ws_bootstrap_trigle_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
|
void ws_bootstrap_trickle_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
|
||||||
|
|
||||||
|
void ws_primary_parent_update(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neighbor);
|
||||||
|
|
||||||
|
void ws_secondary_parent_update(protocol_interface_info_entry_t *interface);
|
||||||
|
|
||||||
|
void ws_nud_entry_remove_active(protocol_interface_info_entry_t *cur, void *neighbor);
|
||||||
|
|
||||||
|
void ws_nud_active_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
|
||||||
|
|
||||||
|
void ws_dhcp_client_address_request(protocol_interface_info_entry_t *cur, uint8_t *prefix, uint8_t *parent_link_local);
|
||||||
|
|
||||||
|
void ws_dhcp_client_address_delete(protocol_interface_info_entry_t *cur, uint8_t *prefix);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define ws_bootstrap_init(interface_id, bootstrap_mode) (-1)
|
#define ws_bootstrap_init(interface_id, bootstrap_mode) (-1)
|
||||||
#define ws_bootstrap_state_machine(cur)
|
#define ws_bootstrap_state_machine(cur)
|
||||||
|
#define ws_bootstrap_restart(cur)
|
||||||
|
#define ws_primary_parent_update(interface, neighbor)
|
||||||
|
#define ws_secondary_parent_update(interface)
|
||||||
|
|
||||||
#endif //HAVE_WS
|
#endif //HAVE_WS
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,13 @@
|
||||||
|
|
||||||
|
|
||||||
#include "ns_types.h"
|
#include "ns_types.h"
|
||||||
|
#include "ns_list.h"
|
||||||
#include "fhss_api.h"
|
#include "fhss_api.h"
|
||||||
#include "fhss_config.h"
|
#include "fhss_config.h"
|
||||||
#include "net_fhss.h"
|
#include "net_fhss.h"
|
||||||
#include "6LoWPAN/ws/ws_common_defines.h"
|
#include "6LoWPAN/ws/ws_common_defines.h"
|
||||||
#include "6LoWPAN/ws/ws_neighbor_class.h"
|
#include "6LoWPAN/ws/ws_neighbor_class.h"
|
||||||
|
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
|
||||||
|
|
||||||
struct ws_pan_information_s;
|
struct ws_pan_information_s;
|
||||||
struct ws_neighbor_class_s;
|
struct ws_neighbor_class_s;
|
||||||
|
@ -40,6 +42,17 @@ typedef struct parent_info_s {
|
||||||
uint32_t timestamp; /**< Timestamp when packet was received */
|
uint32_t timestamp; /**< Timestamp when packet was received */
|
||||||
} parent_info_t;
|
} parent_info_t;
|
||||||
|
|
||||||
|
typedef struct ws_nud_table_entry {
|
||||||
|
void *neighbor_info;
|
||||||
|
uint16_t timer; /*!< Timer which resolution is 100ms*/
|
||||||
|
unsigned retry_count: 2;
|
||||||
|
bool wait_response: 1; /*!< True when NS is sended and wait NA, False when random timer is active*/
|
||||||
|
bool nud_process;
|
||||||
|
ns_list_link_t link;
|
||||||
|
} ws_nud_table_entry_t;
|
||||||
|
|
||||||
|
typedef NS_LIST_HEAD(ws_nud_table_entry_t, link) ws_nud_table_list_t;
|
||||||
|
|
||||||
typedef struct ws_info_s {
|
typedef struct ws_info_s {
|
||||||
char network_name[33]; // Network name max 32 octets + terminating 0.
|
char network_name[33]; // Network name max 32 octets + terminating 0.
|
||||||
uint16_t network_pan_id;
|
uint16_t network_pan_id;
|
||||||
|
@ -54,8 +67,24 @@ typedef struct ws_info_s {
|
||||||
uint32_t pan_version_timer; /**< border router version udate timeout */
|
uint32_t pan_version_timer; /**< border router version udate timeout */
|
||||||
uint32_t pan_version_timeout_timer; /**< routers will fallback to previous state after this */
|
uint32_t pan_version_timeout_timer; /**< routers will fallback to previous state after this */
|
||||||
uint8_t gtkhash[32];
|
uint8_t gtkhash[32];
|
||||||
|
bool address_registration_event_active : 1;
|
||||||
bool configuration_learned: 1;
|
bool configuration_learned: 1;
|
||||||
|
bool trickle_pas_running: 1;
|
||||||
|
bool trickle_pa_running: 1;
|
||||||
|
bool trickle_pcs_running: 1;
|
||||||
|
bool trickle_pc_running: 1;
|
||||||
|
// default fhss parameters for this device
|
||||||
|
uint8_t fhss_uc_dwell_interval;
|
||||||
|
uint8_t fhss_bc_dwell_interval;
|
||||||
|
uint32_t fhss_bc_interval;
|
||||||
|
uint8_t fhss_uc_channel_function;
|
||||||
|
uint8_t fhss_bc_channel_function;
|
||||||
|
uint16_t fhss_uc_fixed_channel;
|
||||||
|
uint16_t fhss_bc_fixed_channel;
|
||||||
|
uint32_t fhss_channel_mask[8];
|
||||||
|
ws_nud_table_entry_t nud_table_entrys[ACTIVE_NUD_PROCESS_MAX];
|
||||||
|
ws_nud_table_list_t active_nud_process;
|
||||||
|
ws_nud_table_list_t free_nud_entries;
|
||||||
struct ws_pan_information_s pan_information;
|
struct ws_pan_information_s pan_information;
|
||||||
ws_hopping_schedule_t hopping_schdule;
|
ws_hopping_schedule_t hopping_schdule;
|
||||||
struct ws_neighbor_class_s neighbor_storage;
|
struct ws_neighbor_class_s neighbor_storage;
|
||||||
|
@ -65,6 +94,8 @@ typedef struct ws_info_s {
|
||||||
|
|
||||||
#ifdef HAVE_WS
|
#ifdef HAVE_WS
|
||||||
|
|
||||||
|
int8_t ws_generate_channel_list(uint32_t *channel_mask, uint16_t number_of_channels, uint8_t regulatory_domain);
|
||||||
|
|
||||||
int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur);
|
int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur);
|
||||||
|
|
||||||
int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur);
|
int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue