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: anonymous
Subject: [lwip-devel] [bugs #8708] Fix for IP and TCP header alignment with Ethernet
Date: Tue, 27 Apr 2004 11:33:23 -0400
User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0; Q312461)

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




/**************************************************************************/
[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 11:33

Category:  None
Severity:  5 - Average
Item Group:  Faulty Behaviour
Resolution:  None
Assigned to:  None
Status:  Open


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.






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

-------------------------------------------------------
Date: Tue 04/27/04 at 11: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]