[Top][All Lists]

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

AW: [lwip-devel] R: [lwip-users] Sending to myself

From: Goldschmidt Simon
Subject: AW: [lwip-devel] R: [lwip-users] Sending to myself
Date: Thu, 10 Jan 2008 12:38:09 +0100

Copying the code to your netif would also work.

The important thing here is that you MUST NEVER call ip_input from your 
netif_output function (the TCP part of the lwip core is not reentrant since it 
uses some global variables)!

Therefore, the loopif has changed in the CVS version:
- without an OS (raw API only, no netconn or sockets api), it uses a queue for 
the ouput packets and empties that queue when loopif_poll is called (must be 
from the main loop, not from inside a core stack function)
- with an OS (using tcpip_thread/tcpip.c ...), it can call netif->input 
directly since this leads to putting the packet on a queue inside tcpip_thread.

So when implementing it yourself, you have to choose the right way to do it 
depending on your setup (OS or no OS).


-----Urspr√ľngliche Nachricht-----
Von: address@hidden [mailto:address@hidden Im Auftrag von Ceresoli Luca
Gesendet: Donnerstag, 10. Januar 2008 12:24
An: address@hidden
Betreff: [lwip-devel] R: [lwip-users] Sending to myself

Hi Simon,

thanks for the advice. I tried to implement what you suggested, but it still 
has some issues.

The changes to the lwip code are in the attached patch.
Changes to user code are limited to adding a loopif and calling loopif_poll().

I can now send UDP packets to myself, but:
- If the sender pcb is not bound to the local address, I receive
  the packets with a sender IP equal to
- If the sender pcb is bound to my local address, the packets are
  dropped by udp_sendto_if() where it checks pcb->local_ip.

I fear hacking further in this direction would be pretty invasive.
I think I'll try another approach: copying the queue management stuff into 
netif, so it works within the netif itself. Do you foresee anything that makes 
this a bad idea?

Luca Ceresoli

-----Messaggio originale-----
Da: address@hidden
[mailto:address@hidden conto di Goldschmidt Simon
Inviato: mercoledì 9 gennaio 2008 17.19
A: Mailing list for lwIP users
Oggetto: RE: [lwip-users] Sending to myself


The routine you created is already included in loopif.c (the loopback 
interface). You only would have to make sure that packets sent to your own 
external IP get sent over the loopback interface. The method to implement that 
would be ip_route().


-----Urspr√ľngliche Nachricht-----
Von: address@hidden [mailto:address@hidden Im Auftrag von Ceresoli Luca
Gesendet: Mittwoch, 9. Januar 2008 16:23
An: address@hidden
Betreff: [lwip-users] Sending to myself


I'm not sure if this is a bug or a missing feature, but here it is: lwip does 
not send packets to its own IP address.
I use raw API, NO_SYS=1, lwip CVS dec 11, 2007.

I see that the code simply does not check if dest_IP == own_IP.
This leads to gratuitous ARP requests, which cannot be answered.

I think the most logical solution would be to redirect the packet up the stack 
when it has reached down to the IP level. But in the absence of any packet 
queue, this would increase the used (processor) stack depth and potentially 
introduce loops.

Currently I solved it implementing the following netif->output(), which seems 
to work, but with heavy (processor) stack load.

err_t myif_output(struct netif* netif, struct pbuf* p, struct ip_addr* dest_ip) 
        if (ip_addr_cmp(dest_ip, &netif->ip_addr))
                return netif->input(p, netif);
                return etharp_output(netif, p, dest_ip); }

- Is the above routine safe?
- Is there any safe and clean way to add this feature, possibly to lwip itself,
  avoiding deep (processor) stack usage?

Thanks in advance,
Luca Ceresoli

lwip-users mailing list

lwip-users mailing list

reply via email to

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