|
INET Framework for OMNeT++/OMNEST
|
00001 #include "AnsaOSPFInterfaceStateWaiting.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::InterfaceStateWaiting::ProcessEvent(AnsaOSPF::Interface* intf, AnsaOSPF::Interface::InterfaceEventType event) 00009 { 00010 if ((event == AnsaOSPF::Interface::BackupSeen) || 00011 (event == AnsaOSPF::Interface::WaitTimer)) 00012 { 00013 CalculateDesignatedRouter(intf); 00014 } 00015 if (event == AnsaOSPF::Interface::InterfaceDown) { 00016 intf->SetIsGoingDown(true); 00017 intf->Reset(); 00018 ChangeState(intf, new AnsaOSPF::InterfaceStateDown, this); 00019 intf->SetIsGoingDown(false); 00020 } 00021 if (event == AnsaOSPF::Interface::LoopIndication) { 00022 intf->Reset(); 00023 ChangeState(intf, new AnsaOSPF::InterfaceStateLoopback, this); 00024 } 00025 if (event == AnsaOSPF::Interface::HelloTimer) { 00026 if (intf->GetType() == AnsaOSPF::Interface::Broadcast) { 00027 intf->SendHelloPacket(AnsaOSPF::AllSPFRouters); 00028 } else { // AnsaOSPF::Interface::NBMA 00029 unsigned long neighborCount = intf->GetNeighborCount(); 00030 int ttl = (intf->GetType() == AnsaOSPF::Interface::Virtual) ? VIRTUAL_LINK_TTL : 1; 00031 for (unsigned long i = 0; i < neighborCount; i++) { 00032 AnsaOSPF::Neighbor* neighbor = intf->GetNeighbor(i); 00033 if (neighbor->GetPriority() > 0) { 00034 intf->SendHelloPacket(neighbor->GetAddress(), ttl); 00035 } 00036 } 00037 } 00038 intf->GetArea()->GetRouter()->GetMessageHandler()->StartTimer(intf->GetHelloTimer(), intf->GetHelloInterval()); 00039 } 00040 if (event == AnsaOSPF::Interface::AcknowledgementTimer) { 00041 intf->SendDelayedAcknowledgements(); 00042 } 00043 } 00044