From 77d8322da85518381d8abbb34ac54b99e036434f Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 21 Sep 2015 18:32:15 +0200 Subject: [PATCH] uip-ds6-route: added callback for next hop addition and removal --- core/net/ipv6/uip-ds6-route.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/net/ipv6/uip-ds6-route.c b/core/net/ipv6/uip-ds6-route.c index 49674d8ba..3f4ac81e7 100644 --- a/core/net/ipv6/uip-ds6-route.c +++ b/core/net/ipv6/uip-ds6-route.c @@ -47,12 +47,22 @@ #include +/* A configurable function called after adding a new neighbor as next hop */ +#ifdef NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK +void NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK(const linkaddr_t *addr); +#endif /* NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK */ + +/* A configurable function called after removing a next hop neighbor */ +#ifdef NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK +void NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK(const linkaddr_t *addr); +#endif /* NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK */ + /* The nbr_routes holds a neighbor table to be able to maintain information about what routes go through what neighbor. This neighbor table is registered with the central nbr-table repository so that it will be maintained along with the rest of the neighbor tables in the system. */ -NBR_TABLE(struct uip_ds6_route_neighbor_routes, nbr_routes); +NBR_TABLE_GLOBAL(struct uip_ds6_route_neighbor_routes, nbr_routes); MEMB(neighborroutememb, struct uip_ds6_route_neighbor_route, UIP_DS6_ROUTE_NB); /* Each route is repressented by a uip_ds6_route_t structure and @@ -335,6 +345,9 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length, return NULL; } LIST_STRUCT_INIT(routes, route_list); +#ifdef NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK + NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK((const linkaddr_t *)nexthop_lladdr); +#endif } /* Allocate a routing entry and populate it. */ @@ -435,6 +448,10 @@ uip_ds6_route_rm(uip_ds6_route_t *route) #endif /* (DEBUG) & DEBUG_ANNOTATE */ PRINTF("uip_ds6_route_rm: removing neighbor too\n"); nbr_table_remove(nbr_routes, route->neighbor_routes->route_list); +#ifdef NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK + NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK( + (const linkaddr_t *)nbr_table_get_lladdr(nbr_routes, route->neighbor_routes->route_list)); +#endif } memb_free(&routememb, route); memb_free(&neighborroutememb, neighbor_route);