git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
AcessNative - Now can use the `dir` CLIShell builtin
[tpg/acess2.git]
/
Modules
/
IPStack
/
arp.c
diff --git
a/Modules/IPStack/arp.c
b/Modules/IPStack/arp.c
index
8238263
..
e0912ad
100644
(file)
--- a/
Modules/IPStack/arp.c
+++ b/
Modules/IPStack/arp.c
@@
-42,7
+42,7
@@
struct sARP_Cache6 {
int giARP_Cache6Space;
tMutex glARP_Cache6;
#endif
int giARP_Cache6Space;
tMutex glARP_Cache6;
#endif
- int giARP_LastUpdateID = 0;
+
volatile
int giARP_LastUpdateID = 0;
// === CODE ===
/**
// === CODE ===
/**
@@
-81,13
+81,12
@@
tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address)
if( IPStack_CompareAddress(4, &Address, Interface->Address, Interface->SubnetBits) == 0 )
{
tRoute *route = IPStack_FindRoute(4, Interface, &Address);
if( IPStack_CompareAddress(4, &Address, Interface->Address, Interface->SubnetBits) == 0 )
{
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);
- }
+ // If the next hop is defined, use it
+ // - 0.0.0.0 as the next hop means "no next hop / direct"
+ if( route && ((tIPv4*)route->NextHop)->L != 0 )
+ {
+ // Recursion: see /Recursion/
+ return ARP_Resolve4(Interface, *(tIPv4*)route->NextHop);
}
}
}
}
@@
-135,10
+134,14
@@
tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address)
// Wait for a reply
for(;;)
{
// Wait for a reply
for(;;)
{
- while(lastID == giARP_LastUpdateID && now() < timeout)
+ while(lastID == giARP_LastUpdateID && now() < timeout)
{
Threads_Yield();
Threads_Yield();
+ }
- if( now() >= timeout ) break; // Timeout
+ if( now() >= timeout ) {
+ Log_Log("ARP4", "Timeout");
+ break; // Timeout
+ }
lastID = giARP_LastUpdateID;
lastID = giARP_LastUpdateID;
@@
-148,6
+151,10
@@
tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address)
if(gaARP_Cache4[i].IP.L != Address.L) continue;
Mutex_Release( &glARP_Cache4 );
if(gaARP_Cache4[i].IP.L != Address.L) continue;
Mutex_Release( &glARP_Cache4 );
+ Log_Debug("ARP4", "Return %02x:%02x:%02x:%02x:%02x:%02x",
+ 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]);
return gaARP_Cache4[i].MAC;
}
Mutex_Release( &glARP_Cache4 );
return gaARP_Cache4[i].MAC;
}
Mutex_Release( &glARP_Cache4 );
@@
-183,7
+190,6
@@
void ARP_UpdateCache4(tIPv4 SWAddr, tMacAddr HWAddr)
i = free;
else
i = oldest;
i = free;
else
i = oldest;
- gaARP_Cache4[i].IP = SWAddr;
}
Log_Log("ARP4", "Caching %i.%i.%i.%i (%02x:%02x:%02x:%02x:%02x:%02x) in %i",
}
Log_Log("ARP4", "Caching %i.%i.%i.%i (%02x:%02x:%02x:%02x:%02x:%02x) in %i",
@@
-192,6
+198,7
@@
void ARP_UpdateCache4(tIPv4 SWAddr, tMacAddr HWAddr)
i
);
i
);
+ gaARP_Cache4[i].IP = SWAddr;
gaARP_Cache4[i].MAC = HWAddr;
gaARP_Cache4[i].LastUpdate = now();
giARP_LastUpdateID ++;
gaARP_Cache4[i].MAC = HWAddr;
gaARP_Cache4[i].LastUpdate = now();
giARP_LastUpdateID ++;
UCC
git Repository :: git.ucc.asn.au