blob: 24b489dbaa4c2fe835ef045fda84482d8082cf0d [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
akmhoqueb1710aa2014-02-19 17:13:36 -06007namespace nlsr {
8
akmhoque298385a2014-02-13 14:13:09 -06009using namespace std;
10
akmhoque1a481092014-02-19 16:34:22 -060011class Nlsr;
akmhoque298385a2014-02-13 14:13:09 -060012
13class Lsdb{
14public:
15 Lsdb()
16 : lsaRefreshTime(0)
17 {
18 }
19
20
21 bool doesLsaExist(string key, int lsType);
22 // function related to Name LSDB
akmhoque1a481092014-02-19 16:34:22 -060023 bool buildAndInstallOwnNameLsa(Nlsr& pnlsr);
akmhoque298385a2014-02-13 14:13:09 -060024 std::pair<NameLsa&, bool> getNameLsa(string key);
akmhoque1a481092014-02-19 16:34:22 -060025 bool installNameLsa(Nlsr& pnlsr, NameLsa &nlsa);
26 bool removeNameLsa(Nlsr& pnlsr, string& key);
akmhoque298385a2014-02-13 14:13:09 -060027 void printNameLsdb(); //debugging
28
29 //function related to Cor LSDB
akmhoque1a481092014-02-19 16:34:22 -060030 bool buildAndInstallOwnCorLsa(Nlsr& pnlsr);
akmhoque298385a2014-02-13 14:13:09 -060031 std::pair<CorLsa&, bool> getCorLsa(string key);
akmhoque1a481092014-02-19 16:34:22 -060032 bool installCorLsa(Nlsr& pnlsr, CorLsa &clsa);
33 bool removeCorLsa(Nlsr& pnlsr, string& key);
akmhoque298385a2014-02-13 14:13:09 -060034 void printCorLsdb(); //debugging
35
36 //function related to Adj LSDB
akmhoque1a481092014-02-19 16:34:22 -060037 void scheduledAdjLsaBuild(Nlsr& pnlsr);
38 bool buildAndInstallOwnAdjLsa(Nlsr& pnlsr);
39 bool removeAdjLsa(Nlsr& pnlsr, string& key);
40 bool installAdjLsa(Nlsr& pnlsr, AdjLsa &alsa);
akmhoque298385a2014-02-13 14:13:09 -060041 std::pair<AdjLsa& , bool> getAdjLsa(string key);
42 std::list<AdjLsa>& getAdjLsdb();
43 void printAdjLsdb();
44
akmhoque1a481092014-02-19 16:34:22 -060045 //void scheduleRefreshLsdb(Nlsr& pnlsr, int interval);
akmhoque298385a2014-02-13 14:13:09 -060046 void setLsaRefreshTime(int lrt);
47 void setThisRouterPrefix(string trp);
48
49private:
50 bool addNameLsa(NameLsa &nlsa);
51 bool doesNameLsaExist(string key);
52
53
54 bool addCorLsa(CorLsa& clsa);
55 bool doesCorLsaExist(string key);
56
57 bool addAdjLsa(AdjLsa &alsa);
58 bool doesAdjLsaExist(string key);
akmhoque85d88332014-02-17 21:11:21 -060059
60 ndn::EventId
akmhoque1a481092014-02-19 16:34:22 -060061 scheduleNameLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
62 void exprireOrRefreshNameLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
akmhoque85d88332014-02-17 21:11:21 -060063 ndn::EventId
akmhoque1a481092014-02-19 16:34:22 -060064 scheduleAdjLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
65 void exprireOrRefreshAdjLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
akmhoque85d88332014-02-17 21:11:21 -060066 ndn::EventId
akmhoque1a481092014-02-19 16:34:22 -060067 scheduleCorLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
68 void exprireOrRefreshCorLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
akmhoque298385a2014-02-13 14:13:09 -060069
70
71private:
akmhoque1a481092014-02-19 16:34:22 -060072 void cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, EventId eid);
akmhoque85d88332014-02-17 21:11:21 -060073
akmhoque298385a2014-02-13 14:13:09 -060074 std::list<NameLsa> nameLsdb;
75 std::list<AdjLsa> adjLsdb;
76 std::list<CorLsa> corLsdb;
77
78 int lsaRefreshTime;
79 string thisRouterPrefix;
80
81};
82
akmhoqueb1710aa2014-02-19 17:13:36 -060083}//namespace nlsr
84
akmhoque298385a2014-02-13 14:13:09 -060085#endif