mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
nd6: use default_router_list internally only
This patch rearranges the code division between nd6.c and ip6.c such that the latter does not need to access ND6-internal data structures (specifically, "default_router_list") directly anymore.
This commit is contained in:
parent
cee59ba8cd
commit
06ff89cbe4
@ -144,15 +144,9 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
}
|
||||
|
||||
/* Get the netif for a suitable router. */
|
||||
i = nd6_select_router(dest, NULL);
|
||||
if (i >= 0) {
|
||||
if (default_router_list[i].neighbor_entry != NULL) {
|
||||
if (default_router_list[i].neighbor_entry->netif != NULL) {
|
||||
if (netif_is_up(default_router_list[i].neighbor_entry->netif) && netif_is_link_up(default_router_list[i].neighbor_entry->netif)) {
|
||||
return default_router_list[i].neighbor_entry->netif;
|
||||
}
|
||||
}
|
||||
}
|
||||
netif = nd6_find_route(dest);
|
||||
if (netif != NULL && netif_is_up(netif) && netif_is_link_up(netif)) {
|
||||
return netif;
|
||||
}
|
||||
|
||||
/* try with the netif that matches the source address. */
|
||||
|
@ -93,6 +93,7 @@ static void nd6_free_neighbor_cache_entry(s8_t i);
|
||||
static s8_t nd6_find_destination_cache_entry(const ip6_addr_t *ip6addr);
|
||||
static s8_t nd6_new_destination_cache_entry(void);
|
||||
static s8_t nd6_is_prefix_in_netif(const ip6_addr_t *ip6addr, struct netif *netif);
|
||||
static s8_t nd6_select_router(const ip6_addr_t *ip6addr, struct netif *netif);
|
||||
static s8_t nd6_get_router(const ip6_addr_t *router_addr, struct netif *netif);
|
||||
static s8_t nd6_new_router(const ip6_addr_t *router_addr, struct netif *netif);
|
||||
static s8_t nd6_get_onlink_prefix(ip6_addr_t *prefix, struct netif *netif);
|
||||
@ -1396,6 +1397,30 @@ nd6_select_router(const ip6_addr_t *ip6addr, struct netif *netif)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a router-announced route to the given destination.
|
||||
*
|
||||
* The caller is responsible for checking whether the returned netif, if any,
|
||||
* is in a suitable state (up, link up) to be used for packet transmission.
|
||||
*
|
||||
* @param ip6addr the destination IPv6 address
|
||||
* @return the netif to use for the destination, or NULL if none found
|
||||
*/
|
||||
struct netif *
|
||||
nd6_find_route(const ip6_addr_t *ip6addr)
|
||||
{
|
||||
s8_t i;
|
||||
|
||||
i = nd6_select_router(ip6addr, NULL);
|
||||
if (i >= 0) {
|
||||
if (default_router_list[i].neighbor_entry != NULL) {
|
||||
return default_router_list[i].neighbor_entry->netif; /* may be NULL */
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an entry for a default router.
|
||||
*
|
||||
|
@ -143,7 +143,7 @@ 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);
|
||||
struct netif *nd6_find_route(const ip6_addr_t *ip6addr);
|
||||
u16_t nd6_get_destination_mtu(const ip6_addr_t *ip6addr, struct netif *netif);
|
||||
err_t nd6_queue_packet(s8_t neighbor_index, struct pbuf *p);
|
||||
#if LWIP_ND6_TCP_REACHABILITY_HINTS
|
||||
|
Loading…
Reference in New Issue
Block a user