/*
* Acess2 IP Stack
* - Address Resolution Protocol
+ * - Part of the IPv4 protocol
*/
#define DEBUG 0
#include "ipstack.h"
#include "arp.h"
#include "link.h"
-#define ARPv6 1
+#define ARPv6 0
#define ARP_CACHE_SIZE 64
#define ARP_MAX_AGE (60*60*1000) // 1Hr
ENTER("pInterface xAddress", Interface, Address);
+ // Check routing tables
+ {
+ tRoute *route = IPStack_FindRoute(4, Interface, &Address);
+ if( route ) {
+ // If the next hop is defined, use it
+ // - 0.0.0.0 as the next hop means "no next hop / direct"
+ if( ((tIPv4*)route->NextHop)->L != 0 ) {
+ // Recursion: see /Recursion/
+ return ARP_Resolve4(Interface, *(tIPv4*)route->NextHop);
+ }
+ }
+ }
+
+ // Check ARP Cache
Mutex_Acquire( &glARP_Cache4 );
for( i = 0; i < giARP_Cache4Space; i++ )
{
req.SWSize = 4;
req.Request = htons(1);
req.SourceMac = Interface->Adapter->MacAddr;
- req.SourceIP = Interface->IP4.Address;
+ req.SourceIP = *(tIPv4*)Interface->Address;
req.DestMac = cMAC_BROADCAST;
req.DestIP = Address;
req4->DestIP = req4->SourceIP;
req4->DestMac = req4->SourceMac;
- req4->SourceIP = iface->IP4.Address;
+ req4->SourceIP = *(tIPv4*)iface->Address;;
req4->SourceMac = Adapter->MacAddr;
req4->Request = htons(2);
Log_Debug("ARP", "Sending back us (%02x:%02x:%02x:%02x:%02x:%02x)",
{
req6->DestIP = req6->SourceIP;
req6->DestMac = req6->SourceMac;
- req6->SourceIP = iface->IP6.Address;
+ req6->SourceIP = *(tIPv6*)iface->Address;
req6->SourceMac = Adapter->MacAddr;
req6->Request = htons(2);
Log_Debug("ARP", "Sending back us (%02x:%02x:%02x:%02x:%02x:%02x)",