Digi NS9750 User Manual

Page 424

Advertising
background image

S a m p l e h a s h t a b l e c o d e

4 0 0

N S 9 7 5 0 H a r d w a r e R e f e r e n c e

* Function: int calculate_hash_bit (BYTE *mca)

*

* Description:

*

This routine calculates which bit in the CRC hash table needs

*

to be set for the MERCURY to recognize incoming packets with

*

the MCA passed to us.

*

* Parameters:

*

*

mca

pointer to multi-cast address

*

* Return Values:

*

*

bit position to set in hash table

*

*/

#define POLYNOMIAL 0x4c11db6L

static int calculate_hash_bit (BYTE *mca)

{

WORD32 crc;

WORD16 *mcap, bp, bx;

int result, index, mca_word, bit_index;

BYTE lsb;

WORD16 copy_mca[3]

memcpy (copy_mca,mca,sizeof(copy_mca));

for (index = 0; index < 3; index++)

{

copy_mca [index] = SWAP16 (copy_mca [index]);

}

mcap = copy_mca;

crc = 0xffffffffL;

for (mca_word = 0; mca_word < 3; mca_word++)

{

bp = *mcap;

Advertising