blob: 9e8c20776a0528fc7ef38610d81094dbefc88826 [file] [log] [blame]
akmhoque53353462014-04-22 08:43:45 -05001#ifndef NLSR_LSDB_HPP
2#define NLSR_LSDB_HPP
3
4#include <utility>
akmhoquefdbddb12014-05-02 18:35:19 -05005#include <boost/cstdint.hpp>
6
akmhoque53353462014-04-22 08:43:45 -05007#include "lsa.hpp"
8
9namespace nlsr {
10class Nlsr;
11
12class Lsdb
13{
14public:
15 Lsdb()
16 : m_lsaRefreshTime(0)
17 {
18 }
19
20
21 bool
22 doesLsaExist(std::string key, int lsType);
23 // function related to Name LSDB
24
25 bool
26 buildAndInstallOwnNameLsa(Nlsr& pnlsr);
27
akmhoqueb6450b12014-04-24 00:01:03 -050028 NameLsa*
29 findNameLsa(const std::string key);
akmhoque53353462014-04-22 08:43:45 -050030
31 bool
32 installNameLsa(Nlsr& pnlsr, NameLsa& nlsa);
33
34 bool
35 removeNameLsa(Nlsr& pnlsr, std::string& key);
36
37 bool
38 isNameLsaNew(std::string key, uint64_t seqNo);
39
40 void
41 printNameLsdb(); //debugging
42
43 //function related to Cor LSDB
44 bool
akmhoqueb6450b12014-04-24 00:01:03 -050045 buildAndInstallOwnCoordinateLsa(Nlsr& pnlsr);
akmhoque53353462014-04-22 08:43:45 -050046
akmhoqueb6450b12014-04-24 00:01:03 -050047 CoordinateLsa*
48 findCoordinateLsa(const std::string& key);
akmhoque53353462014-04-22 08:43:45 -050049
50 bool
akmhoqueb6450b12014-04-24 00:01:03 -050051 installCoordinateLsa(Nlsr& pnlsr, CoordinateLsa& clsa);
akmhoque53353462014-04-22 08:43:45 -050052
53 bool
akmhoqueb6450b12014-04-24 00:01:03 -050054 removeCoordinateLsa(Nlsr& pnlsr, const std::string& key);
akmhoque53353462014-04-22 08:43:45 -050055
56 bool
akmhoqueb6450b12014-04-24 00:01:03 -050057 isCoordinateLsaNew(const std::string& key, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050058
59 void
60 printCorLsdb(); //debugging
61
62 //function related to Adj LSDB
63 void
64 scheduledAdjLsaBuild(Nlsr& pnlsr);
65
66 bool
67 buildAndInstallOwnAdjLsa(Nlsr& pnlsr);
68
69 bool
70 removeAdjLsa(Nlsr& pnlsr, std::string& key);
71
72 bool
73 isAdjLsaNew(std::string key, uint64_t seqNo);
74 bool
75 installAdjLsa(Nlsr& pnlsr, AdjLsa& alsa);
76
akmhoqueb6450b12014-04-24 00:01:03 -050077 AdjLsa*
78 findAdjLsa(std::string key);
akmhoque53353462014-04-22 08:43:45 -050079
80 std::list<AdjLsa>&
81 getAdjLsdb();
82
83 void
84 printAdjLsdb();
85
86 //void scheduleRefreshLsdb(Nlsr& pnlsr, int interval);
87 void
88 setLsaRefreshTime(int lrt);
89
90 void
91 setThisRouterPrefix(std::string trp);
92
93private:
94 bool
95 addNameLsa(NameLsa& nlsa);
96
97 bool
98 doesNameLsaExist(std::string key);
99
100
101 bool
akmhoqueb6450b12014-04-24 00:01:03 -0500102 addCoordinateLsa(CoordinateLsa& clsa);
akmhoque53353462014-04-22 08:43:45 -0500103
104 bool
akmhoqueb6450b12014-04-24 00:01:03 -0500105 doesCoordinateLsaExist(const std::string& key);
akmhoque53353462014-04-22 08:43:45 -0500106
107 bool
108 addAdjLsa(AdjLsa& alsa);
109
110 bool
111 doesAdjLsaExist(std::string key);
112
113 ndn::EventId
114 scheduleNameLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime);
115
116 void
117 exprireOrRefreshNameLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo);
118
119 ndn::EventId
120 scheduleAdjLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime);
121
122 void
123 exprireOrRefreshAdjLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo);
124
125 ndn::EventId
akmhoqueb6450b12014-04-24 00:01:03 -0500126 scheduleCoordinateLsaExpiration(Nlsr& pnlsr, const std::string& key, int seqNo,
127 int expTime);
akmhoque53353462014-04-22 08:43:45 -0500128
129 void
akmhoqueb6450b12014-04-24 00:01:03 -0500130 exprireOrRefreshCoordinateLsa(Nlsr& pnlsr, const std::string& lsaKey,
131 uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500132
133
134private:
135 void
136 cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, ndn::EventId eid);
137
138 std::list<NameLsa> m_nameLsdb;
139 std::list<AdjLsa> m_adjLsdb;
akmhoqueb6450b12014-04-24 00:01:03 -0500140 std::list<CoordinateLsa> m_corLsdb;
akmhoque53353462014-04-22 08:43:45 -0500141
142 int m_lsaRefreshTime;
143 std::string m_thisRouterPrefix;
144
145};
146
147}//namespace nlsr
148
149#endif //NLSR_LSDB_HPP