Skip to content

Commit 0724863

Browse files
author
Jarkko Paso
committed
Merge branch 'master' into IOTTHD-3027
* master: (50 commits) Added empty function for test Added support for ARO registration failure Added empty function fr new interface Added api to configure network size parameters Flagged mbed TLS KW header and corrected bool definitions Corrected NIST AES KW flagging Removed temporary KW functions and corrected ut and style Added GKH MIC validation and encryption Moved 4WH functions to library and added constants Added unit test to NIST AES KW library added parent priority handling. (#1942) Fix coverity error (#1943) thread_mle_message_handler: fix build warning (#1940) Follow Mbed OS coding style (#1941) Sync mbed_lib.json with Mbed OS (#1935) Added Wi-Sun flagging to eapol helper Disabled EAPOL flags Tuned EAPOL timers for small networks added Wi-SUN neighbor table management to Wi-SUN Corrected KMP api start on authenticator ...
2 parents 65ccc41 + acce0dd commit 0724863

File tree

125 files changed

+12198
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+12198
-136
lines changed

mbed_lib.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
{
22
"name": "nanostack",
33
"config": {
4-
"configuration": "nanostack_full"
4+
"configuration": {
5+
"help": "Build time configuration. Refer to Handbook for valid values. Default: full stack",
6+
"value": "nanostack_full"
7+
}
58
},
6-
"macros": ["NS_USE_EXTERNAL_MBED_TLS"]
9+
"macros": ["NS_USE_EXTERNAL_MBED_TLS"],
10+
"target_overrides": {
11+
"KW24D": {
12+
"nanostack.configuration": "lowpan_router"
13+
},
14+
"NCS36510": {
15+
"nanostack.configuration": "lowpan_router"
16+
},
17+
"TB_SENSE_12": {
18+
"nanostack.configuration": "lowpan_router"
19+
},
20+
"KW41Z": {
21+
"nanostack.configuration": "lowpan_router"
22+
}
23+
}
724
}

nanostack/net_thread_test.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,30 @@ int thread_test_mle_message_send(int8_t interface_id, uint8_t *dst_address, uint
530530
* \return <0 Failure
531531
*/
532532
int thread_test_extension_name_set(int8_t interface_id, char extension_name[16]);
533+
534+
/**
535+
* \brief Set multicast addresses per message.
536+
*
537+
* \param value Number of addresses per message (valid range 1-15)
538+
*
539+
* \return 0 OK
540+
* \return <0 Failure
541+
*/
542+
int8_t thread_test_mcast_address_per_message_set(uint8_t value);
543+
544+
/**
545+
* Thread router parent priority set.
546+
*
547+
* This function is used to set parent priority in connectivity TLV.
548+
*
549+
* \param interface_id Network interface ID.
550+
* \param parent_priority value to be set (0x40 High, 0x00 Medium, 0xC0 Low, 0x80 Do not use) .
551+
*
552+
* \return 0, Set OK.
553+
* \return <0 Set Fail.
554+
*/
555+
int thread_test_parent_priority_set(int8_t interface_id, uint8_t parent_priority);
556+
533557
#ifdef __cplusplus
534558
}
535559
#endif

nanostack/net_ws_test.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern "C" {
4040
#include "ns_types.h"
4141

4242
/**
43-
* \brief Set extension name.
43+
* \brief Set Pan size.
4444
*
4545
* Pan size is reported to advertisement. Using this function
4646
* actual value can be overridden.
@@ -54,6 +54,24 @@ extern "C" {
5454
* \return <0 Failure
5555
*/
5656
int ws_test_pan_size_set(int8_t interface_id, uint16_t pan_size);
57+
58+
/**
59+
* \brief Set maximum child count.
60+
*
61+
* Maximum amount of children allowed for this device
62+
*
63+
* Values above MAC neighbor table - RPL parents - temporary entries will cause undefined behaviour
64+
*
65+
* Set child count to 0xffff to stop override
66+
*
67+
* \param interface_id Network Interface
68+
* \param child_count Pan size reported in advertisements
69+
*
70+
* \return 0 OK
71+
* \return <0 Failure
72+
*/
73+
int ws_test_max_child_count_set(int8_t interface_id, uint16_t child_count);
74+
5775
#ifdef __cplusplus
5876
}
5977
#endif

nanostack/ws_management_api.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ extern "C" {
7575
#define CHANNEL_SPACING_100 0x03 // 100 khz
7676
#define CHANNEL_SPACING_250 0x04 // 250 khz
7777

78+
#define NETWORK_SIZE_AUTOMATIC 0x00
79+
#define NETWORK_SIZE_SMALL 0x01
80+
#define NETWORK_SIZE_LARGE 0x10
81+
7882

7983
/** Temporary API change flag. this will be removed when new version of API is implemented on applications
8084
*
@@ -126,6 +130,27 @@ int ws_management_regulatory_domain_set(
126130
uint8_t operating_class,
127131
uint8_t operating_mode);
128132

133+
/**
134+
* Set timing parameters related to network size.
135+
*
136+
* timing parameters follows the specification example from Wi-SUN specification
137+
*
138+
* Default value: automatic
139+
* small network size: hundreds of devices
140+
* Large network size: thousands of devices
141+
* automatic: when discovering the network network size is learned
142+
* from advertisements and timings adjusted accordingly
143+
*
144+
* \param interface_id Network interface ID.
145+
* \param network_size define from NETWORK_SIZE_*.
146+
*
147+
* \return 0, Init OK.
148+
* \return <0 Init fail.
149+
*/
150+
int ws_management_network_size_set(
151+
int8_t interface_id,
152+
uint8_t network_size);
153+
129154
/**
130155
* Set channel mask for FHSS operation.
131156
*

source/6LoWPAN/ND/nd_router_object.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,12 @@ bool nd_ns_aro_handler(protocol_interface_info_entry_t *cur_interface, const uin
923923
}
924924

925925
/* TODO - check hard upper limit on registrations? */
926+
if (ws_info(cur_interface) &&
927+
!ws_common_allow_child_registration(cur_interface)) {
928+
aro_out->present = true;
929+
aro_out->status = ARO_FULL;
930+
return true;
931+
}
926932

927933
/* We need to have entry in the Neighbour Cache */
928934
ipv6_neighbour_t *neigh = ipv6_neighbour_lookup_or_create(&cur_interface->ipv6_neighbour_cache, src_addr);

source/6LoWPAN/Thread/thread_common.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ int thread_info_allocate_and_init(protocol_interface_info_entry_t *cur)
484484
cur->thread_info->version = thread_version; // Default implementation version
485485
cur->thread_info->thread_device_mode = THREAD_DEVICE_MODE_END_DEVICE;
486486
cur->thread_info->childUpdateReqTimer = -1;
487+
cur->thread_info->parent_priority = CONNECTIVITY_PP_INVALID; // default invalid - calculated using child count
487488

488489
thread_routing_init(&cur->thread_info->routing);
489490
thread_network_local_server_data_base_init(&cur->thread_info->localServerDataBase);
@@ -1245,7 +1246,9 @@ uint8_t *thread_connectivity_tlv_write(uint8_t *ptr, protocol_interface_info_ent
12451246
*ptr++ = 10;
12461247

12471248
// determine parent priority
1248-
if ((mode & MLE_DEV_MASK) == MLE_RFD_DEV && (3 * mle_class_rfd_entry_count_get(cur) > 2 * THREAD_MAX_MTD_CHILDREN)) {
1249+
if ((thread->parent_priority & CONNECTIVITY_PP_MASK) != CONNECTIVITY_PP_INVALID) {
1250+
*ptr++ = thread->parent_priority & CONNECTIVITY_PP_MASK;
1251+
} else if ((mode & MLE_DEV_MASK) == MLE_RFD_DEV && (3 * mle_class_rfd_entry_count_get(cur) > 2 * THREAD_MAX_MTD_CHILDREN)) {
12491252
*ptr++ = CONNECTIVITY_PP_LOW;
12501253
} else if (!(mode & MLE_RX_ON_IDLE) && (3 * mle_class_sleepy_entry_count_get(cur) > 2 * THREAD_MAX_SED_CHILDREN)) {
12511254
*ptr++ = CONNECTIVITY_PP_LOW;

source/6LoWPAN/Thread/thread_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct mac_neighbor_table_entry;
6868
#define THREAD_KEY_INDEX(seq) ((uint8_t) (((seq) & 0x0000007f) + 1))
6969

7070
extern uint8_t thread_version;
71+
extern uint8_t thread_max_mcast_addr;
7172
extern uint32_t thread_delay_timer_default;
7273
extern uint32_t thread_router_selection_jitter;
7374
extern uint16_t thread_joiner_port;
@@ -316,6 +317,7 @@ typedef struct thread_info_s {
316317
//uint8_t lastValidRouteMask[8];
317318
int8_t interface_id; //Thread Interface ID
318319
uint8_t version;
320+
uint8_t parent_priority;
319321
uint8_t testMaxActiveRouterIdLimit; //Default for this is 32
320322
uint8_t maxChildCount; //Default for this is 24
321323
uint8_t partition_weighting;

source/6LoWPAN/Thread/thread_constants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,6 @@
186186
/** Thread prefix minimum lifetime in seconds */
187187
#define THREAD_MIN_PREFIX_LIFETIME 3600
188188

189+
#define THREAD_MCAST_ADDR_PER_MSG 4 // One multicast registration message fits 4 addresses by default
190+
189191
#endif /* THREAD_CONSTANTS_H_ */

source/6LoWPAN/Thread/thread_extension.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ static void thread_extension_reset_timeout_cb(void *arg)
210210
// Delete all domain stuff and start discovery.
211211
thread_extension_bootstrap_network_certificate_set(cur, NULL, 0);
212212
thread_extension_bootstrap_network_private_key_set(cur, NULL, 0);
213-
thread_nvm_store_active_configuration_remove();
214213
thread_nvm_store_mleid_rloc_map_remove();
215-
thread_nvm_store_pending_configuration_remove();
216214
thread_nvm_store_link_info_clear();
217215
thread_joiner_application_link_configuration_delete(cur->id);
218216
thread_bootstrap_connection_error(cur->id, CON_ERROR_NETWORK_KICK, NULL);
@@ -295,8 +293,6 @@ static int thread_extension_reenroll_req_cb(int8_t service_id, uint8_t source_ad
295293
goto send_response;
296294
}
297295

298-
299-
300296
thread_extension_bootstrap_reenrollment_start(cur, service_id, pbbr_addr);
301297

302298
send_response:
@@ -674,8 +670,6 @@ bool thread_extension_aloc_map(protocol_interface_info_entry_t *cur, uint16_t *a
674670
}
675671
return false;
676672
}
677-
// Amount of Addressess in MLR message 4 fits in one fragment
678-
#define ADDR_PER_MSG 4
679673

680674
void thread_extension_mcast_subscrition_change(protocol_interface_info_entry_t *interface)
681675
{
@@ -688,7 +682,7 @@ void thread_extension_mcast_subscrition_change(protocol_interface_info_entry_t *
688682
if (0 != thread_extension_primary_bbr_get(interface, br_ml_addr, NULL, &mlr_timer, NULL)) {
689683
return;
690684
}
691-
addr = ns_dyn_mem_temporary_alloc(16 * ADDR_PER_MSG + 2);
685+
addr = ns_dyn_mem_temporary_alloc(16 * thread_max_mcast_addr + 2);
692686
if (!addr) {
693687
return;
694688
}
@@ -708,7 +702,7 @@ void thread_extension_mcast_subscrition_change(protocol_interface_info_entry_t *
708702
ptr += 16;
709703
addr_len = ptr - addr;
710704
addr[1] = addr_len - 2;// Fill in the length
711-
if (addr_len > 16 * ADDR_PER_MSG) {
705+
if (addr_len > 16 * thread_max_mcast_addr) {
712706
// Send first patch
713707
thread_extension_mlr_req_send(interface, br_ml_addr, addr, addr_len);
714708
// Reset the packet to start

source/6LoWPAN/Thread/thread_extension_bbr.c

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
typedef struct {
7070
uint8_t pbbr_multicast_address[16];
7171
uint8_t tri_address[16];
72+
uint8_t registrar_address[16];
7273
uint8_t domain_prefix[8];
7374
uint32_t mlr_timeout;
7475
uint32_t delay_timer;
@@ -317,6 +318,7 @@ static int thread_pbbr_data_req_recv_cb(int8_t service_id, uint8_t source_addres
317318
(void) source_port;
318319

319320
uint8_t payload_ptr[18] = {0};
321+
uint8_t *address_ptr;
320322
uint8_t *request_tlv_ptr;
321323
uint16_t request_tlv_len;
322324
uint8_t *ptr = payload_ptr;
@@ -326,6 +328,8 @@ static int thread_pbbr_data_req_recv_cb(int8_t service_id, uint8_t source_addres
326328
return -1;
327329
}
328330

331+
tr_debug("MGMT_BBR_GET.req received");
332+
329333
request_tlv_len = thread_tmfcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_GET, &request_tlv_ptr);
330334

331335
if (0 == request_tlv_len) {
@@ -335,7 +339,14 @@ static int thread_pbbr_data_req_recv_cb(int8_t service_id, uint8_t source_addres
335339

336340
if (thread_meshcop_tlv_list_type_available(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_REGISTRAR_IPV6_ADDRESS)) {
337341
tr_debug("Registrar IPv6 address requested");
338-
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_REGISTRAR_IPV6_ADDRESS, 16, this->tri_address);
342+
// If registrar address is not set, return TRI address
343+
if (addr_is_ipv6_unspecified(this->registrar_address)) {
344+
address_ptr = this->tri_address;
345+
} else {
346+
address_ptr = this->registrar_address;
347+
}
348+
349+
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_REGISTRAR_IPV6_ADDRESS, 16, address_ptr);
339350
}
340351

341352
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr);
@@ -348,6 +359,35 @@ static int thread_pbbr_data_set_recv_cb(int8_t service_id, uint8_t source_addres
348359
(void) source_address;
349360
(void) source_port;
350361

362+
uint8_t response[3] = {0};
363+
uint8_t *ptr = response;
364+
int8_t response_code = -1;
365+
uint8_t *registrar_addr = NULL;
366+
thread_pbbr_t *this = thread_border_router_find_by_service(service_id);
367+
368+
if (!request_ptr || !this) {
369+
return -1;
370+
}
371+
372+
tr_debug("MGMT_BBR_SET.req received");
373+
374+
if (16 == thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_REGISTRAR_IPV6_ADDRESS, &registrar_addr)) {
375+
memcpy(this->registrar_address, registrar_addr, 16);
376+
response_code = 1;
377+
}
378+
379+
ptr = thread_meshcop_tlv_data_write_uint8(response, MESHCOP_TLV_STATE, response_code);
380+
381+
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, response, ptr - response);
382+
383+
return 0;
384+
}
385+
386+
static int thread_pbbr_sec_data_set_recv_cb(int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *request_ptr)
387+
{
388+
(void) source_address;
389+
(void) source_port;
390+
351391
uint8_t response[3] = {0};
352392
uint8_t *ptr = response;
353393

@@ -1144,7 +1184,9 @@ static int thread_extension_bbr_pbbr_start(thread_pbbr_t *this)
11441184
coap_service_register_uri(this->coap_service_id, THREAD_URI_BBR_NMK_RX_NTF, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_pbbr_nmkp_relay_rx_recv_cb);
11451185
// Register BBR data request URI
11461186
coap_service_register_uri(this->coap_service_id, THREAD_URI_BBR_DATA_REQ, COAP_SERVICE_ACCESS_GET_ALLOWED, thread_pbbr_data_req_recv_cb);
1147-
coap_service_register_uri(this->coap_service_id, THREAD_URI_BBR_DATA_SET, COAP_SERVICE_ACCESS_GET_ALLOWED, thread_pbbr_data_set_recv_cb);
1187+
coap_service_register_uri(this->coap_service_id, THREAD_URI_BBR_DATA_SET, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_pbbr_data_set_recv_cb);
1188+
coap_service_register_uri(this->coap_service_id, THREAD_URI_MGMT_SEC_PENDING_SET, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_pbbr_sec_data_set_recv_cb);
1189+
11481190

11491191
// create secure service for Network master key provisioning
11501192
this->coap_nmkp_virtual_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_SECURE | COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET, thread_pbbr_pskd_security_start_cb, NULL);
@@ -1182,6 +1224,7 @@ int8_t thread_extension_bbr_init(int8_t interface_id, int8_t backbone_interface_
11821224
this->pbbr_started = false;
11831225
memcpy(this->pbbr_multicast_address, ADDR_LINK_LOCAL_ALL_ROUTERS, 16);
11841226
this->pbbr_port = THREAD_BBR_BACKBONE_PORT;
1227+
memset(this->registrar_address, 0, 16);
11851228
memcpy(this->tri_address, ADDR_LINK_LOCAL_ALL_ROUTERS, 16);
11861229
this->tri_port = THREAD_BBR_BACKBONE_PORT;
11871230
this->joiner_router_rloc = 0xffff;

0 commit comments

Comments
 (0)