INET Framework for OMNeT++/OMNEST
OSPFNeighborStateDown.cc
Go to the documentation of this file.
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 "OSPFNeighborStateDown.h"
00019 #include "OSPFNeighborStateAttempt.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::NeighborStateDown::ProcessEvent(OSPF::Neighbor* neighbor, OSPF::Neighbor::NeighborEventType event)
00027 {
00028     if (event == OSPF::Neighbor::Start) {
00029         MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler();
00030         int             ttl            = (neighbor->GetInterface()->GetType() == OSPF::Interface::Virtual) ? VIRTUAL_LINK_TTL : 1;
00031 
00032         messageHandler->ClearTimer(neighbor->GetPollTimer());
00033         neighbor->GetInterface()->SendHelloPacket(neighbor->GetAddress(), ttl);
00034         messageHandler->StartTimer(neighbor->GetInactivityTimer(), neighbor->GetRouterDeadInterval());
00035         ChangeState(neighbor, new OSPF::NeighborStateAttempt, this);
00036     }
00037     if (event == OSPF::Neighbor::HelloReceived) {
00038         MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler();
00039         messageHandler->ClearTimer(neighbor->GetPollTimer());
00040         messageHandler->StartTimer(neighbor->GetInactivityTimer(), neighbor->GetRouterDeadInterval());
00041         ChangeState(neighbor, new OSPF::NeighborStateInit, this);
00042     }
00043     if (event == OSPF::Neighbor::PollTimer) {
00044         int ttl = (neighbor->GetInterface()->GetType() == OSPF::Interface::Virtual) ? VIRTUAL_LINK_TTL : 1;
00045         neighbor->GetInterface()->SendHelloPacket(neighbor->GetAddress(), ttl);
00046         MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler();
00047         messageHandler->StartTimer(neighbor->GetPollTimer(), neighbor->GetInterface()->GetPollInterval());
00048     }
00049 }