From a48370d5e99d81328d5890253eca42817fd33aae Mon Sep 17 00:00:00 2001 From: jifl Date: Mon, 10 Mar 2008 16:12:31 +0000 Subject: [PATCH] * inet_chksum.c: Allow choice of one of the sample algorithms to be made from lwipopts.h. Fix comment on how to override LWIP_CHKSUM. --- CHANGELOG | 4 ++++ src/core/ipv4/inet_chksum.c | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1781b64a..f2e46370 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,10 @@ HISTORY ++ New features: + 2008-03-10 Jonathan Larmour + * inet_chksum.c: Allow choice of one of the sample algorithms to be + made from lwipopts.h. Fix comment on how to override LWIP_CHKSUM. + 2008-01-22 Frédéric Bernon * tcp.c, tcp_in.c, tcp.h, opt.h: Rename LWIP_CALCULATE_EFF_SEND_MSS in TCP_CALCULATE_EFF_SEND_MSS to have coherent TCP options names. diff --git a/src/core/ipv4/inet_chksum.c b/src/core/ipv4/inet_chksum.c index 9bba4f4c..bc492fea 100644 --- a/src/core/ipv4/inet_chksum.c +++ b/src/core/ipv4/inet_chksum.c @@ -46,14 +46,26 @@ /* These are some reference implementations of the checksum algorithm, with the * aim of being simple, correct and fully portable. Checksumming is the * first thing you would want to optimize for your platform. If you create - * your own version, link it in and in your sys_arch.h put: + * your own version, link it in and in your cc.h put: * * #define LWIP_CHKSUM -*/ -#ifndef LWIP_CHKSUM -#define LWIP_CHKSUM lwip_standard_chksum + * + * Or you can select from the implementations below by defining + * LWIP_CHKSUM_ALGORITHM to 1, 2 or 3. + */ -#if 1 /* Version A */ +#ifndef LWIP_CHKSUM +# define LWIP_CHKSUM lwip_standard_chksum +# ifndef LWIP_CHKSUM_ALGORITHM +# define LWIP_CHKSUM_ALGORITHM 1 +# endif +#endif +/* If none set: */ +#ifndef LWIP_CHKSUM_ALGORITHM +# define LWIP_CHKSUM_ALGORITHM 0 +#endif + +#if (LWIP_CHKSUM_ALGORITHM == 1) /* Version #1 */ /** * lwip checksum * @@ -104,7 +116,7 @@ lwip_standard_chksum(void *dataptr, u16_t len) } #endif -#if 0 /* Version B */ +#if (LWIP_CHKSUM_ALGORITHM == 2) /* Alternative version #2 */ /* * Curt McDowell * Broadcom Corp. @@ -160,7 +172,7 @@ lwip_standard_chksum(void *dataptr, int len) } #endif -#if 0 /* Version C */ +#if (LWIP_CHKSUM_ALGORITHM == 3) /* Alternative version #3 */ /** * An optimized checksum routine. Basically, it uses loop-unrolling on * the checksum loop, treating the head and tail bytes specially, whereas @@ -236,8 +248,6 @@ lwip_standard_chksum(void *dataptr, int len) } #endif -#endif /* LWIP_CHKSUM */ - /* inet_chksum_pseudo: * * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain.