From 7722938d63d206ebc0e1da732009e1e9f2cd9d72 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 4 Jun 2000 18:34:39 +0000 Subject: Added library progdocs. --- lib/checksum.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'lib/checksum.c') diff --git a/lib/checksum.c b/lib/checksum.c index 94cf71e..2ffc177 100644 --- a/lib/checksum.c +++ b/lib/checksum.c @@ -1,11 +1,15 @@ /* * BIRD Library -- IP One-Complement Checksum * - * (c) 1999 Martin Mares + * (c) 1999--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ +/** + * DOC: Miscellaneous functions. + */ + #include #include "nest/bird.h" @@ -83,6 +87,20 @@ ipsum_calc(void *frag, unsigned len, va_list args) return sum; } +/** + * ipsum_verify - verify an IP checksum + * @frag: first packet fragment + * @len: length in bytes + * + * This function verifies whether a given fragmented packet + * has correct one's complement checksum as used by the IP + * protocol. + * + * It uses all the clever tricks described in RFC 1071 to speed + * up checksum calculation as much as possible. + * + * Result: 1 if the checksum is correct, 0 else. + */ int ipsum_verify(void *frag, unsigned len, ...) { @@ -95,6 +113,17 @@ ipsum_verify(void *frag, unsigned len, ...) return sum == 0xffff; } +/** + * ipsum_calculate - compute an IP checksum + * @frag: first packet fragment + * @len: length in bytes + * + * This function caculates a one's complement checksum of a given fragmented + * packet. + * + * It uses all the clever tricks described in RFC 1071 to speed + * up checksum calculation as much as possible. + */ u16 ipsum_calculate(void *frag, unsigned len, ...) { -- cgit v1.2.3