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