Skip to content

Commit 572861b

Browse files
author
Juha Heiskanen
authored
Merge pull request #2041 from ARMmbed/iotthd-3309
EAPOL parent synch update
2 parents e32d3c1 + a2addf8 commit 572861b

File tree

4 files changed

+103
-8
lines changed

4 files changed

+103
-8
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ static void ws_bootstrap_pan_version_increment(protocol_interface_info_entry_t *
9292
static ws_nud_table_entry_t *ws_nud_entry_discover(protocol_interface_info_entry_t *cur, void *neighbor);
9393
static void ws_nud_entry_remove(protocol_interface_info_entry_t *cur, mac_neighbor_table_entry_t *entry_ptr);
9494

95+
typedef enum {
96+
WS_PARENT_SOFT_SYNCH = 0, /**< let FHSS make decision if synchronization is needed*/
97+
WS_PARENT_HARD_SYNCH, /**< Synch FHSS with latest synch information*/
98+
WS_EAPOL_PARENT_SYNCH, /**< Broadcast synch with EAPOL parent*/
99+
} ws_parent_synch_e;
100+
95101
mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)
96102

97103
{
@@ -470,8 +476,6 @@ static int8_t ws_fhss_discovery_configure(protocol_interface_info_entry_t *cur)
470476
fhss_configuration.fhss_broadcast_interval = 0;
471477
uint8_t tmp_uc_fixed_channel = ws_randomize_fixed_channel(cur->ws_info->fhss_uc_fixed_channel, cur->ws_info->hopping_schdule.number_of_channels);
472478
uint8_t tmp_bc_fixed_channel = ws_randomize_fixed_channel(cur->ws_info->fhss_bc_fixed_channel, cur->ws_info->hopping_schdule.number_of_channels);
473-
memset(fhss_configuration.channel_mask, 0, sizeof(uint32_t) * 8);
474-
channel_list_set_channel(fhss_configuration.channel_mask, tmp_uc_fixed_channel, true);
475479
fhss_configuration.unicast_fixed_channel = tmp_uc_fixed_channel;
476480
fhss_configuration.broadcast_fixed_channel = tmp_bc_fixed_channel;
477481
ns_fhss_ws_configuration_set(cur->ws_info->fhss_api, &fhss_configuration);
@@ -503,7 +507,7 @@ static int8_t ws_fhss_enable(protocol_interface_info_entry_t *cur)
503507
/* Sets the parent and broadcast schedule we are following
504508
*
505509
*/
506-
static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry *cur, llc_neighbour_req_t *neighbor_info, bool force_synch)
510+
static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry *cur, llc_neighbour_req_t *neighbor_info, ws_parent_synch_e synch_req)
507511
{
508512

509513
fhss_ws_configuration_t fhss_configuration;
@@ -516,7 +520,9 @@ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry
516520

517521
// Learning broadcast network configuration
518522
if (neighbor_info->ws_neighbor->broadcast_shedule_info_stored) {
519-
ws_fhss_set_defaults(cur, &fhss_configuration);
523+
if (synch_req == WS_EAPOL_PARENT_SYNCH) {
524+
ws_fhss_set_defaults(cur, &fhss_configuration);
525+
}
520526
fhss_configuration.ws_bc_channel_function = (fhss_ws_channel_functions)neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_channel_function;
521527
if (fhss_configuration.ws_bc_channel_function == WS_FIXED_CHANNEL) {
522528
cur->ws_info->hopping_schdule.bc_fixed_channel = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.fixed_channel;
@@ -532,12 +538,28 @@ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry
532538
ns_fhss_ws_configuration_set(cur->ws_info->fhss_api, &fhss_configuration);
533539

534540
// We have broadcast schedule set up set the broadcast parent schedule
535-
ns_fhss_ws_set_parent(cur->ws_info->fhss_api, neighbor_info->neighbor->mac64, &neighbor_info->ws_neighbor->fhss_data.bc_timing_info, force_synch);
541+
ns_fhss_ws_set_parent(cur->ws_info->fhss_api, neighbor_info->neighbor->mac64, &neighbor_info->ws_neighbor->fhss_data.bc_timing_info, synch_req != WS_PARENT_SOFT_SYNCH);
536542

537543
// Update LLC to follow updated fhss settings
538544
ws_bootstrap_llc_hopping_update(cur, &fhss_configuration);
539545
}
540546

547+
void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur, llc_neighbour_req_t *neighbor_info, ws_bs_ie_t *ws_bs_ie)
548+
{
549+
if (neighbor_info->ws_neighbor->broadcast_shedule_info_stored || cur->ws_info->configuration_learned) {
550+
return;
551+
}
552+
553+
if (memcmp(neighbor_info->neighbor->mac64, cur->ws_info->parent_info.addr, 8)) {
554+
return;
555+
}
556+
557+
//Store Brodacst Shedule
558+
ws_neighbor_class_neighbor_broadcast_schedule_set(neighbor_info->ws_neighbor, ws_bs_ie);
559+
560+
ws_bootstrap_primary_parent_set(cur, neighbor_info, WS_EAPOL_PARENT_SYNCH);
561+
}
562+
541563
static void ws_bootstrap_ll_address_validate(struct protocol_interface_info_entry *cur)
542564
{
543565
// Configure EUI64 for MAC if missing
@@ -1042,7 +1064,13 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
10421064
if (neighbor_info.neighbor->link_role == PRIORITY_PARENT_NEIGHBOUR) {
10431065
// RPL priority parent configuration we must update FHSS data
10441066
//Update synch to primary parent allways to update broadcast shedule and timing
1045-
ws_bootstrap_primary_parent_set(cur, &neighbor_info, !old_version);
1067+
ws_parent_synch_e synreq;
1068+
if (old_version) {
1069+
synreq = WS_PARENT_SOFT_SYNCH;
1070+
} else {
1071+
synreq = WS_PARENT_HARD_SYNCH;
1072+
}
1073+
ws_bootstrap_primary_parent_set(cur, &neighbor_info, synreq);
10461074
}
10471075

10481076
if (old_version) {
@@ -1070,7 +1098,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
10701098
// return to state machine after 1-2 s
10711099
cur->bootsrap_state_machine_cnt = randLIB_get_random_in_range(10, 20);
10721100
// enable frequency hopping for unicast channel and start listening first neighbour
1073-
ws_bootstrap_primary_parent_set(cur, &neighbor_info, true);
1101+
ws_bootstrap_primary_parent_set(cur, &neighbor_info, WS_PARENT_HARD_SYNCH);
10741102
// set neighbor as priority parent clear if there is others
10751103
protocol_6lowpan_neighbor_priority_clear_all(cur->id, PRIORITY_1ST);
10761104
neighbor_info.neighbor->link_role = PRIORITY_PARENT_NEIGHBOUR;
@@ -2543,7 +2571,7 @@ void ws_primary_parent_update(protocol_interface_info_entry_t *interface, mac_ne
25432571
llc_neighbour_req_t neighbor_info;
25442572
neighbor_info.neighbor = neighbor;
25452573
neighbor_info.ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
2546-
ws_bootstrap_primary_parent_set(interface, &neighbor_info, true);
2574+
ws_bootstrap_primary_parent_set(interface, &neighbor_info, WS_PARENT_HARD_SYNCH);
25472575

25482576
ws_secondary_parent_update(interface);
25492577
}

source/6LoWPAN/ws/ws_bootstrap.h

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

3232
#ifdef HAVE_WS
3333

34+
struct llc_neighbour_req;
35+
struct ws_bs_ie;
36+
3437
int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode);
3538

3639
void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur);
@@ -72,6 +75,8 @@ void ws_dhcp_client_address_delete(protocol_interface_info_entry_t *cur, uint8_t
7275

7376
bool ws_eapol_relay_state_active(protocol_interface_info_entry_t *cur);
7477

78+
void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur, struct llc_neighbour_req *neighbor_info, struct ws_bs_ie *ws_bs_ie);
79+
7580
#else
7681

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

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,12 @@ static void ws_llc_mac_indication_cb(const mac_api_t *api, const mcps_data_ind_t
513513
mac_payload_IE_t ws_wp_nested;
514514
ws_us_ie_t us_ie;
515515
bool us_ie_inline = false;
516+
bool bs_ie_inline = false;
516517
ws_wp_nested.id = WS_WP_NESTED_IE;
518+
ws_bs_ie_t ws_bs_ie;
517519
if (mac_ie_payload_discover(ie_ext->payloadIeList, ie_ext->payloadIeListLength, &ws_wp_nested) > 2) {
518520
us_ie_inline = ws_wp_nested_us_read(ws_wp_nested.content_ptr, ws_wp_nested.length, &us_ie);
521+
bs_ie_inline = ws_wp_nested_bs_read(ws_wp_nested.content_ptr, ws_wp_nested.length, &ws_bs_ie);
519522
}
520523

521524
llc_neighbour_req_t neighbor_info;
@@ -545,6 +548,9 @@ static void ws_llc_mac_indication_cb(const mac_api_t *api, const mcps_data_ind_t
545548
if (neighbor_info.neighbor->link_role == PRIORITY_PARENT_NEIGHBOUR) {
546549
// We have broadcast schedule set up set the broadcast parent schedule
547550
ns_fhss_ws_set_parent(interface->ws_info->fhss_api, neighbor_info.neighbor->mac64, &neighbor_info.ws_neighbor->fhss_data.bc_timing_info, false);
551+
} else if (ws_utt.message_type == WS_FT_EAPOL && bs_ie_inline) {
552+
//Synch Broadcast Only 1 time when configuration is not learned
553+
ws_bootstrap_eapol_parent_synch(interface, &neighbor_info, &ws_bs_ie);
548554
}
549555
}
550556

@@ -681,6 +687,8 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
681687
} else if (user_id == MPX_KEY_MANAGEMENT_ENC_USER_ID) {
682688
ie_header_mask.ea_ie = ws_eapol_handshake_first_msg(data->msdu, data->msduLength, base->interface_ptr);
683689
ie_header_mask.bt_ie = ie_header_mask.ea_ie;
690+
nested_wp_id.bs_ie = ie_header_mask.ea_ie;
691+
684692
}
685693

686694
nested_wp_id.us_ie = true;
@@ -764,6 +772,11 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
764772
ptr = ws_wp_base_write(ptr, nested_ie_length);
765773
//Write unicast schedule
766774
ptr = ws_wp_nested_hopping_schedule_write(ptr, base->ie_params.hopping_schedule, true);
775+
776+
if (nested_wp_id.bs_ie) {
777+
//Write Broadcastcast schedule
778+
ptr = ws_wp_nested_hopping_schedule_write(ptr, base->ie_params.hopping_schedule, false);
779+
}
767780
}
768781

769782

test/nanostack/unittest/stub/ws_bootstrap_stub.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,59 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include <string.h>
1819
#include "nsconfig.h"
1920
#include "ns_types.h"
2021
#include "ns_trace.h"
2122
#include "net_interface.h"
2223
#include "eventOS_event.h"
24+
#include "randLIB.h"
25+
#include "common_functions.h"
26+
#include "mac_common_defines.h"
27+
#include "sw_mac.h"
28+
#include "ccmLIB.h"
2329
#include "NWK_INTERFACE/Include/protocol.h"
30+
#include "6LoWPAN/Bootstraps/protocol_6lowpan.h"
2431
#include "6LoWPAN/Bootstraps/protocol_6lowpan_interface.h"
32+
#include "ipv6_stack/protocol_ipv6.h"
33+
#include "6LoWPAN/MAC/mac_helper.h"
34+
#include "6LoWPAN/MAC/mac_data_poll.h"
35+
#include "6LoWPAN/MAC/mpx_api.h"
36+
#include "6LoWPAN/MAC/mac_ie_lib.h"
37+
#include "MPL/mpl.h"
38+
#include "RPL/rpl_protocol.h"
39+
#include "RPL/rpl_control.h"
40+
#include "RPL/rpl_data.h"
41+
#include "Common_Protocols/icmpv6.h"
42+
#include "Common_Protocols/icmpv6_radv.h"
43+
#include "Common_Protocols/ipv6_constants.h"
44+
#include "Service_Libs/Trickle/trickle.h"
45+
#include "Service_Libs/fhss/channel_list.h"
46+
#include "6LoWPAN/ws/ws_common_defines.h"
47+
#include "6LoWPAN/ws/ws_common_defines.h"
48+
#include "6LoWPAN/ws/ws_config.h"
2549
#include "6LoWPAN/ws/ws_common.h"
2650
#include "6LoWPAN/ws/ws_bootstrap.h"
51+
#include "6LoWPAN/ws/ws_bbr_api_internal.h"
52+
#include "6LoWPAN/ws/ws_common_defines.h"
53+
#include "6LoWPAN/ws/ws_llc.h"
54+
#include "6LoWPAN/ws/ws_neighbor_class.h"
55+
#include "6LoWPAN/ws/ws_ie_lib.h"
56+
#include "6LoWPAN/lowpan_adaptation_interface.h"
57+
#include "Service_Libs/etx/etx.h"
58+
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
59+
#include "Service_Libs/nd_proxy/nd_proxy.h"
60+
#include "Service_Libs/blacklist/blacklist.h"
61+
#include "platform/topo_trace.h"
62+
#include "libDHCPv6/libDHCPv6.h"
63+
#include "DHCPv6_client/dhcpv6_client_api.h"
64+
#include "ws_management_api.h"
65+
#include "net_rpl.h"
66+
#include "mac_api.h"
67+
#include "6LoWPAN/ws/ws_pae_controller.h"
68+
#include "6LoWPAN/ws/ws_eapol_pdu.h"
69+
#include "6LoWPAN/ws/ws_eapol_auth_relay.h"
70+
#include "6LoWPAN/ws/ws_eapol_relay.h"
2771

2872
#include "mac_api.h"
2973

@@ -71,3 +115,8 @@ bool ws_eapol_relay_state_active(protocol_interface_info_entry_t *cur)
71115
{
72116
return false;
73117
}
118+
119+
void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur, llc_neighbour_req_t *neighbor_info, ws_bs_ie_t *ws_bs_ie)
120+
{
121+
122+
}

0 commit comments

Comments
 (0)