blob: 51218f0664f8f201301d51790b6bc588a54188e7 [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
akmhoque298385a2014-02-13 14:13:09 -060023
akmhoque1fd8c1e2014-02-19 19:41:49 -060024namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -060025{
akmhoque298385a2014-02-13 14:13:09 -060026
akmhoque1fd8c1e2014-02-19 19:41:49 -060027 using namespace ndn;
28 using namespace std;
akmhoque298385a2014-02-13 14:13:09 -060029
akmhoque1fd8c1e2014-02-19 19:41:49 -060030 class Nlsr
31 {
32 public:
33 Nlsr()
34 : io(ndn::make_shared<boost::asio::io_service>())
akmhoque2bb198e2014-02-28 11:46:27 -060035 , nlsrFace(make_shared<ndn::Face>(io))
akmhoque1fd8c1e2014-02-19 19:41:49 -060036 , scheduler(*io)
akmhoque1fd8c1e2014-02-19 19:41:49 -060037 , confParam()
38 , adl()
39 , npl()
40 , im()
41 , dm()
42 , sm()
akmhoque66e66182014-02-21 17:56:03 -060043 , km()
akmhoque2bb198e2014-02-28 11:46:27 -060044 , isDaemonProcess(false)
45 , configFileName("nlsr.conf")
akmhoque1fd8c1e2014-02-19 19:41:49 -060046 , nlsrLsdb()
47 , adjBuildCount(0)
48 , isBuildAdjLsaSheduled(0)
49 , isRouteCalculationScheduled(0)
50 , isRoutingTableCalculating(0)
51 , routingTable()
52 , npt()
53 , fib()
akmhoque2bb198e2014-02-28 11:46:27 -060054 , slh(io)
akmhoque1fd8c1e2014-02-19 19:41:49 -060055 , nlsrLogger()
akmhoque2bb198e2014-02-28 11:46:27 -060056 {}
akmhoque298385a2014-02-13 14:13:09 -060057
akmhoque1fd8c1e2014-02-19 19:41:49 -060058 void nlsrRegistrationFailed(const ndn::Name& name);
akmhoque298385a2014-02-13 14:13:09 -060059
akmhoque1fd8c1e2014-02-19 19:41:49 -060060 void setInterestFilterNlsr(const string& name);
61 void startEventLoop();
akmhoque298385a2014-02-13 14:13:09 -060062
akmhoque1fd8c1e2014-02-19 19:41:49 -060063 int usage(const string& progname);
akmhoque298385a2014-02-13 14:13:09 -060064
akmhoque1fd8c1e2014-02-19 19:41:49 -060065 string getConfFileName()
66 {
67 return configFileName;
68 }
akmhoque298385a2014-02-13 14:13:09 -060069
akmhoque1fd8c1e2014-02-19 19:41:49 -060070 void setConfFileName(const string& fileName)
71 {
72 configFileName=fileName;
73 }
akmhoque298385a2014-02-13 14:13:09 -060074
akmhoque1fd8c1e2014-02-19 19:41:49 -060075 bool isSetDaemonProcess()
76 {
77 return isDaemonProcess;
78 }
akmhoque298385a2014-02-13 14:13:09 -060079
akmhoque1fd8c1e2014-02-19 19:41:49 -060080 void setIsDaemonProcess(bool value)
81 {
82 isDaemonProcess=value;
83 }
akmhoque298385a2014-02-13 14:13:09 -060084
akmhoque1fd8c1e2014-02-19 19:41:49 -060085 ConfParameter& getConfParameter()
86 {
87 return confParam;
88 }
akmhoque298385a2014-02-13 14:13:09 -060089
akmhoque1fd8c1e2014-02-19 19:41:49 -060090 Adl& getAdl()
91 {
92 return adl;
93 }
akmhoque298385a2014-02-13 14:13:09 -060094
akmhoque1fd8c1e2014-02-19 19:41:49 -060095 Npl& getNpl()
96 {
97 return npl;
98 }
akmhoque298385a2014-02-13 14:13:09 -060099
akmhoque1fd8c1e2014-02-19 19:41:49 -0600100 ndn::shared_ptr<boost::asio::io_service>& getIo()
101 {
102 return io;
103 }
akmhoque298385a2014-02-13 14:13:09 -0600104
akmhoque1fd8c1e2014-02-19 19:41:49 -0600105 ndn::Scheduler& getScheduler()
106 {
107 return scheduler;
108 }
akmhoque298385a2014-02-13 14:13:09 -0600109
akmhoque2bb198e2014-02-28 11:46:27 -0600110 ndn::shared_ptr<ndn::Face> getNlsrFace()
akmhoque1fd8c1e2014-02-19 19:41:49 -0600111 {
112 return nlsrFace;
113 }
akmhoque298385a2014-02-13 14:13:09 -0600114
akmhoque66e66182014-02-21 17:56:03 -0600115 KeyManager& getKeyManager()
akmhoque1fd8c1e2014-02-19 19:41:49 -0600116 {
akmhoque2bb198e2014-02-28 11:46:27 -0600117 return km;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600118 }
akmhoque298385a2014-02-13 14:13:09 -0600119
akmhoque66e66182014-02-21 17:56:03 -0600120
akmhoque1fd8c1e2014-02-19 19:41:49 -0600121 interestManager& getIm()
122 {
123 return im;
124 }
akmhoque298385a2014-02-13 14:13:09 -0600125
akmhoque1fd8c1e2014-02-19 19:41:49 -0600126 DataManager& getDm()
127 {
128 return dm;
129 }
akmhoque298385a2014-02-13 14:13:09 -0600130
akmhoque1fd8c1e2014-02-19 19:41:49 -0600131 SequencingManager& getSm()
132 {
133 return sm;
134 }
akmhoque298385a2014-02-13 14:13:09 -0600135
akmhoque1fd8c1e2014-02-19 19:41:49 -0600136 Lsdb& getLsdb()
137 {
138 return nlsrLsdb;
139 }
akmhoque298385a2014-02-13 14:13:09 -0600140
akmhoque1fd8c1e2014-02-19 19:41:49 -0600141 RoutingTable& getRoutingTable()
142 {
143 return routingTable;
144 }
akmhoque298385a2014-02-13 14:13:09 -0600145
akmhoque1fd8c1e2014-02-19 19:41:49 -0600146 Npt& getNpt()
147 {
148 return npt;
149 }
akmhoque298385a2014-02-13 14:13:09 -0600150
akmhoque1fd8c1e2014-02-19 19:41:49 -0600151 Fib& getFib()
152 {
153 return fib;
154 }
akmhoque298385a2014-02-13 14:13:09 -0600155
akmhoque1fd8c1e2014-02-19 19:41:49 -0600156 long int getAdjBuildCount()
157 {
158 return adjBuildCount;
159 }
akmhoque298385a2014-02-13 14:13:09 -0600160
akmhoque1fd8c1e2014-02-19 19:41:49 -0600161 void incrementAdjBuildCount()
162 {
163 adjBuildCount++;
164 }
akmhoque298385a2014-02-13 14:13:09 -0600165
akmhoque1fd8c1e2014-02-19 19:41:49 -0600166 void setAdjBuildCount(long int abc)
167 {
168 adjBuildCount=abc;
169 }
akmhoque298385a2014-02-13 14:13:09 -0600170
akmhoque1fd8c1e2014-02-19 19:41:49 -0600171 int getIsBuildAdjLsaSheduled()
172 {
173 return isBuildAdjLsaSheduled;
174 }
akmhoque298385a2014-02-13 14:13:09 -0600175
akmhoque1fd8c1e2014-02-19 19:41:49 -0600176 void setIsBuildAdjLsaSheduled(int iabls)
177 {
178 isBuildAdjLsaSheduled=iabls;
179 }
akmhoque298385a2014-02-13 14:13:09 -0600180
akmhoque298385a2014-02-13 14:13:09 -0600181
akmhoque1fd8c1e2014-02-19 19:41:49 -0600182 void setApiPort(int ap)
183 {
184 apiPort=ap;
185 }
akmhoque298385a2014-02-13 14:13:09 -0600186
akmhoque1fd8c1e2014-02-19 19:41:49 -0600187 int getApiPort()
188 {
189 return apiPort;
190 }
akmhoque298385a2014-02-13 14:13:09 -0600191
akmhoque1fd8c1e2014-02-19 19:41:49 -0600192 int getIsRoutingTableCalculating()
193 {
194 return isRoutingTableCalculating;
195 }
akmhoque85d88332014-02-17 21:11:21 -0600196
akmhoque1fd8c1e2014-02-19 19:41:49 -0600197 void setIsRoutingTableCalculating(int irtc)
198 {
199 isRoutingTableCalculating=irtc;
200 }
akmhoque298385a2014-02-13 14:13:09 -0600201
akmhoque1fd8c1e2014-02-19 19:41:49 -0600202 int getIsRouteCalculationScheduled()
203 {
204 return isRouteCalculationScheduled;
205 }
akmhoque298385a2014-02-13 14:13:09 -0600206
akmhoque1fd8c1e2014-02-19 19:41:49 -0600207 void setIsRouteCalculationScheduled(int ircs)
208 {
209 isRouteCalculationScheduled=ircs;
210 }
akmhoque298385a2014-02-13 14:13:09 -0600211
akmhoque2bb198e2014-02-28 11:46:27 -0600212 SyncLogicHandler& getSlh()
213 {
214 return slh;
215 }
216
akmhoque1fd8c1e2014-02-19 19:41:49 -0600217 NlsrLogger& getNlsrLogger()
218 {
219 return nlsrLogger;
220 }
221
akmhoque2bb198e2014-02-28 11:46:27 -0600222 void initNlsr();
223
akmhoque1fd8c1e2014-02-19 19:41:49 -0600224 private:
225 ConfParameter confParam;
226 Adl adl;
227 Npl npl;
228 ndn::shared_ptr<boost::asio::io_service> io;
229 ndn::Scheduler scheduler;
akmhoque2bb198e2014-02-28 11:46:27 -0600230 ndn::shared_ptr<ndn::Face> nlsrFace;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600231 interestManager im;
232 DataManager dm;
233 SequencingManager sm;
akmhoque66e66182014-02-21 17:56:03 -0600234 KeyManager km;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600235 bool isDaemonProcess;
236 string configFileName;
237 int apiPort;
238
239 Lsdb nlsrLsdb;
240 RoutingTable routingTable;
241 Npt npt;
242 Fib fib;
akmhoque2bb198e2014-02-28 11:46:27 -0600243 SyncLogicHandler slh;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600244 NlsrLogger nlsrLogger;
245
246 long int adjBuildCount;
247 int isBuildAdjLsaSheduled;
248 int isRouteCalculationScheduled;
249 int isRoutingTableCalculating;
250
akmhoque1fd8c1e2014-02-19 19:41:49 -0600251
252
253 };
akmhoque298385a2014-02-13 14:13:09 -0600254
akmhoqueb1710aa2014-02-19 17:13:36 -0600255} //namespace nlsr
256
akmhoque298385a2014-02-13 14:13:09 -0600257#endif