blob: bef818911ec66cbd063fb9628d733c246d3e3f0d [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#ifndef NLSR_HPP
2#define NLSR_HPP
3
4#include <ndn-cpp-dev/face.hpp>
5#include <ndn-cpp-dev/security/key-chain.hpp>
6#include <ndn-cpp-dev/util/scheduler.hpp>
7
akmhoque53353462014-04-22 08:43:45 -05008#include "conf-parameter.hpp"
9#include "adl.hpp"
10#include "npl.hpp"
11#include "communication/interest-manager.hpp"
12#include "communication/data-manager.hpp"
13#include "lsdb.hpp"
14#include "sequencing-manager.hpp"
15#include "route/routing-table.hpp"
16#include "route/npt.hpp"
17#include "route/fib.hpp"
18#include "security/key-manager.hpp"
19#include "communication/sync-logic-handler.hpp"
akmhoque2bb198e2014-02-28 11:46:27 -060020
21
akmhoque53353462014-04-22 08:43:45 -050022namespace nlsr {
23
24inline static void
25NullDeleter(boost::asio::io_service* variable)
akmhoque298385a2014-02-13 14:13:09 -060026{
akmhoque53353462014-04-22 08:43:45 -050027 // do nothing
28}
akmhoque298385a2014-02-13 14:13:09 -060029
akmhoque53353462014-04-22 08:43:45 -050030class Nlsr
31{
32public:
33 Nlsr()
34 : m_io(new boost::asio::io_service)
35 , m_nlsrFace(new Face(ndn::shared_ptr<boost::asio::io_service>(&*m_io,
36 &NullDeleter)))
37 , m_scheduler(*m_io)
38 , m_confParam()
39 , m_adl()
40 , m_npl()
41 , m_im()
42 , m_dm()
43 , m_sm()
44 , m_km()
45 , m_isDaemonProcess(false)
46 , m_configFileName("nlsr.conf")
47 , m_nlsrLsdb()
48 , m_adjBuildCount(0)
49 , m_isBuildAdjLsaSheduled(false)
50 , m_isRouteCalculationScheduled(false)
51 , m_isRoutingTableCalculating(false)
52 , m_routingTable()
53 , m_npt()
54 , m_fib()
55 , m_slh(m_io)
56 {}
akmhoque298385a2014-02-13 14:13:09 -060057
akmhoque53353462014-04-22 08:43:45 -050058 void
59 registrationFailed(const ndn::Name& name);
60
61 void
62 setInterestFilterNlsr(const string& name);
63
64 void
65 startEventLoop();
66
67 int
68 usage(const string& progname);
69
70 std::string
71 getConfFileName()
Yingdi Yu40cd1c32014-04-17 15:02:17 -070072 {
akmhoque53353462014-04-22 08:43:45 -050073 return m_configFileName;
Yingdi Yu40cd1c32014-04-17 15:02:17 -070074 }
75
akmhoque53353462014-04-22 08:43:45 -050076 void
77 setConfFileName(const string& fileName)
akmhoque5a44dd42014-03-12 18:11:32 -050078 {
akmhoque53353462014-04-22 08:43:45 -050079 m_configFileName = fileName;
80 }
akmhoque5a44dd42014-03-12 18:11:32 -050081
akmhoque53353462014-04-22 08:43:45 -050082 bool
83 getIsSetDaemonProcess()
84 {
85 return m_isDaemonProcess;
86 }
akmhoque5a44dd42014-03-12 18:11:32 -050087
akmhoque53353462014-04-22 08:43:45 -050088 void
89 setIsDaemonProcess(bool value)
90 {
91 m_isDaemonProcess = value;
92 }
akmhoque5a44dd42014-03-12 18:11:32 -050093
akmhoque53353462014-04-22 08:43:45 -050094 ConfParameter&
95 getConfParameter()
96 {
97 return m_confParam;
98 }
akmhoque5a44dd42014-03-12 18:11:32 -050099
akmhoque53353462014-04-22 08:43:45 -0500100 Adl&
101 getAdl()
102 {
103 return m_adl;
104 }
akmhoque298385a2014-02-13 14:13:09 -0600105
akmhoque53353462014-04-22 08:43:45 -0500106 Npl&
107 getNpl()
108 {
109 return m_npl;
110 }
akmhoque298385a2014-02-13 14:13:09 -0600111
akmhoque53353462014-04-22 08:43:45 -0500112 ndn::shared_ptr<boost::asio::io_service>&
113 getIo()
114 {
115 return m_io;
116 }
akmhoque298385a2014-02-13 14:13:09 -0600117
akmhoque53353462014-04-22 08:43:45 -0500118 ndn::Scheduler&
119 getScheduler()
120 {
121 return m_scheduler;
122 }
akmhoque298385a2014-02-13 14:13:09 -0600123
akmhoque53353462014-04-22 08:43:45 -0500124 ndn::shared_ptr<ndn::Face>
125 getNlsrFace()
126 {
127 return m_nlsrFace;
128 }
akmhoque298385a2014-02-13 14:13:09 -0600129
akmhoque53353462014-04-22 08:43:45 -0500130 KeyManager&
131 getKeyManager()
132 {
133 return m_km;
134 }
akmhoque298385a2014-02-13 14:13:09 -0600135
akmhoque66e66182014-02-21 17:56:03 -0600136
akmhoque53353462014-04-22 08:43:45 -0500137 InterestManager&
138 getIm()
139 {
140 return m_im;
141 }
akmhoque298385a2014-02-13 14:13:09 -0600142
akmhoque53353462014-04-22 08:43:45 -0500143 DataManager&
144 getDm()
145 {
146 return m_dm;
147 }
akmhoque298385a2014-02-13 14:13:09 -0600148
akmhoque53353462014-04-22 08:43:45 -0500149 SequencingManager&
150 getSm()
151 {
152 return m_sm;
153 }
akmhoque298385a2014-02-13 14:13:09 -0600154
akmhoque53353462014-04-22 08:43:45 -0500155 Lsdb&
156 getLsdb()
157 {
158 return m_nlsrLsdb;
159 }
akmhoque298385a2014-02-13 14:13:09 -0600160
akmhoque53353462014-04-22 08:43:45 -0500161 RoutingTable&
162 getRoutingTable()
163 {
164 return m_routingTable;
165 }
akmhoque298385a2014-02-13 14:13:09 -0600166
akmhoque53353462014-04-22 08:43:45 -0500167 Npt&
168 getNpt()
169 {
170 return m_npt;
171 }
akmhoque298385a2014-02-13 14:13:09 -0600172
akmhoque53353462014-04-22 08:43:45 -0500173 Fib&
174 getFib()
175 {
176 return m_fib;
177 }
akmhoque298385a2014-02-13 14:13:09 -0600178
akmhoque53353462014-04-22 08:43:45 -0500179 long int
180 getAdjBuildCount()
181 {
182 return m_adjBuildCount;
183 }
akmhoque298385a2014-02-13 14:13:09 -0600184
akmhoque53353462014-04-22 08:43:45 -0500185 void
186 incrementAdjBuildCount()
187 {
188 m_adjBuildCount++;
189 }
akmhoque298385a2014-02-13 14:13:09 -0600190
akmhoque53353462014-04-22 08:43:45 -0500191 void
192 setAdjBuildCount(long int abc)
193 {
194 m_adjBuildCount = abc;
195 }
akmhoque298385a2014-02-13 14:13:09 -0600196
akmhoque53353462014-04-22 08:43:45 -0500197 int
198 getIsBuildAdjLsaSheduled()
199 {
200 return m_isBuildAdjLsaSheduled;
201 }
akmhoque298385a2014-02-13 14:13:09 -0600202
akmhoque53353462014-04-22 08:43:45 -0500203 void
204 setIsBuildAdjLsaSheduled(bool iabls)
205 {
206 m_isBuildAdjLsaSheduled = iabls;
207 }
akmhoque298385a2014-02-13 14:13:09 -0600208
akmhoque298385a2014-02-13 14:13:09 -0600209
akmhoque53353462014-04-22 08:43:45 -0500210 void
211 setApiPort(int ap)
212 {
213 m_apiPort = ap;
214 }
akmhoque298385a2014-02-13 14:13:09 -0600215
akmhoque53353462014-04-22 08:43:45 -0500216 int
217 getApiPort()
218 {
219 return m_apiPort;
220 }
akmhoque298385a2014-02-13 14:13:09 -0600221
akmhoque53353462014-04-22 08:43:45 -0500222 bool
223 getIsRoutingTableCalculating()
224 {
225 return m_isRoutingTableCalculating;
226 }
akmhoque85d88332014-02-17 21:11:21 -0600227
akmhoque53353462014-04-22 08:43:45 -0500228 void
229 setIsRoutingTableCalculating(bool irtc)
230 {
231 m_isRoutingTableCalculating = irtc;
232 }
akmhoque298385a2014-02-13 14:13:09 -0600233
akmhoque53353462014-04-22 08:43:45 -0500234 bool
235 getIsRouteCalculationScheduled()
236 {
237 return m_isRouteCalculationScheduled;
238 }
akmhoque298385a2014-02-13 14:13:09 -0600239
akmhoque53353462014-04-22 08:43:45 -0500240 void
241 setIsRouteCalculationScheduled(bool ircs)
242 {
243 m_isRouteCalculationScheduled = ircs;
244 }
akmhoque298385a2014-02-13 14:13:09 -0600245
akmhoque53353462014-04-22 08:43:45 -0500246 SyncLogicHandler&
247 getSlh()
248 {
249 return m_slh;
250 }
akmhoque2bb198e2014-02-28 11:46:27 -0600251
akmhoque53353462014-04-22 08:43:45 -0500252 void
253 initialize();
akmhoque1fd8c1e2014-02-19 19:41:49 -0600254
akmhoque53353462014-04-22 08:43:45 -0500255private:
256 ndn::shared_ptr<boost::asio::io_service> m_io;
257 ndn::shared_ptr<ndn::Face> m_nlsrFace;
258 ndn::Scheduler m_scheduler;
259 ConfParameter m_confParam;
260 Adl m_adl;
261 Npl m_npl;
262 InterestManager m_im;
263 DataManager m_dm;
264 SequencingManager m_sm;
265 KeyManager m_km;
266 bool m_isDaemonProcess;
267 string m_configFileName;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600268
akmhoque1fd8c1e2014-02-19 19:41:49 -0600269
akmhoque53353462014-04-22 08:43:45 -0500270 Lsdb m_nlsrLsdb;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600271
akmhoque53353462014-04-22 08:43:45 -0500272
273 long int m_adjBuildCount;
274 bool m_isBuildAdjLsaSheduled;
275 bool m_isRouteCalculationScheduled;
276 bool m_isRoutingTableCalculating;
277
278 RoutingTable m_routingTable;
279 Npt m_npt;
280 Fib m_fib;
281 SyncLogicHandler m_slh;
282
283 int m_apiPort;
284
285
286};
akmhoque298385a2014-02-13 14:13:09 -0600287
akmhoqueb1710aa2014-02-19 17:13:36 -0600288} //namespace nlsr
289
akmhoque53353462014-04-22 08:43:45 -0500290#endif //NLSR_HPP