blob: 40a7de090192693292a61cb8dec8bd387fbfee32 [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
Yingdi Yu40cd1c32014-04-17 15:02:17 -070029 inline static void
30 NullDeleter(boost::asio::io_service* variable)
31 {
32 // do nothing
33 }
34
akmhoque5a44dd42014-03-12 18:11:32 -050035 class Nlsr
36 {
37 public:
38 Nlsr()
Yingdi Yu40cd1c32014-04-17 15:02:17 -070039 : m_io(new boost::asio::io_service)
40 , m_nlsrFace(new Face(shared_ptr<boost::asio::io_service>(&*m_io, &NullDeleter)))
akmhoque05d5fcf2014-04-15 14:58:45 -050041 , m_scheduler(*m_io)
42 , m_confParam()
43 , m_adl()
44 , m_npl()
45 , m_im()
46 , m_dm()
47 , m_sm()
48 , m_km()
akmhoque5a44dd42014-03-12 18:11:32 -050049 , isDaemonProcess(false)
akmhoque05d5fcf2014-04-15 14:58:45 -050050 , m_configFileName("nlsr.conf")
51 , m_nlsrLsdb()
52 , m_adjBuildCount(0)
akmhoque5a44dd42014-03-12 18:11:32 -050053 , isBuildAdjLsaSheduled(0)
54 , isRouteCalculationScheduled(0)
55 , isRoutingTableCalculating(0)
akmhoque05d5fcf2014-04-15 14:58:45 -050056 , m_routingTable()
57 , m_npt()
58 , m_fib()
59 , m_slh(m_io)
60 , m_nlsrLogger()
akmhoque5a44dd42014-03-12 18:11:32 -050061 {}
62
63 void nlsrRegistrationFailed(const ndn::Name& name);
64
65 void setInterestFilterNlsr(const string& name);
66 void startEventLoop();
67
68 int usage(const string& progname);
69
70 string getConfFileName()
akmhoque1fd8c1e2014-02-19 19:41:49 -060071 {
akmhoque05d5fcf2014-04-15 14:58:45 -050072 return m_configFileName;
akmhoque5a44dd42014-03-12 18:11:32 -050073 }
akmhoque298385a2014-02-13 14:13:09 -060074
akmhoque5a44dd42014-03-12 18:11:32 -050075 void setConfFileName(const string& fileName)
76 {
akmhoque05d5fcf2014-04-15 14:58:45 -050077 m_configFileName=fileName;
akmhoque5a44dd42014-03-12 18:11:32 -050078 }
akmhoque298385a2014-02-13 14:13:09 -060079
akmhoque05d5fcf2014-04-15 14:58:45 -050080 bool getIsSetDaemonProcess()
akmhoque5a44dd42014-03-12 18:11:32 -050081 {
82 return isDaemonProcess;
83 }
akmhoque298385a2014-02-13 14:13:09 -060084
akmhoque5a44dd42014-03-12 18:11:32 -050085 void setIsDaemonProcess(bool value)
86 {
87 isDaemonProcess=value;
88 }
akmhoque298385a2014-02-13 14:13:09 -060089
akmhoque5a44dd42014-03-12 18:11:32 -050090 ConfParameter& getConfParameter()
91 {
akmhoque05d5fcf2014-04-15 14:58:45 -050092 return m_confParam;
akmhoque5a44dd42014-03-12 18:11:32 -050093 }
akmhoque298385a2014-02-13 14:13:09 -060094
akmhoque5a44dd42014-03-12 18:11:32 -050095 Adl& getAdl()
96 {
akmhoque05d5fcf2014-04-15 14:58:45 -050097 return m_adl;
akmhoque5a44dd42014-03-12 18:11:32 -050098 }
akmhoque298385a2014-02-13 14:13:09 -060099
akmhoque5a44dd42014-03-12 18:11:32 -0500100 Npl& getNpl()
101 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500102 return m_npl;
akmhoque5a44dd42014-03-12 18:11:32 -0500103 }
akmhoque298385a2014-02-13 14:13:09 -0600104
akmhoque5a44dd42014-03-12 18:11:32 -0500105 ndn::shared_ptr<boost::asio::io_service>& getIo()
106 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500107 return m_io;
akmhoque5a44dd42014-03-12 18:11:32 -0500108 }
akmhoque298385a2014-02-13 14:13:09 -0600109
akmhoque5a44dd42014-03-12 18:11:32 -0500110 ndn::Scheduler& getScheduler()
111 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500112 return m_scheduler;
akmhoque5a44dd42014-03-12 18:11:32 -0500113 }
akmhoque298385a2014-02-13 14:13:09 -0600114
akmhoque5a44dd42014-03-12 18:11:32 -0500115 ndn::shared_ptr<ndn::Face> getNlsrFace()
116 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500117 return m_nlsrFace;
akmhoque5a44dd42014-03-12 18:11:32 -0500118 }
akmhoque298385a2014-02-13 14:13:09 -0600119
akmhoque5a44dd42014-03-12 18:11:32 -0500120 KeyManager& getKeyManager()
121 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500122 return m_km;
akmhoque5a44dd42014-03-12 18:11:32 -0500123 }
akmhoque298385a2014-02-13 14:13:09 -0600124
akmhoque66e66182014-02-21 17:56:03 -0600125
akmhoque05d5fcf2014-04-15 14:58:45 -0500126 InterestManager& getIm()
akmhoque5a44dd42014-03-12 18:11:32 -0500127 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500128 return m_im;
akmhoque5a44dd42014-03-12 18:11:32 -0500129 }
akmhoque298385a2014-02-13 14:13:09 -0600130
akmhoque5a44dd42014-03-12 18:11:32 -0500131 DataManager& getDm()
132 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500133 return m_dm;
akmhoque5a44dd42014-03-12 18:11:32 -0500134 }
akmhoque298385a2014-02-13 14:13:09 -0600135
akmhoque5a44dd42014-03-12 18:11:32 -0500136 SequencingManager& getSm()
137 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500138 return m_sm;
akmhoque5a44dd42014-03-12 18:11:32 -0500139 }
akmhoque298385a2014-02-13 14:13:09 -0600140
akmhoque5a44dd42014-03-12 18:11:32 -0500141 Lsdb& getLsdb()
142 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500143 return m_nlsrLsdb;
akmhoque5a44dd42014-03-12 18:11:32 -0500144 }
akmhoque298385a2014-02-13 14:13:09 -0600145
akmhoque5a44dd42014-03-12 18:11:32 -0500146 RoutingTable& getRoutingTable()
147 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500148 return m_routingTable;
akmhoque5a44dd42014-03-12 18:11:32 -0500149 }
akmhoque298385a2014-02-13 14:13:09 -0600150
akmhoque5a44dd42014-03-12 18:11:32 -0500151 Npt& getNpt()
152 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500153 return m_npt;
akmhoque5a44dd42014-03-12 18:11:32 -0500154 }
akmhoque298385a2014-02-13 14:13:09 -0600155
akmhoque5a44dd42014-03-12 18:11:32 -0500156 Fib& getFib()
157 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500158 return m_fib;
akmhoque5a44dd42014-03-12 18:11:32 -0500159 }
akmhoque298385a2014-02-13 14:13:09 -0600160
akmhoque5a44dd42014-03-12 18:11:32 -0500161 long int getAdjBuildCount()
162 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500163 return m_adjBuildCount;
akmhoque5a44dd42014-03-12 18:11:32 -0500164 }
akmhoque298385a2014-02-13 14:13:09 -0600165
akmhoque5a44dd42014-03-12 18:11:32 -0500166 void incrementAdjBuildCount()
167 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500168 m_adjBuildCount++;
akmhoque5a44dd42014-03-12 18:11:32 -0500169 }
akmhoque298385a2014-02-13 14:13:09 -0600170
akmhoque5a44dd42014-03-12 18:11:32 -0500171 void setAdjBuildCount(long int abc)
172 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500173 m_adjBuildCount=abc;
akmhoque5a44dd42014-03-12 18:11:32 -0500174 }
akmhoque298385a2014-02-13 14:13:09 -0600175
akmhoque5a44dd42014-03-12 18:11:32 -0500176 int getIsBuildAdjLsaSheduled()
177 {
178 return isBuildAdjLsaSheduled;
179 }
akmhoque298385a2014-02-13 14:13:09 -0600180
akmhoque05d5fcf2014-04-15 14:58:45 -0500181 void setIsBuildAdjLsaSheduled(bool iabls)
akmhoque5a44dd42014-03-12 18:11:32 -0500182 {
183 isBuildAdjLsaSheduled=iabls;
184 }
akmhoque298385a2014-02-13 14:13:09 -0600185
akmhoque298385a2014-02-13 14:13:09 -0600186
akmhoque5a44dd42014-03-12 18:11:32 -0500187 void setApiPort(int ap)
188 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500189 m_apiPort=ap;
akmhoque5a44dd42014-03-12 18:11:32 -0500190 }
akmhoque298385a2014-02-13 14:13:09 -0600191
akmhoque5a44dd42014-03-12 18:11:32 -0500192 int getApiPort()
193 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500194 return m_apiPort;
akmhoque5a44dd42014-03-12 18:11:32 -0500195 }
akmhoque298385a2014-02-13 14:13:09 -0600196
akmhoque05d5fcf2014-04-15 14:58:45 -0500197 bool getIsRoutingTableCalculating()
akmhoque5a44dd42014-03-12 18:11:32 -0500198 {
199 return isRoutingTableCalculating;
200 }
akmhoque85d88332014-02-17 21:11:21 -0600201
akmhoque05d5fcf2014-04-15 14:58:45 -0500202 void setIsRoutingTableCalculating(bool irtc)
akmhoque5a44dd42014-03-12 18:11:32 -0500203 {
204 isRoutingTableCalculating=irtc;
205 }
akmhoque298385a2014-02-13 14:13:09 -0600206
akmhoque05d5fcf2014-04-15 14:58:45 -0500207 bool getIsRouteCalculationScheduled()
akmhoque5a44dd42014-03-12 18:11:32 -0500208 {
209 return isRouteCalculationScheduled;
210 }
akmhoque298385a2014-02-13 14:13:09 -0600211
akmhoque05d5fcf2014-04-15 14:58:45 -0500212 void setIsRouteCalculationScheduled(bool ircs)
akmhoque5a44dd42014-03-12 18:11:32 -0500213 {
214 isRouteCalculationScheduled=ircs;
215 }
akmhoque298385a2014-02-13 14:13:09 -0600216
akmhoque5a44dd42014-03-12 18:11:32 -0500217 SyncLogicHandler& getSlh()
218 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500219 return m_slh;
akmhoque5a44dd42014-03-12 18:11:32 -0500220 }
akmhoque2bb198e2014-02-28 11:46:27 -0600221
akmhoque5a44dd42014-03-12 18:11:32 -0500222 NlsrLogger& getNlsrLogger()
223 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500224 return m_nlsrLogger;
akmhoque5a44dd42014-03-12 18:11:32 -0500225 }
akmhoque1fd8c1e2014-02-19 19:41:49 -0600226
akmhoque05d5fcf2014-04-15 14:58:45 -0500227 void initialize();
akmhoque2bb198e2014-02-28 11:46:27 -0600228
akmhoque5a44dd42014-03-12 18:11:32 -0500229 private:
akmhoque05d5fcf2014-04-15 14:58:45 -0500230 ConfParameter m_confParam;
231 Adl m_adl;
232 Npl m_npl;
233 ndn::shared_ptr<boost::asio::io_service> m_io;
234 ndn::Scheduler m_scheduler;
235 ndn::shared_ptr<ndn::Face> m_nlsrFace;
236 InterestManager m_im;
237 DataManager m_dm;
238 SequencingManager m_sm;
239 KeyManager m_km;
akmhoque5a44dd42014-03-12 18:11:32 -0500240 bool isDaemonProcess;
akmhoque05d5fcf2014-04-15 14:58:45 -0500241 string m_configFileName;
242 int m_apiPort;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600243
akmhoque05d5fcf2014-04-15 14:58:45 -0500244 Lsdb m_nlsrLsdb;
245 RoutingTable m_routingTable;
246 Npt m_npt;
247 Fib m_fib;
248 SyncLogicHandler m_slh;
249 NlsrLogger m_nlsrLogger;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600250
akmhoque05d5fcf2014-04-15 14:58:45 -0500251 long int m_adjBuildCount;
252 bool isBuildAdjLsaSheduled;
253 bool isRouteCalculationScheduled;
254 bool isRoutingTableCalculating;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600255
akmhoque1fd8c1e2014-02-19 19:41:49 -0600256
257
akmhoque5a44dd42014-03-12 18:11:32 -0500258 };
akmhoque298385a2014-02-13 14:13:09 -0600259
akmhoqueb1710aa2014-02-19 17:13:36 -0600260} //namespace nlsr
261
akmhoque298385a2014-02-13 14:13:09 -0600262#endif