+/**
+ * \brief Resolves a MAC address from an IPv4 address
+ */
+tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address)
+{
+ int lastID;
+ int i;
+
+ ENTER("pInterface xAddress", Interface, Address);
+
+ LOCK( &glARP_Cache4 );
+ for( i = 0; i < giARP_Cache4Space; i++ )
+ {
+ if(gaARP_Cache4[i].IP.L != Address.L) continue;
+
+ // Check if the entry needs to be refreshed
+ if( now() - gaARP_Cache4[i].LastUpdate > ARP_MAX_AGE ) break;
+
+ RELEASE( &glARP_Cache4 );
+ LOG("Return %x:%x:%x:%x:%x:%x",
+ gaARP_Cache4[i].MAC.B[0], gaARP_Cache4[i].MAC.B[1],
+ gaARP_Cache4[i].MAC.B[2], gaARP_Cache4[i].MAC.B[3],
+ gaARP_Cache4[i].MAC.B[4], gaARP_Cache4[i].MAC.B[5]
+ );
+ LEAVE('-');
+ return gaARP_Cache4[i].MAC;
+ }
+ RELEASE( &glARP_Cache4 );
+
+ lastID = giARP_LastUpdateID;
+ ARP_int_Resolve4(Interface, Address);
+ for(;;)
+ {
+ while(lastID == giARP_LastUpdateID) Threads_Yield();
+ lastID = giARP_LastUpdateID;
+
+ LOCK( &glARP_Cache4 );
+ for( i = 0; i < giARP_Cache4Space; i++ )
+ {
+ if(gaARP_Cache4[i].IP.L != Address.L) continue;
+
+ RELEASE( &glARP_Cache4 );
+ return gaARP_Cache4[i].MAC;
+ }
+ RELEASE( &glARP_Cache4 );
+ }
+}
+