Skip to content

Commit c2df001

Browse files
authored
Merge pull request #11423 from JarkkoPaso/nanostack_release_for_mbedos_5_14
Nanostack release for mbedos 5 14
2 parents 21ebb72 + 4ebbbc5 commit c2df001

37 files changed

+920
-225
lines changed

features/nanostack/sal-stack-nanostack/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ override CFLAGS += -I$(EVENTLOOP_DIR)/nanostack-event-loop
3737
override CFLAGS += -I$(NSDL_DIR)/nsdl-c
3838
override CFLAGS += -I$(COAP_DIR)
3939
override CFLAGS += -I$(COAP_SERVICE_LIB)/coap-service
40-
override CFLAGS += -I$(MBEDTLS_DIR)/include
40+
override CFLAGS += -I$(MBEDTLS_DIR)/include -I$(MBEDTLS_DIR)/crypto/include
4141
override CFLAGS += $(addprefix -I,$(INCLUDE_DIRS))
4242
override CFLAGS += $(addprefix -D,$(FLAGS))
4343

@@ -153,7 +153,7 @@ mbed-release-build-$(1): $(1)-$(2)-$(3)-build
153153
.PHONY: $(1)-$(2)-build
154154
$(1)-$(2)-$(3)-build: export-headers
155155
@echo Build $(2) on $(1) for $(3)
156-
make CC=$(CC_$(1)) CONFIG=$(2) CPU=$(3) APPEND_LIB_NAME=1 CFLAGS="-DNS_USE_EXTERNAL_MBED_TLS -I../mbedtls/include/"
156+
make CC=$(CC_$(1)) CONFIG=$(2) CPU=$(3) APPEND_LIB_NAME=1 CFLAGS="-DNS_USE_EXTERNAL_MBED_TLS -I../mbedtls/include/ -I../crypto/include/"
157157

158158
# Generate target directory name
159159
# Like: FEATURE_NANOSTACK/FEATURE_LOWPAN_ROUTER/TOOLCHAIN_ARM/TARGET_CORTEX_M0P

features/nanostack/sal-stack-nanostack/nanostack/ws_bbr_api.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,24 @@ int ws_bbr_node_keys_remove(int8_t interface_id, uint8_t *eui64);
120120
*/
121121
int ws_bbr_node_access_revoke_start(int8_t interface_id);
122122

123+
/**
124+
* Set EAPOL node limit
125+
*
126+
* Border router stores EAPOL key information for each authenticated node.
127+
* Sets the maximum number of EAPOL nodes stored by border router. If count
128+
* of node's exceed the limit, border router deletes the node information
129+
* starting from oldest node (node that has authenticated longest time
130+
* ago), to make room for new nodes. When network keys are updated, nodes
131+
* which have been removed from storage, must make full authentication again.
132+
* Value for this parameter should be set to be more than maximum amount of
133+
* nodes that are expected to be connected to border router.
134+
*
135+
* \param interface_id Network interface ID.
136+
* \param limit Limit for nodes
137+
*
138+
* \return 0, Node limit set
139+
* \return <0 Node limit set failed.
140+
*/
141+
int ws_bbr_eapol_node_limit_set(int8_t interface_id, uint16_t limit);
142+
123143
#endif /* WS_BBR_API_H_ */

features/nanostack/sal-stack-nanostack/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ int8_t arm_6lowpan_bootstarp_bootstrap_set(int8_t interface_id, net_6lowpan_mode
17871787
*/
17881788
if (cur->lowpan_info & INTERFACE_NWK_ROUTER_DEVICE) {
17891789
//rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, true);
1790-
//rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, cur);
1790+
//rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, NULL, cur);
17911791
}
17921792
#endif
17931793
cur->configure_flags |= INTERFACE_BOOTSTRAP_DEFINED;
@@ -2182,7 +2182,7 @@ void nwk_6lowpan_nd_address_registartion_ready(protocol_interface_info_entry_t *
21822182
// arm_nwk_6lowpan_rpl_dodag_poison from a previous connection may have left force_leaf set
21832183
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, false);
21842184
rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, true);
2185-
rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, cur);
2185+
rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, NULL, cur);
21862186
}
21872187
// Send unicast DIS to coordinator
21882188
nwk_bootstrap_icmp_rpl_dis_coord_msg_tx(cur);

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ int ws_bbr_node_keys_remove(int8_t interface_id, uint8_t *eui64)
609609
{
610610
(void) interface_id;
611611
(void) eui64;
612-
613612
#ifdef HAVE_WS_BORDER_ROUTER
614613
return ws_pae_controller_node_keys_remove(interface_id, eui64);
615614
#else
@@ -620,11 +619,20 @@ int ws_bbr_node_keys_remove(int8_t interface_id, uint8_t *eui64)
620619
int ws_bbr_node_access_revoke_start(int8_t interface_id)
621620
{
622621
(void) interface_id;
623-
624622
#ifdef HAVE_WS_BORDER_ROUTER
625623
return ws_pae_controller_node_access_revoke_start(interface_id);
626624
#else
627625
return -1;
628626
#endif
629627
}
630628

629+
int ws_bbr_eapol_node_limit_set(int8_t interface_id, uint16_t limit)
630+
{
631+
(void) interface_id;
632+
#ifdef HAVE_WS_BORDER_ROUTER
633+
return ws_pae_controller_node_limit_set(interface_id, limit);
634+
#else
635+
(void) limit;
636+
return -1;
637+
#endif
638+
}

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 75 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp
8181
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur);
8282
static int8_t ws_bootsrap_event_trig(ws_bootsrap_event_type_e event_type, int8_t interface_id, arm_library_event_priority_e priority, void *event_data);
8383

84-
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new, bool multicast);
84+
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new);
8585
static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entry_t *cur);
8686
static uint16_t ws_bootstrap_rank_get(protocol_interface_info_entry_t *cur);
8787
static uint16_t ws_bootstrap_min_rank_inc_get(protocol_interface_info_entry_t *cur);
@@ -97,13 +97,15 @@ static void ws_bootstrap_pan_version_increment(protocol_interface_info_entry_t *
9797
static ws_nud_table_entry_t *ws_nud_entry_discover(protocol_interface_info_entry_t *cur, void *neighbor);
9898
static void ws_nud_entry_remove(protocol_interface_info_entry_t *cur, mac_neighbor_table_entry_t *entry_ptr);
9999
static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data);
100+
static bool ws_rpl_dio_new_parent_accept(struct protocol_interface_info_entry *interface);
100101

101102
typedef enum {
102103
WS_PARENT_SOFT_SYNCH = 0, /**< let FHSS make decision if synchronization is needed*/
103104
WS_PARENT_HARD_SYNCH, /**< Synch FHSS with latest synch information*/
104105
WS_EAPOL_PARENT_SYNCH, /**< Broadcast synch with EAPOL parent*/
105106
} ws_parent_synch_e;
106107

108+
107109
static void ws_bootsrap_create_ll_address(uint8_t *ll_address, const uint8_t *mac64)
108110
{
109111
memcpy(ll_address, ADDR_LINK_LOCAL_PREFIX, 8);
@@ -925,7 +927,7 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
925927
// Save route cost for all neighbours
926928
llc_neighbour_req_t neighbor_info;
927929
neighbor_info.neighbor = NULL;
928-
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false, false)) {
930+
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) {
929931
neighbor_info.ws_neighbor->routing_cost = pan_information.routing_cost;
930932
}
931933

@@ -1080,10 +1082,10 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
10801082

10811083
if (cur->ws_info->configuration_learned || cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
10821084
//If we are border router or learned configuration we only update already learned neighbours.
1083-
neighbour_pointer_valid = ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false, true);
1085+
neighbour_pointer_valid = ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false);
10841086

10851087
} else {
1086-
neighbour_pointer_valid = ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, true, true);
1088+
neighbour_pointer_valid = ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, true);
10871089
if (!neighbour_pointer_valid) {
10881090
return;
10891091
}
@@ -1169,7 +1171,7 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
11691171
*/
11701172

11711173
llc_neighbour_req_t neighbor_info;
1172-
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false, false)) {
1174+
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) {
11731175
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index);
11741176
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, ws_utt, data->timestamp);
11751177
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us);
@@ -1366,19 +1368,10 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13661368
}
13671369
}
13681370

1369-
uint32_t link_min_timeout;
13701371
//Read current timestamp
13711372
uint32_t time_from_last_unicast_shedule = ws_time_from_last_unicast_traffic(current_time_stamp, ws_neighbor);
13721373

1373-
1374-
if (cur->trusted_device) {
1375-
link_min_timeout = WS_NEIGHBOR_TRUSTED_LINK_MIN_TIMEOUT;
1376-
} else {
1377-
1378-
link_min_timeout = WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT;
1379-
}
1380-
1381-
if (time_from_last_unicast_shedule > link_min_timeout || !ws_neighbor->unicast_data_rx) {
1374+
if (time_from_last_unicast_shedule > WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT || !ws_neighbor->unicast_data_rx) {
13821375
//Accept only Enough Old Device
13831376
if (!neighbor_entry_ptr) {
13841377
//Accept first compare
@@ -1399,8 +1392,9 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13991392

14001393
}
14011394

1402-
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new, bool multicast)
1395+
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new)
14031396
{
1397+
neighbor_buffer->ws_neighbor = NULL;
14041398
neighbor_buffer->neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), mac_64, ADDR_802_15_4_LONG);
14051399
if (neighbor_buffer->neighbor) {
14061400
neighbor_buffer->ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor_buffer->neighbor->index);
@@ -1421,27 +1415,6 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en
14211415
return false;
14221416
}
14231417

1424-
if (multicast) {
1425-
//for multicast neighbour we must limit if we have already enough information
1426-
if (interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
1427-
//Border router never allocate neighbors by multicast
1428-
return false;
1429-
}
1430-
1431-
uint16_t parent_candidate_size = rpl_control_parent_candidate_list_size(interface, false);
1432-
1433-
//if we have enough candidates at list do not accept new multicast neighbours
1434-
if (parent_candidate_size >= 4) {
1435-
return false;
1436-
}
1437-
1438-
parent_candidate_size = rpl_control_parent_candidate_list_size(interface, true);
1439-
//If we have already enough parent selected Candidates count is bigger tahn 4
1440-
if (parent_candidate_size >= 2) {
1441-
return false;
1442-
}
1443-
}
1444-
14451418
ws_bootstrap_neighbor_table_clean(interface);
14461419

14471420
neighbor_buffer->neighbor = ws_bootstrap_mac_neighbor_add(interface, mac_64);
@@ -1458,6 +1431,24 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en
14581431
return true;
14591432
}
14601433

1434+
static bool ws_rpl_dio_new_parent_accept(struct protocol_interface_info_entry *interface)
1435+
{
1436+
uint16_t parent_candidate_size = rpl_control_parent_candidate_list_size(interface, false);
1437+
//TODO check bootstarap state for review
1438+
//if we have enough candidates at list do not accept new multicast neighbours
1439+
if (parent_candidate_size > WS_NEIGHBOUR_MAX_CANDIDATE_PROBE) {
1440+
return false;
1441+
}
1442+
1443+
parent_candidate_size = rpl_control_parent_candidate_list_size(interface, true);
1444+
//If we have already enough parent selected Candidates count is bigger tahn 4
1445+
if (parent_candidate_size >= 2) {
1446+
return false;
1447+
}
1448+
1449+
return true;
1450+
}
1451+
14611452

14621453
static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data)
14631454
{
@@ -2010,6 +2001,48 @@ static void ws_rpl_prefix_callback(prefix_entry_t *prefix, void *handle, uint8_t
20102001
}
20112002
}
20122003

2004+
static bool ws_rpl_new_parent_callback_t(uint8_t *ll_parent_address, void *handle)
2005+
{
2006+
2007+
protocol_interface_info_entry_t *cur = handle;
2008+
if (!cur->rpl_domain || cur->interface_mode != INTERFACE_UP) {
2009+
return false;
2010+
}
2011+
2012+
uint8_t mac64[8];
2013+
memcpy(mac64, ll_parent_address + 8, 8);
2014+
mac64[0] ^= 2;
2015+
llc_neighbour_req_t neigh_buffer;
2016+
if (ws_bootstrap_neighbor_info_request(cur, mac64, &neigh_buffer, false)) {
2017+
return true;
2018+
}
2019+
2020+
if (!ws_rpl_dio_new_parent_accept(cur)) {
2021+
return false;
2022+
}
2023+
2024+
//Discover Multicast temporary entry
2025+
2026+
ws_neighbor_temp_class_t *entry = ws_llc_get_multicast_temp_entry(cur, mac64);
2027+
if (!entry) {
2028+
return false;
2029+
}
2030+
//Create entry
2031+
bool create_ok = ws_bootstrap_neighbor_info_request(cur, mac64, &neigh_buffer, true);
2032+
if (create_ok) {
2033+
ws_neighbor_class_entry_t *ws_neigh = neigh_buffer.ws_neighbor;
2034+
//Copy fhss temporary data
2035+
*ws_neigh = entry->neigh_info_list;
2036+
//ETX Create here
2037+
etx_lqi_dbm_update(cur->id, entry->mpduLinkQuality, entry->signal_dbm, neigh_buffer.neighbor->index);
2038+
mac_neighbor_table_trusted_neighbor(mac_neighbor_info(cur), neigh_buffer.neighbor, true);
2039+
}
2040+
ws_llc_free_multicast_temp_entry(cur, entry);
2041+
2042+
2043+
return create_ok;
2044+
}
2045+
20132046
static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
20142047
{
20152048
tr_debug("RPL Activate");
@@ -2018,7 +2051,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
20182051

20192052
addr_add_router_groups(cur);
20202053
rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, downstream);
2021-
rpl_control_set_callback(protocol_6lowpan_rpl_domain, ws_bootstrap_rpl_callback, ws_rpl_prefix_callback, cur);
2054+
rpl_control_set_callback(protocol_6lowpan_rpl_domain, ws_bootstrap_rpl_callback, ws_rpl_prefix_callback, ws_rpl_new_parent_callback_t, cur);
20222055
// If i am router I Do this
20232056
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, leaf);
20242057
rpl_control_request_parent_link_confirmation(true);
@@ -2493,6 +2526,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
24932526
cur->ws_info->trickle_pas_running = false;
24942527
cur->ws_info->trickle_pcs_running = false;
24952528

2529+
// Indicate PAE controller that bootstrap is ready
2530+
ws_pae_controller_bootstrap_done(cur);
2531+
24962532
ws_bootstrap_advertise_start(cur);
24972533
ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE);
24982534
break;
@@ -2520,7 +2556,7 @@ void ws_bootstrap_network_scan_process(protocol_interface_info_entry_t *cur)
25202556

25212557
// Add EAPOL neighbour
25222558
llc_neighbour_req_t neighbor_info;
2523-
if (!ws_bootstrap_neighbor_info_request(cur, cur->ws_info->parent_info.addr, &neighbor_info, true, false)) {
2559+
if (!ws_bootstrap_neighbor_info_request(cur, cur->ws_info->parent_info.addr, &neighbor_info, true)) {
25242560
return;
25252561
}
25262562

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "6LoWPAN/ws/ws_common.h"
2828
#include "6LoWPAN/ws/ws_bootstrap.h"
2929
#include "6LoWPAN/ws/ws_bbr_api_internal.h"
30+
#include "6LoWPAN/ws/ws_pae_controller.h"
3031
#include "Service_Libs/etx/etx.h"
3132
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
3233
#include "Service_Libs/blacklist/blacklist.h"
@@ -327,7 +328,7 @@ void ws_common_network_size_configure(protocol_interface_info_entry_t *cur, uint
327328
} else {
328329
ws_bbr_rpl_config(0, 0, 0);
329330
}
330-
331+
ws_pae_controller_timing_adjust(1); // Fast and reactive network
331332
} else if (network_size < 300) {
332333
// Configure the Wi-SUN discovery trickle parameters
333334
cur->ws_info->trickle_params_pan_discovery = trickle_params_pan_discovery_medium;
@@ -336,6 +337,7 @@ void ws_common_network_size_configure(protocol_interface_info_entry_t *cur, uint
336337
// doublings:5 (960s)
337338
// redundancy; 10
338339
ws_bbr_rpl_config(15, 5, 10);
340+
ws_pae_controller_timing_adjust(9); // medium limited network
339341
} else {
340342
// Configure the Wi-SUN discovery trickle parameters
341343
cur->ws_info->trickle_params_pan_discovery = trickle_params_pan_discovery_large;
@@ -344,6 +346,7 @@ void ws_common_network_size_configure(protocol_interface_info_entry_t *cur, uint
344346
// doublings:1 (1048s, 17 min)
345347
// redundancy; 10 May need some tuning still
346348
ws_bbr_rpl_config(19, 1, 10);
349+
ws_pae_controller_timing_adjust(24); // Very slow and high latency network
347350
}
348351
return;
349352
}
@@ -423,7 +426,7 @@ bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, con
423426
}
424427
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbour->index);
425428
ws_neighbor->negative_aro_send = true;
426-
neighbour->lifetime = WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT; //Remove anyway if Packet is freed before MAC push
429+
neighbour->lifetime = WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT; //Remove anyway if Packet is freed before MAC push
427430
return true;
428431
}
429432

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,5 @@ uint32_t ws_common_version_timeout_get(uint8_t config);
143143
#define ws_common_etx_validate(interface, neigh) ((void) 0)
144144
#define ws_common_negative_aro_mark(interface, eui64)(false)
145145

146-
147146
#endif //HAVE_WS
148147
#endif //WS_COMMON_H_

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ typedef struct ws_bs_ie {
186186
#define WS_FAN_VERSION_1_0 1
187187

188188
#define WS_NEIGHBOR_LINK_TIMEOUT 2200
189-
#define WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT 60
190-
#define WS_NEIGHBOR_TRUSTED_LINK_MIN_TIMEOUT 15
189+
#define WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT 120
191190
#define WS_NEIGHBOR_NUD_TIMEOUT WS_NEIGHBOR_LINK_TIMEOUT / 2
192191

193192
#define WS_NEIGBOR_ETX_SAMPLE_MAX 3

0 commit comments

Comments
 (0)