blob: 55e8044ae611cc1a4032c2df86f6f36917d4c912 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoque53353462014-04-22 08:43:45 -050023#include <string>
24#include <utility>
akmhoque157b0a42014-05-13 00:26:37 -050025
akmhoque53353462014-04-22 08:43:45 -050026#include "lsdb.hpp"
27#include "nlsr.hpp"
akmhoque157b0a42014-05-13 00:26:37 -050028#include "conf-parameter.hpp"
akmhoque31d1d4b2014-05-05 22:08:14 -050029#include "utility/name-helper.hpp"
akmhoque674b0b12014-05-20 14:33:28 -050030#include "logger.hpp"
akmhoque53353462014-04-22 08:43:45 -050031
32namespace nlsr {
33
akmhoque674b0b12014-05-20 14:33:28 -050034INIT_LOGGER("Lsdb");
35
akmhoque53353462014-04-22 08:43:45 -050036using namespace std;
37
38void
akmhoque31d1d4b2014-05-05 22:08:14 -050039Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
akmhoque53353462014-04-22 08:43:45 -050040{
akmhoque31d1d4b2014-05-05 22:08:14 -050041 m_nlsr.getScheduler().cancelEvent(eid);
akmhoque53353462014-04-22 08:43:45 -050042}
43
44static bool
akmhoque31d1d4b2014-05-05 22:08:14 -050045nameLsaCompareByKey(const NameLsa& nlsa1, const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -050046{
47 return nlsa1.getKey() == key;
48}
49
50
51bool
akmhoque31d1d4b2014-05-05 22:08:14 -050052Lsdb::buildAndInstallOwnNameLsa()
akmhoque53353462014-04-22 08:43:45 -050053{
akmhoque31d1d4b2014-05-05 22:08:14 -050054 NameLsa nameLsa(m_nlsr.getConfParameter().getRouterPrefix(),
55 "name",
56 m_nlsr.getSequencingManager().getNameLsaSeq() + 1,
akmhoquec7a79b22014-05-26 08:06:19 -050057 getLsaExpirationTimePoint(),
akmhoque31d1d4b2014-05-05 22:08:14 -050058 m_nlsr.getNamePrefixList());
59 m_nlsr.getSequencingManager().increaseNameLsaSeq();
60 return installNameLsa(nameLsa);
akmhoque53353462014-04-22 08:43:45 -050061}
62
akmhoqueb6450b12014-04-24 00:01:03 -050063NameLsa*
akmhoque31d1d4b2014-05-05 22:08:14 -050064Lsdb::findNameLsa(const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -050065{
66 std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
67 m_nameLsdb.end(),
68 bind(nameLsaCompareByKey, _1, key));
akmhoque157b0a42014-05-13 00:26:37 -050069 if (it != m_nameLsdb.end()) {
akmhoqueb6450b12014-04-24 00:01:03 -050070 return &(*it);
akmhoque53353462014-04-22 08:43:45 -050071 }
akmhoqueb6450b12014-04-24 00:01:03 -050072 return 0;
akmhoque53353462014-04-22 08:43:45 -050073}
74
75bool
akmhoque31d1d4b2014-05-05 22:08:14 -050076Lsdb::isNameLsaNew(const ndn::Name& key, uint64_t seqNo)
akmhoque53353462014-04-22 08:43:45 -050077{
akmhoqueb6450b12014-04-24 00:01:03 -050078 NameLsa* nameLsaCheck = findNameLsa(key);
akmhoque157b0a42014-05-13 00:26:37 -050079 if (nameLsaCheck != 0) {
80 if (nameLsaCheck->getLsSeqNo() < seqNo) {
akmhoque53353462014-04-22 08:43:45 -050081 return true;
82 }
akmhoque157b0a42014-05-13 00:26:37 -050083 else {
akmhoque53353462014-04-22 08:43:45 -050084 return false;
85 }
86 }
87 return true;
88}
89
90ndn::EventId
akmhoquec7a79b22014-05-26 08:06:19 -050091Lsdb::scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
92 const ndn::time::seconds& expTime)
akmhoque53353462014-04-22 08:43:45 -050093{
akmhoquec7a79b22014-05-26 08:06:19 -050094 return m_nlsr.getScheduler().scheduleEvent(expTime,
akmhoque31d1d4b2014-05-05 22:08:14 -050095 ndn::bind(&Lsdb::exprireOrRefreshNameLsa,
96 this, key, seqNo));
akmhoque53353462014-04-22 08:43:45 -050097}
98
99bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500100Lsdb::installNameLsa(NameLsa& nlsa)
akmhoque53353462014-04-22 08:43:45 -0500101{
Alexander Afanasyev8388ec62014-08-16 18:38:57 -0700102 ndn::time::seconds timeToExpire = m_lsaRefreshTime;
akmhoqueb6450b12014-04-24 00:01:03 -0500103 NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
akmhoque157b0a42014-05-13 00:26:37 -0500104 if (chkNameLsa == 0) {
akmhoque53353462014-04-22 08:43:45 -0500105 addNameLsa(nlsa);
akmhoque2f423352014-06-03 11:49:35 -0500106 _LOG_DEBUG("New Name LSA");
107 _LOG_DEBUG("Adding Name Lsa");
akmhoque53353462014-04-22 08:43:45 -0500108 nlsa.writeLog();
akmhoque674b0b12014-05-20 14:33:28 -0500109
akmhoque157b0a42014-05-13 00:26:37 -0500110 if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500111 m_nlsr.getNamePrefixTable().addEntry(nlsa.getOrigRouter(),
112 nlsa.getOrigRouter());
113 std::list<ndn::Name> nameList = nlsa.getNpl().getNameList();
114 for (std::list<ndn::Name>::iterator it = nameList.begin(); it != nameList.end();
akmhoque157b0a42014-05-13 00:26:37 -0500115 it++) {
116 if ((*it) != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500117 m_nlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter());
akmhoque53353462014-04-22 08:43:45 -0500118 }
119 }
120 }
akmhoque157b0a42014-05-13 00:26:37 -0500121 if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoquec7a79b22014-05-26 08:06:19 -0500122 ndn::time::system_clock::Duration duration = nlsa.getExpirationTimePoint() -
123 ndn::time::system_clock::now();
124 timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
akmhoque53353462014-04-22 08:43:45 -0500125 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500126 nlsa.setExpiringEventId(scheduleNameLsaExpiration(nlsa.getKey(),
akmhoque53353462014-04-22 08:43:45 -0500127 nlsa.getLsSeqNo(),
128 timeToExpire));
129 }
akmhoque157b0a42014-05-13 00:26:37 -0500130 else {
131 if (chkNameLsa->getLsSeqNo() < nlsa.getLsSeqNo()) {
akmhoque674b0b12014-05-20 14:33:28 -0500132 _LOG_DEBUG("Updated Name LSA. Updating LSDB");
akmhoque2f423352014-06-03 11:49:35 -0500133 _LOG_DEBUG("Deleting Name Lsa");
akmhoqueb6450b12014-04-24 00:01:03 -0500134 chkNameLsa->writeLog();
135 chkNameLsa->setLsSeqNo(nlsa.getLsSeqNo());
akmhoquec7a79b22014-05-26 08:06:19 -0500136 chkNameLsa->setExpirationTimePoint(nlsa.getExpirationTimePoint());
akmhoqueb6450b12014-04-24 00:01:03 -0500137 chkNameLsa->getNpl().sort();
akmhoque53353462014-04-22 08:43:45 -0500138 nlsa.getNpl().sort();
akmhoque31d1d4b2014-05-05 22:08:14 -0500139 std::list<ndn::Name> nameToAdd;
akmhoque53353462014-04-22 08:43:45 -0500140 std::set_difference(nlsa.getNpl().getNameList().begin(),
141 nlsa.getNpl().getNameList().end(),
akmhoqueb6450b12014-04-24 00:01:03 -0500142 chkNameLsa->getNpl().getNameList().begin(),
143 chkNameLsa->getNpl().getNameList().end(),
akmhoque53353462014-04-22 08:43:45 -0500144 std::inserter(nameToAdd, nameToAdd.begin()));
akmhoque31d1d4b2014-05-05 22:08:14 -0500145 for (std::list<ndn::Name>::iterator it = nameToAdd.begin();
akmhoque157b0a42014-05-13 00:26:37 -0500146 it != nameToAdd.end(); ++it) {
akmhoqueb6450b12014-04-24 00:01:03 -0500147 chkNameLsa->addName((*it));
akmhoque157b0a42014-05-13 00:26:37 -0500148 if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
149 if ((*it) != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500150 m_nlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter());
akmhoque53353462014-04-22 08:43:45 -0500151 }
152 }
153 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500154 std::list<ndn::Name> nameToRemove;
akmhoqueb6450b12014-04-24 00:01:03 -0500155 std::set_difference(chkNameLsa->getNpl().getNameList().begin(),
156 chkNameLsa->getNpl().getNameList().end(),
akmhoque53353462014-04-22 08:43:45 -0500157 nlsa.getNpl().getNameList().begin(),
158 nlsa.getNpl().getNameList().end(),
159 std::inserter(nameToRemove, nameToRemove.begin()));
akmhoque31d1d4b2014-05-05 22:08:14 -0500160 for (std::list<ndn::Name>::iterator it = nameToRemove.begin();
akmhoque157b0a42014-05-13 00:26:37 -0500161 it != nameToRemove.end(); ++it) {
akmhoqueb6450b12014-04-24 00:01:03 -0500162 chkNameLsa->removeName((*it));
akmhoque157b0a42014-05-13 00:26:37 -0500163 if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
164 if ((*it) != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500165 m_nlsr.getNamePrefixTable().removeEntry((*it), nlsa.getOrigRouter());
akmhoque53353462014-04-22 08:43:45 -0500166 }
167 }
168 }
akmhoque157b0a42014-05-13 00:26:37 -0500169 if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoquec7a79b22014-05-26 08:06:19 -0500170 ndn::time::system_clock::Duration duration = nlsa.getExpirationTimePoint() -
171 ndn::time::system_clock::now();
172 timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
akmhoque53353462014-04-22 08:43:45 -0500173 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500174 cancelScheduleLsaExpiringEvent(chkNameLsa->getExpiringEventId());
175 chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(nlsa.getKey(),
akmhoqueb6450b12014-04-24 00:01:03 -0500176 nlsa.getLsSeqNo(),
177 timeToExpire));
akmhoque2f423352014-06-03 11:49:35 -0500178 _LOG_DEBUG("Adding Name Lsa");
akmhoqueb6450b12014-04-24 00:01:03 -0500179 chkNameLsa->writeLog();
akmhoque53353462014-04-22 08:43:45 -0500180 }
181 }
182 return true;
183}
184
185bool
186Lsdb::addNameLsa(NameLsa& nlsa)
187{
188 std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
189 m_nameLsdb.end(),
190 bind(nameLsaCompareByKey, _1,
191 nlsa.getKey()));
akmhoque157b0a42014-05-13 00:26:37 -0500192 if (it == m_nameLsdb.end()) {
akmhoque53353462014-04-22 08:43:45 -0500193 m_nameLsdb.push_back(nlsa);
194 return true;
195 }
196 return false;
197}
198
199bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500200Lsdb::removeNameLsa(const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500201{
202 std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
203 m_nameLsdb.end(),
akmhoque157b0a42014-05-13 00:26:37 -0500204 ndn::bind(nameLsaCompareByKey, _1, key));
205 if (it != m_nameLsdb.end()) {
akmhoque2f423352014-06-03 11:49:35 -0500206 _LOG_DEBUG("Deleting Name Lsa");
akmhoque53353462014-04-22 08:43:45 -0500207 (*it).writeLog();
akmhoque31d1d4b2014-05-05 22:08:14 -0500208 if ((*it).getOrigRouter() !=
akmhoque157b0a42014-05-13 00:26:37 -0500209 m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500210 m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
211 (*it).getOrigRouter());
212 for (std::list<ndn::Name>::iterator nit = (*it).getNpl().getNameList().begin();
akmhoque157b0a42014-05-13 00:26:37 -0500213 nit != (*it).getNpl().getNameList().end(); ++nit) {
214 if ((*nit) != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500215 m_nlsr.getNamePrefixTable().removeEntry((*nit), (*it).getOrigRouter());
akmhoque53353462014-04-22 08:43:45 -0500216 }
217 }
218 }
219 m_nameLsdb.erase(it);
220 return true;
221 }
222 return false;
223}
224
225bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500226Lsdb::doesNameLsaExist(const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500227{
228 std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
229 m_nameLsdb.end(),
akmhoque157b0a42014-05-13 00:26:37 -0500230 ndn::bind(nameLsaCompareByKey, _1, key));
231 if (it == m_nameLsdb.end()) {
akmhoque53353462014-04-22 08:43:45 -0500232 return false;
233 }
234 return true;
235}
236
237void
akmhoque2f423352014-06-03 11:49:35 -0500238Lsdb::writeNameLsdbLog()
akmhoque53353462014-04-22 08:43:45 -0500239{
akmhoque2f423352014-06-03 11:49:35 -0500240 _LOG_DEBUG("---------------Name LSDB-------------------");
akmhoque53353462014-04-22 08:43:45 -0500241 for (std::list<NameLsa>::iterator it = m_nameLsdb.begin();
akmhoque157b0a42014-05-13 00:26:37 -0500242 it != m_nameLsdb.end() ; it++) {
akmhoque2f423352014-06-03 11:49:35 -0500243 (*it).writeLog();
akmhoque53353462014-04-22 08:43:45 -0500244 }
245}
246
247// Cor LSA and LSDB related Functions start here
248
akmhoque53353462014-04-22 08:43:45 -0500249static bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500250corLsaCompareByKey(const CoordinateLsa& clsa, const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500251{
252 return clsa.getKey() == key;
253}
254
255bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500256Lsdb::buildAndInstallOwnCoordinateLsa()
akmhoque53353462014-04-22 08:43:45 -0500257{
akmhoque31d1d4b2014-05-05 22:08:14 -0500258 CoordinateLsa corLsa(m_nlsr.getConfParameter().getRouterPrefix(),
259 "coordinate",
260 m_nlsr.getSequencingManager().getCorLsaSeq() + 1,
akmhoquec7a79b22014-05-26 08:06:19 -0500261 getLsaExpirationTimePoint(),
akmhoque31d1d4b2014-05-05 22:08:14 -0500262 m_nlsr.getConfParameter().getCorR(),
263 m_nlsr.getConfParameter().getCorTheta());
264 m_nlsr.getSequencingManager().increaseCorLsaSeq();
265 installCoordinateLsa(corLsa);
akmhoque53353462014-04-22 08:43:45 -0500266 return true;
267}
268
akmhoqueb6450b12014-04-24 00:01:03 -0500269CoordinateLsa*
akmhoque31d1d4b2014-05-05 22:08:14 -0500270Lsdb::findCoordinateLsa(const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500271{
akmhoqueb6450b12014-04-24 00:01:03 -0500272 std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
273 m_corLsdb.end(),
akmhoque157b0a42014-05-13 00:26:37 -0500274 ndn::bind(corLsaCompareByKey, _1, key));
275 if (it != m_corLsdb.end()) {
akmhoqueb6450b12014-04-24 00:01:03 -0500276 return &(*it);
akmhoque53353462014-04-22 08:43:45 -0500277 }
akmhoqueb6450b12014-04-24 00:01:03 -0500278 return 0;
akmhoque53353462014-04-22 08:43:45 -0500279}
280
281bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500282Lsdb::isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo)
akmhoque53353462014-04-22 08:43:45 -0500283{
akmhoqueb6450b12014-04-24 00:01:03 -0500284 CoordinateLsa* clsa = findCoordinateLsa(key);
akmhoque157b0a42014-05-13 00:26:37 -0500285 if (clsa != 0) {
286 if (clsa->getLsSeqNo() < seqNo) {
akmhoque53353462014-04-22 08:43:45 -0500287 return true;
288 }
akmhoque157b0a42014-05-13 00:26:37 -0500289 else {
akmhoque53353462014-04-22 08:43:45 -0500290 return false;
291 }
292 }
293 return true;
294}
295
296ndn::EventId
akmhoque31d1d4b2014-05-05 22:08:14 -0500297Lsdb::scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
akmhoquec7a79b22014-05-26 08:06:19 -0500298 const ndn::time::seconds& expTime)
akmhoque53353462014-04-22 08:43:45 -0500299{
akmhoquec7a79b22014-05-26 08:06:19 -0500300 return m_nlsr.getScheduler().scheduleEvent(expTime,
akmhoque31d1d4b2014-05-05 22:08:14 -0500301 ndn::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
302 this, key, seqNo));
akmhoque53353462014-04-22 08:43:45 -0500303}
304
305bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500306Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
akmhoque53353462014-04-22 08:43:45 -0500307{
Alexander Afanasyev8388ec62014-08-16 18:38:57 -0700308 ndn::time::seconds timeToExpire = m_lsaRefreshTime;
akmhoqueb6450b12014-04-24 00:01:03 -0500309 CoordinateLsa* chkCorLsa = findCoordinateLsa(clsa.getKey());
akmhoque157b0a42014-05-13 00:26:37 -0500310 if (chkCorLsa == 0) {
akmhoque674b0b12014-05-20 14:33:28 -0500311 _LOG_DEBUG("New Coordinate LSA. Adding to LSDB");
akmhoque2f423352014-06-03 11:49:35 -0500312 _LOG_DEBUG("Adding Coordinate Lsa");
akmhoque674b0b12014-05-20 14:33:28 -0500313 clsa.writeLog();
akmhoqueb6450b12014-04-24 00:01:03 -0500314 addCoordinateLsa(clsa);
akmhoque2f423352014-06-03 11:49:35 -0500315
akmhoque157b0a42014-05-13 00:26:37 -0500316 if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500317 m_nlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
318 clsa.getOrigRouter());
akmhoque53353462014-04-22 08:43:45 -0500319 }
akmhoque157b0a42014-05-13 00:26:37 -0500320 if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500321 m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
akmhoque53353462014-04-22 08:43:45 -0500322 }
akmhoque157b0a42014-05-13 00:26:37 -0500323 if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoquec7a79b22014-05-26 08:06:19 -0500324 ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
325 ndn::time::system_clock::now();
326 timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
akmhoque53353462014-04-22 08:43:45 -0500327 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500328 scheduleCoordinateLsaExpiration(clsa.getKey(),
akmhoqueb6450b12014-04-24 00:01:03 -0500329 clsa.getLsSeqNo(), timeToExpire);
akmhoque53353462014-04-22 08:43:45 -0500330 }
akmhoque157b0a42014-05-13 00:26:37 -0500331 else {
332 if (chkCorLsa->getLsSeqNo() < clsa.getLsSeqNo()) {
akmhoque674b0b12014-05-20 14:33:28 -0500333 _LOG_DEBUG("Updated Coordinate LSA. Updating LSDB");
akmhoque2f423352014-06-03 11:49:35 -0500334 _LOG_DEBUG("Deleting Coordinate Lsa");
akmhoque674b0b12014-05-20 14:33:28 -0500335 chkCorLsa->writeLog();
akmhoqueb6450b12014-04-24 00:01:03 -0500336 chkCorLsa->setLsSeqNo(clsa.getLsSeqNo());
akmhoquec7a79b22014-05-26 08:06:19 -0500337 chkCorLsa->setExpirationTimePoint(clsa.getExpirationTimePoint());
akmhoque157b0a42014-05-13 00:26:37 -0500338 if (!chkCorLsa->isEqualContent(clsa)) {
akmhoqueb6450b12014-04-24 00:01:03 -0500339 chkCorLsa->setCorRadius(clsa.getCorRadius());
340 chkCorLsa->setCorTheta(clsa.getCorTheta());
akmhoque157b0a42014-05-13 00:26:37 -0500341 if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500342 m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
akmhoque53353462014-04-22 08:43:45 -0500343 }
344 }
akmhoque157b0a42014-05-13 00:26:37 -0500345 if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoquec7a79b22014-05-26 08:06:19 -0500346 ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
347 ndn::time::system_clock::now();
348 timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
akmhoque53353462014-04-22 08:43:45 -0500349 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500350 cancelScheduleLsaExpiringEvent(chkCorLsa->getExpiringEventId());
351 chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(clsa.getKey(),
akmhoqueb6450b12014-04-24 00:01:03 -0500352 clsa.getLsSeqNo(),
353 timeToExpire));
akmhoque2f423352014-06-03 11:49:35 -0500354 _LOG_DEBUG("Adding Coordinate Lsa");
akmhoque674b0b12014-05-20 14:33:28 -0500355 chkCorLsa->writeLog();
akmhoque53353462014-04-22 08:43:45 -0500356 }
357 }
358 return true;
359}
360
361bool
akmhoqueb6450b12014-04-24 00:01:03 -0500362Lsdb::addCoordinateLsa(CoordinateLsa& clsa)
akmhoque53353462014-04-22 08:43:45 -0500363{
akmhoqueb6450b12014-04-24 00:01:03 -0500364 std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
365 m_corLsdb.end(),
akmhoque157b0a42014-05-13 00:26:37 -0500366 ndn::bind(corLsaCompareByKey, _1,
367 clsa.getKey()));
368 if (it == m_corLsdb.end()) {
akmhoque53353462014-04-22 08:43:45 -0500369 m_corLsdb.push_back(clsa);
370 return true;
371 }
372 return false;
373}
374
375bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500376Lsdb::removeCoordinateLsa(const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500377{
akmhoqueb6450b12014-04-24 00:01:03 -0500378 std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
379 m_corLsdb.end(),
akmhoque157b0a42014-05-13 00:26:37 -0500380 ndn::bind(corLsaCompareByKey,
381 _1, key));
382 if (it != m_corLsdb.end()) {
akmhoque2f423352014-06-03 11:49:35 -0500383 _LOG_DEBUG("Deleting Coordinate Lsa");
akmhoque674b0b12014-05-20 14:33:28 -0500384 (*it).writeLog();
akmhoque31d1d4b2014-05-05 22:08:14 -0500385 if ((*it).getOrigRouter() !=
akmhoque157b0a42014-05-13 00:26:37 -0500386 m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500387 m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
388 (*it).getOrigRouter());
akmhoque53353462014-04-22 08:43:45 -0500389 }
390 m_corLsdb.erase(it);
391 return true;
392 }
393 return false;
394}
395
396bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500397Lsdb::doesCoordinateLsaExist(const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500398{
akmhoqueb6450b12014-04-24 00:01:03 -0500399 std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
400 m_corLsdb.end(),
akmhoque157b0a42014-05-13 00:26:37 -0500401 ndn::bind(corLsaCompareByKey,
402 _1, key));
403 if (it == m_corLsdb.end()) {
akmhoque53353462014-04-22 08:43:45 -0500404 return false;
405 }
406 return true;
407}
408
409void
akmhoque2f423352014-06-03 11:49:35 -0500410Lsdb::writeCorLsdbLog()
akmhoque53353462014-04-22 08:43:45 -0500411{
akmhoque2f423352014-06-03 11:49:35 -0500412 _LOG_DEBUG("---------------Cor LSDB-------------------");
akmhoqueb6450b12014-04-24 00:01:03 -0500413 for (std::list<CoordinateLsa>::iterator it = m_corLsdb.begin();
akmhoque157b0a42014-05-13 00:26:37 -0500414 it != m_corLsdb.end() ; it++) {
akmhoque2f423352014-06-03 11:49:35 -0500415 (*it).writeLog();
akmhoque53353462014-04-22 08:43:45 -0500416 }
417}
418
akmhoque53353462014-04-22 08:43:45 -0500419// Adj LSA and LSDB related function starts here
420
421static bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500422adjLsaCompareByKey(AdjLsa& alsa, const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500423{
424 return alsa.getKey() == key;
425}
426
akmhoque53353462014-04-22 08:43:45 -0500427void
akmhoque31d1d4b2014-05-05 22:08:14 -0500428Lsdb::scheduledAdjLsaBuild()
akmhoque53353462014-04-22 08:43:45 -0500429{
akmhoque674b0b12014-05-20 14:33:28 -0500430 _LOG_DEBUG("scheduledAdjLsaBuild Called");
431 m_nlsr.setIsBuildAdjLsaSheduled(false);
akmhoque157b0a42014-05-13 00:26:37 -0500432 if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr)) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500433 int adjBuildCount = m_nlsr.getAdjBuildCount();
akmhoque157b0a42014-05-13 00:26:37 -0500434 if (adjBuildCount > 0) {
435 if (m_nlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0) {
akmhoque674b0b12014-05-20 14:33:28 -0500436 _LOG_DEBUG("Building and installing Adj LSA");
akmhoque31d1d4b2014-05-05 22:08:14 -0500437 buildAndInstallOwnAdjLsa();
akmhoque53353462014-04-22 08:43:45 -0500438 }
akmhoque157b0a42014-05-13 00:26:37 -0500439 else {
akmhoque31d1d4b2014-05-05 22:08:14 -0500440 ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
441 key.append("adjacency");
442 removeAdjLsa(key);
443 m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
akmhoque53353462014-04-22 08:43:45 -0500444 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500445 m_nlsr.setAdjBuildCount(m_nlsr.getAdjBuildCount() - adjBuildCount);
akmhoque53353462014-04-22 08:43:45 -0500446 }
447 }
akmhoque157b0a42014-05-13 00:26:37 -0500448 else {
akmhoque674b0b12014-05-20 14:33:28 -0500449 m_nlsr.setIsBuildAdjLsaSheduled(true);
akmhoque31d1d4b2014-05-05 22:08:14 -0500450 int schedulingTime = m_nlsr.getConfParameter().getInterestRetryNumber() *
451 m_nlsr.getConfParameter().getInterestResendTime();
452 m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(schedulingTime),
453 ndn::bind(&Lsdb::scheduledAdjLsaBuild,
454 this));
akmhoque53353462014-04-22 08:43:45 -0500455 }
456}
457
458
459bool
460Lsdb::addAdjLsa(AdjLsa& alsa)
461{
462 std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
463 m_adjLsdb.end(),
464 bind(adjLsaCompareByKey, _1,
465 alsa.getKey()));
akmhoque157b0a42014-05-13 00:26:37 -0500466 if (it == m_adjLsdb.end()) {
akmhoque53353462014-04-22 08:43:45 -0500467 m_adjLsdb.push_back(alsa);
468 return true;
469 }
470 return false;
471}
472
akmhoqueb6450b12014-04-24 00:01:03 -0500473AdjLsa*
akmhoque31d1d4b2014-05-05 22:08:14 -0500474Lsdb::findAdjLsa(const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500475{
476 std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
477 m_adjLsdb.end(),
478 bind(adjLsaCompareByKey, _1, key));
akmhoque157b0a42014-05-13 00:26:37 -0500479 if (it != m_adjLsdb.end()) {
akmhoqueb6450b12014-04-24 00:01:03 -0500480 return &(*it);
akmhoque53353462014-04-22 08:43:45 -0500481 }
akmhoqueb6450b12014-04-24 00:01:03 -0500482 return 0;
akmhoque53353462014-04-22 08:43:45 -0500483}
484
485
486bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500487Lsdb::isAdjLsaNew(const ndn::Name& key, uint64_t seqNo)
akmhoque53353462014-04-22 08:43:45 -0500488{
akmhoqueb6450b12014-04-24 00:01:03 -0500489 AdjLsa* adjLsaCheck = findAdjLsa(key);
akmhoque157b0a42014-05-13 00:26:37 -0500490 if (adjLsaCheck != 0) {
491 if (adjLsaCheck->getLsSeqNo() < seqNo) {
akmhoque53353462014-04-22 08:43:45 -0500492 return true;
493 }
akmhoque157b0a42014-05-13 00:26:37 -0500494 else {
akmhoque53353462014-04-22 08:43:45 -0500495 return false;
496 }
497 }
498 return true;
499}
500
501
502ndn::EventId
akmhoquec7a79b22014-05-26 08:06:19 -0500503Lsdb::scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
504 const ndn::time::seconds& expTime)
akmhoque53353462014-04-22 08:43:45 -0500505{
akmhoquec7a79b22014-05-26 08:06:19 -0500506 return m_nlsr.getScheduler().scheduleEvent(expTime,
akmhoque31d1d4b2014-05-05 22:08:14 -0500507 ndn::bind(&Lsdb::exprireOrRefreshAdjLsa,
508 this, key, seqNo));
akmhoque53353462014-04-22 08:43:45 -0500509}
510
511bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500512Lsdb::installAdjLsa(AdjLsa& alsa)
akmhoque53353462014-04-22 08:43:45 -0500513{
Alexander Afanasyev8388ec62014-08-16 18:38:57 -0700514 ndn::time::seconds timeToExpire = m_lsaRefreshTime;
akmhoqueb6450b12014-04-24 00:01:03 -0500515 AdjLsa* chkAdjLsa = findAdjLsa(alsa.getKey());
akmhoque157b0a42014-05-13 00:26:37 -0500516 if (chkAdjLsa == 0) {
akmhoque674b0b12014-05-20 14:33:28 -0500517 _LOG_DEBUG("New Adj LSA. Adding to LSDB");
akmhoque2f423352014-06-03 11:49:35 -0500518 _LOG_DEBUG("Adding Adj Lsa");
akmhoque674b0b12014-05-20 14:33:28 -0500519 alsa.writeLog();
akmhoque53353462014-04-22 08:43:45 -0500520 addAdjLsa(alsa);
akmhoque31d1d4b2014-05-05 22:08:14 -0500521 alsa.addNptEntries(m_nlsr);
522 m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
akmhoque157b0a42014-05-13 00:26:37 -0500523 if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoquec7a79b22014-05-26 08:06:19 -0500524 ndn::time::system_clock::Duration duration = alsa.getExpirationTimePoint() -
525 ndn::time::system_clock::now();
526 timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
akmhoque53353462014-04-22 08:43:45 -0500527 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500528 scheduleAdjLsaExpiration(alsa.getKey(),
akmhoque53353462014-04-22 08:43:45 -0500529 alsa.getLsSeqNo(), timeToExpire);
530 }
akmhoque157b0a42014-05-13 00:26:37 -0500531 else {
532 if (chkAdjLsa->getLsSeqNo() < alsa.getLsSeqNo()) {
akmhoque674b0b12014-05-20 14:33:28 -0500533 _LOG_DEBUG("Updated Adj LSA. Updating LSDB");
akmhoque2f423352014-06-03 11:49:35 -0500534 _LOG_DEBUG("Deleting Adj Lsa");
akmhoque674b0b12014-05-20 14:33:28 -0500535 chkAdjLsa->writeLog();
akmhoqueb6450b12014-04-24 00:01:03 -0500536 chkAdjLsa->setLsSeqNo(alsa.getLsSeqNo());
akmhoquec7a79b22014-05-26 08:06:19 -0500537 chkAdjLsa->setExpirationTimePoint(alsa.getExpirationTimePoint());
akmhoque157b0a42014-05-13 00:26:37 -0500538 if (!chkAdjLsa->isEqualContent(alsa)) {
akmhoqueb6450b12014-04-24 00:01:03 -0500539 chkAdjLsa->getAdl().reset();
akmhoquefdbddb12014-05-02 18:35:19 -0500540 chkAdjLsa->getAdl().addAdjacents(alsa.getAdl());
akmhoque31d1d4b2014-05-05 22:08:14 -0500541 m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
akmhoque53353462014-04-22 08:43:45 -0500542 }
akmhoque157b0a42014-05-13 00:26:37 -0500543 if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
akmhoquec7a79b22014-05-26 08:06:19 -0500544 ndn::time::system_clock::Duration duration = alsa.getExpirationTimePoint() -
545 ndn::time::system_clock::now();
546 timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
akmhoque53353462014-04-22 08:43:45 -0500547 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500548 cancelScheduleLsaExpiringEvent(chkAdjLsa->getExpiringEventId());
549 chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(alsa.getKey(),
akmhoqueb6450b12014-04-24 00:01:03 -0500550 alsa.getLsSeqNo(),
551 timeToExpire));
akmhoque2f423352014-06-03 11:49:35 -0500552 _LOG_DEBUG("Adding Adj Lsa");
akmhoque674b0b12014-05-20 14:33:28 -0500553 chkAdjLsa->writeLog();
akmhoque53353462014-04-22 08:43:45 -0500554 }
555 }
556 return true;
557}
558
559bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500560Lsdb::buildAndInstallOwnAdjLsa()
akmhoque53353462014-04-22 08:43:45 -0500561{
akmhoque31d1d4b2014-05-05 22:08:14 -0500562 AdjLsa adjLsa(m_nlsr.getConfParameter().getRouterPrefix(),
563 "adjacency",
564 m_nlsr.getSequencingManager().getAdjLsaSeq() + 1,
akmhoquec7a79b22014-05-26 08:06:19 -0500565 getLsaExpirationTimePoint(),
akmhoque31d1d4b2014-05-05 22:08:14 -0500566 m_nlsr.getAdjacencyList().getNumOfActiveNeighbor(),
567 m_nlsr.getAdjacencyList());
568 m_nlsr.getSequencingManager().increaseAdjLsaSeq();
569 // publish routing update
akmhoque50125a92014-06-30 08:54:17 -0500570 //ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
571 //lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
akmhoque157b0a42014-05-13 00:26:37 -0500572 ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
akmhoque50125a92014-06-30 08:54:17 -0500573 lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
574 lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
akmhoque31d1d4b2014-05-05 22:08:14 -0500575 m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
576 lsaPrefix);
577 return installAdjLsa(adjLsa);
akmhoque53353462014-04-22 08:43:45 -0500578}
579
580bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500581Lsdb::removeAdjLsa(const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500582{
583 std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
584 m_adjLsdb.end(),
akmhoque157b0a42014-05-13 00:26:37 -0500585 ndn::bind(adjLsaCompareByKey, _1, key));
586 if (it != m_adjLsdb.end()) {
akmhoque2f423352014-06-03 11:49:35 -0500587 _LOG_DEBUG("Deleting Adj Lsa");
akmhoque674b0b12014-05-20 14:33:28 -0500588 (*it).writeLog();
akmhoque31d1d4b2014-05-05 22:08:14 -0500589 (*it).removeNptEntries(m_nlsr);
akmhoque53353462014-04-22 08:43:45 -0500590 m_adjLsdb.erase(it);
591 return true;
592 }
593 return false;
594}
595
596bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500597Lsdb::doesAdjLsaExist(const ndn::Name& key)
akmhoque53353462014-04-22 08:43:45 -0500598{
599 std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
600 m_adjLsdb.end(),
601 bind(adjLsaCompareByKey, _1, key));
akmhoque157b0a42014-05-13 00:26:37 -0500602 if (it == m_adjLsdb.end()) {
akmhoque53353462014-04-22 08:43:45 -0500603 return false;
604 }
605 return true;
606}
607
608std::list<AdjLsa>&
609Lsdb::getAdjLsdb()
610{
611 return m_adjLsdb;
612}
613
614void
615Lsdb::setLsaRefreshTime(int lrt)
616{
Alexander Afanasyev8388ec62014-08-16 18:38:57 -0700617 m_lsaRefreshTime = ndn::time::seconds(lrt);
akmhoque53353462014-04-22 08:43:45 -0500618}
619
620void
621Lsdb::setThisRouterPrefix(string trp)
622{
623 m_thisRouterPrefix = trp;
624}
625
626void
akmhoque31d1d4b2014-05-05 22:08:14 -0500627Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
akmhoque53353462014-04-22 08:43:45 -0500628{
akmhoque674b0b12014-05-20 14:33:28 -0500629 _LOG_DEBUG("Lsdb::exprireOrRefreshNameLsa Called");
630 _LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
akmhoqueb6450b12014-04-24 00:01:03 -0500631 NameLsa* chkNameLsa = findNameLsa(lsaKey);
akmhoque157b0a42014-05-13 00:26:37 -0500632 if (chkNameLsa != 0) {
akmhoque674b0b12014-05-20 14:33:28 -0500633 _LOG_DEBUG("LSA Exists with seq no: " << chkNameLsa->getLsSeqNo());
akmhoque157b0a42014-05-13 00:26:37 -0500634 if (chkNameLsa->getLsSeqNo() == seqNo) {
635 if (chkNameLsa->getOrigRouter() == m_thisRouterPrefix) {
akmhoque2f423352014-06-03 11:49:35 -0500636 _LOG_DEBUG("Own Name LSA, so refreshing it");
637 _LOG_DEBUG("Deleting Name Lsa");
akmhoqueb6450b12014-04-24 00:01:03 -0500638 chkNameLsa->writeLog();
akmhoqueb6450b12014-04-24 00:01:03 -0500639 chkNameLsa->setLsSeqNo(chkNameLsa->getLsSeqNo() + 1);
akmhoque31d1d4b2014-05-05 22:08:14 -0500640 m_nlsr.getSequencingManager().setNameLsaSeq(chkNameLsa->getLsSeqNo());
akmhoquec7a79b22014-05-26 08:06:19 -0500641 chkNameLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
akmhoque2f423352014-06-03 11:49:35 -0500642 _LOG_DEBUG("Adding Name Lsa");
akmhoqueb6450b12014-04-24 00:01:03 -0500643 chkNameLsa->writeLog();
akmhoquefdbddb12014-05-02 18:35:19 -0500644 // schedule refreshing event again
akmhoque31d1d4b2014-05-05 22:08:14 -0500645 chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(chkNameLsa->getKey(),
akmhoquefdbddb12014-05-02 18:35:19 -0500646 chkNameLsa->getLsSeqNo(),
Alexander Afanasyev8388ec62014-08-16 18:38:57 -0700647 m_lsaRefreshTime));
akmhoque53353462014-04-22 08:43:45 -0500648 // publish routing update
akmhoque50125a92014-06-30 08:54:17 -0500649 //ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
650 //lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
akmhoque157b0a42014-05-13 00:26:37 -0500651 ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
akmhoque50125a92014-06-30 08:54:17 -0500652 lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
653 lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
akmhoque31d1d4b2014-05-05 22:08:14 -0500654 m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
655 lsaPrefix);
akmhoque53353462014-04-22 08:43:45 -0500656 }
akmhoque157b0a42014-05-13 00:26:37 -0500657 else {
akmhoque674b0b12014-05-20 14:33:28 -0500658 _LOG_DEBUG("Other's Name LSA, so removing form LSDB");
akmhoque31d1d4b2014-05-05 22:08:14 -0500659 removeNameLsa(lsaKey);
akmhoque53353462014-04-22 08:43:45 -0500660 }
661 }
662 }
663}
664
665void
akmhoque31d1d4b2014-05-05 22:08:14 -0500666Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
akmhoque53353462014-04-22 08:43:45 -0500667{
akmhoque674b0b12014-05-20 14:33:28 -0500668 _LOG_DEBUG("Lsdb::exprireOrRefreshAdjLsa Called");
669 _LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
akmhoqueb6450b12014-04-24 00:01:03 -0500670 AdjLsa* chkAdjLsa = findAdjLsa(lsaKey);
akmhoque157b0a42014-05-13 00:26:37 -0500671 if (chkAdjLsa != 0) {
akmhoque2f423352014-06-03 11:49:35 -0500672 _LOG_DEBUG("LSA Exists with seq no: " << chkAdjLsa->getLsSeqNo());
akmhoque157b0a42014-05-13 00:26:37 -0500673 if (chkAdjLsa->getLsSeqNo() == seqNo) {
674 if (chkAdjLsa->getOrigRouter() == m_thisRouterPrefix) {
akmhoque2f423352014-06-03 11:49:35 -0500675 _LOG_DEBUG("Own Adj LSA, so refreshing it");
676 _LOG_DEBUG("Deleting Adj Lsa");
677 chkAdjLsa->writeLog();
akmhoqueb6450b12014-04-24 00:01:03 -0500678 chkAdjLsa->setLsSeqNo(chkAdjLsa->getLsSeqNo() + 1);
akmhoque31d1d4b2014-05-05 22:08:14 -0500679 m_nlsr.getSequencingManager().setAdjLsaSeq(chkAdjLsa->getLsSeqNo());
akmhoquec7a79b22014-05-26 08:06:19 -0500680 chkAdjLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
akmhoque2f423352014-06-03 11:49:35 -0500681 _LOG_DEBUG("Adding Adj Lsa");
682 chkAdjLsa->writeLog();
akmhoquefdbddb12014-05-02 18:35:19 -0500683 // schedule refreshing event again
akmhoque31d1d4b2014-05-05 22:08:14 -0500684 chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(chkAdjLsa->getKey(),
akmhoquefdbddb12014-05-02 18:35:19 -0500685 chkAdjLsa->getLsSeqNo(),
Alexander Afanasyev8388ec62014-08-16 18:38:57 -0700686 m_lsaRefreshTime));
akmhoque53353462014-04-22 08:43:45 -0500687 // publish routing update
akmhoque50125a92014-06-30 08:54:17 -0500688 //ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
689 //lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
akmhoque157b0a42014-05-13 00:26:37 -0500690 ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
akmhoque50125a92014-06-30 08:54:17 -0500691 lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
692 lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
akmhoque31d1d4b2014-05-05 22:08:14 -0500693 m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
694 lsaPrefix);
akmhoque53353462014-04-22 08:43:45 -0500695 }
akmhoque157b0a42014-05-13 00:26:37 -0500696 else {
akmhoque674b0b12014-05-20 14:33:28 -0500697 _LOG_DEBUG("Other's Adj LSA, so removing form LSDB");
akmhoque31d1d4b2014-05-05 22:08:14 -0500698 removeAdjLsa(lsaKey);
akmhoque53353462014-04-22 08:43:45 -0500699 }
700 // schedule Routing table calculaiton
akmhoque31d1d4b2014-05-05 22:08:14 -0500701 m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
akmhoque53353462014-04-22 08:43:45 -0500702 }
703 }
704}
705
706void
akmhoque31d1d4b2014-05-05 22:08:14 -0500707Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
akmhoqueb6450b12014-04-24 00:01:03 -0500708 uint64_t seqNo)
akmhoque53353462014-04-22 08:43:45 -0500709{
akmhoque674b0b12014-05-20 14:33:28 -0500710 _LOG_DEBUG("Lsdb::exprireOrRefreshCorLsa Called ");
711 _LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
akmhoqueb6450b12014-04-24 00:01:03 -0500712 CoordinateLsa* chkCorLsa = findCoordinateLsa(lsaKey);
akmhoque157b0a42014-05-13 00:26:37 -0500713 if (chkCorLsa != 0) {
akmhoque674b0b12014-05-20 14:33:28 -0500714 _LOG_DEBUG("LSA Exists with seq no: " << chkCorLsa->getLsSeqNo());
akmhoque157b0a42014-05-13 00:26:37 -0500715 if (chkCorLsa->getLsSeqNo() == seqNo) {
716 if (chkCorLsa->getOrigRouter() == m_thisRouterPrefix) {
akmhoque2f423352014-06-03 11:49:35 -0500717 _LOG_DEBUG("Own Cor LSA, so refreshing it");
718 _LOG_DEBUG("Deleting Coordinate Lsa");
719 chkCorLsa->writeLog();
akmhoqueb6450b12014-04-24 00:01:03 -0500720 chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
akmhoque31d1d4b2014-05-05 22:08:14 -0500721 m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
akmhoquec7a79b22014-05-26 08:06:19 -0500722 chkCorLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
akmhoque2f423352014-06-03 11:49:35 -0500723 _LOG_DEBUG("Adding Coordinate Lsa");
724 chkCorLsa->writeLog();
akmhoquefdbddb12014-05-02 18:35:19 -0500725 // schedule refreshing event again
akmhoque31d1d4b2014-05-05 22:08:14 -0500726 chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(
727 chkCorLsa->getKey(),
728 chkCorLsa->getLsSeqNo(),
Alexander Afanasyev8388ec62014-08-16 18:38:57 -0700729 m_lsaRefreshTime));
akmhoque53353462014-04-22 08:43:45 -0500730 // publish routing update
akmhoque50125a92014-06-30 08:54:17 -0500731 //ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
732 //lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
akmhoque157b0a42014-05-13 00:26:37 -0500733 ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
akmhoque50125a92014-06-30 08:54:17 -0500734 lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
735 lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
akmhoque31d1d4b2014-05-05 22:08:14 -0500736 m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
737 lsaPrefix);
akmhoque53353462014-04-22 08:43:45 -0500738 }
akmhoque157b0a42014-05-13 00:26:37 -0500739 else {
akmhoque674b0b12014-05-20 14:33:28 -0500740 _LOG_DEBUG("Other's Cor LSA, so removing form LSDB");
akmhoque31d1d4b2014-05-05 22:08:14 -0500741 removeCoordinateLsa(lsaKey);
akmhoque53353462014-04-22 08:43:45 -0500742 }
akmhoque157b0a42014-05-13 00:26:37 -0500743 if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500744 m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
akmhoque53353462014-04-22 08:43:45 -0500745 }
746 }
747 }
748}
749
750
751void
akmhoque06986672014-05-27 13:55:53 -0500752Lsdb::expressInterest(const ndn::Name& interestName, uint32_t interestLifeTime,
753 uint32_t timeoutCount)
akmhoque31d1d4b2014-05-05 22:08:14 -0500754{
akmhoque31d1d4b2014-05-05 22:08:14 -0500755 ndn::Interest interest(interestName);
akmhoquedfe615f2014-07-27 14:12:21 -0500756 uint64_t interestedLsSeqNo = interestName[-1].toNumber();
757 _LOG_DEBUG("Expressing Interest for LSA(name): " << interestName <<
758 " Seq number: " << interestedLsSeqNo );
akmhoque31d1d4b2014-05-05 22:08:14 -0500759 interest.setInterestLifetime(ndn::time::seconds(interestLifeTime));
760 interest.setMustBeFresh(true);
761 m_nlsr.getNlsrFace().expressInterest(interest,
Yingdi Yu20e3a6e2014-05-26 23:16:10 -0700762 ndn::bind(&Lsdb::onContent,
akmhoque31d1d4b2014-05-05 22:08:14 -0500763 this, _1, _2),
764 ndn::bind(&Lsdb::processInterestTimedOut,
akmhoque06986672014-05-27 13:55:53 -0500765 this, _1, timeoutCount));
akmhoque31d1d4b2014-05-05 22:08:14 -0500766}
767
768void
769Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
770{
771 const ndn::Name& intName(interest.getName());
akmhoque674b0b12014-05-20 14:33:28 -0500772 _LOG_DEBUG("Interest recevied for LSA(name): " << intName);
akmhoque31d1d4b2014-05-05 22:08:14 -0500773 string chkString("LSA");
774 int32_t lsaPosition = util::getNameComponentPosition(interest.getName(),
775 chkString);
akmhoque157b0a42014-05-13 00:26:37 -0500776 if (lsaPosition >= 0) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500777 std::string interestedLsType;
778 uint64_t interestedLsSeqNo;
akmhoque50125a92014-06-30 08:54:17 -0500779 ndn::Name origRouter = m_nlsr.getConfParameter().getNetwork();
780 origRouter.append(intName.getSubName(lsaPosition + 1,
781 interest.getName().size() - lsaPosition - 3));
akmhoque157b0a42014-05-13 00:26:37 -0500782 interestedLsType = intName[-2].toUri();
akmhoque31d1d4b2014-05-05 22:08:14 -0500783 interestedLsSeqNo = intName[-1].toNumber();
akmhoquedfe615f2014-07-27 14:12:21 -0500784 _LOG_DEBUG("LSA sequence number from interest: " << interestedLsSeqNo);
akmhoque157b0a42014-05-13 00:26:37 -0500785 if (interestedLsType == "name") {
akmhoque31d1d4b2014-05-05 22:08:14 -0500786 processInterestForNameLsa(interest,
787 origRouter.append(interestedLsType),
788 interestedLsSeqNo);
789 return;
790 }
akmhoque157b0a42014-05-13 00:26:37 -0500791 else if (interestedLsType == "adjacency") {
akmhoque31d1d4b2014-05-05 22:08:14 -0500792 processInterestForAdjacencyLsa(interest,
793 origRouter.append(interestedLsType),
794 interestedLsSeqNo);
795 return;
796 }
akmhoque157b0a42014-05-13 00:26:37 -0500797 else if (interestedLsType == "coordinate") {
akmhoque31d1d4b2014-05-05 22:08:14 -0500798 processInterestForCoordinateLsa(interest,
799 origRouter.append(interestedLsType),
800 interestedLsSeqNo);
801 return;
802 }
akmhoque157b0a42014-05-13 00:26:37 -0500803 else {
akmhoque2f423352014-06-03 11:49:35 -0500804 _LOG_DEBUG("Unrecognized LSA Type :(");
akmhoque31d1d4b2014-05-05 22:08:14 -0500805 }
806 }
807}
808
809void
akmhoque69c9aa92014-07-23 15:15:05 -0500810Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
811{
812 ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
813 data->setName(ndn::Name(interest.getName()).appendVersion());
814 data->setFreshnessPeriod(ndn::time::seconds(10));
815 data->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size());
816 m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName());
akmhoquedfe615f2014-07-27 14:12:21 -0500817 ndn::SignatureSha256WithRsa signature(data->getSignature());
818 ndn::Name signingCertName = signature.getKeyLocator().getName();
akmhoque69c9aa92014-07-23 15:15:05 -0500819 _LOG_DEBUG("Sending data for LSA(name): " << interest.getName());
akmhoquedfe615f2014-07-27 14:12:21 -0500820 _LOG_DEBUG("Data signed with: " << signingCertName);
akmhoque69c9aa92014-07-23 15:15:05 -0500821 m_nlsr.getNlsrFace().put(*data);
822}
823
824void
akmhoque31d1d4b2014-05-05 22:08:14 -0500825Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
826 const ndn::Name& lsaKey,
827 uint32_t interestedlsSeqNo)
828{
829 NameLsa* nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
akmhoque157b0a42014-05-13 00:26:37 -0500830 if (nameLsa != 0) {
831 if (nameLsa->getLsSeqNo() >= interestedlsSeqNo) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500832 std::string content = nameLsa->getData();
akmhoque69c9aa92014-07-23 15:15:05 -0500833 putLsaData(interest,content);
akmhoque31d1d4b2014-05-05 22:08:14 -0500834 }
835 }
836}
837
838void
839Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
840 const ndn::Name& lsaKey,
841 uint32_t interestedlsSeqNo)
842{
843 AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
akmhoque157b0a42014-05-13 00:26:37 -0500844 if (adjLsa != 0) {
845 if (adjLsa->getLsSeqNo() >= interestedlsSeqNo) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500846 std::string content = adjLsa->getData();
akmhoque69c9aa92014-07-23 15:15:05 -0500847 putLsaData(interest,content);
akmhoque31d1d4b2014-05-05 22:08:14 -0500848 }
849 }
850}
851
852void
853Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
854 const ndn::Name& lsaKey,
855 uint32_t interestedlsSeqNo)
856{
857 CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
akmhoque157b0a42014-05-13 00:26:37 -0500858 if (corLsa != 0) {
859 if (corLsa->getLsSeqNo() >= interestedlsSeqNo) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500860 std::string content = corLsa->getData();
akmhoque69c9aa92014-07-23 15:15:05 -0500861 putLsaData(interest,content);
akmhoque31d1d4b2014-05-05 22:08:14 -0500862 }
863 }
864}
865
866void
Yingdi Yu20e3a6e2014-05-26 23:16:10 -0700867Lsdb::onContent(const ndn::Interest& interest, const ndn::Data& data)
akmhoque31d1d4b2014-05-05 22:08:14 -0500868{
akmhoquedfe615f2014-07-27 14:12:21 -0500869 _LOG_DEBUG("Received data for LSA(name): " << data.getName());
870 if (data.getSignature().hasKeyLocator()) {
871 if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
872 _LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName());
873 }
874 }
Yingdi Yu20e3a6e2014-05-26 23:16:10 -0700875 m_nlsr.getValidator().validate(data,
876 ndn::bind(&Lsdb::onContentValidated, this, _1),
877 ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2));
878
879}
880
881void
882Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
883{
884 const ndn::Name& dataName = data->getName();
akmhoquedfe615f2014-07-27 14:12:21 -0500885 _LOG_DEBUG("Data validation successful for LSA(name): " << dataName);
Yingdi Yu20e3a6e2014-05-26 23:16:10 -0700886 string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
akmhoque31d1d4b2014-05-05 22:08:14 -0500887 string chkString("LSA");
888 int32_t lsaPosition = util::getNameComponentPosition(dataName, chkString);
akmhoque157b0a42014-05-13 00:26:37 -0500889 if (lsaPosition >= 0) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500890 std::string interestedLsType;
891 uint64_t interestedLsSeqNo;
akmhoque50125a92014-06-30 08:54:17 -0500892 ndn::Name origRouter = m_nlsr.getConfParameter().getNetwork();
893 origRouter.append(dataName.getSubName(lsaPosition + 1,
894 dataName.size() - lsaPosition - 4));
akmhoque157b0a42014-05-13 00:26:37 -0500895 interestedLsType = dataName[-3].toUri();
akmhoque31d1d4b2014-05-05 22:08:14 -0500896 interestedLsSeqNo = dataName[-2].toNumber();
akmhoque157b0a42014-05-13 00:26:37 -0500897 if (interestedLsType == "name") {
akmhoque31d1d4b2014-05-05 22:08:14 -0500898 processContentNameLsa(origRouter.append(interestedLsType),
899 interestedLsSeqNo, dataContent);
900 return;
901 }
akmhoque157b0a42014-05-13 00:26:37 -0500902 else if (interestedLsType == "adjacency") {
akmhoque31d1d4b2014-05-05 22:08:14 -0500903 processContentAdjacencyLsa(origRouter.append(interestedLsType),
904 interestedLsSeqNo, dataContent);
905 return;
906 }
akmhoque157b0a42014-05-13 00:26:37 -0500907 else if (interestedLsType == "coordinate") {
akmhoque31d1d4b2014-05-05 22:08:14 -0500908 processContentCoordinateLsa(origRouter.append(interestedLsType),
909 interestedLsSeqNo, dataContent);
910 return;
911 }
akmhoque157b0a42014-05-13 00:26:37 -0500912 else {
akmhoque2f423352014-06-03 11:49:35 -0500913 _LOG_DEBUG("Unrecognized LSA Type :(");
akmhoque31d1d4b2014-05-05 22:08:14 -0500914 }
915 }
916}
917
918void
Yingdi Yu20e3a6e2014-05-26 23:16:10 -0700919Lsdb::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, const std::string& msg)
920{
akmhoque2f423352014-06-03 11:49:35 -0500921 _LOG_DEBUG("Validation Error: " << msg);
Yingdi Yu20e3a6e2014-05-26 23:16:10 -0700922}
923
924void
akmhoque31d1d4b2014-05-05 22:08:14 -0500925Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
926 uint32_t lsSeqNo, std::string& dataContent)
927{
akmhoque157b0a42014-05-13 00:26:37 -0500928 if (isNameLsaNew(lsaKey, lsSeqNo)) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500929 NameLsa nameLsa;
akmhoque157b0a42014-05-13 00:26:37 -0500930 if (nameLsa.initializeFromContent(dataContent)) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500931 installNameLsa(nameLsa);
932 }
akmhoque157b0a42014-05-13 00:26:37 -0500933 else {
akmhoque2f423352014-06-03 11:49:35 -0500934 _LOG_DEBUG("LSA data decoding error :(");
akmhoque31d1d4b2014-05-05 22:08:14 -0500935 }
936 }
937}
938
939void
940Lsdb::processContentAdjacencyLsa(const ndn::Name& lsaKey,
941 uint32_t lsSeqNo, std::string& dataContent)
942{
akmhoque157b0a42014-05-13 00:26:37 -0500943 if (isAdjLsaNew(lsaKey, lsSeqNo)) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500944 AdjLsa adjLsa;
akmhoque157b0a42014-05-13 00:26:37 -0500945 if (adjLsa.initializeFromContent(dataContent)) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500946 installAdjLsa(adjLsa);
947 }
akmhoque157b0a42014-05-13 00:26:37 -0500948 else {
akmhoque2f423352014-06-03 11:49:35 -0500949 _LOG_DEBUG("LSA data decoding error :(");
akmhoque31d1d4b2014-05-05 22:08:14 -0500950 }
951 }
952}
953
954void
955Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
956 uint32_t lsSeqNo, std::string& dataContent)
957{
akmhoque157b0a42014-05-13 00:26:37 -0500958 if (isCoordinateLsaNew(lsaKey, lsSeqNo)) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500959 CoordinateLsa corLsa;
akmhoque157b0a42014-05-13 00:26:37 -0500960 if (corLsa.initializeFromContent(dataContent)) {
akmhoque31d1d4b2014-05-05 22:08:14 -0500961 installCoordinateLsa(corLsa);
962 }
akmhoque157b0a42014-05-13 00:26:37 -0500963 else {
akmhoque2f423352014-06-03 11:49:35 -0500964 _LOG_DEBUG("LSA data decoding error :(");
akmhoque31d1d4b2014-05-05 22:08:14 -0500965 }
966 }
967}
968
969void
akmhoque06986672014-05-27 13:55:53 -0500970Lsdb::processInterestTimedOut(const ndn::Interest& interest, uint32_t timeoutCount)
akmhoque31d1d4b2014-05-05 22:08:14 -0500971{
972 const ndn::Name& interestName(interest.getName());
akmhoque674b0b12014-05-20 14:33:28 -0500973 _LOG_DEBUG("Interest timed out for LSA(name): " << interestName);
akmhoque06986672014-05-27 13:55:53 -0500974 if ((timeoutCount + 1) <= m_nlsr.getConfParameter().getInterestRetryNumber()) {
975 _LOG_DEBUG("Interest timeoutCount: " << (timeoutCount + 1));
976 _LOG_DEBUG("Need to express interest again for LSA(name): " << interestName);
977 expressInterest(interestName,
978 m_nlsr.getConfParameter().getInterestResendTime(),
979 timeoutCount + 1);
980 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500981}
982
akmhoquec7a79b22014-05-26 08:06:19 -0500983ndn::time::system_clock::TimePoint
984Lsdb::getLsaExpirationTimePoint()
985{
986 ndn::time::system_clock::TimePoint expirationTimePoint = ndn::time::system_clock::now();
987 expirationTimePoint = expirationTimePoint +
988 ndn::time::seconds(m_nlsr.getConfParameter().getRouterDeadInterval());
989 return expirationTimePoint;
990}
akmhoque31d1d4b2014-05-05 22:08:14 -0500991
992void
akmhoque2f423352014-06-03 11:49:35 -0500993Lsdb::writeAdjLsdbLog()
akmhoque53353462014-04-22 08:43:45 -0500994{
akmhoque2f423352014-06-03 11:49:35 -0500995 _LOG_DEBUG("---------------Adj LSDB-------------------");
akmhoque53353462014-04-22 08:43:45 -0500996 for (std::list<AdjLsa>::iterator it = m_adjLsdb.begin();
akmhoque157b0a42014-05-13 00:26:37 -0500997 it != m_adjLsdb.end() ; it++) {
akmhoque2f423352014-06-03 11:49:35 -0500998 (*it).writeLog();
akmhoque53353462014-04-22 08:43:45 -0500999 }
1000}
1001
1002//-----utility function -----
1003bool
akmhoque31d1d4b2014-05-05 22:08:14 -05001004Lsdb::doesLsaExist(const ndn::Name& key, const std::string& lsType)
akmhoque53353462014-04-22 08:43:45 -05001005{
akmhoque157b0a42014-05-13 00:26:37 -05001006 if (lsType == "name") {
akmhoque53353462014-04-22 08:43:45 -05001007 return doesNameLsaExist(key);
1008 }
akmhoque157b0a42014-05-13 00:26:37 -05001009 else if (lsType == "adjacency") {
akmhoque53353462014-04-22 08:43:45 -05001010 return doesAdjLsaExist(key);
1011 }
akmhoque157b0a42014-05-13 00:26:37 -05001012 else if (lsType == "coordinate") {
akmhoqueb6450b12014-04-24 00:01:03 -05001013 return doesCoordinateLsaExist(key);
akmhoque53353462014-04-22 08:43:45 -05001014 }
1015 return false;
1016}
1017
Alexander Afanasyev8388ec62014-08-16 18:38:57 -07001018} // namespace nlsr