INET Framework for OMNeT++/OMNEST
AnsaOspf6::Router Class Reference

#include <ansaOspfRouter6.h>

List of all members.

Public Member Functions

 Router (ProcessID pid, RouterID id, cSimpleModule *containingModule)
virtual ~Router (void)
void SetRouterID (RouterID id)
RouterID GetRouterID (void) const
void SetProcessID (ProcessID pid)
ProcessID GetProcessID (void) const
unsigned long GetAreaCount (void) const
MessageHandlerGetMessageHandler (void)
unsigned long GetASExternalLSACount (void) const
AsExternalLsaGetASExternalLSA (unsigned long i)
const AsExternalLsaGetASExternalLSA (unsigned long i) const
bool GetASBoundaryRouter (void) const
unsigned long GetRoutingTableEntryCount (void) const
RoutingTableEntryGetRoutingTableEntry (unsigned long i)
const RoutingTableEntryGetRoutingTableEntry (unsigned long i) const
void AddRoutingTableEntry (RoutingTableEntry *entry)
void AddArea (Area *area)
AreaGetArea (AreaID areaID)
AreaGetAreaByIndex (int index)
AreaGetArea (IPv6Address address)
InterfaceGetNonVirtualInterface (unsigned char ifIndex)
bool InstallLSA (OspfLsa6 *lsa, AreaID areaID=BackboneAreaID)
OspfLsa6FindLSA (LsaType6 lsaType, LsaKeyType6 lsaKey, AreaID areaID)
void AgeDatabase (void)
bool HasAnyNeighborInStates (int states) const
void RemoveFromAllRetransmissionLists (LsaKeyType6 lsaKey)
bool IsOnAnyRetransmissionList (LsaKeyType6 lsaKey) const
bool FloodLSA (OspfLsa6 *lsa, AreaID areaID=BackboneAreaID, Interface *intf=NULL, Neighbor *neighbor=NULL)
bool IsDestinationUnreachable (OspfLsa6 *lsa) const
void RebuildRoutingTable (void)

Public Attributes

Stat stat

Private Member Functions

bool InstallASExternalLSA (OspfAsExternalLsa6 *lsa)
AsExternalLsaFindASExternalLSA (LsaKeyType6 lsaKey)
const AsExternalLsaFindASExternalLSA (LsaKeyType6 lsaKey) const

Private Attributes

RouterID routerID
ProcessID processID
std::map< AreaID, Area * > areasByID
std::vector< Area * > areas
std::map< LsaKeyType6,
AsExternalLsa
*, LsaKeyType6_Less
asExternalLSAsByID
std::vector< AsExternalLsa * > asExternalLSAs
std::map< IPv6Address,
OspfAsExternalLsa6,
IPv6Address_Less
externalRoutes
OspfTimer6ageTimer
std::vector< RoutingTableEntry * > routingTable
MessageHandlermessageHandler

Detailed Description

Definition at line 28 of file ansaOspfRouter6.h.


Constructor & Destructor Documentation

AnsaOspf6::Router::Router ( ProcessID  pid,
RouterID  id,
cSimpleModule *  containingModule 
)

Constructor. Initializes internal variables, adds a MessageHandler and starts the Database Age timer.

Definition at line 22 of file ansaOspfRouter6.cc.

                                                                                   :
      routerID(id),
      processID(pid){

   messageHandler = new AnsaOspf6::MessageHandler(this, containingModule);
   /*
   ageTimer = new OspfTimer6;
   ageTimer->setTimerKind(DatabaseAgeTimer);
   ageTimer->setContextPointer(this);
   ageTimer->setName("AnsaOspf6::Router::DatabaseAgeTimer");
   messageHandler->StartTimer(ageTimer, 1.0);
   */
}
AnsaOspf6::Router::~Router ( void  ) [virtual]

Destructor. Clears all LSA lists and kills the Database Age timer.

Definition at line 40 of file ansaOspfRouter6.cc.

                             {
   long areaCount = areas.size();
   for (long i = 0; i < areaCount; i++){
      delete areas[i];
   }
   long lsaCount = asExternalLSAs.size();
   for (long j = 0; j < lsaCount; j++){
      delete asExternalLSAs[j];
   }
   long routeCount = routingTable.size();
   for (long k = 0; k < routeCount; k++){
      delete routingTable[k];
   }

   /* TODO
   messageHandler->ClearTimer(ageTimer);
   delete ageTimer;
   */
   delete messageHandler;
}

Member Function Documentation

Adds a new Area to the Area list.

Parameters:
area[in] The Area to add.

Definition at line 66 of file ansaOspfRouter6.cc.

Referenced by AnsaOspfRouting6::loadInterfaceConfig().

                                                 {
   area->SetRouter(this);
   areasByID[area->GetAreaID()] = area;
   areas.push_back(area);
}

Definition at line 62 of file ansaOspfRouter6.h.

{ routingTable.push_back(entry); }

Ages the LSAs in the Router's database. This method is called on every firing of the DatabaseAgeTimer(every second).

See also:
RFC2328 Section 14.

Definition at line 311 of file ansaOspfRouter6.cc.

                                     {
}

Find the AS External LSA identified by the input lsaKey in the database.

Parameters:
lsaKey[in] Look for the AS External LSA which is identified by this key.
Returns:
The pointer to the AS External LSA if it was found, NULL otherwise.

Definition at line 384 of file ansaOspfRouter6.cc.

                                                                                      {
   std::map<AnsaOspf6::LsaKeyType6, AnsaOspf6::AsExternalLsa*, AnsaOspf6::LsaKeyType6_Less>
      ::iterator lsaIt = asExternalLSAsByID.find(lsaKey);
   if (lsaIt != asExternalLSAsByID.end()){
      return lsaIt->second;
   }else{
      return NULL;
   }
}

Find the AS External LSA identified by the input lsaKey in the database.

Parameters:
lsaKey[in] Look for the AS External LSA which is identified by this key.
Returns:
The const pointer to the AS External LSA if it was found, NULL otherwise.

Definition at line 400 of file ansaOspfRouter6.cc.

                                                                                                  {
   std::map<AnsaOspf6::LsaKeyType6, AnsaOspf6::AsExternalLsa*, AnsaOspf6::LsaKeyType6_Less>
      ::const_iterator lsaIt = asExternalLSAsByID.find(lsaKey);
   if (lsaIt != asExternalLSAsByID.end()){
      return lsaIt->second;
   }else{
      return NULL;
   }
}

Definition at line 269 of file ansaOspfRouter6.cc.

                                                                                                        {
   /*
   switch (lsaType){
      case RouterLSAType: {
         std::map<AnsaOspf6::AreaID, AnsaOspf6::Area*>::iterator areaIt = areasByID.find(areaID);
         if (areaIt != areasByID.end()){
            return areaIt->second->FindRouterLSA(lsaKey.linkStateID);
         }
      }
         break;
      case NetworkLSAType: {
         std::map<AnsaOspf6::AreaID, AnsaOspf6::Area*>::iterator areaIt = areasByID.find(areaID);
         if (areaIt != areasByID.end()){
            return areaIt->second->FindNetworkLSA(lsaKey.linkStateID);
         }
      }
         break;
      case SummaryLSA_NetworksType:
      case SummaryLSA_ASBoundaryRoutersType: {
         std::map<AnsaOspf6::AreaID, AnsaOspf6::Area*>::iterator areaIt = areasByID.find(areaID);
         if (areaIt != areasByID.end()){
            return areaIt->second->FindSummaryLSA(lsaKey);
         }
      }
         break;
      case ASExternalLSAType: {
         return FindASExternalLSA(lsaKey);
      }
         break;
      default:
         ASSERT(false);
         break;
   }
   return NULL;
   */
}
bool AnsaOspf6::Router::FloodLSA ( OspfLsa6 lsa,
AnsaOspf6::AreaID  areaID = BackboneAreaID,
AnsaOspf6::Interface intf = NULL,
AnsaOspf6::Neighbor neighbor = NULL 
)

Floods out the input lsa on a set of Interfaces.

See also:
RFC2328 Section 13.3.
Parameters:
lsa[in] The LSA to be flooded out.
areaID[in] If the lsa is a Router, Network or Summary LSA, then flood it only in this Area.
intf[in] The Interface this LSA arrived on.
neighbor[in] The Nieghbor this LSA arrived from.
Returns:
True if the LSA was floooded back out on the receiving Interface, false otherwise.

Definition at line 366 of file ansaOspfRouter6.cc.

                                                                                                                          {
}

Returns the pointer to the Area identified by the input areaID, if it's on the Area list, NULL otherwise.

Parameters:
areaID[in] The Area identifier.

Definition at line 78 of file ansaOspfRouter6.cc.

Referenced by AnsaOspfRouting6::loadInterfaceConfig().

                                                              {
   std::map<AnsaOspf6::AreaID, AnsaOspf6::Area*>::iterator areaIt = areasByID.find(areaID);
   if (areaIt != areasByID.end()){
      return (areaIt->second);
   }else{
      return NULL;
   }
}

Definition at line 87 of file ansaOspfRouter6.cc.

Referenced by operator<<().

                                                        {
   if (index < areas.size()){
      return areas[index];
   }else{
      return NULL;
   }
}
unsigned long AnsaOspf6::Router::GetAreaCount ( void  ) const [inline]

Definition at line 51 of file ansaOspfRouter6.h.

Referenced by operator<<().

{ return areas.size(); }
bool AnsaOspf6::Router::GetASBoundaryRouter ( void  ) const [inline]

Definition at line 58 of file ansaOspfRouter6.h.

{ return (externalRoutes.size() > 0); }
AsExternalLsa* AnsaOspf6::Router::GetASExternalLSA ( unsigned long  i) [inline]

Definition at line 56 of file ansaOspfRouter6.h.

Referenced by AnsaOspf6::Neighbor::CreateDatabaseSummary().

{ return asExternalLSAs[i]; }
const AsExternalLsa* AnsaOspf6::Router::GetASExternalLSA ( unsigned long  i) const [inline]

Definition at line 57 of file ansaOspfRouter6.h.

{ return asExternalLSAs[i]; }
unsigned long AnsaOspf6::Router::GetASExternalLSACount ( void  ) const [inline]

Definition at line 55 of file ansaOspfRouter6.h.

Referenced by AnsaOspf6::Neighbor::CreateDatabaseSummary().

{ return asExternalLSAs.size(); }

Returns the pointer of the physical Interface identified by the input interface index, NULL if the Router doesn't have such an interface.

Parameters:
ifIndex[in] The interface index to look for.

Definition at line 102 of file ansaOspfRouter6.cc.

Referenced by AnsaOspfRouting6::initialize().

                                                                                 {
   long areaCount = areas.size();
   for (long i = 0; i < areaCount; i++){
      AnsaOspf6::Interface* intf = areas[i]->GetInterface(ifIndex);
      if (intf != NULL){
         return intf;
      }
   }
   return NULL;
}
ProcessID AnsaOspf6::Router::GetProcessID ( void  ) const [inline]

Definition at line 50 of file ansaOspfRouter6.h.

{ return processID; }
RouterID AnsaOspf6::Router::GetRouterID ( void  ) const [inline]

Definition at line 48 of file ansaOspfRouter6.h.

Referenced by AnsaOspf6::InterfaceState::CalculateDesignatedRouter(), and operator<<().

{ return routerID; }

Definition at line 60 of file ansaOspfRouter6.h.

{ return routingTable[i]; }
const RoutingTableEntry* AnsaOspf6::Router::GetRoutingTableEntry ( unsigned long  i) const [inline]

Definition at line 61 of file ansaOspfRouter6.h.

{ return routingTable[i]; }
unsigned long AnsaOspf6::Router::GetRoutingTableEntryCount ( void  ) const [inline]

Definition at line 59 of file ansaOspfRouter6.h.

{ return routingTable.size(); }
bool AnsaOspf6::Router::HasAnyNeighborInStates ( int  states) const

Returns true if any Neighbor on any Interface in any of the Router's Areas is in any of the input states, false otherwise.

Parameters:
states[in] A bitfield combination of NeighborStateType values.

Definition at line 320 of file ansaOspfRouter6.cc.

                                                             {
   long areaCount = areas.size();
   for (long i = 0; i < areaCount; i++){
      if (areas[i]->HasAnyNeighborInStates(states)){
         return true;
      }
   }
   return false;
}

Definition at line 375 of file ansaOspfRouter6.cc.

                                                                 {
}

Installs a new LSA into the Router database. Checks the input LSA's type and installs it into either the selected Area's database, or if it's an AS External LSA then into the Router's common asExternalLSAs list.

Parameters:
lsa[in] The LSA to install. It will be copied into the database.
areaID[in] Identifies the input Router, Network and Summary LSA's Area.
Returns:
True if the routing table needs to be updated, false otherwise.

Definition at line 122 of file ansaOspfRouter6.cc.

                                                                      {
   switch (lsa->getHeader().getLsType()){
      case RouterLsaType: {
         std::map<AnsaOspf6::AreaID, AnsaOspf6::Area*>::iterator areaIt = areasByID.find(areaID);
         if (areaIt != areasByID.end()){
            OspfRouterLsa6* ospfRouterLSA = check_and_cast<OspfRouterLsa6*> (lsa);
            return areaIt->second->InstallRouterLSA(ospfRouterLSA);
         }
      }
         break;
      case NetworkLsaType: {
         std::map<AnsaOspf6::AreaID, AnsaOspf6::Area*>::iterator areaIt = areasByID.find(areaID);
         if (areaIt != areasByID.end()){
            OspfNetworkLsa6* ospfNetworkLSA = check_and_cast<OspfNetworkLsa6*> (lsa);
            return areaIt->second->InstallNetworkLSA(ospfNetworkLSA);
         }
      }

      case InterAreaPrefixLsaType: {
         std::map<AnsaOspf6::AreaID, AnsaOspf6::Area*>::iterator areaIt = areasByID.find(areaID);
         if (areaIt != areasByID.end()){
            OspfInterAreaPrefixLsa6* ospfInterAreaPrefixLSA = check_and_cast<OspfInterAreaPrefixLsa6*> (lsa);
            return areaIt->second->InstallInterAreaPrefixLSA(ospfInterAreaPrefixLSA);
         }
      }

      case InterAreaRouterLsaType: {
         std::map<AnsaOspf6::AreaID, AnsaOspf6::Area*>::iterator areaIt = areasByID.find(areaID);
         if (areaIt != areasByID.end()){
            OspfInterAreaRouterLsa6* ospfInterAreaRouterLSA = check_and_cast<OspfInterAreaRouterLsa6*> (lsa);
            return areaIt->second->InstallInterAreaRouterLSA(ospfInterAreaRouterLSA);
         }
      }

      case AsExternalLsaType: {
         OspfAsExternalLsa6* ospfASExternalLSA = check_and_cast<OspfAsExternalLsa6*> (lsa);
         return InstallASExternalLSA(ospfASExternalLSA);
      }

      case LinkLsaType: {
         // TODO
      }

      case IntraAreaPrefixLsaType: {
         std::map<AnsaOspf6::AreaID, AnsaOspf6::Area*>::iterator areaIt = areasByID.find(areaID);
         if (areaIt != areasByID.end()){
            OspfIntraAreaPrefixLsa6* ospfIntraAreaPrefixLSA = check_and_cast<OspfIntraAreaPrefixLsa6*> (lsa);
            return areaIt->second->InstallIntraAreaPrefixLSA(ospfIntraAreaPrefixLSA);
         }
      }
   }
   return false;
}

Definition at line 370 of file ansaOspfRouter6.cc.

                                                                  {

}

Returns true if there's at least one LSA on any Neighbor's retransmission list identified by the input lsaKey, false otherwise.

Parameters:
lsaKey[in] Identifies the LSAs to look for on the retransmission lists.

Definition at line 347 of file ansaOspfRouter6.cc.

                                                                                 {
   long areaCount = areas.size();
   for (long i = 0; i < areaCount; i++){
      if (areas[i]->IsOnAnyRetransmissionList(lsaKey)){
         return true;
      }
   }
   return false;
}

Rebuilds the routing table from scratch(based on the LSA database).

See also:
RFC2328 Section 16.

Definition at line 182 of file ansaOspfRouter6.cc.

                                             {

   /*
    unsigned long                         areaCount       = areas.size();
    bool                                  hasTransitAreas = false;
    std::vector<AnsaOspf6::RoutingTableEntry*> newTable;
    unsigned long                         i;

    EV << "Rebuilding routing table:\n";

    for (i = 0; i < areaCount; i++) {
        areas[i]->CalculateShortestPathTree(newTable);
        if (areas[i]->GetTransitCapability()) {
            hasTransitAreas = true;
        }
    }
    if (areaCount > 1) {
        AnsaOspf6::Area* backbone = GetArea(AnsaOspf6::BackboneAreaID);
        if (backbone != NULL) {
            backbone->CalculateInterAreaRoutes(newTable);
        }
    } else {
        if (areaCount == 1) {
            areas[0]->CalculateInterAreaRoutes(newTable);
        }
    }
    if (hasTransitAreas) {
        for (i = 0; i < areaCount; i++) {
            if (areas[i]->GetTransitCapability()) {
                areas[i]->ReCheckSummaryLSAs(newTable);
            }
        }
    }
    CalculateASExternalRoutes(newTable);

    // backup the routing table
    unsigned long                         routeCount = routingTable.size();
    std::vector<AnsaOspf6::RoutingTableEntry*> oldTable;

    oldTable.assign(routingTable.begin(), routingTable.end());
    routingTable.clear();
    routingTable.assign(newTable.begin(), newTable.end());

    RoutingTableAccess         routingTableAccess;
    std::vector<const IPRoute*> eraseEntries;
    IRoutingTable*              simRoutingTable    = routingTableAccess.get();
    unsigned long              routingEntryNumber = simRoutingTable->getNumRoutes();
    // remove entries from the IP routing table inserted by the OSPF module
    for (i = 0; i < routingEntryNumber; i++) {
        const IPRoute *entry = simRoutingTable->getRoute(i);
        const AnsaOspf6::RoutingTableEntry* ospfEntry = dynamic_cast<const AnsaOspf6::RoutingTableEntry*>(entry);
        if (ospfEntry != NULL) {
            eraseEntries.push_back(entry);
        }
    }

    unsigned int eraseCount = eraseEntries.size();
    for (i = 0; i < eraseCount; i++) {
        simRoutingTable->deleteRoute(eraseEntries[i]);
    }

    // add the new routing entries
    routeCount = routingTable.size();
    for (i = 0; i < routeCount; i++) {
        if (routingTable[i]->GetDestinationType() == AnsaOspf6::RoutingTableEntry::NetworkDestination) {
            simRoutingTable->addRoute(new AnsaOspf6::RoutingTableEntry(*(routingTable[i])));
        }
    }

    NotifyAboutRoutingTableChanges(oldTable);

    routeCount = oldTable.size();
    for (i = 0; i < routeCount; i++) {
        delete(oldTable[i]);
    }

    EV << "Routing table was rebuilt.\n"
       << "Results:\n";

    routeCount = routingTable.size();
    for (i = 0; i < routeCount; i++) {
        EV << *routingTable[i]
           << "\n";
    }
    */
}

Removes all LSAs from all Neighbor's retransmission lists which are identified by the input lsaKey.

Parameters:
lsaKey[in] Identifies the LSAs to remove from the retransmission lists.

Definition at line 335 of file ansaOspfRouter6.cc.

                                                                                  {
   long areaCount = areas.size();
   for (long i = 0; i < areaCount; i++){
      areas[i]->RemoveFromAllRetransmissionLists(lsaKey);
   }
}

Definition at line 49 of file ansaOspfRouter6.h.

{ processID = pid; }

Definition at line 47 of file ansaOspfRouter6.h.

{ routerID = id; }

Member Data Documentation

Definition at line 37 of file ansaOspfRouter6.h.

std::vector<Area*> AnsaOspf6::Router::areas [private]

Definition at line 33 of file ansaOspfRouter6.h.

Referenced by GetAreaCount().

std::map<AreaID, Area*> AnsaOspf6::Router::areasByID [private]

Definition at line 32 of file ansaOspfRouter6.h.

Definition at line 35 of file ansaOspfRouter6.h.

Referenced by GetASExternalLSA(), and GetASExternalLSACount().

Definition at line 39 of file ansaOspfRouter6.h.

Referenced by GetMessageHandler(), and Router().

Definition at line 31 of file ansaOspfRouter6.h.

Referenced by GetProcessID(), and SetProcessID().

Definition at line 30 of file ansaOspfRouter6.h.

Referenced by GetRouterID(), and SetRouterID().

Definition at line 41 of file ansaOspfRouter6.h.


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