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 "LinkStateAcknowledgementHandler.h" 00019 #include "OSPFRouter.h" 00020 00021 OSPF::LinkStateAcknowledgementHandler::LinkStateAcknowledgementHandler(OSPF::Router* containingRouter) : 00022 OSPF::IMessageHandler(containingRouter) 00023 { 00024 } 00025 00026 void OSPF::LinkStateAcknowledgementHandler::ProcessPacket(OSPFPacket* packet, OSPF::Interface* intf, OSPF::Neighbor* neighbor) 00027 { 00028 router->GetMessageHandler()->PrintEvent("Link State Acknowledgement packet received", intf, neighbor); 00029 00030 if (neighbor->GetState() >= OSPF::Neighbor::ExchangeState) { 00031 OSPFLinkStateAcknowledgementPacket* lsAckPacket = check_and_cast<OSPFLinkStateAcknowledgementPacket*> (packet); 00032 00033 int lsaCount = lsAckPacket->getLsaHeadersArraySize(); 00034 00035 EV << " Processing packet contents:\n"; 00036 00037 for (int i = 0; i < lsaCount; i++) { 00038 OSPFLSAHeader& lsaHeader = lsAckPacket->getLsaHeaders(i); 00039 OSPFLSA* lsaOnRetransmissionList; 00040 OSPF::LSAKeyType lsaKey; 00041 00042 EV << " "; 00043 PrintLSAHeader(lsaHeader, ev.getOStream()); 00044 EV << "\n"; 00045 00046 lsaKey.linkStateID = lsaHeader.getLinkStateID(); 00047 lsaKey.advertisingRouter = lsaHeader.getAdvertisingRouter().getInt(); 00048 00049 if ((lsaOnRetransmissionList = neighbor->FindOnRetransmissionList(lsaKey)) != NULL) { 00050 if (operator== (lsaHeader, lsaOnRetransmissionList->getHeader())) { 00051 neighbor->RemoveFromRetransmissionList(lsaKey); 00052 } else { 00053 EV << "Got an Acknowledgement packet for an unsent Update packet.\n"; 00054 } 00055 } 00056 } 00057 if (neighbor->IsLinkStateRetransmissionListEmpty()) { 00058 neighbor->ClearUpdateRetransmissionTimer(); 00059 } 00060 } 00061 }