|
INET Framework for OMNeT++/OMNEST
|
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 #include "ansaOspfArea6.h" 00016 #include "ansaOspfRouter6.h" 00017 00018 #include "ansaOspfInterfaceStateDown6.h" 00019 #include "ansaOspfInterfaceStateLoopback6.h" 00020 #include "ansaOspfInterfaceStateDesignatedRouter6.h" 00021 00022 void AnsaOspf6::InterfaceStateDesignatedRouter::ProcessEvent(AnsaOspf6::Interface* intf, AnsaOspf6::Interface::InterfaceEventType event){ 00023 00024 if (event == AnsaOspf6::Interface::NeighborChange){ 00025 CalculateDesignatedRouter(intf); 00026 } 00027 00028 if (event == AnsaOspf6::Interface::InterfaceDown){ 00029 intf->SetIsGoingDown(true); 00030 intf->Reset(); 00031 ChangeState(intf, new AnsaOspf6::InterfaceStateDown, this); 00032 intf->SetIsGoingDown(false); 00033 } 00034 00035 if (event == AnsaOspf6::Interface::LoopIndication){ 00036 intf->Reset(); 00037 ChangeState(intf, new AnsaOspf6::InterfaceStateLoopback, this); 00038 } 00039 00040 if (event == AnsaOspf6::Interface::HelloTimer) { 00041 if (intf->GetType() == AnsaOspf6::Interface::Broadcast){ 00042 intf->SendHelloPacket(AnsaOspf6::AllSPFRouters); 00043 }else{ // AnsaOspf6::Interface::NBMA 00044 unsigned long neighborCount = intf->GetNeighborCount(); 00045 int ttl = (intf->GetType() == AnsaOspf6::Interface::Virtual) ? VIRTUAL_LINK_TTL : 1; 00046 for (unsigned long i = 0; i < neighborCount; i++) { 00047 intf->SendHelloPacket(intf->GetNeighbor(i)->GetAddress(), ttl); 00048 } 00049 } 00050 intf->GetArea()->GetRouter()->GetMessageHandler()->StartTimer(intf->GetHelloTimer(), intf->GetHelloInterval()); 00051 } 00052 00053 if (event == AnsaOspf6::Interface::AcknowledgementTimer) { 00054 intf->SendDelayedAcknowledgements(); 00055 } 00056 }