lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Checksum problem with lwip_chksum()


From: Chris WIlliams
Subject: [lwip-users] Checksum problem with lwip_chksum()
Date: Thu, 2 Sep 2004 11:33:12 +0100

I have had problems with checksums, and traced a problem in
lwip_chksum().

The problem is to do with alignment:

I am using Hitachi H8 which is 2 byte aligned and I have set

#define MEM_ALIGNMENT           2

The problem is that a definition of the kind:

char *text = "This is text";

is BYTE aligned.

If you try to send this with the following call:

tcp_write(port,text,strlen(text),0);

that is without copy, you can fail to get the correct checksum from
lwip_chksum(). This assumes that ALL the data it receives will be 2 byte
aligned. 

This caused one of my applications to always fail. If you change the
call to:

tcp_write(port,terminal,length,1);

then it works OK because it copies the data into a pbuf first which IS
correctly aligned.

I have reworked lwip_chksum() to work in bytes. This is slower, but it
does now work correctly.

Has anybody else seen this problem? Is it a particular problem of the H8
(Paul C, did you have any problem here?). Would anybody like me to post
my new code?

Chris.
-- 
---------------------------------------------------------------------------
| Chris Williams    EMail address@hidden                      |
|                   Tel/Fax  01686 688065                                 |
| Chrysalis Design. Electronics, Computers, Hardware, Software.           |
|                   Design and development to meet all your needs.        |
---------------------------------------------------------------------------




reply via email to

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