INET Framework for OMNeT++/OMNEST
ansaOspfInterfaceStateNotDesignatedRouter6.cc
Go to the documentation of this file.
00001 //
00002 // This program is free software: you can redistribute it and/or modify
00003 // it under the terms of the GNU Lesser General Public License as published by
00004 // the Free Software Foundation, either version 3 of the License, or
00005 // (at your option) any later version.
00006 // 
00007 // This program is distributed in the hope that it will be useful,
00008 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 // GNU Lesser General Public License for more details.
00011 // 
00012 // You should have received a copy of the GNU Lesser General Public License
00013 // along with this program.  If not, see http://www.gnu.org/licenses/.
00014 // 
00015 
00016 #include "ansaOspfArea6.h"
00017 #include "ansaOspfRouter6.h"
00018 
00019 #include "ansaOspfInterfaceStateBackup6.h"
00020 #include "ansaOspfInterfaceStateDesignatedRouter6.h"
00021 #include "ansaOspfInterfaceStateDown6.h"
00022 #include "ansaOspfInterfaceStateLoopback6.h"
00023 #include "ansaOspfInterfaceStateNotDesignatedRouter6.h"
00024 
00025 void AnsaOspf6::InterfaceStateNotDesignatedRouter::ProcessEvent(AnsaOspf6::Interface* intf, AnsaOspf6::Interface::InterfaceEventType event){
00026 
00027    if (event == AnsaOspf6::Interface::NeighborChange){
00028       CalculateDesignatedRouter(intf);
00029    }
00030 
00031    if (event == AnsaOspf6::Interface::InterfaceDown){
00032       intf->SetIsGoingDown(true);
00033       intf->Reset();
00034       ChangeState(intf, new AnsaOspf6::InterfaceStateDown, this);
00035       intf->SetIsGoingDown(false);
00036    }
00037 
00038    if (event == AnsaOspf6::Interface::LoopIndication){
00039       intf->Reset();
00040       ChangeState(intf, new AnsaOspf6::InterfaceStateLoopback, this);
00041    }
00042 
00043    if (event == AnsaOspf6::Interface::HelloTimer){
00044       if (intf->GetType() == AnsaOspf6::Interface::Broadcast){
00045          intf->SendHelloPacket(AnsaOspf6::AllSPFRouters);
00046       }else{    // AnsaOspf6::Interface::NBMA
00047          if (intf->GetRouterPriority() > 0){
00048             unsigned long neighborCount = intf->GetNeighborCount();
00049             for (unsigned long i = 0; i < neighborCount; i++) {
00050                const AnsaOspf6::Neighbor* neighbor = intf->GetNeighbor(i);
00051                if (neighbor->GetPriority() > 0) {
00052                   intf->SendHelloPacket(neighbor->GetAddress());
00053                }
00054             }
00055          }else{
00056            intf->SendHelloPacket(AnsaOspf6::AllDRouters);
00057            intf->SendHelloPacket(AnsaOspf6::AllDRouters);
00058          }
00059       }
00060       intf->GetArea()->GetRouter()->GetMessageHandler()->StartTimer(intf->GetHelloTimer(), intf->GetHelloInterval());
00061    }
00062 
00063    if (event == AnsaOspf6::Interface::AcknowledgementTimer) {
00064       intf->SendDelayedAcknowledgements();
00065    }
00066 }