|
AM79C90 Datasheet, PDF (52/62 Pages) Advanced Micro Devices – CMOS Local Area Network Controller for Ethernet (C-LANCE) | |||
|
◁ |
AMD
{
int k,i, byte; /* temporary array indices */
int hashcode; /* the object of this program */
char buf[80]; /* holds input characters */
for (i=0;i<8;i++) ladrf[i] = 0; /* clear log. adr. filter */
printf (âEnter Ethernet addresses as 6 octets separated by blanks.\nâ);
printf (âEach octet is one or two hex characters. The first octet \nâ);
printf (âentered is the first octet to be transmitted. The LSB of \nâ);
printf (âthe first octet is the first bit transmitted. After each \nâ);
printf (âaddress is entered, the Logical Address Filter contents \nâ);
printf (âare displayed, least significant byte first, with the \nâ);
printf (âappropriate bits set for all addresses entered so far.\nâ);
printf (â To exit press the <Enter> key.\n\nâ);
while (1)
{
loop:
printf (â\nEnter address: â);
/* If 1st character = CR, quit, otherwise read address. */
gets (buf);
if ( buf[0] == â\0â) break;
if (sscanf (buf, â%x %x %x %x %x %xâ,
&adr[0], &adr[1], &adr[2],&adr[3],&adr[4],&adr[5])
!= 6)
{ printf
(âAddress must contain 6 octets separated by blanks.\nâ);
goto loop;
}
if ((adr[0] & 1) == 0)
{ printf (âFirst octet of multicast address â);
printf (âmust be an odd number.\nâ);
goto loop;
}
/* Initialize CRC */
for (i=0; i<32; i++) CRC[i] = 1;
/* Process each bit of the address in the order of transmission.*/
for (byte=0; byte<6; byte++)
for (i=0; i<8; i++)
updateCRC ((adr[byte] >> i) & 1);
/* The hash code is the 6 least significant bits of the CRC
in reverse order: CRC[0] = hash[5], CRC[1] = hash[4], etc.
*/
hashcode = 0;
for (i=0; i<6; i++) hashcode = (hashcode << 1) + CRC[i];
/* Bits 3â5 of hashcode point to byte in address filter.
Bits 0â2 point to bit within that byte. */
byte = hashcode >> 3;
52
Am79C90
|
▷ |