INET Framework for OMNeT++/OMNEST
ansaOspfNeighborStateLoading6.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 "ansaOspfNeighborStateDown6.h"
00022 #include "ansaOspfNeighborStateExchangeStart6.h"
00023 #include "ansaOspfNeighborStateFull6.h"
00024 #include "ansaOspfNeighborStateInit6.h"
00025 #include "ansaOspfNeighborStateLoading6.h"
00026 #include "ansaOspfNeighborStateTwoWay6.h"
00027 
00028 void AnsaOspf6::NeighborStateLoading::ProcessEvent(AnsaOspf6::Neighbor* neighbor,
00029       AnsaOspf6::Neighbor::NeighborEventType event) {
00030    if ((event == AnsaOspf6::Neighbor::KillNeighbor) || (event == AnsaOspf6::Neighbor::LinkDown)){
00031       MessageHandler* messageHandler =
00032             neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler();
00033       neighbor->Reset();
00034       messageHandler->ClearTimer(neighbor->GetInactivityTimer());
00035       ChangeState(neighbor, new AnsaOspf6::NeighborStateDown, this);
00036    }
00037    if (event == AnsaOspf6::Neighbor::InactivityTimer){
00038       neighbor->Reset();
00039       if (neighbor->GetInterface()->GetType() == AnsaOspf6::Interface::NBMA){
00040          MessageHandler* messageHandler =
00041                neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler();
00042          messageHandler->StartTimer(neighbor->GetPollTimer(),
00043                neighbor->GetInterface()->GetPollInterval());
00044       }
00045       ChangeState(neighbor, new AnsaOspf6::NeighborStateDown, this);
00046    }
00047    if (event == AnsaOspf6::Neighbor::OneWayReceived){
00048       neighbor->Reset();
00049       ChangeState(neighbor, new AnsaOspf6::NeighborStateInit, this);
00050    }
00051    if (event == AnsaOspf6::Neighbor::HelloReceived){
00052       MessageHandler* messageHandler =
00053             neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler();
00054       messageHandler->ClearTimer(neighbor->GetInactivityTimer());
00055       messageHandler->StartTimer(neighbor->GetInactivityTimer(), neighbor->GetRouterDeadInterval());
00056    }
00057    if (event == AnsaOspf6::Neighbor::LoadingDone){
00058       neighbor->ClearRequestRetransmissionTimer();
00059       ChangeState(neighbor, new AnsaOspf6::NeighborStateFull, this);
00060    }
00061    if (event == AnsaOspf6::Neighbor::IsAdjacencyOK){
00062       if (!neighbor->NeedAdjacency()){
00063          neighbor->Reset();
00064          ChangeState(neighbor, new AnsaOspf6::NeighborStateTwoWay, this);
00065       }
00066    }
00067    if ((event == AnsaOspf6::Neighbor::SequenceNumberMismatch) || (event
00068          == AnsaOspf6::Neighbor::BadLinkStateRequest)){
00069       MessageHandler* messageHandler =
00070             neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler();
00071       neighbor->Reset();
00072       neighbor->IncrementDDSequenceNumber();
00073       neighbor->SendDatabaseDescriptionPacket(true);
00074       messageHandler->StartTimer(neighbor->GetDDRetransmissionTimer(),
00075             neighbor->GetInterface()->GetRetransmissionInterval());
00076       ChangeState(neighbor, new AnsaOspf6::NeighborStateExchangeStart, this);
00077    }
00078    if (event == AnsaOspf6::Neighbor::RequestRetransmissionTimer){
00079       neighbor->SendLinkStateRequestPacket();
00080       neighbor->StartRequestRetransmissionTimer();
00081    }
00082    if (event == AnsaOspf6::Neighbor::UpdateRetransmissionTimer){
00083       neighbor->RetransmitUpdatePacket();
00084       neighbor->StartUpdateRetransmissionTimer();
00085    }
00086    if (event == AnsaOspf6::Neighbor::DDRetransmissionTimer){
00087       neighbor->DeleteLastSentDDPacket();
00088    }
00089 }