[Top][All Lists]

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

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

From: Ceresoli Luca
Subject: [lwip-devel] R: [lwip-users] Sending to myself
Date: Thu, 10 Jan 2008 12:24:18 +0100

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

Attachment: self.patch
Description: self.patch

reply via email to

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