INET Framework for OMNeT++/OMNEST
AnsaOSPFInterfaceStateNotDesignatedRouter.cc
Go to the documentation of this file.
00001 #include "AnsaOSPFInterfaceStateNotDesignatedRouter.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::InterfaceStateNotDesignatedRouter::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             if (intf->GetRouterPriority() > 0) {
00028                 unsigned long neighborCount = intf->GetNeighborCount();
00029                 for (unsigned long i = 0; i < neighborCount; i++) {
00030                     const AnsaOSPF::Neighbor* neighbor = intf->GetNeighbor(i);
00031                     if (neighbor->GetPriority() > 0) {
00032                         intf->SendHelloPacket(neighbor->GetAddress());
00033                     }
00034                 }
00035             } else {
00036                 intf->SendHelloPacket(intf->GetDesignatedRouter().ipInterfaceAddress);
00037                 intf->SendHelloPacket(intf->GetBackupDesignatedRouter().ipInterfaceAddress);
00038             }
00039         }
00040         intf->GetArea()->GetRouter()->GetMessageHandler()->StartTimer(intf->GetHelloTimer(), intf->GetHelloInterval());
00041     }
00042     if (event == AnsaOSPF::Interface::AcknowledgementTimer) {
00043         intf->SendDelayedAcknowledgements();
00044     }
00045 }
00046