2 * crc32.h for early Linux 2.4.19pre kernel inclusion
3 * This defines ether_crc_le() and ether_crc() as inline functions
4 * This is slated to change to using the library crc32 functions
5 * as kernel 2.5.2 included at some future date.
10 #include <linux/types.h>
12 /* The little-endian AUTODIN II ethernet CRC calculation.
13 N.B. Do not use for bulk data, use a table-based routine instead.
14 This is common code and should be moved to net/core/crc.c */
15 static unsigned const ethernet_polynomial_le = 0xedb88320U;
16 static inline unsigned ether_crc_le(int length, unsigned char *data)
18 unsigned int crc = 0xffffffff; /* Initial value. */
19 while(--length >= 0) {
20 unsigned char current_octet = *data++;
22 for (bit = 8; --bit >= 0; current_octet >>= 1) {
23 if ((crc ^ current_octet) & 1) {
25 crc ^= ethernet_polynomial_le;
33 static unsigned const ethernet_polynomial = 0x04c11db7U;
34 static inline u32 ether_crc(int length, unsigned char *data)
37 while (--length >= 0) {
38 unsigned char current_octet = *data++;
40 for (bit = 0; bit < 8; bit++, current_octet >>= 1) {
42 ((crc < 0) ^ (current_octet & 1) ?
43 ethernet_polynomial : 0);
49 #endif /* _LINUX_CRC32_H */