Skip to content

Commit d207f4d

Browse files
author
Arto Kinnunen
committed
Merge branch 'release_internal' into release_external
* release_internal: MPL: buffered max limit increased to 8k (ARMmbed#2482) Fixed Unit test's LLC drop a packet if FHSS shedule is not configured. Fixed missing asynch trigle setup stop at if down process Wi-SUN fhss API default value setting fixes Fixed coverity issues from management API Corrected out of bounds access coverity warning (ARMmbed#2475) Multicast forwarding is separated from the routing flag Wi-SUN discovery staten enter upxdate Iotthd 4308 (ARMmbed#2473) Removed time increment from NVM time read function on interface up fhss_tx_handle update Fixed UFSI update print function (ARMmbed#2470) FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469) Corrected defects and coding style Corrected trace macro Distributed key storage NVM writes to longer time period FHSS WS: handle blocked interrupts (ARMmbed#2466) Added validation at MAC ack buffer handler DNS configuration lifetime validation
2 parents 09d9e24 + d166c89 commit d207f4d

23 files changed

+334
-124
lines changed

nanostack/ws_management_api.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ int ws_management_channel_plan_set(
382382
*
383383
* Change the default configuration for Wi-SUN FHSS operation.
384384
*
385+
* Calling with fhss_uc_dwell_interval = 0, fhss_broadcast_interval = 0xffffffff,
386+
* fhss_bc_dwell_interval = 0 restores stack defaults
385387
*
386388
* \param interface_id Network interface ID.
387389
* \param fhss_uc_dwell_interval default to 250 ms.
@@ -403,6 +405,7 @@ int ws_management_fhss_timing_configure(
403405
* Change the default configuration for Wi-SUN FHSS operation.
404406
* if application defined is used the behaviour is undefined
405407
*
408+
* Calling with dwell_interval = 0, channel_function = 0xff, fixed_channel = 0xffff restores stack defaults
406409
*
407410
* \param interface_id Network interface ID.
408411
* \param channel_function Unicast channel function.
@@ -458,6 +461,8 @@ int ws_management_fhss_unicast_channel_function_validate(
458461
* Change the default configuration for Wi-SUN FHSS operation.
459462
* if application defined is used the behaviour is undefined
460463
*
464+
* Calling with dwell_interval = 0, channel_function = 0xff,
465+
* broadcast_interval = 0xffffffff, fixed_channel = 0xffff restores stack defaults
461466
*
462467
* \param interface_id Network interface ID.
463468
* \param channel_function Broadcast channel function.

source/6LoWPAN/Thread/thread_bbr_api.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,14 @@ static void thread_bbr_network_data_send(thread_bbr_t *this, uint8_t prefix[8],
629629

630630
static void thread_bbr_routing_enable(thread_bbr_t *this, bool multicast_routing_enabled)
631631
{
632+
// Start multicast proxying
633+
// We do not enable multicast forwarding as there is other default router present in network
634+
multicast_fwd_set_forwarding(this->interface_id, multicast_routing_enabled);
635+
632636
if (this->routing_enabled) {
633637
return;
634638
}
635639
tr_info("br: enable routing");
636-
// Start multicast proxying
637-
// We do not enable multicast forwarding as there is other default router present in network
638-
multicast_fwd_set_forwarding(this->interface_id, multicast_routing_enabled);
639640
this->routing_enabled = true;
640641
}
641642

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,15 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
10451045
return ret_val;
10461046
}
10471047

1048+
static void ws_bootstrap_asynch_trickle_stop(protocol_interface_info_entry_t *cur)
1049+
{
1050+
cur->ws_info->trickle_pas_running = false;
1051+
cur->ws_info->trickle_pa_running = false;
1052+
cur->ws_info->trickle_pcs_running = false;
1053+
cur->ws_info->trickle_pc_running = false;
1054+
cur->ws_info->trickle_pc_consistency_block_period = 0;
1055+
}
1056+
10481057
static int8_t ws_bootstrap_down(protocol_interface_info_entry_t *cur)
10491058
{
10501059
if (!cur || !(cur->lowpan_info & INTERFACE_NWK_ACTIVE)) {
@@ -1058,7 +1067,7 @@ static int8_t ws_bootstrap_down(protocol_interface_info_entry_t *cur)
10581067
ns_fhss_delete(cur->ws_info->fhss_api);
10591068
cur->ws_info->fhss_api = NULL;
10601069
// Reset WS information
1061-
// ws_common_reset(cur)
1070+
ws_bootstrap_asynch_trickle_stop(cur);
10621071
ws_llc_reset(cur);
10631072
if (nd_proxy_downstream_interface_unregister(cur->id) != 0) {
10641073
tr_warn("nd proxy unregister failed");
@@ -1103,11 +1112,7 @@ void ws_bootstrap_configuration_reset(protocol_interface_info_entry_t *cur)
11031112

11041113
cur->nwk_bootstrap_state = ER_ACTIVE_SCAN;
11051114
cur->ws_info->network_pan_id = 0xffff;
1106-
cur->ws_info->trickle_pas_running = false;
1107-
cur->ws_info->trickle_pa_running = false;
1108-
cur->ws_info->trickle_pcs_running = false;
1109-
cur->ws_info->trickle_pc_running = false;
1110-
cur->ws_info->trickle_pc_consistency_block_period = 0;
1115+
ws_bootstrap_asynch_trickle_stop(cur);
11111116

11121117
//cur->mac_security_key_usage_update_cb = ws_management_mac_security_key_update_cb;
11131118
return;
@@ -3228,6 +3233,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
32283233
case WS_DISCOVERY_START:
32293234
tr_info("Discovery start");
32303235

3236+
protocol_mac_reset(cur);
3237+
ws_llc_reset(cur);
3238+
lowpan_adaptation_interface_reset(cur->id);
32313239
//Clear Pending Key Index State
32323240
cur->ws_info->pending_key_index_info.state = NO_PENDING_PROCESS;
32333241
cur->mac_parameters->mac_default_key_index = 0;
@@ -3236,11 +3244,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
32363244
blacklist_clear();
32373245

32383246
// All trickle timers stopped to allow entry from any state
3239-
cur->ws_info->trickle_pa_running = false;
3240-
cur->ws_info->trickle_pc_running = false;
3241-
cur->ws_info->trickle_pas_running = false;
3242-
cur->ws_info->trickle_pcs_running = false;
3243-
cur->ws_info->trickle_pc_consistency_block_period = 0;
3247+
ws_bootstrap_asynch_trickle_stop(cur);
32443248

32453249
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
32463250
tr_info("Border router start network");
@@ -3329,11 +3333,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
33293333
case WS_CONFIGURATION_START:
33303334
tr_info("Configuration start");
33313335
// Old configuration is considered invalid stopping all
3332-
cur->ws_info->trickle_pa_running = false;
3333-
cur->ws_info->trickle_pc_running = false;
3334-
cur->ws_info->trickle_pas_running = false;
3335-
cur->ws_info->trickle_pcs_running = false;
3336-
cur->ws_info->trickle_pc_consistency_block_period = 0;
3336+
ws_bootstrap_asynch_trickle_stop(cur);
33373337

33383338
// Build list of possible neighbours and learn first broadcast schedule
33393339

@@ -3342,11 +3342,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
33423342
case WS_OPERATION_START:
33433343
tr_info("operation start");
33443344
// Advertisements stopped during the RPL scan
3345-
cur->ws_info->trickle_pa_running = false;
3346-
cur->ws_info->trickle_pc_running = false;
3347-
cur->ws_info->trickle_pas_running = false;
3348-
cur->ws_info->trickle_pcs_running = false;
3349-
cur->ws_info->trickle_pc_consistency_block_period = 0;
3345+
ws_bootstrap_asynch_trickle_stop(cur);
33503346
// Activate RPL
33513347
// Activate IPv6 stack
33523348
ws_bootstrap_ip_stack_activate(cur);
@@ -3362,11 +3358,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
33623358
case WS_ROUTING_READY:
33633359
tr_info("Routing ready");
33643360
// stopped all to make sure we can enter here from any state
3365-
cur->ws_info->trickle_pa_running = false;
3366-
cur->ws_info->trickle_pc_running = false;
3367-
cur->ws_info->trickle_pas_running = false;
3368-
cur->ws_info->trickle_pcs_running = false;
3369-
cur->ws_info->trickle_pc_consistency_block_period = 0;
3361+
ws_bootstrap_asynch_trickle_stop(cur);
33703362

33713363
// Indicate PAE controller that bootstrap is ready
33723364
ws_pae_controller_bootstrap_done(cur);
@@ -3547,11 +3539,7 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
35473539
case ER_PANA_AUTH:
35483540
tr_info("authentication start");
35493541
// Advertisements stopped during the EAPOL
3550-
cur->ws_info->trickle_pa_running = false;
3551-
cur->ws_info->trickle_pc_running = false;
3552-
cur->ws_info->trickle_pas_running = false;
3553-
cur->ws_info->trickle_pcs_running = false;
3554-
cur->ws_info->trickle_pc_consistency_block_period = 0;
3542+
ws_bootstrap_asynch_trickle_stop(cur);
35553543
ws_fhss_configure(cur, false);
35563544
int8_t new_default = cur->ws_info->weakest_received_rssi - 1;
35573545
if ((new_default < CCA_DEFAULT_DBM) && (new_default >= CCA_LOW_LIMIT) && (new_default <= CCA_HIGH_LIMIT)) {

source/6LoWPAN/ws/ws_cfg_settings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ int8_t ws_cfg_fhss_validate(ws_fhss_cfg_t *cfg, ws_fhss_cfg_t *new_cfg)
942942
return CFG_SETTINGS_ERROR_FHSS_CONF;
943943
}
944944

945-
if (new_cfg->fhss_bc_dwell_interval < 15) {
945+
if (new_cfg->fhss_bc_dwell_interval < 100) {
946946
return CFG_SETTINGS_ERROR_FHSS_CONF;
947947
}
948948

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,16 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
12591259
return;
12601260
}
12611261

1262+
if (!base->ie_params.hopping_schedule) {
1263+
tr_error("Missing FHSS configurations");
1264+
mcps_data_conf_t data_conf;
1265+
memset(&data_conf, 0, sizeof(mcps_data_conf_t));
1266+
data_conf.msduHandle = data->msduHandle;
1267+
data_conf.status = MLME_TRANSACTION_OVERFLOW;
1268+
user_cb->data_confirm(&base->mpx_data_base.mpx_api, &data_conf);
1269+
return;
1270+
}
1271+
12621272
if (user_id == MPX_KEY_MANAGEMENT_ENC_USER_ID) {
12631273
ws_llc_mpx_eapol_request(base, user_cb, data);
12641274
} else if (user_id == MPX_LOWPAN_ENC_USER_ID) {
@@ -1643,10 +1653,11 @@ mpx_api_t *ws_llc_mpx_api_get(struct protocol_interface_info_entry *interface)
16431653
int8_t ws_llc_asynch_request(struct protocol_interface_info_entry *interface, asynch_request_t *request)
16441654
{
16451655
llc_data_base_t *base = ws_llc_discover_by_interface(interface);
1646-
if (!base) {
1656+
if (!base || !base->ie_params.hopping_schedule) {
16471657
return -1;
16481658
}
16491659

1660+
16501661
//Calculate IE Buffer size
16511662
request->wh_requested_ie_list.fc_ie = false; //Never should not be a part Asynch message
16521663
request->wh_requested_ie_list.rsl_ie = false; //Never should not be a part Asynch message

source/6LoWPAN/ws/ws_management_api.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -461,22 +461,22 @@ int ws_management_fhss_timing_configure(
461461
return -2;
462462
}
463463

464-
if (fhss_uc_dwell_interval > 0) {
465-
cfg.fhss_uc_dwell_interval = fhss_uc_dwell_interval;
466-
} else if (fhss_uc_dwell_interval == 0xff) {
464+
if (fhss_uc_dwell_interval == 0) {
467465
cfg.fhss_uc_dwell_interval = cfg_default.fhss_uc_dwell_interval;
466+
} else {
467+
cfg.fhss_uc_dwell_interval = fhss_uc_dwell_interval;
468468
}
469469

470-
if (fhss_broadcast_interval > 0) {
471-
cfg.fhss_bc_interval = fhss_broadcast_interval;
472-
} else if (fhss_broadcast_interval == 0xffff) {
470+
if (fhss_broadcast_interval > 0xffffff) {
473471
cfg.fhss_bc_interval = cfg_default.fhss_bc_interval;
472+
} else if (fhss_broadcast_interval > 0) {
473+
cfg.fhss_bc_interval = fhss_broadcast_interval;
474474
}
475475

476-
if (fhss_bc_dwell_interval > 0) {
477-
cfg.fhss_bc_dwell_interval = fhss_bc_dwell_interval;
478-
} else if (fhss_bc_dwell_interval == 0xff) {
476+
if (fhss_bc_dwell_interval == 0) {
479477
cfg.fhss_bc_dwell_interval = cfg_default.fhss_bc_dwell_interval;
478+
} else {
479+
cfg.fhss_bc_dwell_interval = fhss_bc_dwell_interval;
480480
}
481481

482482
if (ws_cfg_fhss_set(cur, NULL, &cfg, 0) < 0) {
@@ -509,10 +509,10 @@ int ws_management_fhss_unicast_channel_function_configure(
509509
return -2;
510510
}
511511

512-
if (dwell_interval > 0) {
513-
cfg.fhss_uc_dwell_interval = dwell_interval;
514-
} else {
512+
if (dwell_interval == 0) {
515513
cfg.fhss_uc_dwell_interval = cfg_default.fhss_uc_dwell_interval;
514+
} else {
515+
cfg.fhss_uc_dwell_interval = dwell_interval;
516516
}
517517
if (channel_function < 0xff) {
518518
cfg.fhss_uc_channel_function = channel_function;
@@ -611,16 +611,16 @@ int ws_management_fhss_broadcast_channel_function_configure(
611611
return -2;
612612
}
613613

614-
if (dwell_interval > 0) {
615-
cfg.fhss_bc_dwell_interval = dwell_interval;
616-
} else {
614+
if (dwell_interval == 0) {
617615
cfg.fhss_bc_dwell_interval = cfg_default.fhss_bc_dwell_interval;
616+
} else {
617+
cfg.fhss_bc_dwell_interval = dwell_interval;
618618
}
619619

620-
if (broadcast_interval > 0) {
621-
cfg.fhss_bc_interval = broadcast_interval;
622-
} else {
620+
if (broadcast_interval > 0xffffff) {
623621
cfg.fhss_bc_interval = cfg_default.fhss_bc_interval;
622+
} else if (broadcast_interval > 0) {
623+
cfg.fhss_bc_interval = broadcast_interval;
624624
}
625625

626626
if (channel_function != 0xff) {

source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,30 @@ static void ws_neighbor_calculate_ufsi_drift(ws_neighbor_class_entry_t *ws_neigh
103103
{
104104
if (ws_neighbor->fhss_data.uc_timing_info.utt_rx_timestamp && ws_neighbor->fhss_data.uc_timing_info.ufsi) {
105105
uint32_t seq_length = 0x10000;
106-
if (ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function == WS_TR51CF) {
106+
if (ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function == WS_TR51CF) {
107107
seq_length = ws_neighbor->fhss_data.uc_timing_info.unicast_number_of_channels;
108108
}
109+
uint32_t ufsi_prev_tmp = ws_neighbor->fhss_data.uc_timing_info.ufsi;
110+
uint32_t ufsi_cur_tmp = ws_utt->ufsi;
111+
if (ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function == WS_DH1CF) {
112+
if (ufsi_cur_tmp < ufsi_prev_tmp) {
113+
ufsi_cur_tmp += 0xffffff;
114+
}
115+
}
109116
// Convert 24-bit UFSI to real time before drift calculation
110-
uint32_t time_since_seq_start_prev_ms = own_ceil((float)((uint64_t)ws_neighbor->fhss_data.uc_timing_info.ufsi * seq_length * ws_neighbor->fhss_data.uc_timing_info.unicast_dwell_interval) / 0x1000000);
111-
uint32_t time_since_seq_start_cur_ms = own_ceil((float)((uint64_t)ws_utt->ufsi * seq_length * ws_neighbor->fhss_data.uc_timing_info.unicast_dwell_interval) / 0x1000000);
117+
uint32_t time_since_seq_start_prev_ms = own_ceil((float)((uint64_t)ufsi_prev_tmp * seq_length * ws_neighbor->fhss_data.uc_timing_info.unicast_dwell_interval) / 0x1000000);
118+
uint32_t time_since_seq_start_cur_ms = own_ceil((float)((uint64_t)ufsi_cur_tmp * seq_length * ws_neighbor->fhss_data.uc_timing_info.unicast_dwell_interval) / 0x1000000);
112119
uint32_t time_since_last_ufsi_us = timestamp - ws_neighbor->fhss_data.uc_timing_info.utt_rx_timestamp;
120+
121+
if (ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function == WS_TR51CF) {
122+
uint32_t full_uc_schedule_ms = ws_neighbor->fhss_data.uc_timing_info.unicast_dwell_interval * ws_neighbor->fhss_data.uc_timing_info.unicast_number_of_channels;
123+
uint32_t temp_ms = (time_since_last_ufsi_us / 1000) / full_uc_schedule_ms;
124+
if (time_since_seq_start_cur_ms >= time_since_seq_start_prev_ms) {
125+
temp_ms--;
126+
}
127+
time_since_seq_start_cur_ms += temp_ms * full_uc_schedule_ms + (full_uc_schedule_ms - time_since_seq_start_prev_ms) + time_since_seq_start_prev_ms;
128+
}
129+
113130
uint32_t ufsi_diff_ms = time_since_seq_start_cur_ms - time_since_seq_start_prev_ms;
114131
int32_t ufsi_drift_ms = (int32_t)(time_since_last_ufsi_us / 1000 - ufsi_diff_ms);
115132
// Only trace if there is significant error

source/6LoWPAN/ws/ws_pae_auth.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ void ws_pae_auth_fast_timer(uint16_t ticks)
695695
ws_pae_auth_timer_stop(pae_auth);
696696
}
697697
}
698+
699+
// Update key storage fast timer
700+
ws_pae_key_storage_fast_timer(ticks);
698701
}
699702

700703
void ws_pae_auth_slow_timer(uint16_t seconds)

0 commit comments

Comments
 (0)