Skip to content

Commit bf8e89e

Browse files
author
Arto Kinnunen
authored
Ignore neighbors using unsupported channel function (ARMmbed#2395)
Nodes do not support Vendor specific channel function. Ignore potential neighbors which do not support node's channel function.
1 parent 1c263fd commit bf8e89e

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static void ws_bootstap_eapol_neigh_entry_allocate(struct protocol_interface_inf
156156
uint8_t mac_64[8];
157157
memset(mac_64, 0, sizeof(mac_64));
158158

159-
mac_neighbor_table_entry_t *mac_entry = ws_bootstrap_mac_neighbor_add(interface, mac_64);
159+
mac_neighbor_table_entry_t *mac_entry = ws_bootstrap_mac_neighbor_add(interface, mac_64);
160160

161161
if (!mac_entry) {
162162
return;
@@ -1580,6 +1580,26 @@ bool ws_bootstrap_validate_channel_plan(ws_us_ie_t *ws_us, struct protocol_inter
15801580
return true;
15811581
}
15821582

1583+
bool ws_bootstrap_validate_channel_function(ws_us_ie_t *ws_us, ws_bs_ie_t *ws_bs)
1584+
{
1585+
if (ws_us) {
1586+
if (ws_us->channel_function != WS_FIXED_CHANNEL &&
1587+
ws_us->channel_function != WS_TR51CF &&
1588+
ws_us->channel_function != WS_DH1CF) {
1589+
return false;
1590+
}
1591+
}
1592+
1593+
if (ws_bs) {
1594+
if (ws_bs->channel_function != WS_FIXED_CHANNEL &&
1595+
ws_bs->channel_function != WS_TR51CF &&
1596+
ws_bs->channel_function != WS_DH1CF) {
1597+
return false;
1598+
}
1599+
}
1600+
1601+
return true;
1602+
}
15831603

15841604
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)
15851605
{
@@ -1618,7 +1638,8 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
16181638
return;
16191639
}
16201640

1621-
if (!ws_bootstrap_validate_channel_plan(&ws_us, cur)) {
1641+
if (!ws_bootstrap_validate_channel_plan(&ws_us, cur) ||
1642+
!ws_bootstrap_validate_channel_function(&ws_us, NULL)) {
16221643
return;
16231644
}
16241645

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef enum {
3131

3232
struct llc_neighbour_req;
3333
struct ws_us_ie;
34+
struct ws_bs_ie;
3435
struct ws_neighbor_class_entry;
3536

3637
int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode);
@@ -82,6 +83,8 @@ void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur,
8283

8384
bool ws_bootstrap_validate_channel_plan(struct ws_us_ie *ws_us, struct protocol_interface_info_entry *cur);
8485

86+
bool ws_bootstrap_validate_channel_function(struct ws_us_ie *ws_us, struct ws_bs_ie *ws_bs);
87+
8588
void ws_bootstrap_eapol_rx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64);
8689

8790
struct ws_neighbor_class_entry *ws_bootstrap_eapol_tx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64);

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,14 @@ static void ws_llc_data_indication_cb(const mac_api_t *api, const mcps_data_ind_
613613
protocol_interface_info_entry_t *interface = base->interface_ptr;
614614

615615
//Validate Unicast shedule Channel Plan
616-
if (us_ie_inline && !ws_bootstrap_validate_channel_plan(&us_ie, interface)) {
617-
//Channel plan configuration mismatch
616+
if (us_ie_inline &&
617+
(!ws_bootstrap_validate_channel_plan(&us_ie, interface) ||
618+
!ws_bootstrap_validate_channel_function(&us_ie, NULL))) {
619+
//Channel plan or channel function configuration mismatch
620+
return;
621+
}
622+
623+
if (bs_ie_inline && !ws_bootstrap_validate_channel_function(NULL, &ws_bs_ie)) {
618624
return;
619625
}
620626

@@ -730,8 +736,14 @@ static void ws_llc_eapol_indication_cb(const mac_api_t *api, const mcps_data_ind
730736
protocol_interface_info_entry_t *interface = base->interface_ptr;
731737

732738
//Validate Unicast shedule Channel Plan
733-
if (us_ie_inline && !ws_bootstrap_validate_channel_plan(&us_ie, interface)) {
734-
//Channel plan configuration mismatch
739+
if (us_ie_inline &&
740+
(!ws_bootstrap_validate_channel_plan(&us_ie, interface) ||
741+
!ws_bootstrap_validate_channel_function(&us_ie, NULL))) {
742+
//Channel plan or channel function configuration mismatch
743+
return;
744+
}
745+
746+
if (bs_ie_inline && !ws_bootstrap_validate_channel_function(NULL, &ws_bs_ie)) {
735747
return;
736748
}
737749

test/nanostack/unittest/stub/ws_bootstrap_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ bool ws_bootstrap_validate_channel_plan(ws_us_ie_t *ws_us, struct protocol_inter
131131
return true;
132132
}
133133

134+
bool ws_bootstrap_validate_channel_function(ws_us_ie_t *ws_us, ws_bs_ie_t *ws_bs)
135+
{
136+
return true;
137+
}
138+
134139
struct ws_neighbor_class_entry *ws_bootstrap_eapol_tx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64)
135140
{
136141
return NULL;

0 commit comments

Comments
 (0)