blob: 9a580f35975cf7b67ca03d465209c47a93fefded [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
8#include "nlsr_conf_param.hpp"
9#include "nlsr_adl.hpp"
10#include "nlsr_npl.hpp"
akmhoque2bb198e2014-02-28 11:46:27 -060011#include "communication/nlsr_im.hpp"
12#include "communication/nlsr_dm.hpp"
akmhoque298385a2014-02-13 14:13:09 -060013#include "nlsr_lsdb.hpp"
14#include "nlsr_sm.hpp"
akmhoque2bb198e2014-02-28 11:46:27 -060015#include "route/nlsr_rt.hpp"
16#include "route/nlsr_npt.hpp"
17#include "route/nlsr_fib.hpp"
18#include "utility/nlsr_logger.hpp"
19#include "security/nlsr_km.hpp"
20#include "communication/nlsr_slh.hpp"
21
22
akmhoque1fd8c1e2014-02-19 19:41:49 -060023namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -060024{
akmhoque298385a2014-02-13 14:13:09 -060025
akmhoque5a44dd42014-03-12 18:11:32 -050026 using namespace ndn;
27 using namespace std;
akmhoque298385a2014-02-13 14:13:09 -060028
akmhoque5a44dd42014-03-12 18:11:32 -050029 class Nlsr
30 {
31 public:
32 Nlsr()
33 : io(ndn::make_shared<boost::asio::io_service>())
34 , nlsrFace(make_shared<ndn::Face>(io))
35 , scheduler(*io)
36 , confParam()
37 , adl()
38 , npl()
39 , im()
40 , dm()
41 , sm()
42 , km()
43 , isDaemonProcess(false)
44 , configFileName("nlsr.conf")
45 , nlsrLsdb()
46 , adjBuildCount(0)
47 , isBuildAdjLsaSheduled(0)
48 , isRouteCalculationScheduled(0)
49 , isRoutingTableCalculating(0)
50 , routingTable()
51 , npt()
52 , fib()
53 , slh(io)
54 , nlsrLogger()
55 {}
56
57 void nlsrRegistrationFailed(const ndn::Name& name);
58
59 void setInterestFilterNlsr(const string& name);
60 void startEventLoop();
61
62 int usage(const string& progname);
63
64 string getConfFileName()
akmhoque1fd8c1e2014-02-19 19:41:49 -060065 {
akmhoque5a44dd42014-03-12 18:11:32 -050066 return configFileName;
67 }
akmhoque298385a2014-02-13 14:13:09 -060068
akmhoque5a44dd42014-03-12 18:11:32 -050069 void setConfFileName(const string& fileName)
70 {
71 configFileName=fileName;
72 }
akmhoque298385a2014-02-13 14:13:09 -060073
akmhoque5a44dd42014-03-12 18:11:32 -050074 bool isSetDaemonProcess()
75 {
76 return isDaemonProcess;
77 }
akmhoque298385a2014-02-13 14:13:09 -060078
akmhoque5a44dd42014-03-12 18:11:32 -050079 void setIsDaemonProcess(bool value)
80 {
81 isDaemonProcess=value;
82 }
akmhoque298385a2014-02-13 14:13:09 -060083
akmhoque5a44dd42014-03-12 18:11:32 -050084 ConfParameter& getConfParameter()
85 {
86 return confParam;
87 }
akmhoque298385a2014-02-13 14:13:09 -060088
akmhoque5a44dd42014-03-12 18:11:32 -050089 Adl& getAdl()
90 {
91 return adl;
92 }
akmhoque298385a2014-02-13 14:13:09 -060093
akmhoque5a44dd42014-03-12 18:11:32 -050094 Npl& getNpl()
95 {
96 return npl;
97 }
akmhoque298385a2014-02-13 14:13:09 -060098
akmhoque5a44dd42014-03-12 18:11:32 -050099 ndn::shared_ptr<boost::asio::io_service>& getIo()
100 {
101 return io;
102 }
akmhoque298385a2014-02-13 14:13:09 -0600103
akmhoque5a44dd42014-03-12 18:11:32 -0500104 ndn::Scheduler& getScheduler()
105 {
106 return scheduler;
107 }
akmhoque298385a2014-02-13 14:13:09 -0600108
akmhoque5a44dd42014-03-12 18:11:32 -0500109 ndn::shared_ptr<ndn::Face> getNlsrFace()
110 {
111 return nlsrFace;
112 }
akmhoque298385a2014-02-13 14:13:09 -0600113
akmhoque5a44dd42014-03-12 18:11:32 -0500114 KeyManager& getKeyManager()
115 {
116 return km;
117 }
akmhoque298385a2014-02-13 14:13:09 -0600118
akmhoque66e66182014-02-21 17:56:03 -0600119
akmhoque5a44dd42014-03-12 18:11:32 -0500120 interestManager& getIm()
121 {
122 return im;
123 }
akmhoque298385a2014-02-13 14:13:09 -0600124
akmhoque5a44dd42014-03-12 18:11:32 -0500125 DataManager& getDm()
126 {
127 return dm;
128 }
akmhoque298385a2014-02-13 14:13:09 -0600129
akmhoque5a44dd42014-03-12 18:11:32 -0500130 SequencingManager& getSm()
131 {
132 return sm;
133 }
akmhoque298385a2014-02-13 14:13:09 -0600134
akmhoque5a44dd42014-03-12 18:11:32 -0500135 Lsdb& getLsdb()
136 {
137 return nlsrLsdb;
138 }
akmhoque298385a2014-02-13 14:13:09 -0600139
akmhoque5a44dd42014-03-12 18:11:32 -0500140 RoutingTable& getRoutingTable()
141 {
142 return routingTable;
143 }
akmhoque298385a2014-02-13 14:13:09 -0600144
akmhoque5a44dd42014-03-12 18:11:32 -0500145 Npt& getNpt()
146 {
147 return npt;
148 }
akmhoque298385a2014-02-13 14:13:09 -0600149
akmhoque5a44dd42014-03-12 18:11:32 -0500150 Fib& getFib()
151 {
152 return fib;
153 }
akmhoque298385a2014-02-13 14:13:09 -0600154
akmhoque5a44dd42014-03-12 18:11:32 -0500155 long int getAdjBuildCount()
156 {
157 return adjBuildCount;
158 }
akmhoque298385a2014-02-13 14:13:09 -0600159
akmhoque5a44dd42014-03-12 18:11:32 -0500160 void incrementAdjBuildCount()
161 {
162 adjBuildCount++;
163 }
akmhoque298385a2014-02-13 14:13:09 -0600164
akmhoque5a44dd42014-03-12 18:11:32 -0500165 void setAdjBuildCount(long int abc)
166 {
167 adjBuildCount=abc;
168 }
akmhoque298385a2014-02-13 14:13:09 -0600169
akmhoque5a44dd42014-03-12 18:11:32 -0500170 int getIsBuildAdjLsaSheduled()
171 {
172 return isBuildAdjLsaSheduled;
173 }
akmhoque298385a2014-02-13 14:13:09 -0600174
akmhoque5a44dd42014-03-12 18:11:32 -0500175 void setIsBuildAdjLsaSheduled(int iabls)
176 {
177 isBuildAdjLsaSheduled=iabls;
178 }
akmhoque298385a2014-02-13 14:13:09 -0600179
akmhoque298385a2014-02-13 14:13:09 -0600180
akmhoque5a44dd42014-03-12 18:11:32 -0500181 void setApiPort(int ap)
182 {
183 apiPort=ap;
184 }
akmhoque298385a2014-02-13 14:13:09 -0600185
akmhoque5a44dd42014-03-12 18:11:32 -0500186 int getApiPort()
187 {
188 return apiPort;
189 }
akmhoque298385a2014-02-13 14:13:09 -0600190
akmhoque5a44dd42014-03-12 18:11:32 -0500191 int getIsRoutingTableCalculating()
192 {
193 return isRoutingTableCalculating;
194 }
akmhoque85d88332014-02-17 21:11:21 -0600195
akmhoque5a44dd42014-03-12 18:11:32 -0500196 void setIsRoutingTableCalculating(int irtc)
197 {
198 isRoutingTableCalculating=irtc;
199 }
akmhoque298385a2014-02-13 14:13:09 -0600200
akmhoque5a44dd42014-03-12 18:11:32 -0500201 int getIsRouteCalculationScheduled()
202 {
203 return isRouteCalculationScheduled;
204 }
akmhoque298385a2014-02-13 14:13:09 -0600205
akmhoque5a44dd42014-03-12 18:11:32 -0500206 void setIsRouteCalculationScheduled(int ircs)
207 {
208 isRouteCalculationScheduled=ircs;
209 }
akmhoque298385a2014-02-13 14:13:09 -0600210
akmhoque5a44dd42014-03-12 18:11:32 -0500211 SyncLogicHandler& getSlh()
212 {
213 return slh;
214 }
akmhoque2bb198e2014-02-28 11:46:27 -0600215
akmhoque5a44dd42014-03-12 18:11:32 -0500216 NlsrLogger& getNlsrLogger()
217 {
218 return nlsrLogger;
219 }
akmhoque1fd8c1e2014-02-19 19:41:49 -0600220
akmhoque5a44dd42014-03-12 18:11:32 -0500221 void initNlsr();
akmhoque2bb198e2014-02-28 11:46:27 -0600222
akmhoque5a44dd42014-03-12 18:11:32 -0500223 private:
224 ConfParameter confParam;
225 Adl adl;
226 Npl npl;
227 ndn::shared_ptr<boost::asio::io_service> io;
228 ndn::Scheduler scheduler;
229 ndn::shared_ptr<ndn::Face> nlsrFace;
230 interestManager im;
231 DataManager dm;
232 SequencingManager sm;
233 KeyManager km;
234 bool isDaemonProcess;
235 string configFileName;
236 int apiPort;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600237
akmhoque5a44dd42014-03-12 18:11:32 -0500238 Lsdb nlsrLsdb;
239 RoutingTable routingTable;
240 Npt npt;
241 Fib fib;
242 SyncLogicHandler slh;
243 NlsrLogger nlsrLogger;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600244
akmhoque5a44dd42014-03-12 18:11:32 -0500245 long int adjBuildCount;
246 int isBuildAdjLsaSheduled;
247 int isRouteCalculationScheduled;
248 int isRoutingTableCalculating;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600249
akmhoque1fd8c1e2014-02-19 19:41:49 -0600250
251
akmhoque5a44dd42014-03-12 18:11:32 -0500252 };
akmhoque298385a2014-02-13 14:13:09 -0600253
akmhoqueb1710aa2014-02-19 17:13:36 -0600254} //namespace nlsr
255
akmhoque298385a2014-02-13 14:13:09 -0600256#endif