|
INET Framework for OMNeT++/OMNEST
|
00001 #include "AnsaOSPFInterfaceStateBackup.h" 00002 #include "AnsaOSPFInterfaceStateDown.h" 00003 #include "AnsaOSPFInterfaceStateLoopback.h" 00004 #include "AnsaOSPFArea.h" 00005 #include "AnsaOSPFRouter.h" 00006 #include "AnsaMessageHandler.h" 00007 00008 void AnsaOSPF::InterfaceStateBackup::ProcessEvent(AnsaOSPF::Interface* intf, AnsaOSPF::Interface::InterfaceEventType event) 00009 { 00010 if (event == AnsaOSPF::Interface::NeighborChange) { 00011 CalculateDesignatedRouter(intf); 00012 } 00013 if (event == AnsaOSPF::Interface::InterfaceDown) { 00014 intf->SetIsGoingDown(true); 00015 intf->Reset(); 00016 ChangeState(intf, new AnsaOSPF::InterfaceStateDown, this); 00017 intf->SetIsGoingDown(false); 00018 } 00019 if (event == AnsaOSPF::Interface::LoopIndication) { 00020 intf->Reset(); 00021 ChangeState(intf, new AnsaOSPF::InterfaceStateLoopback, this); 00022 } 00023 if (event == AnsaOSPF::Interface::HelloTimer) { 00024 if (intf->GetType() == AnsaOSPF::Interface::Broadcast) { 00025 intf->SendHelloPacket(AnsaOSPF::AllSPFRouters); 00026 } else { // AnsaOSPF::Interface::NBMA 00027 unsigned long neighborCount = intf->GetNeighborCount(); 00028 int ttl = (intf->GetType() == AnsaOSPF::Interface::Virtual) ? VIRTUAL_LINK_TTL : 1; 00029 for (unsigned long i = 0; i < neighborCount; i++) { 00030 intf->SendHelloPacket(intf->GetNeighbor(i)->GetAddress(), ttl); 00031 } 00032 } 00033 intf->GetArea()->GetRouter()->GetMessageHandler()->StartTimer(intf->GetHelloTimer(), intf->GetHelloInterval()); 00034 } 00035 if (event == AnsaOSPF::Interface::AcknowledgementTimer) { 00036 intf->SendDelayedAcknowledgements(); 00037 } 00038 } 00039