Hi,
Thank you very much for your reply.
I know that netif->state set to a pointer of tapif or tunif structure in the contrib code. I can add the list of netif gateways to these structures or define a new structure. Which one is better?
As you said, I should add the routing entries of any netif in its state field. What's your idea about the following changes?
1. Overriding LWIP_HOOK_IP4_ROUTE(ip_addr_t* dst_addr) to find a correct netif.
**********
2. Definition of LWIP_HOOK_ETHARP_GET_GW(struct netif* if, ip_addr_t* dst_addr) to find a correct gateway.
I should add LWIP_HOOK_ETHARP_GET_GW in HOOK section of opt.h, I guess.
**********
3. Using LWIP_HOOK_ETHARP_GET_GW function call in the following part of "etharp_output()".
{
#ifdef LWIP_HOOK_ETHARP_GET_GW
dst_addr = LWIP_HOOK_ETHARP_GET_GW(netif, ipaddr /* The IP address of the packet destination */ );
if(!dst_addr) { /* no route to destination in routing table */
#endif
/* 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;
}
#ifdef LWIP_HOOK_ETHARP_GET_GW
}
#endif
}
**********
4. Adding a field "struct rt_table rt_table" to netif->state.
struct route_entry {
ip_addr_t ip;
ip_addr_t mask;
ip_addr_t gw;
/* more option such metric and etc. could be added too */
};
struct rt_table {
struct route_entry *head;
int len;
};
Do you have any idea about where these structures should be?
**********
4. Adding a function to add a routing entry and a function to remove.
/**
* Add a routing entry to lwIP netif.
*
* @param netif a netif structure
* @param route_entry a pre-allocated route_entry structuref
*
*/
void add_route(struct netif *netif, struct route_entry *route_entry);
/**
* Remove a routing entry from lwIP netif.
*
* @param netif a netif structure
* @param route_entry a pre-allocated route_entry structuref
*
*/
void rm_route(struct netif *netif, struct route_entry *route_entry);