INET Framework for OMNeT++/OMNEST
AnsaASExternalLSA.cc
Go to the documentation of this file.
00001 #include "AnsaLSA.h"
00002 
00003 bool AnsaOSPF::ASExternalLSA::Update(const OSPFASExternalLSA* lsa)
00004 {
00005     bool different = DiffersFrom(lsa);
00006     (*this) = (*lsa);
00007     ResetInstallTime();
00008     if (different) {
00009         ClearNextHops();
00010         return true;
00011     } else {
00012         return false;
00013     }
00014 }
00015 
00016 bool AnsaOSPF::ASExternalLSA::DiffersFrom(const OSPFASExternalLSA* asExternalLSA) const
00017 {
00018     const OSPFLSAHeader& lsaHeader = asExternalLSA->getHeader();
00019     bool differentHeader = ((header_var.getLsOptions() != lsaHeader.getLsOptions()) ||
00020                             ((header_var.getLsAge() == MAX_AGE) && (lsaHeader.getLsAge() != MAX_AGE)) ||
00021                             ((header_var.getLsAge() != MAX_AGE) && (lsaHeader.getLsAge() == MAX_AGE)) ||
00022                             (header_var.getLsaLength() != lsaHeader.getLsaLength()));
00023     bool differentBody   = false;
00024 
00025     if (!differentHeader) {
00026         const OSPFASExternalLSAContents& lsaContents  = asExternalLSA->getContents();
00027         unsigned int                     tosInfoCount = contents_var.getExternalTOSInfoArraySize();
00028 
00029         differentBody = ((contents_var.getNetworkMask() != lsaContents.getNetworkMask()) ||
00030                          (contents_var.getE_ExternalMetricType() != lsaContents.getE_ExternalMetricType()) ||
00031                          (contents_var.getRouteCost() != lsaContents.getRouteCost()) ||
00032                          (contents_var.getForwardingAddress() != lsaContents.getForwardingAddress()) ||
00033                          (contents_var.getExternalRouteTag() != lsaContents.getExternalRouteTag()) ||
00034                          (tosInfoCount != lsaContents.getExternalTOSInfoArraySize()));
00035 
00036         if (!differentBody) {
00037             for (unsigned int i = 0; i < tosInfoCount; i++) {
00038                 const ExternalTOSInfo& currentTOSInfo = contents_var.getExternalTOSInfo(i);
00039                 const ExternalTOSInfo& lsaTOSInfo     = lsaContents.getExternalTOSInfo(i);
00040 
00041                 if ((currentTOSInfo.tosData.tos != lsaTOSInfo.tosData.tos) ||
00042                     (currentTOSInfo.tosData.tosMetric[0] != lsaTOSInfo.tosData.tosMetric[0]) ||
00043                     (currentTOSInfo.tosData.tosMetric[1] != lsaTOSInfo.tosData.tosMetric[1]) ||
00044                     (currentTOSInfo.tosData.tosMetric[2] != lsaTOSInfo.tosData.tosMetric[2]) ||
00045                     (currentTOSInfo.E_ExternalMetricType != lsaTOSInfo.E_ExternalMetricType) ||
00046                     (currentTOSInfo.forwardingAddress != lsaTOSInfo.forwardingAddress) ||
00047                     (currentTOSInfo.externalRouteTag != lsaTOSInfo.externalRouteTag))
00048                 {
00049                     differentBody = true;
00050                     break;
00051                 }
00052             }
00053         }
00054     }
00055 
00056     return (differentHeader || differentBody);
00057 }