|
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 "ansaOspfRouter6.h" 00018 00019 #include "ansaOspfInterfaceStateDown6.h" 00020 #include "ansaOspfInterfaceStateLoopback6.h" 00021 #include "ansaOspfInterfaceStateNotDesignatedRouter6.h" 00022 #include "ansaOspfInterfaceStatePointToPoint6.h" 00023 #include "ansaOspfInterfaceStateWaiting6.h" 00024 00025 void AnsaOspf6::InterfaceStateDown::ProcessEvent(AnsaOspf6::Interface* intf, AnsaOspf6::Interface::InterfaceEventType event){ 00026 00027 if (event == AnsaOspf6::Interface::InterfaceUp){ 00028 00029 AnsaOspf6::MessageHandler* messageHandler = intf->GetArea()->GetRouter()->GetMessageHandler(); 00030 00031 // add some deviation to avoid startup collisions 00032 messageHandler->StartTimer(intf->GetHelloTimer(), truncnormal(0.1, 0.01)); 00033 /* TODO 00034 messageHandler->StartTimer(intf->GetAcknowledgementTimer(), intf->GetAcknowledgementDelay()); 00035 */ 00036 00037 switch (intf->GetType()){ 00038 case AnsaOspf6::Interface::PointToPoint: 00039 case AnsaOspf6::Interface::PointToMultiPoint: 00040 case AnsaOspf6::Interface::Virtual: 00041 ChangeState(intf, new AnsaOspf6::InterfaceStatePointToPoint, this); 00042 break; 00043 00044 case AnsaOspf6::Interface::NBMA: 00045 if (intf->GetRouterPriority() == 0){ 00046 ChangeState(intf, new AnsaOspf6::InterfaceStateNotDesignatedRouter, this); 00047 }else{ 00048 ChangeState(intf, new AnsaOspf6::InterfaceStateWaiting, this); 00049 messageHandler->StartTimer(intf->GetWaitTimer(), intf->GetRouterDeadInterval()); 00050 00051 long neighborCount = intf->GetNeighborCount(); 00052 for (long i = 0; i < neighborCount; i++) { 00053 AnsaOspf6::Neighbor* neighbor = intf->GetNeighbor(i); 00054 if (neighbor->GetPriority() > 0) { 00055 neighbor->ProcessEvent(AnsaOspf6::Neighbor::Start); 00056 } 00057 } 00058 } 00059 break; 00060 00061 case AnsaOspf6::Interface::Broadcast: 00062 if (intf->GetRouterPriority() == 0){ 00063 ChangeState(intf, new AnsaOspf6::InterfaceStateNotDesignatedRouter, this); 00064 }else{ 00065 ChangeState(intf, new AnsaOspf6::InterfaceStateWaiting, this); 00066 messageHandler->StartTimer(intf->GetWaitTimer(), intf->GetRouterDeadInterval()); 00067 } 00068 break; 00069 00070 default: 00071 break; 00072 } 00073 } 00074 00075 if (event == AnsaOspf6::Interface::LoopIndication) { 00076 intf->Reset(); 00077 ChangeState(intf, new AnsaOspf6::InterfaceStateLoopback, this); 00078 } 00079 } 00080