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
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to