mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-17 17:10:03 +00:00
Added LWIP_HOOK_ETHARP_GET_GW to implement IPv4 routing with multiple gateways
This commit is contained in:
parent
3fceef0936
commit
40d25adb88
@ -6,6 +6,10 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2013-03-17: Simon Goldschmidt (patch by Ghobad Emadi)
|
||||||
|
* opt.h, etharp.c: Added LWIP_HOOK_ETHARP_GET_GW to implement IPv4 routing with
|
||||||
|
multiple gateways
|
||||||
|
|
||||||
2013-04-20: Fatih Asici
|
2013-04-20: Fatih Asici
|
||||||
* opt.h, etharp.h/.c: patch #7993: Added support for transmitting packets
|
* opt.h, etharp.h/.c: patch #7993: Added support for transmitting packets
|
||||||
with VLAN headers via hook function LWIP_HOOK_VLAN_SET and to check them
|
with VLAN headers via hook function LWIP_HOOK_VLAN_SET and to check them
|
||||||
|
@ -2235,6 +2235,19 @@
|
|||||||
* that case, ip_route() continues as normal.
|
* that case, ip_route() continues as normal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LWIP_HOOK_ETHARP_GET_GW(netif, dest):
|
||||||
|
* - called from etharp_output() (IPv4)
|
||||||
|
* - netif: the netif used for sending
|
||||||
|
* - dest: the destination IPv4 address
|
||||||
|
* Returns the IPv4 address of the gateway to handle the specified destination
|
||||||
|
* IPv4 address. If NULL is returned, the netif's default gateway is used.
|
||||||
|
* The returned address MUST be reachable on the specified netif!
|
||||||
|
* This function is meant to implement advanced IPv4 routing together with
|
||||||
|
* LWIP_HOOK_IP4_ROUTE(). The actual routing/gateway table implementation is
|
||||||
|
* not part of lwIP but can e.g. be hidden in the netif's state argument.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr):
|
* LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr):
|
||||||
* - called from ethernet_input() if VLAN support is enabled
|
* - called from ethernet_input() if VLAN support is enabled
|
||||||
|
@ -954,14 +954,22 @@ etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr)
|
|||||||
if (!ip_addr_islinklocal(&iphdr->src))
|
if (!ip_addr_islinklocal(&iphdr->src))
|
||||||
#endif /* LWIP_AUTOIP */
|
#endif /* LWIP_AUTOIP */
|
||||||
{
|
{
|
||||||
/* interface has default gateway? */
|
#ifdef LWIP_HOOK_ETHARP_GET_GW
|
||||||
if (!ip_addr_isany(&netif->gw)) {
|
/* For advanced routing, a single default gateway might not be enough, so get
|
||||||
/* send to hardware address of default gateway IP address */
|
the IP address of the gateway to handle the current destination address. */
|
||||||
dst_addr = &(netif->gw);
|
dst_addr = LWIP_HOOK_ETHARP_GET_GW(netif, ipaddr);
|
||||||
/* no default gateway available */
|
if(dst_addr == NULL)
|
||||||
} else {
|
#endif /* LWIP_HOOK_ETHARP_GET_GW */
|
||||||
/* no route to destination error (default gateway missing) */
|
{
|
||||||
return ERR_RTE;
|
/* interface has default gateway? */
|
||||||
|
if (!ip_addr_isany(&netif->gw)) {
|
||||||
|
/* send to hardware address of default gateway IP address */
|
||||||
|
dst_addr = &(netif->gw);
|
||||||
|
/* no default gateway available */
|
||||||
|
} else {
|
||||||
|
/* no route to destination error (default gateway missing) */
|
||||||
|
return ERR_RTE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user