Replace the lame big endian crc with wpaul's standard big endian crc
algorithm, supplied by wpaul himself. The lame one has an origin that's been called into question, so rather than argue about that (one could make an excellent fair use argument), replace it with better code since that's what FreeBSD is about. Submitted by: wpaul[1], Klaus Klein [1] Bill called this a silly bikeshed. Maybe his is not incorrect.
This commit is contained in:
parent
eba9b48b10
commit
092d0b6b38
@ -745,38 +745,24 @@ sk_xmchash(addr)
|
||||
return (~crc & ((1 << HASH_BITS) - 1));
|
||||
}
|
||||
|
||||
/* gmchash is just a big endian crc */
|
||||
static u_int32_t
|
||||
sk_gmchash(addr)
|
||||
const uint8_t *addr;
|
||||
{
|
||||
u_int32_t crc;
|
||||
u_int idx, bit;
|
||||
uint8_t tmpData, data;
|
||||
uint32_t crc, carry;
|
||||
int idx, bit;
|
||||
uint8_t data;
|
||||
|
||||
/* Compute CRC for the address value. */
|
||||
crc = 0xFFFFFFFF; /* initial value */
|
||||
|
||||
for (idx = 0; idx < 6; idx++) {
|
||||
data = *addr++;
|
||||
|
||||
/* Change bit order in byte. */
|
||||
tmpData = data;
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
if (tmpData & 1) {
|
||||
data |= 1 << (7 - bit);
|
||||
} else {
|
||||
data &= ~(1 << (7 - bit));
|
||||
}
|
||||
tmpData >>= 1;
|
||||
}
|
||||
|
||||
crc ^= (data << 24);
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
if (crc & 0x80000000) {
|
||||
crc = (crc << 1) ^ GMAC_POLY;
|
||||
} else {
|
||||
crc <<= 1;
|
||||
}
|
||||
for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
|
||||
carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
|
||||
crc <<= 1;
|
||||
if (carry)
|
||||
crc = (crc ^ GMAC_POLY) | carry;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -745,38 +745,24 @@ sk_xmchash(addr)
|
||||
return (~crc & ((1 << HASH_BITS) - 1));
|
||||
}
|
||||
|
||||
/* gmchash is just a big endian crc */
|
||||
static u_int32_t
|
||||
sk_gmchash(addr)
|
||||
const uint8_t *addr;
|
||||
{
|
||||
u_int32_t crc;
|
||||
u_int idx, bit;
|
||||
uint8_t tmpData, data;
|
||||
uint32_t crc, carry;
|
||||
int idx, bit;
|
||||
uint8_t data;
|
||||
|
||||
/* Compute CRC for the address value. */
|
||||
crc = 0xFFFFFFFF; /* initial value */
|
||||
|
||||
for (idx = 0; idx < 6; idx++) {
|
||||
data = *addr++;
|
||||
|
||||
/* Change bit order in byte. */
|
||||
tmpData = data;
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
if (tmpData & 1) {
|
||||
data |= 1 << (7 - bit);
|
||||
} else {
|
||||
data &= ~(1 << (7 - bit));
|
||||
}
|
||||
tmpData >>= 1;
|
||||
}
|
||||
|
||||
crc ^= (data << 24);
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
if (crc & 0x80000000) {
|
||||
crc = (crc << 1) ^ GMAC_POLY;
|
||||
} else {
|
||||
crc <<= 1;
|
||||
}
|
||||
for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
|
||||
carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
|
||||
crc <<= 1;
|
||||
if (carry)
|
||||
crc = (crc ^ GMAC_POLY) | carry;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user