From cee59ba8cdae886afbcb8e514da6dbb2d7b6519e Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Wed, 14 Dec 2016 12:44:23 +0000 Subject: [PATCH] nd6: add nd6_clear_destination_cache() function The new function, while currently not used internally, allows external code to clear the ND destination cache in the case that it may have become inconsistent with the current situation, for example as the result of a change of locally assigned addresses, or a change in routing tables implemented through the LWIP_HOOK_ND6_GET_GW hook. --- src/core/ipv6/nd6.c | 16 ++++++++++++++++ src/include/lwip/nd6.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c index 72a25239..37b91dbb 100644 --- a/src/core/ipv6/nd6.c +++ b/src/core/ipv6/nd6.c @@ -1293,6 +1293,22 @@ nd6_new_destination_cache_entry(void) return j; } +/** + * Clear the destination cache. + * + * This operation may be necessary for consistency in the light of changing + * local addresses and/or use of the gateway hook. + */ +void +nd6_clear_destination_cache(void) +{ + s8_t i; + + for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) { + ip6_addr_set_any(&destination_cache[i].destination_addr); + } +} + /** * Determine whether an address matches an on-link prefix. * diff --git a/src/include/lwip/nd6.h b/src/include/lwip/nd6.h index e4715ad3..e6e2d9c1 100644 --- a/src/include/lwip/nd6.h +++ b/src/include/lwip/nd6.h @@ -141,6 +141,7 @@ extern u32_t retrans_timer; void nd6_tmr(void); void nd6_input(struct pbuf *p, struct netif *inp); +void nd6_clear_destination_cache(void); s8_t nd6_get_next_hop_entry(const ip6_addr_t *ip6addr, struct netif *netif); s8_t nd6_select_router(const ip6_addr_t *ip6addr, struct netif *netif); u16_t nd6_get_destination_mtu(const ip6_addr_t *ip6addr, struct netif *netif);