X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FIPStack%2Fipv6.c;h=9368c3e2614950f42e8f362819a2ba04db93f376;hb=fe2794b4f932c0755674493b6a6da4b60a5c2433;hp=31aedcb3e564808b57eebb71082037d55063aae2;hpb=6c5a509b5e14e097ca537c539bc9babe3b8f0c4c;p=tpg%2Facess2.git diff --git a/Modules/IPStack/ipv6.c b/Modules/IPStack/ipv6.c index 31aedcb3..9368c3e2 100644 --- a/Modules/IPStack/ipv6.c +++ b/Modules/IPStack/ipv6.c @@ -7,6 +7,7 @@ #include "ipv6.h" // === IMPORTS === +extern tInterface *gIP_Interfaces; extern Uint32 IPv4_Netmask(int FixedBits); // === PROTOTYPES === @@ -16,7 +17,7 @@ tInterface *IPv6_GetInterface(tAdapter *Adapter, tIPv6 Address, int Broadcast); // === CODE === /** - * \fn int IPv6_Initialise() + * \brief Initialise the IPv6 handling code */ int IPv6_Initialise() { @@ -27,18 +28,41 @@ int IPv6_Initialise() /** * \fn void IPv6_int_GetPacket(tInterface *Interface, tMacAddr From, int Length, void *Buffer) * \brief Process an IPv6 Packet + * \param Interface Input interface + * \param From Source MAC address + * \param Length Packet length + * \param Buffer Packet data */ void IPv6_int_GetPacket(tAdapter *Interface, tMacAddr From, int Length, void *Buffer) { tIPv6Header *hdr = Buffer; if(Length < sizeof(tIPv6Header)) return; - if(hdr->Version != 6) return; + hdr->Head = ntohl(hdr->Head); + + //if( ((hdr->Head >> (20+8)) & 0xF) != 6 ) + if( hdr->Version != 6 ) + return; + + Log_Debug("IPv6", "hdr = {"); + Log_Debug("IPv6", " .Version = %i", hdr->Version ); + Log_Debug("IPv6", " .TrafficClass = %i", hdr->TrafficClass ); + Log_Debug("IPv6", " .FlowLabel = %i", hdr->FlowLabel ); + Log_Debug("IPv6", " .PayloadLength = 0x%04x", ntohs(hdr->PayloadLength) ); + Log_Debug("IPv6", " .NextHeader = 0x%02x", hdr->NextHeader ); + Log_Debug("IPv6", " .HopLimit = 0x%02x", hdr->HopLimit ); + Log_Debug("IPv6", " .Source = %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x", hdr->Source ); + Log_Debug("IPv6", " .Destination = %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x", hdr->Destination ); + Log_Debug("IPv6", "}"); + } /** * \fn tInterface *IPv6_GetInterface(tAdapter *Adapter, tIPv6 Address) * \brief Searches an adapter for a matching address + * \param Adapter Source adapter + * \param Address Destination Address + * \param Broadcast Allow broadcast? */ tInterface *IPv6_GetInterface(tAdapter *Adapter, tIPv6 Address, int Broadcast) { @@ -46,31 +70,36 @@ tInterface *IPv6_GetInterface(tAdapter *Adapter, tIPv6 Address, int Broadcast) tInterface *iface = NULL; Uint32 netmask; - for( iface = Adapter->Interfaces; iface; iface = iface->Next) + for( iface = gIP_Interfaces; iface; iface = iface->Next) { + tIPv6 *thisAddr; + // Check for this adapter + if( iface->Adapter != Adapter ) continue; + // Skip non-IPv6 Interfaces if( iface->Type != 6 ) continue; + thisAddr = (tIPv6*)iface->Address; // If the address is a perfect match, return this interface - if( IP6_EQU(Address, iface->IP6.Address) ) return iface; + if( IP6_EQU(Address, *thisAddr) ) return iface; // Check if we want to match broadcast addresses if( !Broadcast ) continue; // Check for broadcast - if( iface->IP6.SubnetBits > 32 && Address.L[0] != iface->IP6.Address.L[0] ) + if( iface->SubnetBits > 32 && Address.L[0] != thisAddr->L[0] ) continue; - if( iface->IP6.SubnetBits > 64 && Address.L[1] != iface->IP6.Address.L[1] ) + if( iface->SubnetBits > 64 && Address.L[1] != thisAddr->L[1] ) continue; - if( iface->IP6.SubnetBits > 96 && Address.L[2] != iface->IP6.Address.L[2] ) + if( iface->SubnetBits > 96 && Address.L[2] != thisAddr->L[2] ) continue; - j = iface->IP6.SubnetBits / 32; - i = iface->IP6.SubnetBits % 32; - netmask = IPv4_Netmask( iface->IP6.SubnetBits % 32 ); + j = iface->SubnetBits / 32; + i = iface->SubnetBits % 32; + netmask = IPv4_Netmask( iface->SubnetBits % 32 ); // Check the last bit of the netmask - if( (Address.L[j] >> i) != (iface->IP6.Address.L[j] >> i) ) continue; + if( (Address.L[j] >> i) != (thisAddr->L[j] >> i) ) continue; // Check that the host portion is one if( (Address.L[j] & ~netmask) != (0xFFFFFFFF & ~netmask) ) continue;