lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #26273] etharp.c : fix alignment issue in etharp_raw


From: Guillaume du PONTAVICE
Subject: [lwip-devel] [bug #26273] etharp.c : fix alignment issue in etharp_raw
Date: Tue, 21 Apr 2009 16:49:51 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8

URL:
  <http://savannah.nongnu.org/bugs/?26273>

                 Summary: etharp.c : fix alignment issue in etharp_raw
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: gdupontavice
            Submitted on: mar 21 avr 2009 16:49:48 GMT
                Category: ARP
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 
            lwIP version: CVS Head

    _______________________________________________________

Details:

I am working on ST5100 chipset (ST20 core / OS20, using ST toolset ST20
2.3.1, using structure packing option -falign1 for etharp.c)
unfortunately the compiler seems not being able to correctly handle the
following affectations in etharp.c (function etharp_raw)

hdr->sipaddr = *(struct ip_addr2 *)ipsrc_addr;
hdr->dipaddr = *(struct ip_addr2 *)ipdst_addr;

the result is : the MAC address which is located just after the IP in the ARP
header got corrupted :


ffffffffffff
001914c5f0b4
0806
0001
0800
0604
0001
001914c5f0b4   <= sender MAC
c0a800bc       <= sender IP
00000000c0a8   <= destination MAC (corrupted)
00eb0000       <= destination IP  (corrupted)


using the patch hereafter, everything is fine, I got the following ARP
packet

ffffffffffff
001914c5f0b4
0806
0001
0800
0604
0001
001914c5f0b4   <= sender MAC
c0a800bc       <= sender IP
000000000000   <= destination MAC
c0a800eb       <= destination IP


Index: etharp.c
===================================================================
RCS file: /sources/lwip/lwip/src/netif/etharp.c,v
retrieving revision 1.150
diff -u -r1.150 etharp.c
--- etharp.c    18 Feb 2009 16:48:30 -0000      1.150
+++ etharp.c    21 Apr 2009 16:09:24 -0000
@@ -1077,8 +1077,8 @@
 #endif /* LWIP_AUTOIP */
     hdr->ethhdr.src.addr[k]  = ethsrc_addr->addr[k];
   }
-  hdr->sipaddr = *(struct ip_addr2 *)ipsrc_addr;
-  hdr->dipaddr = *(struct ip_addr2 *)ipdst_addr;
+  SMEMCPY(&hdr->sipaddr,ipsrc_addr,sizeof(hdr->sipaddr));
+  SMEMCPY(&hdr->dipaddr,ipdst_addr,sizeof(hdr->dipaddr));
 
   hdr->hwtype = htons(HWTYPE_ETHERNET);
   hdr->proto = htons(ETHTYPE_IP);





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?26273>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/





reply via email to

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