Skip to content

Commit c6e2457

Browse files
author
Juha Heiskanen
authored
Merge pull request ARMmbed#1802 from ARMmbed/asynch_channel_plan_filter
Wi-sun bootstrap verify channel plan component against own configured…
2 parents 1bdc4e6 + c851b07 commit c6e2457

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,31 @@ static bool ws_bootstrap_network_found(protocol_interface_info_entry_t *cur)
815815
return true;
816816
}
817817

818+
static bool ws_channel_plan_zero_compare(ws_channel_plan_zero_t *rx_plan, ws_hopping_schedule_t *hopping_schdule)
819+
{
820+
if (rx_plan->operation_class != hopping_schdule->operating_class) {
821+
return false;
822+
} else if( rx_plan->regulator_domain != hopping_schdule->regulatory_domain) {
823+
return false;
824+
}
825+
return true;
826+
}
827+
828+
static bool ws_channel_plan_one_compare(ws_channel_plan_one_t *rx_plan, ws_hopping_schedule_t *hopping_schdule)
829+
{
830+
uint16_t num_of_channel = hopping_schdule->number_of_channels;
831+
if (rx_plan->ch0 != hopping_schdule->ch0_freq) {
832+
return false;
833+
} else if( rx_plan->channel_spacing != hopping_schdule->channel_spacing) {
834+
return false;
835+
} else if (rx_plan->number_of_channel != num_of_channel) {
836+
return false;
837+
}
838+
return true;
839+
}
840+
841+
842+
818843

819844
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)
820845
{
@@ -831,7 +856,6 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
831856
//Check Network Name
832857
if (!ws_bootstrap_network_name_matches(ie_ext, cur->ws_info->network_name)) {
833858
// Not in our network
834-
tr_debug("Network name not matching");
835859
return;
836860
}
837861
break;
@@ -845,17 +869,30 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
845869
ws_utt_ie_t ws_utt;
846870
if (!ws_wh_utt_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ws_utt)) {
847871
// Corrupted
848-
tr_error("No ufsi");
849872
return;
850873
}
851874

852875
ws_us_ie_t ws_us;
853876
if (!ws_wp_nested_us_read(ie_ext->payloadIeList, ie_ext->payloadIeListLength, &ws_us)) {
854877
// Corrupted
855-
tr_error("No unicast schedule");
856878
return;
857879
}
858880

881+
//Compare Unicast channel Plan
882+
if (ws_us.channel_plan != cur->ws_info->hopping_schdule.channel_plan) {
883+
return;
884+
}
885+
886+
if (ws_us.channel_plan == 0) {
887+
if (!ws_channel_plan_zero_compare(&ws_us.plan.zero, &cur->ws_info->hopping_schdule)) {
888+
return;
889+
}
890+
} else if (ws_us.channel_plan == 1) {
891+
if (!ws_channel_plan_one_compare(&ws_us.plan.one, &cur->ws_info->hopping_schdule)) {
892+
return;
893+
}
894+
}
895+
859896
//Handle Message's
860897
switch (message_type) {
861898
case WS_FT_PAN_ADVERT:

0 commit comments

Comments
 (0)