3 * - IPv6 Protcol Handling
10 extern Uint32 IPv4_Netmask(int FixedBits);
13 int IPv6_Initialise();
14 void IPv6_int_GetPacket(tAdapter *Interface, tMacAddr From, int Length, void *Buffer);
15 tInterface *IPv6_GetInterface(tAdapter *Adapter, tIPv6 Address, int Broadcast);
19 * \fn int IPv6_Initialise()
23 Link_RegisterType(IPV6_ETHERNET_ID, IPv6_int_GetPacket);
28 * \fn void IPv6_int_GetPacket(tInterface *Interface, tMacAddr From, int Length, void *Buffer)
29 * \brief Process an IPv6 Packet
31 void IPv6_int_GetPacket(tAdapter *Interface, tMacAddr From, int Length, void *Buffer)
33 tIPv6Header *hdr = Buffer;
34 if(Length < sizeof(tIPv6Header)) return;
36 if(hdr->Version != 6) return;
40 * \fn tInterface *IPv6_GetInterface(tAdapter *Adapter, tIPv6 Address)
41 * \brief Searches an adapter for a matching address
43 tInterface *IPv6_GetInterface(tAdapter *Adapter, tIPv6 Address, int Broadcast)
46 tInterface *iface = NULL;
49 for( iface = Adapter->Interfaces; iface; iface = iface->Next)
51 // Skip non-IPv6 Interfaces
52 if( iface->Type != 6 ) continue;
54 // If the address is a perfect match, return this interface
55 if( IP6_EQU(Address, iface->IP6.Address) ) return iface;
57 // Check if we want to match broadcast addresses
58 if( !Broadcast ) continue;
60 // Check for broadcast
61 if( iface->IP6.SubnetBits > 32 && Address.L[0] != iface->IP6.Address.L[0] )
63 if( iface->IP6.SubnetBits > 64 && Address.L[1] != iface->IP6.Address.L[1] )
65 if( iface->IP6.SubnetBits > 96 && Address.L[2] != iface->IP6.Address.L[2] )
68 j = iface->IP6.SubnetBits / 32;
69 i = iface->IP6.SubnetBits % 32;
70 netmask = IPv4_Netmask( iface->IP6.SubnetBits % 32 );
72 // Check the last bit of the netmask
73 if( (Address.L[j] >> i) != (iface->IP6.Address.L[j] >> i) ) continue;
75 // Check that the host portion is one
76 if( (Address.L[j] & ~netmask) != (0xFFFFFFFF & ~netmask) ) continue;
77 if( j >= 2 && Address.L[3] != 0xFFFFFFFF) continue;
78 if( j >= 1 && Address.L[2] != 0xFFFFFFFF) continue;
79 if( j >= 0 && Address.L[1] != 0xFFFFFFFF) continue;