blob: 98140344fe0c1712669336ff425d806ed6fd95f5 [file] [log] [blame]
akmhoque53353462014-04-22 08:43:45 -05001#ifndef NLSR_LSDB_HPP
2#define NLSR_LSDB_HPP
3
4#include <utility>
5#include "lsa.hpp"
6
7namespace nlsr {
8class Nlsr;
9
10class Lsdb
11{
12public:
13 Lsdb()
14 : m_lsaRefreshTime(0)
15 {
16 }
17
18
19 bool
20 doesLsaExist(std::string key, int lsType);
21 // function related to Name LSDB
22
23 bool
24 buildAndInstallOwnNameLsa(Nlsr& pnlsr);
25
akmhoqueb6450b12014-04-24 00:01:03 -050026 NameLsa*
27 findNameLsa(const std::string key);
akmhoque53353462014-04-22 08:43:45 -050028
29 bool
30 installNameLsa(Nlsr& pnlsr, NameLsa& nlsa);
31
32 bool
33 removeNameLsa(Nlsr& pnlsr, std::string& key);
34
35 bool
36 isNameLsaNew(std::string key, uint64_t seqNo);
37
38 void
39 printNameLsdb(); //debugging
40
41 //function related to Cor LSDB
42 bool
akmhoqueb6450b12014-04-24 00:01:03 -050043 buildAndInstallOwnCoordinateLsa(Nlsr& pnlsr);
akmhoque53353462014-04-22 08:43:45 -050044
akmhoqueb6450b12014-04-24 00:01:03 -050045 CoordinateLsa*
46 findCoordinateLsa(const std::string& key);
akmhoque53353462014-04-22 08:43:45 -050047
48 bool
akmhoqueb6450b12014-04-24 00:01:03 -050049 installCoordinateLsa(Nlsr& pnlsr, CoordinateLsa& clsa);
akmhoque53353462014-04-22 08:43:45 -050050
51 bool
akmhoqueb6450b12014-04-24 00:01:03 -050052 removeCoordinateLsa(Nlsr& pnlsr, const std::string& key);
akmhoque53353462014-04-22 08:43:45 -050053
54 bool
akmhoqueb6450b12014-04-24 00:01:03 -050055 isCoordinateLsaNew(const std::string& key, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050056
57 void
58 printCorLsdb(); //debugging
59
60 //function related to Adj LSDB
61 void
62 scheduledAdjLsaBuild(Nlsr& pnlsr);
63
64 bool
65 buildAndInstallOwnAdjLsa(Nlsr& pnlsr);
66
67 bool
68 removeAdjLsa(Nlsr& pnlsr, std::string& key);
69
70 bool
71 isAdjLsaNew(std::string key, uint64_t seqNo);
72 bool
73 installAdjLsa(Nlsr& pnlsr, AdjLsa& alsa);
74
akmhoqueb6450b12014-04-24 00:01:03 -050075 AdjLsa*
76 findAdjLsa(std::string key);
akmhoque53353462014-04-22 08:43:45 -050077
78 std::list<AdjLsa>&
79 getAdjLsdb();
80
81 void
82 printAdjLsdb();
83
84 //void scheduleRefreshLsdb(Nlsr& pnlsr, int interval);
85 void
86 setLsaRefreshTime(int lrt);
87
88 void
89 setThisRouterPrefix(std::string trp);
90
91private:
92 bool
93 addNameLsa(NameLsa& nlsa);
94
95 bool
96 doesNameLsaExist(std::string key);
97
98
99 bool
akmhoqueb6450b12014-04-24 00:01:03 -0500100 addCoordinateLsa(CoordinateLsa& clsa);
akmhoque53353462014-04-22 08:43:45 -0500101
102 bool
akmhoqueb6450b12014-04-24 00:01:03 -0500103 doesCoordinateLsaExist(const std::string& key);
akmhoque53353462014-04-22 08:43:45 -0500104
105 bool
106 addAdjLsa(AdjLsa& alsa);
107
108 bool
109 doesAdjLsaExist(std::string key);
110
111 ndn::EventId
112 scheduleNameLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime);
113
114 void
115 exprireOrRefreshNameLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo);
116
117 ndn::EventId
118 scheduleAdjLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime);
119
120 void
121 exprireOrRefreshAdjLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo);
122
123 ndn::EventId
akmhoqueb6450b12014-04-24 00:01:03 -0500124 scheduleCoordinateLsaExpiration(Nlsr& pnlsr, const std::string& key, int seqNo,
125 int expTime);
akmhoque53353462014-04-22 08:43:45 -0500126
127 void
akmhoqueb6450b12014-04-24 00:01:03 -0500128 exprireOrRefreshCoordinateLsa(Nlsr& pnlsr, const std::string& lsaKey,
129 uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500130
131
132private:
133 void
134 cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, ndn::EventId eid);
135
136 std::list<NameLsa> m_nameLsdb;
137 std::list<AdjLsa> m_adjLsdb;
akmhoqueb6450b12014-04-24 00:01:03 -0500138 std::list<CoordinateLsa> m_corLsdb;
akmhoque53353462014-04-22 08:43:45 -0500139
140 int m_lsaRefreshTime;
141 std::string m_thisRouterPrefix;
142
143};
144
145}//namespace nlsr
146
147#endif //NLSR_LSDB_HPP