[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] RE:Re: Checksum problem with lwip_chksum()
From: |
Chris WIlliams |
Subject: |
[lwip-users] RE:Re: Checksum problem with lwip_chksum() |
Date: |
Thu, 2 Sep 2004 20:14:35 +0100 |
We all have our own way of coding. This is my routine at the moment.
I can't tell if this is faster of slower than John Taylors. If people
find this of use, could it be included properly?
Good luck.
static u16_t
lwip_chksum(void *dataptr, int len)
{
u32_t acc = 0;
unsigned char *dp = (unsigned char *)dataptr;
int half_len;
for(half_len = len / 2;half_len;half_len--){
acc += ((u16_t)*dp++) << 8;
acc += *dp++;
}
if(len & 1){
acc += ((u16_t)*dp++) << 8;
}
acc = (acc >> 16) + (acc & 0xffffUL);
if ((acc & 0xffff0000L) != 0) {
acc = (acc >> 16) + (acc & 0xffffUL);
}
return (u16_t)acc;
}
--
---------------------------------------------------------------------------
| Chris Williams EMail address@hidden |
| Tel/Fax 01686 688065 |
| Chrysalis Design. Electronics, Computers, Hardware, Software. |
| Design and development to meet all your needs. |
---------------------------------------------------------------------------