X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FIPStack%2Farp.c;h=abaea27584599a4e7d662503e64a5da903637054;hb=7c43aea724fea42bc297f47f9c180a5080c6fd17;hp=e0912ad8550388756b9d8419f492dc0d9a9961a4;hpb=30c11f371da98d13344e8bed3766d3e574a65ac9;p=tpg%2Facess2.git diff --git a/Modules/IPStack/arp.c b/Modules/IPStack/arp.c index e0912ad8..abaea275 100644 --- a/Modules/IPStack/arp.c +++ b/Modules/IPStack/arp.c @@ -77,6 +77,14 @@ tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address) ENTER("pInterface xAddress", Interface, Address); + // Check for broadcast + if( Address.L == -1 ) + { + LOG("Broadcast"); + LEAVE('-'); + return cMAC_BROADCAST; + } + // Check routing tables if not on this subnet if( IPStack_CompareAddress(4, &Address, Interface->Address, Interface->SubnetBits) == 0 ) { @@ -86,8 +94,23 @@ tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address) if( route && ((tIPv4*)route->NextHop)->L != 0 ) { // Recursion: see /Recursion/ + LOG("Recursing with %s", IPStack_PrintAddress(4, route->NextHop)); + LEAVE('-'); return ARP_Resolve4(Interface, *(tIPv4*)route->NextHop); } + // No route, fall though + } + else + { + Uint32 netmask; + // Check for broadcast + netmask = IPv4_Netmask(Interface->SubnetBits); + if( (Address.L & ~netmask) == (0xFFFFFFFF & ~netmask) ) + { + LOG("Local Broadcast"); + LEAVE('-'); + return cMAC_BROADCAST; + } } // Check ARP Cache