/* * turns a 32-bit partial checksum (e.g. from csum_partial) into a * 1's complement 16-bit checksum.
*/ staticinline __sum16 csum_fold(__wsum sum)
{
u32 tmp = (__force u32)sum;
/* * swap the two 16-bit halves of sum * if there is a carry from adding the two 16-bit halves, * it will carry from the lower half into the upper half, * giving us the correct sum in the upper half.
*/ return (__force __sum16)(~(tmp + rol32(tmp, 16)) >> 16);
} #define csum_fold csum_fold
/* * This is a version of ip_compute_csum() optimized for IP headers, * which always checksum on 4 octet boundaries. ihl is the number * of 32-bit words and is always >= 5.
*/ staticinline __sum16 ip_fast_csum(constvoid *iph, unsignedint ihl)
{
u64 sum;
__uint128_t tmp; int n = ihl; /* we want it signed */
tmp = *(const __uint128_t *)iph;
iph += 16;
n -= 4;
tmp += ((tmp >> 64) | (tmp << 64));
sum = tmp >> 64; do {
sum += *(const u32 *)iph;
iph += 4;
} while (--n > 0);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.