INET Framework for OMNeT++/OMNEST
inet::ospfv2::Ospfv2RoutingTableEntry Class Reference

#include <Ospfv2RoutingTableEntry.h>

Inheritance diagram for inet::ospfv2::Ospfv2RoutingTableEntry:
inet::Ipv4Route inet::IRoute

Public Types

enum  RoutingPathType { INTRAAREA = 0, INTERAREA = 1, TYPE1_EXTERNAL = 2, TYPE2_EXTERNAL = 3 }
 
typedef unsigned char RoutingDestinationType
 
- 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...
 

Public Member Functions

 Ospfv2RoutingTableEntry (IInterfaceTable *ift)
 
 Ospfv2RoutingTableEntry (const Ospfv2RoutingTableEntry &entry)
 
virtual ~Ospfv2RoutingTableEntry ()
 
bool operator== (const Ospfv2RoutingTableEntry &entry) const
 
bool operator!= (const Ospfv2RoutingTableEntry &entry) const
 
void setDestinationType (RoutingDestinationType type)
 
RoutingDestinationType getDestinationType () const
 
void setOptionalCapabilities (Ospfv2Options options)
 
Ospfv2Options getOptionalCapabilities () const
 
void setArea (AreaId source)
 
AreaId getArea () const
 
void setPathType (RoutingPathType type)
 
RoutingPathType getPathType () const
 
Metric getCost () const
 
void setCost (Metric cost)
 
void setType2Cost (Metric type2Cost)
 
Metric getType2Cost () const
 
void setLinkStateOrigin (const Ospfv2Lsa *lsa)
 
const Ospfv2LsagetLinkStateOrigin () const
 
void addNextHop (NextHop hop)
 
void clearNextHops ()
 
unsigned int getNextHopCount () const
 
NextHop getNextHop (unsigned int index) const
 
virtual std::string str () const
 
- Public Member Functions inherited from inet::Ipv4Route
 Ipv4Route ()
 
virtual ~Ipv4Route ()
 
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
 

Static Public Member Functions

static const char * getDestinationTypeString (RoutingDestinationType destType)
 
static const char * getPathTypeString (RoutingPathType pathType)
 
- Static Public Member Functions inherited from inet::IRoute
static const char * sourceTypeName (SourceType sourceType)
 

Static Public Attributes

static const unsigned char NETWORK_DESTINATION = 0
 
static const unsigned char AREA_BORDER_ROUTER_DESTINATION = 1
 
static const unsigned char AS_BOUNDARY_ROUTER_DESTINATION = 2
 

Private Attributes

IInterfaceTableift = nullptr
 
RoutingDestinationType destinationType = 0
 
Ospfv2Options optionalCapabilities
 
AreaId area
 
RoutingPathType pathType = static_cast<RoutingPathType>(-1)
 
Metric cost = 0
 
Metric type2Cost = 0
 
const Ospfv2LsalinkStateOrigin = nullptr
 
std::vector< NextHopnextHops
 

Additional Inherited Members

- Protected Member Functions inherited from inet::Ipv4Route
void changed (int fieldCode)
 

Member Typedef Documentation

◆ RoutingDestinationType

Member Enumeration Documentation

◆ RoutingPathType

Enumerator
INTRAAREA 
INTERAREA 
TYPE1_EXTERNAL 
TYPE2_EXTERNAL 
25  {
26  INTRAAREA = 0,
27  INTERAREA = 1,
28  TYPE1_EXTERNAL = 2,
29  TYPE2_EXTERNAL = 3
30  };

Constructor & Destructor Documentation

◆ Ospfv2RoutingTableEntry() [1/2]

inet::ospfv2::Ospfv2RoutingTableEntry::Ospfv2RoutingTableEntry ( IInterfaceTable ift)

◆ Ospfv2RoutingTableEntry() [2/2]

inet::ospfv2::Ospfv2RoutingTableEntry::Ospfv2RoutingTableEntry ( const Ospfv2RoutingTableEntry entry)
23  :
24  ift(entry.ift),
25  destinationType(entry.destinationType),
26  optionalCapabilities(entry.optionalCapabilities),
27  area(entry.area),
28  pathType(entry.pathType),
29  cost(entry.cost),
30  type2Cost(entry.type2Cost),
31  linkStateOrigin(entry.linkStateOrigin),
32  nextHops(entry.nextHops)
33 {
34  setDestination(entry.getDestination());
35  setNetmask(entry.getNetmask());
36  setInterface(entry.getInterface());
37  setGateway(entry.getGateway());
38  setSourceType(entry.getSourceType());
39  setMetric(entry.getMetric());
40  setAdminDist(entry.getAdminDist());
41 }

◆ ~Ospfv2RoutingTableEntry()

virtual inet::ospfv2::Ospfv2RoutingTableEntry::~Ospfv2RoutingTableEntry ( )
inlinevirtual
55 {}

Member Function Documentation

◆ addNextHop()

void inet::ospfv2::Ospfv2RoutingTableEntry::addNextHop ( NextHop  hop)
44 {
45  if (nextHops.size() == 0) {
46  NetworkInterface *routingInterface = ift->getInterfaceById(hop.ifIndex);
47 
48  setInterface(routingInterface);
49  // TODO this used to be commented out, but it seems we need it
50  // otherwise gateways will never be filled in and gateway is needed for broadcast networks
51  setGateway(hop.hopAddress);
52  }
53  else {
54  for (size_t i = 0; i < nextHops.size(); i++) {
55  if (hop.ifIndex == nextHops.at(i).ifIndex && hop.hopAddress == nextHops.at(i).hopAddress)
56  return;
57  }
58  }
59  nextHops.push_back(hop);
60 }

Referenced by inet::ospfv2::Router::calculateASExternalRoutes(), inet::ospfv2::Ospfv2Area::calculateInterAreaRoutes(), inet::ospfv2::Ospfv2Area::calculateShortestPathTree(), inet::ospfv2::Ospfv2Area::createRoutingTableEntryFromSummaryLSA(), inet::ospfv2::Router::getPreferredEntry(), and inet::ospfv2::Ospfv2Area::recheckSummaryLSAs().

◆ clearNextHops()

◆ getArea()

◆ getCost()

◆ getDestinationType()

◆ getDestinationTypeString()

const char * inet::ospfv2::Ospfv2RoutingTableEntry::getDestinationTypeString ( RoutingDestinationType  destType)
static
154 {
155  switch (destType) {
157  return "Network";
159  return "AreaBorderRouter";
161  return "ASBoundaryRouter";
163  return "AreaBorderRouter+ASBoundaryRouter";
164  default:
165  return "Unknown";
166  }
167 }

Referenced by inet::ospfv2::operator<<(), and str().

◆ getLinkStateOrigin()

◆ getNextHop()

◆ getNextHopCount()

◆ getOptionalCapabilities()

Ospfv2Options inet::ospfv2::Ospfv2RoutingTableEntry::getOptionalCapabilities ( ) const
inline
63 { return optionalCapabilities; }

◆ getPathType()

◆ getPathTypeString()

const char * inet::ospfv2::Ospfv2RoutingTableEntry::getPathTypeString ( RoutingPathType  pathType)
static
170 {
171  switch (pathType) {
173  return "IntraArea";
175  return "InterArea";
177  return "Type1External";
179  return "Type2External";
180  default:
181  return "Unknown";
182  }
183 }

Referenced by inet::ospfv2::operator<<(), and str().

◆ getType2Cost()

Metric inet::ospfv2::Ospfv2RoutingTableEntry::getType2Cost ( ) const
inline

◆ operator!=()

bool inet::ospfv2::Ospfv2RoutingTableEntry::operator!= ( const Ospfv2RoutingTableEntry entry) const
inline
58 { return !((*this) == entry); }

◆ operator==()

bool inet::ospfv2::Ospfv2RoutingTableEntry::operator== ( const Ospfv2RoutingTableEntry entry) const
63 {
64  unsigned int hopCount = nextHops.size();
65  unsigned int i = 0;
66 
67  if (hopCount != entry.nextHops.size()) {
68  return false;
69  }
70  for (i = 0; i < hopCount; i++) {
71  if ((nextHops[i] != entry.nextHops[i])) {
72  return false;
73  }
74  }
75 
76  return (destinationType == entry.destinationType) &&
77  (getDestination() == entry.getDestination()) &&
78  (getNetmask() == entry.getNetmask()) &&
79  (optionalCapabilities == entry.optionalCapabilities) &&
80  (area == entry.area) &&
81  (pathType == entry.pathType) &&
82  (cost == entry.cost) &&
83  (type2Cost == entry.type2Cost) &&
84  (linkStateOrigin == entry.linkStateOrigin);
85 }

◆ setArea()

◆ setCost()

◆ setDestinationType()

◆ setLinkStateOrigin()

void inet::ospfv2::Ospfv2RoutingTableEntry::setLinkStateOrigin ( const Ospfv2Lsa lsa)
inline

◆ setOptionalCapabilities()

void inet::ospfv2::Ospfv2RoutingTableEntry::setOptionalCapabilities ( Ospfv2Options  options)
inline

◆ setPathType()

◆ setType2Cost()

void inet::ospfv2::Ospfv2RoutingTableEntry::setType2Cost ( Metric  type2Cost)
inline

◆ str()

std::string inet::ospfv2::Ospfv2RoutingTableEntry::str ( ) const
virtual

Reimplemented from inet::Ipv4Route.

119 {
120  std::ostringstream out;
121  out << getSourceTypeAbbreviation();
122  out << " ";
123  if (getDestination().isUnspecified())
124  out << "0.0.0.0";
125  else
126  out << getDestination();
127  out << "/";
128  if (getNetmask().isUnspecified())
129  out << "0";
130  else
131  out << getNetmask().getNetmaskLength();
132  out << " gw:";
133  if (getGateway().isUnspecified())
134  out << "* ";
135  else
136  out << getGateway() << " ";
137  if (getRoutingTable() && getRoutingTable()->isAdminDistEnabled())
138  out << "AD:" << getAdminDist() << " ";
139  out << "metric:" << getMetric() << " ";
140  out << "if:";
141  if (!getInterface())
142  out << "*";
143  else
144  out << getInterfaceName();
145 
148  << " area:" << area.str(false);
149 
150  return out.str();
151 }

Member Data Documentation

◆ area

AreaId inet::ospfv2::Ospfv2RoutingTableEntry::area
private

Referenced by operator==(), and str().

◆ AREA_BORDER_ROUTER_DESTINATION

◆ AS_BOUNDARY_ROUTER_DESTINATION

◆ cost

Metric inet::ospfv2::Ospfv2RoutingTableEntry::cost = 0
private

Referenced by operator==().

◆ destinationType

RoutingDestinationType inet::ospfv2::Ospfv2RoutingTableEntry::destinationType = 0
private

Referenced by operator==(), and str().

◆ ift

IInterfaceTable* inet::ospfv2::Ospfv2RoutingTableEntry::ift = nullptr
private

Referenced by addNextHop().

◆ linkStateOrigin

const Ospfv2Lsa* inet::ospfv2::Ospfv2RoutingTableEntry::linkStateOrigin = nullptr
private

Referenced by operator==().

◆ NETWORK_DESTINATION

◆ nextHops

std::vector<NextHop> inet::ospfv2::Ospfv2RoutingTableEntry::nextHops
private

Referenced by addNextHop(), and operator==().

◆ optionalCapabilities

Ospfv2Options inet::ospfv2::Ospfv2RoutingTableEntry::optionalCapabilities
private

Referenced by operator==().

◆ pathType

RoutingPathType inet::ospfv2::Ospfv2RoutingTableEntry::pathType = static_cast<RoutingPathType>(-1)
private

Referenced by getPathTypeString(), operator==(), and str().

◆ type2Cost

Metric inet::ospfv2::Ospfv2RoutingTableEntry::type2Cost = 0
private

Referenced by operator==().


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::Ipv4Route::getSourceTypeAbbreviation
const char * getSourceTypeAbbreviation() const
Definition: Ipv4Route.cc:29
inet::ospfv2::Ospfv2RoutingTableEntry::cost
Metric cost
Definition: Ospfv2RoutingTableEntry.h:45
inet::Ipv4Route::setMetric
virtual void setMetric(int _metric) override
Definition: Ipv4Route.h:71
inet::Ipv4Route::getMetric
int getMetric() const override
"Cost" to reach the destination
Definition: Ipv4Route.h:95
inet::Ipv4Address::getNetmaskLength
int getNetmaskLength() const
Counts 1 bits in a netmask.
Definition: Ipv4Address.cc:234
inet::ospfv2::Ospfv2RoutingTableEntry::TYPE1_EXTERNAL
@ TYPE1_EXTERNAL
Definition: Ospfv2RoutingTableEntry.h:28
inet::ospfv2::Ospfv2RoutingTableEntry::destinationType
RoutingDestinationType destinationType
Definition: Ospfv2RoutingTableEntry.h:41
inet::ospfv2::Ospfv2RoutingTableEntry::getDestinationTypeString
static const char * getDestinationTypeString(RoutingDestinationType destType)
Definition: Ospfv2RoutingTableEntry.cc:153
inet::Ipv4Route::getInterfaceName
const char * getInterfaceName() const
Convenience method.
Definition: Ipv4Route.cc:100
inet::ospfv2::Ospfv2RoutingTableEntry::AREA_BORDER_ROUTER_DESTINATION
static const unsigned char AREA_BORDER_ROUTER_DESTINATION
Definition: Ospfv2RoutingTableEntry.h:36
inet::IRoute::dOSPF
@ dOSPF
Definition: IRoute.h:67
inet::IInterfaceTable::getInterfaceById
virtual NetworkInterface * getInterfaceById(int id) const =0
Returns an interface by its Id.
inet::ospfv2::Ospfv2RoutingTableEntry::NETWORK_DESTINATION
static const unsigned char NETWORK_DESTINATION
Definition: Ospfv2RoutingTableEntry.h:35
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::Ipv4Address::ALLONES_ADDRESS
static const Ipv4Address ALLONES_ADDRESS
255.255.255.255
Definition: Ipv4Address.h:94
inet::Ipv4Route::getRoutingTable
IIpv4RoutingTable * getRoutingTable() const
Definition: Ipv4Route.h:59
inet::Ipv4Route::setGateway
virtual void setGateway(Ipv4Address _gateway)
Definition: Ipv4Route.h:66
inet::ospfv2::BACKBONE_AREAID
const AreaId BACKBONE_AREAID(0, 0, 0, 0)
inet::IRoute::OSPF
@ OSPF
managed by the given routing protocol
Definition: IRoute.h:35
inet::ospfv2::Ospfv2RoutingTableEntry::INTERAREA
@ INTERAREA
Definition: Ospfv2RoutingTableEntry.h:27
type
removed type
Definition: IUdp-gates.txt:7
inet::ospfv2::Ospfv2RoutingTableEntry::nextHops
std::vector< NextHop > nextHops
Definition: Ospfv2RoutingTableEntry.h:48
inet::ospfv2::Ospfv2RoutingTableEntry::linkStateOrigin
const Ospfv2Lsa * linkStateOrigin
Definition: Ospfv2RoutingTableEntry.h:47
inet::Ipv4Route::getInterface
NetworkInterface * getInterface() const override
Next hop interface.
Definition: Ipv4Route.h:83
inet::Ipv4Route::source
cObject * source
Object identifying the source.
Definition: Ipv4Route.h:35
inet::Ipv4Address::str
std::string str(bool printUnspec=true) const
Returns the string representation of the address (e.g.
Definition: Ipv4Address.cc:98
inet::ospfv2::Ospfv2RoutingTableEntry::AS_BOUNDARY_ROUTER_DESTINATION
static const unsigned char AS_BOUNDARY_ROUTER_DESTINATION
Definition: Ospfv2RoutingTableEntry.h:37
inet::Ipv4Route::setAdminDist
virtual void setAdminDist(unsigned int _adminDist) override
Definition: Ipv4Route.h:70
inet::ospfv2::Ospfv2RoutingTableEntry::ift
IInterfaceTable * ift
Definition: Ospfv2RoutingTableEntry.h:40
inet::Ipv4Route::getNetmask
const Ipv4Address & getNetmask() const
Represents length of prefix to match.
Definition: Ipv4Route.h:77
inet::ospfv2::Ospfv2RoutingTableEntry::type2Cost
Metric type2Cost
Definition: Ospfv2RoutingTableEntry.h:46
inet::Ipv4Route::setInterface
virtual void setInterface(NetworkInterface *_interfacePtr) override
Definition: Ipv4Route.h:67
inet::ospfv2::Ospfv2RoutingTableEntry::area
AreaId area
Definition: Ospfv2RoutingTableEntry.h:43
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::ospfv2::Ospfv2RoutingTableEntry::getPathTypeString
static const char * getPathTypeString(RoutingPathType pathType)
Definition: Ospfv2RoutingTableEntry.cc:169
inet::ospfv2::Ospfv2RoutingTableEntry::optionalCapabilities
Ospfv2Options optionalCapabilities
Definition: Ospfv2RoutingTableEntry.h:42
inet::ospfv2::Ospfv2RoutingTableEntry::INTRAAREA
@ INTRAAREA
Definition: Ospfv2RoutingTableEntry.h:26
inet::ospfv2::Ospfv2RoutingTableEntry::TYPE2_EXTERNAL
@ TYPE2_EXTERNAL
Definition: Ospfv2RoutingTableEntry.h:29
inet::ospfv2::Ospfv2RoutingTableEntry::pathType
RoutingPathType pathType
Definition: Ospfv2RoutingTableEntry.h:44
inet::Ipv4Route::setSourceType
virtual void setSourceType(SourceType _source) override
Definition: Ipv4Route.h:68