?? packetcrc.cpp
字號:
#include "../../../include/kdndis.h"
#include "ne2000.h"
/*++
Routine Description:
Runs the AUTODIN II CRC algorithm on buffer Buffer of
length Length.
Arguments:
Buffer - the input buffer
Length - the length of Buffer
Return Value:
The 32-bit CRC value.
Note:
This is adapted from the comments in the assembly language
version in _GENREQ.ASM of the DWB NE1000/2000 driver.
--*/
ULONG CardComputeCrc(IN PUCHAR Buffer, IN UINT Length)
{
ULONG Crc, Carry;
UINT i, j;
UCHAR CurByte;
Crc = 0xffffffff;
for (i = 0; i < Length; i++)
{
CurByte = Buffer[i];
for (j = 0; j < 8; j++)
{
Carry = ((Crc & 0x80000000) ? 1 : 0) ^ (CurByte & 0x01);
Crc <<= 1;
CurByte >>= 1;
if (Carry)
{
Crc = (Crc ^ 0x04c11db6) | Carry;
}
}
}
return Crc;
}
/*++
Routine Description:
For a given multicast address, returns the byte and bit in
the card multicast registers that it hashes to. Calls
CardComputeCrc() to determine the CRC value.
Arguments:
Address - the address
Byte - the byte that it hashes to
Value - will have a 1 in the relevant bit
--*/
VOID CardGetMulticastBit(IN UCHAR Address[NE2000_LENGTH_OF_ADDRESS], OUT UCHAR * Byte, OUT UCHAR * Value)
{
ULONG Crc;
UINT BitNumber;
// First compute the CRC.
Crc = CardComputeCrc(Address, NE2000_LENGTH_OF_ADDRESS);
// The bit number is now in the 6 most significant bits of CRC.
BitNumber = (UINT)((Crc >> 26) & 0x3f);
*Byte = (UCHAR)(BitNumber / 8);
*Value = (UCHAR)((UCHAR)1 << (BitNumber % 8));
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -