blob: 96f0ff165e77c0b22852bd0720d0d6f473e647ef [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
26 std::pair<NameLsa&, bool>
27 getNameLsa(std::string key);
28
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
43 buildAndInstallOwnCorLsa(Nlsr& pnlsr);
44
45 std::pair<CorLsa&, bool>
46 getCorLsa(std::string key);
47
48 bool
49 installCorLsa(Nlsr& pnlsr, CorLsa& clsa);
50
51 bool
52 removeCorLsa(Nlsr& pnlsr, std::string& key);
53
54 bool
55 isCorLsaNew(std::string key, uint64_t seqNo);
56
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
75 std::pair<AdjLsa&, bool>
76 getAdjLsa(std::string key);
77
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
100 addCorLsa(CorLsa& clsa);
101
102 bool
103 doesCorLsaExist(std::string key);
104
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
124 scheduleCorLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime);
125
126 void
127 exprireOrRefreshCorLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo);
128
129
130private:
131 void
132 cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, ndn::EventId eid);
133
134 std::list<NameLsa> m_nameLsdb;
135 std::list<AdjLsa> m_adjLsdb;
136 std::list<CorLsa> m_corLsdb;
137
138 int m_lsaRefreshTime;
139 std::string m_thisRouterPrefix;
140
141};
142
143}//namespace nlsr
144
145#endif //NLSR_LSDB_HPP