From 08bcfd69727e020694006c0e7fe9e6151c8fa6d8 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 21 Sep 2015 18:23:14 +0200 Subject: [PATCH] RPL: added callback for parent switches --- core/net/rpl/rpl-dag.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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);