Go to the documentation of this file.00001 
00019 #ifndef NEIGHBORCACHE_H
00020 #define NEIGHBORCACHE_H
00021 
00022 #include <map>
00023 #include <vector>
00024 #include <omnetpp.h>
00025 #include "IPv6Address.h"
00026 #include "MACAddress.h"
00027 
00028 
00042 class INET_API IPv6NeighbourCache
00043 {
00044   public:
00045     typedef std::vector<cMessage*> MsgPtrVector;  
00046 
00048     enum ReachabilityState {INCOMPLETE, REACHABLE, STALE, DELAY, PROBE};
00049 
00055     struct Key
00056     {
00057         IPv6Address address;
00058         int interfaceID;
00059         Key(IPv6Address addr, int ifaceID) {address=addr; interfaceID=ifaceID;}
00060         bool operator<(const Key& b) const {
00061             return interfaceID==b.interfaceID ? address<b.address : interfaceID<b.interfaceID;
00062         }
00063     };
00064 
00066     struct Neighbour
00067     {
00068         
00069         const Key *nceKey;
00070         MACAddress macAddress;
00071         bool isRouter;
00072         bool isDefaultRouter; 
00073 
00074         
00075         ReachabilityState reachabilityState;
00076         simtime_t reachabilityExpires; 
00077         short numProbesSent;
00078         cMessage *nudTimeoutEvent; 
00079 
00080         
00081         
00082         
00083         
00084         int numOfARNSSent;
00085         cMessage *arTimer;
00086         MsgPtrVector pendingPackets; 
00087         IPv6Address nsSrcAddr;
00088 
00089         
00090         
00091         
00092         
00093         
00094         
00095         
00096         simtime_t routerExpiryTime;   
00097     };
00098 
00099     
00100     
00101     
00102     
00103     
00104     
00105 
00107     typedef std::map<Key,Neighbour> NeighbourMap;
00108     typedef NeighbourMap::iterator iterator;
00109 
00110   protected:
00111     NeighbourMap neighbourMap;
00112 
00113   public:
00114     IPv6NeighbourCache();
00115     virtual ~IPv6NeighbourCache() {}
00116 
00118     virtual Neighbour *lookup(const IPv6Address& addr, int interfaceID);
00119 
00121     virtual const Key *lookupKeyAddr(Key& key);
00122 
00124     iterator begin()  {return neighbourMap.begin();}
00125 
00127     iterator end()  {return neighbourMap.end();}
00128 
00130     
00131     virtual Neighbour *addNeighbour(const IPv6Address& addr, int interfaceID);
00132 
00134     virtual Neighbour *addNeighbour(const IPv6Address& addr, int interfaceID,
00135                             MACAddress macAddress);
00136 
00138     
00139     virtual Neighbour *addRouter(const IPv6Address& addr, int interfaceID,
00140                         simtime_t expiryTime);
00141 
00143     virtual Neighbour *addRouter(const IPv6Address& addr, int interfaceID,
00144                          MACAddress macAddress, simtime_t expiryTime);
00145 
00147     virtual void remove(const IPv6Address& addr, int interfaceID);
00148 
00150     virtual void remove(NeighbourMap::iterator it);
00151 
00153     static const char *stateName(ReachabilityState state);
00154 };
00155 
00156 #endif