INET Framework for OMNeT++/OMNEST
|
Represents the IPv6 routing table and neighbour discovery data structures. More...
#include <IPv6RoutingTable.h>
Classes | |
struct | DestCacheEntry |
class | RouteLessThan |
Public Member Functions | |
IPv6RoutingTable () | |
virtual | ~IPv6RoutingTable () |
virtual bool | isRouter () const |
IP forwarding on/off. More... | |
virtual bool | isMulticastForwardingEnabled () |
virtual void | routeChanged (IPv6Route *entry, int fieldCode) |
To be called from route objects whenever a field changes. More... | |
bool | isHomeAgent () const |
Determine whether normal Router or Home Agent. More... | |
void | setIsHomeAgent (bool value) |
Define whether normal Router or Home Agent. More... | |
bool | isMobileNode () const |
Determine whether a node is a Mobile Node or Correspondent Node: MN if TRUE or else a CN. More... | |
void | setIsMobileNode (bool value) |
Define whether a node is a Mobile Node or Correspondent Node: MN if TRUE or else a CN. More... | |
const IPv6Address & | getHomeAddress () |
bool | isHomeAddress (const IPv6Address &addr) |
Check whether provided address is a HoA. More... | |
void | deleteDefaultRoutes (int interfaceID) |
Deletes the current default routes for the given interface. More... | |
void | deleteAllRoutes () |
Deletes all routes from the routing table. More... | |
void | deletePrefixes (int interfaceID) |
Deletes all prefixes registered for the given interface. More... | |
bool | hasMIPv6Support () |
Can be used to check whether this node supports MIPv6 or not (MN, MR, HA or CN). More... | |
void | setMIPv6Support (bool value) |
This method is used to define whether the node support MIPv6 or not (MN, MR, HA or CN). More... | |
bool | isOnLinkAddress (const IPv6Address &address) |
Checks whether the provided address is in an on-link address with respect to the prefix advertisement list. More... | |
virtual bool | handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override |
ILifecycle method. More... | |
virtual bool | isForwardingEnabled () const override |
Forwarding on/off. More... | |
virtual bool | isMulticastForwardingEnabled () const override |
Multicast forwarding on/off. More... | |
virtual L3Address | getRouterIdAsGeneric () const override |
Returns routerId. More... | |
virtual bool | isLocalAddress (const L3Address &dest) const override |
Checks if the address is a local one, i.e. More... | |
virtual bool | isLocalBroadcastAddress (const L3Address &dest) const |
virtual InterfaceEntry * | getInterfaceByAddress (const L3Address &address) const override |
Returns an interface given by its address. More... | |
virtual InterfaceEntry * | findInterfaceByLocalBroadcastAddress (const L3Address &dest) const |
virtual IRoute * | findBestMatchingRoute (const L3Address &dest) const override |
The routing function. More... | |
virtual InterfaceEntry * | getOutputInterfaceForDestination (const L3Address &dest) const override |
Convenience function based on findBestMatchingRoute(). More... | |
virtual L3Address | getNextHopForDestination (const L3Address &dest) const override |
Convenience function based on findBestMatchingRoute(). More... | |
virtual bool | isLocalMulticastAddress (const L3Address &dest) const override |
Checks if the address is in one of the local multicast group address list. More... | |
virtual IMulticastRoute * | findBestMatchingMulticastRoute (const L3Address &origin, const L3Address &group) const override |
Returns route for a multicast origin and group. More... | |
virtual IRoute * | getDefaultRoute () const override |
Finds and returns the default route, or nullptr if it doesn't exist. More... | |
virtual void | addRoute (IRoute *entry) override |
Adds a route to the routing table. More... | |
virtual IRoute * | removeRoute (IRoute *entry) override |
Removes the given route from the routing table, and returns it. More... | |
virtual bool | deleteRoute (IRoute *entry) override |
Deletes the given route from the routing table. More... | |
virtual IMulticastRoute * | getMulticastRoute (int i) const override |
Returns the kth multicast route. More... | |
virtual int | getNumMulticastRoutes () const override |
Returns the total number of multicast routes. More... | |
virtual void | addMulticastRoute (IMulticastRoute *entry) override |
Adds a multicast route to the routing table. More... | |
virtual IMulticastRoute * | removeMulticastRoute (IMulticastRoute *entry) override |
Removes the given route from the routing table, and returns it. More... | |
virtual bool | deleteMulticastRoute (IMulticastRoute *entry) override |
Deletes the given multicast route from the routing table. More... | |
virtual IRoute * | createRoute () override |
virtual void | printRoutingTable () const override |
Prints the routing table. More... | |
Interfaces | |
virtual InterfaceEntry * | getInterfaceByAddress (const IPv6Address &address) const |
Returns an interface given by its address. More... | |
Routing functions | |
virtual bool | isLocalAddress (const IPv6Address &dest) const |
Checks if the address is one of the host's addresses, i.e. More... | |
const IPv6Address & | lookupDestCache (const IPv6Address &dest, int &outInterfaceId) |
Looks up the given destination address in the Destination Cache, then returns the next-hop address and the interface in the outInterfaceId variable. More... | |
const IPv6Route * | doLongestPrefixMatch (const IPv6Address &dest) |
Performs longest prefix match in the routing table and returns the resulting route, or nullptr if there was no match. More... | |
virtual bool | isPrefixPresent (const IPv6Address &prefix) const |
Checks if the given prefix already exists in the routing table (prefix list) More... | |
Managing the destination cache | |
virtual void | updateDestCache (const IPv6Address &dest, const IPv6Address &nextHopAddr, int interfaceId, simtime_t expiryTime) |
Add or update a destination cache entry. More... | |
virtual void | purgeDestCache () |
Discard all entries in destination cache. More... | |
virtual void | purgeDestCacheEntriesToNeighbour (const IPv6Address &nextHopAddr, int interfaceId) |
Discard all entries in destination cache where next hop is the given address on the given interface. More... | |
void | purgeDestCacheForInterfaceID (int interfaceId) |
Removes all destination cache entries for the specified interface. More... | |
Managing prefixes and the route table | |
virtual void | addOrUpdateOnLinkPrefix (const IPv6Address &destPrefix, int prefixLength, int interfaceId, simtime_t expiryTime) |
Add on-link prefix (route of type FROM_RA), or update existing one. More... | |
virtual void | deleteOnLinkPrefix (const IPv6Address &destPrefix, int prefixLength) |
Remove an on-link prefix. More... | |
virtual void | addOrUpdateOwnAdvPrefix (const IPv6Address &destPrefix, int prefixLength, int interfaceId, simtime_t expiryTime) |
Add route of type OWN_ADV_PREFIX. More... | |
virtual void | addStaticRoute (const IPv6Address &destPrefix, int prefixLength, unsigned int interfaceId, const IPv6Address &nextHop, int metric=0) |
Creates a static route. More... | |
virtual void | addDefaultRoute (const IPv6Address &raSrcAddr, unsigned int ifID, simtime_t routerLifetime) |
Adds a default route for a host. More... | |
virtual void | addRoutingProtocolRoute (IPv6Route *route) |
Adds the given getRoute(which can be OSPF, BGP, RIP or any other route) with src==ROUTING_PROT. More... | |
virtual IPv6Route * | removeRoute (IPv6Route *route) |
Removes the given route from the routing table, and returns it. More... | |
virtual bool | deleteRoute (IPv6Route *route) |
Deletes the given route from the route table. More... | |
virtual void | deleteInterfaceRoutes (const InterfaceEntry *entry) |
Deletes the routes that are using the specified interface. More... | |
virtual int | getNumRoutes () const override |
Return the number of routes. More... | |
virtual IPv6Route * | getRoute (int i) const override |
Return the ith route. More... | |
Public Member Functions inherited from inet::IRoutingTable | |
virtual | ~IRoutingTable () |
Public Member Functions inherited from inet::ILifecycle | |
virtual | ~ILifecycle () |
Protected Types | |
typedef std::map< IPv6Address, DestCacheEntry > | DestCache |
typedef std::vector< IPv6Route * > | RouteList |
Protected Member Functions | |
virtual IPv6Route * | createNewRoute (IPv6Address destPrefix, int prefixLength, IRoute::SourceType src) |
virtual void | addRoute (IPv6Route *route) |
bool | routeLessThan (const IPv6Route *a, const IPv6Route *b) const |
virtual void | configureInterfaceForIPv6 (InterfaceEntry *ie) |
virtual void | assignRequiredNodeAddresses (InterfaceEntry *ie) |
RFC 3513: Section 2.8 A Node's Required Address Assign the various addresses to the node's respective interface. More... | |
virtual void | configureInterfaceFromXML (InterfaceEntry *ie, cXMLElement *cfg) |
virtual void | configureTunnelFromXML (cXMLElement *cfg) |
void | internalAddRoute (IPv6Route *route) |
IPv6Route * | internalRemoveRoute (IPv6Route *route) |
RouteList::iterator | internalDeleteRoute (RouteList::iterator it) |
virtual void | refreshDisplay () const override |
virtual int | numInitStages () const override |
virtual void | initialize (int stage) override |
virtual void | parseXMLConfigFile () |
virtual void | handleMessage (cMessage *) override |
Raises an error. More... | |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override |
Called by the signal handler whenever a change of a category occurs to which this client has subscribed. More... | |
Protected Attributes | |
IInterfaceTable * | ift = nullptr |
bool | isrouter = false |
bool | multicastForward = false |
bool | useAdminDist = false |
bool | ishome_agent = false |
bool | ismobile_node = false |
bool | mipv6Support = false |
DestCache | destCache |
RouteList | routeList |
Friends | |
std::ostream & | operator<< (std::ostream &os, const DestCacheEntry &e) |
Represents the IPv6 routing table and neighbour discovery data structures.
This object has one instance per host or router.
See the NED documentation for general overview.
This is a simple module without gates, it requires function calls to it (message handling does nothing). Methods are provided for reading and updating the interface table and the route table, as well as for unicast and multicast routing.
The route table is read from a file. The route table can also be read and modified during simulation, typically by routing protocol implementations.
|
protected |
|
protected |
|
virtual |
|
virtual |
Adds a default route for a host.
This method requires the RA's source address and the router expiry time plus the simTime().
Referenced by inet::IPv6NeighbourDiscovery::processRAForRouterUpdates().
|
inlineoverridevirtual |
Adds a multicast route to the routing table.
Routes are allowed to be modified while in the routing table. (There is a notification mechanism that allows routing table internals to be updated on a routing entry change.)
Implements inet::IRoutingTable.
|
virtual |
Add on-link prefix (route of type FROM_RA), or update existing one.
To be called from code processing on-link prefixes in Router Advertisements. Expiry time can be derived from the Valid Lifetime field in the Router Advertisements.
NOTE: This method does NOT update the lifetime of matching addresses in the IInterfaceTable (see IPv6InterfaceData); that has to be done separately.
Referenced by inet::IPv6NeighbourDiscovery::processRAPrefixInfo().
|
virtual |
Add route of type OWN_ADV_PREFIX.
This is a prefix that this router advertises on this interface.
Referenced by inet::FlatNetworkConfigurator6::addOwnAdvPrefixRoutes(), and initialize().
|
protectedvirtual |
Referenced by addDefaultRoute(), addOrUpdateOnLinkPrefix(), addOrUpdateOwnAdvPrefix(), addRoutingProtocolRoute(), and addStaticRoute().
|
inlineoverridevirtual |
Adds a route to the routing table.
Routes are allowed to be modified while in the routing table. (There is a notification mechanism that allows routing table internals to be updated on a routing entry change.)
Implements inet::IRoutingTable.
|
virtual |
Adds the given getRoute(which can be OSPF, BGP, RIP or any other route) with src==ROUTING_PROT.
To store additional information with the route, one can subclass from IPv6Route and add more fields.
|
virtual |
Creates a static route.
If metric is omitted, it gets initialized to the interface's metric value.
Referenced by inet::FlatNetworkConfigurator6::addStaticRoutes(), and configureInterfaceForIPv6().
|
protectedvirtual |
RFC 3513: Section 2.8 A Node's Required Address Assign the various addresses to the node's respective interface.
This should be done when the IPv6 Protocol stack is created.
Referenced by configureInterfaceForIPv6().
|
protectedvirtual |
Referenced by initialize().
|
protectedvirtual |
Referenced by parseXMLConfigFile().
|
protectedvirtual |
Referenced by parseXMLConfigFile().
|
protectedvirtual |
Referenced by addDefaultRoute(), addOrUpdateOnLinkPrefix(), addOrUpdateOwnAdvPrefix(), and addStaticRoute().
|
inlineoverridevirtual |
Implements inet::IRoutingTable.
void inet::IPv6RoutingTable::deleteAllRoutes | ( | ) |
Deletes all routes from the routing table.
void inet::IPv6RoutingTable::deleteDefaultRoutes | ( | int | interfaceID | ) |
Deletes the current default routes for the given interface.
Referenced by inet::IPv6NeighbourDiscovery::routersUnreachabilityDetection().
|
virtual |
Deletes the routes that are using the specified interface.
Referenced by receiveSignal().
|
inlineoverridevirtual |
Deletes the given multicast route from the routing table.
Returns true if the route was deleted, and false if it was not in the routing table.
Implements inet::IRoutingTable.
|
virtual |
Remove an on-link prefix.
To be called when the prefix gets advertised with zero lifetime, or to purge an expired prefix.
NOTE: This method does NOT remove the matching addresses from the IInterfaceTable (see IPv6InterfaceData); that has to be done separately.
Referenced by inet::IPv6NeighbourDiscovery::processRAPrefixInfo(), and inet::IPv6NeighbourDiscovery::timeoutPrefixEntry().
void inet::IPv6RoutingTable::deletePrefixes | ( | int | interfaceID | ) |
Deletes all prefixes registered for the given interface.
Referenced by inet::IPv6NeighbourDiscovery::routersUnreachabilityDetection().
|
virtual |
Deletes the given route from the route table.
Returns true, if it was deleted, false if it was not found in the routing table.
|
inlineoverridevirtual |
Deletes the given route from the routing table.
Returns true if the route was deleted, and false if it was not in the routing table.
Implements inet::IRoutingTable.
Referenced by deleteRoute().
const IPv6Route * inet::IPv6RoutingTable::doLongestPrefixMatch | ( | const IPv6Address & | dest | ) |
Performs longest prefix match in the routing table and returns the resulting route, or nullptr if there was no match.
Referenced by inet::IPv6NeighbourDiscovery::determineNextHop(), and inet::IPv6::determineOutputInterface().
|
inlineoverridevirtual |
Returns route for a multicast origin and group.
Implements inet::IRoutingTable.
|
inlineoverridevirtual |
The routing function.
Performs longest prefix match for the given destination address, and returns the resulting route. Returns nullptr if there is no matching route.
Implements inet::IRoutingTable.
|
inlinevirtual |
|
inlineoverridevirtual |
Finds and returns the default route, or nullptr if it doesn't exist.
Implements inet::IRoutingTable.
const IPv6Address & inet::IPv6RoutingTable::getHomeAddress | ( | ) |
|
virtual |
Returns an interface given by its address.
Returns nullptr if not found.
Referenced by inet::IPv6::encapsulate(), and getInterfaceByAddress().
|
overridevirtual |
Returns an interface given by its address.
Returns nullptr if not found.
Implements inet::IRoutingTable.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Convenience function based on findBestMatchingRoute().
Returns the gateway for the destination address. Returns the unspecified address if the destination is not in routing table or the gateway field is not filled in in the route.
Implements inet::IRoutingTable.
|
inlineoverridevirtual |
Returns the total number of multicast routes.
Implements inet::IRoutingTable.
|
overridevirtual |
|
inlineoverridevirtual |
Convenience function based on findBestMatchingRoute().
Returns the output interface for the packets with dest as destination address, or nullptr if the destination is not in routing table.
Implements inet::IRoutingTable.
|
overridevirtual |
|
inlineoverridevirtual |
Returns routerId.
Implements inet::IRoutingTable.
|
overrideprotectedvirtual |
|
overridevirtual |
ILifecycle method.
Implements inet::ILifecycle.
|
inline |
Can be used to check whether this node supports MIPv6 or not (MN, MR, HA or CN).
Referenced by inet::IPv6::localDeliver(), inet::IPv6::processExtensionHeaders(), and inet::IPv6NeighbourDiscovery::sendPeriodicRA().
|
overrideprotectedvirtual |
|
protected |
Referenced by addRoute(), and routeChanged().
|
protected |
Referenced by deleteDefaultRoutes(), deleteInterfaceRoutes(), deleteOnLinkPrefix(), deletePrefixes(), deleteRoute(), and doLongestPrefixMatch().
Referenced by removeRoute(), and routeChanged().
|
inlineoverridevirtual |
Forwarding on/off.
Implements inet::IRoutingTable.
bool inet::IPv6RoutingTable::isHomeAddress | ( | const IPv6Address & | addr | ) |
Check whether provided address is a HoA.
Referenced by inet::xMIPv6::processType2RH(), inet::IPv6::routePacket(), and inet::xMIPv6::validateHoTMessage().
|
inline |
Determine whether normal Router or Home Agent.
Referenced by inet::IPv6NeighbourDiscovery::createAndSendRAPacket(), inet::IPv6Tunneling::decapsulateDatagram(), inet::xMIPv6::processBUMessage(), inet::xMIPv6::removeTimerEntries(), and inet::IPv6::routePacket().
|
virtual |
Checks if the address is one of the host's addresses, i.e.
assigned to one of its interfaces (tentatively or not).
Referenced by inet::IPv6Tunneling::createTunnel(), inet::IPv6::handleMessageFromHL(), inet::IPv6NeighbourDiscovery::processNSForTentativeAddress(), inet::IPv6::routeMulticastPacket(), and inet::IPv6::routePacket().
|
inlineoverridevirtual |
Checks if the address is a local one, i.e.
one of the host's.
Implements inet::IRoutingTable.
Referenced by isLocalAddress().
|
inlinevirtual |
|
inlineoverridevirtual |
Checks if the address is in one of the local multicast group address list.
Implements inet::IRoutingTable.
|
inline |
Determine whether a node is a Mobile Node or Correspondent Node: MN if TRUE or else a CN.
Referenced by inet::IPv6Tunneling::decapsulateDatagram(), inet::xMIPv6::initialize(), inet::xMIPv6::initiateMIPv6Protocol(), inet::IPv6NeighbourDiscovery::makeTentativeAddressPermanent(), inet::xMIPv6::processBAMessage(), inet::xMIPv6::processBUMessage(), inet::IPv6NeighbourDiscovery::processRAPrefixInfoForAddrAutoConf(), inet::xMIPv6::removeTimerEntries(), inet::IPv6::resolveMACAddressAndSendPacket(), and inet::IPv6::routePacket().
|
inlinevirtual |
|
inlineoverridevirtual |
Multicast forwarding on/off.
Implements inet::IRoutingTable.
bool inet::IPv6RoutingTable::isOnLinkAddress | ( | const IPv6Address & | address | ) |
Checks whether the provided address is in an on-link address with respect to the prefix advertisement list.
Referenced by inet::xMIPv6::processBUMessage().
|
virtual |
Checks if the given prefix already exists in the routing table (prefix list)
Referenced by inet::IPv6NeighbourDiscovery::processRAPrefixInfo().
|
inlinevirtual |
IP forwarding on/off.
Referenced by inet::IPv6Tunneling::createTunnel(), inet::IPv6::determineOutputInterface(), isLocalAddress(), inet::IPv6NeighbourDiscovery::makeTentativeAddressPermanent(), inet::IPv6::routeMulticastPacket(), inet::IPv6::routePacket(), inet::IPv6NeighbourDiscovery::sendSolicitedNA(), and inet::IPv6NeighbourDiscovery::sendUnsolicitedNA().
const IPv6Address & inet::IPv6RoutingTable::lookupDestCache | ( | const IPv6Address & | dest, |
int & | outInterfaceId | ||
) |
Looks up the given destination address in the Destination Cache, then returns the next-hop address and the interface in the outInterfaceId variable.
If the destination is not in the cache, outInterfaceId is set to -1 and the unspecified address is returned. The caller should check for interfaceId==-1, because unspecified address is also returned if the link layer doesn't use addresses at all (e.g. PPP).
NOTE: outInterfaceId is an OUTPUT parameter – its initial value is ignored, and the lookupDestCache() sets it to the correct value instead.
Referenced by inet::IPv6::determineOutputInterface(), and inet::IPv6Tunneling::encapsulateDatagram().
|
inlineoverrideprotectedvirtual |
|
protectedvirtual |
Referenced by initialize().
|
overridevirtual |
Prints the routing table.
Implements inet::IRoutingTable.
|
virtual |
|
virtual |
Discard all entries in destination cache where next hop is the given address on the given interface.
This is typically called when a router becomes unreachable, and all destinations going via that router have to go though router selection again.
Referenced by inet::IPv6NeighbourDiscovery::timeoutDefaultRouter().
void inet::IPv6RoutingTable::purgeDestCacheForInterfaceID | ( | int | interfaceId | ) |
|
overrideprotectedvirtual |
Called by the signal handler whenever a change of a category occurs to which this client has subscribed.
|
overrideprotectedvirtual |
|
inlineoverridevirtual |
Removes the given route from the routing table, and returns it.
nullptr is returned of the route was not in the routing table.
Implements inet::IRoutingTable.
Removes the given route from the routing table, and returns it.
nullptr is returned if the route was not in the routing table.
Referenced by handleOperationStage().
Removes the given route from the routing table, and returns it.
nullptr is returned if the route was not in the routing table.
Implements inet::IRoutingTable.
Referenced by removeRoute().
|
virtual |
To be called from route objects whenever a field changes.
Used for maintaining internal data structures and firing "routing table changed" notifications.
Referenced by inet::IPv6Route::changed().
|
protected |
Referenced by inet::IPv6RoutingTable::RouteLessThan::operator()().
|
inline |
|
inline |
Define whether a node is a Mobile Node or Correspondent Node: MN if TRUE or else a CN.
Referenced by inet::xMIPv6::initialize().
|
inline |
This method is used to define whether the node support MIPv6 or not (MN, MR, HA or CN).
Referenced by inet::xMIPv6::initialize().
|
virtual |
Add or update a destination cache entry.
Referenced by inet::IPv6NeighbourDiscovery::determineNextHop(), and inet::IPv6::determineOutputInterface().
|
friend |
|
protected |
|
protected |
|
protected |
Referenced by initialize().
|
protected |
Referenced by initialize().
|
protected |
Referenced by configureInterfaceForIPv6(), and initialize().
|
protected |
Referenced by initialize().
|
protected |
Referenced by initialize().
|
protected |
Referenced by addOrUpdateOnLinkPrefix(), addOrUpdateOwnAdvPrefix(), deleteAllRoutes(), deleteDefaultRoutes(), deleteInterfaceRoutes(), deleteOnLinkPrefix(), deletePrefixes(), deleteRoute(), doLongestPrefixMatch(), getNumRoutes(), getRoute(), handleOperationStage(), initialize(), internalAddRoute(), internalDeleteRoute(), internalRemoveRoute(), isPrefixPresent(), printRoutingTable(), and ~IPv6RoutingTable().
|
protected |
Referenced by initialize(), and routeLessThan().