-/**
- * \brief Updates the ARP Cache entry for an IPv4 Address
- */
-void ARP_UpdateCache4(tIPv4 SWAddr, tMacAddr HWAddr)
-{
- int i;
- int free = -1;
- int oldest = 0;
-
- // Find an entry for the IP address in the cache
- Mutex_Acquire(&glARP_Cache4);
- for( i = giARP_Cache4Space; i--; )
- {
- if(gaARP_Cache4[oldest].LastUpdate > gaARP_Cache4[i].LastUpdate) {
- oldest = i;
- }
- if( gaARP_Cache4[i].IP.L == SWAddr.L ) break;
- if( gaARP_Cache4[i].LastUpdate == 0 && free == -1 ) free = i;
- }
- // If there was no match, we need to make one
- if(i == -1) {
- if(free != -1)
- i = free;
- else
- i = oldest;
- }
-
- if( memcmp(&gaARP_Cache4[i].MAC, &HWAddr, sizeof(HWAddr)) != 0 )
- {
- Log_Log("ARP4", "Caching %i.%i.%i.%i (%02x:%02x:%02x:%02x:%02x:%02x) in %i",
- SWAddr.B[0], SWAddr.B[1], SWAddr.B[2], SWAddr.B[3],
- HWAddr.B[0], HWAddr.B[1], HWAddr.B[2], HWAddr.B[3], HWAddr.B[4], HWAddr.B[5],
- i
- );
-
- gaARP_Cache4[i].IP = SWAddr;
- gaARP_Cache4[i].MAC = HWAddr;
- gaARP_Cache4[i].LastUpdate = now();
- Semaphore_Signal(&gARP_Cache4Semaphore, giARP_WaitingThreads);
- }
- Mutex_Release(&glARP_Cache4);
-}
-
-#if ARPv6
-/**
- * \brief Updates the ARP Cache entry for an IPv6 Address
- */
-void ARP_UpdateCache6(tIPv6 SWAddr, tMacAddr HWAddr)
-{
- int i;
- int free = -1;
- int oldest = 0;
-
- // Find an entry for the MAC address in the cache
- Mutex_Acquire(&glARP_Cache6);
- for( i = giARP_Cache6Space; i--; )
- {
- if(gaARP_Cache6[oldest].LastUpdate > gaARP_Cache6[i].LastUpdate) {
- oldest = i;
- }
- if( MAC_EQU(gaARP_Cache6[i].MAC, HWAddr) ) break;
- if( gaARP_Cache6[i].LastUpdate == 0 && free == -1 ) free = i;
- }
- // If there was no match, we need to make one
- if(i == -1) {
- if(free != -1)
- i = free;
- else
- i = oldest;
- gaARP_Cache6[i].MAC = HWAddr;
- }
-
- gaARP_Cache6[i].IP = SWAddr;
- gaARP_Cache6[i].LastUpdate = now();
- giARP_LastUpdateID ++;
- Mutex_Release(&glARP_Cache6);
-}
-#endif
-