1 #ifndef __CKSUM_H 2 #define __CKSUM_H 3 4 #include <stddef.h> 5 #include <stdint.h> 6 7 #include <zircon/compiler.h> 8 9 __BEGIN_CDECLS 10 11 /* 12 * Computes the CRC-CCITT, starting with an initialization value. 13 * buf: the data on which to apply the checksum 14 * length: the number of bytes of data in 'buf' to be calculated. 15 */ 16 uint16_t crc16(const uint8_t *buf, size_t length); 17 18 /* 19 * Computes an updated version of the CRC-CCITT from existing CRC. 20 * crc: the previous values of the CRC 21 * buf: the data on which to apply the checksum 22 * length: the number of bytes of data in 'buf' to be calculated. 23 */ 24 uint16_t update_crc16(uint16_t crc, const uint8_t *buf, size_t len); 25 26 uint32_t crc32(uint32_t crc, const uint8_t *buf, size_t len); 27 28 uint32_t crc32_combine(uint32_t crc1, uint32_t crc2, size_t len2); 29 30 uint32_t adler32(uint32_t adler, const uint8_t *buf, size_t len); 31 32 uint32_t adler32_combine(uint32_t adler1, uint32_t adler2, size_t len2); 33 34 const uint32_t* get_crc_table(void); 35 36 __END_CDECLS 37 38 #endif 39 40