lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Using 2 MACs with LwIP


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:
Hello All,

I was wondering if there is any information about using 2 MACs concurrently for TCP/IP work within the LwIP framework. My architecture is ARM Cortex A9 - Xilinx Zynq, and I've got it working nicely with one MAC and a single IP address... Need to add a second, separate, link. Has anything like this been done, or are there any suggestions on how to go about this from experienced users?

Thanks,
Vadim


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

Attachment: ipCache.c
Description: Text Data

Attachment: ipCache.h
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]