lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] Simulation of TCP connections with multiplesourceIP add


From: Leena Mokadam
Subject: RE: [lwip-users] Simulation of TCP connections with multiplesourceIP addresses
Date: Thu, 10 May 2007 14:07:05 +0530

Hi Simon,

Thanks fro the response. I tried to write a simple client to send the data
to server. My application ended with a segmentation fault when tried to
create socket with lwip_socket() API. Could you please help in finding the
problem?

Thanks and Regards,
Leena M.

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Goldschmidt Simon
Sent: Thursday, May 03, 2007 6:31 PM
To: Mailing list for lwIP users
Subject: RE: [lwip-users] Simulation of TCP connections with
multiplesourceIP addresses

Hi,

> In the current code, lwIP's routing and interface structure 
> is intentionally simplified. You can have only one IP address 
> for each interface ("netif"). I _think_ lwip should allow you 
> to do what you want if you set up a netif for each IP 
> address. When you need to send something from a specific 

That's what I thought, too. At least for the TX side, having an
ethernetif.c
that allows multiple instances (multiple calls to ethernetif_init() with
multiple 'struct netif's) but sends everything on one HW-interface only,
this should work.

On the RX side I'm not so sure. Maybe you have to call netif->init()
with the
right struct netif for the local IP address. Also maybe it works for any
netif,
I really don't know that, too. You would have to check that...

As for an example, for socket API client connection, I guess you would
do it
somehow like this:

>>>>>>>>>>CODE>>>>>>>>>>
struct sockaddr_in local_addr;
struct sockaddr_in server_addr;
int sock;
sock = lwip_socket(AF_INET, SOCK_STREAM, 0)

memset(&local_addr, 0, sizeof(struct sockaddr_in));
local_addr.sin_family = AF_INET;
local_addr.sin_port = 0; // note I don't really know if this works!
ret = inet_aton("192.168.20.120", &local_addr.sin_addr);
lwip_bind(sock, &local_addr, sizeof(local_addr));

memset(&server_addr, 0, sizeof(struct sockaddr_in));
server_addr.sin_family = AF_INET;
server_addr.sin_port = ntohs(SERVER_PORT);
ret = inet_aton("server ip address", &server_addr.sin_addr);
lwip_connect(sock, &server_addr, sizeof(server_addr));
<<<<<<<<<<CODE<<<<<<<<<<

For a socket API server connection, this would be somehow like this:

>>>>>>>>>>CODE>>>>>>>>>>
struct sockaddr_in local_addr;
struct sockaddr_in client_addr;
int sock_listen, sock_conn;
sock_listen = lwip_socket(AF_INET, SOCK_STREAM, 0)

memset(&local_addr, 0, sizeof(struct sockaddr_in));
local_addr.sin_family = AF_INET;
local_addr.sin_port = ntohs(SERVER_PORT);
ret = inet_aton("192.168.20.120", &local_addr.sin_addr);
lwip_bind(sock_listen, &local_addr, sizeof(local_addr));

lwip_listen(sock_listen, 1);

sock_conn = lwip_accept(sock_listen, &client_addr, sizeof(client_addr));
<<<<<<<<<<CODE<<<<<<<<<<


Note I have put this down from my mind, not tested it. Also, I have left
out all error checking.

Hope this helps, and tell us if it works or not, as I find this a pretty
interesting info about the stack ;-)

Simon


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





reply via email to

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