lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Dest address gets corrupted


From: Rainer Salminen
Subject: [lwip-users] Dest address gets corrupted
Date: Thu, 5 Nov 2009 20:39:53 +0200

Hi
 
I suspect a bug.
If incoming packet contains IP header, then outgoing packet has source address as destination address causing either use of loopback interface or a failed ARP request.
 
The reason is that in function ip_output_if_opt() (in file ip.c) parameter dest points to source ip address after source and destination addresses are swapped.
The line causing error is in bold below.
 
 
 /* Should the IP header be generated or is it already included in p? */
  if (dest != IP_HDRINCL) {
 ....
   if (ip_addr_isany(src)) {
      ip_addr_set(&(iphdr->src), &(netif->ip_addr));
    } else {
      ip_addr_set(&(iphdr->src), src);
    }
    IPH_CHKSUM_SET(iphdr, 0);
#if CHECKSUM_GEN_IP
    IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, ip_hlen));
#endif
  } else {
    /* IP header already included in p */
    iphdr = p->payload;
    dest = &(iphdr->dest);
  }
 
The simplest fix is to move
 
dest = &(iphdr->dest);
 
out of else branch so that it applies also to then -part.
 
 
Can you confirm the bug and the fix?
 
 
Regards,
 
  RS

 


reply via email to

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