X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FIPStack%2Fipv4.c;h=6c387cc173e0e6b48a78854e335af096acaaa559;hb=f903bcea88df0cf2e12583ae74e35c4bfb6760bf;hp=eb7e51df67e3ea495147675563eeac8535e31c38;hpb=9cae7d64750db729b6bee582a8e7203ec3de36b4;p=tpg%2Facess2.git diff --git a/Modules/IPStack/ipv4.c b/Modules/IPStack/ipv4.c index eb7e51df..6c387cc1 100644 --- a/Modules/IPStack/ipv4.c +++ b/Modules/IPStack/ipv4.c @@ -71,6 +71,8 @@ int IPv4_SendPacket(tInterface *Iface, tIPv4 Address, int Protocol, int ID, int 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; } @@ -79,8 +81,9 @@ int IPv4_SendPacket(tInterface *Iface, tIPv4 Address, int Protocol, int ID, int 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; } @@ -121,7 +124,7 @@ void IPv4_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buff Uint8 *data; int dataLength; int ret; - + if(Length < sizeof(tIPv4Header)) return; #if 0 @@ -200,8 +203,12 @@ void IPv4_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buff 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 ; } @@ -310,12 +317,15 @@ Uint16 IPv4_Checksum(const void *Buf, int Size) const Uint16 *arr = Buf; int i; - Size = (Size + 1) >> 1; // 16-bit word count - for(i = 0; i < Size; i++ ) + // Sum all whole words + for(i = 0; i < Size/2; i++ ) { Uint16 val = ntohs(arr[i]); sum += val; } + // Add the tail word +// if( i*2 != Size ) +// sum += arr[i]&0xFF; // Apply one's complement while (sum >> 16)