summaryrefslogtreecommitdiffstats
path: root/lib/checksum.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-06-04 20:34:39 +0200
committerMartin Mares <mj@ucw.cz>2000-06-04 20:34:39 +0200
commit7722938d63d206ebc0e1da732009e1e9f2cd9d72 (patch)
tree41073dbf2866687d85476982ffa1c0288a878da0 /lib/checksum.c
parent102e3e0e0277e7b123c7c1ae3635c4a8fb55c900 (diff)
downloadbird-7722938d63d206ebc0e1da732009e1e9f2cd9d72.tar
bird-7722938d63d206ebc0e1da732009e1e9f2cd9d72.zip
Added library progdocs.
Diffstat (limited to 'lib/checksum.c')
-rw-r--r--lib/checksum.c31
1 files changed, 30 insertions, 1 deletions
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 <mj@ucw.cz>
+ * (c) 1999--2000 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
+/**
+ * DOC: Miscellaneous functions.
+ */
+
#include <stdarg.h>
#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, ...)
{