rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #ifndef __CKSUM_H |
| 2 | #define __CKSUM_H |
| 3 | |
| 4 | #include <compiler.h> |
| 5 | |
| 6 | __BEGIN_CDECLS |
| 7 | |
| 8 | /* |
| 9 | * Computes the CRC-CCITT, starting with an initialization value. |
| 10 | * buf: the data on which to apply the checksum |
| 11 | * length: the number of bytes of data in 'buf' to be calculated. |
| 12 | */ |
| 13 | unsigned short crc16(const unsigned char *buf, unsigned int length); |
| 14 | |
| 15 | /* |
| 16 | * Computes an updated version of the CRC-CCITT from existing CRC. |
| 17 | * crc: the previous values of the CRC |
| 18 | * buf: the data on which to apply the checksum |
| 19 | * length: the number of bytes of data in 'buf' to be calculated. |
| 20 | */ |
| 21 | unsigned short update_crc16(unsigned short crc, const unsigned char *buf, unsigned int len); |
| 22 | |
| 23 | unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len); |
| 24 | |
| 25 | unsigned long adler32(unsigned long adler, const unsigned char *buf, unsigned int len); |
| 26 | |
| 27 | uint32_t crc32_no_comp(uint32_t crc, const unsigned char *buf, unsigned int len); |
| 28 | |
| 29 | __END_CDECLS |
| 30 | |
| 31 | #endif |
| 32 | |