diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 7403f9931..20507449d 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -60,6 +60,11 @@ #define DEBUG DEBUG_NONE #include "net/ip/uip-debug.h" +/* A configurable function called after every RPL parent switch */ +#ifdef RPL_CALLBACK_PARENT_SWITCH +void RPL_CALLBACK_PARENT_SWITCH(rpl_parent_t *old, rpl_parent_t *new); +#endif /* RPL_CALLBACK_PARENT_SWITCH */ + /*---------------------------------------------------------------------------*/ extern rpl_of_t RPL_OF; static rpl_of_t * const objective_functions[] = {&RPL_OF}; @@ -188,6 +193,10 @@ rpl_set_preferred_parent(rpl_dag_t *dag, rpl_parent_t *p) } PRINTF("\n"); +#ifdef RPL_CALLBACK_PARENT_SWITCH + RPL_CALLBACK_PARENT_SWITCH(dag->preferred_parent, p); +#endif /* RPL_CALLBACK_PARENT_SWITCH */ + /* Always keep the preferred parent locked, so it remains in the * neighbor table. */ nbr_table_unlock(rpl_parents, dag->preferred_parent);