|
INET Framework for OMNeT++/OMNEST
|
A C++ interface to abstract the functionality of a routing table, regardless of address type.
More...
#include <NextHopRoutingTable.h>
A C++ interface to abstract the functionality of a routing table, regardless of address type.
◆ MulticastRouteVector
◆ RouteVector
◆ NextHopRoutingTable()
| inet::NextHopRoutingTable::NextHopRoutingTable |
( |
| ) |
|
◆ ~NextHopRoutingTable()
| inet::NextHopRoutingTable::~NextHopRoutingTable |
( |
| ) |
|
|
virtual |
◆ addMulticastRoute()
| void inet::NextHopRoutingTable::addMulticastRoute |
( |
IMulticastRoute * |
entry | ) |
|
|
overridevirtual |
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.
◆ addRoute()
| void inet::NextHopRoutingTable::addRoute |
( |
IRoute * |
entry | ) |
|
|
overridevirtual |
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.
318 NextHopRoute *entry = check_and_cast<NextHopRoute *>(route);
321 if (!entry->getInterface())
322 throw cRuntimeError(
"addRoute(): interface cannot be nullptr");
Referenced by inet::NextHopNetworkConfigurator::addStaticRoutes().
◆ configureInterface()
167 int metric = (int)(ceil(2e9 / ie->getDatarate()));
168 int interfaceModuleId = ie->getId();
170 auto d = ie->addProtocolData<NextHopInterfaceData>();
171 d->setMetric(metric);
173 d->setAddress(ie->getMacAddress());
175 d->setAddress(ModulePathAddress(interfaceModuleId));
177 d->setAddress(ModuleIdAddress(interfaceModuleId));
Referenced by initialize().
◆ configureLoopback()
| void inet::NextHopRoutingTable::configureLoopback |
( |
| ) |
|
|
protectedvirtual |
◆ configureRouterId()
| void inet::NextHopRoutingTable::configureRouterId |
( |
| ) |
|
|
protectedvirtual |
140 const char *routerIdStr = par(
"routerId");
141 if (!strcmp(routerIdStr,
"auto")) {
143 for (
int i = 0; i <
ift->getNumInterfaces(); ++i) {
144 NetworkInterface *ie =
ift->getInterface(i);
145 if (!ie->isLoopback()) {
146 L3Address interfaceAddr = ie->getProtocolData<NextHopInterfaceData>()->getAddress();
Referenced by initialize().
◆ createRoute()
| IRoute * inet::NextHopRoutingTable::createRoute |
( |
| ) |
|
|
overridevirtual |
◆ deleteMulticastRoute()
| bool inet::NextHopRoutingTable::deleteMulticastRoute |
( |
IMulticastRoute * |
entry | ) |
|
|
overridevirtual |
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.
◆ deleteRoute()
| bool inet::NextHopRoutingTable::deleteRoute |
( |
IRoute * |
entry | ) |
|
|
overridevirtual |
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.
348 if (entry !=
nullptr) {
349 EV_INFO <<
"remove route " << entry->str() <<
"\n";
353 return entry !=
nullptr;
◆ findBestMatchingMulticastRoute()
Returns route for a multicast origin and group.
Implements inet::IRoutingTable.
289 Enter_Method(
"findBestMatchingMulticastRoute(%s, %s)", origin.str().c_str(), group.str().c_str());
◆ findBestMatchingRoute()
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.
249 Enter_Method(
"findBestMatchingRoute(%s)", dest.str().c_str());
253 NextHopRoute *bestRoute =
nullptr;
256 if (dest.matches(
e->getDestinationAsGeneric(),
e->getPrefixLength())) {
257 bestRoute =
const_cast<NextHopRoute *
>(
e);
Referenced by getNextHopForDestination(), and getOutputInterfaceForDestination().
◆ getDefaultRoute()
| IRoute * inet::NextHopRoutingTable::getDefaultRoute |
( |
| ) |
const |
|
overridevirtual |
Finds and returns the default route, or nullptr if it doesn't exist.
Implements inet::IRoutingTable.
309 if (i !=
routes.rend() && (*i)->getPrefixLength() == 0)
◆ getInterfaceByAddress()
Returns an interface given by its address.
Returns nullptr if not found.
Implements inet::IRoutingTable.
242 Enter_Method(
"getInterfaceByAddress(%s)", address.str().c_str());
244 return ift->findInterfaceByAddress(address);
◆ getMulticastRoute()
| IMulticastRoute * inet::NextHopRoutingTable::getMulticastRoute |
( |
int |
k | ) |
const |
|
overridevirtual |
◆ getNextHopForDestination()
| L3Address inet::NextHopRoutingTable::getNextHopForDestination |
( |
const L3Address & |
dest | ) |
const |
|
overridevirtual |
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.
274 Enter_Method(
"getGatewayForDestAddr(%s)", dest.str().c_str());
277 return e ?
e->getNextHopAsGeneric() : L3Address();
◆ getNumMulticastRoutes()
| int inet::NextHopRoutingTable::getNumMulticastRoutes |
( |
| ) |
const |
|
overridevirtual |
◆ getNumRoutes()
| int inet::NextHopRoutingTable::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.
266 Enter_Method(
"getInterfaceForDestAddr(%s)", dest.str().c_str());
269 return e ?
e->getInterface() :
nullptr;
◆ getRoute()
| IRoute * inet::NextHopRoutingTable::getRoute |
( |
int |
k | ) |
const |
|
overridevirtual |
◆ getRouterIdAsGeneric()
| L3Address inet::NextHopRoutingTable::getRouterIdAsGeneric |
( |
| ) |
const |
|
overridevirtual |
◆ handleMessage()
| void inet::NextHopRoutingTable::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Raises an error.
115 throw cRuntimeError(
"This module doesn't process messages");
◆ initialize()
| void inet::NextHopRoutingTable::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
50 cSimpleModule::initialize(stage);
54 ift.reference(
this,
"interfaceTableModule",
true);
56 const char *addressTypeString = par(
"addressType");
57 if (!strcmp(addressTypeString,
"mac"))
59 else if (!strcmp(addressTypeString,
"modulepath"))
61 else if (!strcmp(addressTypeString,
"moduleid"))
64 throw cRuntimeError(
"Unknown address type");
85 IInterfaceTable *interfaceTable = getModuleFromPar<IInterfaceTable>(par(
"interfaceTableModule"),
this);
86 for (
int i = 0; i < interfaceTable->getNumInterfaces(); ++i)
◆ internalAddRoute()
| void inet::NextHopRoutingTable::internalAddRoute |
( |
NextHopRoute * |
route | ) |
|
|
protected |
358 ASSERT(route->getRoutingTableAsGeneric() ==
nullptr);
363 routes.insert(pos, route);
365 route->setRoutingTable(
this);
Referenced by addRoute(), and routeChanged().
◆ internalRemoveRoute()
◆ isAdminDistEnabled()
| virtual bool inet::NextHopRoutingTable::isAdminDistEnabled |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ isForwardingEnabled()
| bool inet::NextHopRoutingTable::isForwardingEnabled |
( |
| ) |
const |
|
overridevirtual |
◆ isLocalAddress()
| bool inet::NextHopRoutingTable::isLocalAddress |
( |
const L3Address & |
dest | ) |
const |
|
overridevirtual |
Checks if the address is a local one, i.e.
one of the host's.
Implements inet::IRoutingTable.
237 return ift->isLocalAddress(dest);
◆ isLocalMulticastAddress()
| bool inet::NextHopRoutingTable::isLocalMulticastAddress |
( |
const L3Address & |
dest | ) |
const |
|
overridevirtual |
Checks if the address is in one of the local multicast group address list.
Implements inet::IRoutingTable.
282 Enter_Method(
"isLocalMulticastAddress(%s)", dest.str().c_str());
284 return dest.isMulticast();
◆ isMulticastForwardingEnabled()
| bool inet::NextHopRoutingTable::isMulticastForwardingEnabled |
( |
| ) |
const |
|
overridevirtual |
◆ numInitStages()
| virtual int inet::NextHopRoutingTable::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ printRoutingTable()
| void inet::NextHopRoutingTable::printRoutingTable |
( |
| ) |
const |
|
overridevirtual |
Prints routing table.
Implements inet::IRoutingTable.
417 for (
const auto& elem :
routes)
418 EV_INFO << (elem)->getInterface()->getInterfaceFullPath() <<
" -> " << (elem)->getDestinationAsGeneric().str() <<
" as " << (elem)->str() << endl;
◆ receiveSignal()
| void inet::NextHopRoutingTable::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.
120 Enter_Method(
"%s", cComponent::getSignalName(signalID));
◆ refreshDisplay()
| void inet::NextHopRoutingTable::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
◆ 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()
| IRoute * inet::NextHopRoutingTable::removeRoute |
( |
IRoute * |
entry | ) |
|
|
overridevirtual |
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.
334 if (entry !=
nullptr) {
335 EV_INFO <<
"remove route " << entry->str() <<
"\n";
337 entry->setRoutingTable(
nullptr);
◆ routeChanged()
| void inet::NextHopRoutingTable::routeChanged |
( |
NextHopRoute * |
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.
129 ASSERT(entry !=
nullptr);
Referenced by inet::NextHopRoute::changed().
◆ routeLessThan()
209 if (a->getPrefixLength() !=
b->getPrefixLength())
210 return a->getPrefixLength() >
b->getPrefixLength();
212 if (a->getDestinationAsGeneric() !=
b->getDestinationAsGeneric())
213 return a->getDestinationAsGeneric() <
b->getDestinationAsGeneric();
215 return a->getMetric() <
b->getMetric();
Referenced by internalAddRoute().
◆ addressType
◆ forwarding
| bool inet::NextHopRoutingTable::forwarding = false |
|
private |
◆ ift
◆ multicastForwarding
| bool inet::NextHopRoutingTable::multicastForwarding = false |
|
private |
◆ multicastRoutes
◆ routerId
| L3Address inet::NextHopRoutingTable::routerId |
|
private |
◆ routes
The documentation for this class was generated from the following files:
static bool routeLessThan(const NextHopRoute *a, const NextHopRoute *b)
Definition: NextHopRoutingTable.cc:204
ModuleRefByPar< IInterfaceTable > ift
Definition: NextHopRoutingTable.h:27
@ MODULEID
Definition: L3Address.h:40
@ F_DESTINATION
Definition: IRoute.h:47
MulticastRouteVector multicastRoutes
Definition: NextHopRoutingTable.h:38
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:40
simsignal_t routeChangedSignal
Definition: Simsignals.cc:43
const value< double, units::C > e(1.602176487e-19)
virtual NextHopRoute * findBestMatchingRoute(const L3Address &dest) const override
The routing function.
Definition: NextHopRoutingTable.cc:247
INET_API InitStage INITSTAGE_NETWORK_LAYER
Initialization of network layer protocols.
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
bool multicastForwarding
Definition: NextHopRoutingTable.h:32
@ MODULEPATH
Definition: L3Address.h:39
bool isUnspecified() const
Definition: L3Address.cc:138
L3Address::AddressType addressType
Definition: NextHopRoutingTable.h:30
virtual void configureInterface(NetworkInterface *ie)
Definition: NextHopRoutingTable.cc:165
void internalAddRoute(NextHopRoute *route)
Definition: NextHopRoutingTable.cc:356
simsignal_t interfaceDeletedSignal
Definition: Simsignals.cc:31
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:
value< int64_t, units::b > b
Definition: Units.h:1241
simsignal_t routeAddedSignal
Definition: Simsignals.cc:41
RouteVector routes
Definition: NextHopRoutingTable.h:35
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
const double k
Definition: Qam1024Modulation.cc:14
virtual void configureLoopback()
Definition: NextHopRoutingTable.cc:180
#define Enter_Method(...)
Definition: SelfDoc.h:71
simsignal_t routeDeletedSignal
Definition: Simsignals.cc:42
@ MAC
Definition: L3Address.h:38
simsignal_t interfaceIpv4ConfigChangedSignal
Definition: Simsignals.cc:35
L3Address routerId
Definition: NextHopRoutingTable.h:29
@ F_PREFIX_LENGTH
Definition: IRoute.h:48
virtual void configureRouterId()
Definition: NextHopRoutingTable.cc:137
NextHopRoute * internalRemoveRoute(NextHopRoute *route)
Definition: NextHopRoutingTable.cc:368
simsignal_t interfaceCreatedSignal
Definition: Simsignals.cc:30
@ F_METRIC
Definition: IRoute.h:54
bool forwarding
Definition: NextHopRoutingTable.h:31
simsignal_t interfaceConfigChangedSignal
Definition: Simsignals.cc:33
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.