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,
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 ;
}