Skip to content

Commit 3e6cb31

Browse files
author
Jarkko Paso
committed
Squashed 'features/nanostack/sal-stack-nanostack/' changes from c473148..0824752
0824752 Merge branch 'release_internal' into release_external f598339 Merge branch 'master' into release_internal 678e0fd Removed unicast RX flag set. it was affecting that we remove neighbor too early. a4317fc Corrected coding style cd2848e Added support for calculating the length of the TLS send message buffer f255931 Removed UDP echo msg data print and added source address print. adcca3d RPL dio config advertisment update 6db1f31 Merge pull request #2198 from ARMmbed/IOTTHD-3691 ad244d1 MAC: changed CCA and TX fail trace level to debug 496074a RPL parent select update: 32e22d3 MAC: Added trace to when CCA fails and packet TX is canceled 47b2e03 Corrected GKH initiation on supplicant c83423a PAE controller now removes keys from MAC on stop (ifdown) a6f98b7 Flagged extended key usage call with mbedTLS flags 0675a89 Added dynamic setting to enable certificate validation ff531d3 Added IDevID and LDevID certificate validation b30635f Merge pull request #2191 from ARMmbed/IOTTHD-3693 88019ec Updated message generated traces ea15b0e Remove all instances when domain is disbaled and clear EAPOL relay. dce25d3 Corrected security protocols init and security message routing 7b39e25 Do not trig Renew again after RPL parent registration done state. 3cad7bd DHCPv6 renew and transaction id update c5b6df3 DHCPv6 client update dea0d53 DHCPv6 client API update 5eaad10 Added missing address active flag init. 34c751b Corrected triggering of next GTK handshake on authenticator 4fad826 Corrected export keys callback parameters 26c10a6 SW MAC / 802.15.4 Frame counter per key support Update b62b120 Added robustness on DAO-ACK handling dfcebef Added support for new certificate modification functions fd4b2e9 WS ARO handler update e2d46b9 wi-sun neagtive ARO missing ACK update 443f03f Merge pull request #2181 from ARMmbed/IOTTHD-3530_2 f36da31 MAC: Update frame counter for asynch frames 3260fa1 Merge pull request #2177 from ARMmbed/IOTTHD-3530 f18052a MAC: Initialize frame counter with 0xffffffff 5453e5b MAC: Do not increment framecounter if security param init fails 5bd19c4 MAC: Do not update framecounter for fhss channel retry git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: 0824752
1 parent 396dae5 commit 3e6cb31

Some content is hidden

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

54 files changed

+1171
-184
lines changed

nanostack/dhcp_service_api.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ void dhcp_service_update_server_address(uint32_t msg_tr_id, uint8_t *server_addr
217217
*/
218218
void dhcp_service_req_remove(uint32_t msg_tr_id);
219219

220+
/**
221+
* \brief Stops transactions for a messages (retransmissions).
222+
*
223+
* Clears off sending retransmissions for a particular message transaction by finding it via its message class pointer.
224+
*
225+
* \param msg_class_ptr The message class pointer.
226+
*
227+
*/
228+
void dhcp_service_req_remove_all(void *msg_class_ptr);
229+
220230
/**
221231
* \brief Timer tick function for retransmissions.
222232
*

nanostack/sw_mac.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ extern int ns_sw_mac_phy_statistics_start(struct mac_api_s *mac_api, struct phy_
9797
*/
9898
extern uint32_t ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api);
9999

100+
/**
101+
* @brief Enable or disable Frame counter per security key. SW MAC must be create before enable this feature!
102+
* @param mac_api MAC instance.
103+
* @param enable_feature True will allocate frame counter table for devices / key False will clear mode and free counter table.
104+
* @return 0 on success, -1 on fail.
105+
*/
106+
extern int8_t ns_sw_mac_enable_frame_counter_per_key(struct mac_api_s *mac_api, bool enable_feature);
107+
100108
#ifdef __cplusplus
101109
}
102110
#endif

nanostack/ws_bbr_api.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,26 @@ int ws_bbr_node_access_revoke_start(int8_t interface_id);
140140
*/
141141
int ws_bbr_eapol_node_limit_set(int8_t interface_id, uint16_t limit);
142142

143+
/**
144+
* Extended certificate validation
145+
*/
146+
#define BBR_CRT_EXT_VALID_NONE 0x00 /**< Do not make extended validations */
147+
#define BBR_CRT_EXT_VALID_WISUN 0x01 /**< Validate Wi-SUN specific fields */
148+
149+
/**
150+
* Sets extended certificate validation setting
151+
*
152+
* Sets extended certificate validation setting on border router. Function can be used
153+
* to set which fields on client certificate are validated.
154+
*
155+
* \param interface_id Network interface ID
156+
* \param validation Extended Certificate validation setting
157+
* BBR_CRT_EXT_VALID_NONE Do not make extended validations
158+
* BBR_CRT_EXT_VALID_WISUN Validate Wi-SUN specific fields
159+
*
160+
* \return 0 Validation setting was set
161+
* \return <0 Setting set failed
162+
*/
163+
int ws_bbr_ext_certificate_validation_set(int8_t interface_id, uint8_t validation);
164+
143165
#endif /* WS_BBR_API_H_ */

source/6LoWPAN/MAC/mac_helper.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,12 @@ int8_t mac_helper_security_default_recv_key_set(protocol_interface_info_entry_t
349349
return 0;
350350
}
351351

352-
int8_t mac_helper_security_auto_request_key_index_set(protocol_interface_info_entry_t *interface, uint8_t id)
352+
int8_t mac_helper_security_auto_request_key_index_set(protocol_interface_info_entry_t *interface, uint8_t key_attibute_index, uint8_t id)
353353
{
354354
if (id == 0) {
355355
return -1;
356356
}
357-
357+
interface->mac_parameters->mac_default_key_attribute_id = key_attibute_index;
358358
mac_helper_pib_8bit_set(interface, macAutoRequestKeyIndex, id);
359359
return 0;
360360
}
@@ -442,13 +442,11 @@ void mac_helper_security_key_swap_next_to_default(protocol_interface_info_entry_
442442
interface->mac_parameters->mac_prev_key_index = interface->mac_parameters->mac_default_key_index;
443443
interface->mac_parameters->mac_prev_key_attribute_id = interface->mac_parameters->mac_default_key_attribute_id;
444444

445-
interface->mac_parameters->mac_default_key_index = interface->mac_parameters->mac_next_key_index;
446-
interface->mac_parameters->mac_default_key_attribute_id = interface->mac_parameters->mac_next_key_attribute_id;
445+
mac_helper_security_auto_request_key_index_set(interface, interface->mac_parameters->mac_next_key_attribute_id, interface->mac_parameters->mac_next_key_index);
446+
447447
interface->mac_parameters->mac_next_key_index = 0;
448448
interface->mac_parameters->mac_next_key_attribute_id = prev_attribute;
449449

450-
mac_helper_pib_8bit_set(interface, macAutoRequestKeyIndex, interface->mac_parameters->mac_default_key_index);
451-
452450
}
453451

454452
void mac_helper_security_key_clean(protocol_interface_info_entry_t *interface)
@@ -841,7 +839,7 @@ int8_t mac_helper_link_frame_counter_read(int8_t interface_id, uint32_t *seq_ptr
841839
}
842840
mlme_get_t get_req;
843841
get_req.attr = macFrameCounter;
844-
get_req.attr_index = 0;
842+
get_req.attr_index = cur->mac_parameters->mac_default_key_attribute_id;
845843
cur->mac_api->mlme_req(cur->mac_api, MLME_GET, &get_req);
846844
*seq_ptr = cur->mac_parameters->security_frame_counter;
847845

@@ -858,7 +856,7 @@ int8_t mac_helper_link_frame_counter_set(int8_t interface_id, uint32_t seq_ptr)
858856
}
859857
mlme_set_t set_req;
860858
set_req.attr = macFrameCounter;
861-
set_req.attr_index = 0;
859+
set_req.attr_index = cur->mac_parameters->mac_default_key_attribute_id;
862860
set_req.value_pointer = &seq_ptr;
863861
set_req.value_size = 4;
864862
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_req);

source/6LoWPAN/MAC/mac_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int8_t mac_helper_security_default_key_set(struct protocol_interface_info_entry
6969

7070
int8_t mac_helper_security_default_recv_key_set(struct protocol_interface_info_entry *interface, const uint8_t *key, uint8_t id, uint8_t keyid_mode);
7171

72-
int8_t mac_helper_security_auto_request_key_index_set(struct protocol_interface_info_entry *interface, uint8_t id);
72+
int8_t mac_helper_security_auto_request_key_index_set(struct protocol_interface_info_entry *interface, uint8_t key_attibute_index, uint8_t id);
7373

7474
int8_t mac_helper_security_next_key_set(struct protocol_interface_info_entry *interface, uint8_t *key, uint8_t id, uint8_t keyid_mode);
7575

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,3 +636,18 @@ int ws_bbr_eapol_node_limit_set(int8_t interface_id, uint16_t limit)
636636
return -1;
637637
#endif
638638
}
639+
640+
int ws_bbr_ext_certificate_validation_set(int8_t interface_id, uint8_t validation)
641+
{
642+
(void) interface_id;
643+
#ifdef HAVE_WS_BORDER_ROUTER
644+
bool enabled = false;
645+
if (validation & BBR_CRT_EXT_VALID_WISUN) {
646+
enabled = true;
647+
}
648+
return ws_pae_controller_ext_certificate_validation_set(interface_id, enabled);
649+
#else
650+
(void) validation;
651+
return -1;
652+
#endif
653+
}

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13711371
//Read current timestamp
13721372
uint32_t time_from_last_unicast_shedule = ws_time_from_last_unicast_traffic(current_time_stamp, ws_neighbor);
13731373

1374-
if (time_from_last_unicast_shedule > WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT || !ws_neighbor->unicast_data_rx) {
1374+
if (time_from_last_unicast_shedule > WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT) {
13751375
//Accept only Enough Old Device
13761376
if (!neighbor_entry_ptr) {
13771377
//Accept first compare
@@ -1581,6 +1581,10 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
15811581
return -2;
15821582
}
15831583

1584+
if (ns_sw_mac_enable_frame_counter_per_key(cur->mac_api, true)) {
1585+
return -1;
1586+
}
1587+
15841588
if (!etx_storage_list_allocate(cur->id, buffer.device_decription_table_size)) {
15851589
return -1;
15861590
}
@@ -1940,6 +1944,9 @@ static void ws_dhcp_client_global_adress_cb(int8_t interface, uint8_t dhcp_addr[
19401944
if (cur) {
19411945
rpl_control_register_address(cur, prefix);
19421946
}
1947+
} else {
1948+
//Delete dhcpv6 client
1949+
dhcp_client_global_address_delete(interface, dhcp_addr, prefix);
19431950
}
19441951
}
19451952

@@ -2055,6 +2062,9 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
20552062
// If i am router I Do this
20562063
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, leaf);
20572064
rpl_control_request_parent_link_confirmation(true);
2065+
rpl_control_set_dio_multicast_min_config_advertisment_count(WS_MIN_DIO_MULTICAST_CONFIG_ADVERTISMENT_COUNT);
2066+
rpl_control_set_dao_retry_count(WS_MAX_DAO_RETRIES);
2067+
rpl_control_set_initial_dao_ack_wait(WS_MAX_DAO_INITIAL_TIMEOUT);
20582068

20592069
cur->ws_info->rpl_state = 0xff; // Set invalid state and learn from event
20602070
}
@@ -2107,7 +2117,9 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur)
21072117
ws_bootstrap_neighbor_list_clean(cur);
21082118

21092119
// Clear RPL information
2110-
rpl_control_remove_domain_from_interface(cur);
2120+
rpl_control_free_domain_instances_from_interface(cur);
2121+
// Clear EAPOL relay address
2122+
ws_eapol_relay_delete(cur);
21112123

21122124
// Clear ip stack from old information
21132125
ws_bootstrap_ip_stack_reset(cur);
@@ -2169,7 +2181,7 @@ static void ws_bootstrap_nw_key_clear(protocol_interface_info_entry_t *cur, uint
21692181
static void ws_bootstrap_nw_key_index_set(protocol_interface_info_entry_t *cur, uint8_t index)
21702182
{
21712183
// Set send key
2172-
mac_helper_security_auto_request_key_index_set(cur, index + 1);
2184+
mac_helper_security_auto_request_key_index_set(cur, index, index + 1);
21732185
}
21742186

21752187
static void ws_bootstrap_nw_frame_counter_set(protocol_interface_info_entry_t *cur, uint32_t counter)

source/6LoWPAN/ws/ws_common.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "Service_Libs/etx/etx.h"
3232
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
3333
#include "Service_Libs/blacklist/blacklist.h"
34+
#include "RPL/rpl_protocol.h"
35+
#include "RPL/rpl_control.h"
3436
#include "ws_management_api.h"
3537
#include "mac_api.h"
3638

@@ -404,6 +406,13 @@ bool ws_common_allow_child_registration(protocol_interface_info_entry_t *interfa
404406
return true;
405407
}
406408

409+
//Verify that we have Selected Parent
410+
if (interface->bootsrap_mode != ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER && !rpl_control_parent_candidate_list_size(interface, true)) {
411+
tr_info("Do not accept new ARO child: no selected parent");
412+
return false;
413+
}
414+
415+
407416
ns_list_foreach_safe(mac_neighbor_table_entry_t, cur, &mac_neighbor_info(interface)->neighbour_list) {
408417

409418
if (ipv6_neighbour_has_registered_by_eui64(&interface->ipv6_neighbour_cache, cur->mac64)) {

source/6LoWPAN/ws/ws_config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,12 @@ extern uint8_t DEVICE_MIN_SENS;
133133
#define FRAME_COUNTER_INCREMENT 1000 // How much frame counter is incremented on start up
134134
#define FRAME_COUNTER_STORE_THRESHOLD 800 // How much frame counter must increment before it is stored
135135

136+
137+
/*
138+
* RPL Configuration parameters
139+
*/
140+
#define WS_MAX_DAO_RETRIES 3 // With 40s, 80s, 160s, 320s, 640s
141+
#define WS_MAX_DAO_INITIAL_TIMEOUT 400 // With 40s initial value exponentially increasing
142+
#define WS_MIN_DIO_MULTICAST_CONFIG_ADVERTISMENT_COUNT 10 // Define 10 multicast advertisment when learn config or learn config update
143+
136144
#endif /* WS_CONFIG_H_ */

source/6LoWPAN/ws/ws_pae_auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,12 @@ static void ws_pae_auth_next_kmp_trigger(pae_auth_t *pae_auth, supp_entry_t *sup
919919

920920
kmp_api_t *api = ws_pae_lib_kmp_list_type_get(&supp_entry->kmp_list, next_type);
921921
if (api != NULL) {
922+
/* For other types than GTK, only one ongoing negotiation at the same time,
923+
for GTK there can be previous terminating and the new one for next key index */
922924
if (next_type != IEEE_802_11_GKH) {
923925
tr_info("KMP already ongoing; ignored, eui-64: %s", trace_array(supp_entry->addr.eui_64, 8));
924926
return;
925927
}
926-
// Delete KMP
927-
ws_pae_lib_kmp_list_delete(&supp_entry->kmp_list, api);
928928
}
929929
}
930930

0 commit comments

Comments
 (0)