@@ -192,20 +192,18 @@ static bool rpl_instance_parent_selection_ready(rpl_instance_t *instance)
192192
193193void rpl_downward_neighbour_gone (rpl_instance_t * instance , rpl_neighbour_t * neighbour )
194194{
195- if (neighbour -> dao_path_control == 0 ) {
196- return ;
197- }
198- neighbour -> old_dao_path_control = neighbour -> dao_path_control ;
199- neighbour -> dao_path_control = 0 ;
200- rpl_downward_process_dao_parent_changes (instance );
195+
196+ // Currently don't need to do anything - caller is expected to
197+ // trigger parent selection, which will do everything required.
198+ (void ) instance ;
199+ (void ) neighbour ;
201200}
202201
203202void rpl_downward_process_dao_parent_changes (rpl_instance_t * instance )
204203{
205- uint8_t mop = rpl_instance_mop (instance );
206204 bool storing ;
207205
208- switch (mop ) {
206+ switch (rpl_instance_mop ( instance ) ) {
209207 case RPL_MODE_NON_STORING :
210208 storing = false;
211209 break ;
@@ -219,6 +217,7 @@ void rpl_downward_process_dao_parent_changes(rpl_instance_t *instance)
219217
220218 bool bits_removed = false;
221219 uint8_t bits_added = 0 ;
220+
222221 ns_list_foreach (rpl_neighbour_t , neighbour , & instance -> candidate_neighbours ) {
223222 if (neighbour -> old_dao_path_control != neighbour -> dao_path_control ) {
224223 if (neighbour -> old_dao_path_control & ~ neighbour -> dao_path_control ) {
@@ -230,11 +229,21 @@ void rpl_downward_process_dao_parent_changes(rpl_instance_t *instance)
230229 }
231230 }
232231 }
233- tr_debug ( "removed=%x, added=%x" , bits_removed , bits_added );
232+
234233 if (!(bits_removed || bits_added )) {
235234 return ;
236235 }
237236
237+ tr_debug ("removed=%x, added=%x" , bits_removed , bits_added );
238+
239+ ns_list_foreach (rpl_neighbour_t , neighbour , & instance -> candidate_neighbours ) {
240+ if (neighbour -> dao_path_control != 0 && neighbour -> old_dao_path_control == 0 ) {
241+ //Candidate has become a DAO parent
242+ rpl_control_event (instance -> domain , RPL_EVENT_DAO_PARENT_ADD );
243+ break ;
244+ }
245+ }
246+
238247 if (storing ) {
239248 /* XXX more complicated - No-Paths to people losing stuff, etc.
240249 * Need to think a bit about what each parent would have had.
@@ -253,8 +262,8 @@ void rpl_downward_process_dao_parent_changes(rpl_instance_t *instance)
253262 }
254263 }
255264 }
256- //GENERATE PARENT Update event
257- rpl_control_event ( instance -> domain , RPL_EVENT_DAO_PARENT_SWITCH );
265+
266+ //Trig DAO allways after change
258267 rpl_instance_dao_trigger (instance , 0 );
259268 }
260269}
0 commit comments