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::RoutingTableEntry inet::ospf::RoutingTableEntry

Public Types

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, dUnknown = 255
}
 Cisco like administrative distances. More...
 
- 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
}
 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...
 

Public Member Functions

 IPv4Route ()
 
virtual ~IPv4Route ()
 
virtual std::string info () const override
 
virtual std::string detailedInfo () const override
 
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 (InterfaceEntry *_interfacePtr) override
 
virtual void setSourceType (SourceType _source) override
 
virtual void setAdminDist (unsigned int _adminDist)
 
virtual void setMetric (int _metric) override
 
IPv4Address getDestination () const
 Destination address prefix to match. More...
 
IPv4Address getNetmask () const
 Represents length of prefix to match. More...
 
IPv4Address getGateway () const
 Next hop address. More...
 
InterfaceEntrygetInterface () 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...
 
InterfaceEntryinterfacePtr
 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

- Static Public Member Functions inherited from inet::IRoute
static const char * sourceTypeName (SourceType sourceType)
 

Detailed Description

Member Enumeration Documentation

Cisco like administrative distances.

Enumerator
dDirectlyConnected 
dStatic 
dEIGRPSummary 
dBGPExternal 
dEIGRPInternal 
dIGRP 
dOSPF 
dISIS 
dRIP 
dEGP 
dODR 
dEIGRPExternal 
dBGPInternal 
dDHCPlearned 
dUnknown 
40  {
42  dStatic = 1,
43  dEIGRPSummary = 5,
44  dBGPExternal = 20,
45  dEIGRPInternal = 90,
46  dIGRP = 100,
47  dOSPF = 110,
48  dISIS = 115,
49  dRIP = 120,
50  dEGP = 140,
51  dODR = 160,
52  dEIGRPExternal = 170,
53  dBGPInternal = 200,
54  dDHCPlearned = 254,
55  dUnknown = 255
56  };
Definition: IPv4Route.h:48
Definition: IPv4Route.h:55
Definition: IPv4Route.h:50
Definition: IPv4Route.h:45
Definition: IPv4Route.h:43
Definition: IPv4Route.h:54
Definition: IPv4Route.h:42
Definition: IPv4Route.h:53
Definition: IPv4Route.h:46
Definition: IPv4Route.h:41
Definition: IPv4Route.h:51
Definition: IPv4Route.h:49
Definition: IPv4Route.h:44
Definition: IPv4Route.h:52
Definition: IPv4Route.h:47

Constructor & Destructor Documentation

inet::IPv4Route::IPv4Route ( const IPv4Route obj)
private
inet::IPv4Route::IPv4Route ( )
inline
79  : rt(nullptr), interfacePtr(nullptr), sourceType(MANUAL), adminDist(dUnknown),
80  metric(0), source(nullptr), protocolData(nullptr) {}
InterfaceEntry * interfacePtr
interface
Definition: IPv4Route.h:63
Definition: IPv4Route.h:55
SourceType sourceType
manual, routing prot, etc.
Definition: IPv4Route.h:64
IIPv4RoutingTable * rt
the routing table in which this route is inserted, or nullptr
Definition: IPv4Route.h:59
cObject * source
Object identifying the source.
Definition: IPv4Route.h:67
cObject * protocolData
Routing Protocol specific data.
Definition: IPv4Route.h:68
manually added static route
Definition: IRoute.h:40
int metric
Metric ("cost" to reach the destination)
Definition: IPv4Route.h:66
unsigned int adminDist
Cisco like administrative distance.
Definition: IPv4Route.h:65
inet::IPv4Route::~IPv4Route ( )
virtual
38 {
39  delete protocolData;
40 }
cObject * protocolData
Routing Protocol specific data.
Definition: IPv4Route.h:68

Member Function Documentation

void inet::IPv4Route::changed ( int  fieldCode)
protected

Referenced by inet::IPv4MulticastRoute::addOutInterface(), inet::IPv4MulticastRoute::clearOutInterfaces(), inet::IPv4MulticastRoute::removeOutInterface(), and inet::IPv4MulticastRoute::setInInterface().

99 {
100  if (rt)
101  rt->routeChanged(this, fieldCode);
102 }
IIPv4RoutingTable * rt
the routing table in which this route is inserted, or nullptr
Definition: IPv4Route.h:59
virtual void routeChanged(IPv4Route *entry, int fieldCode)=0
To be called from route objects whenever a field changes.
std::string inet::IPv4Route::detailedInfo ( ) const
overridevirtual
83 {
84  return std::string();
85 }
bool inet::IPv4Route::equals ( const IPv4Route route) const
88 {
89  return rt == route.rt && dest == route.dest && netmask == route.netmask && gateway == route.gateway &&
90  interfacePtr == route.interfacePtr && sourceType == route.sourceType && metric == route.metric;
91 }
InterfaceEntry * interfacePtr
interface
Definition: IPv4Route.h:63
SourceType sourceType
manual, routing prot, etc.
Definition: IPv4Route.h:64
IIPv4RoutingTable * rt
the routing table in which this route is inserted, or nullptr
Definition: IPv4Route.h:59
IPv4Address gateway
Next hop.
Definition: IPv4Route.h:62
IPv4Address netmask
Route mask.
Definition: IPv4Route.h:61
IPv4Address dest
Destination.
Definition: IPv4Route.h:60
int metric
Metric ("cost" to reach the destination)
Definition: IPv4Route.h:66
unsigned int inet::IPv4Route::getAdminDist ( ) const
inline

Route source specific preference value.

Referenced by inet::PIMSM::addNewRouteG(), inet::PIMSM::addNewRouteSG(), inet::IPv4RoutingTable::routeLessThan(), and inet::PIMDM::unroutableMulticastPacketArrived().

123 { return adminDist; }
unsigned int adminDist
Cisco like administrative distance.
Definition: IPv4Route.h:65
IPv4Address inet::IPv4Route::getDestination ( ) const
inline

Destination address prefix to match.

Referenced by inet::ospf::Router::addExternalRouteInIPTable(), inet::ospf::Area::calculateInterAreaRoutes(), inet::ospf::Area::calculateShortestPathTree(), inet::bgp::BGPRouting::checkExternalRoute(), inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::bgp::BGPRouting::decisionProcess(), inet::bgp::BGPRouting::deleteBGPRoutingEntry(), inet::IPv4NetworkConfigurator::dumpConfig(), inet::NetworkInfo::dumpRoutingInfo(), inet::LDP::findPeerAddrFromInterface(), inet::ospf::Area::findSameOrWorseCostRoute(), inet::DHCPClient::finish(), inet::ospf::Router::getRoutesToASBoundaryRouter(), inet::ospf::Router::hasRouteToASBoundaryRouter(), inet::IPv4RoutingTable::internalAddRoute(), inet::bgp::BGPRouting::isInRoutingTable(), inet::bgp::BGPRouting::isInTable(), inet::ospf::Router::lookup(), inet::bgp::operator<<(), inet::ospf::operator<<(), inet::ospf::RoutingTableEntry::operator==(), inet::ospf::Area::originateSummaryLSA(), inet::IPv4RoutingTable::printRoutingTable(), inet::LDP::rebuildFecList(), inet::TED::rebuildRoutingTable(), inet::PIMDM::receiveSignal(), inet::ospf::Area::recheckSummaryLSAs(), inet::visualizer::RoutingTableVisualizerBase::DirectiveResolver::resolveDirective(), inet::IPv4RoutingTable::routeLessThan(), inet::bgp::RoutingTableEntry::RoutingTableEntry(), inet::ospf::RoutingTableEntry::RoutingTableEntry(), inet::ospf::Router::updateExternalRoute(), and inet::bgp::BGPRouting::updateSendProcess().

105 { return dest; }
IPv4Address dest
Destination.
Definition: IPv4Route.h:60
virtual L3Address inet::IPv4Route::getDestinationAsGeneric ( ) const
inlineoverridevirtual

Destination address prefix to match.

Implements inet::IRoute.

139 { return getDestination(); }
IPv4Address getDestination() const
Destination address prefix to match.
Definition: IPv4Route.h:105
const char * inet::IPv4Route::getInterfaceName ( ) const

Convenience method.

Referenced by inet::IPv4NetworkConfigurator::dumpConfig(), inet::NetworkInfo::dumpRoutingInfo(), inet::DHCPClient::finish(), inet::ospf::operator<<(), and inet::TED::rebuildRoutingTable().

94 {
95  return interfacePtr ? interfacePtr->getName() : "";
96 }
InterfaceEntry * interfacePtr
interface
Definition: IPv4Route.h:63
virtual L3Address inet::IPv4Route::getNextHopAsGeneric ( ) const
inlineoverridevirtual

Next hop address.

Implements inet::IRoute.

141 { return getGateway(); } //TODO rename IPv4 method
IPv4Address getGateway() const
Next hop address.
Definition: IPv4Route.h:111
virtual int inet::IPv4Route::getPrefixLength ( ) const
inlineoverridevirtual

Represents length of prefix to match.

Implements inet::IRoute.

140 { return getNetmask().getNetmaskLength(); }
int getNetmaskLength() const
Counts 1 bits in a netmask.
Definition: IPv4Address.cc:245
IPv4Address getNetmask() const
Represents length of prefix to match.
Definition: IPv4Route.h:108
cObject* inet::IPv4Route::getProtocolData ( ) const
inlineoverridevirtual

Implements inet::IRoute.

131 { return protocolData; }
cObject * protocolData
Routing Protocol specific data.
Definition: IPv4Route.h:68
IIPv4RoutingTable* inet::IPv4Route::getRoutingTable ( ) const
inline
IRoutingTable * inet::IPv4Route::getRoutingTableAsGeneric ( ) const
overridevirtual

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

Implements inet::IRoute.

105 {
106  return getRoutingTable();
107 }
IIPv4RoutingTable * getRoutingTable() const
Definition: IPv4Route.h:91
cObject* inet::IPv4Route::getSource ( ) const
inlineoverridevirtual

Source of route.

Implements inet::IRoute.

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

129 { return source; }
cObject * source
Object identifying the source.
Definition: IPv4Route.h:67
std::string inet::IPv4Route::info ( ) const
overridevirtual

Referenced by inet::IPv4RoutingTable::addRoute(), inet::IPv4NetworkConfigurator::addStaticRoutes(), inet::IPv4RoutingTable::deleteRoute(), inet::IPv4MulticastRoute::detailedInfo(), inet::operator<<(), inet::IPv4RoutingTable::removeRoute(), and inet::visualizer::RoutingTableVisualizerBase::DirectiveResolver::resolveDirective().

43 {
44  std::stringstream out;
45 
46  out << "dest:";
47  if (dest.isUnspecified())
48  out << "* ";
49  else
50  out << dest << " ";
51  out << "gw:";
52  if (gateway.isUnspecified())
53  out << "* ";
54  else
55  out << gateway << " ";
56  out << "mask:";
57  if (netmask.isUnspecified())
58  out << "* ";
59  else
60  out << netmask << " ";
61  out << "metric:" << metric << " ";
62  out << "if:";
63  if (!interfacePtr)
64  out << "*";
65  else
66  out << interfacePtr->getName();
68  out << "(" << interfacePtr->ipv4Data()->getIPAddress() << ")";
69  out << " ";
70  out << (gateway.isUnspecified() ? "DIRECT" : "REMOTE");
71  out << " " << IRoute::sourceTypeName(sourceType);
72 
73 #ifdef WITH_AODV
74  if (dynamic_cast<AODVRouteData *>(protocolData)) {
75  AODVRouteData *data = (AODVRouteData *)protocolData;
76  out << data;
77  }
78 #endif // ifdef WITH_AODV
79  return out.str();
80 }
IPv4InterfaceData * ipv4Data() const
Definition: InterfaceEntry.h:221
bool isUnspecified() const
True if all four address bytes are zero.
Definition: IPv4Address.h:176
InterfaceEntry * interfacePtr
interface
Definition: IPv4Route.h:63
static const char * sourceTypeName(SourceType sourceType)
Definition: IRoute.cc:22
SourceType sourceType
manual, routing prot, etc.
Definition: IPv4Route.h:64
cObject * protocolData
Routing Protocol specific data.
Definition: IPv4Route.h:68
IPv4Address getIPAddress() const
Definition: IPv4InterfaceData.h:177
IPv4Address gateway
Next hop.
Definition: IPv4Route.h:62
IPv4Address netmask
Route mask.
Definition: IPv4Route.h:61
IPv4Address dest
Destination.
Definition: IPv4Route.h:60
int metric
Metric ("cost" to reach the destination)
Definition: IPv4Route.h:66
virtual bool inet::IPv4Route::isValid ( ) const
inlinevirtual

test validity of route entry, e.g.

check expiry

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

94 { return true; }
bool inet::IPv4Route::operator!= ( const IPv4Route route) const
inline
86 { return !equals(route); }
bool equals(const IPv4Route &route) const
Definition: IPv4Route.cc:87
IPv4Route& inet::IPv4Route::operator= ( const IPv4Route obj)
private
bool inet::IPv4Route::operator== ( const IPv4Route route) const
inline
85 { return equals(route); }
bool equals(const IPv4Route &route) const
Definition: IPv4Route.cc:87
virtual void inet::IPv4Route::setAdminDist ( unsigned int  _adminDist)
inlinevirtual

Referenced by inet::IPv4RoutingTable::updateNetmaskRoutes().

101 { if (adminDist != _adminDist) { adminDist = _adminDist; changed(F_ADMINDIST); } }
void changed(int fieldCode)
Definition: IPv4Route.cc:98
unsigned int adminDist
Cisco like administrative distance.
Definition: IPv4Route.h:65
Definition: IRoute.h:63
virtual void inet::IPv4Route::setDestination ( const L3Address dest)
inlineoverridevirtual

Implements inet::IRoute.

Referenced by setDestination().

135 { setDestination(dest.toIPv4()); }
virtual void setDestination(IPv4Address _dest)
Definition: IPv4Route.h:96
IPv4Address dest
Destination.
Definition: IPv4Route.h:60
virtual void inet::IPv4Route::setNextHop ( const L3Address nextHop)
inlineoverridevirtual

Implements inet::IRoute.

137 { setGateway(nextHop.toIPv4()); } //TODO rename IPv4 method
virtual void setGateway(IPv4Address _gateway)
Definition: IPv4Route.h:98
virtual void inet::IPv4Route::setPrefixLength ( int  len)
inlineoverridevirtual

Implements inet::IRoute.

uint16_t len
Definition: TCP_NSC.cc:85
static IPv4Address makeNetmask(int length)
Creates and returns a netmask with the given length.
Definition: IPv4Address.h:335
virtual void setNetmask(IPv4Address _netmask)
Definition: IPv4Route.h:97
void inet::IPv4Route::setProtocolData ( cObject *  protocolData)
inlineoverridevirtual

Implements inet::IRoute.

132 { this->protocolData = protocolData; }
cObject * protocolData
Routing Protocol specific data.
Definition: IPv4Route.h:68
virtual void inet::IPv4Route::setRoutingTable ( IIPv4RoutingTable rt)
inlinevirtual

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

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

90 { this->rt = rt; }
IIPv4RoutingTable * rt
the routing table in which this route is inserted, or nullptr
Definition: IPv4Route.h:59
void inet::IPv4Route::setSource ( cObject *  _source)
inlineoverridevirtual

Implements inet::IRoute.

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable(), and inet::IPv4RoutingTable::updateNetmaskRoutes().

128 { if (source != _source) { source = _source; changed(F_SOURCE); } }
Definition: IRoute.h:61
cObject * source
Object identifying the source.
Definition: IPv4Route.h:67
void changed(int fieldCode)
Definition: IPv4Route.cc:98

Member Data Documentation

unsigned int inet::IPv4Route::adminDist
private

Cisco like administrative distance.

IPv4Address inet::IPv4Route::dest
private

Destination.

Referenced by equals(), and info().

IPv4Address inet::IPv4Route::gateway
private

Next hop.

Referenced by equals(), and info().

InterfaceEntry* inet::IPv4Route::interfacePtr
private

interface

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

int inet::IPv4Route::metric
private

Metric ("cost" to reach the destination)

Referenced by equals(), info(), and inet::IPv4MulticastRoute::info().

IPv4Address inet::IPv4Route::netmask
private

Route mask.

Referenced by equals(), and info().

cObject* inet::IPv4Route::protocolData
private

Routing Protocol specific data.

Referenced by info(), and ~IPv4Route().

IIPv4RoutingTable* inet::IPv4Route::rt
private

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

Referenced by changed(), inet::IPv4MulticastRoute::changed(), and equals().

cObject* inet::IPv4Route::source
private

Object identifying the source.

SourceType inet::IPv4Route::sourceType
private

manual, routing prot, etc.

Referenced by equals(), info(), and inet::IPv4MulticastRoute::info().


The documentation for this class was generated from the following files: