/* * computes the checksum of a memory block at buff, length len, * and adds in "sum" (32-bit) * * returns a 32-bit number suitable for feeding into itself * or csum_tcpudp_magic * * this function must be called with even lengths, except * for the last fragment, which may be odd * * it's best to have buff aligned on a 32-bit boundary
*/ extern __wsum csum_partial(constvoid *, int, __wsum);
/* * Optimized for IP headers, which always checksum on 4 octet boundaries. * * Written by Randolph Chung <tausq@debian.org>, and then mucked with by * LaMont Jones <lamont@debian.org>
*/ staticinline __sum16 ip_fast_csum(constvoid *iph, unsignedint ihl)
{ unsignedint sum; unsignedlong t0, t1, t2;
/* * Fold a partial checksum
*/ staticinline __sum16 csum_fold(__wsum csum)
{
u32 sum = (__force u32)csum; /* add the swapped two 16-bit halves of sum, a possible carry from adding the two 16-bit halves, will carry from the lower half into the upper half,
giving us the correct sum in the upper half. */
sum += (sum << 16) + (sum >> 16); return (__force __sum16)(~sum >> 16);
}
/* * computes the checksum of the TCP/UDP pseudo-header * returns a 16-bit checksum, already complemented
*/ staticinline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
__u32 len, __u8 proto,
__wsum sum)
{ return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
}
/* * this routine is used for miscellaneous IP-like checksums, mainly * in icmp.c
*/ staticinline __sum16 ip_compute_csum(constvoid *buf, int len)
{ return csum_fold (csum_partial(buf, len, 0));
}
/* ** We can execute two loads and two adds per cycle on PA 8000. ** But add insn's get serialized waiting for the carry bit. ** Try to keep 4 registers with "live" values ahead of the ALU.
*/
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.