Fixing error reporting
[tpg/acess2.git] / Modules / IPStack / ipv4.c
index e37085b..ad6c891 100644 (file)
@@ -64,11 +64,16 @@ int IPv4_RegisterCallback(int ID, tIPCallback Callback)
 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) ) {
+               return 0;
+       }
+       
        // OUTPUT Firewall rule go here
        ret = IPTablesV4_TestChain("OUTPUT",
                (tIPv4*)Iface->Address, &Address,
@@ -284,9 +289,10 @@ Uint16 IPv4_Checksum(const void *Buf, int Size)
        Size = (Size + 1) >> 1; // 16-bit word count
        for(i = 0; i < Size; i++ )
        {
-               if((int)sum + arr[i] > 0xFFFF)
+               Uint16  val = ntohs(arr[i]);
+               if((int)sum + val > 0xFFFF)
                        sum ++; // Simulate 1's complement
-               sum += arr[i];
+               sum += val;
        }
        return ~sum ;
 }

UCC git Repository :: git.ucc.asn.au