@@ -180,6 +180,16 @@ static void rpl_downward_target_refresh(rpl_dao_target_t *target)
180
180
target -> info .non_root .path_lifetime = 0 ;
181
181
}
182
182
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
+
183
193
void rpl_downward_neighbour_gone (rpl_instance_t * instance , rpl_neighbour_t * neighbour )
184
194
{
185
195
if (neighbour -> dao_path_control == 0 ) {
@@ -380,6 +390,7 @@ void rpl_instance_publish_dao_target(rpl_instance_t *instance, const uint8_t *pr
380
390
tr_debug ("New Target %s" , trace_ipv6 (target -> prefix ));
381
391
/* Path lifetime left as 0 for now - will be filled in on transmission, along with refresh timer */
382
392
rpl_instance_dao_trigger (instance , 0 );
393
+
383
394
}
384
395
385
396
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
627
638
628
639
void rpl_instance_send_address_registration (rpl_instance_t * instance , const uint8_t addr [16 ])
629
640
{
641
+ if (!rpl_instance_parent_selection_ready (instance )) {
642
+ return ;
643
+ }
644
+
645
+
630
646
if (addr ) {
631
647
rpl_dao_target_t * target = rpl_instance_get_pending_target_confirmation_for_address (instance , addr );
632
648
if (!target ) {
@@ -1751,14 +1767,31 @@ static if_address_entry_t *rpl_interface_addr_get(protocol_interface_info_entry_
1751
1767
return NULL ;
1752
1768
}
1753
1769
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
+ }
1754
1777
1778
+ instance -> wait_response = NULL ;
1779
+ instance -> pending_neighbour_confirmation = false;
1780
+ instance -> delay_dao_timer = 0 ;
1781
+ }
1755
1782
1756
1783
void rpl_instance_parent_address_reg_timer_update (rpl_instance_t * instance , uint16_t seconds )
1757
1784
{
1758
1785
if (!instance -> pending_neighbour_confirmation ) {
1759
1786
return ; //No need validate any confirmation
1760
1787
}
1761
1788
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
+
1762
1795
//Get Pendig active target
1763
1796
rpl_dao_target_t * dao_target = rpl_instance_get_active_target_confirmation (instance );
1764
1797
if (!dao_target ) {
@@ -1772,8 +1805,7 @@ void rpl_instance_parent_address_reg_timer_update(rpl_instance_t *instance, uint
1772
1805
}
1773
1806
1774
1807
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 ) {
1777
1809
//Must Wait response time untill finish
1778
1810
dao_target -> response_wait_time -= seconds ;
1779
1811
return ;
@@ -1792,17 +1824,13 @@ void rpl_instance_parent_address_reg_timer_update(rpl_instance_t *instance, uint
1792
1824
//Get address and buffer
1793
1825
protocol_interface_info_entry_t * interface = protocol_stack_interface_info_get_by_id (neighbour -> interface_id );
1794
1826
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 );
1798
1828
return ;
1799
1829
}
1800
1830
1801
1831
if_address_entry_t * address = rpl_interface_addr_get (interface , dao_target -> prefix );
1802
1832
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 );
1806
1834
return ;
1807
1835
}
1808
1836
@@ -1839,6 +1867,7 @@ void rpl_instance_address_registration_done(protocol_interface_info_entry_t *int
1839
1867
} else {
1840
1868
tr_error ("Address registration failed" );
1841
1869
rpl_delete_neighbour (instance , neighbour );
1870
+ rpl_instance_address_registration_cancel (instance );
1842
1871
}
1843
1872
}
1844
1873
0 commit comments