#include <IPv6NeighbourCache.h>
This is just a plain container class -- the IPv6NeighbourDiscovery module is free to manipulate the contents of the Neighbour entries as it pleases.
NOTE: we don't keep a separate Default Router List, the Neighbour Cache serves that purpose too. Removing an entry from the Default Router List in our case is done by setting the isDefaultRouter flag of the entry to false.
Public Types | |
typedef std::vector< cMessage * > | MsgPtrVector |
typedef std::map< Key, Neighbour > | NeighbourMap |
typedef NeighbourMap::iterator | iterator |
INCOMPLETE | |
REACHABLE | |
STALE | |
DELAY | |
PROBE | |
enum | ReachabilityState { INCOMPLETE, REACHABLE, STALE, DELAY, PROBE } |
Public Member Functions | |
IPv6NeighbourCache () | |
~IPv6NeighbourCache () | |
Neighbour * | lookup (const IPv6Address &addr, int interfaceID) |
const Key * | lookupKeyAddr (Key &key) |
iterator | begin () |
iterator | end () |
Neighbour * | addNeighbour (const IPv6Address &addr, int interfaceID) |
Neighbour * | addNeighbour (const IPv6Address &addr, int interfaceID, MACAddress macAddress) |
Neighbour * | addRouter (const IPv6Address &addr, int interfaceID, simtime_t expiryTime) |
Neighbour * | addRouter (const IPv6Address &addr, int interfaceID, MACAddress macAddress, simtime_t expiryTime) |
void | remove (const IPv6Address &addr, int interfaceID) |
void | remove (NeighbourMap::iterator it) |
Static Public Member Functions | |
static const char * | stateName (ReachabilityState state) |
Private Attributes | |
NeighbourMap | neighbourMap |
Classes | |
struct | Key |
struct | Neighbour |
typedef NeighbourMap::iterator IPv6NeighbourCache::iterator |
typedef std::vector<cMessage*> IPv6NeighbourCache::MsgPtrVector |
typedef std::map<Key,Neighbour> IPv6NeighbourCache::NeighbourMap |
The std::map underlying the Neighbour Cache data structure
IPv6NeighbourCache::IPv6NeighbourCache | ( | ) |
IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::addNeighbour | ( | const IPv6Address & | addr, | |
int | interfaceID, | |||
MACAddress | macAddress | |||
) |
Creates and initializes a neighbour entry with isRouter=false, MAC address and state=STALE.
00078 { 00079 Key key(addr, interfaceID); 00080 ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet 00081 Neighbour& nbor = neighbourMap[key]; 00082 00083 nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience. 00084 nbor.macAddress = macAddress; 00085 nbor.isRouter = false; 00086 nbor.isDefaultRouter = false; 00087 nbor.reachabilityState = STALE; 00088 nbor.reachabilityExpires = 0; 00089 nbor.numProbesSent = 0; 00090 nbor.nudTimeoutEvent = NULL; 00091 nbor.routerExpiryTime = 0; 00092 return &nbor; 00093 }
IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::addNeighbour | ( | const IPv6Address & | addr, | |
int | interfaceID | |||
) |
Creates and initializes a neighbour entry with isRouter=false, state=INCOMPLETE.
00060 { 00061 Key key(addr, interfaceID); 00062 ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet 00063 Neighbour& nbor = neighbourMap[key]; 00064 00065 nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience. 00066 nbor.isRouter = false; 00067 nbor.isDefaultRouter = false; 00068 nbor.reachabilityState = INCOMPLETE; 00069 nbor.reachabilityExpires = 0; 00070 nbor.numProbesSent = 0; 00071 nbor.nudTimeoutEvent = NULL; 00072 nbor.numOfARNSSent = 0; 00073 nbor.routerExpiryTime = 0; 00074 return &nbor; 00075 }
IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::addRouter | ( | const IPv6Address & | addr, | |
int | interfaceID, | |||
MACAddress | macAddress, | |||
simtime_t | expiryTime | |||
) |
Creates and initializes a router entry (isRouter=isDefaultRouter=true), MAC address and state=STALE.
00115 { 00116 Key key(addr, interfaceID); 00117 ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet 00118 Neighbour& nbor = neighbourMap[key]; 00119 00120 nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience. 00121 nbor.macAddress = macAddress; 00122 nbor.isRouter = true; 00123 nbor.isDefaultRouter = true; 00124 nbor.reachabilityState = STALE; 00125 nbor.reachabilityExpires = 0; 00126 nbor.numProbesSent = 0; 00127 nbor.nudTimeoutEvent = NULL; 00128 00129 nbor.routerExpiryTime = expiryTime; 00130 return &nbor; 00131 }
IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::addRouter | ( | const IPv6Address & | addr, | |
int | interfaceID, | |||
simtime_t | expiryTime | |||
) |
Creates and initializes a router entry (isRouter=isDefaultRouter=true), state=INCOMPLETE.
00097 { 00098 Key key(addr, interfaceID); 00099 ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet 00100 Neighbour& nbor = neighbourMap[key]; 00101 00102 nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience. 00103 nbor.isRouter = true; 00104 nbor.isDefaultRouter = true;//FIXME: a router may advertise itself it self as a router but not as a default one.-WEI 00105 nbor.reachabilityState = INCOMPLETE; 00106 nbor.reachabilityExpires = 0; 00107 nbor.numProbesSent = 0; 00108 nbor.nudTimeoutEvent = NULL; 00109 nbor.routerExpiryTime = expiryTime; 00110 return &nbor; 00111 }
iterator IPv6NeighbourCache::begin | ( | ) | [inline] |
iterator IPv6NeighbourCache::end | ( | ) | [inline] |
IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::lookup | ( | const IPv6Address & | addr, | |
int | interfaceID | |||
) |
Returns a neighbour entry, or NULL.
00047 { 00048 Key key(addr, interfaceID); 00049 NeighbourMap::iterator i = neighbourMap.find(key); 00050 return i==neighbourMap.end() ? NULL : &(i->second); 00051 }
const IPv6NeighbourCache::Key * IPv6NeighbourCache::lookupKeyAddr | ( | Key & | key | ) |
Experimental code.
00054 { 00055 NeighbourMap::iterator i = neighbourMap.find(key); 00056 return &(i->first); 00057 }
void IPv6NeighbourCache::remove | ( | NeighbourMap::iterator | it | ) |
Deletes the given neighbour from the cache.
00143 { 00144 delete it->second.nudTimeoutEvent; 00145 neighbourMap.erase(it); 00146 }
void IPv6NeighbourCache::remove | ( | const IPv6Address & | addr, | |
int | interfaceID | |||
) |
Deletes the given neighbour from the cache.
00134 { 00135 Key key(addr, interfaceID); 00136 NeighbourMap::iterator it = neighbourMap.find(key); 00137 ASSERT(it!=neighbourMap.end()); // entry must exist 00138 delete it->second.nudTimeoutEvent; 00139 neighbourMap.erase(it); 00140 }
const char * IPv6NeighbourCache::stateName | ( | ReachabilityState | state | ) | [static] |
Returns the name of the given state as string
00149 { 00150 switch (state) 00151 { 00152 case INCOMPLETE: return "INCOMPLETE"; 00153 case REACHABLE: return "REACHABLE"; 00154 case STALE: return "STALE"; 00155 case DELAY: return "DELAY"; 00156 case PROBE: return "PROBE"; 00157 default: return "???"; 00158 } 00159 }
NeighbourMap IPv6NeighbourCache::neighbourMap [private] |