blob: 93b2f10465e0bda79ebe68e7da53b397fee12395 [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#ifndef NLSR_LSDB_HPP
2#define NLSR_LSDB_HPP
3
4#include <utility>
5#include "nlsr_lsa.hpp"
6
akmhoque1fd8c1e2014-02-19 19:41:49 -06007namespace nlsr
8{
akmhoqueb1710aa2014-02-19 17:13:36 -06009
akmhoque1fd8c1e2014-02-19 19:41:49 -060010 using namespace std;
akmhoque298385a2014-02-13 14:13:09 -060011
akmhoque1fd8c1e2014-02-19 19:41:49 -060012 class Nlsr;
akmhoque298385a2014-02-13 14:13:09 -060013
akmhoque1fd8c1e2014-02-19 19:41:49 -060014 class Lsdb
15 {
16 public:
17 Lsdb()
18 : lsaRefreshTime(0)
19 {
20 }
akmhoque298385a2014-02-13 14:13:09 -060021
akmhoque298385a2014-02-13 14:13:09 -060022
akmhoque1fd8c1e2014-02-19 19:41:49 -060023 bool doesLsaExist(string key, int lsType);
24 // function related to Name LSDB
25 bool buildAndInstallOwnNameLsa(Nlsr& pnlsr);
26 std::pair<NameLsa&, bool> getNameLsa(string key);
27 bool installNameLsa(Nlsr& pnlsr, NameLsa &nlsa);
28 bool removeNameLsa(Nlsr& pnlsr, string& key);
29 void printNameLsdb(); //debugging
akmhoque298385a2014-02-13 14:13:09 -060030
akmhoque1fd8c1e2014-02-19 19:41:49 -060031 //function related to Cor LSDB
32 bool buildAndInstallOwnCorLsa(Nlsr& pnlsr);
33 std::pair<CorLsa&, bool> getCorLsa(string key);
34 bool installCorLsa(Nlsr& pnlsr, CorLsa &clsa);
35 bool removeCorLsa(Nlsr& pnlsr, string& key);
36 void printCorLsdb(); //debugging
akmhoque298385a2014-02-13 14:13:09 -060037
akmhoque1fd8c1e2014-02-19 19:41:49 -060038 //function related to Adj LSDB
39 void scheduledAdjLsaBuild(Nlsr& pnlsr);
40 bool buildAndInstallOwnAdjLsa(Nlsr& pnlsr);
41 bool removeAdjLsa(Nlsr& pnlsr, string& key);
42 bool installAdjLsa(Nlsr& pnlsr, AdjLsa &alsa);
43 std::pair<AdjLsa& , bool> getAdjLsa(string key);
44 std::list<AdjLsa>& getAdjLsdb();
45 void printAdjLsdb();
akmhoque298385a2014-02-13 14:13:09 -060046
akmhoque1fd8c1e2014-02-19 19:41:49 -060047 //void scheduleRefreshLsdb(Nlsr& pnlsr, int interval);
48 void setLsaRefreshTime(int lrt);
49 void setThisRouterPrefix(string trp);
akmhoque85d88332014-02-17 21:11:21 -060050
akmhoque1fd8c1e2014-02-19 19:41:49 -060051 private:
52 bool addNameLsa(NameLsa &nlsa);
53 bool doesNameLsaExist(string key);
akmhoque298385a2014-02-13 14:13:09 -060054
akmhoque85d88332014-02-17 21:11:21 -060055
akmhoque1fd8c1e2014-02-19 19:41:49 -060056 bool addCorLsa(CorLsa& clsa);
57 bool doesCorLsaExist(string key);
akmhoque298385a2014-02-13 14:13:09 -060058
akmhoque1fd8c1e2014-02-19 19:41:49 -060059 bool addAdjLsa(AdjLsa &alsa);
60 bool doesAdjLsaExist(string key);
akmhoque298385a2014-02-13 14:13:09 -060061
akmhoque1fd8c1e2014-02-19 19:41:49 -060062 ndn::EventId
63 scheduleNameLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
64 void exprireOrRefreshNameLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
65 ndn::EventId
66 scheduleAdjLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
67 void exprireOrRefreshAdjLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
68 ndn::EventId
69 scheduleCorLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
70 void exprireOrRefreshCorLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
71
72
73 private:
74 void cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, EventId eid);
75
76 std::list<NameLsa> nameLsdb;
77 std::list<AdjLsa> adjLsdb;
78 std::list<CorLsa> corLsdb;
79
80 int lsaRefreshTime;
81 string thisRouterPrefix;
82
83 };
akmhoque298385a2014-02-13 14:13:09 -060084
akmhoqueb1710aa2014-02-19 17:13:36 -060085}//namespace nlsr
86
akmhoque298385a2014-02-13 14:13:09 -060087#endif