INET Framework for OMNeT++/OMNEST
IPv6NeighbourCache Class Reference

#include <IPv6NeighbourCache.h>

List of all members.

Classes

struct  Key
struct  Neighbour

Public Types

enum  ReachabilityState {
  INCOMPLETE, REACHABLE, STALE, DELAY,
  PROBE
}
typedef std::vector< cMessage * > MsgPtrVector
typedef std::map< Key, NeighbourNeighbourMap
typedef NeighbourMap::iterator iterator

Public Member Functions

 IPv6NeighbourCache ()
virtual ~IPv6NeighbourCache ()
virtual Neighbourlookup (const IPv6Address &addr, int interfaceID)
virtual const KeylookupKeyAddr (Key &key)
iterator begin ()
iterator end ()
virtual NeighbouraddNeighbour (const IPv6Address &addr, int interfaceID)
virtual NeighbouraddNeighbour (const IPv6Address &addr, int interfaceID, MACAddress macAddress)
virtual NeighbouraddRouter (const IPv6Address &addr, int interfaceID, simtime_t expiryTime)
virtual NeighbouraddRouter (const IPv6Address &addr, int interfaceID, MACAddress macAddress, simtime_t expiryTime)
virtual void remove (const IPv6Address &addr, int interfaceID)
virtual void remove (NeighbourMap::iterator it)

Static Public Member Functions

static const char * stateName (ReachabilityState state)

Protected Attributes

NeighbourMap neighbourMap

Detailed Description

Copyright (C) 2005 Andras Varga Copyright (C) 2005 Wei Yang, Ng

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program; if not, see <http://www.gnu.org/licenses/>. IPv6 Neighbour Cache (RFC 2461 Neighbor Discovery for IPv6). Used internally by the IPv6NeighbourDiscovery simple module.

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.


Member Typedef Documentation

typedef NeighbourMap::iterator IPv6NeighbourCache::iterator
typedef std::vector<cMessage*> IPv6NeighbourCache::MsgPtrVector

The std::map underlying the Neighbour Cache data structure


Member Enumeration Documentation

Neighbour's reachability state

Enumerator:
INCOMPLETE 
REACHABLE 
STALE 
DELAY 
PROBE 

Constructor & Destructor Documentation

IPv6NeighbourCache::IPv6NeighbourCache ( )
{
    WATCH_MAP(neighbourMap);
}
virtual IPv6NeighbourCache::~IPv6NeighbourCache ( ) [inline, virtual]
{}

Member Function Documentation

IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::addNeighbour ( const IPv6Address addr,
int  interfaceID 
) [virtual]

Creates and initializes a neighbour entry with isRouter=false, state=INCOMPLETE.

Referenced by IPv6NeighbourDiscovery::processIPv6Datagram(), IPv6NeighbourDiscovery::processNSWithSpecifiedSrcAddr(), and IPv6NeighbourDiscovery::processRAForRouterUpdates().

{
    Key key(addr, interfaceID);
    ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet
    Neighbour& nbor = neighbourMap[key];

    nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience.
    nbor.isRouter = false;
    nbor.isDefaultRouter = false;
    nbor.reachabilityState = INCOMPLETE;
    nbor.reachabilityExpires = 0;
    nbor.numProbesSent = 0;
    nbor.nudTimeoutEvent = NULL;
    nbor.numOfARNSSent = 0;
    nbor.routerExpiryTime = 0;
    return &nbor;
}
IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::addNeighbour ( const IPv6Address addr,
int  interfaceID,
MACAddress  macAddress 
) [virtual]

Creates and initializes a neighbour entry with isRouter=false, MAC address and state=STALE.

{
    Key key(addr, interfaceID);
    ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet
    Neighbour& nbor = neighbourMap[key];

    nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience.
    nbor.macAddress = macAddress;
    nbor.isRouter = false;
    nbor.isDefaultRouter = false;
    nbor.reachabilityState = STALE;
    nbor.reachabilityExpires = 0;
    nbor.numProbesSent = 0;
    nbor.nudTimeoutEvent = NULL;
    nbor.routerExpiryTime = 0;
    return &nbor;
}
IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::addRouter ( const IPv6Address addr,
int  interfaceID,
MACAddress  macAddress,
simtime_t  expiryTime 
) [virtual]

Creates and initializes a router entry (isRouter=isDefaultRouter=true), MAC address and state=STALE.

{
    Key key(addr, interfaceID);
    ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet
    Neighbour& nbor = neighbourMap[key];

    nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience.
    nbor.macAddress = macAddress;
    nbor.isRouter = true;
    nbor.isDefaultRouter = true;
    nbor.reachabilityState = STALE;
    nbor.reachabilityExpires = 0;
    nbor.numProbesSent = 0;
    nbor.nudTimeoutEvent = NULL;

    nbor.routerExpiryTime = expiryTime;
    return &nbor;
}
IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::addRouter ( const IPv6Address addr,
int  interfaceID,
simtime_t  expiryTime 
) [virtual]

Creates and initializes a router entry (isRouter=isDefaultRouter=true), state=INCOMPLETE.

Referenced by IPv6NeighbourDiscovery::processRAForRouterUpdates().

{
    Key key(addr, interfaceID);
    ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet
    Neighbour& nbor = neighbourMap[key];

    nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience.
    nbor.isRouter = true;
    nbor.isDefaultRouter = true;//FIXME: a router may advertise itself it self as a router but not as a default one.-WEI
    nbor.reachabilityState = INCOMPLETE;
    nbor.reachabilityExpires = 0;
    nbor.numProbesSent = 0;
    nbor.nudTimeoutEvent = NULL;
    nbor.routerExpiryTime = expiryTime;
    return &nbor;
}
iterator IPv6NeighbourCache::begin ( ) [inline]

For iteration on the internal std::map

Referenced by IPv6NeighbourDiscovery::selectDefaultRouter().

{return neighbourMap.begin();}
iterator IPv6NeighbourCache::end ( ) [inline]

For iteration on the internal std::map

Referenced by IPv6NeighbourDiscovery::selectDefaultRouter().

{return neighbourMap.end();}
IPv6NeighbourCache::Neighbour * IPv6NeighbourCache::lookup ( const IPv6Address addr,
int  interfaceID 
) [virtual]
const IPv6NeighbourCache::Key * IPv6NeighbourCache::lookupKeyAddr ( Key key) [virtual]

Experimental code.

Referenced by addNeighbour(), and addRouter().

{
    NeighbourMap::iterator i = neighbourMap.find(key);
    return &(i->first);
}
void IPv6NeighbourCache::remove ( NeighbourMap::iterator  it) [virtual]

Deletes the given neighbour from the cache.

{
    delete it->second.nudTimeoutEvent;
    neighbourMap.erase(it);
}
void IPv6NeighbourCache::remove ( const IPv6Address addr,
int  interfaceID 
) [virtual]

Deletes the given neighbour from the cache.

Referenced by IPv6NeighbourDiscovery::dropQueuedPacketsAwaitingAR(), IPv6NeighbourDiscovery::processNUDTimeout(), IPv6NeighbourDiscovery::selectDefaultRouter(), and IPv6NeighbourDiscovery::timeoutDefaultRouter().

{
    Key key(addr, interfaceID);
    NeighbourMap::iterator it = neighbourMap.find(key);
    ASSERT(it!=neighbourMap.end()); // entry must exist
    delete it->second.nudTimeoutEvent;
    neighbourMap.erase(it);
}
const char * IPv6NeighbourCache::stateName ( ReachabilityState  state) [static]

Returns the name of the given state as string

Referenced by operator<<().

{
    switch (state)
    {
        case INCOMPLETE: return "INCOMPLETE";
        case REACHABLE:  return "REACHABLE";
        case STALE:      return "STALE";
        case DELAY:      return "DELAY";
        case PROBE:      return "PROBE";
        default:         return "???";
    }
}

Member Data Documentation


The documentation for this class was generated from the following files: