|
INET Framework for OMNeT++/OMNEST
|
00001 // 00002 // Copyright (C) 2006 Andras Babos and Andras Varga 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public License 00006 // as published by the Free Software Foundation; either version 2 00007 // of the License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU Lesser General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU Lesser General Public License 00015 // along with this program; if not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #include "OSPFNeighborStateAttempt.h" 00019 #include "OSPFNeighborStateDown.h" 00020 #include "OSPFNeighborStateInit.h" 00021 #include "MessageHandler.h" 00022 #include "OSPFInterface.h" 00023 #include "OSPFArea.h" 00024 #include "OSPFRouter.h" 00025 00026 void OSPF::NeighborStateAttempt::ProcessEvent(OSPF::Neighbor* neighbor, OSPF::Neighbor::NeighborEventType event) 00027 { 00028 if ((event == OSPF::Neighbor::KillNeighbor) || (event == OSPF::Neighbor::LinkDown)) { 00029 MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler(); 00030 neighbor->Reset(); 00031 messageHandler->ClearTimer(neighbor->GetInactivityTimer()); 00032 ChangeState(neighbor, new OSPF::NeighborStateDown, this); 00033 } 00034 if (event == OSPF::Neighbor::InactivityTimer) { 00035 neighbor->Reset(); 00036 if (neighbor->GetInterface()->GetType() == OSPF::Interface::NBMA) { 00037 MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler(); 00038 messageHandler->StartTimer(neighbor->GetPollTimer(), neighbor->GetInterface()->GetPollInterval()); 00039 } 00040 ChangeState(neighbor, new OSPF::NeighborStateDown, this); 00041 } 00042 if (event == OSPF::Neighbor::HelloReceived) { 00043 MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler(); 00044 messageHandler->ClearTimer(neighbor->GetInactivityTimer()); 00045 messageHandler->StartTimer(neighbor->GetInactivityTimer(), neighbor->GetRouterDeadInterval()); 00046 ChangeState(neighbor, new OSPF::NeighborStateInit, this); 00047 } 00048 }