42,6 → 42,11 |
|
#define CRC_DIVIDER_LE 0xEDB88320 |
|
/** IP checksum value for computed zero checksum. |
* Zero is returned as 0xFFFF (not flipped) |
*/ |
#define IP_CHECKSUM_ZERO 0xFFFFu |
|
uint32_t compute_crc32_le( uint32_t seed, uint8_t * data, size_t length ){ |
size_t index; |
|
123,5 → 128,14 |
return ( uint16_t ) sum; |
} |
|
uint16_t ip_checksum( uint8_t * data, size_t length ){ |
uint16_t checksum; |
|
checksum = compact_checksum(compute_checksum( 0, data, length )); |
|
// flip, zero is returned as 0xFFFF (not flipped) |
return ( ~ checksum ) ? ( uint16_t ) ( ~ checksum ) : IP_CHECKSUM_ZERO; |
} |
|
/** @} |
*/ |