|
INET Framework for OMNeT++/OMNEST
|
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 "LSA.h" 00019 00020 bool OSPF::NetworkLSA::Update(const OSPFNetworkLSA* lsa) 00021 { 00022 bool different = DiffersFrom(lsa); 00023 (*this) = (*lsa); 00024 ResetInstallTime(); 00025 if (different) { 00026 ClearNextHops(); 00027 return true; 00028 } else { 00029 return false; 00030 } 00031 } 00032 00033 bool OSPF::NetworkLSA::DiffersFrom(const OSPFNetworkLSA* networkLSA) const 00034 { 00035 const OSPFLSAHeader& lsaHeader = networkLSA->getHeader(); 00036 bool differentHeader = ((header_var.getLsOptions() != lsaHeader.getLsOptions()) || 00037 ((header_var.getLsAge() == MAX_AGE) && (lsaHeader.getLsAge() != MAX_AGE)) || 00038 ((header_var.getLsAge() != MAX_AGE) && (lsaHeader.getLsAge() == MAX_AGE)) || 00039 (header_var.getLsaLength() != lsaHeader.getLsaLength())); 00040 bool differentBody = false; 00041 00042 if (!differentHeader) { 00043 differentBody = ((networkMask_var != networkLSA->getNetworkMask()) || 00044 (attachedRouters_arraysize != networkLSA->getAttachedRoutersArraySize())); 00045 00046 if (!differentBody) { 00047 unsigned int routerCount = attachedRouters_arraysize; 00048 for (unsigned int i = 0; i < routerCount; i++) { 00049 if (attachedRouters_var[i] != networkLSA->getAttachedRouters(i)) { 00050 differentBody = true; 00051 break; 00052 } 00053 } 00054 } 00055 } 00056 00057 return (differentHeader || differentBody); 00058 }