summaryrefslogtreecommitdiff
path: root/src/checksum.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/checksum.h')
-rw-r--r--src/checksum.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/checksum.h b/src/checksum.h
index 7d4a003..700ee1a 100644
--- a/src/checksum.h
+++ b/src/checksum.h
@@ -1,5 +1,17 @@
+#include <netinet/in.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
+/* calculates the checksum of len bytes at buff when combined with wsum.
+ * return value is already in network order, but must be inverted before
+ * sending.
+ * example: hdr.th_sum = csum_partial(data, len, csum_partial(hdr, hdrlen, 0));
+ */
uint16_t csum_partial(const void *buff, int len, uint16_t wsum);
+
+/* calculates the checksum of a sockaddr_in or sockaddr_in6.
+ * if incl_port is set then the sin_port will be included.
+ * otherwise identical to csum_partial.
+ */
+uint16_t csum_sockaddr_partial(const struct sockaddr *addr, int incl_port, uint16_t wsum);