|
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 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 "ansaOspfNeighborStateInit6.h" 00024 #include "ansaOspfNeighborStateTwoWay6.h" 00025 00026 void AnsaOspf6::NeighborStateInit::ProcessEvent(AnsaOspf6::Neighbor* neighbor, 00027 AnsaOspf6::Neighbor::NeighborEventType event) { 00028 00029 if ((event == AnsaOspf6::Neighbor::KillNeighbor) || (event == AnsaOspf6::Neighbor::LinkDown)){ 00030 MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler(); 00031 neighbor->Reset(); 00032 messageHandler->ClearTimer(neighbor->GetInactivityTimer()); 00033 ChangeState(neighbor, new AnsaOspf6::NeighborStateDown, this); 00034 } 00035 if (event == AnsaOspf6::Neighbor::InactivityTimer){ 00036 neighbor->Reset(); 00037 if (neighbor->GetInterface()->GetType() == AnsaOspf6::Interface::NBMA){ 00038 MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler(); 00039 messageHandler->StartTimer(neighbor->GetPollTimer(), neighbor->GetInterface()->GetPollInterval()); 00040 } 00041 ChangeState(neighbor, new AnsaOspf6::NeighborStateDown, this); 00042 } 00043 if (event == AnsaOspf6::Neighbor::HelloReceived){ 00044 MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler(); 00045 messageHandler->ClearTimer(neighbor->GetInactivityTimer()); 00046 messageHandler->StartTimer(neighbor->GetInactivityTimer(), neighbor->GetRouterDeadInterval()); 00047 } 00048 if (event == AnsaOspf6::Neighbor::TwoWayReceived){ 00049 if (neighbor->NeedAdjacency()){ 00050 MessageHandler* messageHandler = neighbor->GetInterface()->GetArea()->GetRouter()->GetMessageHandler(); 00051 if (!(neighbor->IsFirstAdjacencyInited())){ 00052 neighbor->InitFirstAdjacency(); 00053 }else{ 00054 neighbor->IncrementDDSequenceNumber(); 00055 } 00056 neighbor->SendDatabaseDescriptionPacket(true); 00057 messageHandler->StartTimer(neighbor->GetDDRetransmissionTimer(), neighbor->GetInterface()->GetRetransmissionInterval()); 00058 ChangeState(neighbor, new AnsaOspf6::NeighborStateExchangeStart, this); 00059 }else{ 00060 ChangeState(neighbor, new AnsaOspf6::NeighborStateTwoWay, this); 00061 } 00062 } 00063 }