diff --git a/sys/include/net/gnrc/rpl/dodag.h b/sys/include/net/gnrc/rpl/dodag.h index 6cdebf7edc..8fca28712b 100644 --- a/sys/include/net/gnrc/rpl/dodag.h +++ b/sys/include/net/gnrc/rpl/dodag.h @@ -147,6 +147,14 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent); */ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent); +/** + * @brief Removes the dodag state of @p dodag after + * GNRC_RPL_CLEANUP_TIME milliseconds + * + * @param[in] dodag Pointer to the DODAG + */ +void gnrc_rpl_cleanup_start(gnrc_rpl_dodag_t *dodag); + /** * @brief Start a local repair. * diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c index 4631d1902f..c3f7bc75a7 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c @@ -246,6 +246,14 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent) return true; } +void gnrc_rpl_cleanup_start(gnrc_rpl_dodag_t *dodag) +{ + evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)&dodag->instance->cleanup_event); + ((evtimer_event_t *)&(dodag->instance->cleanup_event))->offset = GNRC_RPL_CLEANUP_TIME; + dodag->instance->cleanup_event.msg.type = GNRC_RPL_MSG_TYPE_INSTANCE_CLEANUP; + evtimer_add_msg(&gnrc_rpl_evtimer, &dodag->instance->cleanup_event, gnrc_rpl_pid); +} + void gnrc_rpl_local_repair(gnrc_rpl_dodag_t *dodag) { DEBUG("RPL: [INFO] Local Repair started\n"); @@ -260,10 +268,7 @@ void gnrc_rpl_local_repair(gnrc_rpl_dodag_t *dodag) if (dodag->my_rank != GNRC_RPL_INFINITE_RANK) { dodag->my_rank = GNRC_RPL_INFINITE_RANK; trickle_reset_timer(&dodag->trickle); - evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)&dodag->instance->cleanup_event); - ((evtimer_event_t *)&(dodag->instance->cleanup_event))->offset = GNRC_RPL_CLEANUP_TIME; - dodag->instance->cleanup_event.msg.type = GNRC_RPL_MSG_TYPE_INSTANCE_CLEANUP; - evtimer_add_msg(&gnrc_rpl_evtimer, &dodag->instance->cleanup_event, gnrc_rpl_pid); + gnrc_rpl_cleanup_start(dodag); } } diff --git a/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c b/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c index 8c7bebd35f..b2551b6073 100644 --- a/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c +++ b/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c @@ -56,7 +56,7 @@ void gnrc_rpl_p2p_update(void) p2p_ext->lifetime_sec -= GNRC_RPL_LIFETIME_UPDATE_STEP; if (p2p_ext->lifetime_sec <= 0) { gnrc_rpl_dodag_remove_all_parents(p2p_ext->dodag); - p2p_ext->dodag->instance->cleanup = GNRC_RPL_CLEANUP_TIME; + gnrc_rpl_cleanup_start(p2p_ext->dodag); continue; } p2p_ext->dro_delay -= GNRC_RPL_LIFETIME_UPDATE_STEP;