[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] ICMP Checksum for STM32
From: |
Laurent NAVARRO |
Subject: |
[lwip-devel] ICMP Checksum for STM32 |
Date: |
Sun, 15 Jan 2012 19:54:48 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 |
Hello,
I've just tried to upgrade the STM32 Demo to LwIP 1.4.0 and I've met
some issues as ping was failing (other stuff seems to works).
The point is on icmp.c which was patched by ST team on their demo package.
The point is that the STM32 include the ability to compute checksum on
IP,TCP,UDP and ICMP header but it require the field to contains a 0 before.
It's perfectly handled for IP,TCP,UDP in lwIP thanks to
CHECKSUM_GEN_IP,CHECKSUM_GEN_TCP,CHECKSUM_GEN_UDP options
but there's no CHECKSUM_GEN_ICMP and this checksum is always computed.
First idea would be to add this option and to set the code around line
192 conditional.
/* adjust the checksum */
if (iecho->chksum >= PP_HTONS(0xffffU - (ICMP_ECHO << 8))) {
iecho->chksum += PP_HTONS(ICMP_ECHO << 8) + 1;
} else {
iecho->chksum += PP_HTONS(ICMP_ECHO << 8);
}
But I think it can be consider as a compatibility break to introduce
this option.
Then I suggest to add option CHECKSUM_NOTGEN_ICMP (we just break the
naming option logic, there's less consequence ;-) )
Then I propose this code for ipv4 icmp.h line 192 (I've just tested it )
#if CHECKSUM_NOTGEN_ICMP
iecho->chksum = 0;
#else
/* adjust the checksum */
if (iecho->chksum >= PP_HTONS(0xffffU - (ICMP_ECHO << 8))) {
iecho->chksum += PP_HTONS(ICMP_ECHO << 8) + 1;
} else {
iecho->chksum += PP_HTONS(ICMP_ECHO << 8);
}
#endif
regards,
Laurent
- [lwip-devel] ICMP Checksum for STM32,
Laurent NAVARRO <=