Lines Matching refs:checksum
16 * checksum.c - ipv4/ipv6 checksum calculation
27 #include "checksum.h"
30 * adds data to a checksum
31 * current - the current checksum (or 0 to start a new checksum)
32 * data - the data to add to the checksum
36 uint32_t checksum = current;
41 checksum += *data_16;
46 checksum += *(uint8_t *)data_16;
49 return checksum;
53 * folds a 32-bit partial checksum into 16 bits
55 * returns: the folded checksum in network byte order
65 * folds and closes the checksum
67 * returns: a header checksum value in network byte order
75 * data - data to checksum
86 * calculate the pseudo header checksum for use in tcp/udp/icmp headers
106 * calculate the pseudo header checksum for use in tcp/udp headers
126 * calculates a new checksum given a previous checksum and the old and new pseudo-header checksums
127 * checksum - the header checksum in the original packet in network byte order
128 * old_hdr_sum - the pseudo-header checksum of the original packet
129 * new_hdr_sum - the pseudo-header checksum of the translated packet
130 * returns: the new header checksum in network byte order
132 uint16_t ip_checksum_adjust(uint16_t checksum, uint32_t old_hdr_sum, uint32_t new_hdr_sum) {
135 checksum = ~checksum;
136 uint16_t folded_sum = ip_checksum_fold(checksum + new_hdr_sum);