INET Framework for OMNeT++/OMNEST
inet::ospf::RoutingTableEntry Class Reference

#include <OSPFRoutingTableEntry.h>

Inheritance diagram for inet::ospf::RoutingTableEntry:
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::IPv4Route
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

 RoutingTableEntry (IInterfaceTable *ift)
 
 RoutingTableEntry (const RoutingTableEntry &entry)
 
virtual ~RoutingTableEntry ()
 
bool operator== (const RoutingTableEntry &entry) const
 
bool operator!= (const RoutingTableEntry &entry) const
 
void setDestinationType (RoutingDestinationType type)
 
RoutingDestinationType getDestinationType () const
 
void setOptionalCapabilities (OSPFOptions options)
 
OSPFOptions getOptionalCapabilities () const
 
void setArea (AreaID source)
 
AreaID getArea () const
 
void setPathType (RoutingPathType type)
 
RoutingPathType getPathType () const
 
void setCost (Metric pathCost)
 
Metric getCost () const
 
void setType2Cost (Metric pathCost)
 
Metric getType2Cost () const
 
void setLinkStateOrigin (const OSPFLSA *lsa)
 
const OSPFLSAgetLinkStateOrigin () const
 
void addNextHop (NextHop hop)
 
void clearNextHops ()
 
unsigned int getNextHopCount () const
 
NextHop getNextHop (unsigned int index) const
 
- Public Member Functions inherited from inet::IPv4Route
 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
 

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
 
OSPFOptions optionalCapabilities
 
AreaID area
 
RoutingPathType pathType = (RoutingPathType)-1
 
Metric cost = 0
 
Metric type2Cost = 0
 
const OSPFLSAlinkStateOrigin = nullptr
 
std::vector< NextHopnextHops
 

Additional Inherited Members

- Static Public Member Functions inherited from inet::IRoute
static const char * sourceTypeName (SourceType sourceType)
 
- Protected Member Functions inherited from inet::IPv4Route
void changed (int fieldCode)
 

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
INTRAAREA 
INTERAREA 
TYPE1_EXTERNAL 
TYPE2_EXTERNAL 
38  {
39  INTRAAREA = 0,
40  INTERAREA = 1,
41  TYPE1_EXTERNAL = 2,
42  TYPE2_EXTERNAL = 3
43  };
Definition: OSPFRoutingTableEntry.h:42
Definition: OSPFRoutingTableEntry.h:39
Definition: OSPFRoutingTableEntry.h:40
Definition: OSPFRoutingTableEntry.h:41

Constructor & Destructor Documentation

inet::ospf::RoutingTableEntry::RoutingTableEntry ( IInterfaceTable ift)
24  :
25  ift(_ift),
29 {
32 }
managed by the given routing protocol
Definition: IRoute.h:46
AreaID area
Definition: OSPFRoutingTableEntry.h:56
Definition: OSPFRoutingTableEntry.h:39
RoutingDestinationType destinationType
Definition: OSPFRoutingTableEntry.h:54
virtual void setSourceType(SourceType _source) override
Definition: IPv4Route.h:100
const AreaID BACKBONE_AREAID(0, 0, 0, 0)
static const unsigned char NETWORK_DESTINATION
Definition: OSPFRoutingTableEntry.h:48
RoutingPathType pathType
Definition: OSPFRoutingTableEntry.h:57
IInterfaceTable * ift
Definition: OSPFRoutingTableEntry.h:53
static const IPv4Address ALLONES_ADDRESS
255.255.255.255
Definition: IPv4Address.h:105
virtual void setNetmask(IPv4Address _netmask)
Definition: IPv4Route.h:97
inet::ospf::RoutingTableEntry::RoutingTableEntry ( const RoutingTableEntry entry)
34  :
35  destinationType(entry.destinationType),
36  optionalCapabilities(entry.optionalCapabilities),
37  area(entry.area),
38  pathType(entry.pathType),
39  cost(entry.cost),
40  type2Cost(entry.type2Cost),
41  linkStateOrigin(entry.linkStateOrigin),
42  nextHops(entry.nextHops)
43 {
44  setDestination(entry.getDestination());
45  setNetmask(entry.getNetmask());
46  setGateway(entry.getGateway());
47  setInterface(entry.getInterface());
48  setSourceType(entry.getSourceType());
49  setMetric(entry.getMetric());
50 }
Metric cost
Definition: OSPFRoutingTableEntry.h:58
AreaID area
Definition: OSPFRoutingTableEntry.h:56
OSPFOptions optionalCapabilities
Definition: OSPFRoutingTableEntry.h:55
RoutingDestinationType destinationType
Definition: OSPFRoutingTableEntry.h:54
virtual void setSourceType(SourceType _source) override
Definition: IPv4Route.h:100
virtual void setInterface(InterfaceEntry *_interfacePtr) override
Definition: IPv4Route.h:99
virtual void setGateway(IPv4Address _gateway)
Definition: IPv4Route.h:98
std::vector< NextHop > nextHops
Definition: OSPFRoutingTableEntry.h:61
const OSPFLSA * linkStateOrigin
Definition: OSPFRoutingTableEntry.h:60
virtual void setMetric(int _metric) override
Definition: IPv4Route.h:102
Metric type2Cost
Definition: OSPFRoutingTableEntry.h:59
RoutingPathType pathType
Definition: OSPFRoutingTableEntry.h:57
virtual void setDestination(IPv4Address _dest)
Definition: IPv4Route.h:96
virtual void setNetmask(IPv4Address _netmask)
Definition: IPv4Route.h:97
virtual inet::ospf::RoutingTableEntry::~RoutingTableEntry ( )
inlinevirtual
68 {}

Member Function Documentation

void inet::ospf::RoutingTableEntry::addNextHop ( NextHop  hop)

Referenced by inet::ospf::Router::calculateASExternalRoutes(), inet::ospf::Area::calculateInterAreaRoutes(), inet::ospf::Area::calculateShortestPathTree(), inet::ospf::Area::createRoutingTableEntryFromSummaryLSA(), and inet::ospf::Area::recheckSummaryLSAs().

89 {
90  if (nextHops.size() == 0) {
91  InterfaceEntry *routingInterface = ift->getInterfaceById(hop.ifIndex);
92 
93  setInterface(routingInterface);
94  // TODO: this used to be commented out, but it seems we need it
95  // otherwise gateways will never be filled in and gateway is needed for broadcast networks
96  setGateway(hop.hopAddress);
97  }
98  nextHops.push_back(hop);
99 }
virtual InterfaceEntry * getInterfaceById(int id) const =0
Returns an interface by its Id.
virtual void setInterface(InterfaceEntry *_interfacePtr) override
Definition: IPv4Route.h:99
virtual void setGateway(IPv4Address _gateway)
Definition: IPv4Route.h:98
std::vector< NextHop > nextHops
Definition: OSPFRoutingTableEntry.h:61
IInterfaceTable * ift
Definition: OSPFRoutingTableEntry.h:53
void inet::ospf::RoutingTableEntry::clearNextHops ( )
inline
const OSPFLSA* inet::ospf::RoutingTableEntry::getLinkStateOrigin ( ) const
inline
NextHop inet::ospf::RoutingTableEntry::getNextHop ( unsigned int  index) const
inline
unsigned int inet::ospf::RoutingTableEntry::getNextHopCount ( ) const
inline
OSPFOptions inet::ospf::RoutingTableEntry::getOptionalCapabilities ( ) const
inline
76 { return optionalCapabilities; }
OSPFOptions optionalCapabilities
Definition: OSPFRoutingTableEntry.h:55
Metric inet::ospf::RoutingTableEntry::getType2Cost ( ) const
inline

Referenced by inet::ospf::Router::calculateASExternalRoutes(), and inet::ospf::operator<<().

84 { return type2Cost; }
Metric type2Cost
Definition: OSPFRoutingTableEntry.h:59
bool inet::ospf::RoutingTableEntry::operator!= ( const RoutingTableEntry entry) const
inline
71 { return !((*this) == entry); }
bool inet::ospf::RoutingTableEntry::operator== ( const RoutingTableEntry entry) const
102 {
103  unsigned int hopCount = nextHops.size();
104  unsigned int i = 0;
105 
106  if (hopCount != entry.nextHops.size()) {
107  return false;
108  }
109  for (i = 0; i < hopCount; i++) {
110  if ((nextHops[i] != entry.nextHops[i])) {
111  return false;
112  }
113  }
114 
115  return (destinationType == entry.destinationType) &&
116  (getDestination() == entry.getDestination()) &&
117  (getNetmask() == entry.getNetmask()) &&
118  (optionalCapabilities == entry.optionalCapabilities) &&
119  (area == entry.area) &&
120  (pathType == entry.pathType) &&
121  (cost == entry.cost) &&
122  (type2Cost == entry.type2Cost) &&
123  (linkStateOrigin == entry.linkStateOrigin);
124 }
Metric cost
Definition: OSPFRoutingTableEntry.h:58
AreaID area
Definition: OSPFRoutingTableEntry.h:56
OSPFOptions optionalCapabilities
Definition: OSPFRoutingTableEntry.h:55
RoutingDestinationType destinationType
Definition: OSPFRoutingTableEntry.h:54
std::vector< NextHop > nextHops
Definition: OSPFRoutingTableEntry.h:61
const OSPFLSA * linkStateOrigin
Definition: OSPFRoutingTableEntry.h:60
Metric type2Cost
Definition: OSPFRoutingTableEntry.h:59
RoutingPathType pathType
Definition: OSPFRoutingTableEntry.h:57
IPv4Address getDestination() const
Destination address prefix to match.
Definition: IPv4Route.h:105
IPv4Address getNetmask() const
Represents length of prefix to match.
Definition: IPv4Route.h:108
void inet::ospf::RoutingTableEntry::setArea ( AreaID  source)
inline
void inet::ospf::RoutingTableEntry::setCost ( Metric  pathCost)

Referenced by inet::ospf::Router::calculateASExternalRoutes(), inet::ospf::Area::calculateShortestPathTree(), and inet::ospf::Area::createRoutingTableEntryFromSummaryLSA().

65 {
66  cost = pathCost;
67  // FIXME: this is a hack. But the correct way to do it is to implement a separate IIPv4RoutingTable module for OSPF...
69  setMetric(cost + type2Cost * 1000);
70  }
71  else {
72  setMetric(cost);
73  }
74 }
Metric cost
Definition: OSPFRoutingTableEntry.h:58
Definition: OSPFRoutingTableEntry.h:42
virtual void setMetric(int _metric) override
Definition: IPv4Route.h:102
Metric type2Cost
Definition: OSPFRoutingTableEntry.h:59
RoutingPathType pathType
Definition: OSPFRoutingTableEntry.h:57
void inet::ospf::RoutingTableEntry::setDestinationType ( RoutingDestinationType  type)
inline
void inet::ospf::RoutingTableEntry::setLinkStateOrigin ( const OSPFLSA lsa)
inline
void inet::ospf::RoutingTableEntry::setOptionalCapabilities ( OSPFOptions  options)
inline
void inet::ospf::RoutingTableEntry::setPathType ( RoutingPathType  type)

Referenced by inet::ospf::Router::calculateASExternalRoutes(), inet::ospf::Area::calculateShortestPathTree(), inet::ospf::Area::createRoutingTableEntryFromSummaryLSA(), and inet::ospf::Router::lookup().

53 {
54  pathType = type;
55  // FIXME: this is a hack. But the correct way to do it is to implement a separate IIPv4RoutingTable module for OSPF...
57  setMetric(cost + type2Cost * 1000);
58  }
59  else {
60  setMetric(cost);
61  }
62 }
Metric cost
Definition: OSPFRoutingTableEntry.h:58
Definition: OSPFRoutingTableEntry.h:42
virtual void setMetric(int _metric) override
Definition: IPv4Route.h:102
Metric type2Cost
Definition: OSPFRoutingTableEntry.h:59
RoutingPathType pathType
Definition: OSPFRoutingTableEntry.h:57
void inet::ospf::RoutingTableEntry::setType2Cost ( Metric  pathCost)

Referenced by inet::ospf::Router::calculateASExternalRoutes().

77 {
78  type2Cost = pathCost;
79  // FIXME: this is a hack. But the correct way to do it is to implement a separate IIPv4RoutingTable module for OSPF...
81  setMetric(cost + type2Cost * 1000);
82  }
83  else {
84  setMetric(cost);
85  }
86 }
Metric cost
Definition: OSPFRoutingTableEntry.h:58
Definition: OSPFRoutingTableEntry.h:42
virtual void setMetric(int _metric) override
Definition: IPv4Route.h:102
Metric type2Cost
Definition: OSPFRoutingTableEntry.h:59
RoutingPathType pathType
Definition: OSPFRoutingTableEntry.h:57

Member Data Documentation

AreaID inet::ospf::RoutingTableEntry::area
private

Referenced by operator==().

Metric inet::ospf::RoutingTableEntry::cost = 0
private
RoutingDestinationType inet::ospf::RoutingTableEntry::destinationType = 0
private

Referenced by operator==().

IInterfaceTable* inet::ospf::RoutingTableEntry::ift = nullptr
private

Referenced by addNextHop().

const OSPFLSA* inet::ospf::RoutingTableEntry::linkStateOrigin = nullptr
private

Referenced by operator==().

std::vector<NextHop> inet::ospf::RoutingTableEntry::nextHops
private

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

OSPFOptions inet::ospf::RoutingTableEntry::optionalCapabilities
private

Referenced by operator==().

RoutingPathType inet::ospf::RoutingTableEntry::pathType = (RoutingPathType)-1
private
Metric inet::ospf::RoutingTableEntry::type2Cost = 0
private

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