blob: 9e3ffe7d4e6af62369780e6cefc6178470952a76 [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#include<string>
2#include<utility>
3#include "nlsr_lsdb.hpp"
4#include "nlsr.hpp"
5
6using namespace std;
7
8static bool
9nameLsaCompareByKey(NameLsa& nlsa1, string& key){
10 return nlsa1.getNameLsaKey()==key;
11}
12
13
14bool
15Lsdb::buildAndInstallOwnNameLsa(nlsr& pnlsr)
16{
17 NameLsa nameLsa(pnlsr.getConfParameter().getRouterPrefix()
18 , 1
19 , pnlsr.getSm().getNameLsaSeq()+1
20 , pnlsr.getConfParameter().getRouterDeadInterval()
21 , pnlsr.getNpl() );
22 pnlsr.getSm().setNameLsaSeq(pnlsr.getSm().getNameLsaSeq()+1);
23 return installNameLsa(pnlsr,nameLsa);
24
25}
26
27std::pair<NameLsa&, bool>
28Lsdb::getNameLsa(string key)
29{
30 std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
31 nameLsdb.end(),
32 bind(nameLsaCompareByKey, _1, key));
33
34 if( it != nameLsdb.end())
35 {
36 return std::make_pair(boost::ref((*it)),true);
37 }
38
39 NameLsa nlsa;
40 return std::make_pair(boost::ref(nlsa),false);
41
42}
43
44
45void
46Lsdb::scheduleNameLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime)
47{
48 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
49 ndn::bind(&Lsdb::exprireOrRefreshNameLsa,
50 this,boost::ref(pnlsr), key, seqNo));
51}
52
53bool
54Lsdb::installNameLsa(nlsr& pnlsr, NameLsa &nlsa)
55{
56 int timeToExpire=lsaRefreshTime;
57 std::pair<NameLsa& , bool> chkNameLsa=getNameLsa(nlsa.getNameLsaKey());
58 if ( !chkNameLsa.second )
59 {
60 addNameLsa(nlsa);
61 printNameLsdb();
62 if ( nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
63 {
64 pnlsr.getNpt().addNpte(nlsa.getOrigRouter(),nlsa.getOrigRouter(),pnlsr);
65 std::list<string> nameList=nlsa.getNpl().getNameList();
66 for(std::list<string>::iterator it=nameList.begin(); it!=nameList.end();it++)
67 {
68 if ( (*it) !=pnlsr.getConfParameter().getRouterPrefix())
69 {
70 pnlsr.getNpt().addNpte((*it),nlsa.getOrigRouter(),pnlsr);
71 }
72 }
73 }
74
75 if(nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
76 {
77 timeToExpire=nlsa.getLifeTime();
78 }
79 scheduleNameLsaExpiration( pnlsr, nlsa.getNameLsaKey(),
80 nlsa.getLsSeqNo(), timeToExpire);
81 }
82 else
83 {
84 if ( chkNameLsa.first.getLsSeqNo() < nlsa.getLsSeqNo() )
85 {
86 chkNameLsa.first.setLsSeqNo(nlsa.getLsSeqNo());
87 chkNameLsa.first.setLifeTime(nlsa.getLifeTime());
88
89 chkNameLsa.first.getNpl().sortNpl();
90 nlsa.getNpl().sortNpl();
91
92 std::list<string> nameToAdd;
93 std::set_difference(nlsa.getNpl().getNameList().begin(),
94 nlsa.getNpl().getNameList().end(),
95 chkNameLsa.first.getNpl().getNameList().begin(),
96 chkNameLsa.first.getNpl().getNameList().end(),
97 std::inserter(nameToAdd, nameToAdd.begin()));
98 for(std::list<string>::iterator it=nameToAdd.begin(); it!=nameToAdd.end();
99 ++it)
100 {
101 chkNameLsa.first.addNameToLsa((*it));
102 if ( nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
103 {
104 if ( (*it) !=pnlsr.getConfParameter().getRouterPrefix())
105 {
106 pnlsr.getNpt().addNpte((*it),nlsa.getOrigRouter(),pnlsr);
107 }
108 }
109 }
110
111 std::list<string> nameToRemove;
112 std::set_difference(chkNameLsa.first.getNpl().getNameList().begin(),
113 chkNameLsa.first.getNpl().getNameList().end(),
114 nlsa.getNpl().getNameList().begin(),
115 nlsa.getNpl().getNameList().end(),
116 std::inserter(nameToRemove, nameToRemove.begin()));
117 for(std::list<string>::iterator it=nameToRemove.begin();
118 it!=nameToRemove.end(); ++it)
119 {
120 chkNameLsa.first.removeNameFromLsa((*it));
121 if ( nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
122 {
123 if ( (*it) !=pnlsr.getConfParameter().getRouterPrefix())
124 {
125 pnlsr.getNpt().removeNpte((*it),nlsa.getOrigRouter(),pnlsr);
126 }
127 }
128 }
129
130 if(nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
131 {
132 timeToExpire=nlsa.getLifeTime();
133 }
134 scheduleNameLsaExpiration( pnlsr, nlsa.getNameLsaKey(),
135 nlsa.getLsSeqNo(), timeToExpire);
136 }
137 }
138
139 return true;
140}
141
142bool
143Lsdb::addNameLsa(NameLsa &nlsa)
144{
145 std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
146 nameLsdb.end(), bind(nameLsaCompareByKey, _1, nlsa.getNameLsaKey()));
147
148 if( it == nameLsdb.end())
149 {
150 nameLsdb.push_back(nlsa);
151 return true;
152 }
153 return false;
154}
155
156bool
157Lsdb::removeNameLsa(nlsr& pnlsr, string& key)
158{
159 std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
160 nameLsdb.end(),
161 bind(nameLsaCompareByKey, _1, key));
162 if ( it != nameLsdb.end() )
163 {
164 if ( (*it).getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix() )
165 {
166 pnlsr.getNpt().removeNpte((*it).getOrigRouter(),(*it).getOrigRouter(),pnlsr);
167 for( std::list<string>::iterator nit=(*it).getNpl().getNameList().begin();
168 nit!=(*it).getNpl().getNameList().end(); ++nit)
169 {
170 if ( (*nit) !=pnlsr.getConfParameter().getRouterPrefix())
171 {
172 pnlsr.getNpt().removeNpte((*nit),(*it).getOrigRouter(),pnlsr);
173 }
174 }
175
176 }
177 nameLsdb.erase(it);
178 return true;
179 }
180 return false;
181}
182
183bool
184Lsdb::doesNameLsaExist(string key)
185{
186 std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
187 nameLsdb.end(),
188 bind(nameLsaCompareByKey, _1, key));
189
190 if( it == nameLsdb.end()){
191 return false;
192 }
193
194 return true;
195}
196
197void
198Lsdb::printNameLsdb()
199{
200 cout<<"---------------Name LSDB-------------------"<<endl;
201 for( std::list<NameLsa>::iterator it=nameLsdb.begin();
202 it!= nameLsdb.end() ; it++)
203 {
204 cout<< (*it) <<endl;
205 }
206}
207
208// Cor LSA and LSDB related Functions start here
209
210
211static bool
212corLsaCompareByKey(CorLsa& clsa, string& key){
213 return clsa.getCorLsaKey()==key;
214}
215
216bool
217Lsdb::buildAndInstallOwnCorLsa(nlsr& pnlsr){
218 CorLsa corLsa(pnlsr.getConfParameter().getRouterPrefix()
219 , 3
220 , pnlsr.getSm().getCorLsaSeq()+1
221 , pnlsr.getConfParameter().getRouterDeadInterval()
222 , pnlsr.getConfParameter().getCorR()
223 , pnlsr.getConfParameter().getCorTheta() );
224 pnlsr.getSm().setCorLsaSeq(pnlsr.getSm().getCorLsaSeq()+1);
225 installCorLsa(pnlsr, corLsa);
226
227 return true;
228}
229
230std::pair<CorLsa&, bool>
231Lsdb::getCorLsa(string key)
232{
233 std::list< CorLsa >::iterator it = std::find_if( corLsdb.begin(),
234 corLsdb.end(),
235 bind(corLsaCompareByKey, _1, key));
236
237 if( it != corLsdb.end()){
238 return std::make_pair(boost::ref((*it)), true);
239 }
240
241 CorLsa clsa;
242 return std::make_pair(boost::ref(clsa),false);
243}
244
245void
246Lsdb::scheduleCorLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime)
247{
248 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
249 ndn::bind(&Lsdb::exprireOrRefreshCorLsa,
250 this,boost::ref(pnlsr),key,seqNo));
251}
252
253bool
254Lsdb::installCorLsa(nlsr& pnlsr, CorLsa &clsa)
255{
256 int timeToExpire=lsaRefreshTime;
257 std::pair<CorLsa& , bool> chkCorLsa=getCorLsa(clsa.getCorLsaKey());
258 if ( !chkCorLsa.second )
259 {
260 addCorLsa(clsa);
261 printCorLsdb(); //debugging purpose
262 if ( clsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
263 {
264 pnlsr.getNpt().addNpte(clsa.getOrigRouter(),clsa.getOrigRouter(),pnlsr);
265 }
266 if (pnlsr.getConfParameter().getIsHyperbolicCalc() >=1 )
267 {
268 pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
269 }
270
271 if(clsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
272 {
273 timeToExpire=clsa.getLifeTime();
274 }
275 scheduleCorLsaExpiration(pnlsr,clsa.getCorLsaKey(),
276 clsa.getLsSeqNo(), timeToExpire);
277
278 }
279 else
280 {
281 if ( chkCorLsa.first.getLsSeqNo() < clsa.getLsSeqNo() )
282 {
283 chkCorLsa.first.setLsSeqNo(clsa.getLsSeqNo());
284 chkCorLsa.first.setLifeTime(clsa.getLifeTime());
285 if ( !chkCorLsa.first.isLsaContentEqual(clsa) )
286 {
287 chkCorLsa.first.setCorRadius(clsa.getCorRadius());
288 chkCorLsa.first.setCorTheta(clsa.getCorTheta());
289
290 if (pnlsr.getConfParameter().getIsHyperbolicCalc() >=1 )
291 {
292 pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
293 }
294
295 }
296
297 if(clsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
298 {
299 timeToExpire=clsa.getLifeTime();
300 }
301 scheduleCorLsaExpiration(pnlsr,clsa.getCorLsaKey(),
302 clsa.getLsSeqNo(), timeToExpire);
303 }
304
305 }
306
307 return true;
308}
309
310bool
311Lsdb::addCorLsa(CorLsa& clsa)
312{
313 std::list<CorLsa >::iterator it = std::find_if( corLsdb.begin(),
314 corLsdb.end(),
315 bind(corLsaCompareByKey, _1, clsa.getCorLsaKey()));
316
317 if( it == corLsdb.end())
318 {
319 corLsdb.push_back(clsa);
320 return true;
321 }
322 return false;
323}
324
325bool
326Lsdb::removeCorLsa(nlsr& pnlsr, string& key)
327{
328 std::list<CorLsa >::iterator it = std::find_if( corLsdb.begin(),
329 corLsdb.end(),
330 bind(corLsaCompareByKey, _1, key));
331 if ( it != corLsdb.end() )
332 {
333 if ( (*it).getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
334 {
335 pnlsr.getNpt().removeNpte((*it).getOrigRouter(),(*it).getOrigRouter(),pnlsr);
336 }
337 corLsdb.erase(it);
338 return true;
339 }
340 return false;
341
342}
343
344bool
345Lsdb::doesCorLsaExist(string key)
346{
347 std::list<CorLsa >::iterator it = std::find_if( corLsdb.begin(),
348 corLsdb.end(),
349 bind(corLsaCompareByKey, _1, key));
350
351 if( it == corLsdb.end()){
352 return false;
353 }
354
355 return true;
356}
357
358void
359Lsdb::printCorLsdb() //debugging
360{
361 cout<<"---------------Cor LSDB-------------------"<<endl;
362 for( std::list<CorLsa>::iterator it=corLsdb.begin();
363 it!= corLsdb.end() ; it++)
364 {
365 cout<< (*it) <<endl;
366 }
367}
368
369
370// Adj LSA and LSDB related function starts here
371
372static bool
373adjLsaCompareByKey(AdjLsa& alsa, string& key){
374 return alsa.getAdjLsaKey()==key;
375}
376
377
378void
379Lsdb::scheduledAdjLsaBuild(nlsr& pnlsr)
380{
381 cout<<"scheduledAdjLsaBuild Called"<<endl;
382 pnlsr.setIsBuildAdjLsaSheduled(0);
383
384 if( pnlsr.getAdl().isAdjLsaBuildable(pnlsr))
385 {
386 int adjBuildCount=pnlsr.getAdjBuildCount();
387 if(adjBuildCount>0 )
388 {
389 if (pnlsr.getAdl().getNumOfActiveNeighbor()>0)
390 {
391 buildAndInstallOwnAdjLsa(pnlsr);
392 }
393 else
394 {
395 string key=pnlsr.getConfParameter().getRouterPrefix()+"/2";
396 removeAdjLsa(pnlsr,key);
397 pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
398 }
399 pnlsr.setAdjBuildCount(pnlsr.getAdjBuildCount()-adjBuildCount);
400 }
401 }
402 else
403 {
404 pnlsr.setIsBuildAdjLsaSheduled(1);
405 int schedulingTime=pnlsr.getConfParameter().getInterestRetryNumber()*
406 pnlsr.getConfParameter().getInterestResendTime();
407 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(schedulingTime),
408 ndn::bind(&Lsdb::scheduledAdjLsaBuild, pnlsr.getLsdb(),
409 boost::ref(pnlsr)));
410 }
411
412}
413
414
415bool
416Lsdb::addAdjLsa(AdjLsa &alsa)
417{
418 std::list<AdjLsa >::iterator it = std::find_if( adjLsdb.begin(),
419 adjLsdb.end(),
420 bind(adjLsaCompareByKey, _1, alsa.getAdjLsaKey()));
421
422 if( it == adjLsdb.end()){
423 adjLsdb.push_back(alsa);
424 return true;
425 }
426 return false;
427
428}
429
430std::pair<AdjLsa& , bool>
431Lsdb::getAdjLsa(string key)
432{
433 std::list<AdjLsa >::iterator it = std::find_if( adjLsdb.begin(),
434 adjLsdb.end(),
435 bind(adjLsaCompareByKey, _1, key));
436
437 if( it != adjLsdb.end()){
438 return std::make_pair(boost::ref((*it)),true);
439 }
440
441 AdjLsa alsa;
442 return std::make_pair(boost::ref(alsa),false);
443}
444
445
446
447void
448Lsdb::scheduleAdjLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime)
449{
450 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
451 ndn::bind(&Lsdb::exprireOrRefreshAdjLsa,
452 this,boost::ref(pnlsr),key,seqNo));
453}
454
455bool
456Lsdb::installAdjLsa(nlsr& pnlsr, AdjLsa &alsa)
457{
458 int timeToExpire=lsaRefreshTime;
459 std::pair<AdjLsa& , bool> chkAdjLsa=getAdjLsa(alsa.getAdjLsaKey());
460 if ( !chkAdjLsa.second )
461 {
462 addAdjLsa(alsa);
463 alsa.addNptEntriesForAdjLsa(pnlsr);
464 pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
465
466 if(alsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
467 {
468 timeToExpire=alsa.getLifeTime();
469 }
470 scheduleAdjLsaExpiration(pnlsr,alsa.getAdjLsaKey(),
471 alsa.getLsSeqNo(),timeToExpire);
472
473 }
474 else
475 {
476 if ( chkAdjLsa.first.getLsSeqNo() < alsa.getLsSeqNo() )
477 {
478 chkAdjLsa.first.setLsSeqNo(alsa.getLsSeqNo());
479 chkAdjLsa.first.setLifeTime(alsa.getLifeTime());
480
481 if ( ! chkAdjLsa.first.isLsaContentEqual(alsa))
482 {
483 chkAdjLsa.first.getAdl().resetAdl();
484 chkAdjLsa.first.getAdl().addAdjacentsFromAdl(alsa.getAdl());
485 pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
486 }
487
488 if(alsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
489 {
490 timeToExpire=alsa.getLifeTime();
491 }
492 scheduleAdjLsaExpiration(pnlsr,alsa.getAdjLsaKey(),
493 alsa.getLsSeqNo(),timeToExpire);
494 }
495
496 }
497
498 printAdjLsdb();
499
500 return true;
501}
502
503bool
504Lsdb::buildAndInstallOwnAdjLsa(nlsr& pnlsr)
505{
506 AdjLsa adjLsa(pnlsr.getConfParameter().getRouterPrefix()
507 , 2
508 , pnlsr.getSm().getAdjLsaSeq()+1
509 , pnlsr.getConfParameter().getRouterDeadInterval()
510 , pnlsr.getAdl().getNumOfActiveNeighbor()
511 , pnlsr.getAdl() );
512 pnlsr.getSm().setAdjLsaSeq(pnlsr.getSm().getAdjLsaSeq()+1);
513 return installAdjLsa(pnlsr, adjLsa);
514}
515
516bool
517Lsdb::removeAdjLsa(nlsr& pnlsr, string& key)
518{
519 std::list<AdjLsa >::iterator it = std::find_if( adjLsdb.begin(),
520 adjLsdb.end(),
521 bind(adjLsaCompareByKey, _1, key));
522 if ( it != adjLsdb.end() )
523 {
524 (*it).removeNptEntriesForAdjLsa(pnlsr);
525 adjLsdb.erase(it);
526 return true;
527 }
528 return false;
529
530}
531
532bool
533Lsdb::doesAdjLsaExist(string key)
534{
535 std::list< AdjLsa >::iterator it = std::find_if( adjLsdb.begin(),
536 adjLsdb.end(),
537 bind(adjLsaCompareByKey, _1, key));
538
539 if( it == adjLsdb.end()){
540 return false;
541 }
542
543 return true;
544}
545
546std::list<AdjLsa>&
547Lsdb::getAdjLsdb()
548{
549 return adjLsdb;
550}
551
552void
553Lsdb::setLsaRefreshTime(int lrt)
554{
555 lsaRefreshTime=lrt;
556}
557
558void
559Lsdb::setThisRouterPrefix(string trp)
560{
561 thisRouterPrefix=trp;
562}
563
564void
565Lsdb::exprireOrRefreshNameLsa(nlsr& pnlsr, string lsaKey, int seqNo)
566{
567 cout<<"Lsdb::exprireOrRefreshNameLsa Called "<<endl;
568 cout<<"LSA Key : "<<lsaKey<<" Seq No: "<<endl;
569 std::pair<NameLsa& , bool> chkNameLsa=getNameLsa(lsaKey);
570 if( chkNameLsa.second )
571 {
572 cout<<" LSA Exists with seq no: "<<chkNameLsa.first.getLsSeqNo()<<endl;
573 if ( chkNameLsa.first.getLsSeqNo() == seqNo )
574 {
575 if(chkNameLsa.first.getOrigRouter() == thisRouterPrefix )
576 {
577 cout<<"Own Name LSA, so refreshing name LSA"<<endl;
578 chkNameLsa.first.setLsSeqNo(chkNameLsa.first.getLsSeqNo()+1);
579 pnlsr.getSm().setNameLsaSeq(chkNameLsa.first.getLsSeqNo());
580 // publish routing update
581 }
582 else
583 {
584 cout<<"Other's Name LSA, so removing form LSDB"<<endl;
585 removeNameLsa(pnlsr, lsaKey);
586 }
587 }
588 }
589}
590
591void
592Lsdb::exprireOrRefreshAdjLsa(nlsr& pnlsr, string lsaKey, int seqNo)
593{
594 cout<<"Lsdb::exprireOrRefreshAdjLsa Called "<<endl;
595 cout<<"LSA Key : "<<lsaKey<<" Seq No: "<<endl;
596 std::pair<AdjLsa& , bool> chkAdjLsa=getAdjLsa(lsaKey);
597 if( chkAdjLsa.second )
598 {
599 cout<<" LSA Exists with seq no: "<<chkAdjLsa.first.getLsSeqNo()<<endl;
600 if ( chkAdjLsa.first.getLsSeqNo() == seqNo )
601 {
602 if(chkAdjLsa.first.getOrigRouter() == thisRouterPrefix )
603 {
604 cout<<"Own Adj LSA, so refreshing Adj LSA"<<endl;
605 chkAdjLsa.first.setLsSeqNo(chkAdjLsa.first.getLsSeqNo()+1);
606 pnlsr.getSm().setAdjLsaSeq(chkAdjLsa.first.getLsSeqNo());
607 // publish routing update
608 }
609 else
610 {
611 cout<<"Other's Adj LSA, so removing form LSDB"<<endl;
612 removeAdjLsa(pnlsr, lsaKey);
613 }
614
615 // schedule Routing table calculaiton
616 pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
617 }
618 }
619}
620
621void
622Lsdb::exprireOrRefreshCorLsa(nlsr& pnlsr, string lsaKey, int seqNo)
623{
624 cout<<"Lsdb::exprireOrRefreshCorLsa Called "<<endl;
625 cout<<"LSA Key : "<<lsaKey<<" Seq No: "<<endl;
626 std::pair<CorLsa& , bool> chkCorLsa=getCorLsa(lsaKey);
627 if( chkCorLsa.second )
628 {
629 cout<<" LSA Exists with seq no: "<<chkCorLsa.first.getLsSeqNo()<<endl;
630 if ( chkCorLsa.first.getLsSeqNo() == seqNo )
631 {
632 if(chkCorLsa.first.getOrigRouter() == thisRouterPrefix )
633 {
634 cout<<"Own Cor LSA, so refreshing Cor LSA"<<endl;
635 chkCorLsa.first.setLsSeqNo(chkCorLsa.first.getLsSeqNo()+1);
636 pnlsr.getSm().setCorLsaSeq(chkCorLsa.first.getLsSeqNo());
637 // publish routing update
638 }
639 else
640 {
641 cout<<"Other's Cor LSA, so removing form LSDB"<<endl;
642 removeCorLsa(pnlsr, lsaKey);
643 }
644
645 if (pnlsr.getConfParameter().getIsHyperbolicCalc() >=1 )
646 {
647 pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
648 }
649 }
650 }
651}
652
653
654void
655Lsdb::printAdjLsdb()
656{
657 cout<<"---------------Adj LSDB-------------------"<<endl;
658 for( std::list<AdjLsa>::iterator it=adjLsdb.begin();
659 it!= adjLsdb.end() ; it++)
660 {
661 cout<< (*it) <<endl;
662 }
663}
664
665//-----utility function -----
666bool
667Lsdb::doesLsaExist(string key, int lsType)
668{
669 if ( lsType == 1)
670 {
671 return doesNameLsaExist(key);
672 }
673 else if ( lsType == 2)
674 {
675 return doesAdjLsaExist(key);
676 }
677 else if ( lsType == 3)
678 {
679 return doesCorLsaExist(key);
680 }
681
682 return false;
683}
684
685