|
From: | Adam Fullerton |
Subject: | Re: [lwip-users] Using 2 MACs with LwIP |
Date: | Thu, 09 Jan 2014 08:59:32 +0000 |
User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
Hi,
I just added a second network interface. The problem that I found was that unless the network interfaces were on different sub-nets then lwIP would send the response to the first interface. This behaviour may be OK for some applications but in my IEEE15888 application this was a problem. I solved it by keeping a copy of the IP addresses received on each network interface. Then searching the list for the destination IP address on the way out: /****************************************************************************** * Function Name: ipGetNetIf * Description : Function to get a pointer to an lwIP network interface based * on the destination IP address * Arguments : IN dest - Pointer to the destination IP address * Return Value : Pointer to the interface or NULL if not found ******************************************************************************/ struct netif * ipGetNetIf(struct ip_addr *dest) { struct netif *pResult = NULL; PRTEIP pEtherCList = gpEtherC; #ifdef _HARDWIRE_BROADCAST_PORT_ /* Hardwire broadcast messages to port0 for PTP testing purposes */ if (*((PIPADR)dest) == INADDR_BROADCAST) { PRTEIP pEtherC0 = ipFindNetIf(&gpEtherC, "\\\\.\\ieee15888:0"); if (pEtherC0) { return &pEtherC0->ipNetIf; } } #endif /* For each network interface */ while (pEtherCList) { /* Make sure that the cache is enabled */ if (pEtherCList->bfIpCacheEnabled) { /* Look for the entry */ if (icSearch(pEtherCList->pIpCache, (PIPADR)dest)) { pResult = &pEtherCList->ipNetIf; break; } } pEtherCList = pEtherCList->pNext; } return pResult; } /****************************************************************************** End of function ipGetNetIf ******************************************************************************/ I hope this helps. Cheers, Adam. On 09/01/2014 02:30, Vadim Vaynerman wrote:
|
ipCache.c
Description: Text Data
ipCache.h
Description: Text document
[Prev in Thread] | Current Thread | [Next in Thread] |