Lines Matching refs:checksum
32 // Combine the checksum of |buffer| with |size| bytes with |checksum|. This is
33 // used for checksum calculations for IP and UDP.
36 uint32_t checksum) {
39 checksum += *data++;
44 checksum += *reinterpret_cast<const uint8_t*>(data);
46 // msw is the most significant word, the upper 16 bits of the checksum
47 for (uint32_t msw = checksum >> 16; msw != 0; msw = checksum >> 16) {
48 checksum = (checksum & 0xFFFF) + msw;
50 return checksum;
53 // Convenienct template function for checksum calculation
55 static uint32_t addChecksum(const T& data, uint32_t checksum) {
56 return addChecksum(reinterpret_cast<const uint8_t*>(&data), sizeof(T), checksum);
59 // Finalize the IP or UDP |checksum| by inverting and truncating it.
60 static uint32_t finishChecksum(uint32_t checksum) {
61 return ~checksum & 0xFFFF;