lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bugs #8708] Fix for IP and TCP header alignment with Ether


From: Leon Woestenberg
Subject: [lwip-devel] [bugs #8708] Fix for IP and TCP header alignment with Ethernet
Date: Wed, 28 Apr 2004 19:25:31 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040206 Firefox/0.8

This mail is an automated notification from the bugs tracker
 of the project: lwIP - A Lightweight TCP/IP stack.

/**************************************************************************/
[bugs #8708] Latest Modifications:

Changes by: 
                Leon Woestenberg <address@hidden>
'Date: 
                Wed 04/28/04 at 23:25 (Europe/Amsterdam)

            What     | Removed                   | Added
---------------------------------------------------------------------------
            Category | None                      | pbufs
          Resolution | None                      | Fixed
         Assigned to | None                      | likewise
              Status | Open                      | Closed







/**************************************************************************/
[bugs #8708] Full Item Snapshot:

URL: <http://savannah.nongnu.org/bugs/?func=detailitem&item_id=8708>
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: 0
On: Tue 04/27/04 at 15:33

Category:  pbufs
Severity:  5 - Average
Item Group:  Faulty Behaviour
Resolution:  Fixed
Assigned to:  likewise
Status:  Closed


Summary:  Fix for IP and TCP header alignment with Ethernet

Original Submission:  On 32-bit processors that cannot do unaligned accesses, 
there are problems with 32-bit values in the IP and TCP headers, due to their 
being preceded by an ethernet header of 14 bytes.

This patch (against CVS as at 27-Apr-04) overcomes this problem by optionally 
putting two bytes of padding at the beginning of the Ethernet header. This 
makes the Ethernet header 16 bytes long, and the transferring of data to or 
from the Ethernet chip starts two bytes into the buffer. Thanks to Timmy Brolin 
for the original suggestion.

Some comments on the patch:

ip_addr.h: A new struct ip_addr2 is defined for use in the ARP packets. 
Depending on the amount of padding, either dipaddr or sipaddr will be 
unaligned. ip_addr2 contains a two-element 16-bit array, addrw[2]. There is 
only one place where this field must be accessed by name.

etharp.h: PAD_ETH_SIZE is normally defined as 2. If it is undefined or zero, 
the adjustments are not performed (but struct ip_addr2 is still used)

etharp.c: The test for 0.0.0.0 is the only place where addrw[] is used. The 
various assigments of IP addresses are performed using structure copies 
instead, with pointer casts where necessary to change between struct ip_addr 
and struct ip_addr2. Address compatison is performed using memcmp().

ethernetif.c: As this template is now up-to-date with etharp, it shows the 
modifications required in an ethernet driver to support PAD_ETH_SIZE. 
pbuf_header() is used to drop and regain the two bytes padding for eas of 
transferring to and from the chip. In low_level_input(), the allocated pbuf 
must allow for PAD_ETH_SIZE. The call to pbuf_header in case ETHTYPE_IP must 
use -sizeof(struct eth_hdr) instead of just -14.


Follow-up Comments
------------------


-------------------------------------------------------
Date: Wed 04/28/04 at 11:04         By: softins
A further correction is required in etharp.c when compiling with debug enabled. 
See the second patch file, just added.

-------------------------------------------------------
Date: Tue 04/27/04 at 15:38         By: softins
Actually submitted by softins, but forgot to log in first.






File Attachments
-------------------

-------------------------------------------------------
Date: Wed 04/28/04 at 11:04  Name: etherpad2.patch  Size: 1KB   By: softins
Extra patch for etharp.c to correct debug statement
http://savannah.nongnu.org/bugs/download.php?item_id=8708&amp;item_file_id=1249

-------------------------------------------------------
Date: Tue 04/27/04 at 15:33  Name: etherpad.patch  Size: 7KB   By: None
Patch for ip_addr.h, etharp.h, etharp.c and ethernetif.c (against CVS as at 
27-Apr-04)
http://savannah.nongnu.org/bugs/download.php?item_id=8708&amp;item_file_id=1240






For detailed info, follow this link:
<http://savannah.nongnu.org/bugs/?func=detailitem&item_id=8708>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/







reply via email to

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