INET Framework for OMNeT++/OMNEST
inet::Ipv4Route Class Reference

Ipv4 unicast route in IIpv4RoutingTable. More...

#include <Ipv4Route.h>

Inheritance diagram for inet::Ipv4Route:
inet::IRoute inet::bgp::BgpRoutingTableEntry inet::DsdvIpv4Route inet::ospfv2::Ospfv2RoutingTableEntry inet::ospfv3::Ospfv3Ipv4RoutingTableEntry

Public Member Functions

 Ipv4Route ()
 
virtual ~Ipv4Route ()
 
virtual std::string str () const override
 
virtual std::string detailedInfo () const
 
bool operator== (const Ipv4Route &route) const
 
bool operator!= (const Ipv4Route &route) const
 
bool equals (const Ipv4Route &route) const
 
virtual void setRoutingTable (IIpv4RoutingTable *rt)
 To be called by the routing table when this route is added or removed from it. More...
 
IIpv4RoutingTablegetRoutingTable () const
 
virtual bool isValid () const
 test validity of route entry, e.g. More...
 
virtual void setDestination (Ipv4Address _dest)
 
virtual void setNetmask (Ipv4Address _netmask)
 
virtual void setGateway (Ipv4Address _gateway)
 
virtual void setInterface (NetworkInterface *_interfacePtr) override
 
virtual void setSourceType (SourceType _source) override
 
const char * getSourceTypeAbbreviation () const
 
virtual void setAdminDist (unsigned int _adminDist) override
 
virtual void setMetric (int _metric) override
 
const Ipv4AddressgetDestination () const
 Destination address prefix to match. More...
 
const Ipv4AddressgetNetmask () const
 Represents length of prefix to match. More...
 
const Ipv4AddressgetGateway () const
 Next hop address. More...
 
NetworkInterfacegetInterface () const override
 Next hop interface. More...
 
const char * getInterfaceName () const
 Convenience method. More...
 
SourceType getSourceType () const override
 Source of route. More...
 
unsigned int getAdminDist () const
 Route source specific preference value. More...
 
int getMetric () const override
 "Cost" to reach the destination More...
 
void setSource (cObject *_source) override
 
cObject * getSource () const override
 Source of route. More...
 
cObject * getProtocolData () const override
 
void setProtocolData (cObject *protocolData) override
 
virtual IRoutingTablegetRoutingTableAsGeneric () const override
 The routing table in which this route is inserted, or nullptr. More...
 
virtual void setDestination (const L3Address &dest) override
 
virtual void setPrefixLength (int len) override
 
virtual void setNextHop (const L3Address &nextHop) override
 
virtual L3Address getDestinationAsGeneric () const override
 Destination address prefix to match. More...
 
virtual int getPrefixLength () const override
 Represents length of prefix to match. More...
 
virtual L3Address getNextHopAsGeneric () const override
 Next hop address. More...
 
- Public Member Functions inherited from inet::IRoute
virtual ~IRoute ()
 
virtual void setSourceType (SourceType type)=0
 

Protected Member Functions

void changed (int fieldCode)
 

Private Member Functions

 Ipv4Route (const Ipv4Route &obj)
 
Ipv4Routeoperator= (const Ipv4Route &obj)
 

Private Attributes

IIpv4RoutingTablert
 the routing table in which this route is inserted, or nullptr More...
 
Ipv4Address dest
 Destination. More...
 
Ipv4Address netmask
 Route mask. More...
 
Ipv4Address gateway
 Next hop. More...
 
NetworkInterfaceinterfacePtr
 interface More...
 
SourceType sourceType
 manual, routing prot, etc. More...
 
unsigned int adminDist
 Cisco like administrative distance. More...
 
int metric
 Metric ("cost" to reach the destination) More...
 
cObject * source
 Object identifying the source. More...
 
cObject * protocolData
 Routing Protocol specific data. More...
 

Additional Inherited Members

- Public Types inherited from inet::IRoute
enum  SourceType {
  MANUAL, IFACENETMASK, ROUTER_ADVERTISEMENT, OWN_ADV_PREFIX,
  ICMP_REDIRECT, RIP, OSPF, BGP,
  ZEBRA, MANET, MANET2, DYMO,
  AODV, EIGRP, LISP, BABEL,
  ODR, UNKNOWN, ISIS
}
 Specifies where the route comes from. More...
 
enum  ChangeCodes {
  F_DESTINATION, F_PREFIX_LENGTH, F_NEXTHOP, F_IFACE,
  F_SOURCE, F_TYPE, F_ADMINDIST, F_METRIC,
  F_EXPIRYTIME, F_LAST
}
 Field codes for NB_ROUTE_CHANGED notifications. More...
 
enum  RouteAdminDist {
  dDirectlyConnected = 0, dStatic = 1, dEIGRPSummary = 5, dBGPExternal = 20,
  dEIGRPInternal = 90, dIGRP = 100, dOSPF = 110, dISIS = 115,
  dRIP = 120, dEGP = 140, dODR = 160, dEIGRPExternal = 170,
  dBGPInternal = 200, dDHCPlearned = 254, dBABEL = 125, dLISP = 210,
  dUnknown = 255
}
 Cisco like administrative distances. More...
 
- Static Public Member Functions inherited from inet::IRoute
static const char * sourceTypeName (SourceType sourceType)
 

Detailed Description

Constructor & Destructor Documentation

◆ Ipv4Route() [1/2]

inet::Ipv4Route::Ipv4Route ( const Ipv4Route obj)
private

◆ Ipv4Route() [2/2]

inet::Ipv4Route::Ipv4Route ( )
inline
47  : rt(nullptr), interfacePtr(nullptr), sourceType(MANUAL), adminDist(dUnknown),
48  metric(0), source(nullptr), protocolData(nullptr) {}

◆ ~Ipv4Route()

inet::Ipv4Route::~Ipv4Route ( )
virtual
25 {
26  delete protocolData;
27 }

Member Function Documentation

◆ changed()

void inet::Ipv4Route::changed ( int  fieldCode)
protected
106 {
107  if (rt)
108  rt->routeChanged(this, fieldCode);
109 }

◆ detailedInfo()

std::string inet::Ipv4Route::detailedInfo ( ) const
virtual
90 {
91  return std::string();
92 }

◆ equals()

bool inet::Ipv4Route::equals ( const Ipv4Route route) const
95 {
96  return rt == route.rt && dest == route.dest && netmask == route.netmask && gateway == route.gateway &&
97  interfacePtr == route.interfacePtr && sourceType == route.sourceType && metric == route.metric;
98 }

◆ getAdminDist()

◆ getDestination()

const Ipv4Address& inet::Ipv4Route::getDestination ( ) const
inline

Destination address prefix to match.

74 { return dest; }

Referenced by inet::ospfv2::Router::addExternalRouteInIPTable(), inet::bgp::BgpRouter::addToAdvertiseList(), inet::bgp::BgpRoutingTableEntry::BgpRoutingTableEntry(), inet::ospfv2::Ospfv2Area::calculateInterAreaRoutes(), inet::ospfv3::Ospfv3Area::calculateInterAreaRoutes(), inet::ospfv2::Ospfv2Area::calculateShortestPathTree(), inet::ospfv3::Ospfv3Area::calculateShortestPathTree(), inet::bgp::BgpRouter::checkExternalRoute(), inet::Ipv4NetworkConfigurator::configureRoutingTable(), inet::bgp::BgpRouter::decisionProcess(), inet::bgp::BgpRouter::deleteBGPRoutingEntry(), inet::Ipv4NetworkConfigurator::dumpConfig(), inet::Ldp::findPeerAddrFromInterface(), inet::ospfv3::Ospfv3Area::findSameOrWorseCostRoute(), inet::ospfv2::Router::getDefaultRoute(), inet::ospfv2::Router::getRoutesToASBoundaryRouter(), getSourceTypeAbbreviation(), inet::ospfv2::Router::hasRouteToASBoundaryRouter(), inet::Ipv4RoutingTable::internalAddRoute(), inet::ospfv2::Ospfv2Area::isDefaultRoute(), inet::bgp::BgpRouter::isDefaultRoute(), inet::ospfv2::Router::isDirectRoute(), inet::ospfv3::Ospfv3Process::isInRoutingTable(), inet::bgp::BgpRouter::isInRoutingTable(), inet::bgp::BgpRouter::isInTable(), inet::bgp::BgpRouter::isReachable(), inet::ospfv2::Router::lookup(), inet::bgp::operator<<(), inet::ospfv2::operator<<(), inet::ospfv2::Ospfv2RoutingTableEntry::operator==(), inet::ospfv2::Ospfv2Area::originateSummaryLSA(), inet::ospfv2::Ospfv2RoutingTableEntry::Ospfv2RoutingTableEntry(), inet::Ipv4RoutingTable::printRoutingTable(), inet::eigrp::EigrpIpv4Pdm::processRTRouteDel(), inet::Ldp::rebuildFecList(), inet::ospfv3::Ospfv3Process::rebuildRoutingTable(), inet::Ted::rebuildRoutingTable(), inet::PimDm::receiveSignal(), inet::ospfv3::Ospfv3Area::recheckInterAreaPrefixLSAs(), inet::ospfv2::Ospfv2Area::recheckSummaryLSAs(), inet::Ipv4RoutingTable::routeLessThan(), inet::bgp::BgpRoutingTableEntry::str(), str(), inet::ospfv2::Ospfv2RoutingTableEntry::str(), inet::ospfv2::Router::updateExternalRoute(), and inet::bgp::BgpRouter::updateSendProcess().

◆ getDestinationAsGeneric()

virtual L3Address inet::Ipv4Route::getDestinationAsGeneric ( ) const
inlineoverridevirtual

◆ getGateway()

◆ getInterface()

◆ getInterfaceName()

◆ getMetric()

◆ getNetmask()

const Ipv4Address& inet::Ipv4Route::getNetmask ( ) const
inline

Represents length of prefix to match.

77 { return netmask; }

Referenced by inet::ospfv2::Router::addExternalRouteInIPTable(), inet::bgp::BgpRoutingTableEntry::BgpRoutingTableEntry(), inet::ospfv2::Ospfv2Area::calculateInterAreaRoutes(), inet::ospfv3::Ospfv3Area::calculateInterAreaRoutes(), inet::ospfv2::Ospfv2Area::calculateShortestPathTree(), inet::Ipv4NetworkConfigurator::configureRoutingTable(), inet::bgp::BgpRouter::decisionProcess(), inet::bgp::BgpRouter::deleteBGPRoutingEntry(), inet::Ipv4NetworkConfigurator::dumpConfig(), inet::ospfv3::Ospfv3Area::findSameOrWorseCostRoute(), inet::ospfv2::Router::getDefaultRoute(), inet::ospfv2::Router::getRoutesToASBoundaryRouter(), inet::Dsdv::handleMessageWhenUp(), inet::ospfv2::Router::hasRouteToASBoundaryRouter(), inet::Ipv4RoutingTable::internalAddRoute(), inet::ospfv2::Ospfv2Area::isDefaultRoute(), inet::bgp::BgpRouter::isDefaultRoute(), inet::ospfv3::Ospfv3Process::isInRoutingTable(), inet::bgp::BgpRouter::isInRoutingTable(), inet::bgp::BgpRouter::isInTable(), inet::bgp::BgpRouter::isReachable(), inet::bgp::BgpRouter::isRouteExcluded(), inet::bgp::operator<<(), inet::ospfv2::operator<<(), inet::ospfv2::Ospfv2RoutingTableEntry::operator==(), inet::ospfv2::Ospfv2Area::originateSummaryLSA(), inet::ospfv2::Ospfv2RoutingTableEntry::Ospfv2RoutingTableEntry(), inet::Ipv4RoutingTable::printRoutingTable(), inet::eigrp::EigrpIpv4Pdm::processRTRouteDel(), inet::Ldp::rebuildFecList(), inet::PimDm::receiveSignal(), inet::Ipv4RoutingTable::routeLessThan(), inet::bgp::BgpRoutingTableEntry::str(), str(), inet::ospfv2::Ospfv2RoutingTableEntry::str(), inet::ospfv2::Router::updateExternalRoute(), and inet::bgp::BgpRouter::updateSendProcess().

◆ getNextHopAsGeneric()

virtual L3Address inet::Ipv4Route::getNextHopAsGeneric ( ) const
inlineoverridevirtual

Next hop address.

Implements inet::IRoute.

110 { return getGateway(); } // TODO rename Ipv4 method

Referenced by inet::ospfv2::Ospfv2::handleInterfaceDown().

◆ getPrefixLength()

virtual int inet::Ipv4Route::getPrefixLength ( ) const
inlineoverridevirtual

◆ getProtocolData()

cObject* inet::Ipv4Route::getProtocolData ( ) const
inlineoverridevirtual

Implements inet::IRoute.

100 { return protocolData; }

◆ getRoutingTable()

◆ getRoutingTableAsGeneric()

IRoutingTable * inet::Ipv4Route::getRoutingTableAsGeneric ( ) const
overridevirtual

The routing table in which this route is inserted, or nullptr.

Implements inet::IRoute.

112 {
113  return getRoutingTable();
114 }

◆ getSource()

cObject* inet::Ipv4Route::getSource ( ) const
inlineoverridevirtual

Source of route.

Implements inet::IRoute.

98 { return source; }

Referenced by inet::Ipv4NetworkConfigurator::configureRoutingTable().

◆ getSourceType()

◆ getSourceTypeAbbreviation()

const char * inet::Ipv4Route::getSourceTypeAbbreviation ( ) const
29  {
30  switch (sourceType) {
31  case IFACENETMASK:
32  return "C";
33  case MANUAL:
34  return getDestination().isUnspecified() ? "S*" : "S";
36  return "ra";
37  case RIP:
38  return "R";
39  case OSPF:
40  return "O";
41  case BGP:
42  return "B";
43  case EIGRP:
44  return getAdminDist() < Ipv4Route::dEIGRPExternal ? "D" : "D EX";
45  case LISP:
46  return "l";
47  case BABEL:
48  return "ba";
49  case ODR:
50  return "o";
51  default:
52  return "???";
53  }
54 }

Referenced by inet::bgp::BgpRoutingTableEntry::str(), str(), and inet::ospfv2::Ospfv2RoutingTableEntry::str().

◆ isValid()

virtual bool inet::Ipv4Route::isValid ( ) const
inlinevirtual

test validity of route entry, e.g.

check expiry

Reimplemented in inet::DsdvIpv4Route.

62 { return true; }

Referenced by inet::Ipv4RoutingTable::purge().

◆ operator!=()

bool inet::Ipv4Route::operator!= ( const Ipv4Route route) const
inline
54 { return !equals(route); }

◆ operator=()

Ipv4Route& inet::Ipv4Route::operator= ( const Ipv4Route obj)
private

◆ operator==()

bool inet::Ipv4Route::operator== ( const Ipv4Route route) const
inline
53 { return equals(route); }

◆ setAdminDist()

◆ setDestination() [1/2]

virtual void inet::Ipv4Route::setDestination ( const L3Address dest)
inlineoverridevirtual

Implements inet::IRoute.

104 { setDestination(dest.toIpv4()); }

Referenced by setDestination().

◆ setDestination() [2/2]

◆ setGateway()

◆ setInterface()

◆ setMetric()

◆ setNetmask()

◆ setNextHop()

virtual void inet::Ipv4Route::setNextHop ( const L3Address nextHop)
inlineoverridevirtual

Implements inet::IRoute.

106 { setGateway(nextHop.toIpv4()); } // TODO rename Ipv4 method

Referenced by inet::ospfv3::Ospfv3Process::rebuildRoutingTable().

◆ setPrefixLength()

virtual void inet::Ipv4Route::setPrefixLength ( int  len)
inlineoverridevirtual

◆ setProtocolData()

void inet::Ipv4Route::setProtocolData ( cObject *  protocolData)
inlineoverridevirtual

Implements inet::IRoute.

101 { this->protocolData = protocolData; }

◆ setRoutingTable()

virtual void inet::Ipv4Route::setRoutingTable ( IIpv4RoutingTable rt)
inlinevirtual

To be called by the routing table when this route is added or removed from it.

58 { this->rt = rt; }

Referenced by inet::Ipv4RoutingTable::internalAddRoute(), inet::Ipv4RoutingTable::removeRoute(), and inet::Ipv4RoutingTable::updateNetmaskRoutes().

◆ setSource()

void inet::Ipv4Route::setSource ( cObject *  _source)
inlineoverridevirtual

◆ setSourceType()

◆ str()

std::string inet::Ipv4Route::str ( ) const
overridevirtual

Reimplemented in inet::ospfv2::Ospfv2RoutingTableEntry, and inet::bgp::BgpRoutingTableEntry.

57 {
58  std::stringstream out;
60  if (getDestination().isUnspecified())
61  out << " 0.0.0.0";
62  else
63  out << " " << getDestination();
64  out << "/";
65  if (getNetmask().isUnspecified())
66  out << "0";
67  else
68  out << getNetmask().getNetmaskLength();
69  out << " gw:";
70  if (gateway.isUnspecified())
71  out << "*";
72  else
73  out << getGateway();
74  if (rt && rt->isAdminDistEnabled())
75  out << " AD:" << adminDist;
76  out << " metric:" << metric;
77  out << " if:";
78  if (!interfacePtr)
79  out << "*";
80  else
81  out << getInterfaceName();
82 
83  if (protocolData)
84  out << " " << protocolData->str();
85 
86  return out.str();
87 }

Referenced by inet::Ipv4RoutingTable::addRoute(), inet::Ipv4NetworkConfigurator::addStaticRoutes(), inet::Ipv4RoutingTable::deleteRoute(), and inet::Ipv4RoutingTable::removeRoute().

Member Data Documentation

◆ adminDist

unsigned int inet::Ipv4Route::adminDist
private

Cisco like administrative distance.

Referenced by str().

◆ dest

Ipv4Address inet::Ipv4Route::dest
private

Destination.

Referenced by equals().

◆ gateway

Ipv4Address inet::Ipv4Route::gateway
private

Next hop.

Referenced by equals(), and str().

◆ interfacePtr

NetworkInterface* inet::Ipv4Route::interfacePtr
private

interface

Referenced by equals(), getInterfaceName(), and str().

◆ metric

int inet::Ipv4Route::metric
private

Metric ("cost" to reach the destination)

Referenced by equals(), and str().

◆ netmask

Ipv4Address inet::Ipv4Route::netmask
private

Route mask.

Referenced by equals().

◆ protocolData

cObject* inet::Ipv4Route::protocolData
private

Routing Protocol specific data.

Referenced by str(), and ~Ipv4Route().

◆ rt

IIpv4RoutingTable* inet::Ipv4Route::rt
private

the routing table in which this route is inserted, or nullptr

Referenced by changed(), equals(), and str().

◆ source

cObject* inet::Ipv4Route::source
private

Object identifying the source.

◆ sourceType

SourceType inet::Ipv4Route::sourceType
private

manual, routing prot, etc.

Referenced by equals(), and getSourceTypeAbbreviation().


The documentation for this class was generated from the following files:
inet::Ipv4Route::getGateway
const Ipv4Address & getGateway() const
Next hop address.
Definition: Ipv4Route.h:80
inet::IRoute::dEIGRPExternal
@ dEIGRPExternal
Definition: IRoute.h:72
inet::IRoute::F_IFACE
@ F_IFACE
Definition: IRoute.h:50
inet::Ipv4Route::adminDist
unsigned int adminDist
Cisco like administrative distance.
Definition: Ipv4Route.h:33
inet::Ipv4Route::getSourceTypeAbbreviation
const char * getSourceTypeAbbreviation() const
Definition: Ipv4Route.cc:29
inet::IRoute::ODR
@ ODR
Definition: IRoute.h:42
inet::Ipv4Route::changed
void changed(int fieldCode)
Definition: Ipv4Route.cc:105
inet::IRoute::F_DESTINATION
@ F_DESTINATION
Definition: IRoute.h:47
inet::Ipv4Route::sourceType
SourceType sourceType
manual, routing prot, etc.
Definition: Ipv4Route.h:32
inet::Ipv4Route::equals
bool equals(const Ipv4Route &route) const
Definition: Ipv4Route.cc:94
inet::IRoute::RIP
@ RIP
managed by the given routing protocol
Definition: IRoute.h:34
inet::IRoute::MANUAL
@ MANUAL
manually added static route
Definition: IRoute.h:29
inet::Ipv4Address::getNetmaskLength
int getNetmaskLength() const
Counts 1 bits in a netmask.
Definition: Ipv4Address.cc:234
inet::IRoute::LISP
@ LISP
Definition: IRoute.h:42
inet::IRoute::ROUTER_ADVERTISEMENT
@ ROUTER_ADVERTISEMENT
on-link prefix, from Router Advertisement
Definition: IRoute.h:31
inet::NetworkInterface::getInterfaceName
const char * getInterfaceName() const
Definition: NetworkInterface.h:233
inet::IRoute::EIGRP
@ EIGRP
Definition: IRoute.h:42
inet::IRoutingTable::isAdminDistEnabled
virtual bool isAdminDistEnabled() const =0
Administrative distance on/off.
inet::IRoute::BGP
@ BGP
managed by the given routing protocol
Definition: IRoute.h:36
inet::Ipv4Route::getInterfaceName
const char * getInterfaceName() const
Convenience method.
Definition: Ipv4Route.cc:100
inet::Ipv4Route::setNetmask
virtual void setNetmask(Ipv4Address _netmask)
Definition: Ipv4Route.h:65
inet::Ipv4Route::getDestination
const Ipv4Address & getDestination() const
Destination address prefix to match.
Definition: Ipv4Route.h:74
inet::Ipv4Route::getRoutingTable
IIpv4RoutingTable * getRoutingTable() const
Definition: Ipv4Route.h:59
inet::Ipv4Route::setGateway
virtual void setGateway(Ipv4Address _gateway)
Definition: Ipv4Route.h:66
inet::IRoute::F_SOURCE
@ F_SOURCE
Definition: IRoute.h:51
inet::IRoute::OSPF
@ OSPF
managed by the given routing protocol
Definition: IRoute.h:35
inet::Ipv4Address::makeNetmask
static Ipv4Address makeNetmask(int length)
Creates and returns a netmask with the given length.
Definition: Ipv4Address.h:329
inet::Ipv4Route::gateway
Ipv4Address gateway
Next hop.
Definition: Ipv4Route.h:30
inet::IIpv4RoutingTable::routeChanged
virtual void routeChanged(Ipv4Route *entry, int fieldCode)=0
To be called from route objects whenever a field changes.
inet::Ipv4Route::interfacePtr
NetworkInterface * interfacePtr
interface
Definition: Ipv4Route.h:31
inet::Ipv4Route::source
cObject * source
Object identifying the source.
Definition: Ipv4Route.h:35
inet::Ipv4Route::rt
IIpv4RoutingTable * rt
the routing table in which this route is inserted, or nullptr
Definition: Ipv4Route.h:27
inet::Ipv4Route::getNetmask
const Ipv4Address & getNetmask() const
Represents length of prefix to match.
Definition: Ipv4Route.h:77
inet::Ipv4Route::netmask
Ipv4Address netmask
Route mask.
Definition: Ipv4Route.h:29
inet::Ipv4Route::metric
int metric
Metric ("cost" to reach the destination)
Definition: Ipv4Route.h:34
inet::Ipv4Route::dest
Ipv4Address dest
Destination.
Definition: Ipv4Route.h:28
inet::Ipv4Route::protocolData
cObject * protocolData
Routing Protocol specific data.
Definition: Ipv4Route.h:36
inet::IRoute::dUnknown
@ dUnknown
Definition: IRoute.h:77
inet::Ipv4Route::getAdminDist
unsigned int getAdminDist() const
Route source specific preference value.
Definition: Ipv4Route.h:92
inet::Ipv4Route::setDestination
virtual void setDestination(Ipv4Address _dest)
Definition: Ipv4Route.h:64
inet::IRoute::BABEL
@ BABEL
Definition: IRoute.h:42
inet::IRoute::F_PREFIX_LENGTH
@ F_PREFIX_LENGTH
Definition: IRoute.h:48
inet::IRoute::F_METRIC
@ F_METRIC
Definition: IRoute.h:54
inet::Ipv4Address::isUnspecified
bool isUnspecified() const
True if all four address bytes are zero.
Definition: Ipv4Address.h:165
inet::IRoute::F_NEXTHOP
@ F_NEXTHOP
Definition: IRoute.h:49
inet::IRoute::IFACENETMASK
@ IFACENETMASK
comes from an interface's netmask
Definition: IRoute.h:30
inet::IRoute::F_ADMINDIST
@ F_ADMINDIST
Definition: IRoute.h:53