[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] problem with multi IP address on one PHY
From: |
wu . mingyuan |
Subject: |
[lwip-users] problem with multi IP address on one PHY |
Date: |
Sat, 19 Jul 2008 12:29:22 +0800 |
In the first implement,the first ip
address work normally, the
follow-up
ip address can establish normal tcp link, but the
ping command is not reachable.
In the second implement, all ip address
can be accessed by the ping command, TCP link
can also connect normal. But after
a few miniutes,all the ip address lost its TCP connection and the the ping
command is not reachable.
The only difference between the two
ways of implement is on the package distridubution part.
First Implement:
/* ethernetif.c */
static struct netif *xNetIf[netifMAX_NETIF]
= {NULL};
static portBASE_TYPE uxNetIfCount =
0;
static void
low_level_init(struct netif *netif)
{
unsigned portBASE_TYPE
uxPriority;
/* set MAC hardware address
length */
netif->hwaddr_len =
ETHARP_HWADDR_LEN;
/* set MAC hardware address
*/
netif->hwaddr[0] =
emacETHADDR0;
...
/* maximum transfer unit
*/
netif->mtu = 1500;
/* device capabilities
*/
/* don't set NETIF_FLAG_ETHARP
if this device is not an ethernet one */
netif->flags = NETIF_FLAG_BROADCAST
| NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
/* Do whatever else is
needed to initialize interface. */
xNetIf[uxNetIfCount] =
netif;
if (0 == uxNetIfCount)
{
Init_EMAC();
vTaskPrioritySet(
NULL, uxPriority );
/* Create
the task that handles the EMAC. */
xTaskCreate(
ethernetif_input, ( signed portCHAR * ) "ETH_INT", netifINTERFACE_TASK_STACK_SIZE,
NULL, netifINTERFACE_TASK_PRIORITY, NULL );
}
/* increase cont */
uxNetIfCount++;
}
static void ethernetif_input( void *
pvParameters )
{
//struct ethernetif
*ethernetif;
struct eth_hdr
*ethhdr;
struct pbuf
*p;
portBASE_TYPE
uxNetIfIndex;
struct netif
*netif;
struct ethip_hdr
*ethiphdr;
portBASE_TYPE
xReceived;
( void ) pvParameters;
for( ;; )
{
do
{
//ethernetif = xNetIf->state;
/* move received packet into a new pbuf */
p = low_level_input( xNetIf[0] );
if( p == NULL )
{
vTaskDelay(1);
}
} while(
p == NULL );
/* points
to packet payload, which starts with an Ethernet header */
ethhdr
= p->payload;
ethiphdr
= p->payload;
LINK_STATS_INC(link.recv);
switch (htons(ethhdr->type))
{
/* IP or ARP packet? */
case ETHTYPE_IP:
case ETHTYPE_ARP:
#if PPPOE_SUPPORT
/* PPPoE packet? */
case ETHTYPE_PPPOEDISC:
case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
/* full packet send to tcpip_thread to process */
for (uxNetIfIndex = 0; uxNetIfIndex < uxNetIfCount; uxNetIfIndex++)
{
netif = xNetIf[uxNetIfIndex];
/* dest is on the local netif? */
if (netif->input(p, netif) != ERR_OK)
{
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input:
IP input error\n"));
pbuf_free(p);
p = NULL;
}
}
break;
default:
pbuf_free(p);
p = NULL;
break;
}
}
}
Second Implement:
static void ethernetif_input( void *
pvParameters )
{
...
/* full packet send to tcpip_thread to process */
ethiphdr = p->payload;
xReceived = pdTRUE;
for (uxNetIfIndex = 0; uxNetIfIndex < uxNetIfCount; uxNetIfIndex++)
{
netif = xNetIf[uxNetIfIndex];
/* dest is on the local netif? */
if (ip_addr_netcmp(&(ethiphdr->ip.dest),
&(netif->ip_addr), &(netif->netmask)))
{
if (netif->input(p, netif)
!= ERR_OK)
{
xReceived = pdFALSE;
}
}
}
if (pdFALSE == xReceived)
{
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input:
IP input error\n"));
pbuf_free(p);
p = NULL;
}
...
}
--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail is solely property of the sender's organization. This mail communication is confidential. Recipients named above are obligated to maintain secrecy and are not permitted to disclose the contents of this communication to others.
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the originator of the message. Any views expressed in this message are those of the individual sender.
This message has been scanned for viruses and Spam by ZTE Anti-Spam system.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-users] problem with multi IP address on one PHY,
wu . mingyuan <=