int IPv4_SendPacket(tInterface *Iface, tIPv4 Address, int Protocol, int ID, int Length, const void *Data)
{
tMacAddr to = ARP_Resolve4(Iface, Address);
- const tMacAddr zero = {{0,0,0,0,0,0}};
int bufSize = sizeof(tIPv4Header) + Length;
char buf[bufSize];
tIPv4Header *hdr = (void*)buf;
int ret;
- if( MAC_EQU(to, zero) ) {
+ if( MAC_EQU(to, cMAC_ZERO) ) {
+ // No route to host
+ Log_Notice("IPv4", "No route to host %i.%i.%i.%i",
+ Address.B[0], Address.B[1], Address.B[2], Address.B[3]);
return 0;
}
4, (tIPv4*)Iface->Address, &Address,
Protocol, 0,
Length, Data);
- if(ret != 0) {
+ if(ret > 0) {
// Just drop it (with an error)
+ Log_Notice("IPv4", "Firewall dropped packet");
return 0;
}
Uint8 *data;
int dataLength;
int ret;
-
+
if(Length < sizeof(tIPv4Header)) return;
#if 0
case 1:
Log_Debug("IPv4", "Silently dropping packet");
return ;
+ case -1:
+ // Bad rule
+ break ;
// Unknown, silent drop
default:
+ Log_Warning("IPv4", "Unknown firewall rule");
return ;
}
rt = IPStack_FindRoute(4, NULL, &hdr->Destination); // Get the route (gets the interface)
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)",