@@ -192,20 +192,18 @@ static bool rpl_instance_parent_selection_ready(rpl_instance_t *instance)
192
192
193
193
void rpl_downward_neighbour_gone (rpl_instance_t * instance , rpl_neighbour_t * neighbour )
194
194
{
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 ;
201
200
}
202
201
203
202
void rpl_downward_process_dao_parent_changes (rpl_instance_t * instance )
204
203
{
205
- uint8_t mop = rpl_instance_mop (instance );
206
204
bool storing ;
207
205
208
- switch (mop ) {
206
+ switch (rpl_instance_mop ( instance ) ) {
209
207
case RPL_MODE_NON_STORING :
210
208
storing = false;
211
209
break ;
@@ -219,6 +217,7 @@ void rpl_downward_process_dao_parent_changes(rpl_instance_t *instance)
219
217
220
218
bool bits_removed = false;
221
219
uint8_t bits_added = 0 ;
220
+
222
221
ns_list_foreach (rpl_neighbour_t , neighbour , & instance -> candidate_neighbours ) {
223
222
if (neighbour -> old_dao_path_control != neighbour -> dao_path_control ) {
224
223
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)
230
229
}
231
230
}
232
231
}
233
- tr_debug ( "removed=%x, added=%x" , bits_removed , bits_added );
232
+
234
233
if (!(bits_removed || bits_added )) {
235
234
return ;
236
235
}
237
236
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
+
238
247
if (storing ) {
239
248
/* XXX more complicated - No-Paths to people losing stuff, etc.
240
249
* 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)
253
262
}
254
263
}
255
264
}
256
- //GENERATE PARENT Update event
257
- rpl_control_event ( instance -> domain , RPL_EVENT_DAO_PARENT_SWITCH );
265
+
266
+ //Trig DAO allways after change
258
267
rpl_instance_dao_trigger (instance , 0 );
259
268
}
260
269
}
0 commit comments