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

#include <OSPFArea.h>

Inheritance diagram for inet::ospf::Area:

Public Member Functions

 Area (IInterfaceTable *ift, AreaID id=BACKBONE_AREAID)
 
virtual ~Area ()
 
void setAreaID (AreaID areaId)
 
AreaID getAreaID () const
 
void addAddressRange (IPv4AddressRange addressRange, bool advertise)
 
unsigned int getAddressRangeCount () const
 
IPv4AddressRange getAddressRange (unsigned int index) const
 
void addHostRoute (HostRouteParameters &hostRouteParameters)
 
void setTransitCapability (bool transit)
 
bool getTransitCapability () const
 
void setExternalRoutingCapability (bool flooded)
 
bool getExternalRoutingCapability () const
 
void setStubDefaultCost (Metric cost)
 
Metric getStubDefaultCost () const
 
void setSPFTreeRoot (RouterLSA *root)
 
RouterLSAgetSPFTreeRoot ()
 
const RouterLSAgetSPFTreeRoot () const
 
void setRouter (Router *router)
 
RoutergetRouter ()
 
const RoutergetRouter () const
 
unsigned long getRouterLSACount () const
 
RouterLSAgetRouterLSA (unsigned long i)
 
const RouterLSAgetRouterLSA (unsigned long i) const
 
unsigned long getNetworkLSACount () const
 
NetworkLSAgetNetworkLSA (unsigned long i)
 
const NetworkLSAgetNetworkLSA (unsigned long i) const
 
unsigned long getSummaryLSACount () const
 
SummaryLSAgetSummaryLSA (unsigned long i)
 
const SummaryLSAgetSummaryLSA (unsigned long i) const
 
bool containsAddress (IPv4Address address) const
 
bool hasAddressRange (IPv4AddressRange addressRange) const
 
IPv4AddressRange getContainingAddressRange (IPv4AddressRange addressRange, bool *advertise=nullptr) const
 
void addInterface (Interface *intf)
 
InterfacegetInterface (unsigned char ifIndex)
 
InterfacegetInterface (IPv4Address address)
 
bool hasVirtualLink (AreaID withTransitArea) const
 
InterfacefindVirtualLink (RouterID routerID)
 
bool installRouterLSA (OSPFRouterLSA *lsa)
 
bool installNetworkLSA (OSPFNetworkLSA *lsa)
 
bool installSummaryLSA (OSPFSummaryLSA *lsa)
 
RouterLSAfindRouterLSA (LinkStateID linkStateID)
 
const RouterLSAfindRouterLSA (LinkStateID linkStateID) const
 
NetworkLSAfindNetworkLSA (LinkStateID linkStateID)
 
const NetworkLSAfindNetworkLSA (LinkStateID linkStateID) const
 
SummaryLSAfindSummaryLSA (LSAKeyType lsaKey)
 
const SummaryLSAfindSummaryLSA (LSAKeyType lsaKey) const
 
void ageDatabase ()
 
bool hasAnyNeighborInStates (int states) const
 
void removeFromAllRetransmissionLists (LSAKeyType lsaKey)
 
bool isOnAnyRetransmissionList (LSAKeyType lsaKey) const
 
bool floodLSA (OSPFLSA *lsa, Interface *intf=nullptr, Neighbor *neighbor=nullptr)
 
bool isLocalAddress (IPv4Address address) const
 
RouterLSAoriginateRouterLSA ()
 
NetworkLSAoriginateNetworkLSA (const Interface *intf)
 
SummaryLSAoriginateSummaryLSA (const RoutingTableEntry *entry, const std::map< LSAKeyType, bool, LSAKeyType_Less > &originatedLSAs, SummaryLSA *&lsaToReoriginate)
 
void calculateShortestPathTree (std::vector< RoutingTableEntry * > &newRoutingTable)
 
void calculateInterAreaRoutes (std::vector< RoutingTableEntry * > &newRoutingTable)
 
void recheckSummaryLSAs (std::vector< RoutingTableEntry * > &newRoutingTable)
 
std::string info () const override
 
std::string detailedInfo () const override
 

Private Member Functions

SummaryLSAoriginateSummaryLSA (const SummaryLSA *summaryLSA)
 
bool hasLink (OSPFLSA *fromLSA, OSPFLSA *toLSA) const
 
std::vector< NextHop > * calculateNextHops (OSPFLSA *destination, OSPFLSA *parent) const
 
std::vector< NextHop > * calculateNextHops (Link &destination, OSPFLSA *parent) const
 
LinkStateID getUniqueLinkStateID (IPv4AddressRange destination, Metric destinationCost, SummaryLSA *&lsaToReoriginate) const
 Returns a link state ID for the input destination. More...
 
bool findSameOrWorseCostRoute (const std::vector< RoutingTableEntry * > &newRoutingTable, const SummaryLSA &currentLSA, unsigned short currentCost, bool &destinationInRoutingTable, std::list< RoutingTableEntry * > &sameOrWorseCost) const
 Browse through the newRoutingTable looking for entries describing the same destination as the currentLSA. More...
 
RoutingTableEntrycreateRoutingTableEntryFromSummaryLSA (const SummaryLSA &summaryLSA, unsigned short entryCost, const RoutingTableEntry &borderRouterEntry) const
 Returns a new RoutingTableEntry based on the input SummaryLSA, with the input cost and the borderRouterEntry's next hops. More...
 

Private Attributes

IInterfaceTableift
 
AreaID areaID
 
std::map< IPv4AddressRange, bool > advertiseAddressRanges
 
std::vector< IPv4AddressRangeareaAddressRanges
 
std::vector< Interface * > associatedInterfaces
 
std::vector< HostRouteParametershostRoutes
 
std::map< LinkStateID, RouterLSA * > routerLSAsByID
 
std::vector< RouterLSA * > routerLSAs
 
std::map< LinkStateID, NetworkLSA * > networkLSAsByID
 
std::vector< NetworkLSA * > networkLSAs
 
std::map< LSAKeyType, SummaryLSA *, LSAKeyType_LesssummaryLSAsByID
 
std::vector< SummaryLSA * > summaryLSAs
 
bool transitCapability
 
bool externalRoutingCapability
 
Metric stubDefaultCost
 
RouterLSAspfTreeRoot
 
RouterparentRouter
 

Constructor & Destructor Documentation

inet::ospf::Area::Area ( IInterfaceTable ift,
AreaID  id = BACKBONE_AREAID 
)
26  :
27  ift(ift),
28  areaID(id),
29  transitCapability(false),
31  stubDefaultCost(1),
32  spfTreeRoot(nullptr),
33  parentRouter(nullptr)
34 {
35 }
bool externalRoutingCapability
Definition: OSPFArea.h:53
RouterLSA * spfTreeRoot
Definition: OSPFArea.h:55
bool transitCapability
Definition: OSPFArea.h:52
IInterfaceTable * ift
Definition: OSPFArea.h:40
Router * parentRouter
Definition: OSPFArea.h:57
AreaID areaID
Definition: OSPFArea.h:41
Metric stubDefaultCost
Definition: OSPFArea.h:54
inet::ospf::Area::~Area ( )
virtual
38 {
39  int interfaceNum = associatedInterfaces.size();
40  for (int i = 0; i < interfaceNum; i++) {
41  delete (associatedInterfaces[i]);
42  }
43  associatedInterfaces.clear();
44  long lsaCount = routerLSAs.size();
45  for (long j = 0; j < lsaCount; j++) {
46  delete routerLSAs[j];
47  }
48  routerLSAs.clear();
49  lsaCount = networkLSAs.size();
50  for (long k = 0; k < lsaCount; k++) {
51  delete networkLSAs[k];
52  }
53  networkLSAs.clear();
54  lsaCount = summaryLSAs.size();
55  for (long m = 0; m < lsaCount; m++) {
56  delete summaryLSAs[m];
57  }
58  summaryLSAs.clear();
59 }
std::vector< NetworkLSA * > networkLSAs
Definition: OSPFArea.h:49
std::vector< SummaryLSA * > summaryLSAs
Definition: OSPFArea.h:51
std::vector< RouterLSA * > routerLSAs
Definition: OSPFArea.h:47
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
const double k
Definition: QAM16Modulation.cc:24
value< double, units::m > m
Definition: Units.h:1047

Member Function Documentation

void inet::ospf::Area::addAddressRange ( IPv4AddressRange  addressRange,
bool  advertise 
)

Referenced by inet::ospf::OSPFConfigReader::loadAreaFromXML().

68 {
69  int addressRangeNum = areaAddressRanges.size();
70  bool found = false;
71  bool erased = false;
72 
73  for (int i = 0; i < addressRangeNum; i++) {
74  IPv4AddressRange curRange = areaAddressRanges[i];
75  if (curRange.contains(addressRange)) { // contains or same
76  found = true;
77  if (advertiseAddressRanges[curRange] != advertise) {
78  throw cRuntimeError("Inconsistent advertise settings for %s and %s address ranges in area %s",
79  addressRange.str().c_str(), curRange.str().c_str(), areaID.str(false).c_str());
80  }
81  }
82  else if (addressRange.contains(curRange)) {
83  if (advertiseAddressRanges[curRange] != advertise) {
84  throw cRuntimeError("Inconsistent advertise settings for %s and %s address ranges in area %s",
85  addressRange.str().c_str(), curRange.str().c_str(), areaID.str(false).c_str());
86  }
87  advertiseAddressRanges.erase(curRange);
89  erased = true;
90  }
91  }
92  if (erased && found) // the found entry contains new entry and new entry contains erased entry ==> the found entry also contains the erased entry
93  throw cRuntimeError("Model error: bad contents in areaAddressRanges vector");
94  if (erased) {
95  auto it = areaAddressRanges.begin();
96  while (it != areaAddressRanges.end()) {
97  if (*it == NULL_IPV4ADDRESSRANGE)
98  it = areaAddressRanges.erase(it);
99  else
100  it++;
101  }
102  }
103  if (!found) {
104  areaAddressRanges.push_back(addressRange);
105  advertiseAddressRanges[addressRange] = advertise;
106  }
107 }
std::string str(bool printUnspec=true) const
Returns the string representation of the address (e.g.
Definition: IPv4Address.cc:109
std::vector< IPv4AddressRange > areaAddressRanges
Definition: OSPFArea.h:43
std::map< IPv4AddressRange, bool > advertiseAddressRanges
Definition: OSPFArea.h:42
AreaID areaID
Definition: OSPFArea.h:41
const IPv4AddressRange NULL_IPV4ADDRESSRANGE(IPv4Address(0, 0, 0, 0), IPv4Address(0, 0, 0, 0))
void inet::ospf::Area::addHostRoute ( HostRouteParameters hostRouteParameters)
inline

Referenced by inet::ospf::OSPFConfigReader::loadHostRoute().

68 { hostRoutes.push_back(hostRouteParameters); }
std::vector< HostRouteParameters > hostRoutes
Definition: OSPFArea.h:45
void inet::ospf::Area::addInterface ( Interface intf)

Referenced by inet::ospf::OSPFConfigReader::loadInterfaceParameters(), and inet::ospf::OSPFConfigReader::loadVirtualLink().

62 {
63  intf->setArea(this);
64  associatedInterfaces.push_back(intf);
65 }
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
void inet::ospf::Area::ageDatabase ( )
395 {
396  long lsaCount = routerLSAs.size();
397  bool shouldRebuildRoutingTable = false;
398  long i;
399 
400  for (i = 0; i < lsaCount; i++) {
401  RouterLSA *lsa = routerLSAs[i];
402  unsigned short lsAge = lsa->getHeader().getLsAge();
403  bool selfOriginated = (lsa->getHeader().getAdvertisingRouter() == parentRouter->getRouterID());
404  bool unreachable = parentRouter->isDestinationUnreachable(lsa);
405 
406  if ((selfOriginated && (lsAge < (LS_REFRESH_TIME - 1))) || (!selfOriginated && (lsAge < (MAX_AGE - 1)))) {
407  lsa->getHeader().setLsAge(lsAge + 1);
408  if ((lsAge + 1) % CHECK_AGE == 0) {
409  if (!lsa->validateLSChecksum()) {
410  EV_ERROR << "Invalid LS checksum. Memory error detected!\n";
411  }
412  }
413  lsa->incrementInstallTime();
414  }
415  if (selfOriginated && (lsAge == (LS_REFRESH_TIME - 1))) {
416  if (unreachable) {
417  lsa->getHeader().setLsAge(MAX_AGE);
418  floodLSA(lsa);
419  lsa->incrementInstallTime();
420  }
421  else {
422  long sequenceNumber = lsa->getHeader().getLsSequenceNumber();
423  if (sequenceNumber == MAX_SEQUENCE_NUMBER) {
424  lsa->getHeader().setLsAge(MAX_AGE);
425  floodLSA(lsa);
426  lsa->incrementInstallTime();
427  }
428  else {
429  RouterLSA *newLSA = originateRouterLSA();
430 
431  newLSA->getHeader().setLsSequenceNumber(sequenceNumber + 1);
432  shouldRebuildRoutingTable |= lsa->update(newLSA);
433  delete newLSA;
434 
435  floodLSA(lsa);
436  }
437  }
438  }
439  if (!selfOriginated && (lsAge == MAX_AGE - 1)) {
440  lsa->getHeader().setLsAge(MAX_AGE);
441  floodLSA(lsa);
442  lsa->incrementInstallTime();
443  }
444  if (lsAge == MAX_AGE) {
445  LSAKeyType lsaKey;
446 
447  lsaKey.linkStateID = lsa->getHeader().getLinkStateID();
448  lsaKey.advertisingRouter = lsa->getHeader().getAdvertisingRouter();
449 
450  if (!isOnAnyRetransmissionList(lsaKey) &&
452  {
453  if (!selfOriginated || unreachable) {
454  routerLSAsByID.erase(lsa->getHeader().getLinkStateID());
455  delete lsa;
456  routerLSAs[i] = nullptr;
457  shouldRebuildRoutingTable = true;
458  }
459  else {
460  RouterLSA *newLSA = originateRouterLSA();
461  long sequenceNumber = lsa->getHeader().getLsSequenceNumber();
462 
463  newLSA->getHeader().setLsSequenceNumber((sequenceNumber == MAX_SEQUENCE_NUMBER) ? INITIAL_SEQUENCE_NUMBER : sequenceNumber + 1);
464  shouldRebuildRoutingTable |= lsa->update(newLSA);
465  delete newLSA;
466 
467  floodLSA(lsa);
468  }
469  }
470  }
471  }
472 
473  auto routerIt = routerLSAs.begin();
474  while (routerIt != routerLSAs.end()) {
475  if ((*routerIt) == nullptr) {
476  routerIt = routerLSAs.erase(routerIt);
477  }
478  else {
479  routerIt++;
480  }
481  }
482 
483  lsaCount = networkLSAs.size();
484  for (i = 0; i < lsaCount; i++) {
485  unsigned short lsAge = networkLSAs[i]->getHeader().getLsAge();
486  bool unreachable = parentRouter->isDestinationUnreachable(networkLSAs[i]);
487  NetworkLSA *lsa = networkLSAs[i];
488  Interface *localIntf = getInterface(lsa->getHeader().getLinkStateID());
489  bool selfOriginated = false;
490 
491  if ((localIntf != nullptr) &&
492  (localIntf->getState() == Interface::DESIGNATED_ROUTER_STATE) &&
493  (localIntf->getNeighborCount() > 0) &&
494  (localIntf->hasAnyNeighborInStates(Neighbor::FULL_STATE)))
495  {
496  selfOriginated = true;
497  }
498 
499  if ((selfOriginated && (lsAge < (LS_REFRESH_TIME - 1))) || (!selfOriginated && (lsAge < (MAX_AGE - 1)))) {
500  lsa->getHeader().setLsAge(lsAge + 1);
501  if ((lsAge + 1) % CHECK_AGE == 0) {
502  if (!lsa->validateLSChecksum()) {
503  EV_ERROR << "Invalid LS checksum. Memory error detected!\n";
504  }
505  }
506  lsa->incrementInstallTime();
507  }
508  if (selfOriginated && (lsAge == (LS_REFRESH_TIME - 1))) {
509  if (unreachable) {
510  lsa->getHeader().setLsAge(MAX_AGE);
511  floodLSA(lsa);
512  lsa->incrementInstallTime();
513  }
514  else {
515  long sequenceNumber = lsa->getHeader().getLsSequenceNumber();
516  if (sequenceNumber == MAX_SEQUENCE_NUMBER) {
517  lsa->getHeader().setLsAge(MAX_AGE);
518  floodLSA(lsa);
519  lsa->incrementInstallTime();
520  }
521  else {
522  NetworkLSA *newLSA = originateNetworkLSA(localIntf);
523 
524  if (newLSA != nullptr) {
525  newLSA->getHeader().setLsSequenceNumber(sequenceNumber + 1);
526  shouldRebuildRoutingTable |= lsa->update(newLSA);
527  delete newLSA;
528  }
529  else { // no neighbors on the network -> old NetworkLSA must be flushed
530  lsa->getHeader().setLsAge(MAX_AGE);
531  lsa->incrementInstallTime();
532  }
533 
534  floodLSA(lsa);
535  }
536  }
537  }
538  if (!selfOriginated && (lsAge == MAX_AGE - 1)) {
539  lsa->getHeader().setLsAge(MAX_AGE);
540  floodLSA(lsa);
541  lsa->incrementInstallTime();
542  }
543  if (lsAge == MAX_AGE) {
544  LSAKeyType lsaKey;
545 
546  lsaKey.linkStateID = lsa->getHeader().getLinkStateID();
547  lsaKey.advertisingRouter = lsa->getHeader().getAdvertisingRouter();
548 
549  if (!isOnAnyRetransmissionList(lsaKey) &&
551  {
552  if (!selfOriginated || unreachable) {
553  networkLSAsByID.erase(lsa->getHeader().getLinkStateID());
554  delete lsa;
555  networkLSAs[i] = nullptr;
556  shouldRebuildRoutingTable = true;
557  }
558  else {
559  NetworkLSA *newLSA = originateNetworkLSA(localIntf);
560  long sequenceNumber = lsa->getHeader().getLsSequenceNumber();
561 
562  if (newLSA != nullptr) {
563  newLSA->getHeader().setLsSequenceNumber((sequenceNumber == MAX_SEQUENCE_NUMBER) ? INITIAL_SEQUENCE_NUMBER : sequenceNumber + 1);
564  shouldRebuildRoutingTable |= lsa->update(newLSA);
565  delete newLSA;
566 
567  floodLSA(lsa);
568  }
569  else { // no neighbors on the network -> old NetworkLSA must be deleted
570  delete networkLSAs[i];
571  }
572  }
573  }
574  }
575  }
576 
577  auto networkIt = networkLSAs.begin();
578  while (networkIt != networkLSAs.end()) {
579  if ((*networkIt) == nullptr) {
580  networkIt = networkLSAs.erase(networkIt);
581  }
582  else {
583  networkIt++;
584  }
585  }
586 
587  lsaCount = summaryLSAs.size();
588  for (i = 0; i < lsaCount; i++) {
589  unsigned short lsAge = summaryLSAs[i]->getHeader().getLsAge();
590  bool selfOriginated = (summaryLSAs[i]->getHeader().getAdvertisingRouter() == parentRouter->getRouterID());
591  bool unreachable = parentRouter->isDestinationUnreachable(summaryLSAs[i]);
592  SummaryLSA *lsa = summaryLSAs[i];
593 
594  if ((selfOriginated && (lsAge < (LS_REFRESH_TIME - 1))) || (!selfOriginated && (lsAge < (MAX_AGE - 1)))) {
595  lsa->getHeader().setLsAge(lsAge + 1);
596  if ((lsAge + 1) % CHECK_AGE == 0) {
597  if (!lsa->validateLSChecksum()) {
598  EV_ERROR << "Invalid LS checksum. Memory error detected!\n";
599  }
600  }
601  lsa->incrementInstallTime();
602  }
603  if (selfOriginated && (lsAge == (LS_REFRESH_TIME - 1))) {
604  if (unreachable) {
605  lsa->getHeader().setLsAge(MAX_AGE);
606  floodLSA(lsa);
607  lsa->incrementInstallTime();
608  }
609  else {
610  long sequenceNumber = lsa->getHeader().getLsSequenceNumber();
611  if (sequenceNumber == MAX_SEQUENCE_NUMBER) {
612  lsa->getHeader().setLsAge(MAX_AGE);
613  floodLSA(lsa);
614  lsa->incrementInstallTime();
615  }
616  else {
617  SummaryLSA *newLSA = originateSummaryLSA(lsa);
618 
619  if (newLSA != nullptr) {
620  newLSA->getHeader().setLsSequenceNumber(sequenceNumber + 1);
621  shouldRebuildRoutingTable |= lsa->update(newLSA);
622  delete newLSA;
623 
624  floodLSA(lsa);
625  }
626  else {
627  lsa->getHeader().setLsAge(MAX_AGE);
628  floodLSA(lsa);
629  lsa->incrementInstallTime();
630  }
631  }
632  }
633  }
634  if (!selfOriginated && (lsAge == MAX_AGE - 1)) {
635  lsa->getHeader().setLsAge(MAX_AGE);
636  floodLSA(lsa);
637  lsa->incrementInstallTime();
638  }
639  if (lsAge == MAX_AGE) {
640  LSAKeyType lsaKey;
641 
642  lsaKey.linkStateID = lsa->getHeader().getLinkStateID();
643  lsaKey.advertisingRouter = lsa->getHeader().getAdvertisingRouter();
644 
645  if (!isOnAnyRetransmissionList(lsaKey) &&
647  {
648  if (!selfOriginated || unreachable) {
649  summaryLSAsByID.erase(lsaKey);
650  delete lsa;
651  summaryLSAs[i] = nullptr;
652  shouldRebuildRoutingTable = true;
653  }
654  else {
655  SummaryLSA *newLSA = originateSummaryLSA(lsa);
656  if (newLSA != nullptr) {
657  long sequenceNumber = lsa->getHeader().getLsSequenceNumber();
658 
659  newLSA->getHeader().setLsSequenceNumber((sequenceNumber == MAX_SEQUENCE_NUMBER) ? INITIAL_SEQUENCE_NUMBER : sequenceNumber + 1);
660  shouldRebuildRoutingTable |= lsa->update(newLSA);
661  delete newLSA;
662 
663  floodLSA(lsa);
664  }
665  else {
666  summaryLSAsByID.erase(lsaKey);
667  delete lsa;
668  summaryLSAs[i] = nullptr;
669  shouldRebuildRoutingTable = true;
670  }
671  }
672  }
673  }
674  }
675 
676  auto summaryIt = summaryLSAs.begin();
677  while (summaryIt != summaryLSAs.end()) {
678  if ((*summaryIt) == nullptr) {
679  summaryIt = summaryLSAs.erase(summaryIt);
680  }
681  else {
682  summaryIt++;
683  }
684  }
685 
686  long interfaceCount = associatedInterfaces.size();
687  for (long m = 0; m < interfaceCount; m++) {
688  associatedInterfaces[m]->ageTransmittedLSALists();
689  }
690 
691  if (shouldRebuildRoutingTable) {
693  }
694 }
std::map< LinkStateID, RouterLSA * > routerLSAsByID
Definition: OSPFArea.h:46
std::vector< NetworkLSA * > networkLSAs
Definition: OSPFArea.h:49
#define INITIAL_SEQUENCE_NUMBER
Definition: OSPFcommon.h:42
std::vector< SummaryLSA * > summaryLSAs
Definition: OSPFArea.h:51
bool hasAnyNeighborInStates(int states) const
Definition: OSPFArea.cc:696
Interface * getInterface(unsigned char ifIndex)
Definition: OSPFArea.cc:205
std::map< LSAKeyType, SummaryLSA *, LSAKeyType_Less > summaryLSAsByID
Definition: OSPFArea.h:50
bool isDestinationUnreachable(OSPFLSA *lsa) const
Returns true if the destination described by the input lsa is in the routing table, false otherwise.
Definition: OSPFRouter.cc:493
std::vector< RouterLSA * > routerLSAs
Definition: OSPFArea.h:47
RouterID getRouterID() const
Definition: OSPFRouter.h:72
#define CHECK_AGE
Definition: OSPFcommon.h:37
Definition: OSPFNeighbor.h:68
#define MAX_SEQUENCE_NUMBER
Definition: OSPFcommon.h:43
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
SummaryLSA * originateSummaryLSA(const RoutingTableEntry *entry, const std::map< LSAKeyType, bool, LSAKeyType_Less > &originatedLSAs, SummaryLSA *&lsaToReoriginate)
Definition: OSPFArea.cc:1101
#define MAX_AGE
Definition: OSPFcommon.h:36
#define LS_REFRESH_TIME
Definition: OSPFcommon.h:33
RouterLSA * originateRouterLSA()
Definition: OSPFArea.cc:751
NetworkLSA * originateNetworkLSA(const Interface *intf)
Definition: OSPFArea.cc:995
Router * parentRouter
Definition: OSPFArea.h:57
Definition: OSPFNeighbor.h:69
std::map< LinkStateID, NetworkLSA * > networkLSAsByID
Definition: OSPFArea.h:48
Definition: OSPFNeighbor.h:67
bool isOnAnyRetransmissionList(LSAKeyType lsaKey) const
Definition: OSPFArea.cc:715
value< double, units::m > m
Definition: Units.h:1047
bool floodLSA(OSPFLSA *lsa, Interface *intf=nullptr, Neighbor *neighbor=nullptr)
Definition: OSPFArea.cc:726
void rebuildRoutingTable()
Rebuilds the routing table from scratch(based on the LSA database).
Definition: OSPFRouter.cc:704
void inet::ospf::Area::calculateInterAreaRoutes ( std::vector< RoutingTableEntry * > &  newRoutingTable)
See also
RFC 2328 Section 16.2.
Todo:
This function does a lot of lookup in the input newRoutingTable. Restructuring the input vector into some kind of hash would quite probably speed up execution.

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

2296 {
2297  unsigned long i = 0;
2298  unsigned long j = 0;
2299  unsigned long lsaCount = summaryLSAs.size();
2300 
2301  for (i = 0; i < lsaCount; i++) {
2302  SummaryLSA *currentLSA = summaryLSAs[i];
2303  OSPFLSAHeader& currentHeader = currentLSA->getHeader();
2304 
2305  unsigned long routeCost = currentLSA->getRouteCost();
2306  unsigned short lsAge = currentHeader.getLsAge();
2307  RouterID originatingRouter = currentHeader.getAdvertisingRouter();
2308  bool selfOriginated = (originatingRouter == parentRouter->getRouterID());
2309 
2310  if ((routeCost == LS_INFINITY) || (lsAge == MAX_AGE) || (selfOriginated)) { // (1) and(2)
2311  continue;
2312  }
2313 
2314  char lsType = currentHeader.getLsType();
2315  unsigned long routeCount = newRoutingTable.size();
2316  IPv4AddressRange destination;
2317 
2318  destination.address = currentHeader.getLinkStateID();
2319  destination.mask = currentLSA->getNetworkMask();
2320 
2321  if ((lsType == SUMMARYLSA_NETWORKS_TYPE) && (parentRouter->hasAddressRange(destination))) { // (3)
2322  bool foundIntraAreaRoute = false;
2323 
2324  // look for an "Active" INTRAAREA route
2325  for (j = 0; j < routeCount; j++) {
2326  RoutingTableEntry *routingEntry = newRoutingTable[j];
2327 
2328  if ((routingEntry->getDestinationType() == RoutingTableEntry::NETWORK_DESTINATION) &&
2329  (routingEntry->getPathType() == RoutingTableEntry::INTRAAREA) &&
2330  destination.containedByRange(routingEntry->getDestination(), routingEntry->getNetmask()))
2331  {
2332  foundIntraAreaRoute = true;
2333  break;
2334  }
2335  }
2336  if (foundIntraAreaRoute) {
2337  continue;
2338  }
2339  }
2340 
2341  RoutingTableEntry *borderRouterEntry = nullptr;
2342 
2343  // The routingEntry describes a route to an other area -> look for the border router originating it
2344  for (j = 0; j < routeCount; j++) { // (4) N == destination, BR == borderRouterEntry
2345  RoutingTableEntry *routingEntry = newRoutingTable[j];
2346 
2347  if ((routingEntry->getArea() == areaID) &&
2348  (((routingEntry->getDestinationType() & RoutingTableEntry::AREA_BORDER_ROUTER_DESTINATION) != 0) ||
2349  ((routingEntry->getDestinationType() & RoutingTableEntry::AS_BOUNDARY_ROUTER_DESTINATION) != 0)) &&
2350  (routingEntry->getDestination() == originatingRouter))
2351  {
2352  borderRouterEntry = routingEntry;
2353  break;
2354  }
2355  }
2356  if (borderRouterEntry == nullptr) {
2357  continue;
2358  }
2359  else { // (5)
2360  /* "Else, this LSA describes an inter-area path to destination N,
2361  * whose cost is the distance to BR plus the cost specified in the LSA.
2362  * Call the cost of this inter-area path IAC."
2363  */
2364  bool destinationInRoutingTable = true;
2365  unsigned short currentCost = routeCost + borderRouterEntry->getCost();
2366  std::list<RoutingTableEntry *> sameOrWorseCost;
2367 
2368  if (findSameOrWorseCostRoute(newRoutingTable,
2369  *currentLSA,
2370  currentCost,
2371  destinationInRoutingTable,
2372  sameOrWorseCost))
2373  {
2374  continue;
2375  }
2376 
2377  if (destinationInRoutingTable && (sameOrWorseCost.size() > 0)) {
2378  RoutingTableEntry *equalEntry = nullptr;
2379 
2380  /* Look for an equal cost entry in the sameOrWorseCost list, and
2381  * also clear the more expensive entries from the newRoutingTable.
2382  */
2383  //FIXME The code does not work according to the comment
2384  for (auto checkedEntry : sameOrWorseCost) {
2385  if (checkedEntry->getCost() > currentCost) {
2386  for (auto entryIt = newRoutingTable.begin(); entryIt != newRoutingTable.end(); entryIt++) {
2387  if (checkedEntry == (*entryIt)) {
2388  newRoutingTable.erase(entryIt);
2389  break;
2390  }
2391  }
2392  }
2393  else { // EntryCost == currentCost
2394  equalEntry = checkedEntry; // should be only one - if there are more they are ignored
2395  }
2396  }
2397 
2398  unsigned long nextHopCount = borderRouterEntry->getNextHopCount();
2399 
2400  if (equalEntry != nullptr) {
2401  /* Add the next hops of the border router advertising this destination
2402  * to the equal entry.
2403  */
2404  for (unsigned long j = 0; j < nextHopCount; j++) {
2405  equalEntry->addNextHop(borderRouterEntry->getNextHop(j));
2406  }
2407  }
2408  else {
2409  RoutingTableEntry *newEntry = createRoutingTableEntryFromSummaryLSA(*currentLSA, currentCost, *borderRouterEntry);
2410  ASSERT(newEntry != nullptr);
2411  newRoutingTable.push_back(newEntry);
2412  }
2413  }
2414  else {
2415  RoutingTableEntry *newEntry = createRoutingTableEntryFromSummaryLSA(*currentLSA, currentCost, *borderRouterEntry);
2416  ASSERT(newEntry != nullptr);
2417  newRoutingTable.push_back(newEntry);
2418  }
2419  }
2420  }
2421 }
bool hasAddressRange(const IPv4AddressRange &addressRange) const
Returns true if one of the Router&#39;s Areas the same IPv4 address range configured as the input IPv4 ad...
Definition: OSPFRouter.cc:466
std::vector< SummaryLSA * > summaryLSAs
Definition: OSPFArea.h:51
Definition: OSPFRoutingTableEntry.h:39
RouterID getRouterID() const
Definition: OSPFRouter.h:72
static const unsigned char NETWORK_DESTINATION
Definition: OSPFRoutingTableEntry.h:48
static const unsigned char AS_BOUNDARY_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:50
bool findSameOrWorseCostRoute(const std::vector< RoutingTableEntry * > &newRoutingTable, const SummaryLSA &currentLSA, unsigned short currentCost, bool &destinationInRoutingTable, std::list< RoutingTableEntry * > &sameOrWorseCost) const
Browse through the newRoutingTable looking for entries describing the same destination as the current...
Definition: OSPFArea.cc:2188
static const unsigned char AREA_BORDER_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:49
#define LS_INFINITY
Definition: TED.cc:32
RoutingTableEntry * createRoutingTableEntryFromSummaryLSA(const SummaryLSA &summaryLSA, unsigned short entryCost, const RoutingTableEntry &borderRouterEntry) const
Returns a new RoutingTableEntry based on the input SummaryLSA, with the input cost and the borderRout...
Definition: OSPFArea.cc:2254
#define MAX_AGE
Definition: OSPFcommon.h:36
IPv4Address getNetworkMask() const
Returns an address with the network mask corresponding to the address class.
Definition: IPv4Address.cc:189
Router * parentRouter
Definition: OSPFArea.h:57
IPv4Address RouterID
Definition: OSPFcommon.h:137
AreaID areaID
Definition: OSPFArea.h:41
Definition: OSPFPacket_m.h:247
std::vector< NextHop > * inet::ospf::Area::calculateNextHops ( OSPFLSA destination,
OSPFLSA parent 
) const
private

Referenced by calculateShortestPathTree().

1888 {
1889  std::vector<NextHop> *hops = new std::vector<NextHop>;
1890  unsigned long i, j;
1891 
1892  RouterLSA *routerLSA = dynamic_cast<RouterLSA *>(parent);
1893  if (routerLSA != nullptr) {
1894  if (routerLSA != spfTreeRoot) {
1895  unsigned int nextHopCount = routerLSA->getNextHopCount();
1896  for (i = 0; i < nextHopCount; i++) {
1897  hops->push_back(routerLSA->getNextHop(i));
1898  }
1899  return hops;
1900  }
1901  else {
1902  RouterLSA *destinationRouterLSA = dynamic_cast<RouterLSA *>(destination);
1903  if (destinationRouterLSA != nullptr) {
1904  unsigned long interfaceNum = associatedInterfaces.size();
1905  for (i = 0; i < interfaceNum; i++) {
1906  Interface::OSPFInterfaceType intfType = associatedInterfaces[i]->getType();
1907  if ((intfType == Interface::POINTTOPOINT) ||
1908  ((intfType == Interface::VIRTUAL) &&
1909  (associatedInterfaces[i]->getState() > Interface::LOOPBACK_STATE)))
1910  {
1911  Neighbor *ptpNeighbor = associatedInterfaces[i]->getNeighborCount() > 0 ? associatedInterfaces[i]->getNeighbor(0) : nullptr;
1912  if (ptpNeighbor != nullptr) {
1913  if (ptpNeighbor->getNeighborID() == destinationRouterLSA->getHeader().getLinkStateID()) {
1914  NextHop nextHop;
1915  nextHop.ifIndex = associatedInterfaces[i]->getIfIndex();
1916  nextHop.hopAddress = ptpNeighbor->getAddress();
1917  nextHop.advertisingRouter = destinationRouterLSA->getHeader().getAdvertisingRouter();
1918  hops->push_back(nextHop);
1919  break;
1920  }
1921  }
1922  }
1923  if (intfType == Interface::POINTTOMULTIPOINT) {
1924  Neighbor *ptmpNeighbor = associatedInterfaces[i]->getNeighborByID(destinationRouterLSA->getHeader().getLinkStateID());
1925  if (ptmpNeighbor != nullptr) {
1926  unsigned int linkCount = destinationRouterLSA->getLinksArraySize();
1927  IPv4Address rootID = IPv4Address(parentRouter->getRouterID());
1928  for (j = 0; j < linkCount; j++) {
1929  Link& link = destinationRouterLSA->getLinks(j);
1930  if (link.getLinkID() == rootID) {
1931  NextHop nextHop;
1932  nextHop.ifIndex = associatedInterfaces[i]->getIfIndex();
1933  nextHop.hopAddress = IPv4Address(link.getLinkData());
1934  nextHop.advertisingRouter = destinationRouterLSA->getHeader().getAdvertisingRouter();
1935  hops->push_back(nextHop);
1936  }
1937  }
1938  break;
1939  }
1940  }
1941  }
1942  }
1943  else {
1944  NetworkLSA *destinationNetworkLSA = dynamic_cast<NetworkLSA *>(destination);
1945  if (destinationNetworkLSA != nullptr) {
1946  IPv4Address networkDesignatedRouter = destinationNetworkLSA->getHeader().getLinkStateID();
1947  unsigned long interfaceNum = associatedInterfaces.size();
1948  for (i = 0; i < interfaceNum; i++) {
1949  Interface::OSPFInterfaceType intfType = associatedInterfaces[i]->getType();
1950  if (((intfType == Interface::BROADCAST) ||
1951  (intfType == Interface::NBMA)) &&
1952  (associatedInterfaces[i]->getDesignatedRouter().ipInterfaceAddress == networkDesignatedRouter))
1953  {
1954  IPv4AddressRange range = associatedInterfaces[i]->getAddressRange();
1955  NextHop nextHop;
1956 
1957  nextHop.ifIndex = associatedInterfaces[i]->getIfIndex();
1958  //nextHop.hopAddress = (range.address & range.mask); //TODO revise it!
1959  nextHop.hopAddress = IPv4Address::UNSPECIFIED_ADDRESS; //TODO revise it!
1960  nextHop.advertisingRouter = destinationNetworkLSA->getHeader().getAdvertisingRouter();
1961  hops->push_back(nextHop);
1962  }
1963  }
1964  }
1965  }
1966  }
1967  }
1968  else {
1969  NetworkLSA *networkLSA = dynamic_cast<NetworkLSA *>(parent);
1970  if (networkLSA != nullptr) {
1971  if (networkLSA->getParent() != spfTreeRoot) {
1972  unsigned int nextHopCount = networkLSA->getNextHopCount();
1973  for (i = 0; i < nextHopCount; i++) {
1974  hops->push_back(networkLSA->getNextHop(i));
1975  }
1976  return hops;
1977  }
1978  else {
1979  IPv4Address parentLinkStateID = parent->getHeader().getLinkStateID();
1980 
1981  RouterLSA *destinationRouterLSA = dynamic_cast<RouterLSA *>(destination);
1982  if (destinationRouterLSA != nullptr) {
1983  RouterID destinationRouterID = destinationRouterLSA->getHeader().getLinkStateID();
1984  unsigned int linkCount = destinationRouterLSA->getLinksArraySize();
1985  for (i = 0; i < linkCount; i++) {
1986  Link& link = destinationRouterLSA->getLinks(i);
1987  NextHop nextHop;
1988 
1989  if (((link.getType() == TRANSIT_LINK) &&
1990  (link.getLinkID() == parentLinkStateID)) ||
1991  ((link.getType() == STUB_LINK) &&
1992  ((link.getLinkID() & IPv4Address(link.getLinkData())) == (parentLinkStateID & networkLSA->getNetworkMask()))))
1993  {
1994  unsigned long interfaceNum = associatedInterfaces.size();
1995  for (j = 0; j < interfaceNum; j++) {
1996  Interface::OSPFInterfaceType intfType = associatedInterfaces[j]->getType();
1997  if (((intfType == Interface::BROADCAST) ||
1998  (intfType == Interface::NBMA)) &&
1999  (associatedInterfaces[j]->getDesignatedRouter().ipInterfaceAddress == parentLinkStateID))
2000  {
2001  Neighbor *nextHopNeighbor = associatedInterfaces[j]->getNeighborByID(destinationRouterID);
2002  if (nextHopNeighbor != nullptr) {
2003  nextHop.ifIndex = associatedInterfaces[j]->getIfIndex();
2004  nextHop.hopAddress = nextHopNeighbor->getAddress();
2005  nextHop.advertisingRouter = destinationRouterLSA->getHeader().getAdvertisingRouter();
2006  hops->push_back(nextHop);
2007  }
2008  }
2009  }
2010  }
2011  }
2012  }
2013  }
2014  }
2015  }
2016 
2017  return hops;
2018 }
Definition: OSPFInterface.h:60
Definition: OSPFInterface.h:65
Definition: OSPFInterface.h:56
RouterID getRouterID() const
Definition: OSPFRouter.h:72
Definition: OSPFPacket_m.h:378
Definition: OSPFInterface.h:58
Definition: OSPFPacket_m.h:377
RouterLSA * spfTreeRoot
Definition: OSPFArea.h:55
Definition: OSPFInterface.h:57
Definition: OSPFInterface.h:59
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
static const IPv4Address UNSPECIFIED_ADDRESS
0.0.0.0
Definition: IPv4Address.h:102
IPv4Address NextHop
Definition: BGPCommon.h:51
Router * parentRouter
Definition: OSPFArea.h:57
IPv4Address RouterID
Definition: OSPFcommon.h:137
OSPFInterfaceType
Definition: OSPFInterface.h:54
std::vector< NextHop > * inet::ospf::Area::calculateNextHops ( Link destination,
OSPFLSA parent 
) const
private
2021 {
2022  std::vector<NextHop> *hops = new std::vector<NextHop>;
2023  unsigned long i;
2024 
2025  RouterLSA *routerLSA = check_and_cast<RouterLSA *>(parent);
2026  if (routerLSA != spfTreeRoot) {
2027  unsigned int nextHopCount = routerLSA->getNextHopCount();
2028  for (i = 0; i < nextHopCount; i++) {
2029  hops->push_back(routerLSA->getNextHop(i));
2030  }
2031  return hops;
2032  }
2033  else {
2034  unsigned long interfaceNum = associatedInterfaces.size();
2035  for (i = 0; i < interfaceNum; i++) {
2036  Interface *interface = associatedInterfaces[i];
2037  Interface::OSPFInterfaceType intfType = interface->getType();
2038 
2039  if ((intfType == Interface::POINTTOPOINT) ||
2040  ((intfType == Interface::VIRTUAL) &&
2041  (interface->getState() > Interface::LOOPBACK_STATE)))
2042  {
2043  Neighbor *neighbor = (interface->getNeighborCount() > 0) ? interface->getNeighbor(0) : nullptr;
2044  if (neighbor != nullptr) {
2045  IPv4Address neighborAddress = neighbor->getAddress();
2046  if (((neighborAddress != NULL_IPV4ADDRESS) &&
2047  (neighborAddress == destination.getLinkID())) ||
2048  ((neighborAddress == NULL_IPV4ADDRESS) &&
2049  (interface->getAddressRange().address == destination.getLinkID()) &&
2050  (interface->getAddressRange().mask.getInt() == destination.getLinkData())))
2051  {
2052  NextHop nextHop;
2053  nextHop.ifIndex = interface->getIfIndex();
2054  nextHop.hopAddress = neighborAddress;
2055  nextHop.advertisingRouter = parentRouter->getRouterID();
2056  hops->push_back(nextHop);
2057  break;
2058  }
2059  }
2060  }
2061  if ((intfType == Interface::BROADCAST) ||
2062  (intfType == Interface::NBMA))
2063  {
2064  if (isSameNetwork(destination.getLinkID(), IPv4Address(destination.getLinkData()), interface->getAddressRange().address, interface->getAddressRange().mask)) {
2065  NextHop nextHop;
2066  nextHop.ifIndex = interface->getIfIndex();
2067  // TODO: this has been commented because the linkID is not a real IP address in this case and we don't know the next hop address here, verify
2068  // nextHop.hopAddress = destination.getLinkID();
2069  nextHop.advertisingRouter = parentRouter->getRouterID();
2070  hops->push_back(nextHop);
2071  break;
2072  }
2073  }
2074  if (intfType == Interface::POINTTOMULTIPOINT) {
2075  if (destination.getType() == STUB_LINK) {
2076  if (destination.getLinkID() == interface->getAddressRange().address) {
2077  // The link contains the router's own interface address and a full mask,
2078  // so we insert a next hop pointing to the interface itself. Kind of pointless, but
2079  // not much else we could do...
2080  // TODO: check what other OSPF implementations do in this situation
2081  NextHop nextHop;
2082  nextHop.ifIndex = interface->getIfIndex();
2083  nextHop.hopAddress = interface->getAddressRange().address;
2084  nextHop.advertisingRouter = parentRouter->getRouterID();
2085  hops->push_back(nextHop);
2086  break;
2087  }
2088  }
2089  if (destination.getType() == POINTTOPOINT_LINK) {
2090  Neighbor *neighbor = interface->getNeighborByID(destination.getLinkID());
2091  if (neighbor != nullptr) {
2092  NextHop nextHop;
2093  nextHop.ifIndex = interface->getIfIndex();
2094  nextHop.hopAddress = neighbor->getAddress();
2095  nextHop.advertisingRouter = parentRouter->getRouterID();
2096  hops->push_back(nextHop);
2097  break;
2098  }
2099  }
2100  }
2101  // next hops for virtual links are generated later, after examining transit areas' SummaryLSAs
2102  }
2103 
2104  if (hops->size() == 0) {
2105  unsigned long hostRouteCount = hostRoutes.size();
2106  for (i = 0; i < hostRouteCount; i++) {
2107  if ((destination.getLinkID() == hostRoutes[i].address) &&
2108  (destination.getLinkData() == 0xFFFFFFFF))
2109  {
2110  NextHop nextHop;
2111  nextHop.ifIndex = hostRoutes[i].ifIndex;
2112  nextHop.hopAddress = hostRoutes[i].address;
2113  nextHop.advertisingRouter = parentRouter->getRouterID();
2114  hops->push_back(nextHop);
2115  break;
2116  }
2117  }
2118  }
2119  }
2120 
2121  return hops;
2122 }
const IPv4Address NULL_IPV4ADDRESS(0, 0, 0, 0)
Definition: OSPFInterface.h:60
Definition: OSPFInterface.h:65
Definition: OSPFInterface.h:56
RouterID getRouterID() const
Definition: OSPFRouter.h:72
Definition: OSPFPacket_m.h:378
Definition: OSPFInterface.h:58
RouterLSA * spfTreeRoot
Definition: OSPFArea.h:55
Definition: OSPFInterface.h:57
Definition: OSPFInterface.h:59
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
bool isSameNetwork(IPv4Address address1, IPv4Address mask1, IPv4Address address2, IPv4Address mask2)
Definition: OSPFcommon.h:182
IPv4Address NextHop
Definition: BGPCommon.h:51
Router * parentRouter
Definition: OSPFArea.h:57
Definition: OSPFPacket_m.h:376
std::vector< HostRouteParameters > hostRoutes
Definition: OSPFArea.h:45
OSPFInterfaceType
Definition: OSPFInterface.h:54
void inet::ospf::Area::calculateShortestPathTree ( std::vector< RoutingTableEntry * > &  newRoutingTable)
1397 {
1398  RouterID routerID = parentRouter->getRouterID();
1399  bool finished = false;
1400  std::vector<OSPFLSA *> treeVertices;
1401  OSPFLSA *justAddedVertex;
1402  std::vector<OSPFLSA *> candidateVertices;
1403  unsigned long i, j, k;
1404  unsigned long lsaCount;
1405 
1406  if (spfTreeRoot == nullptr) {
1407  RouterLSA *newLSA = originateRouterLSA();
1408 
1409  installRouterLSA(newLSA);
1410 
1411  RouterLSA *routerLSA = findRouterLSA(routerID);
1412 
1413  spfTreeRoot = routerLSA;
1414  floodLSA(newLSA);
1415  delete newLSA;
1416  }
1417  if (spfTreeRoot == nullptr) {
1418  return;
1419  }
1420 
1421  lsaCount = routerLSAs.size();
1422  for (i = 0; i < lsaCount; i++) {
1423  routerLSAs[i]->clearNextHops();
1424  }
1425  lsaCount = networkLSAs.size();
1426  for (i = 0; i < lsaCount; i++) {
1427  networkLSAs[i]->clearNextHops();
1428  }
1430  treeVertices.push_back(spfTreeRoot);
1431  justAddedVertex = spfTreeRoot; // (1)
1432 
1433  do {
1434  LSAType vertexType = static_cast<LSAType>(justAddedVertex->getHeader().getLsType());
1435 
1436  if (vertexType == ROUTERLSA_TYPE) {
1437  RouterLSA *routerVertex = check_and_cast<RouterLSA *>(justAddedVertex);
1438  if (routerVertex->getV_VirtualLinkEndpoint()) { // (2)
1439  transitCapability = true;
1440  }
1441 
1442  unsigned int linkCount = routerVertex->getLinksArraySize();
1443  for (i = 0; i < linkCount; i++) {
1444  Link& link = routerVertex->getLinks(i);
1445  LinkType linkType = static_cast<LinkType>(link.getType());
1446  OSPFLSA *joiningVertex;
1447  LSAType joiningVertexType;
1448 
1449  if (linkType == STUB_LINK) { // (2) (a)
1450  continue;
1451  }
1452 
1453  if (linkType == TRANSIT_LINK) {
1454  joiningVertex = findNetworkLSA(link.getLinkID());
1455  joiningVertexType = NETWORKLSA_TYPE;
1456  }
1457  else {
1458  joiningVertex = findRouterLSA(link.getLinkID());
1459  joiningVertexType = ROUTERLSA_TYPE;
1460  }
1461 
1462  if ((joiningVertex == nullptr) ||
1463  (joiningVertex->getHeader().getLsAge() == MAX_AGE) ||
1464  (!hasLink(joiningVertex, justAddedVertex))) // (from, to) (2) (b)
1465  {
1466  continue;
1467  }
1468 
1469  unsigned int treeSize = treeVertices.size();
1470  bool alreadyOnTree = false;
1471 
1472  for (j = 0; j < treeSize; j++) {
1473  if (treeVertices[j] == joiningVertex) {
1474  alreadyOnTree = true;
1475  break;
1476  }
1477  }
1478  if (alreadyOnTree) { // (2) (c)
1479  continue;
1480  }
1481 
1482  unsigned long linkStateCost = routerVertex->getDistance() + link.getLinkCost();
1483  unsigned int candidateCount = candidateVertices.size();
1484  OSPFLSA *candidate = nullptr;
1485 
1486  for (j = 0; j < candidateCount; j++) {
1487  if (candidateVertices[j] == joiningVertex) {
1488  candidate = candidateVertices[j];
1489  }
1490  }
1491  if (candidate != nullptr) { // (2) (d)
1492  RoutingInfo *routingInfo = check_and_cast<RoutingInfo *>(candidate);
1493  unsigned long candidateDistance = routingInfo->getDistance();
1494 
1495  if (linkStateCost > candidateDistance) {
1496  continue;
1497  }
1498  if (linkStateCost < candidateDistance) {
1499  routingInfo->setDistance(linkStateCost);
1500  routingInfo->clearNextHops();
1501  }
1502  std::vector<NextHop> *newNextHops = calculateNextHops(joiningVertex, justAddedVertex); // (destination, parent)
1503  unsigned int nextHopCount = newNextHops->size();
1504  for (k = 0; k < nextHopCount; k++) {
1505  routingInfo->addNextHop((*newNextHops)[k]);
1506  }
1507  delete newNextHops;
1508  }
1509  else {
1510  if (joiningVertexType == ROUTERLSA_TYPE) {
1511  RouterLSA *joiningRouterVertex = check_and_cast<RouterLSA *>(joiningVertex);
1512  joiningRouterVertex->setDistance(linkStateCost);
1513  std::vector<NextHop> *newNextHops = calculateNextHops(joiningVertex, justAddedVertex); // (destination, parent)
1514  unsigned int nextHopCount = newNextHops->size();
1515  for (k = 0; k < nextHopCount; k++) {
1516  joiningRouterVertex->addNextHop((*newNextHops)[k]);
1517  }
1518  delete newNextHops;
1519  RoutingInfo *vertexRoutingInfo = check_and_cast<RoutingInfo *>(joiningRouterVertex);
1520  vertexRoutingInfo->setParent(justAddedVertex);
1521 
1522  candidateVertices.push_back(joiningRouterVertex);
1523  }
1524  else {
1525  NetworkLSA *joiningNetworkVertex = check_and_cast<NetworkLSA *>(joiningVertex);
1526  joiningNetworkVertex->setDistance(linkStateCost);
1527  std::vector<NextHop> *newNextHops = calculateNextHops(joiningVertex, justAddedVertex); // (destination, parent)
1528  unsigned int nextHopCount = newNextHops->size();
1529  for (k = 0; k < nextHopCount; k++) {
1530  joiningNetworkVertex->addNextHop((*newNextHops)[k]);
1531  }
1532  delete newNextHops;
1533  RoutingInfo *vertexRoutingInfo = check_and_cast<RoutingInfo *>(joiningNetworkVertex);
1534  vertexRoutingInfo->setParent(justAddedVertex);
1535 
1536  candidateVertices.push_back(joiningNetworkVertex);
1537  }
1538  }
1539  }
1540  }
1541 
1542  if (vertexType == NETWORKLSA_TYPE) {
1543  NetworkLSA *networkVertex = check_and_cast<NetworkLSA *>(justAddedVertex);
1544  unsigned int routerCount = networkVertex->getAttachedRoutersArraySize();
1545 
1546  for (i = 0; i < routerCount; i++) { // (2)
1547  RouterLSA *joiningVertex = findRouterLSA(networkVertex->getAttachedRouters(i));
1548  if ((joiningVertex == nullptr) ||
1549  (joiningVertex->getHeader().getLsAge() == MAX_AGE) ||
1550  (!hasLink(joiningVertex, justAddedVertex))) // (from, to) (2) (b)
1551  {
1552  continue;
1553  }
1554 
1555  unsigned int treeSize = treeVertices.size();
1556  bool alreadyOnTree = false;
1557 
1558  for (j = 0; j < treeSize; j++) {
1559  if (treeVertices[j] == joiningVertex) {
1560  alreadyOnTree = true;
1561  break;
1562  }
1563  }
1564  if (alreadyOnTree) { // (2) (c)
1565  continue;
1566  }
1567 
1568  unsigned long linkStateCost = networkVertex->getDistance(); // link cost from network to router is always 0
1569  unsigned int candidateCount = candidateVertices.size();
1570  OSPFLSA *candidate = nullptr;
1571 
1572  for (j = 0; j < candidateCount; j++) {
1573  if (candidateVertices[j] == joiningVertex) {
1574  candidate = candidateVertices[j];
1575  }
1576  }
1577  if (candidate != nullptr) { // (2) (d)
1578  RoutingInfo *routingInfo = check_and_cast<RoutingInfo *>(candidate);
1579  unsigned long candidateDistance = routingInfo->getDistance();
1580 
1581  if (linkStateCost > candidateDistance) {
1582  continue;
1583  }
1584  if (linkStateCost < candidateDistance) {
1585  routingInfo->setDistance(linkStateCost);
1586  routingInfo->clearNextHops();
1587  }
1588  std::vector<NextHop> *newNextHops = calculateNextHops(joiningVertex, justAddedVertex); // (destination, parent)
1589  unsigned int nextHopCount = newNextHops->size();
1590  for (k = 0; k < nextHopCount; k++) {
1591  routingInfo->addNextHop((*newNextHops)[k]);
1592  }
1593  delete newNextHops;
1594  }
1595  else {
1596  joiningVertex->setDistance(linkStateCost);
1597  std::vector<NextHop> *newNextHops = calculateNextHops(joiningVertex, justAddedVertex); // (destination, parent)
1598  unsigned int nextHopCount = newNextHops->size();
1599  for (k = 0; k < nextHopCount; k++) {
1600  joiningVertex->addNextHop((*newNextHops)[k]);
1601  }
1602  delete newNextHops;
1603  RoutingInfo *vertexRoutingInfo = check_and_cast<RoutingInfo *>(joiningVertex);
1604  vertexRoutingInfo->setParent(justAddedVertex);
1605 
1606  candidateVertices.push_back(joiningVertex);
1607  }
1608  }
1609  }
1610 
1611  if (candidateVertices.empty()) { // (3)
1612  finished = true;
1613  }
1614  else {
1615  unsigned int candidateCount = candidateVertices.size();
1616  unsigned long minDistance = LS_INFINITY;
1617  OSPFLSA *closestVertex = candidateVertices[0];
1618 
1619  for (i = 0; i < candidateCount; i++) {
1620  RoutingInfo *routingInfo = check_and_cast<RoutingInfo *>(candidateVertices[i]);
1621  unsigned long currentDistance = routingInfo->getDistance();
1622 
1623  if (currentDistance < minDistance) {
1624  closestVertex = candidateVertices[i];
1625  minDistance = currentDistance;
1626  }
1627  else {
1628  if (currentDistance == minDistance) {
1629  if ((closestVertex->getHeader().getLsType() == ROUTERLSA_TYPE) &&
1630  (candidateVertices[i]->getHeader().getLsType() == NETWORKLSA_TYPE))
1631  {
1632  closestVertex = candidateVertices[i];
1633  }
1634  }
1635  }
1636  }
1637 
1638  treeVertices.push_back(closestVertex);
1639 
1640  for (auto it = candidateVertices.begin(); it != candidateVertices.end(); it++) {
1641  if ((*it) == closestVertex) {
1642  candidateVertices.erase(it);
1643  break;
1644  }
1645  }
1646 
1647  if (closestVertex->getHeader().getLsType() == ROUTERLSA_TYPE) {
1648  RouterLSA *routerLSA = check_and_cast<RouterLSA *>(closestVertex);
1649  if (routerLSA->getB_AreaBorderRouter() || routerLSA->getE_ASBoundaryRouter()) {
1650  RoutingTableEntry *entry = new RoutingTableEntry(ift);
1651  RouterID destinationID = routerLSA->getHeader().getLinkStateID();
1652  unsigned int nextHopCount = routerLSA->getNextHopCount();
1654 
1655  entry->setDestination(destinationID);
1656  entry->setLinkStateOrigin(routerLSA);
1657  entry->setArea(areaID);
1658  entry->setPathType(RoutingTableEntry::INTRAAREA);
1659  entry->setCost(routerLSA->getDistance());
1660  if (routerLSA->getB_AreaBorderRouter()) {
1662  }
1663  if (routerLSA->getE_ASBoundaryRouter()) {
1665  }
1666  entry->setDestinationType(destinationType);
1667  entry->setOptionalCapabilities(routerLSA->getHeader().getLsOptions());
1668  for (i = 0; i < nextHopCount; i++) {
1669  entry->addNextHop(routerLSA->getNextHop(i));
1670  }
1671 
1672  newRoutingTable.push_back(entry);
1673 
1674  Area *backbone;
1675  if (areaID != BACKBONE_AREAID) {
1677  }
1678  else {
1679  backbone = this;
1680  }
1681  if (backbone != nullptr) {
1682  Interface *virtualIntf = backbone->findVirtualLink(destinationID);
1683  if ((virtualIntf != nullptr) && (virtualIntf->getTransitAreaID() == areaID)) {
1684  IPv4AddressRange range;
1685  range.address = getInterface(routerLSA->getNextHop(0).ifIndex)->getAddressRange().address;
1686  range.mask = IPv4Address::ALLONES_ADDRESS;
1687  virtualIntf->setAddressRange(range);
1688  virtualIntf->setIfIndex(ift, routerLSA->getNextHop(0).ifIndex);
1689  virtualIntf->setOutputCost(routerLSA->getDistance());
1690  Neighbor *virtualNeighbor = virtualIntf->getNeighbor(0);
1691  if (virtualNeighbor != nullptr) {
1692  unsigned int linkCount = routerLSA->getLinksArraySize();
1693  RouterLSA *toRouterLSA = dynamic_cast<RouterLSA *>(justAddedVertex);
1694  if (toRouterLSA != nullptr) {
1695  for (i = 0; i < linkCount; i++) {
1696  Link& link = routerLSA->getLinks(i);
1697 
1698  if ((link.getType() == POINTTOPOINT_LINK) &&
1699  (link.getLinkID() == toRouterLSA->getHeader().getLinkStateID()) &&
1700  (virtualIntf->getState() < Interface::WAITING_STATE))
1701  {
1702  virtualNeighbor->setAddress(IPv4Address(link.getLinkData()));
1703  virtualIntf->processEvent(Interface::INTERFACE_UP);
1704  break;
1705  }
1706  }
1707  }
1708  else {
1709  NetworkLSA *toNetworkLSA = dynamic_cast<NetworkLSA *>(justAddedVertex);
1710  if (toNetworkLSA != nullptr) {
1711  for (i = 0; i < linkCount; i++) {
1712  Link& link = routerLSA->getLinks(i);
1713 
1714  if ((link.getType() == TRANSIT_LINK) &&
1715  (link.getLinkID() == toNetworkLSA->getHeader().getLinkStateID()) &&
1716  (virtualIntf->getState() < Interface::WAITING_STATE))
1717  {
1718  virtualNeighbor->setAddress(IPv4Address(link.getLinkData()));
1719  virtualIntf->processEvent(Interface::INTERFACE_UP);
1720  break;
1721  }
1722  }
1723  }
1724  }
1725  }
1726  }
1727  }
1728  }
1729  }
1730 
1731  if (closestVertex->getHeader().getLsType() == NETWORKLSA_TYPE) {
1732  NetworkLSA *networkLSA = check_and_cast<NetworkLSA *>(closestVertex);
1733  IPv4Address destinationID = (networkLSA->getHeader().getLinkStateID() & networkLSA->getNetworkMask());
1734  unsigned int nextHopCount = networkLSA->getNextHopCount();
1735  bool overWrite = false;
1736  RoutingTableEntry *entry = nullptr;
1737  unsigned long routeCount = newRoutingTable.size();
1738  IPv4Address longestMatch(0u);
1739 
1740  for (i = 0; i < routeCount; i++) {
1741  if (newRoutingTable[i]->getDestinationType() == RoutingTableEntry::NETWORK_DESTINATION) {
1742  RoutingTableEntry *routingEntry = newRoutingTable[i];
1743  IPv4Address entryAddress = routingEntry->getDestination();
1744  IPv4Address entryMask = routingEntry->getNetmask();
1745 
1746  if ((entryAddress & entryMask) == (destinationID & entryMask)) {
1747  if ((destinationID & entryMask) > longestMatch) {
1748  longestMatch = (destinationID & entryMask);
1749  entry = routingEntry;
1750  }
1751  }
1752  }
1753  }
1754  if (entry != nullptr) {
1755  const OSPFLSA *entryOrigin = entry->getLinkStateOrigin();
1756  if ((entry->getCost() != networkLSA->getDistance()) ||
1757  (entryOrigin->getHeader().getLinkStateID() >= networkLSA->getHeader().getLinkStateID()))
1758  {
1759  overWrite = true;
1760  }
1761  }
1762 
1763  if ((entry == nullptr) || (overWrite)) {
1764  if (entry == nullptr) {
1765  entry = new RoutingTableEntry(ift);
1766  }
1767 
1768  entry->setDestination(IPv4Address(destinationID));
1769  entry->setNetmask(networkLSA->getNetworkMask());
1770  entry->setLinkStateOrigin(networkLSA);
1771  entry->setArea(areaID);
1772  entry->setPathType(RoutingTableEntry::INTRAAREA);
1773  entry->setCost(networkLSA->getDistance());
1774  entry->setDestinationType(RoutingTableEntry::NETWORK_DESTINATION);
1775  entry->setOptionalCapabilities(networkLSA->getHeader().getLsOptions());
1776  for (i = 0; i < nextHopCount; i++) {
1777  entry->addNextHop(networkLSA->getNextHop(i));
1778  }
1779 
1780  if (!overWrite) {
1781  newRoutingTable.push_back(entry);
1782  }
1783  }
1784  }
1785 
1786  justAddedVertex = closestVertex;
1787  }
1788  } while (!finished);
1789 
1790  unsigned int treeSize = treeVertices.size();
1791  for (i = 0; i < treeSize; i++) {
1792  RouterLSA *routerVertex = dynamic_cast<RouterLSA *>(treeVertices[i]);
1793  if (routerVertex == nullptr) {
1794  continue;
1795  }
1796 
1797  unsigned int linkCount = routerVertex->getLinksArraySize();
1798  for (j = 0; j < linkCount; j++) {
1799  Link& link = routerVertex->getLinks(j);
1800  if (link.getType() != STUB_LINK) {
1801  continue;
1802  }
1803 
1804  unsigned long distance = routerVertex->getDistance() + link.getLinkCost();
1805  unsigned long destinationID = (link.getLinkID().getInt() & link.getLinkData());
1806  RoutingTableEntry *entry = nullptr;
1807  unsigned long routeCount = newRoutingTable.size();
1808  unsigned long longestMatch = 0;
1809 
1810  for (k = 0; k < routeCount; k++) {
1811  if (newRoutingTable[k]->getDestinationType() == RoutingTableEntry::NETWORK_DESTINATION) {
1812  RoutingTableEntry *routingEntry = newRoutingTable[k];
1813  unsigned long entryAddress = routingEntry->getDestination().getInt();
1814  unsigned long entryMask = routingEntry->getNetmask().getInt();
1815 
1816  if ((entryAddress & entryMask) == (destinationID & entryMask)) {
1817  if ((destinationID & entryMask) > longestMatch) {
1818  longestMatch = (destinationID & entryMask);
1819  entry = routingEntry;
1820  }
1821  }
1822  }
1823  }
1824 
1825  if (entry != nullptr) {
1826  Metric entryCost = entry->getCost();
1827 
1828  if (distance > entryCost) {
1829  continue;
1830  }
1831  if (distance < entryCost) {
1832  //FIXME remove
1833  //if(parentRouter->getRouterID() == 0xC0A80302) {
1834  // EV << "CHEAPER STUB LINK FOUND TO " << IPv4Address(destinationID).str() << "\n";
1835  //}
1836  entry->setCost(distance);
1837  entry->clearNextHops();
1838  entry->setLinkStateOrigin(routerVertex);
1839  }
1840  if (distance == entryCost) {
1841  // no const version from check_and_cast
1842  const OSPFLSA *lsOrigin = entry->getLinkStateOrigin();
1843  if (dynamic_cast<const RouterLSA *>(lsOrigin) || dynamic_cast<const NetworkLSA *>(lsOrigin)) {
1844  if (lsOrigin->getHeader().getLinkStateID() < routerVertex->getHeader().getLinkStateID()) {
1845  entry->setLinkStateOrigin(routerVertex);
1846  }
1847  }
1848  else {
1849  throw cRuntimeError("Can not cast class '%s' to RouterLSA or NetworkLSA", lsOrigin->getClassName());
1850  }
1851  }
1852  std::vector<NextHop> *newNextHops = calculateNextHops(link, routerVertex); // (destination, parent)
1853  unsigned int nextHopCount = newNextHops->size();
1854  for (k = 0; k < nextHopCount; k++) {
1855  entry->addNextHop((*newNextHops)[k]);
1856  }
1857  delete newNextHops;
1858  }
1859  else {
1860  //FIXME remove
1861  //if(parentRouter->getRouterID() == 0xC0A80302) {
1862  // EV << "STUB LINK FOUND TO " << IPv4Address(destinationID).str() << "\n";
1863  //}
1864  entry = new RoutingTableEntry(ift);
1865 
1866  entry->setDestination(IPv4Address(destinationID));
1867  entry->setNetmask(IPv4Address(link.getLinkData()));
1868  entry->setLinkStateOrigin(routerVertex);
1869  entry->setArea(areaID);
1870  entry->setPathType(RoutingTableEntry::INTRAAREA);
1871  entry->setCost(distance);
1872  entry->setDestinationType(RoutingTableEntry::NETWORK_DESTINATION);
1873  entry->setOptionalCapabilities(routerVertex->getHeader().getLsOptions());
1874  std::vector<NextHop> *newNextHops = calculateNextHops(link, routerVertex); // (destination, parent)
1875  unsigned int nextHopCount = newNextHops->size();
1876  for (k = 0; k < nextHopCount; k++) {
1877  entry->addNextHop((*newNextHops)[k]);
1878  }
1879  delete newNextHops;
1880 
1881  newRoutingTable.push_back(entry);
1882  }
1883  }
1884  }
1885 }
void setDistance(unsigned long d)
Definition: LSA.h:55
std::vector< NetworkLSA * > networkLSAs
Definition: OSPFArea.h:49
unsigned long Metric
Definition: OSPFcommon.h:64
Definition: OSPFInterface.h:66
Definition: OSPFRoutingTableEntry.h:39
Interface * getInterface(unsigned char ifIndex)
Definition: OSPFArea.cc:205
std::vector< RouterLSA * > routerLSAs
Definition: OSPFArea.h:47
RouterID getRouterID() const
Definition: OSPFRouter.h:72
const AreaID BACKBONE_AREAID(0, 0, 0, 0)
bool installRouterLSA(OSPFRouterLSA *lsa)
Definition: OSPFArea.cc:261
unsigned char RoutingDestinationType
Definition: OSPFRoutingTableEntry.h:45
Definition: OSPFPacket_m.h:378
static const unsigned char NETWORK_DESTINATION
Definition: OSPFRoutingTableEntry.h:48
static const unsigned char AS_BOUNDARY_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:50
std::vector< NextHop > * calculateNextHops(OSPFLSA *destination, OSPFLSA *parent) const
Definition: OSPFArea.cc:1887
Definition: OSPFPacket_m.h:246
Area(IInterfaceTable *ift, AreaID id=BACKBONE_AREAID)
Definition: OSPFArea.cc:26
static const unsigned char AREA_BORDER_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:49
bool hasLink(OSPFLSA *fromLSA, OSPFLSA *toLSA) const
Definition: OSPFArea.cc:2124
Definition: OSPFPacket_m.h:377
RouterLSA * spfTreeRoot
Definition: OSPFArea.h:55
IPv4Address address
Definition: OSPFcommon.h:79
#define LS_INFINITY
Definition: TED.cc:32
LinkType
Enum generated from inet/routing/ospfv2/OSPFPacket.msg:115 by nedtool.
Definition: OSPFPacket_m.h:375
unsigned long getDistance() const
Definition: LSA.h:56
Area * getAreaByID(AreaID areaID)
Returns the pointer to the Area identified by the input areaID, if it&#39;s on the Area list...
Definition: OSPFRouter.cc:72
Definition: OSPFInterface.h:43
#define MAX_AGE
Definition: OSPFcommon.h:36
bool transitCapability
Definition: OSPFArea.h:52
IInterfaceTable * ift
Definition: OSPFArea.h:40
Definition: OSPFPacket_m.h:245
LSAType
Enum generated from inet/routing/ospfv2/OSPFPacket.msg:84 by nedtool.
Definition: OSPFPacket_m.h:244
IPv4AddressRange getAddressRange(unsigned int index) const
Definition: OSPFArea.h:67
RouterLSA * originateRouterLSA()
Definition: OSPFArea.cc:751
Router * parentRouter
Definition: OSPFArea.h:57
static const IPv4Address ALLONES_ADDRESS
255.255.255.255
Definition: IPv4Address.h:105
const double k
Definition: QAM16Modulation.cc:24
RouterLSA * findRouterLSA(LinkStateID linkStateID)
Definition: OSPFArea.cc:328
IPv4Address RouterID
Definition: OSPFcommon.h:137
AreaID areaID
Definition: OSPFArea.h:41
Definition: OSPFPacket_m.h:376
Interface * findVirtualLink(RouterID routerID)
Definition: OSPFArea.cc:248
NetworkLSA * findNetworkLSA(LinkStateID linkStateID)
Definition: OSPFArea.cc:350
bool floodLSA(OSPFLSA *lsa, Interface *intf=nullptr, Neighbor *neighbor=nullptr)
Definition: OSPFArea.cc:726
bool inet::ospf::Area::containsAddress ( IPv4Address  address) const
161 {
162  int addressRangeNum = areaAddressRanges.size();
163  for (int i = 0; i < addressRangeNum; i++) {
164  if (areaAddressRanges[i].contains(address)) {
165  return true;
166  }
167  }
168  return false;
169 }
std::vector< IPv4AddressRange > areaAddressRanges
Definition: OSPFArea.h:43
bool contains(const std::vector< T > &v, const T &a)
Definition: stlutils.h:69
RoutingTableEntry * inet::ospf::Area::createRoutingTableEntryFromSummaryLSA ( const SummaryLSA summaryLSA,
unsigned short  entryCost,
const RoutingTableEntry borderRouterEntry 
) const
private

Returns a new RoutingTableEntry based on the input SummaryLSA, with the input cost and the borderRouterEntry's next hops.

Referenced by calculateInterAreaRoutes().

2257 {
2258  IPv4AddressRange destination;
2259 
2260  destination.address = summaryLSA.getHeader().getLinkStateID();
2261  destination.mask = summaryLSA.getNetworkMask();
2262 
2263  RoutingTableEntry *newEntry = new RoutingTableEntry(ift);
2264 
2265  if (summaryLSA.getHeader().getLsType() == SUMMARYLSA_NETWORKS_TYPE) {
2266  newEntry->setDestination(destination.address & destination.mask);
2267  newEntry->setNetmask(destination.mask);
2268  newEntry->setDestinationType(RoutingTableEntry::NETWORK_DESTINATION);
2269  }
2270  else {
2271  newEntry->setDestination(destination.address);
2272  newEntry->setNetmask(IPv4Address::ALLONES_ADDRESS);
2273  newEntry->setDestinationType(RoutingTableEntry::AS_BOUNDARY_ROUTER_DESTINATION);
2274  }
2275  newEntry->setArea(areaID);
2276  newEntry->setPathType(RoutingTableEntry::INTERAREA);
2277  newEntry->setCost(entryCost);
2278  newEntry->setOptionalCapabilities(summaryLSA.getHeader().getLsOptions());
2279  newEntry->setLinkStateOrigin(&summaryLSA);
2280 
2281  unsigned int nextHopCount = borderRouterEntry.getNextHopCount();
2282  for (unsigned int j = 0; j < nextHopCount; j++) {
2283  newEntry->addNextHop(borderRouterEntry.getNextHop(j));
2284  }
2285 
2286  return newEntry;
2287 }
Definition: OSPFRoutingTableEntry.h:40
static const unsigned char NETWORK_DESTINATION
Definition: OSPFRoutingTableEntry.h:48
static const unsigned char AS_BOUNDARY_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:50
IInterfaceTable * ift
Definition: OSPFArea.h:40
static const IPv4Address ALLONES_ADDRESS
255.255.255.255
Definition: IPv4Address.h:105
AreaID areaID
Definition: OSPFArea.h:41
Definition: OSPFPacket_m.h:247
std::string inet::ospf::Area::detailedInfo ( ) const
override

Referenced by inet::ospf::operator<<().

117 {
118  std::stringstream out;
119  int i;
120  out << "\n areaID: " << areaID.str(false) << ", ";
121  out << "transitCapability: " << (transitCapability ? "true" : "false") << ", ";
122  out << "externalRoutingCapability: " << (externalRoutingCapability ? "true" : "false") << ", ";
123  out << "stubDefaultCost: " << stubDefaultCost << "\n";
124  int addressRangeNum = areaAddressRanges.size();
125  for (i = 0; i < addressRangeNum; i++) {
126  out << " addressRanges[" << i << "]: ";
127  out << areaAddressRanges[i].address.str(false);
128  out << "/" << areaAddressRanges[i].mask.str(false) << "\n";
129  }
130  int interfaceNum = associatedInterfaces.size();
131  for (i = 0; i < interfaceNum; i++) {
132  out << " interface[" << i << "]: address: ";
133  out << associatedInterfaces[i]->getAddressRange().address.str(false);
134  out << "/" << associatedInterfaces[i]->getAddressRange().mask.str(false) << "\n";
135  }
136 
137  out << "\n";
138  out << " Database:\n";
139  out << " RouterLSAs:\n";
140  long lsaCount = routerLSAs.size();
141  for (i = 0; i < lsaCount; i++) {
142  out << " " << *routerLSAs[i] << "\n";
143  }
144  out << " NetworkLSAs:\n";
145  lsaCount = networkLSAs.size();
146  for (i = 0; i < lsaCount; i++) {
147  out << " " << *networkLSAs[i] << "\n";
148  }
149  out << " SummaryLSAs:\n";
150  lsaCount = summaryLSAs.size();
151  for (i = 0; i < lsaCount; i++) {
152  out << " " << *summaryLSAs[i] << "\n";
153  }
154 
155  out << "--------------------------------------------------------------------------------";
156 
157  return out.str();
158 }
std::string str(bool printUnspec=true) const
Returns the string representation of the address (e.g.
Definition: IPv4Address.cc:109
std::vector< NetworkLSA * > networkLSAs
Definition: OSPFArea.h:49
std::vector< SummaryLSA * > summaryLSAs
Definition: OSPFArea.h:51
std::vector< RouterLSA * > routerLSAs
Definition: OSPFArea.h:47
bool externalRoutingCapability
Definition: OSPFArea.h:53
std::vector< IPv4AddressRange > areaAddressRanges
Definition: OSPFArea.h:43
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
bool transitCapability
Definition: OSPFArea.h:52
AreaID areaID
Definition: OSPFArea.h:41
Metric stubDefaultCost
Definition: OSPFArea.h:54
NetworkLSA * inet::ospf::Area::findNetworkLSA ( LinkStateID  linkStateID)

Referenced by calculateShortestPathTree(), inet::ospf::NeighborState::changeState(), and inet::ospf::InterfaceState::changeState().

351 {
352  auto lsaIt = networkLSAsByID.find(linkStateID);
353  if (lsaIt != networkLSAsByID.end()) {
354  return lsaIt->second;
355  }
356  else {
357  return nullptr;
358  }
359 }
std::map< LinkStateID, NetworkLSA * > networkLSAsByID
Definition: OSPFArea.h:48
const NetworkLSA * inet::ospf::Area::findNetworkLSA ( LinkStateID  linkStateID) const
362 {
363  std::map<LinkStateID, NetworkLSA *>::const_iterator lsaIt = networkLSAsByID.find(linkStateID);
364  if (lsaIt != networkLSAsByID.end()) {
365  return lsaIt->second;
366  }
367  else {
368  return nullptr;
369  }
370 }
std::map< LinkStateID, NetworkLSA * > networkLSAsByID
Definition: OSPFArea.h:48
RouterLSA * inet::ospf::Area::findRouterLSA ( LinkStateID  linkStateID)

Referenced by calculateShortestPathTree(), inet::ospf::NeighborState::changeState(), inet::ospf::InterfaceState::changeState(), and inet::ospf::HelloHandler::processPacket().

329 {
330  auto lsaIt = routerLSAsByID.find(linkStateID);
331  if (lsaIt != routerLSAsByID.end()) {
332  return lsaIt->second;
333  }
334  else {
335  return nullptr;
336  }
337 }
std::map< LinkStateID, RouterLSA * > routerLSAsByID
Definition: OSPFArea.h:46
const RouterLSA * inet::ospf::Area::findRouterLSA ( LinkStateID  linkStateID) const
340 {
341  std::map<LinkStateID, RouterLSA *>::const_iterator lsaIt = routerLSAsByID.find(linkStateID);
342  if (lsaIt != routerLSAsByID.end()) {
343  return lsaIt->second;
344  }
345  else {
346  return nullptr;
347  }
348 }
std::map< LinkStateID, RouterLSA * > routerLSAsByID
Definition: OSPFArea.h:46
bool inet::ospf::Area::findSameOrWorseCostRoute ( const std::vector< RoutingTableEntry * > &  newRoutingTable,
const SummaryLSA summaryLSA,
unsigned short  currentCost,
bool &  destinationInRoutingTable,
std::list< RoutingTableEntry * > &  sameOrWorseCost 
) const
private

Browse through the newRoutingTable looking for entries describing the same destination as the currentLSA.

If a cheaper route is found then skip this LSA(return true), else note those which are of equal or worse cost than the currentCost.

Referenced by calculateInterAreaRoutes().

2193 {
2194  destinationInRoutingTable = false;
2195  sameOrWorseCost.clear();
2196 
2197  long routeCount = newRoutingTable.size();
2198  IPv4AddressRange destination;
2199 
2200  destination.address = summaryLSA.getHeader().getLinkStateID();
2201  destination.mask = summaryLSA.getNetworkMask();
2202 
2203  for (long j = 0; j < routeCount; j++) {
2204  RoutingTableEntry *routingEntry = newRoutingTable[j];
2205  bool foundMatching = false;
2206 
2207  if (summaryLSA.getHeader().getLsType() == SUMMARYLSA_NETWORKS_TYPE) {
2208  if ((routingEntry->getDestinationType() == RoutingTableEntry::NETWORK_DESTINATION) &&
2209  isSameNetwork(destination.address, destination.mask, routingEntry->getDestination(), routingEntry->getNetmask())) //TODO or use containing ?
2210  {
2211  foundMatching = true;
2212  }
2213  }
2214  else {
2215  if ((((routingEntry->getDestinationType() & RoutingTableEntry::AREA_BORDER_ROUTER_DESTINATION) != 0) ||
2216  ((routingEntry->getDestinationType() & RoutingTableEntry::AS_BOUNDARY_ROUTER_DESTINATION) != 0)) &&
2217  (destination.address == routingEntry->getDestination()) &&
2218  (destination.mask == routingEntry->getNetmask()))
2219  {
2220  foundMatching = true;
2221  }
2222  }
2223 
2224  if (foundMatching) {
2225  destinationInRoutingTable = true;
2226 
2227  /* If the matching entry is an INTRAAREA getRoute(intra-area paths are
2228  * always preferred to other paths of any cost), or it's a cheaper INTERAREA
2229  * route, then skip this LSA.
2230  */
2231  if ((routingEntry->getPathType() == RoutingTableEntry::INTRAAREA) ||
2232  ((routingEntry->getPathType() == RoutingTableEntry::INTERAREA) &&
2233  (routingEntry->getCost() < currentCost)))
2234  {
2235  return true;
2236  }
2237  else {
2238  // if it's an other INTERAREA path
2239  if ((routingEntry->getPathType() == RoutingTableEntry::INTERAREA) &&
2240  (routingEntry->getCost() >= currentCost))
2241  {
2242  sameOrWorseCost.push_back(routingEntry);
2243  } // else it's external -> same as if not in the table
2244  }
2245  }
2246  }
2247  return false;
2248 }
Definition: OSPFRoutingTableEntry.h:39
Definition: OSPFRoutingTableEntry.h:40
static const unsigned char NETWORK_DESTINATION
Definition: OSPFRoutingTableEntry.h:48
static const unsigned char AS_BOUNDARY_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:50
static const unsigned char AREA_BORDER_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:49
bool isSameNetwork(IPv4Address address1, IPv4Address mask1, IPv4Address address2, IPv4Address mask2)
Definition: OSPFcommon.h:182
Definition: OSPFPacket_m.h:247
SummaryLSA * inet::ospf::Area::findSummaryLSA ( LSAKeyType  lsaKey)

Referenced by getUniqueLinkStateID().

373 {
374  auto lsaIt = summaryLSAsByID.find(lsaKey);
375  if (lsaIt != summaryLSAsByID.end()) {
376  return lsaIt->second;
377  }
378  else {
379  return nullptr;
380  }
381 }
std::map< LSAKeyType, SummaryLSA *, LSAKeyType_Less > summaryLSAsByID
Definition: OSPFArea.h:50
const SummaryLSA * inet::ospf::Area::findSummaryLSA ( LSAKeyType  lsaKey) const
384 {
385  std::map<LSAKeyType, SummaryLSA *, LSAKeyType_Less>::const_iterator lsaIt = summaryLSAsByID.find(lsaKey);
386  if (lsaIt != summaryLSAsByID.end()) {
387  return lsaIt->second;
388  }
389  else {
390  return nullptr;
391  }
392 }
std::map< LSAKeyType, SummaryLSA *, LSAKeyType_Less > summaryLSAsByID
Definition: OSPFArea.h:50
Interface * inet::ospf::Area::findVirtualLink ( RouterID  routerID)

Referenced by calculateShortestPathTree(), and inet::ospf::MessageHandler::processPacket().

249 {
250  int interfaceNum = associatedInterfaces.size();
251  for (int i = 0; i < interfaceNum; i++) {
252  if ((associatedInterfaces[i]->getType() == Interface::VIRTUAL) &&
253  (associatedInterfaces[i]->getNeighborByID(routerID) != nullptr))
254  {
255  return associatedInterfaces[i];
256  }
257  }
258  return nullptr;
259 }
Definition: OSPFInterface.h:60
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
bool inet::ospf::Area::floodLSA ( OSPFLSA lsa,
Interface intf = nullptr,
Neighbor neighbor = nullptr 
)

Referenced by ageDatabase(), calculateShortestPathTree(), inet::ospf::InterfaceState::changeState(), inet::ospf::NeighborState::changeState(), and inet::ospf::HelloHandler::processPacket().

727 {
728  bool floodedBackOut = false;
729  long interfaceCount = associatedInterfaces.size();
730 
731  for (long i = 0; i < interfaceCount; i++) {
732  if (associatedInterfaces[i]->floodLSA(lsa, intf, neighbor)) {
733  floodedBackOut = true;
734  }
735  }
736 
737  return floodedBackOut;
738 }
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
bool floodLSA(OSPFLSA *lsa, Interface *intf=nullptr, Neighbor *neighbor=nullptr)
Definition: OSPFArea.cc:726
IPv4AddressRange inet::ospf::Area::getAddressRange ( unsigned int  index) const
inline

Referenced by calculateShortestPathTree(), getInterface(), and isLocalAddress().

67 { return areaAddressRanges[index]; }
std::vector< IPv4AddressRange > areaAddressRanges
Definition: OSPFArea.h:43
unsigned int inet::ospf::Area::getAddressRangeCount ( ) const
inline
66 { return areaAddressRanges.size(); }
std::vector< IPv4AddressRange > areaAddressRanges
Definition: OSPFArea.h:43
IPv4AddressRange inet::ospf::Area::getContainingAddressRange ( IPv4AddressRange  addressRange,
bool *  advertise = nullptr 
) const
183 {
184  int addressRangeNum = areaAddressRanges.size();
185  for (int i = 0; i < addressRangeNum; i++) {
186  if (areaAddressRanges[i].contains(addressRange)) {
187  if (advertise != nullptr) {
188  std::map<IPv4AddressRange, bool>::const_iterator rangeIt = advertiseAddressRanges.find(areaAddressRanges[i]);
189  if (rangeIt != advertiseAddressRanges.end()) {
190  *advertise = rangeIt->second;
191  }
192  else {
193  throw cRuntimeError("Model error: inconsistent contents in areaAddressRanges and advertiseAddressRanges variables");
194  }
195  }
196  return areaAddressRanges[i];
197  }
198  }
199  if (advertise != nullptr) {
200  *advertise = false;
201  }
202  return NULL_IPV4ADDRESSRANGE;
203 }
std::vector< IPv4AddressRange > areaAddressRanges
Definition: OSPFArea.h:43
std::map< IPv4AddressRange, bool > advertiseAddressRanges
Definition: OSPFArea.h:42
bool contains(const std::vector< T > &v, const T &a)
Definition: stlutils.h:69
const IPv4AddressRange NULL_IPV4ADDRESSRANGE(IPv4Address(0, 0, 0, 0), IPv4Address(0, 0, 0, 0))
Interface * inet::ospf::Area::getInterface ( unsigned char  ifIndex)

Referenced by ageDatabase(), calculateShortestPathTree(), and inet::ospf::MessageHandler::processPacket().

206 {
207  int interfaceNum = associatedInterfaces.size();
208  for (int i = 0; i < interfaceNum; i++) {
209  if ((associatedInterfaces[i]->getType() != Interface::VIRTUAL) &&
210  (associatedInterfaces[i]->getIfIndex() == ifIndex))
211  {
212  return associatedInterfaces[i];
213  }
214  }
215  return nullptr;
216 }
Definition: OSPFInterface.h:60
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
Interface * inet::ospf::Area::getInterface ( IPv4Address  address)
219 {
220  int interfaceNum = associatedInterfaces.size();
221  for (int i = 0; i < interfaceNum; i++) {
222  if ((associatedInterfaces[i]->getType() != Interface::VIRTUAL) &&
223  (associatedInterfaces[i]->getAddressRange().address == address))
224  {
225  return associatedInterfaces[i];
226  }
227  }
228  return nullptr;
229 }
Definition: OSPFInterface.h:60
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
IPv4AddressRange getAddressRange(unsigned int index) const
Definition: OSPFArea.h:67
NetworkLSA* inet::ospf::Area::getNetworkLSA ( unsigned long  i)
inline

Referenced by inet::ospf::Neighbor::createDatabaseSummary().

87 { return networkLSAs[i]; }
std::vector< NetworkLSA * > networkLSAs
Definition: OSPFArea.h:49
const NetworkLSA* inet::ospf::Area::getNetworkLSA ( unsigned long  i) const
inline
88 { return networkLSAs[i]; }
std::vector< NetworkLSA * > networkLSAs
Definition: OSPFArea.h:49
unsigned long inet::ospf::Area::getNetworkLSACount ( ) const
inline

Referenced by inet::ospf::Neighbor::createDatabaseSummary().

86 { return networkLSAs.size(); }
std::vector< NetworkLSA * > networkLSAs
Definition: OSPFArea.h:49
Router* inet::ospf::Area::getRouter ( )
inline

Referenced by inet::ospf::InterfaceState::calculateDesignatedRouter(), inet::ospf::InterfaceState::changeState(), inet::ospf::NeighborState::changeState(), inet::ospf::Neighbor::clearRequestRetransmissionTimer(), inet::ospf::Neighbor::clearUpdateRetransmissionTimer(), inet::ospf::Neighbor::createDatabaseSummary(), inet::ospf::Interface::createUpdatePacket(), inet::ospf::Interface::floodLSA(), inet::ospf::Neighbor::needAdjacency(), inet::ospf::NeighborStateAttempt::processEvent(), inet::ospf::NeighborStateExchangeStart::processEvent(), inet::ospf::NeighborStateFull::processEvent(), inet::ospf::NeighborStateInit::processEvent(), inet::ospf::NeighborStateTwoWay::processEvent(), inet::ospf::NeighborStateExchange::processEvent(), inet::ospf::InterfaceStateBackup::processEvent(), inet::ospf::InterfaceStateDesignatedRouter::processEvent(), inet::ospf::NeighborStateDown::processEvent(), inet::ospf::InterfaceStateDown::processEvent(), inet::ospf::InterfaceStateNotDesignatedRouter::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), inet::ospf::InterfaceStatePointToPoint::processEvent(), inet::ospf::InterfaceStateWaiting::processEvent(), inet::ospf::Interface::reset(), inet::ospf::Neighbor::reset(), inet::ospf::Neighbor::retransmitDatabaseDescriptionPacket(), inet::ospf::Neighbor::retransmitUpdatePacket(), inet::ospf::Neighbor::sendDatabaseDescriptionPacket(), inet::ospf::Interface::sendDelayedAcknowledgements(), inet::ospf::Interface::sendHelloPacket(), inet::ospf::Neighbor::sendLinkStateRequestPacket(), inet::ospf::Interface::sendLSAcknowledgement(), inet::ospf::Neighbor::startRequestRetransmissionTimer(), inet::ospf::Neighbor::startUpdateRetransmissionTimer(), inet::ospf::Interface::~Interface(), and inet::ospf::Neighbor::~Neighbor().

80 { return parentRouter; }
Router * parentRouter
Definition: OSPFArea.h:57
const Router* inet::ospf::Area::getRouter ( ) const
inline
81 { return parentRouter; }
Router * parentRouter
Definition: OSPFArea.h:57
RouterLSA* inet::ospf::Area::getRouterLSA ( unsigned long  i)
inline

Referenced by inet::ospf::Neighbor::createDatabaseSummary().

84 { return routerLSAs[i]; }
std::vector< RouterLSA * > routerLSAs
Definition: OSPFArea.h:47
const RouterLSA* inet::ospf::Area::getRouterLSA ( unsigned long  i) const
inline
85 { return routerLSAs[i]; }
std::vector< RouterLSA * > routerLSAs
Definition: OSPFArea.h:47
unsigned long inet::ospf::Area::getRouterLSACount ( ) const
inline

Referenced by inet::ospf::Neighbor::createDatabaseSummary().

83 { return routerLSAs.size(); }
std::vector< RouterLSA * > routerLSAs
Definition: OSPFArea.h:47
RouterLSA* inet::ospf::Area::getSPFTreeRoot ( )
inline
76 { return spfTreeRoot; }
RouterLSA * spfTreeRoot
Definition: OSPFArea.h:55
const RouterLSA* inet::ospf::Area::getSPFTreeRoot ( ) const
inline
77 { return spfTreeRoot; }
RouterLSA * spfTreeRoot
Definition: OSPFArea.h:55
Metric inet::ospf::Area::getStubDefaultCost ( ) const
inline
74 { return stubDefaultCost; }
Metric stubDefaultCost
Definition: OSPFArea.h:54
SummaryLSA* inet::ospf::Area::getSummaryLSA ( unsigned long  i)
inline

Referenced by inet::ospf::Neighbor::createDatabaseSummary().

90 { return summaryLSAs[i]; }
std::vector< SummaryLSA * > summaryLSAs
Definition: OSPFArea.h:51
const SummaryLSA* inet::ospf::Area::getSummaryLSA ( unsigned long  i) const
inline
91 { return summaryLSAs[i]; }
std::vector< SummaryLSA * > summaryLSAs
Definition: OSPFArea.h:51
unsigned long inet::ospf::Area::getSummaryLSACount ( ) const
inline

Referenced by inet::ospf::Neighbor::createDatabaseSummary().

89 { return summaryLSAs.size(); }
std::vector< SummaryLSA * > summaryLSAs
Definition: OSPFArea.h:51
bool inet::ospf::Area::getTransitCapability ( ) const
inline
70 { return transitCapability; }
bool transitCapability
Definition: OSPFArea.h:52
LinkStateID inet::ospf::Area::getUniqueLinkStateID ( IPv4AddressRange  destination,
Metric  destinationCost,
SummaryLSA *&  lsaToReoriginate 
) const
private

Returns a link state ID for the input destination.

If this router hasn't originated a Summary LSA for the input destination then the function returs the destination address as link state ID. If it has originated a Summary LSA for the input destination then the function checks which LSA would contain the longer netmask. If the two masks are equal then this means thet we're updating an LSA already in the database, so the function returns the destination address as link state ID. If the input destination netmask is longer then the one already in the database, then the returned link state ID is the input destination address ORed together with the inverse of the input destination mask. If the input destination netmask is shorter, then the Summary LSA already in the database has to be replaced by the current destination. In this case the lsaToReoriginate parameter is filled with a copy of the Summary LSA in the database with it's mask replaced by the destination mask and the cost replaced by the input destination cost; the returned link state ID is the input destination address ORed together with the inverse of the mask stored in the Summary LSA in the database. This means that if the lsaToReoriginate parameter is not nullptr on return then another lookup in the database is needed with the same LSAKey as used here(input destination address and the router's own routerID) and the resulting Summary LSA's link state ID should be changed to the one returned by this function.

Referenced by originateSummaryLSA().

1057 {
1058  if (lsaToReoriginate != nullptr) {
1059  delete lsaToReoriginate;
1060  lsaToReoriginate = nullptr;
1061  }
1062 
1063  LSAKeyType lsaKey;
1064 
1065  lsaKey.linkStateID = destination.address;
1066  lsaKey.advertisingRouter = parentRouter->getRouterID();
1067 
1068  const SummaryLSA *foundLSA = findSummaryLSA(lsaKey);
1069 
1070  if (foundLSA == nullptr) {
1071  return lsaKey.linkStateID;
1072  }
1073  else {
1074  IPv4Address existingMask = foundLSA->getNetworkMask();
1075 
1076  if (destination.mask == existingMask) {
1077  return lsaKey.linkStateID;
1078  }
1079  else {
1080  if (destination.mask >= existingMask) {
1081  return lsaKey.linkStateID.makeBroadcastAddress(destination.mask);
1082  }
1083  else {
1084  SummaryLSA *summaryLSA = new SummaryLSA(*foundLSA);
1085 
1086  long sequenceNumber = summaryLSA->getHeader().getLsSequenceNumber();
1087 
1088  summaryLSA->getHeader().setLsAge(0);
1089  summaryLSA->getHeader().setLsSequenceNumber((sequenceNumber == MAX_SEQUENCE_NUMBER) ? INITIAL_SEQUENCE_NUMBER : sequenceNumber + 1);
1090  summaryLSA->setNetworkMask(destination.mask);
1091  summaryLSA->setRouteCost(destinationCost);
1092 
1093  lsaToReoriginate = summaryLSA;
1094 
1095  return lsaKey.linkStateID.makeBroadcastAddress(existingMask);
1096  }
1097  }
1098  }
1099 }
#define INITIAL_SEQUENCE_NUMBER
Definition: OSPFcommon.h:42
RouterID getRouterID() const
Definition: OSPFRouter.h:72
#define MAX_SEQUENCE_NUMBER
Definition: OSPFcommon.h:43
SummaryLSA * findSummaryLSA(LSAKeyType lsaKey)
Definition: OSPFArea.cc:372
Router * parentRouter
Definition: OSPFArea.h:57
bool inet::ospf::Area::hasAddressRange ( IPv4AddressRange  addressRange) const
172 {
173  int addressRangeNum = areaAddressRanges.size();
174  for (int i = 0; i < addressRangeNum; i++) {
175  if (areaAddressRanges[i] == addressRange) {
176  return true;
177  }
178  }
179  return false;
180 }
std::vector< IPv4AddressRange > areaAddressRanges
Definition: OSPFArea.h:43
bool inet::ospf::Area::hasAnyNeighborInStates ( int  states) const

Referenced by ageDatabase().

697 {
698  long interfaceCount = associatedInterfaces.size();
699  for (long i = 0; i < interfaceCount; i++) {
701  return true;
702  }
703  }
704  return false;
705 }
bool hasAnyNeighborInStates(int states) const
Definition: OSPFArea.cc:696
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
bool inet::ospf::Area::hasLink ( OSPFLSA fromLSA,
OSPFLSA toLSA 
) const
private

Referenced by calculateShortestPathTree().

2125 {
2126  unsigned int i;
2127 
2128  RouterLSA *fromRouterLSA = dynamic_cast<RouterLSA *>(fromLSA);
2129  if (fromRouterLSA != nullptr) {
2130  unsigned int linkCount = fromRouterLSA->getLinksArraySize();
2131  RouterLSA *toRouterLSA = dynamic_cast<RouterLSA *>(toLSA);
2132  if (toRouterLSA != nullptr) {
2133  for (i = 0; i < linkCount; i++) {
2134  Link& link = fromRouterLSA->getLinks(i);
2135  LinkType linkType = static_cast<LinkType>(link.getType());
2136 
2137  if (((linkType == POINTTOPOINT_LINK) ||
2138  (linkType == VIRTUAL_LINK)) &&
2139  (link.getLinkID() == toRouterLSA->getHeader().getLinkStateID()))
2140  {
2141  return true;
2142  }
2143  }
2144  }
2145  else {
2146  NetworkLSA *toNetworkLSA = dynamic_cast<NetworkLSA *>(toLSA);
2147  if (toNetworkLSA != nullptr) {
2148  for (i = 0; i < linkCount; i++) {
2149  Link& link = fromRouterLSA->getLinks(i);
2150 
2151  if ((link.getType() == TRANSIT_LINK) &&
2152  (link.getLinkID() == toNetworkLSA->getHeader().getLinkStateID()))
2153  {
2154  return true;
2155  }
2156  if ((link.getType() == STUB_LINK) &&
2157  ((link.getLinkID() & IPv4Address(link.getLinkData())) == (toNetworkLSA->getHeader().getLinkStateID() & toNetworkLSA->getNetworkMask()))) //FIXME should compare masks?
2158  {
2159  return true;
2160  }
2161  }
2162  }
2163  }
2164  }
2165  else {
2166  NetworkLSA *fromNetworkLSA = dynamic_cast<NetworkLSA *>(fromLSA);
2167  if (fromNetworkLSA != nullptr) {
2168  unsigned int routerCount = fromNetworkLSA->getAttachedRoutersArraySize();
2169  RouterLSA *toRouterLSA = dynamic_cast<RouterLSA *>(toLSA);
2170  if (toRouterLSA != nullptr) {
2171  for (i = 0; i < routerCount; i++) {
2172  if (fromNetworkLSA->getAttachedRouters(i) == toRouterLSA->getHeader().getLinkStateID()) {
2173  return true;
2174  }
2175  }
2176  }
2177  }
2178  }
2179 
2180  return false;
2181 }
Definition: OSPFPacket_m.h:379
Definition: OSPFPacket_m.h:378
Definition: OSPFPacket_m.h:377
LinkType
Enum generated from inet/routing/ospfv2/OSPFPacket.msg:115 by nedtool.
Definition: OSPFPacket_m.h:375
Definition: OSPFPacket_m.h:376
bool inet::ospf::Area::hasVirtualLink ( AreaID  withTransitArea) const

Referenced by originateRouterLSA().

232 {
233  if ((areaID != BACKBONE_AREAID) || (withTransitArea == BACKBONE_AREAID)) {
234  return false;
235  }
236 
237  int interfaceNum = associatedInterfaces.size();
238  for (int i = 0; i < interfaceNum; i++) {
239  if ((associatedInterfaces[i]->getType() == Interface::VIRTUAL) &&
240  (associatedInterfaces[i]->getTransitAreaID() == withTransitArea))
241  {
242  return true;
243  }
244  }
245  return false;
246 }
Definition: OSPFInterface.h:60
const AreaID BACKBONE_AREAID(0, 0, 0, 0)
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
AreaID areaID
Definition: OSPFArea.h:41
std::string inet::ospf::Area::info ( ) const
override
110 {
111  std::stringstream out;
112  out << "areaID: " << areaID.str(false);
113  return out.str();
114 }
std::string str(bool printUnspec=true) const
Returns the string representation of the address (e.g.
Definition: IPv4Address.cc:109
AreaID areaID
Definition: OSPFArea.h:41
bool inet::ospf::Area::installNetworkLSA ( OSPFNetworkLSA lsa)

Referenced by inet::ospf::InterfaceState::changeState().

283 {
284  LinkStateID linkStateID = lsa->getHeader().getLinkStateID();
285  auto lsaIt = networkLSAsByID.find(linkStateID);
286  if (lsaIt != networkLSAsByID.end()) {
287  LSAKeyType lsaKey;
288 
289  lsaKey.linkStateID = lsa->getHeader().getLinkStateID();
290  lsaKey.advertisingRouter = lsa->getHeader().getAdvertisingRouter();
291 
293  return lsaIt->second->update(lsa);
294  }
295  else {
296  NetworkLSA *lsaCopy = new NetworkLSA(*lsa);
297  networkLSAsByID[linkStateID] = lsaCopy;
298  networkLSAs.push_back(lsaCopy);
299  return true;
300  }
301 }
std::vector< NetworkLSA * > networkLSAs
Definition: OSPFArea.h:49
void removeFromAllRetransmissionLists(LSAKeyType lsaKey)
Definition: OSPFArea.cc:707
IPv4Address LinkStateID
Definition: OSPFcommon.h:139
std::map< LinkStateID, NetworkLSA * > networkLSAsByID
Definition: OSPFArea.h:48
bool inet::ospf::Area::installRouterLSA ( OSPFRouterLSA lsa)

Referenced by calculateShortestPathTree(), and inet::ospf::InterfaceState::changeState().

262 {
263  LinkStateID linkStateID = lsa->getHeader().getLinkStateID();
264  auto lsaIt = routerLSAsByID.find(linkStateID);
265  if (lsaIt != routerLSAsByID.end()) {
266  LSAKeyType lsaKey;
267 
268  lsaKey.linkStateID = lsa->getHeader().getLinkStateID();
269  lsaKey.advertisingRouter = lsa->getHeader().getAdvertisingRouter();
270 
272  return lsaIt->second->update(lsa);
273  }
274  else {
275  RouterLSA *lsaCopy = new RouterLSA(*lsa);
276  routerLSAsByID[linkStateID] = lsaCopy;
277  routerLSAs.push_back(lsaCopy);
278  return true;
279  }
280 }
std::map< LinkStateID, RouterLSA * > routerLSAsByID
Definition: OSPFArea.h:46
void removeFromAllRetransmissionLists(LSAKeyType lsaKey)
Definition: OSPFArea.cc:707
std::vector< RouterLSA * > routerLSAs
Definition: OSPFArea.h:47
IPv4Address LinkStateID
Definition: OSPFcommon.h:139
bool inet::ospf::Area::installSummaryLSA ( OSPFSummaryLSA lsa)
304 {
305  LSAKeyType lsaKey;
306 
307  lsaKey.linkStateID = lsa->getHeader().getLinkStateID();
308  lsaKey.advertisingRouter = lsa->getHeader().getAdvertisingRouter();
309 
310  auto lsaIt = summaryLSAsByID.find(lsaKey);
311  if (lsaIt != summaryLSAsByID.end()) {
312  LSAKeyType lsaKey;
313 
314  lsaKey.linkStateID = lsa->getHeader().getLinkStateID();
315  lsaKey.advertisingRouter = lsa->getHeader().getAdvertisingRouter();
316 
318  return lsaIt->second->update(lsa);
319  }
320  else {
321  SummaryLSA *lsaCopy = new SummaryLSA(*lsa);
322  summaryLSAsByID[lsaKey] = lsaCopy;
323  summaryLSAs.push_back(lsaCopy);
324  return true;
325  }
326 }
void removeFromAllRetransmissionLists(LSAKeyType lsaKey)
Definition: OSPFArea.cc:707
std::vector< SummaryLSA * > summaryLSAs
Definition: OSPFArea.h:51
std::map< LSAKeyType, SummaryLSA *, LSAKeyType_Less > summaryLSAsByID
Definition: OSPFArea.h:50
bool inet::ospf::Area::isLocalAddress ( IPv4Address  address) const
741 {
742  long interfaceCount = associatedInterfaces.size();
743  for (long i = 0; i < interfaceCount; i++) {
744  if (associatedInterfaces[i]->getAddressRange().address == address) {
745  return true;
746  }
747  }
748  return false;
749 }
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
IPv4AddressRange getAddressRange(unsigned int index) const
Definition: OSPFArea.h:67
bool inet::ospf::Area::isOnAnyRetransmissionList ( LSAKeyType  lsaKey) const

Referenced by ageDatabase().

716 {
717  long interfaceCount = associatedInterfaces.size();
718  for (long i = 0; i < interfaceCount; i++) {
720  return true;
721  }
722  }
723  return false;
724 }
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
bool isOnAnyRetransmissionList(LSAKeyType lsaKey) const
Definition: OSPFArea.cc:715
NetworkLSA * inet::ospf::Area::originateNetworkLSA ( const Interface intf)

Referenced by ageDatabase(), inet::ospf::NeighborState::changeState(), and inet::ospf::InterfaceState::changeState().

996 {
997  if (intf->hasAnyNeighborInStates(Neighbor::FULL_STATE)) {
998  NetworkLSA *networkLSA = new NetworkLSA;
999  OSPFLSAHeader& lsaHeader = networkLSA->getHeader();
1000  long neighborCount = intf->getNeighborCount();
1001  OSPFOptions lsOptions;
1002 
1003  lsaHeader.setLsAge(0);
1004  memset(&lsOptions, 0, sizeof(OSPFOptions));
1005  lsOptions.E_ExternalRoutingCapability = externalRoutingCapability;
1006  lsaHeader.setLsOptions(lsOptions);
1007  lsaHeader.setLsType(NETWORKLSA_TYPE);
1008  lsaHeader.setLinkStateID(intf->getAddressRange().address);
1009  lsaHeader.setAdvertisingRouter(IPv4Address(parentRouter->getRouterID()));
1010  lsaHeader.setLsSequenceNumber(INITIAL_SEQUENCE_NUMBER);
1011 
1012  networkLSA->setNetworkMask(intf->getAddressRange().mask);
1013 
1014  for (long j = 0; j < neighborCount; j++) {
1015  const Neighbor *neighbor = intf->getNeighbor(j);
1016  if (neighbor->getState() == Neighbor::FULL_STATE) {
1017  unsigned short netIndex = networkLSA->getAttachedRoutersArraySize();
1018  networkLSA->setAttachedRoutersArraySize(netIndex + 1);
1019  networkLSA->setAttachedRouters(netIndex, IPv4Address(neighbor->getNeighborID()));
1020  }
1021  }
1022  unsigned short netIndex = networkLSA->getAttachedRoutersArraySize();
1023  networkLSA->setAttachedRoutersArraySize(netIndex + 1);
1024  networkLSA->setAttachedRouters(netIndex, IPv4Address(parentRouter->getRouterID()));
1025 
1026  return networkLSA;
1027  }
1028  else {
1029  return nullptr;
1030  }
1031 }
#define INITIAL_SEQUENCE_NUMBER
Definition: OSPFcommon.h:42
bool externalRoutingCapability
Definition: OSPFArea.h:53
RouterID getRouterID() const
Definition: OSPFRouter.h:72
Definition: OSPFPacket_m.h:246
Router * parentRouter
Definition: OSPFArea.h:57
Definition: OSPFNeighbor.h:69
RouterLSA * inet::ospf::Area::originateRouterLSA ( )

Referenced by ageDatabase(), calculateShortestPathTree(), inet::ospf::InterfaceState::changeState(), inet::ospf::NeighborState::changeState(), and inet::ospf::HelloHandler::processPacket().

752 {
753  RouterLSA *routerLSA = new RouterLSA;
754  OSPFLSAHeader& lsaHeader = routerLSA->getHeader();
755  long interfaceCount = associatedInterfaces.size();
756  OSPFOptions lsOptions;
757  long i;
758 
759  lsaHeader.setLsAge(0);
760  memset(&lsOptions, 0, sizeof(OSPFOptions));
761  lsOptions.E_ExternalRoutingCapability = externalRoutingCapability;
762  lsaHeader.setLsOptions(lsOptions);
763  lsaHeader.setLsType(ROUTERLSA_TYPE);
764  lsaHeader.setLinkStateID(parentRouter->getRouterID());
765  lsaHeader.setAdvertisingRouter(IPv4Address(parentRouter->getRouterID()));
766  lsaHeader.setLsSequenceNumber(INITIAL_SEQUENCE_NUMBER);
767 
768  routerLSA->setB_AreaBorderRouter(parentRouter->getAreaCount() > 1);
769  routerLSA->setE_ASBoundaryRouter((externalRoutingCapability && parentRouter->getASBoundaryRouter()) ? true : false);
771  routerLSA->setV_VirtualLinkEndpoint((backbone == nullptr) ? false : backbone->hasVirtualLink(areaID));
772 
773  routerLSA->setNumberOfLinks(0);
774  routerLSA->setLinksArraySize(0);
775  for (i = 0; i < interfaceCount; i++) {
776  Interface *intf = associatedInterfaces[i];
777 
778  if (intf->getState() == Interface::DOWN_STATE) {
779  continue;
780  }
781  if ((intf->getState() == Interface::LOOPBACK_STATE) &&
782  ((intf->getType() != Interface::POINTTOPOINT) ||
783  (intf->getAddressRange().address != NULL_IPV4ADDRESS)))
784  {
785  Link stubLink;
786  stubLink.setType(STUB_LINK);
787  stubLink.setLinkID(intf->getAddressRange().address);
788  stubLink.setLinkData(0xFFFFFFFF);
789  stubLink.setLinkCost(0);
790  stubLink.setNumberOfTOS(0);
791  stubLink.setTosDataArraySize(0);
792 
793  unsigned short linkIndex = routerLSA->getLinksArraySize();
794  routerLSA->setLinksArraySize(linkIndex + 1);
795  routerLSA->setNumberOfLinks(linkIndex + 1);
796  routerLSA->setLinks(linkIndex, stubLink);
797  }
798  if (intf->getState() > Interface::LOOPBACK_STATE) {
799  switch (intf->getType()) {
801  Neighbor *neighbor = (intf->getNeighborCount() > 0) ? intf->getNeighbor(0) : nullptr;
802  if (neighbor != nullptr) {
803  if (neighbor->getState() == Neighbor::FULL_STATE) {
804  Link link;
805  link.setType(POINTTOPOINT_LINK);
806  link.setLinkID(IPv4Address(neighbor->getNeighborID()));
807  if (intf->getAddressRange().address != NULL_IPV4ADDRESS) {
808  link.setLinkData(intf->getAddressRange().address.getInt());
809  }
810  else {
811  link.setLinkData(intf->getIfIndex());
812  }
813  link.setLinkCost(intf->getOutputCost());
814  link.setNumberOfTOS(0);
815  link.setTosDataArraySize(0);
816 
817  unsigned short linkIndex = routerLSA->getLinksArraySize();
818  routerLSA->setLinksArraySize(linkIndex + 1);
819  routerLSA->setNumberOfLinks(linkIndex + 1);
820  routerLSA->setLinks(linkIndex, link);
821  }
822  if (intf->getState() == Interface::POINTTOPOINT_STATE) {
823  if (neighbor->getAddress() != NULL_IPV4ADDRESS) {
824  Link stubLink;
825  stubLink.setType(STUB_LINK);
826  stubLink.setLinkID(neighbor->getAddress());
827  stubLink.setLinkData(0xFFFFFFFF);
828  stubLink.setLinkCost(intf->getOutputCost());
829  stubLink.setNumberOfTOS(0);
830  stubLink.setTosDataArraySize(0);
831 
832  unsigned short linkIndex = routerLSA->getLinksArraySize();
833  routerLSA->setLinksArraySize(linkIndex + 1);
834  routerLSA->setNumberOfLinks(linkIndex + 1);
835  routerLSA->setLinks(linkIndex, stubLink);
836  }
837  else {
838  if (intf->getAddressRange().mask.getInt() != 0xFFFFFFFF) {
839  Link stubLink;
840  stubLink.setType(STUB_LINK);
841  stubLink.setLinkID(intf->getAddressRange().address
842  & intf->getAddressRange().mask);
843  stubLink.setLinkData(intf->getAddressRange().mask.getInt());
844  stubLink.setLinkCost(intf->getOutputCost());
845  stubLink.setNumberOfTOS(0);
846  stubLink.setTosDataArraySize(0);
847 
848  unsigned short linkIndex = routerLSA->getLinksArraySize();
849  routerLSA->setLinksArraySize(linkIndex + 1);
850  routerLSA->setNumberOfLinks(linkIndex + 1);
851  routerLSA->setLinks(linkIndex, stubLink);
852  }
853  }
854  }
855  }
856  }
857  break;
858 
860  case Interface::NBMA: {
861  if (intf->getState() == Interface::WAITING_STATE) {
862  Link stubLink;
863  stubLink.setType(STUB_LINK);
864  stubLink.setLinkID(intf->getAddressRange().address
865  & intf->getAddressRange().mask);
866  stubLink.setLinkData(intf->getAddressRange().mask.getInt());
867  stubLink.setLinkCost(intf->getOutputCost());
868  stubLink.setNumberOfTOS(0);
869  stubLink.setTosDataArraySize(0);
870 
871  unsigned short linkIndex = routerLSA->getLinksArraySize();
872  routerLSA->setLinksArraySize(linkIndex + 1);
873  routerLSA->setNumberOfLinks(linkIndex + 1);
874  routerLSA->setLinks(linkIndex, stubLink);
875  }
876  else {
877  Neighbor *dRouter = intf->getNeighborByAddress(intf->getDesignatedRouter().ipInterfaceAddress);
878  if (((dRouter != nullptr) && (dRouter->getState() == Neighbor::FULL_STATE)) ||
879  ((intf->getDesignatedRouter().routerID == parentRouter->getRouterID()) &&
880  (intf->hasAnyNeighborInStates(Neighbor::FULL_STATE))))
881  {
882  Link link;
883  link.setType(TRANSIT_LINK);
884  link.setLinkID(intf->getDesignatedRouter().ipInterfaceAddress);
885  link.setLinkData(intf->getAddressRange().address.getInt());
886  link.setLinkCost(intf->getOutputCost());
887  link.setNumberOfTOS(0);
888  link.setTosDataArraySize(0);
889 
890  unsigned short linkIndex = routerLSA->getLinksArraySize();
891  routerLSA->setLinksArraySize(linkIndex + 1);
892  routerLSA->setNumberOfLinks(linkIndex + 1);
893  routerLSA->setLinks(linkIndex, link);
894  }
895  else {
896  Link stubLink;
897  stubLink.setType(STUB_LINK);
898  stubLink.setLinkID(intf->getAddressRange().address
899  & intf->getAddressRange().mask);
900  stubLink.setLinkData(intf->getAddressRange().mask.getInt());
901  stubLink.setLinkCost(intf->getOutputCost());
902  stubLink.setNumberOfTOS(0);
903  stubLink.setTosDataArraySize(0);
904 
905  unsigned short linkIndex = routerLSA->getLinksArraySize();
906  routerLSA->setLinksArraySize(linkIndex + 1);
907  routerLSA->setNumberOfLinks(linkIndex + 1);
908  routerLSA->setLinks(linkIndex, stubLink);
909  }
910  }
911  }
912  break;
913 
914  case Interface::VIRTUAL: {
915  Neighbor *neighbor = (intf->getNeighborCount() > 0) ? intf->getNeighbor(0) : nullptr;
916  if ((neighbor != nullptr) && (neighbor->getState() == Neighbor::FULL_STATE)) {
917  Link link;
918  link.setType(VIRTUAL_LINK);
919  link.setLinkID(IPv4Address(neighbor->getNeighborID()));
920  link.setLinkData(intf->getAddressRange().address.getInt());
921  link.setLinkCost(intf->getOutputCost());
922  link.setNumberOfTOS(0);
923  link.setTosDataArraySize(0);
924 
925  unsigned short linkIndex = routerLSA->getLinksArraySize();
926  routerLSA->setLinksArraySize(linkIndex + 1);
927  routerLSA->setNumberOfLinks(linkIndex + 1);
928  routerLSA->setLinks(linkIndex, link);
929  }
930  }
931  break;
932 
934  Link stubLink;
935  stubLink.setType(STUB_LINK);
936  stubLink.setLinkID(intf->getAddressRange().address);
937  stubLink.setLinkData(0xFFFFFFFF);
938  stubLink.setLinkCost(0);
939  stubLink.setNumberOfTOS(0);
940  stubLink.setTosDataArraySize(0);
941 
942  unsigned short linkIndex = routerLSA->getLinksArraySize();
943  routerLSA->setLinksArraySize(linkIndex + 1);
944  routerLSA->setNumberOfLinks(linkIndex + 1);
945  routerLSA->setLinks(linkIndex, stubLink);
946 
947  long neighborCount = intf->getNeighborCount();
948  for (long i = 0; i < neighborCount; i++) {
949  Neighbor *neighbor = intf->getNeighbor(i);
950  if (neighbor->getState() == Neighbor::FULL_STATE) {
951  Link link;
952  link.setType(POINTTOPOINT_LINK);
953  link.setLinkID(IPv4Address(neighbor->getNeighborID()));
954  link.setLinkData(intf->getAddressRange().address.getInt());
955  link.setLinkCost(intf->getOutputCost());
956  link.setNumberOfTOS(0);
957  link.setTosDataArraySize(0);
958 
959  unsigned short linkIndex = routerLSA->getLinksArraySize();
960  routerLSA->setLinksArraySize(linkIndex + 1);
961  routerLSA->setNumberOfLinks(linkIndex + 1);
962  routerLSA->setLinks(linkIndex, stubLink);
963  }
964  }
965  }
966  break;
967 
968  default:
969  break;
970  }
971  }
972  }
973 
974  long hostRouteCount = hostRoutes.size();
975  for (i = 0; i < hostRouteCount; i++) {
976  Link stubLink;
977  stubLink.setType(STUB_LINK);
978  stubLink.setLinkID(hostRoutes[i].address);
979  stubLink.setLinkData(0xFFFFFFFF);
980  stubLink.setLinkCost(hostRoutes[i].linkCost);
981  stubLink.setNumberOfTOS(0);
982  stubLink.setTosDataArraySize(0);
983 
984  unsigned short linkIndex = routerLSA->getLinksArraySize();
985  routerLSA->setLinksArraySize(linkIndex + 1);
986  routerLSA->setNumberOfLinks(linkIndex + 1);
987  routerLSA->setLinks(linkIndex, stubLink);
988  }
989 
990  routerLSA->setSource(LSATrackingInfo::ORIGINATED);
991 
992  return routerLSA;
993 }
const IPv4Address NULL_IPV4ADDRESS(0, 0, 0, 0)
#define INITIAL_SEQUENCE_NUMBER
Definition: OSPFcommon.h:42
Definition: OSPFInterface.h:60
Definition: OSPFInterface.h:66
Definition: OSPFPacket_m.h:379
Definition: OSPFInterface.h:65
Definition: OSPFInterface.h:64
bool externalRoutingCapability
Definition: OSPFArea.h:53
Definition: OSPFInterface.h:56
RouterID getRouterID() const
Definition: OSPFRouter.h:72
const AreaID BACKBONE_AREAID(0, 0, 0, 0)
Definition: OSPFPacket_m.h:378
Definition: OSPFInterface.h:58
Area(IInterfaceTable *ift, AreaID id=BACKBONE_AREAID)
Definition: OSPFArea.cc:26
Definition: OSPFPacket_m.h:377
Definition: OSPFInterface.h:57
Definition: OSPFInterface.h:59
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
unsigned long getAreaCount() const
Definition: OSPFRouter.h:75
Area * getAreaByID(AreaID areaID)
Returns the pointer to the Area identified by the input areaID, if it&#39;s on the Area list...
Definition: OSPFRouter.cc:72
Definition: OSPFPacket_m.h:245
bool getASBoundaryRouter() const
Definition: OSPFRouter.h:82
Definition: OSPFInterface.h:67
Router * parentRouter
Definition: OSPFArea.h:57
Definition: OSPFNeighbor.h:69
AreaID areaID
Definition: OSPFArea.h:41
Definition: OSPFPacket_m.h:376
std::vector< HostRouteParameters > hostRoutes
Definition: OSPFArea.h:45
SummaryLSA * inet::ospf::Area::originateSummaryLSA ( const RoutingTableEntry entry,
const std::map< LSAKeyType, bool, LSAKeyType_Less > &  originatedLSAs,
SummaryLSA *&  lsaToReoriginate 
)

Referenced by ageDatabase(), and originateSummaryLSA().

1104 {
1105  if (((entry->getDestinationType() & RoutingTableEntry::AREA_BORDER_ROUTER_DESTINATION) != 0) ||
1106  (entry->getPathType() == RoutingTableEntry::TYPE1_EXTERNAL) ||
1107  (entry->getPathType() == RoutingTableEntry::TYPE2_EXTERNAL) ||
1108  (entry->getArea() == areaID))
1109  {
1110  return nullptr;
1111  }
1112 
1113  bool allNextHopsInThisArea = true;
1114  unsigned int nextHopCount = entry->getNextHopCount();
1115 
1116  for (unsigned int i = 0; i < nextHopCount; i++) {
1117  Interface *nextHopInterface = parentRouter->getNonVirtualInterface(entry->getNextHop(i).ifIndex);
1118  if ((nextHopInterface != nullptr) && (nextHopInterface->getAreaID() != areaID)) {
1119  allNextHopsInThisArea = false;
1120  break;
1121  }
1122  }
1123  if ((allNextHopsInThisArea) || (entry->getCost() >= LS_INFINITY)) {
1124  return nullptr;
1125  }
1126 
1127  if ((entry->getDestinationType() & RoutingTableEntry::AS_BOUNDARY_ROUTER_DESTINATION) != 0) {
1128  RoutingTableEntry *preferredEntry = parentRouter->getPreferredEntry(*(entry->getLinkStateOrigin()), false);
1129  if ((preferredEntry != nullptr) && (*preferredEntry == *entry) && (externalRoutingCapability)) {
1130  SummaryLSA *summaryLSA = new SummaryLSA;
1131  OSPFLSAHeader& lsaHeader = summaryLSA->getHeader();
1132  OSPFOptions lsOptions;
1133 
1134  lsaHeader.setLsAge(0);
1135  memset(&lsOptions, 0, sizeof(OSPFOptions));
1136  lsOptions.E_ExternalRoutingCapability = externalRoutingCapability;
1137  lsaHeader.setLsOptions(lsOptions);
1138  lsaHeader.setLsType(SUMMARYLSA_ASBOUNDARYROUTERS_TYPE);
1139  lsaHeader.setLinkStateID(entry->getDestination());
1140  lsaHeader.setAdvertisingRouter(IPv4Address(parentRouter->getRouterID()));
1141  lsaHeader.setLsSequenceNumber(INITIAL_SEQUENCE_NUMBER);
1142 
1143  summaryLSA->setNetworkMask(entry->getNetmask());
1144  summaryLSA->setRouteCost(entry->getCost());
1145  summaryLSA->setTosDataArraySize(0);
1146 
1147  summaryLSA->setSource(LSATrackingInfo::ORIGINATED);
1148 
1149  return summaryLSA;
1150  }
1151  }
1152  else { // entry->getDestinationType() == RoutingTableEntry::NETWORK_DESTINATION
1153  if (entry->getPathType() == RoutingTableEntry::INTERAREA) {
1154  IPv4AddressRange destinationRange;
1155 
1156  destinationRange.address = entry->getDestination();
1157  destinationRange.mask = entry->getNetmask();
1158 
1159  LinkStateID newLinkStateID = getUniqueLinkStateID(destinationRange, entry->getCost(), lsaToReoriginate);
1160 
1161  if (lsaToReoriginate != nullptr) {
1162  LSAKeyType lsaKey;
1163 
1164  lsaKey.linkStateID = entry->getDestination();
1165  lsaKey.advertisingRouter = parentRouter->getRouterID();
1166 
1167  auto lsaIt = summaryLSAsByID.find(lsaKey);
1168  if (lsaIt == summaryLSAsByID.end()) {
1169  delete (lsaToReoriginate);
1170  lsaToReoriginate = nullptr;
1171  return nullptr;
1172  }
1173  else {
1174  SummaryLSA *summaryLSA = new SummaryLSA(*(lsaIt->second));
1175  OSPFLSAHeader& lsaHeader = summaryLSA->getHeader();
1176 
1177  lsaHeader.setLsAge(0);
1178  lsaHeader.setLsSequenceNumber(INITIAL_SEQUENCE_NUMBER);
1179  lsaHeader.setLinkStateID(newLinkStateID);
1180 
1181  return summaryLSA;
1182  }
1183  }
1184  else {
1185  SummaryLSA *summaryLSA = new SummaryLSA;
1186  OSPFLSAHeader& lsaHeader = summaryLSA->getHeader();
1187  OSPFOptions lsOptions;
1188 
1189  lsaHeader.setLsAge(0);
1190  memset(&lsOptions, 0, sizeof(OSPFOptions));
1191  lsOptions.E_ExternalRoutingCapability = externalRoutingCapability;
1192  lsaHeader.setLsOptions(lsOptions);
1193  lsaHeader.setLsType(SUMMARYLSA_NETWORKS_TYPE);
1194  lsaHeader.setLinkStateID(newLinkStateID);
1195  lsaHeader.setAdvertisingRouter(IPv4Address(parentRouter->getRouterID()));
1196  lsaHeader.setLsSequenceNumber(INITIAL_SEQUENCE_NUMBER);
1197 
1198  summaryLSA->setNetworkMask(entry->getNetmask());
1199  summaryLSA->setRouteCost(entry->getCost());
1200  summaryLSA->setTosDataArraySize(0);
1201 
1202  summaryLSA->setSource(LSATrackingInfo::ORIGINATED);
1203 
1204  return summaryLSA;
1205  }
1206  }
1207  else { // entry->getPathType() == RoutingTableEntry::INTRAAREA
1208  IPv4AddressRange destinationAddressRange;
1209 
1210  destinationAddressRange.address = entry->getDestination();
1211  destinationAddressRange.mask = entry->getNetmask();
1212 
1213  bool doAdvertise = false;
1214  IPv4AddressRange containingAddressRange = parentRouter->getContainingAddressRange(destinationAddressRange, &doAdvertise);
1215  if (((entry->getArea() == BACKBONE_AREAID) && // the backbone's configured ranges should be ignored
1216  (transitCapability)) || // when originating Summary LSAs into transit areas
1217  (containingAddressRange == NULL_IPV4ADDRESSRANGE))
1218  {
1219  LinkStateID newLinkStateID = getUniqueLinkStateID(destinationAddressRange, entry->getCost(), lsaToReoriginate);
1220 
1221  if (lsaToReoriginate != nullptr) {
1222  LSAKeyType lsaKey;
1223 
1224  lsaKey.linkStateID = entry->getDestination();
1225  lsaKey.advertisingRouter = parentRouter->getRouterID();
1226 
1227  auto lsaIt = summaryLSAsByID.find(lsaKey);
1228  if (lsaIt == summaryLSAsByID.end()) {
1229  delete (lsaToReoriginate);
1230  lsaToReoriginate = nullptr;
1231  return nullptr;
1232  }
1233  else {
1234  SummaryLSA *summaryLSA = new SummaryLSA(*(lsaIt->second));
1235  OSPFLSAHeader& lsaHeader = summaryLSA->getHeader();
1236 
1237  lsaHeader.setLsAge(0);
1238  lsaHeader.setLsSequenceNumber(INITIAL_SEQUENCE_NUMBER);
1239  lsaHeader.setLinkStateID(newLinkStateID);
1240 
1241  return summaryLSA;
1242  }
1243  }
1244  else {
1245  SummaryLSA *summaryLSA = new SummaryLSA;
1246  OSPFLSAHeader& lsaHeader = summaryLSA->getHeader();
1247  OSPFOptions lsOptions;
1248 
1249  lsaHeader.setLsAge(0);
1250  memset(&lsOptions, 0, sizeof(OSPFOptions));
1251  lsOptions.E_ExternalRoutingCapability = externalRoutingCapability;
1252  lsaHeader.setLsOptions(lsOptions);
1253  lsaHeader.setLsType(SUMMARYLSA_NETWORKS_TYPE);
1254  lsaHeader.setLinkStateID(newLinkStateID);
1255  lsaHeader.setAdvertisingRouter(IPv4Address(parentRouter->getRouterID()));
1256  lsaHeader.setLsSequenceNumber(INITIAL_SEQUENCE_NUMBER);
1257 
1258  summaryLSA->setNetworkMask(entry->getNetmask());
1259  summaryLSA->setRouteCost(entry->getCost());
1260  summaryLSA->setTosDataArraySize(0);
1261 
1262  summaryLSA->setSource(LSATrackingInfo::ORIGINATED);
1263 
1264  return summaryLSA;
1265  }
1266  }
1267  else {
1268  if (doAdvertise) {
1269  Metric maxRangeCost = 0;
1270  unsigned long entryCount = parentRouter->getRoutingTableEntryCount();
1271 
1272  for (unsigned long i = 0; i < entryCount; i++) {
1273  const RoutingTableEntry *routingEntry = parentRouter->getRoutingTableEntry(i);
1274 
1275  if ((routingEntry->getDestinationType() == RoutingTableEntry::NETWORK_DESTINATION) &&
1276  (routingEntry->getPathType() == RoutingTableEntry::INTRAAREA) &&
1277  containingAddressRange.containsRange(routingEntry->getDestination(), routingEntry->getNetmask()) &&
1278  (routingEntry->getCost() > maxRangeCost))
1279  {
1280  maxRangeCost = routingEntry->getCost();
1281  }
1282  }
1283 
1284  LinkStateID newLinkStateID = getUniqueLinkStateID(containingAddressRange, maxRangeCost, lsaToReoriginate);
1285  LSAKeyType lsaKey;
1286 
1287  if (lsaToReoriginate != nullptr) {
1288  lsaKey.linkStateID = lsaToReoriginate->getHeader().getLinkStateID();
1289  lsaKey.advertisingRouter = parentRouter->getRouterID();
1290 
1291  std::map<LSAKeyType, bool, LSAKeyType_Less>::const_iterator originatedIt = originatedLSAs.find(lsaKey);
1292  if (originatedIt != originatedLSAs.end()) {
1293  delete (lsaToReoriginate);
1294  lsaToReoriginate = nullptr;
1295  return nullptr;
1296  }
1297 
1298  lsaKey.linkStateID = entry->getDestination();
1299  lsaKey.advertisingRouter = parentRouter->getRouterID();
1300 
1301  auto lsaIt = summaryLSAsByID.find(lsaKey);
1302  if (lsaIt == summaryLSAsByID.end()) {
1303  delete (lsaToReoriginate);
1304  lsaToReoriginate = nullptr;
1305  return nullptr;
1306  }
1307 
1308  SummaryLSA *summaryLSA = new SummaryLSA(*(lsaIt->second));
1309  OSPFLSAHeader& lsaHeader = summaryLSA->getHeader();
1310 
1311  lsaHeader.setLsAge(0);
1312  lsaHeader.setLsSequenceNumber(INITIAL_SEQUENCE_NUMBER);
1313  lsaHeader.setLinkStateID(newLinkStateID);
1314 
1315  return summaryLSA;
1316  }
1317  else {
1318  lsaKey.linkStateID = newLinkStateID;
1319  lsaKey.advertisingRouter = parentRouter->getRouterID();
1320 
1321  std::map<LSAKeyType, bool, LSAKeyType_Less>::const_iterator originatedIt = originatedLSAs.find(lsaKey);
1322  if (originatedIt != originatedLSAs.end()) {
1323  return nullptr;
1324  }
1325 
1326  SummaryLSA *summaryLSA = new SummaryLSA;
1327  OSPFLSAHeader& lsaHeader = summaryLSA->getHeader();
1328  OSPFOptions lsOptions;
1329 
1330  lsaHeader.setLsAge(0);
1331  memset(&lsOptions, 0, sizeof(OSPFOptions));
1332  lsOptions.E_ExternalRoutingCapability = externalRoutingCapability;
1333  lsaHeader.setLsOptions(lsOptions);
1334  lsaHeader.setLsType(SUMMARYLSA_NETWORKS_TYPE);
1335  lsaHeader.setLinkStateID(newLinkStateID);
1336  lsaHeader.setAdvertisingRouter(IPv4Address(parentRouter->getRouterID()));
1337  lsaHeader.setLsSequenceNumber(INITIAL_SEQUENCE_NUMBER);
1338 
1339  summaryLSA->setNetworkMask(entry->getNetmask());
1340  summaryLSA->setRouteCost(entry->getCost());
1341  summaryLSA->setTosDataArraySize(0);
1342 
1343  summaryLSA->setSource(LSATrackingInfo::ORIGINATED);
1344 
1345  return summaryLSA;
1346  }
1347  }
1348  }
1349  }
1350  }
1351 
1352  return nullptr;
1353 }
unsigned long Metric
Definition: OSPFcommon.h:64
#define INITIAL_SEQUENCE_NUMBER
Definition: OSPFcommon.h:42
Definition: OSPFRoutingTableEntry.h:42
Definition: OSPFRoutingTableEntry.h:39
Interface * getNonVirtualInterface(unsigned char ifIndex)
Returns the pointer of the physical Interface identified by the input interface index, nullptr if the Router doesn&#39;t have such an interface.
Definition: OSPFRouter.cc:95
LinkStateID getUniqueLinkStateID(IPv4AddressRange destination, Metric destinationCost, SummaryLSA *&lsaToReoriginate) const
Returns a link state ID for the input destination.
Definition: OSPFArea.cc:1054
RoutingTableEntry * getPreferredEntry(const OSPFLSA &lsa, bool skipSelfOriginated, std::vector< RoutingTableEntry * > *fromRoutingTable=nullptr)
Selects the preferred routing table entry for the input LSA(which is either an ASExternalLSA or a Sum...
Definition: OSPFRouter.cc:868
std::map< LSAKeyType, SummaryLSA *, LSAKeyType_Less > summaryLSAsByID
Definition: OSPFArea.h:50
bool externalRoutingCapability
Definition: OSPFArea.h:53
IPv4AddressRange getContainingAddressRange(const IPv4AddressRange &addressRange, bool *advertise=nullptr) const
Scans through the router&#39;s areas&#39; preconfigured address ranges and returns the one containing the inp...
Definition: OSPFRouter.cc:1054
RouterID getRouterID() const
Definition: OSPFRouter.h:72
const AreaID BACKBONE_AREAID(0, 0, 0, 0)
Definition: OSPFRoutingTableEntry.h:40
static const unsigned char NETWORK_DESTINATION
Definition: OSPFRoutingTableEntry.h:48
static const unsigned char AS_BOUNDARY_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:50
IPv4Address LinkStateID
Definition: OSPFcommon.h:139
RoutingTableEntry * getRoutingTableEntry(unsigned long i)
Definition: OSPFRouter.h:85
static const unsigned char AREA_BORDER_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:49
#define LS_INFINITY
Definition: TED.cc:32
unsigned long getRoutingTableEntryCount() const
Definition: OSPFRouter.h:84
bool transitCapability
Definition: OSPFArea.h:52
Router * parentRouter
Definition: OSPFArea.h:57
Definition: OSPFRoutingTableEntry.h:41
AreaID areaID
Definition: OSPFArea.h:41
Definition: OSPFPacket_m.h:247
Metric getCost() const
Definition: OSPFRoutingTableEntry.h:82
Definition: OSPFPacket_m.h:248
const IPv4AddressRange NULL_IPV4ADDRESSRANGE(IPv4Address(0, 0, 0, 0), IPv4Address(0, 0, 0, 0))
SummaryLSA * inet::ospf::Area::originateSummaryLSA ( const SummaryLSA summaryLSA)
private
1356 {
1357  const std::map<LSAKeyType, bool, LSAKeyType_Less> emptyMap;
1358  SummaryLSA *dontReoriginate = nullptr;
1359 
1360  const OSPFLSAHeader& lsaHeader = summaryLSA->getHeader();
1361  unsigned long entryCount = parentRouter->getRoutingTableEntryCount();
1362 
1363  for (unsigned long i = 0; i < entryCount; i++) {
1364  const RoutingTableEntry *entry = parentRouter->getRoutingTableEntry(i);
1365 
1366  if ((lsaHeader.getLsType() == SUMMARYLSA_ASBOUNDARYROUTERS_TYPE) &&
1367  ((((entry->getDestinationType() & RoutingTableEntry::AREA_BORDER_ROUTER_DESTINATION) != 0) ||
1368  ((entry->getDestinationType() & RoutingTableEntry::AS_BOUNDARY_ROUTER_DESTINATION) != 0)) &&
1369  ((entry->getDestination() == lsaHeader.getLinkStateID()) && //FIXME Why not compare network addresses (addr masked with netmask)?
1370  (entry->getNetmask() == summaryLSA->getNetworkMask()))))
1371  {
1372  SummaryLSA *returnLSA = originateSummaryLSA(entry, emptyMap, dontReoriginate);
1373  if (dontReoriginate != nullptr) {
1374  delete dontReoriginate;
1375  }
1376  return returnLSA;
1377  }
1378 
1379  IPv4Address lsaMask = summaryLSA->getNetworkMask();
1380 
1381  if ((lsaHeader.getLsType() == SUMMARYLSA_NETWORKS_TYPE) &&
1382  (entry->getDestinationType() == RoutingTableEntry::NETWORK_DESTINATION) &&
1383  isSameNetwork(entry->getDestination(), entry->getNetmask(), lsaHeader.getLinkStateID(), lsaMask))
1384  {
1385  SummaryLSA *returnLSA = originateSummaryLSA(entry, emptyMap, dontReoriginate);
1386  if (dontReoriginate != nullptr) {
1387  delete dontReoriginate;
1388  }
1389  return returnLSA;
1390  }
1391  }
1392 
1393  return nullptr;
1394 }
static const unsigned char NETWORK_DESTINATION
Definition: OSPFRoutingTableEntry.h:48
static const unsigned char AS_BOUNDARY_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:50
RoutingTableEntry * getRoutingTableEntry(unsigned long i)
Definition: OSPFRouter.h:85
static const unsigned char AREA_BORDER_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:49
SummaryLSA * originateSummaryLSA(const RoutingTableEntry *entry, const std::map< LSAKeyType, bool, LSAKeyType_Less > &originatedLSAs, SummaryLSA *&lsaToReoriginate)
Definition: OSPFArea.cc:1101
unsigned long getRoutingTableEntryCount() const
Definition: OSPFRouter.h:84
bool isSameNetwork(IPv4Address address1, IPv4Address mask1, IPv4Address address2, IPv4Address mask2)
Definition: OSPFcommon.h:182
Router * parentRouter
Definition: OSPFArea.h:57
Definition: OSPFPacket_m.h:247
Definition: OSPFPacket_m.h:248
void inet::ospf::Area::recheckSummaryLSAs ( std::vector< RoutingTableEntry * > &  newRoutingTable)
2424 {
2425  unsigned long i = 0;
2426  unsigned long j = 0;
2427  unsigned long lsaCount = summaryLSAs.size();
2428 
2429  for (i = 0; i < lsaCount; i++) {
2430  SummaryLSA *currentLSA = summaryLSAs[i];
2431  OSPFLSAHeader& currentHeader = currentLSA->getHeader();
2432 
2433  unsigned long routeCost = currentLSA->getRouteCost();
2434  unsigned short lsAge = currentHeader.getLsAge();
2435  RouterID originatingRouter = currentHeader.getAdvertisingRouter();
2436  bool selfOriginated = (originatingRouter == parentRouter->getRouterID());
2437 
2438  if ((routeCost == LS_INFINITY) || (lsAge == MAX_AGE) || (selfOriginated)) { // (1) and(2)
2439  continue;
2440  }
2441 
2442  unsigned long routeCount = newRoutingTable.size();
2443  char lsType = currentHeader.getLsType();
2444  RoutingTableEntry *destinationEntry = nullptr;
2445  IPv4AddressRange destination;
2446 
2447  destination.address = currentHeader.getLinkStateID();
2448  destination.mask = currentLSA->getNetworkMask();
2449 
2450  for (j = 0; j < routeCount; j++) { // (3)
2451  RoutingTableEntry *routingEntry = newRoutingTable[j];
2452  bool foundMatching = false;
2453 
2454  if (lsType == SUMMARYLSA_NETWORKS_TYPE) {
2455  if ((routingEntry->getDestinationType() == RoutingTableEntry::NETWORK_DESTINATION) &&
2456  ((destination.address & destination.mask) == routingEntry->getDestination()))
2457  {
2458  foundMatching = true;
2459  }
2460  }
2461  else {
2462  if ((((routingEntry->getDestinationType() & RoutingTableEntry::AREA_BORDER_ROUTER_DESTINATION) != 0) ||
2463  ((routingEntry->getDestinationType() & RoutingTableEntry::AS_BOUNDARY_ROUTER_DESTINATION) != 0)) &&
2464  (destination.address == routingEntry->getDestination()))
2465  {
2466  foundMatching = true;
2467  }
2468  }
2469 
2470  if (foundMatching) {
2471  RoutingTableEntry::RoutingPathType pathType = routingEntry->getPathType();
2472 
2473  if ((pathType == RoutingTableEntry::TYPE1_EXTERNAL) ||
2474  (pathType == RoutingTableEntry::TYPE2_EXTERNAL) ||
2475  (routingEntry->getArea() != BACKBONE_AREAID))
2476  {
2477  break;
2478  }
2479  else {
2480  destinationEntry = routingEntry;
2481  break;
2482  }
2483  }
2484  }
2485  if (destinationEntry == nullptr) {
2486  continue;
2487  }
2488 
2489  RoutingTableEntry *borderRouterEntry = nullptr;
2490  unsigned short currentCost = routeCost;
2491 
2492  for (j = 0; j < routeCount; j++) { // (4) BR == borderRouterEntry
2493  RoutingTableEntry *routingEntry = newRoutingTable[j];
2494 
2495  if ((routingEntry->getArea() == areaID) &&
2496  (((routingEntry->getDestinationType() & RoutingTableEntry::AREA_BORDER_ROUTER_DESTINATION) != 0) ||
2497  ((routingEntry->getDestinationType() & RoutingTableEntry::AS_BOUNDARY_ROUTER_DESTINATION) != 0)) &&
2498  (routingEntry->getDestination() == originatingRouter))
2499  {
2500  borderRouterEntry = routingEntry;
2501  currentCost += borderRouterEntry->getCost();
2502  break;
2503  }
2504  }
2505  if (borderRouterEntry == nullptr) {
2506  continue;
2507  }
2508  else { // (5)
2509  if (currentCost <= destinationEntry->getCost()) {
2510  if (currentCost < destinationEntry->getCost()) {
2511  destinationEntry->clearNextHops();
2512  }
2513 
2514  unsigned long nextHopCount = borderRouterEntry->getNextHopCount();
2515 
2516  for (j = 0; j < nextHopCount; j++) {
2517  destinationEntry->addNextHop(borderRouterEntry->getNextHop(j));
2518  }
2519  }
2520  }
2521  }
2522 }
std::vector< SummaryLSA * > summaryLSAs
Definition: OSPFArea.h:51
Definition: OSPFRoutingTableEntry.h:42
RouterID getRouterID() const
Definition: OSPFRouter.h:72
const AreaID BACKBONE_AREAID(0, 0, 0, 0)
static const unsigned char NETWORK_DESTINATION
Definition: OSPFRoutingTableEntry.h:48
static const unsigned char AS_BOUNDARY_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:50
static const unsigned char AREA_BORDER_ROUTER_DESTINATION
Definition: OSPFRoutingTableEntry.h:49
#define LS_INFINITY
Definition: TED.cc:32
#define MAX_AGE
Definition: OSPFcommon.h:36
IPv4Address getNetworkMask() const
Returns an address with the network mask corresponding to the address class.
Definition: IPv4Address.cc:189
Router * parentRouter
Definition: OSPFArea.h:57
RoutingPathType
Definition: OSPFRoutingTableEntry.h:38
IPv4Address RouterID
Definition: OSPFcommon.h:137
Definition: OSPFRoutingTableEntry.h:41
AreaID areaID
Definition: OSPFArea.h:41
Definition: OSPFPacket_m.h:247
void inet::ospf::Area::removeFromAllRetransmissionLists ( LSAKeyType  lsaKey)

Referenced by installNetworkLSA(), installRouterLSA(), and installSummaryLSA().

708 {
709  long interfaceCount = associatedInterfaces.size();
710  for (long i = 0; i < interfaceCount; i++) {
711  associatedInterfaces[i]->removeFromAllRetransmissionLists(lsaKey);
712  }
713 }
std::vector< Interface * > associatedInterfaces
Definition: OSPFArea.h:44
void inet::ospf::Area::setAreaID ( AreaID  areaId)
inline
63 { areaID = areaId; }
AreaID areaID
Definition: OSPFArea.h:41
void inet::ospf::Area::setExternalRoutingCapability ( bool  flooded)
inline

Referenced by inet::ospf::OSPFConfigReader::loadAreaFromXML().

71 { externalRoutingCapability = flooded; }
bool externalRoutingCapability
Definition: OSPFArea.h:53
void inet::ospf::Area::setRouter ( Router router)
inline

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

79 { parentRouter = router; }
Router * parentRouter
Definition: OSPFArea.h:57
void inet::ospf::Area::setSPFTreeRoot ( RouterLSA root)
inline

Referenced by inet::ospf::InterfaceState::changeState().

75 { spfTreeRoot = root; }
RouterLSA * spfTreeRoot
Definition: OSPFArea.h:55
void inet::ospf::Area::setStubDefaultCost ( Metric  cost)
inline

Referenced by inet::ospf::OSPFConfigReader::loadAreaFromXML().

73 { stubDefaultCost = cost; }
Metric stubDefaultCost
Definition: OSPFArea.h:54
void inet::ospf::Area::setTransitCapability ( bool  transit)
inline
69 { transitCapability = transit; }
bool transitCapability
Definition: OSPFArea.h:52

Member Data Documentation

std::map<IPv4AddressRange, bool> inet::ospf::Area::advertiseAddressRanges
private
std::vector<IPv4AddressRange> inet::ospf::Area::areaAddressRanges
private
bool inet::ospf::Area::externalRoutingCapability
private
std::vector<HostRouteParameters> inet::ospf::Area::hostRoutes
private
IInterfaceTable* inet::ospf::Area::ift
private
std::vector<NetworkLSA *> inet::ospf::Area::networkLSAs
private
std::map<LinkStateID, NetworkLSA *> inet::ospf::Area::networkLSAsByID
private
std::vector<RouterLSA *> inet::ospf::Area::routerLSAs
private
std::map<LinkStateID, RouterLSA *> inet::ospf::Area::routerLSAsByID
private
RouterLSA* inet::ospf::Area::spfTreeRoot
private
Metric inet::ospf::Area::stubDefaultCost
private

Referenced by detailedInfo().

std::vector<SummaryLSA *> inet::ospf::Area::summaryLSAs
private
std::map<LSAKeyType, SummaryLSA *, LSAKeyType_Less> inet::ospf::Area::summaryLSAsByID
private
bool inet::ospf::Area::transitCapability
private

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