Skip to content

Commit 4756be4

Browse files
author
Juha Heiskanen
committed
NEW API for Validation RX Unicast schedule channel.
Integrated to Asynch message handler and LLC layer for Data and EAPOL message. Packet will be dropped if configuration mismatch.
1 parent 0b48e5c commit 4756be4

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,20 @@ static bool ws_channel_plan_one_compare(ws_channel_plan_one_t *rx_plan, ws_hoppi
14851485
return true;
14861486
}
14871487

1488+
bool ws_bootstrap_validate_channel_plan(ws_us_ie_t *ws_us, struct protocol_interface_info_entry *cur)
1489+
{
1490+
if (ws_us->channel_plan == 0) {
1491+
if (!ws_channel_plan_zero_compare(&ws_us->plan.zero, &cur->ws_info->hopping_schdule)) {
1492+
return false;
1493+
}
1494+
} else if (ws_us->channel_plan == 1) {
1495+
if (!ws_channel_plan_one_compare(&ws_us->plan.one, &cur->ws_info->hopping_schdule)) {
1496+
return false;
1497+
}
1498+
}
14881499

1500+
return true;
1501+
}
14891502

14901503

14911504
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)
@@ -1525,14 +1538,8 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
15251538
return;
15261539
}
15271540

1528-
if (ws_us.channel_plan == 0) {
1529-
if (!ws_channel_plan_zero_compare(&ws_us.plan.zero, &cur->ws_info->hopping_schdule)) {
1530-
return;
1531-
}
1532-
} else if (ws_us.channel_plan == 1) {
1533-
if (!ws_channel_plan_one_compare(&ws_us.plan.one, &cur->ws_info->hopping_schdule)) {
1534-
return;
1535-
}
1541+
if (!ws_bootstrap_validate_channel_plan(&ws_us, cur)) {
1542+
return;
15361543
}
15371544

15381545
//Handle Message's

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef enum {
3030
#ifdef HAVE_WS
3131

3232
struct llc_neighbour_req;
33+
struct ws_us_ie;
3334

3435
int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode);
3536

@@ -78,6 +79,8 @@ bool ws_eapol_relay_state_active(protocol_interface_info_entry_t *cur);
7879

7980
void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur, struct llc_neighbour_req *neighbor_info);
8081

82+
bool ws_bootstrap_validate_channel_plan(struct ws_us_ie *ws_us, struct protocol_interface_info_entry *cur);
83+
8184
#else
8285

8386
#define ws_bootstrap_init(interface_id, bootstrap_mode) (-1)

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,12 @@ static void ws_llc_mac_indication_cb(const mac_api_t *api, const mcps_data_ind_t
547547
bs_ie_inline = ws_wp_nested_bs_read(ws_wp_nested.content_ptr, ws_wp_nested.length, &ws_bs_ie);
548548
}
549549

550+
//Validate Unicast shedule Channel Plan
551+
if (us_ie_inline && !ws_bootstrap_validate_channel_plan(&us_ie, interface)) {
552+
//Channel plan configuration mismatch
553+
return;
554+
}
555+
550556
llc_neighbour_req_t neighbor_info;
551557
bool multicast;
552558
bool request_new_entry;

test/nanostack/unittest/stub/ws_bootstrap_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,8 @@ void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur,
125125
{
126126

127127
}
128+
129+
bool ws_bootstrap_validate_channel_plan(ws_us_ie_t *ws_us, struct protocol_interface_info_entry *cur)
130+
{
131+
return true;
132+
}

0 commit comments

Comments
 (0)