- tMacAddr to;
- tRoute *rt;
-
- Log_Debug("IPv4", "Route the packet");
- // Drop the packet if the TTL is zero
- if( hdr->TTL == 0 ) {
- Log_Warning("IPv4", "TODO: Send ICMP-Timeout when TTL exceeded");
- return ;
- }
-
- hdr->TTL --;
-
- rt = IPStack_FindRoute(4, NULL, &hdr->Destination); // Get the route (gets the interface)
- if( !rt || !rt->Interface )
- return ;
- to = ARP_Resolve4(rt->Interface, hdr->Destination); // Resolve address
- if( MAC_EQU(to, cMAC_ZERO) )
- return ;
-
- // Send packet
- Log_Log("IPv4", "Forwarding packet to %i.%i.%i.%i (via %i.%i.%i.%i)",
- hdr->Destination.B[0], hdr->Destination.B[1],
- hdr->Destination.B[2], hdr->Destination.B[3],
- ((tIPv4*)rt->NextHop)->B[0], ((tIPv4*)rt->NextHop)->B[1],
- ((tIPv4*)rt->NextHop)->B[2], ((tIPv4*)rt->NextHop)->B[3]);
- Link_SendPacket(rt->Interface->Adapter, IPV4_ETHERNET_ID, to, Length, Buffer);
-
-