diff options
author | Baruch Siach <baruch@tkos.co.il> | 2013-08-11 07:35:45 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-08-12 07:58:50 +0200 |
commit | b5abbd80740063d63f9630b27760484e0c4a36a4 (patch) | |
tree | b50dc003e1aae2203fcfb1011188b4925b1a94b6 /net | |
parent | 9b0907bd68ffc23ed27cc3c5f51ff505d64beb78 (diff) | |
download | barebox-b5abbd80740063d63f9630b27760484e0c4a36a4.tar.gz barebox-b5abbd80740063d63f9630b27760484e0c4a36a4.tar.xz |
net: fix checksum verification
Checksum calculation on data including its own checksum (as is the case with
IP headers) should give 0xffff before bit flipping. Current code works well
for the correct checksum case, but fails to identify errors.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/net.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -41,7 +41,7 @@ static unsigned int net_ip_id; int net_checksum_ok(unsigned char *ptr, int len) { - return net_checksum(ptr, len) + 1; + return net_checksum(ptr, len) == 0xffff; } uint16_t net_checksum(unsigned char *ptr, int len) |