|
INET Framework for OMNeT++/OMNEST
|
Represents the Ipv6 routing table and neighbour discovery data structures.
More...
#include <Ipv6RoutingTable.h>
|
| virtual void | addRoute (Ipv6Route *route) |
| |
| | Ipv6RoutingTable () |
| |
| virtual | ~Ipv6RoutingTable () |
| |
|
| virtual NetworkInterface * | getInterfaceByAddress (const Ipv6Address &address) const |
| | Returns an interface given by its address. More...
|
| |
| 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...
|
| |
|
| 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...
|
| |
|
| 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...
|
| |
|
| 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 NetworkInterface *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...
|
| |
| virtual bool | handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override |
| | ILifecycle method. More...
|
| |
| virtual bool | isAdminDistEnabled () const override |
| | Administrative distance on/off. 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 NetworkInterface * | getInterfaceByAddress (const L3Address &address) const override |
| | Returns an interface given by its address. More...
|
| |
| virtual NetworkInterface * | findInterfaceByLocalBroadcastAddress (const L3Address &dest) const |
| |
| virtual IRoute * | findBestMatchingRoute (const L3Address &dest) const override |
| | The routing function. More...
|
| |
| virtual NetworkInterface * | 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...
|
| |
| virtual | ~IRoutingTable () |
| |
| virtual | ~ILifecycle () |
| |
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.
◆ DestCache
◆ RouteList
◆ Ipv6RoutingTable()
| inet::Ipv6RoutingTable::Ipv6RoutingTable |
( |
| ) |
|
◆ ~Ipv6RoutingTable()
| inet::Ipv6RoutingTable::~Ipv6RoutingTable |
( |
| ) |
|
|
virtual |
◆ addDefaultRoute()
| void inet::Ipv6RoutingTable::addDefaultRoute |
( |
const Ipv6Address & |
raSrcAddr, |
|
|
unsigned int |
ifID, |
|
|
simtime_t |
routerLifetime |
|
) |
| |
|
virtual |
Adds a default route for a host.
This method requires the RA's source address and the router expiry time plus the simTime().
631 route->setInterface(
ift->getInterfaceById(ifID));
632 route->setNextHop(nextHop);
633 route->setMetric(10);
636 #ifdef INET_WITH_xMIPv6
637 route->setExpiryTime(routerLifetime);
◆ addMulticastRoute()
| virtual void inet::Ipv6RoutingTable::addMulticastRoute |
( |
IMulticastRoute * |
entry | ) |
|
|
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.
◆ addOrUpdateOnLinkPrefix()
| void inet::Ipv6RoutingTable::addOrUpdateOnLinkPrefix |
( |
const Ipv6Address & |
destPrefix, |
|
|
int |
prefixLength, |
|
|
int |
interfaceId, |
|
|
simtime_t |
expiryTime |
|
) |
| |
|
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.
536 Ipv6Route *route =
nullptr;
538 if ((elem)->getSourceType() ==
IRoute::ROUTER_ADVERTISEMENT && (elem)->getDestPrefix() == destPrefix && (elem)->getPrefixLength() == prefixLength) {
544 if (route ==
nullptr) {
547 route->setInterface(
ift->getInterfaceById(interfaceId));
548 route->setExpiryTime(expiryTime);
558 route->setInterface(
ift->getInterfaceById(interfaceId));
559 route->setExpiryTime(expiryTime);
◆ addOrUpdateOwnAdvPrefix()
| void inet::Ipv6RoutingTable::addOrUpdateOwnAdvPrefix |
( |
const Ipv6Address & |
destPrefix, |
|
|
int |
prefixLength, |
|
|
int |
interfaceId, |
|
|
simtime_t |
expiryTime |
|
) |
| |
|
virtual |
Add route of type OWN_ADV_PREFIX.
This is a prefix that this router advertises on this interface.
570 Ipv6Route *route =
nullptr;
572 if ((elem)->getSourceType() ==
IRoute::OWN_ADV_PREFIX && (elem)->getDestPrefix() == destPrefix && (elem)->getPrefixLength() == prefixLength) {
578 if (route ==
nullptr) {
581 route->setInterface(
ift->getInterfaceById(interfaceId));
582 route->setExpiryTime(expiryTime);
592 route->setInterface(
ift->getInterfaceById(interfaceId));
593 route->setExpiryTime(expiryTime);
Referenced by inet::Ipv6FlatNetworkConfigurator::addOwnAdvPrefixRoutes(), and initialize().
◆ addRoute() [1/2]
| void inet::Ipv6RoutingTable::addRoute |
( |
Ipv6Route * |
route | ) |
|
|
virtual |
◆ addRoute() [2/2]
| virtual void inet::Ipv6RoutingTable::addRoute |
( |
IRoute * |
entry | ) |
|
|
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.
◆ addRoutingProtocolRoute()
| void inet::Ipv6RoutingTable::addRoutingProtocolRoute |
( |
Ipv6Route * |
route | ) |
|
|
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.
◆ addStaticRoute()
| void inet::Ipv6RoutingTable::addStaticRoute |
( |
const Ipv6Address & |
destPrefix, |
|
|
int |
prefixLength, |
|
|
unsigned int |
interfaceId, |
|
|
const Ipv6Address & |
nextHop, |
|
|
int |
metric = 0 |
|
) |
| |
|
virtual |
◆ assignRequiredNodeAddresses()
| void inet::Ipv6RoutingTable::assignRequiredNodeAddresses |
( |
NetworkInterface * |
ie | ) |
|
|
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.
250 if (ie->isLoopback()) {
251 ie->getProtocolDataForUpdate<Ipv6InterfaceData>()->assignAddress(Ipv6Address(
"::1"),
false, SIMTIME_ZERO, SIMTIME_ZERO);
256 #ifndef INET_WITH_xMIPv6
260 Ipv6Address linkLocalAddr = Ipv6Address().formLinkLocalAddress(ie->getInterfaceToken());
261 ie->getProtocolDataForUpdate<Ipv6InterfaceData>()->assignAddress(linkLocalAddr,
true, SIMTIME_ZERO, SIMTIME_ZERO);
Referenced by configureInterfaceForIpv6().
◆ configureInterfaceForIpv6()
217 auto ipv6IfData = ie->addProtocolData<Ipv6InterfaceData>();
223 ipv6IfData->setAdvSendAdvertisements(
isrouter);
232 if (!ie->isLoopback())
235 if (ie->isMulticast()) {
Referenced by initialize().
◆ configureInterfaceFromXml()
| void inet::Ipv6RoutingTable::configureInterfaceFromXml |
( |
NetworkInterface * |
ie, |
|
|
cXMLElement * |
cfg |
|
) |
| |
|
protectedvirtual |
313 auto d = ie->getProtocolDataForUpdate<Ipv6InterfaceData>();
316 d->setAdvSendAdvertisements(toBool(getRequiredAttr(cfg,
"AdvSendAdvertisements")));
338 cXMLElementList prefixList = cfg->getElementsByTagName(
"AdvPrefix");
339 for (
auto& elem : prefixList) {
340 cXMLElement *node = elem;
341 Ipv6InterfaceData::AdvPrefix prefix;
347 if (!prefix.prefix.tryParseAddrWithPrefix(node->getNodeValue(), pfxLen))
348 throw cRuntimeError(
"Element <%s> at %s: wrong Ipv6Address/prefix syntax %s",
349 node->getTagName(), node->getSourceLocation(), node->getNodeValue());
351 prefix.prefixLength = pfxLen;
352 prefix.advValidLifetime =
utils::atoul(getRequiredAttr(node,
"AdvValidLifetime"));
353 prefix.advOnLinkFlag = toBool(getRequiredAttr(node,
"AdvOnLinkFlag"));
354 prefix.advPreferredLifetime =
utils::atoul(getRequiredAttr(node,
"AdvPreferredLifetime"));
355 prefix.advAutonomousFlag = toBool(getRequiredAttr(node,
"AdvAutonomousFlag"));
356 d->addAdvPrefix(prefix);
360 cXMLElementList addrList = cfg->getChildrenByTagName(
"inetAddr");
361 for (
auto& elem : addrList) {
362 cXMLElement *node = elem;
363 Ipv6Address address = Ipv6Address(node->getNodeValue());
365 d->assignAddress(address, toBool(getRequiredAttr(node,
"tentative")), SIMTIME_ZERO, SIMTIME_ZERO);
Referenced by parseXmlConfigFile().
◆ configureTunnelFromXml()
| void inet::Ipv6RoutingTable::configureTunnelFromXml |
( |
cXMLElement * |
cfg | ) |
|
|
protectedvirtual |
371 Ipv6Tunneling *tunneling = getModuleFromPar<Ipv6Tunneling>(par(
"ipv6TunnelingModule"),
this);
374 cXMLElementList tunnelList = cfg->getElementsByTagName(
"tunnelEntry");
375 for (
auto& elem : tunnelList) {
376 cXMLElement *node = elem;
378 Ipv6Address entry, exit, trigger;
379 entry.set(getRequiredAttr(node,
"entryPoint"));
380 exit.set(getRequiredAttr(node,
"exitPoint"));
382 cXMLElementList triggerList = node->getElementsByTagName(
"triggers");
384 if (triggerList.size() != 1)
385 throw cRuntimeError(
"element <%s> at %s: Only exactly one trigger allowed",
386 node->getTagName(), node->getSourceLocation());
388 cXMLElement *triggerNode = triggerList[0];
389 trigger.set(getRequiredAttr(triggerNode,
"destination"));
391 EV_INFO <<
"New tunnel: " <<
"entry=" << entry <<
",exit=" << exit <<
",trigger=" << trigger << endl;
Referenced by parseXmlConfigFile().
◆ createNewRoute()
◆ createRoute()
| virtual IRoute* inet::Ipv6RoutingTable::createRoute |
( |
| ) |
|
|
inlineoverridevirtual |
◆ deleteInterfaceRoutes()
| void inet::Ipv6RoutingTable::deleteInterfaceRoutes |
( |
const NetworkInterface * |
entry | ) |
|
|
virtual |
Deletes the routes that are using the specified interface.
836 bool changed =
false;
840 Ipv6Route *route = *it;
841 if (route->getInterface() == entry) {
Referenced by receiveSignal().
◆ deleteMulticastRoute()
| virtual bool inet::Ipv6RoutingTable::deleteMulticastRoute |
( |
IMulticastRoute * |
entry | ) |
|
|
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.
◆ deleteOnLinkPrefix()
| void inet::Ipv6RoutingTable::deleteOnLinkPrefix |
( |
const Ipv6Address & |
destPrefix, |
|
|
int |
prefixLength |
|
) |
| |
|
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.
602 if ((*it)->getSourceType() ==
IRoute::ROUTER_ADVERTISEMENT && (*it)->getDestPrefix() == destPrefix && (*it)->getPrefixLength() == prefixLength) {
◆ deleteRoute() [1/2]
| bool inet::Ipv6RoutingTable::deleteRoute |
( |
Ipv6Route * |
route | ) |
|
|
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.
◆ deleteRoute() [2/2]
| virtual bool inet::Ipv6RoutingTable::deleteRoute |
( |
IRoute * |
entry | ) |
|
|
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.
392 {
return deleteRoute(check_and_cast<Ipv6Route *>(entry)); }
Referenced by deleteRoute().
◆ doLongestPrefixMatch()
Performs longest prefix match in the routing table and returns the resulting route, or nullptr if there was no match.
460 Enter_Method(
"doLongestPrefixMatch(%s)", dest.str().c_str());
467 if (dest.matches((*it)->getDestPrefix(), (*it)->getPrefixLength())) {
468 if (simTime() > (*it)->getExpiryTime() && (*it)->getExpiryTime() != 0) {
470 EV_INFO <<
"Expired prefix detected!!" << endl;
◆ findBestMatchingMulticastRoute()
◆ findBestMatchingRoute()
| virtual IRoute* inet::Ipv6RoutingTable::findBestMatchingRoute |
( |
const L3Address & |
dest | ) |
const |
|
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.
384 {
return const_cast<Ipv6Route *
>((
const_cast<Ipv6RoutingTable *
>(
this))->doLongestPrefixMatch(dest.toIpv6())); }
◆ findInterfaceByLocalBroadcastAddress()
◆ getDefaultRoute()
| virtual IRoute* inet::Ipv6RoutingTable::getDefaultRoute |
( |
| ) |
const |
|
inlineoverridevirtual |
Finds and returns the default route, or nullptr if it doesn't exist.
Implements inet::IRoutingTable.
◆ getInterfaceByAddress() [1/2]
Returns an interface given by its address.
Returns nullptr if not found.
398 Enter_Method(
"getInterfaceByAddress(%s)=?", addr.str().c_str());
400 return ift->findInterfaceByAddress(addr);
Referenced by getInterfaceByAddress().
◆ getInterfaceByAddress() [2/2]
Returns an interface given by its address.
Returns nullptr if not found.
Implements inet::IRoutingTable.
◆ getMulticastRoute()
| virtual IMulticastRoute* inet::Ipv6RoutingTable::getMulticastRoute |
( |
int |
k | ) |
const |
|
inlineoverridevirtual |
◆ getNextHopForDestination()
| virtual L3Address inet::Ipv6RoutingTable::getNextHopForDestination |
( |
const L3Address & |
dest | ) |
const |
|
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.
386 {
const Ipv6Route *
e = (
const_cast<Ipv6RoutingTable *
>(
this))->doLongestPrefixMatch(dest.toIpv6());
return e ?
e->getNextHopAsGeneric() : L3Address(); }
◆ getNumMulticastRoutes()
| virtual int inet::Ipv6RoutingTable::getNumMulticastRoutes |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ getNumRoutes()
| int inet::Ipv6RoutingTable::getNumRoutes |
( |
| ) |
const |
|
overridevirtual |
◆ getOutputInterfaceForDestination()
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.
385 {
const Ipv6Route *
e = (
const_cast<Ipv6RoutingTable *
>(
this))->doLongestPrefixMatch(dest.toIpv6());
return e ?
e->getInterface() :
nullptr; }
◆ getRoute()
| Ipv6Route * inet::Ipv6RoutingTable::getRoute |
( |
int |
i | ) |
const |
|
overridevirtual |
◆ getRouterIdAsGeneric()
| virtual L3Address inet::Ipv6RoutingTable::getRouterIdAsGeneric |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ handleMessage()
| void inet::Ipv6RoutingTable::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Raises an error.
163 throw cRuntimeError(
"This module doesn't process messages");
◆ handleOperationStage()
ILifecycle method.
Implements inet::ILifecycle.
861 int stage = operation->getCurrentStage();
862 if (
dynamic_cast<ModuleStartOperation *
>(operation)) {
866 else if (
dynamic_cast<ModuleStopOperation *
>(operation)) {
872 else if (
dynamic_cast<ModuleCrashOperation *
>(operation)) {
◆ initialize()
| void inet::Ipv6RoutingTable::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
53 cSimpleModule::initialize(stage);
63 ift.reference(
this,
"interfaceTableModule",
true);
65 #ifdef INET_WITH_xMIPv6
70 ismobile_node =
false;
87 for (
int i = 0; i <
ift->getNumInterfaces(); i++) {
88 NetworkInterface *ie =
ift->getInterface(i);
99 for (
int x = 0; x <
ift->getNumInterfaces(); x++) {
100 NetworkInterface *ie =
ift->getInterface(x);
102 if (ie->isLoopback())
105 for (
int y = 0; y < ie->getProtocolData<Ipv6InterfaceData>()->getNumAdvPrefixes(); y++)
106 if (ie->getProtocolData<Ipv6InterfaceData>()->getAdvPrefix(y).prefix.isGlobal())
108 ie->getProtocolData<Ipv6InterfaceData>()->getAdvPrefix(y).prefixLength,
109 ie->getInterfaceId(), SIMTIME_ZERO);
◆ internalAddRoute()
| void inet::Ipv6RoutingTable::internalAddRoute |
( |
Ipv6Route * |
route | ) |
|
|
protected |
690 ASSERT(route->getRoutingTable() ==
nullptr);
693 route->setRoutingTable(
this);
Referenced by addRoute(), and routeChanged().
◆ internalDeleteRoute()
| Ipv6RoutingTable::RouteList::iterator inet::Ipv6RoutingTable::internalDeleteRoute |
( |
RouteList::iterator |
it | ) |
|
|
protected |
◆ internalRemoveRoute()
◆ isAdminDistEnabled()
| virtual bool inet::Ipv6RoutingTable::isAdminDistEnabled |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ isForwardingEnabled()
| virtual bool inet::Ipv6RoutingTable::isForwardingEnabled |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ isLocalAddress() [1/2]
| bool inet::Ipv6RoutingTable::isLocalAddress |
( |
const Ipv6Address & |
dest | ) |
const |
|
virtual |
Checks if the address is one of the host's addresses, i.e.
assigned to one of its interfaces (tentatively or not).
410 Enter_Method(
"isLocalAddress(%s) y/n", dest.str().c_str());
413 if (
ift->isLocalAddress(dest))
429 for (
int i = 0; i <
ift->getNumInterfaces(); i++) {
430 NetworkInterface *ie =
ift->getInterface(i);
431 if (ie->getProtocolData<Ipv6InterfaceData>()->matchesSolicitedNodeMulticastAddress(dest))
◆ isLocalAddress() [2/2]
| virtual bool inet::Ipv6RoutingTable::isLocalAddress |
( |
const L3Address & |
dest | ) |
const |
|
inlineoverridevirtual |
◆ isLocalBroadcastAddress()
| virtual bool inet::Ipv6RoutingTable::isLocalBroadcastAddress |
( |
const L3Address & |
dest | ) |
const |
|
inlinevirtual |
◆ isLocalMulticastAddress()
| virtual bool inet::Ipv6RoutingTable::isLocalMulticastAddress |
( |
const L3Address & |
dest | ) |
const |
|
inlineoverridevirtual |
Checks if the address is in one of the local multicast group address list.
Implements inet::IRoutingTable.
◆ isMulticastForwardingEnabled() [1/2]
| virtual bool inet::Ipv6RoutingTable::isMulticastForwardingEnabled |
( |
| ) |
|
|
inlinevirtual |
◆ isMulticastForwardingEnabled() [2/2]
| virtual bool inet::Ipv6RoutingTable::isMulticastForwardingEnabled |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ isPrefixPresent()
| bool inet::Ipv6RoutingTable::isPrefixPresent |
( |
const Ipv6Address & |
prefix | ) |
const |
|
virtual |
Checks if the given prefix already exists in the routing table (prefix list)
487 if (prefix.matches((elem)->getDestPrefix(), 128))
◆ isRouter()
| virtual bool inet::Ipv6RoutingTable::isRouter |
( |
| ) |
const |
|
inlinevirtual |
◆ lookupDestCache()
| 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.
440 Enter_Method(
"lookupDestCache(%s)", dest.str().c_str());
447 DestCacheEntry& entry = it->second;
448 if (entry.expiryTime > 0 && simTime() > entry.expiryTime) {
454 outInterfaceId = entry.interfaceId;
455 return entry.nextHopAddr;
◆ numInitStages()
| virtual int inet::Ipv6RoutingTable::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ parseXmlConfigFile()
| void inet::Ipv6RoutingTable::parseXmlConfigFile |
( |
| ) |
|
|
protectedvirtual |
121 cXMLElement *config = par(
"routes");
122 for (cXMLElement *child = config->getFirstChild(); child; child = child->getNextSibling()) {
126 if (opp_strcmp(child->getTagName(),
"local") != 0)
129 if (opp_strcmp(child->getAttribute(
"node"), host->getFullName()) != 0)
133 for (cXMLElement *ifTag = child->getFirstChild(); ifTag; ifTag = ifTag->getNextSibling()) {
135 if (opp_strcmp(ifTag->getTagName(),
"interface") == 0) {
137 const char *ifname = ifTag->getAttribute(
"name");
139 throw cRuntimeError(
"<interface> without name attribute at %s", child->getSourceLocation());
141 NetworkInterface *ie =
ift->findInterfaceByName(ifname);
143 throw cRuntimeError(
"no interface named %s was registered, %s", ifname, child->getSourceLocation());
147 else if (opp_strcmp(ifTag->getTagName(),
"tunnel") == 0)
Referenced by initialize().
◆ printRoutingTable()
| void inet::Ipv6RoutingTable::printRoutingTable |
( |
| ) |
const |
|
overridevirtual |
Prints the routing table.
Implements inet::IRoutingTable.
884 EV_INFO << (elem)->getInterface()->getInterfaceFullPath() <<
" -> " << (elem)->getDestinationAsGeneric().str() <<
" as " << (elem)->str() << endl;
◆ purgeDestCache()
| void inet::Ipv6RoutingTable::purgeDestCache |
( |
| ) |
|
|
virtual |
Discard all entries in destination cache.
Referenced by addRoute().
◆ purgeDestCacheEntriesToNeighbour()
| void inet::Ipv6RoutingTable::purgeDestCacheEntriesToNeighbour |
( |
const Ipv6Address & |
nextHopAddr, |
|
|
int |
interfaceId |
|
) |
| |
|
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.
509 if (it->second.interfaceId == interfaceId && it->second.nextHopAddr == nextHopAddr) {
◆ purgeDestCacheForInterfaceId()
| void inet::Ipv6RoutingTable::purgeDestCacheForInterfaceId |
( |
int |
interfaceId | ) |
|
Removes all destination cache entries for the specified interface.
522 if (it->second.interfaceId == interfaceId) {
Referenced by receiveSignal().
◆ receiveSignal()
| void inet::Ipv6RoutingTable::receiveSignal |
( |
cComponent * |
source, |
|
|
simsignal_t |
signalID, |
|
|
cObject * |
obj, |
|
|
cObject * |
details |
|
) |
| |
|
overrideprotectedvirtual |
Called by the signal handler whenever a change of a category occurs to which this client has subscribed.
168 if (getSimulation()->getContextType() == CTX_INITIALIZE)
171 Enter_Method(
"%s", cComponent::getSignalName(signalID));
182 const NetworkInterface *entry = check_and_cast<const NetworkInterface *>(obj);
186 const NetworkInterface *networkInterface = check_and_cast<const NetworkInterfaceChangeDetails *>(obj)->getNetworkInterface();
187 int networkInterfaceId = networkInterface->getInterfaceId();
190 if (!networkInterface->isUp()) {
◆ refreshDisplay()
| void inet::Ipv6RoutingTable::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
155 std::stringstream os;
158 getDisplayString().setTagArg(
"t", 0, os.str().c_str());
◆ removeMulticastRoute()
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.
◆ removeRoute() [1/2]
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().
◆ removeRoute() [2/2]
| virtual IRoute* inet::Ipv6RoutingTable::removeRoute |
( |
IRoute * |
entry | ) |
|
|
inlineoverridevirtual |
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.
391 {
return removeRoute(check_and_cast<Ipv6Route *>(entry)); }
Referenced by removeRoute().
◆ routeChanged()
| void inet::Ipv6RoutingTable::routeChanged |
( |
Ipv6Route * |
entry, |
|
|
int |
fieldCode |
|
) |
| |
|
virtual |
To be called from route objects whenever a field changes.
Used for maintaining internal data structures and firing "routing table changed" notifications.
207 ASSERT(entry !=
nullptr);
Referenced by inet::Ipv6Route::changed().
◆ routeLessThan()
| bool inet::Ipv6RoutingTable::routeLessThan |
( |
const Ipv6Route * |
a, |
|
|
const Ipv6Route * |
b |
|
) |
| const |
|
protected |
655 if (a->getPrefixLength() !=
b->getPrefixLength())
656 return a->getPrefixLength() >
b->getPrefixLength();
659 if (
useAdminDist && (a->getAdminDist() !=
b->getAdminDist()))
660 return a->getAdminDist() <
b->getAdminDist();
663 return a->getMetric() <
b->getMetric();
◆ updateDestCache()
| void inet::Ipv6RoutingTable::updateDestCache |
( |
const Ipv6Address & |
dest, |
|
|
const Ipv6Address & |
nextHopAddr, |
|
|
int |
interfaceId, |
|
|
simtime_t |
expiryTime |
|
) |
| |
|
virtual |
Add or update a destination cache entry.
496 entry.nextHopAddr = nextHopAddr;
497 entry.interfaceId = interfaceId;
498 entry.expiryTime = expiryTime;
◆ operator<<
| std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const DestCacheEntry & |
e |
|
) |
| |
|
friend |
32 os <<
"if=" <<
e.interfaceId <<
" " <<
e.nextHopAddr;
◆ destCache
◆ ift
◆ isrouter
| bool inet::Ipv6RoutingTable::isrouter = false |
|
protected |
◆ multicastForward
| bool inet::Ipv6RoutingTable::multicastForward = false |
|
protected |
◆ routeList
Referenced by addOrUpdateOnLinkPrefix(), addOrUpdateOwnAdvPrefix(), deleteInterfaceRoutes(), deleteOnLinkPrefix(), deleteRoute(), doLongestPrefixMatch(), getNumRoutes(), getRoute(), handleOperationStage(), initialize(), internalAddRoute(), internalDeleteRoute(), internalRemoveRoute(), isPrefixPresent(), printRoutingTable(), and ~Ipv6RoutingTable().
◆ useAdminDist
| bool inet::Ipv6RoutingTable::useAdminDist = false |
|
protected |
The documentation for this class was generated from the following files:
INET_API InitStage INITSTAGE_NETWORK_CONFIGURATION
Initialization of network configuration (e.g.
Stage
Definition: ModuleOperations.h:75
virtual void addRoutingProtocolRoute(Ipv6Route *route)
Adds the given getRoute(which can be OSPF, BGP, RIP or any other route) with src==ROUTING_PROT.
Definition: Ipv6RoutingTable.cc:644
static const Ipv6Address ALL_ROUTERS_2
All-routers multicast address, scope 2 (link-local)
Definition: Ipv6Address.h:69
virtual void deleteInterfaceRoutes(const NetworkInterface *entry)
Deletes the routes that are using the specified interface.
Definition: Ipv6RoutingTable.cc:834
virtual Ipv6Route * createNewRoute(Ipv6Address destPrefix, int prefixLength, IRoute::SourceType src)
Definition: Ipv6RoutingTable.cc:46
@ dStatic
Definition: Ipv6Route.h:31
@ F_DESTINATION
Definition: IRoute.h:47
Ipv6RoutingTable()
Definition: Ipv6RoutingTable.cc:36
void purgeDestCacheForInterfaceId(int interfaceId)
Removes all destination cache entries for the specified interface.
Definition: Ipv6RoutingTable.cc:519
void internalAddRoute(Ipv6Route *route)
Definition: Ipv6RoutingTable.cc:688
@ STAGE_NETWORK_LAYER
Definition: ModuleOperations.h:53
@ MANUAL
manually added static route
Definition: IRoute.h:29
@ dDirectlyConnected
Definition: Ipv6Route.h:30
virtual bool deleteRoute(Ipv6Route *route)
Deletes the given route from the route table.
Definition: Ipv6RoutingTable.cc:723
@ ROUTER_ADVERTISEMENT
on-link prefix, from Router Advertisement
Definition: IRoute.h:31
bool isrouter
Definition: Ipv6RoutingTable.h:45
static const Ipv6Address ALL_NODES_2
All-nodes multicast address, scope 2 (link-local)
Definition: Ipv6Address.h:63
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:40
@ STAGE_NETWORK_LAYER
Definition: ModuleOperations.h:29
simsignal_t routeChangedSignal
Definition: Simsignals.cc:43
const value< double, units::C > e(1.602176487e-19)
void printSignalBanner(simsignal_t signalID, const cObject *obj, const cObject *details)
Utility function.
Definition: Simsignals.cc:126
Stage
Definition: ModuleOperations.h:25
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
virtual void configureInterfaceForIpv6(NetworkInterface *ie)
Definition: Ipv6RoutingTable.cc:215
static const Ipv6Address ALL_ROUTERS_1
All-routers multicast address, scope 1 (interface-local)
Definition: Ipv6Address.h:66
static const Ipv6Address ALL_ROUTERS_5
All-routers multicast address, scope 5 (site-local)
Definition: Ipv6Address.h:72
static const Ipv6Address ALL_NODES_1
All-nodes multicast address, scope 1 (interface-local)
Definition: Ipv6Address.h:60
ModuleRefByPar< IInterfaceTable > ift
Definition: Ipv6RoutingTable.h:43
@ OWN_ADV_PREFIX
on routers: on-link prefix that the router itself advertises on the link
Definition: IRoute.h:32
virtual void assignRequiredNodeAddresses(NetworkInterface *ie)
RFC 3513: Section 2.8 A Node's Required Address Assign the various addresses to the node's respective...
Definition: Ipv6RoutingTable.cc:243
simsignal_t interfaceDeletedSignal
Definition: Simsignals.cc:31
static const Ipv6Address LINKLOCAL_PREFIX
The link-local prefix (fe80::)
Definition: Ipv6Address.h:78
static const Ipv6Address UNSPECIFIED_ADDRESS
The unspecified address.
Definition: Ipv6Address.h:54
virtual void addOrUpdateOwnAdvPrefix(const Ipv6Address &destPrefix, int prefixLength, int interfaceId, simtime_t expiryTime)
Add route of type OWN_ADV_PREFIX.
Definition: Ipv6RoutingTable.cc:564
RouteList routeList
Definition: Ipv6RoutingTable.h:70
Stage
Definition: ModuleOperations.h:48
simsignal_t interfaceStateChangedSignal
Definition: Simsignals.cc:32
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
DestCache destCache
Definition: Ipv6RoutingTable.h:65
unsigned long atoul(const char *s)
Converts string to unsigned long.
Definition: INETUtils.cc:89
value< int64_t, units::b > b
Definition: Units.h:1241
simsignal_t routeAddedSignal
Definition: Simsignals.cc:41
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
virtual NetworkInterface * getInterfaceByAddress(const Ipv6Address &address) const
Returns an interface given by its address.
Definition: Ipv6RoutingTable.cc:396
virtual void parseXmlConfigFile()
Definition: Ipv6RoutingTable.cc:116
virtual int getNumRoutes() const override
Return the number of routes.
Definition: Ipv6RoutingTable.cc:733
virtual Ipv6Route * removeRoute(Ipv6Route *route)
Removes the given route from the routing table, and returns it.
Definition: Ipv6RoutingTable.cc:677
@ STAGE_CRASH
Definition: ModuleOperations.h:76
virtual void configureTunnelFromXml(cXMLElement *cfg)
Definition: Ipv6RoutingTable.cc:369
virtual bool isLocalAddress(const Ipv6Address &dest) const
Checks if the address is one of the host's addresses, i.e.
Definition: Ipv6RoutingTable.cc:408
virtual bool isRouter() const
IP forwarding on/off.
Definition: Ipv6RoutingTable.h:145
RouteList::iterator internalDeleteRoute(RouteList::iterator it)
Definition: Ipv6RoutingTable.cc:712
#define Enter_Method(...)
Definition: SelfDoc.h:71
simsignal_t routeDeletedSignal
Definition: Simsignals.cc:42
@ NORMAL
Definition: Ipv6Tunneling.h:44
virtual void addRoute(Ipv6Route *route)
Definition: Ipv6RoutingTable.cc:666
Ipv6Route * internalRemoveRoute(Ipv6Route *route)
Definition: Ipv6RoutingTable.cc:700
bool useAdminDist
Definition: Ipv6RoutingTable.h:47
@ F_PREFIX_LENGTH
Definition: IRoute.h:48
virtual void configureInterfaceFromXml(NetworkInterface *ie, cXMLElement *cfg)
Definition: Ipv6RoutingTable.cc:306
static const Ipv6Address ALL_OSPF_ROUTERS_MCAST
OSPF multicast address for listening.
Definition: Ipv6Address.h:84
simsignal_t interfaceCreatedSignal
Definition: Simsignals.cc:30
virtual void addStaticRoute(const Ipv6Address &destPrefix, int prefixLength, unsigned int interfaceId, const Ipv6Address &nextHop, int metric=0)
Creates a static route.
Definition: Ipv6RoutingTable.cc:609
@ F_METRIC
Definition: IRoute.h:54
simsignal_t interfaceConfigChangedSignal
Definition: Simsignals.cc:33
static const Ipv6Address SOLICITED_NODE_PREFIX
The solicited-node multicast address prefix (prefix length = 104)
Definition: Ipv6Address.h:75
virtual void purgeDestCache()
Discard all entries in destination cache.
Definition: Ipv6RoutingTable.cc:501
bool multicastForward
Definition: Ipv6RoutingTable.h:46
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
static const Ipv6Address ALL_OSPF_DESIGNATED_ROUTERS_MCAST
OSPF designated routers.
Definition: Ipv6Address.h:87
simsignal_t interfaceIpv6ConfigChangedSignal
Definition: Simsignals.cc:36