INET Framework for OMNeT++/OMNEST
|
Represents the routing table. More...
#include <IPv4RoutingTable.h>
Classes | |
class | RouteLessThan |
Public Member Functions | |
IPv4RoutingTable () | |
virtual | ~IPv4RoutingTable () |
virtual void | printRoutingTable () const override |
For debugging. More... | |
virtual void | printMulticastRoutingTable () const override |
For debugging. More... | |
virtual cModule * | getHostModule () override |
Returns the host or router this routing table lives in. More... | |
virtual bool | isForwardingEnabled () const override |
IPv4 forwarding on/off. More... | |
virtual bool | isMulticastForwardingEnabled () const override |
IPv4 multicast forwarding on/off. More... | |
virtual IPv4Address | getRouterId () const override |
Returns routerId. More... | |
virtual void | setRouterId (IPv4Address a) override |
Sets routerId. More... | |
virtual bool | handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override |
ILifecycle method. 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 InterfaceEntry * | getInterfaceByAddress (const L3Address &address) const override |
Returns an interface given by its address. More... | |
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 * | createRoute () override |
Interfaces | |
virtual void | configureInterfaceForIPv4 (InterfaceEntry *ie) override |
virtual InterfaceEntry * | getInterfaceByAddress (const IPv4Address &address) const override |
Returns an interface given by its address. More... | |
Routing functions (query the route table) | |
virtual bool | isLocalAddress (const IPv4Address &dest) const override |
Checks if the address is a local one, i.e. More... | |
virtual bool | isLocalBroadcastAddress (const IPv4Address &dest) const override |
Checks if the address is a local network broadcast address, i.e. More... | |
virtual InterfaceEntry * | findInterfaceByLocalBroadcastAddress (const IPv4Address &dest) const override |
Returns the interface entry having the specified address as its local broadcast address. More... | |
virtual IPv4Route * | findBestMatchingRoute (const IPv4Address &dest) const override |
The routing function. More... | |
virtual InterfaceEntry * | getInterfaceForDestAddr (const IPv4Address &dest) const override |
Convenience function based on findBestMatchingRoute(). More... | |
virtual IPv4Address | getGatewayForDestAddr (const IPv4Address &dest) const override |
Convenience function based on findBestMatchingRoute(). More... | |
Multicast routing functions | |
virtual bool | isLocalMulticastAddress (const IPv4Address &dest) const override |
Checks if the address is in one of the local multicast group address list. More... | |
virtual const IPv4MulticastRoute * | findBestMatchingMulticastRoute (const IPv4Address &origin, const IPv4Address &group) const override |
Returns route for a multicast source and multicast group. More... | |
Route table manipulation | |
virtual int | getNumRoutes () const override |
Returns the total number of routes (unicast, multicast, plus the default route). More... | |
virtual IPv4Route * | getRoute (int k) const override |
Returns the kth route. More... | |
virtual IPv4Route * | getDefaultRoute () const override |
Finds and returns the default route, or nullptr if it doesn't exist. More... | |
virtual void | addRoute (IPv4Route *entry) override |
Adds a route to the routing table. More... | |
virtual IPv4Route * | removeRoute (IPv4Route *entry) override |
Removes the given route from the routing table, and returns it. More... | |
virtual bool | deleteRoute (IPv4Route *entry) override |
Removes the given route from the routing table, and delete it. More... | |
virtual int | getNumMulticastRoutes () const override |
Returns the total number of multicast routes. More... | |
virtual IPv4MulticastRoute * | getMulticastRoute (int k) const override |
Returns the kth multicast route. More... | |
virtual void | addMulticastRoute (IPv4MulticastRoute *entry) override |
Adds a multicast route to the routing table. More... | |
virtual IPv4MulticastRoute * | removeMulticastRoute (IPv4MulticastRoute *entry) override |
Removes the given route from the routing table, and returns it. More... | |
virtual bool | deleteMulticastRoute (IPv4MulticastRoute *entry) override |
Deletes the given multicast route from the routing table. More... | |
virtual void | purge () override |
Deletes invalid routes from the routing table. More... | |
virtual std::vector< IPv4Address > | gatherAddresses () const override |
Utility function: Returns a vector of all addresses of the node. More... | |
virtual void | routeChanged (IPv4Route *entry, int fieldCode) override |
To be called from route objects whenever a field changes. More... | |
virtual void | multicastRouteChanged (IPv4MulticastRoute *entry, int fieldCode) override |
To be called from multicast route objects whenever a field changes. More... | |
Public Member Functions inherited from inet::IIPv4RoutingTable | |
virtual | ~IIPv4RoutingTable () |
Public Member Functions inherited from inet::IRoutingTable | |
virtual | ~IRoutingTable () |
Public Member Functions inherited from inet::ILifecycle | |
virtual | ~ILifecycle () |
Protected Types | |
typedef IPv4MulticastRoute::OutInterface | OutInterface |
typedef IPv4MulticastRoute::OutInterfaceVector | OutInterfaceVector |
typedef std::map< IPv4Address, IPv4Route * > | RoutingCache |
typedef std::set< IPv4Address > | AddressSet |
Protected Member Functions | |
virtual void | configureLoopbackForIPv4 () |
virtual void | configureRouterId () |
virtual void | updateNetmaskRoutes () |
virtual IPv4Route * | createNewRoute () |
virtual void | refreshDisplay () const override |
virtual void | deleteInterfaceRoutes (const InterfaceEntry *entry) |
virtual void | invalidateCache () |
bool | routeLessThan (const IPv4Route *a, const IPv4Route *b) const |
void | internalAddRoute (IPv4Route *entry) |
IPv4Route * | internalRemoveRoute (IPv4Route *entry) |
void | internalAddMulticastRoute (IPv4MulticastRoute *entry) |
IPv4MulticastRoute * | internalRemoveMulticastRoute (IPv4MulticastRoute *entry) |
virtual int | numInitStages () const override |
virtual void | initialize (int stage) override |
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... | |
Static Protected Member Functions | |
static bool | multicastRouteLessThan (const IPv4MulticastRoute *a, const IPv4MulticastRoute *b) |
Protected Attributes | |
IInterfaceTable * | ift = nullptr |
IPv4Address | routerId |
const char * | netmaskRoutes = nullptr |
bool | forwarding = false |
bool | multicastForward = false |
bool | isNodeUp = false |
bool | useAdminDist = false |
RoutingCache | routingCache |
AddressSet | localAddresses |
AddressSet | localBroadcastAddresses |
Private Types | |
typedef std::vector< IPv4Route * > | RouteVector |
typedef std::vector< IPv4MulticastRoute * > | MulticastRouteVector |
Private Member Functions | |
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 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... | |
Private Attributes | |
RouteVector | routes |
MulticastRouteVector | multicastRoutes |
Represents the routing table.
This object has one instance per host or router. It has methods to manage the route table and the interface table, so one can achieve functionality similar to the "route" and "ifconfig" commands.
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.
Interfaces are dynamically registered: at the start of the simulation, every L2 module adds its own interface entry to the table.
The route table is read from a file (RoutingTableParser); the file can also fill in or overwrite interface settings. The route table can also be read and modified during simulation, typically by routing protocol implementations (e.g. OSPF).
Entries in the route table are represented by IPv4Route objects. IPv4Route objects can be polymorphic: if a routing protocol needs to store additional data, it can simply subclass from IPv4Route, and add the derived object to the table.
Uses RoutingTableParser to read routing files (.irt, .mrt).
|
protected |
|
private |
|
protected |
|
private |
|
protected |
|
virtual |
|
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::IIPv4RoutingTable.
|
inlineoverrideprivatevirtual |
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.
Referenced by addMulticastRoute().
|
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::IIPv4RoutingTable.
|
inlineoverrideprivatevirtual |
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.
Referenced by addRoute().
|
overridevirtual |
Implements inet::IIPv4RoutingTable.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
inlineoverridevirtual |
Implements inet::IRoutingTable.
|
protectedvirtual |
|
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::IIPv4RoutingTable.
|
inlineoverrideprivatevirtual |
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.
Referenced by deleteMulticastRoute().
|
overridevirtual |
Removes the given route from the routing table, and delete it.
Returns true if the route was deleted, and false if it was not in the routing table.
Implements inet::IIPv4RoutingTable.
|
inlineoverrideprivatevirtual |
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().
|
overridevirtual |
Returns route for a multicast source and multicast group.
Implements inet::IIPv4RoutingTable.
|
inlineoverridevirtual |
Returns route for a multicast origin and group.
Implements inet::IRoutingTable.
Referenced by findBestMatchingMulticastRoute().
|
overridevirtual |
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::IIPv4RoutingTable.
|
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.
Referenced by findBestMatchingRoute().
|
overridevirtual |
Returns the interface entry having the specified address as its local broadcast address.
Implements inet::IIPv4RoutingTable.
|
overridevirtual |
Utility function: Returns a vector of all addresses of the node.
Implements inet::IIPv4RoutingTable.
|
overridevirtual |
Finds and returns the default route, or nullptr if it doesn't exist.
Implements inet::IIPv4RoutingTable.
|
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::IIPv4RoutingTable.
|
overridevirtual |
Returns the host or router this routing table lives in.
Implements inet::IIPv4RoutingTable.
|
overridevirtual |
Returns an interface given by its address.
Returns nullptr if not found.
Implements inet::IIPv4RoutingTable.
|
inlineoverridevirtual |
Returns an interface given by its address.
Returns nullptr if not found.
Implements inet::IRoutingTable.
Referenced by getInterfaceByAddress().
|
overridevirtual |
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::IIPv4RoutingTable.
|
inlineoverridevirtual |
Returns the kth multicast route.
Implements inet::IIPv4RoutingTable.
|
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.
|
inlineoverridevirtual |
Returns the total number of routes (unicast, multicast, plus the default route).
Implements inet::IRoutingTable.
|
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 |
|
inlineoverridevirtual |
Returns routerId.
Implements inet::IRoutingTable.
|
overrideprotectedvirtual |
|
overridevirtual |
ILifecycle method.
Implements inet::ILifecycle.
|
overrideprotectedvirtual |
|
protected |
|
protected |
|
protected |
|
protectedvirtual |
|
inlineoverridevirtual |
|
overridevirtual |
Checks if the address is a local one, i.e.
one of the host's.
Implements inet::IIPv4RoutingTable.
|
inlineoverridevirtual |
Checks if the address is a local one, i.e.
one of the host's.
Implements inet::IRoutingTable.
Referenced by isLocalAddress().
|
overridevirtual |
Checks if the address is a local network broadcast address, i.e.
one of the broadcast addresses derived from the interface addresses and netmasks.
Implements inet::IIPv4RoutingTable.
|
overridevirtual |
Checks if the address is in one of the local multicast group address list.
Implements inet::IIPv4RoutingTable.
|
inlineoverridevirtual |
Checks if the address is in one of the local multicast group address list.
Implements inet::IRoutingTable.
Referenced by isLocalMulticastAddress().
|
inlineoverridevirtual |
|
overridevirtual |
To be called from multicast route objects whenever a field changes.
Used for maintaining internal data structures and firing "routing table changed" notifications.
Implements inet::IIPv4RoutingTable.
|
staticprotected |
|
inlineoverrideprotectedvirtual |
|
overridevirtual |
For debugging.
Implements inet::IIPv4RoutingTable.
|
overridevirtual |
For debugging.
Implements inet::IRoutingTable.
|
overridevirtual |
Deletes invalid routes from the routing table.
Invalid routes are those where the isValid() method returns false.
Implements inet::IIPv4RoutingTable.
|
overrideprotectedvirtual |
Called by the signal handler whenever a change of a category occurs to which this client has subscribed.
|
overrideprotectedvirtual |
|
overridevirtual |
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::IIPv4RoutingTable.
|
inlineoverrideprivatevirtual |
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.
Referenced by 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::IIPv4RoutingTable.
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().
|
overridevirtual |
To be called from route objects whenever a field changes.
Used for maintaining internal data structures and firing "routing table changed" notifications.
Implements inet::IIPv4RoutingTable.
|
protected |
Referenced by inet::IPv4RoutingTable::RouteLessThan::operator()().
|
overridevirtual |
|
protectedvirtual |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
protected |
|
private |
|
protected |
|
protected |
|
private |
|
mutableprotected |
|
protected |