Skip to content

Commit

Permalink
Squashed 'features/nanostack/sal-stack-nanostack/' changes from 09d9e24
Browse files Browse the repository at this point in the history
…..d207f4d

d207f4d Merge branch 'release_internal' into release_external
d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482)
0f6666a Fixed Unit test's
1ff9b1d LLC drop a packet if FHSS shedule is not configured.
7cecc28 Fixed missing asynch trigle setup stop at if down process
7a8b2bf Wi-SUN fhss API default value setting fixes
164a370 Fixed coverity issues from management API
8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475)
4ffe6a1 Multicast forwarding is separated from the routing flag
30f4315 Wi-SUN discovery staten enter upxdate
083b84e Iotthd 4308 (ARMmbed#2473)
fcc33d5 Removed time increment from NVM time read function on interface up
9c8e3af fhss_tx_handle update
5491a6b Fixed UFSI update print function (ARMmbed#2470)
86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
a0b112a Corrected defects and coding style
2f4678a Corrected trace macro
5e96751 Distributed key storage NVM writes to longer time period
9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466)
a792e83 Added validation at MAC ack buffer handler
2a465b2 DNS configuration lifetime validation

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: d207f4d
  • Loading branch information
Arto Kinnunen committed Oct 28, 2020
1 parent 4098b26 commit 0293548
Show file tree
Hide file tree
Showing 23 changed files with 334 additions and 124 deletions.
5 changes: 5 additions & 0 deletions nanostack/ws_management_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ int ws_management_channel_plan_set(
*
* Change the default configuration for Wi-SUN FHSS operation.
*
* Calling with fhss_uc_dwell_interval = 0, fhss_broadcast_interval = 0xffffffff,
* fhss_bc_dwell_interval = 0 restores stack defaults
*
* \param interface_id Network interface ID.
* \param fhss_uc_dwell_interval default to 250 ms.
Expand All @@ -403,6 +405,7 @@ int ws_management_fhss_timing_configure(
* Change the default configuration for Wi-SUN FHSS operation.
* if application defined is used the behaviour is undefined
*
* Calling with dwell_interval = 0, channel_function = 0xff, fixed_channel = 0xffff restores stack defaults
*
* \param interface_id Network interface ID.
* \param channel_function Unicast channel function.
Expand Down Expand Up @@ -458,6 +461,8 @@ int ws_management_fhss_unicast_channel_function_validate(
* Change the default configuration for Wi-SUN FHSS operation.
* if application defined is used the behaviour is undefined
*
* Calling with dwell_interval = 0, channel_function = 0xff,
* broadcast_interval = 0xffffffff, fixed_channel = 0xffff restores stack defaults
*
* \param interface_id Network interface ID.
* \param channel_function Broadcast channel function.
Expand Down
7 changes: 4 additions & 3 deletions source/6LoWPAN/Thread/thread_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,14 @@ static void thread_bbr_network_data_send(thread_bbr_t *this, uint8_t prefix[8],

static void thread_bbr_routing_enable(thread_bbr_t *this, bool multicast_routing_enabled)
{
// Start multicast proxying
// We do not enable multicast forwarding as there is other default router present in network
multicast_fwd_set_forwarding(this->interface_id, multicast_routing_enabled);

if (this->routing_enabled) {
return;
}
tr_info("br: enable routing");
// Start multicast proxying
// We do not enable multicast forwarding as there is other default router present in network
multicast_fwd_set_forwarding(this->interface_id, multicast_routing_enabled);
this->routing_enabled = true;
}

Expand Down
50 changes: 19 additions & 31 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,15 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
return ret_val;
}

static void ws_bootstrap_asynch_trickle_stop(protocol_interface_info_entry_t *cur)
{
cur->ws_info->trickle_pas_running = false;
cur->ws_info->trickle_pa_running = false;
cur->ws_info->trickle_pcs_running = false;
cur->ws_info->trickle_pc_running = false;
cur->ws_info->trickle_pc_consistency_block_period = 0;
}

static int8_t ws_bootstrap_down(protocol_interface_info_entry_t *cur)
{
if (!cur || !(cur->lowpan_info & INTERFACE_NWK_ACTIVE)) {
Expand All @@ -1058,7 +1067,7 @@ static int8_t ws_bootstrap_down(protocol_interface_info_entry_t *cur)
ns_fhss_delete(cur->ws_info->fhss_api);
cur->ws_info->fhss_api = NULL;
// Reset WS information
// ws_common_reset(cur)
ws_bootstrap_asynch_trickle_stop(cur);
ws_llc_reset(cur);
if (nd_proxy_downstream_interface_unregister(cur->id) != 0) {
tr_warn("nd proxy unregister failed");
Expand Down Expand Up @@ -1103,11 +1112,7 @@ void ws_bootstrap_configuration_reset(protocol_interface_info_entry_t *cur)

cur->nwk_bootstrap_state = ER_ACTIVE_SCAN;
cur->ws_info->network_pan_id = 0xffff;
cur->ws_info->trickle_pas_running = false;
cur->ws_info->trickle_pa_running = false;
cur->ws_info->trickle_pcs_running = false;
cur->ws_info->trickle_pc_running = false;
cur->ws_info->trickle_pc_consistency_block_period = 0;
ws_bootstrap_asynch_trickle_stop(cur);

//cur->mac_security_key_usage_update_cb = ws_management_mac_security_key_update_cb;
return;
Expand Down Expand Up @@ -3228,6 +3233,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
case WS_DISCOVERY_START:
tr_info("Discovery start");

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

// All trickle timers stopped to allow entry from any state
cur->ws_info->trickle_pa_running = false;
cur->ws_info->trickle_pc_running = false;
cur->ws_info->trickle_pas_running = false;
cur->ws_info->trickle_pcs_running = false;
cur->ws_info->trickle_pc_consistency_block_period = 0;
ws_bootstrap_asynch_trickle_stop(cur);

if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
tr_info("Border router start network");
Expand Down Expand Up @@ -3329,11 +3333,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
case WS_CONFIGURATION_START:
tr_info("Configuration start");
// Old configuration is considered invalid stopping all
cur->ws_info->trickle_pa_running = false;
cur->ws_info->trickle_pc_running = false;
cur->ws_info->trickle_pas_running = false;
cur->ws_info->trickle_pcs_running = false;
cur->ws_info->trickle_pc_consistency_block_period = 0;
ws_bootstrap_asynch_trickle_stop(cur);

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

Expand All @@ -3342,11 +3342,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
case WS_OPERATION_START:
tr_info("operation start");
// Advertisements stopped during the RPL scan
cur->ws_info->trickle_pa_running = false;
cur->ws_info->trickle_pc_running = false;
cur->ws_info->trickle_pas_running = false;
cur->ws_info->trickle_pcs_running = false;
cur->ws_info->trickle_pc_consistency_block_period = 0;
ws_bootstrap_asynch_trickle_stop(cur);
// Activate RPL
// Activate IPv6 stack
ws_bootstrap_ip_stack_activate(cur);
Expand All @@ -3362,11 +3358,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
case WS_ROUTING_READY:
tr_info("Routing ready");
// stopped all to make sure we can enter here from any state
cur->ws_info->trickle_pa_running = false;
cur->ws_info->trickle_pc_running = false;
cur->ws_info->trickle_pas_running = false;
cur->ws_info->trickle_pcs_running = false;
cur->ws_info->trickle_pc_consistency_block_period = 0;
ws_bootstrap_asynch_trickle_stop(cur);

// Indicate PAE controller that bootstrap is ready
ws_pae_controller_bootstrap_done(cur);
Expand Down Expand Up @@ -3547,11 +3539,7 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
case ER_PANA_AUTH:
tr_info("authentication start");
// Advertisements stopped during the EAPOL
cur->ws_info->trickle_pa_running = false;
cur->ws_info->trickle_pc_running = false;
cur->ws_info->trickle_pas_running = false;
cur->ws_info->trickle_pcs_running = false;
cur->ws_info->trickle_pc_consistency_block_period = 0;
ws_bootstrap_asynch_trickle_stop(cur);
ws_fhss_configure(cur, false);
int8_t new_default = cur->ws_info->weakest_received_rssi - 1;
if ((new_default < CCA_DEFAULT_DBM) && (new_default >= CCA_LOW_LIMIT) && (new_default <= CCA_HIGH_LIMIT)) {
Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/ws/ws_cfg_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ int8_t ws_cfg_fhss_validate(ws_fhss_cfg_t *cfg, ws_fhss_cfg_t *new_cfg)
return CFG_SETTINGS_ERROR_FHSS_CONF;
}

if (new_cfg->fhss_bc_dwell_interval < 15) {
if (new_cfg->fhss_bc_dwell_interval < 100) {
return CFG_SETTINGS_ERROR_FHSS_CONF;
}

Expand Down
13 changes: 12 additions & 1 deletion source/6LoWPAN/ws/ws_llc_data_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,16 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
return;
}

if (!base->ie_params.hopping_schedule) {
tr_error("Missing FHSS configurations");
mcps_data_conf_t data_conf;
memset(&data_conf, 0, sizeof(mcps_data_conf_t));
data_conf.msduHandle = data->msduHandle;
data_conf.status = MLME_TRANSACTION_OVERFLOW;
user_cb->data_confirm(&base->mpx_data_base.mpx_api, &data_conf);
return;
}

if (user_id == MPX_KEY_MANAGEMENT_ENC_USER_ID) {
ws_llc_mpx_eapol_request(base, user_cb, data);
} else if (user_id == MPX_LOWPAN_ENC_USER_ID) {
Expand Down Expand Up @@ -1643,10 +1653,11 @@ mpx_api_t *ws_llc_mpx_api_get(struct protocol_interface_info_entry *interface)
int8_t ws_llc_asynch_request(struct protocol_interface_info_entry *interface, asynch_request_t *request)
{
llc_data_base_t *base = ws_llc_discover_by_interface(interface);
if (!base) {
if (!base || !base->ie_params.hopping_schedule) {
return -1;
}


//Calculate IE Buffer size
request->wh_requested_ie_list.fc_ie = false; //Never should not be a part Asynch message
request->wh_requested_ie_list.rsl_ie = false; //Never should not be a part Asynch message
Expand Down
36 changes: 18 additions & 18 deletions source/6LoWPAN/ws/ws_management_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,22 +461,22 @@ int ws_management_fhss_timing_configure(
return -2;
}

if (fhss_uc_dwell_interval > 0) {
cfg.fhss_uc_dwell_interval = fhss_uc_dwell_interval;
} else if (fhss_uc_dwell_interval == 0xff) {
if (fhss_uc_dwell_interval == 0) {
cfg.fhss_uc_dwell_interval = cfg_default.fhss_uc_dwell_interval;
} else {
cfg.fhss_uc_dwell_interval = fhss_uc_dwell_interval;
}

if (fhss_broadcast_interval > 0) {
cfg.fhss_bc_interval = fhss_broadcast_interval;
} else if (fhss_broadcast_interval == 0xffff) {
if (fhss_broadcast_interval > 0xffffff) {
cfg.fhss_bc_interval = cfg_default.fhss_bc_interval;
} else if (fhss_broadcast_interval > 0) {
cfg.fhss_bc_interval = fhss_broadcast_interval;
}

if (fhss_bc_dwell_interval > 0) {
cfg.fhss_bc_dwell_interval = fhss_bc_dwell_interval;
} else if (fhss_bc_dwell_interval == 0xff) {
if (fhss_bc_dwell_interval == 0) {
cfg.fhss_bc_dwell_interval = cfg_default.fhss_bc_dwell_interval;
} else {
cfg.fhss_bc_dwell_interval = fhss_bc_dwell_interval;
}

if (ws_cfg_fhss_set(cur, NULL, &cfg, 0) < 0) {
Expand Down Expand Up @@ -509,10 +509,10 @@ int ws_management_fhss_unicast_channel_function_configure(
return -2;
}

if (dwell_interval > 0) {
cfg.fhss_uc_dwell_interval = dwell_interval;
} else {
if (dwell_interval == 0) {
cfg.fhss_uc_dwell_interval = cfg_default.fhss_uc_dwell_interval;
} else {
cfg.fhss_uc_dwell_interval = dwell_interval;
}
if (channel_function < 0xff) {
cfg.fhss_uc_channel_function = channel_function;
Expand Down Expand Up @@ -611,16 +611,16 @@ int ws_management_fhss_broadcast_channel_function_configure(
return -2;
}

if (dwell_interval > 0) {
cfg.fhss_bc_dwell_interval = dwell_interval;
} else {
if (dwell_interval == 0) {
cfg.fhss_bc_dwell_interval = cfg_default.fhss_bc_dwell_interval;
} else {
cfg.fhss_bc_dwell_interval = dwell_interval;
}

if (broadcast_interval > 0) {
cfg.fhss_bc_interval = broadcast_interval;
} else {
if (broadcast_interval > 0xffffff) {
cfg.fhss_bc_interval = cfg_default.fhss_bc_interval;
} else if (broadcast_interval > 0) {
cfg.fhss_bc_interval = broadcast_interval;
}

if (channel_function != 0xff) {
Expand Down
23 changes: 20 additions & 3 deletions source/6LoWPAN/ws/ws_neighbor_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,30 @@ static void ws_neighbor_calculate_ufsi_drift(ws_neighbor_class_entry_t *ws_neigh
{
if (ws_neighbor->fhss_data.uc_timing_info.utt_rx_timestamp && ws_neighbor->fhss_data.uc_timing_info.ufsi) {
uint32_t seq_length = 0x10000;
if (ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function == WS_TR51CF) {
if (ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function == WS_TR51CF) {
seq_length = ws_neighbor->fhss_data.uc_timing_info.unicast_number_of_channels;
}
uint32_t ufsi_prev_tmp = ws_neighbor->fhss_data.uc_timing_info.ufsi;
uint32_t ufsi_cur_tmp = ws_utt->ufsi;
if (ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function == WS_DH1CF) {
if (ufsi_cur_tmp < ufsi_prev_tmp) {
ufsi_cur_tmp += 0xffffff;
}
}
// Convert 24-bit UFSI to real time before drift calculation
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);
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);
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);
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);
uint32_t time_since_last_ufsi_us = timestamp - ws_neighbor->fhss_data.uc_timing_info.utt_rx_timestamp;

if (ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function == WS_TR51CF) {
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;
uint32_t temp_ms = (time_since_last_ufsi_us / 1000) / full_uc_schedule_ms;
if (time_since_seq_start_cur_ms >= time_since_seq_start_prev_ms) {
temp_ms--;
}
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;
}

uint32_t ufsi_diff_ms = time_since_seq_start_cur_ms - time_since_seq_start_prev_ms;
int32_t ufsi_drift_ms = (int32_t)(time_since_last_ufsi_us / 1000 - ufsi_diff_ms);
// Only trace if there is significant error
Expand Down
3 changes: 3 additions & 0 deletions source/6LoWPAN/ws/ws_pae_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,9 @@ void ws_pae_auth_fast_timer(uint16_t ticks)
ws_pae_auth_timer_stop(pae_auth);
}
}

// Update key storage fast timer
ws_pae_key_storage_fast_timer(ticks);
}

void ws_pae_auth_slow_timer(uint16_t seconds)
Expand Down
Loading

0 comments on commit 0293548

Please sign in to comment.