|
From: | KORAY KORKMAZER \(MIKES INTERNET\) |
Subject: | [lwip-users] using 2 IP numbers at the same time |
Date: | Wed, 7 Nov 2007 11:20:42 +0200 |
Hello, I am pretty new in using lwip and want to ask your
recommendations on an issue about using 2 IP numbers at the same time. Let me describe my design first: I am working on an Xilinx ML-403 platform and writing code
for PPC inside the FGPGA. I have an ethernet interface for communication and
using LwIP(LwIP 2.00.a version) for it. Also using Xilinx MicroKernel. Simply my application will have a static IP number and will
communicate with another system which has a static IP number too. But now another requirement has been arised. That is my
application must communicate with a second system from an another
IP number. And I still have one physical ethernet port. This means that my application must have 2 IP numbers.
And it must listen both connections at the same time. From mail group , I read that this is possible with
creating seperate network interfaces with ‘netif_add’ function. In my design , I thought of creating two threads which
will establish two sockets and add seperate network interfaces at the same
time. But it didn`t work. While I could communicate with one
IP number , the other connection could not be established. Here is my thread that I use for creating socket: void *socket_app_thread( void *arg ) { .....//declarations an initializations IP, port , MAC,
subnet, gw xtemacif_setmac( 0, ( u8_t*
)fullmac ); //Set MAC IP4_ADDR( &gw, gateway[ 0 ], gateway[ 1 ],
gateway[ 2 ], gateway[ 3 ] ); //Set gateway IP4_ADDR( &ipaddr, ip[ 0 ], ip[ 1 ], ip[ 2
], ip[ 3 ] ); //Set ip IP4_ADDR( &netmask, subnet[ 0 ], subnet[ 1
], subnet[ 2 ], subnet[ 3 ] ); //Set subnet msk /* allocate netif structure */ default_netif = mem_malloc( sizeof( struct
netif ) ); if ( default_netif == NULL ) { return NULL; } default_netif = netif_add( default_netif,
&ipaddr,
&netmask,
NULL,
&XTemacIf_ConfigTable[ 0 ],
xtemacif_init,
tcpip_input ); netif_set_default( default_netif ); /* Register XEmacHandler with interrupt
controller and enable interrupts * with XMK */ register_int_handler(
XPAR_OPB_INTC_0_TRIMODE_MAC_GMII_IP2INTC_IRPT_INTR,
(XInterruptHandler )XTemac_IntrFifoHandler,
xtemacif_ptr->instance_ptr ); /* Enable EMAC interrupts in XMK */ enable_interrupt(
XPAR_OPB_INTC_0_TRIMODE_MAC_GMII_IP2INTC_IRPT_INTR );
/*-----------------------------------------------------------------------*/ /* create socket and start application
*/
/*-----------------------------------------------------------------------*/ sock = socket( AF_INET, SOCK_STREAM, 0 ); addr.sin_family = AF_INET; addr.sin_port = htons( port ); addr.sin_addr.s_addr = INADDR_ANY; bind( sock, ( struct sockaddr* ) &addr,
sizeof( addr ) ); listen( sock, 7); SockDesc = accept( sock, ( struct sockaddr* )
&rem, &lensock ); } The second thread is similar with this one, only IP
and port number is different. Do you have any idea where I am having mistakes? I really appreciate for your help. Thanks in advance. Koray. |
[Prev in Thread] | Current Thread | [Next in Thread] |