Skip to content

Commit

Permalink
Merge pull request ARMmbed#1802 from ARMmbed/asynch_channel_plan_filter
Browse files Browse the repository at this point in the history
Wi-sun bootstrap verify channel plan component against own configured…
  • Loading branch information
Juha Heiskanen authored Aug 29, 2018
2 parents 1bdc4e6 + c851b07 commit c6e2457
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,31 @@ static bool ws_bootstrap_network_found(protocol_interface_info_entry_t *cur)
return true;
}

static bool ws_channel_plan_zero_compare(ws_channel_plan_zero_t *rx_plan, ws_hopping_schedule_t *hopping_schdule)
{
if (rx_plan->operation_class != hopping_schdule->operating_class) {
return false;
} else if( rx_plan->regulator_domain != hopping_schdule->regulatory_domain) {
return false;
}
return true;
}

static bool ws_channel_plan_one_compare(ws_channel_plan_one_t *rx_plan, ws_hopping_schedule_t *hopping_schdule)
{
uint16_t num_of_channel = hopping_schdule->number_of_channels;
if (rx_plan->ch0 != hopping_schdule->ch0_freq) {
return false;
} else if( rx_plan->channel_spacing != hopping_schdule->channel_spacing) {
return false;
} else if (rx_plan->number_of_channel != num_of_channel) {
return false;
}
return true;
}




static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, const struct mcps_data_ind_s *data, const struct mcps_data_ie_list *ie_ext, uint8_t message_type)
{
Expand All @@ -831,7 +856,6 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
//Check Network Name
if (!ws_bootstrap_network_name_matches(ie_ext, cur->ws_info->network_name)) {
// Not in our network
tr_debug("Network name not matching");
return;
}
break;
Expand All @@ -845,17 +869,30 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
ws_utt_ie_t ws_utt;
if (!ws_wh_utt_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ws_utt)) {
// Corrupted
tr_error("No ufsi");
return;
}

ws_us_ie_t ws_us;
if (!ws_wp_nested_us_read(ie_ext->payloadIeList, ie_ext->payloadIeListLength, &ws_us)) {
// Corrupted
tr_error("No unicast schedule");
return;
}

//Compare Unicast channel Plan
if (ws_us.channel_plan != cur->ws_info->hopping_schdule.channel_plan) {
return;
}

if (ws_us.channel_plan == 0) {
if (!ws_channel_plan_zero_compare(&ws_us.plan.zero, &cur->ws_info->hopping_schdule)) {
return;
}
} else if (ws_us.channel_plan == 1) {
if (!ws_channel_plan_one_compare(&ws_us.plan.one, &cur->ws_info->hopping_schdule)) {
return;
}
}

//Handle Message's
switch (message_type) {
case WS_FT_PAN_ADVERT:
Expand Down

0 comments on commit c6e2457

Please sign in to comment.