Skip to content

Commit b5d276d

Browse files
author
Mika Tervonen
committed
refactored trickkle running checks
Added boolean to check when trickle is running trickle_running and trickle_stop are not meant to be checkking the high level status of trickle No need to check status anymore for running when analysing inconsistent/consistent state Fixed trickle timer function name
1 parent 61ff793 commit b5d276d

File tree

4 files changed

+50
-29
lines changed

4 files changed

+50
-29
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,10 @@ void ws_bootstrap_configuration_reset(protocol_interface_info_entry_t *cur)
478478

479479
cur->nwk_bootstrap_state = ER_ACTIVE_SCAN;
480480
cur->ws_info->network_pan_id = 0xffff;
481-
trickle_stop(&cur->ws_info->trickle_pan_advertisement_solicit);
482-
trickle_stop(&cur->ws_info->trickle_pan_advertisement);
483-
trickle_stop(&cur->ws_info->trickle_pan_config_solicit);
484-
trickle_stop(&cur->ws_info->trickle_pan_config);
481+
cur->ws_info->trickle_pas_running = false;
482+
cur->ws_info->trickle_pa_running = false;
483+
cur->ws_info->trickle_pcs_running = false;
484+
cur->ws_info->trickle_pc_running = false;
485485

486486
//cur->mac_security_key_usage_update_cb = ws_management_mac_security_key_update_cb;
487487
return;
@@ -524,9 +524,7 @@ static void ws_bootstrap_pan_advertisement_analyse_active(struct protocol_interf
524524
if (pan_information->routing_cost <= cur->ws_info->pan_information.routing_cost) {
525525
trickle_consistent_heard(&cur->ws_info->trickle_pan_advertisement);
526526
} else {
527-
if (trickle_running(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery)) {
528-
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery);
529-
}
527+
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery);
530528
}
531529

532530
}
@@ -655,9 +653,7 @@ static void ws_bootstrap_pan_advertisement_solicit_analyse(struct protocol_inter
655653
* An inconsistent transmission is defined as:
656654
* A PAN Advertisement Solicit with NETNAME-IE matching that of the receiving node.
657655
*/
658-
if (trickle_running(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery)) {
659-
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery);
660-
}
656+
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery);
661657
/*
662658
* A consistent transmission is defined as
663659
* a PAN Advertisement Solicit with NETNAME-IE / Network Name matching that configured on the receiving node.
@@ -734,9 +730,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
734730
trickle_consistent_heard(&cur->ws_info->trickle_pan_config);
735731
} else {
736732
tr_info("different pan version heard");
737-
if (trickle_running(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery)) {
738-
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
739-
}
733+
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
740734
if (common_serial_number_greater_16(cur->ws_info->pan_information.pan_version, pan_version)) {
741735
// older version heard ignoring the message
742736
return;
@@ -813,9 +807,7 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
813807
* A PAN Configuration Solicit with a PAN-ID matching that of the receiving node and
814808
* a NETNAME-IE / Network Name matching the network name configured on the receiving
815809
*/
816-
if (trickle_running(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery)) {
817-
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
818-
}
810+
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
819811
}
820812
static bool ws_bootstrap_network_found(protocol_interface_info_entry_t *cur)
821813
{
@@ -1336,8 +1328,10 @@ static void ws_bootstrap_network_discovery_configure(protocol_interface_info_ent
13361328

13371329
static void ws_bootstrap_advertise_start(protocol_interface_info_entry_t *cur)
13381330
{
1331+
cur->ws_info->trickle_pa_running = true;
13391332
trickle_start(&cur->ws_info->trickle_pan_advertisement, &trickle_params_pan_discovery);
13401333
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement, &trickle_params_pan_discovery);
1334+
cur->ws_info->trickle_pc_running = true;
13411335
trickle_start(&cur->ws_info->trickle_pan_config, &trickle_params_pan_discovery);
13421336
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config, &trickle_params_pan_discovery);
13431337
}
@@ -1365,6 +1359,7 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur)
13651359
ws_bootstrap_ip_stack_addr_clear(cur);
13661360

13671361
// Reset advertisement solicit trickle to start discovering network
1362+
cur->ws_info->trickle_pas_running = true;
13681363
trickle_start(&cur->ws_info->trickle_pan_advertisement_solicit, &trickle_params_pan_discovery);
13691364
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement_solicit, &trickle_params_pan_discovery);
13701365

@@ -1386,6 +1381,7 @@ static void ws_bootstrap_start_configuration_learn(protocol_interface_info_entry
13861381

13871382
cur->ws_info->pas_requests = 0;
13881383
// Reset advertisement solicit trickle to start discovering network
1384+
cur->ws_info->trickle_pcs_running = true;
13891385
trickle_start(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery);
13901386
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery);
13911387
}
@@ -1592,8 +1588,11 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
15921588
break;
15931589
case WS_DISCOVERY_START:
15941590
tr_info("Discovery start");
1595-
trickle_stop(&cur->ws_info->trickle_pan_advertisement);
1596-
trickle_stop(&cur->ws_info->trickle_pan_config);
1591+
// All trikkles stopped so here can be entered anytime
1592+
cur->ws_info->trickle_pa_running = false;
1593+
cur->ws_info->trickle_pc_running = false;
1594+
cur->ws_info->trickle_pas_running = false;
1595+
cur->ws_info->trickle_pcs_running = false;
15971596

15981597
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
15991598
tr_debug("Border router start network");
@@ -1625,25 +1624,33 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
16251624
break;
16261625
case WS_AUTHENTICATION_START:
16271626
tr_info("authentication start");
1628-
trickle_stop(&cur->ws_info->trickle_pan_advertisement_solicit);
1627+
// only advert sol stopped as we might be doing re authentication
1628+
cur->ws_info->trickle_pas_running = false;
16291629
//Add Test ecurity key and security level's
16301630
ws_bootstrap_set_test_key(cur);
16311631
ws_bootstrap_event_configuration_start(cur);
16321632
break;
16331633
case WS_CONFIGURATION_START:
16341634
tr_info("Configuration start");
1635-
trickle_stop(&cur->ws_info->trickle_pan_advertisement);
1636-
trickle_stop(&cur->ws_info->trickle_pan_config);
1635+
// Old configuration is considered invalid stopping all
1636+
cur->ws_info->trickle_pa_running = false;
1637+
cur->ws_info->trickle_pc_running = false;
1638+
cur->ws_info->trickle_pas_running = false;
1639+
cur->ws_info->trickle_pcs_running = false;
16371640

16381641
// Build list of possible neighbours and learn first broadcast schedule
16391642

16401643
ws_bootstrap_start_configuration_learn(cur);
16411644
break;
16421645
case WS_OPERATION_START:
16431646
tr_info("operation start");
1647+
// Advertisements stopped during the RPL scan
1648+
cur->ws_info->trickle_pa_running = false;
1649+
cur->ws_info->trickle_pc_running = false;
1650+
cur->ws_info->trickle_pas_running = false;
1651+
cur->ws_info->trickle_pcs_running = false;
16441652
// Activate RPL
16451653
// Activate IPv6 stack
1646-
trickle_stop(&cur->ws_info->trickle_pan_config_solicit);
16471654
ws_bootstrap_ip_stack_activate(cur);
16481655
ws_bootstrap_rpl_activate(cur);
16491656
ws_bootstrap_network_start(cur);
@@ -1656,6 +1663,12 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
16561663
break;
16571664
case WS_ROUTING_READY:
16581665
tr_info("Routing ready");
1666+
// stopped all to make sure we can enter here from any state
1667+
cur->ws_info->trickle_pa_running = false;
1668+
cur->ws_info->trickle_pc_running = false;
1669+
cur->ws_info->trickle_pas_running = false;
1670+
cur->ws_info->trickle_pcs_running = false;
1671+
16591672
ws_bootstrap_advertise_start(cur);
16601673
ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE);
16611674
break;
@@ -1795,14 +1808,16 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
17951808
}
17961809
}
17971810

1798-
void ws_bootstrap_trigle_timer(protocol_interface_info_entry_t *cur, uint16_t ticks)
1811+
void ws_bootstrap_trickle_timer(protocol_interface_info_entry_t *cur, uint16_t ticks)
17991812
{
1800-
if(trickle_timer(&cur->ws_info->trickle_pan_advertisement_solicit, &trickle_params_pan_discovery, ticks)) {
1813+
if(cur->ws_info->trickle_pas_running &&
1814+
trickle_timer(&cur->ws_info->trickle_pan_advertisement_solicit, &trickle_params_pan_discovery, ticks)) {
18011815
// send PAN advertisement solicit
18021816
tr_info("Send PAN advertisement Solicit");
18031817
ws_bootstrap_pan_advert_solicit(cur);
18041818
}
1805-
if(trickle_timer(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery, ticks)) {
1819+
if(cur->ws_info->trickle_pcs_running &&
1820+
trickle_timer(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery, ticks)) {
18061821
// send PAN Configuration solicit
18071822
if (cur->ws_info->pas_requests > PCS_MAX) {
18081823
// if MAX PCS sent restart discovery
@@ -1814,12 +1829,14 @@ void ws_bootstrap_trigle_timer(protocol_interface_info_entry_t *cur, uint16_t ti
18141829
cur->ws_info->pas_requests++;
18151830
ws_bootstrap_pan_config_solicit(cur);
18161831
}
1817-
if(trickle_timer(&cur->ws_info->trickle_pan_advertisement, &trickle_params_pan_discovery, ticks)) {
1832+
if(cur->ws_info->trickle_pa_running &&
1833+
trickle_timer(&cur->ws_info->trickle_pan_advertisement, &trickle_params_pan_discovery, ticks)) {
18181834
// send PAN advertisement
18191835
tr_info("Send PAN advertisement");
18201836
ws_bootstrap_pan_advert(cur);
18211837
}
1822-
if(trickle_timer(&cur->ws_info->trickle_pan_config, &trickle_params_pan_discovery, ticks)) {
1838+
if(cur->ws_info->trickle_pc_running &&
1839+
trickle_timer(&cur->ws_info->trickle_pan_config, &trickle_params_pan_discovery, ticks)) {
18231840
// send PAN Configuration
18241841
tr_info("Send PAN configuration");
18251842
ws_bootstrap_pan_config(cur);

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *c
5252

5353
void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds);
5454

55-
void ws_bootstrap_trigle_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
55+
void ws_bootstrap_trickle_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
5656

5757
#else
5858

source/6LoWPAN/ws/ws_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void ws_common_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seco
171171

172172
void ws_common_fast_timer(protocol_interface_info_entry_t *cur, uint16_t ticks)
173173
{
174-
ws_bootstrap_trigle_timer(cur, ticks);
174+
ws_bootstrap_trickle_timer(cur, ticks);
175175
}
176176

177177

source/6LoWPAN/ws/ws_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ typedef struct ws_info_s {
5555
uint32_t pan_version_timeout_timer; /**< routers will fallback to previous state after this */
5656
uint8_t gtkhash[32];
5757
bool configuration_learned:1;
58+
bool trickle_pas_running:1;
59+
bool trickle_pa_running:1;
60+
bool trickle_pcs_running:1;
61+
bool trickle_pc_running:1;
5862
// default fhss parameters for this device
5963
uint8_t fhss_uc_dwell_interval;
6064
uint8_t fhss_bc_dwell_interval;

0 commit comments

Comments
 (0)