Skip to content

Commit cfc3223

Browse files
author
Juha Heiskanen
committed
RPL parent confirmation process update
Confirmation start updates: Confirmation start will verified that we have selected a proper parent and linked dao path control to that. Confirmation status update: If confirmation fail by addres egistration full process is stopped and wait that timed parent slection trig process back again. Change-Id: Idd740a2381ff3db5587f05c6e4bd97c52256125b
1 parent c3a2c5c commit cfc3223

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

source/RPL/rpl_downward.c

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ static void rpl_downward_target_refresh(rpl_dao_target_t *target)
180180
target->info.non_root.path_lifetime = 0;
181181
}
182182

183+
static bool rpl_instance_parent_selection_ready(rpl_instance_t *instance)
184+
{
185+
rpl_neighbour_t *neighbour = ns_list_get_first(&instance->candidate_neighbours);
186+
if (neighbour && neighbour->dodag_parent && neighbour->dao_path_control) {
187+
//We have a Primary parent with Dao patha control
188+
return true;
189+
}
190+
return false;
191+
}
192+
183193
void rpl_downward_neighbour_gone(rpl_instance_t *instance, rpl_neighbour_t *neighbour)
184194
{
185195
if (neighbour->dao_path_control == 0) {
@@ -380,6 +390,7 @@ void rpl_instance_publish_dao_target(rpl_instance_t *instance, const uint8_t *pr
380390
tr_debug("New Target %s", trace_ipv6(target->prefix));
381391
/* Path lifetime left as 0 for now - will be filled in on transmission, along with refresh timer */
382392
rpl_instance_dao_trigger(instance, 0);
393+
383394
}
384395

385396
void rpl_instance_dao_trigger(rpl_instance_t *instance, uint16_t delay)
@@ -627,6 +638,11 @@ static rpl_dao_target_t *rpl_instance_get_pending_target_confirmation(rpl_instan
627638

628639
void rpl_instance_send_address_registration(rpl_instance_t *instance, const uint8_t addr[16])
629640
{
641+
if (!rpl_instance_parent_selection_ready(instance)) {
642+
return;
643+
}
644+
645+
630646
if (addr) {
631647
rpl_dao_target_t *target = rpl_instance_get_pending_target_confirmation_for_address(instance, addr);
632648
if (!target) {
@@ -1751,14 +1767,31 @@ static if_address_entry_t *rpl_interface_addr_get(protocol_interface_info_entry_
17511767
return NULL;
17521768
}
17531769

1770+
static void rpl_instance_address_registration_cancel(rpl_instance_t *instance)
1771+
{
1772+
ns_list_foreach_safe(rpl_dao_target_t, n, &instance->dao_targets) {
1773+
n->active_confirmation_state = false;
1774+
n->trig_confirmation_state = false;
1775+
n->response_wait_time = 0;
1776+
}
17541777

1778+
instance->wait_response = NULL;
1779+
instance->pending_neighbour_confirmation = false;
1780+
instance->delay_dao_timer = 0;
1781+
}
17551782

17561783
void rpl_instance_parent_address_reg_timer_update(rpl_instance_t *instance, uint16_t seconds)
17571784
{
17581785
if (!instance->pending_neighbour_confirmation) {
17591786
return; //No need validate any confirmation
17601787
}
17611788

1789+
//Verify that we have selected parent and it have a dao path control
1790+
if (!rpl_instance_parent_selection_ready(instance)) {
1791+
rpl_instance_address_registration_cancel(instance);
1792+
return;
1793+
}
1794+
17621795
//Get Pendig active target
17631796
rpl_dao_target_t *dao_target = rpl_instance_get_active_target_confirmation(instance);
17641797
if (!dao_target) {
@@ -1772,8 +1805,7 @@ void rpl_instance_parent_address_reg_timer_update(rpl_instance_t *instance, uint
17721805
}
17731806

17741807
if (instance->wait_response) {
1775-
uint16_t wait_time = dao_target->response_wait_time;
1776-
if (seconds < wait_time) {
1808+
if (seconds < dao_target->response_wait_time) {
17771809
//Must Wait response time untill finish
17781810
dao_target->response_wait_time -= seconds;
17791811
return;
@@ -1792,17 +1824,13 @@ void rpl_instance_parent_address_reg_timer_update(rpl_instance_t *instance, uint
17921824
//Get address and buffer
17931825
protocol_interface_info_entry_t *interface = protocol_stack_interface_info_get_by_id(neighbour->interface_id);
17941826
if (!interface) {
1795-
dao_target->response_wait_time = 0;
1796-
instance->wait_response = NULL;
1797-
dao_target->active_confirmation_state = false;
1827+
rpl_instance_address_registration_cancel(instance);
17981828
return;
17991829
}
18001830

18011831
if_address_entry_t *address = rpl_interface_addr_get(interface, dao_target->prefix);
18021832
if (!address) {
1803-
dao_target->response_wait_time = 0;
1804-
instance->wait_response = NULL;
1805-
dao_target->active_confirmation_state = false;
1833+
rpl_instance_address_registration_cancel(instance);
18061834
return;
18071835
}
18081836

@@ -1839,6 +1867,7 @@ void rpl_instance_address_registration_done(protocol_interface_info_entry_t *int
18391867
} else {
18401868
tr_error("Address registration failed");
18411869
rpl_delete_neighbour(instance, neighbour);
1870+
rpl_instance_address_registration_cancel(instance);
18421871
}
18431872
}
18441873

0 commit comments

Comments
 (0)