nd6: add LWIP_HOOK_ND6_GET_GW hook

This commit is contained in:
David van Moolenbroek 2016-12-13 20:40:22 +00:00 committed by goldsimon
parent 74a5537e15
commit 7d119fd86b
2 changed files with 25 additions and 0 deletions

View File

@ -1524,6 +1524,9 @@ nd6_new_onlink_prefix(ip6_addr_t *prefix, struct netif *netif)
s8_t
nd6_get_next_hop_entry(const ip6_addr_t *ip6addr, struct netif *netif)
{
#ifdef LWIP_HOOK_ND6_GET_GW
const ip6_addr_t *next_hop_addr;
#endif /* LWIP_HOOK_ND6_GET_GW */
s8_t i;
#if LWIP_NETIF_HWADDRHINT
@ -1567,6 +1570,12 @@ nd6_get_next_hop_entry(const ip6_addr_t *ip6addr, struct netif *netif)
/* Destination in local link. */
destination_cache[nd6_cached_destination_index].pmtu = netif->mtu;
ip6_addr_copy(destination_cache[nd6_cached_destination_index].next_hop_addr, destination_cache[nd6_cached_destination_index].destination_addr);
#ifdef LWIP_HOOK_ND6_GET_GW
} else if ((next_hop_addr = LWIP_HOOK_ND6_GET_GW(netif, ip6addr)) != NULL) {
/* Next hop for destination provided by hook function. */
destination_cache[nd6_cached_destination_index].pmtu = netif->mtu;
ip6_addr_set(&destination_cache[nd6_cached_destination_index].next_hop_addr, next_hop_addr);
#endif /* LWIP_HOOK_ND6_GET_GW */
} else {
/* We need to select a router. */
i = nd6_select_router(ip6addr, netif);

View File

@ -2469,6 +2469,22 @@
#define LWIP_HOOK_IP6_ROUTE(src, dest)
#endif
/**
* LWIP_HOOK_ND6_GET_GW(netif, dest):
* - called from nd6_get_next_hop_entry() (IPv6)
* - netif: the netif used for sending
* - dest: the destination IPv6 address
* Returns the IPv6 address of the next hop to handle the specified destination
* IPv6 address. If NULL is returned, a NDP-discovered router is used instead.
* The returned address MUST be reachable on the specified netif!
* This function is meant to implement advanced IPv6 routing together with
* LWIP_HOOK_IP6_ROUTE(). The actual routing/gateway table implementation is
* not part of lwIP but can e.g. be hidden in the netif's state argument.
*/
#ifdef __DOXYGEN__
#define LWIP_HOOK_ND6_GET_GW(netif, dest)
#endif
/**
* LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr):
* - called from ethernet_input() if VLAN support is enabled