version 1.55, 2000/04/12 10:36:43 |
version 1.56, 2000/05/12 16:22:36 |
Line 789 ether_ifdetach(ifp) |
|
Line 789 ether_ifdetach(ifp) |
|
/* Nothing. */ |
/* Nothing. */ |
} |
} |
|
|
|
#if 0 |
|
/* |
|
* This is for reference. We have a table-driven version |
|
* of the little-endian crc32 generator, which is faster |
|
* than the double-loop. |
|
*/ |
u_int32_t |
u_int32_t |
ether_crc32_le(buf, len) |
ether_crc32_le(buf, len) |
const u_int8_t *buf; |
const u_int8_t *buf; |
Line 806 ether_crc32_le(buf, len) |
|
Line 812 ether_crc32_le(buf, len) |
|
crc >>= 1; |
crc >>= 1; |
c >>= 1; |
c >>= 1; |
if (carry) |
if (carry) |
crc = (crc ^ ETHER_CRC_POLY_LE) | carry; |
crc = (crc ^ ETHER_CRC_POLY_LE); |
} |
} |
} |
} |
|
|
return (crc); |
return (crc); |
} |
} |
|
#else |
|
u_int32_t |
|
ether_crc32_le(buf, len) |
|
const u_int8_t *buf; |
|
size_t len; |
|
{ |
|
static const u_int32_t crctab[] = { |
|
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, |
|
0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, |
|
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, |
|
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c |
|
}; |
|
u_int32_t crc; |
|
int i; |
|
|
|
crc = 0xffffffffU; /* initial value */ |
|
|
|
for (i = 0; i < len; i++) { |
|
crc ^= buf[i]; |
|
crc = (crc >> 4) ^ crctab[crc & 0xf]; |
|
crc = (crc >> 4) ^ crctab[crc & 0xf]; |
|
} |
|
|
|
return (crc); |
|
} |
|
#endif |
|
|
u_int32_t |
u_int32_t |
ether_crc32_be(buf, len) |
ether_crc32_be(buf, len) |