blob: 0c406aca0b92693316ef832212421ada93190381 [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()
akmhoque05d5fcf2014-04-15 14:58:45 -050033 : m_io(ndn::make_shared<boost::asio::io_service>())
34 , m_nlsrFace(make_shared<ndn::Face>(m_io))
35 , m_scheduler(*m_io)
36 , m_confParam()
37 , m_adl()
38 , m_npl()
39 , m_im()
40 , m_dm()
41 , m_sm()
42 , m_km()
akmhoque5a44dd42014-03-12 18:11:32 -050043 , isDaemonProcess(false)
akmhoque05d5fcf2014-04-15 14:58:45 -050044 , m_configFileName("nlsr.conf")
45 , m_nlsrLsdb()
46 , m_adjBuildCount(0)
akmhoque5a44dd42014-03-12 18:11:32 -050047 , isBuildAdjLsaSheduled(0)
48 , isRouteCalculationScheduled(0)
49 , isRoutingTableCalculating(0)
akmhoque05d5fcf2014-04-15 14:58:45 -050050 , m_routingTable()
51 , m_npt()
52 , m_fib()
53 , m_slh(m_io)
54 , m_nlsrLogger()
akmhoque5a44dd42014-03-12 18:11:32 -050055 {}
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 {
akmhoque05d5fcf2014-04-15 14:58:45 -050066 return m_configFileName;
akmhoque5a44dd42014-03-12 18:11:32 -050067 }
akmhoque298385a2014-02-13 14:13:09 -060068
akmhoque5a44dd42014-03-12 18:11:32 -050069 void setConfFileName(const string& fileName)
70 {
akmhoque05d5fcf2014-04-15 14:58:45 -050071 m_configFileName=fileName;
akmhoque5a44dd42014-03-12 18:11:32 -050072 }
akmhoque298385a2014-02-13 14:13:09 -060073
akmhoque05d5fcf2014-04-15 14:58:45 -050074 bool getIsSetDaemonProcess()
akmhoque5a44dd42014-03-12 18:11:32 -050075 {
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 {
akmhoque05d5fcf2014-04-15 14:58:45 -050086 return m_confParam;
akmhoque5a44dd42014-03-12 18:11:32 -050087 }
akmhoque298385a2014-02-13 14:13:09 -060088
akmhoque5a44dd42014-03-12 18:11:32 -050089 Adl& getAdl()
90 {
akmhoque05d5fcf2014-04-15 14:58:45 -050091 return m_adl;
akmhoque5a44dd42014-03-12 18:11:32 -050092 }
akmhoque298385a2014-02-13 14:13:09 -060093
akmhoque5a44dd42014-03-12 18:11:32 -050094 Npl& getNpl()
95 {
akmhoque05d5fcf2014-04-15 14:58:45 -050096 return m_npl;
akmhoque5a44dd42014-03-12 18:11:32 -050097 }
akmhoque298385a2014-02-13 14:13:09 -060098
akmhoque5a44dd42014-03-12 18:11:32 -050099 ndn::shared_ptr<boost::asio::io_service>& getIo()
100 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500101 return m_io;
akmhoque5a44dd42014-03-12 18:11:32 -0500102 }
akmhoque298385a2014-02-13 14:13:09 -0600103
akmhoque5a44dd42014-03-12 18:11:32 -0500104 ndn::Scheduler& getScheduler()
105 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500106 return m_scheduler;
akmhoque5a44dd42014-03-12 18:11:32 -0500107 }
akmhoque298385a2014-02-13 14:13:09 -0600108
akmhoque5a44dd42014-03-12 18:11:32 -0500109 ndn::shared_ptr<ndn::Face> getNlsrFace()
110 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500111 return m_nlsrFace;
akmhoque5a44dd42014-03-12 18:11:32 -0500112 }
akmhoque298385a2014-02-13 14:13:09 -0600113
akmhoque5a44dd42014-03-12 18:11:32 -0500114 KeyManager& getKeyManager()
115 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500116 return m_km;
akmhoque5a44dd42014-03-12 18:11:32 -0500117 }
akmhoque298385a2014-02-13 14:13:09 -0600118
akmhoque66e66182014-02-21 17:56:03 -0600119
akmhoque05d5fcf2014-04-15 14:58:45 -0500120 InterestManager& getIm()
akmhoque5a44dd42014-03-12 18:11:32 -0500121 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500122 return m_im;
akmhoque5a44dd42014-03-12 18:11:32 -0500123 }
akmhoque298385a2014-02-13 14:13:09 -0600124
akmhoque5a44dd42014-03-12 18:11:32 -0500125 DataManager& getDm()
126 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500127 return m_dm;
akmhoque5a44dd42014-03-12 18:11:32 -0500128 }
akmhoque298385a2014-02-13 14:13:09 -0600129
akmhoque5a44dd42014-03-12 18:11:32 -0500130 SequencingManager& getSm()
131 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500132 return m_sm;
akmhoque5a44dd42014-03-12 18:11:32 -0500133 }
akmhoque298385a2014-02-13 14:13:09 -0600134
akmhoque5a44dd42014-03-12 18:11:32 -0500135 Lsdb& getLsdb()
136 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500137 return m_nlsrLsdb;
akmhoque5a44dd42014-03-12 18:11:32 -0500138 }
akmhoque298385a2014-02-13 14:13:09 -0600139
akmhoque5a44dd42014-03-12 18:11:32 -0500140 RoutingTable& getRoutingTable()
141 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500142 return m_routingTable;
akmhoque5a44dd42014-03-12 18:11:32 -0500143 }
akmhoque298385a2014-02-13 14:13:09 -0600144
akmhoque5a44dd42014-03-12 18:11:32 -0500145 Npt& getNpt()
146 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500147 return m_npt;
akmhoque5a44dd42014-03-12 18:11:32 -0500148 }
akmhoque298385a2014-02-13 14:13:09 -0600149
akmhoque5a44dd42014-03-12 18:11:32 -0500150 Fib& getFib()
151 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500152 return m_fib;
akmhoque5a44dd42014-03-12 18:11:32 -0500153 }
akmhoque298385a2014-02-13 14:13:09 -0600154
akmhoque5a44dd42014-03-12 18:11:32 -0500155 long int getAdjBuildCount()
156 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500157 return m_adjBuildCount;
akmhoque5a44dd42014-03-12 18:11:32 -0500158 }
akmhoque298385a2014-02-13 14:13:09 -0600159
akmhoque5a44dd42014-03-12 18:11:32 -0500160 void incrementAdjBuildCount()
161 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500162 m_adjBuildCount++;
akmhoque5a44dd42014-03-12 18:11:32 -0500163 }
akmhoque298385a2014-02-13 14:13:09 -0600164
akmhoque5a44dd42014-03-12 18:11:32 -0500165 void setAdjBuildCount(long int abc)
166 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500167 m_adjBuildCount=abc;
akmhoque5a44dd42014-03-12 18:11:32 -0500168 }
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
akmhoque05d5fcf2014-04-15 14:58:45 -0500175 void setIsBuildAdjLsaSheduled(bool iabls)
akmhoque5a44dd42014-03-12 18:11:32 -0500176 {
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 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500183 m_apiPort=ap;
akmhoque5a44dd42014-03-12 18:11:32 -0500184 }
akmhoque298385a2014-02-13 14:13:09 -0600185
akmhoque5a44dd42014-03-12 18:11:32 -0500186 int getApiPort()
187 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500188 return m_apiPort;
akmhoque5a44dd42014-03-12 18:11:32 -0500189 }
akmhoque298385a2014-02-13 14:13:09 -0600190
akmhoque05d5fcf2014-04-15 14:58:45 -0500191 bool getIsRoutingTableCalculating()
akmhoque5a44dd42014-03-12 18:11:32 -0500192 {
193 return isRoutingTableCalculating;
194 }
akmhoque85d88332014-02-17 21:11:21 -0600195
akmhoque05d5fcf2014-04-15 14:58:45 -0500196 void setIsRoutingTableCalculating(bool irtc)
akmhoque5a44dd42014-03-12 18:11:32 -0500197 {
198 isRoutingTableCalculating=irtc;
199 }
akmhoque298385a2014-02-13 14:13:09 -0600200
akmhoque05d5fcf2014-04-15 14:58:45 -0500201 bool getIsRouteCalculationScheduled()
akmhoque5a44dd42014-03-12 18:11:32 -0500202 {
203 return isRouteCalculationScheduled;
204 }
akmhoque298385a2014-02-13 14:13:09 -0600205
akmhoque05d5fcf2014-04-15 14:58:45 -0500206 void setIsRouteCalculationScheduled(bool ircs)
akmhoque5a44dd42014-03-12 18:11:32 -0500207 {
208 isRouteCalculationScheduled=ircs;
209 }
akmhoque298385a2014-02-13 14:13:09 -0600210
akmhoque5a44dd42014-03-12 18:11:32 -0500211 SyncLogicHandler& getSlh()
212 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500213 return m_slh;
akmhoque5a44dd42014-03-12 18:11:32 -0500214 }
akmhoque2bb198e2014-02-28 11:46:27 -0600215
akmhoque5a44dd42014-03-12 18:11:32 -0500216 NlsrLogger& getNlsrLogger()
217 {
akmhoque05d5fcf2014-04-15 14:58:45 -0500218 return m_nlsrLogger;
akmhoque5a44dd42014-03-12 18:11:32 -0500219 }
akmhoque1fd8c1e2014-02-19 19:41:49 -0600220
akmhoque05d5fcf2014-04-15 14:58:45 -0500221 void initialize();
akmhoque2bb198e2014-02-28 11:46:27 -0600222
akmhoque5a44dd42014-03-12 18:11:32 -0500223 private:
akmhoque05d5fcf2014-04-15 14:58:45 -0500224 ConfParameter m_confParam;
225 Adl m_adl;
226 Npl m_npl;
227 ndn::shared_ptr<boost::asio::io_service> m_io;
228 ndn::Scheduler m_scheduler;
229 ndn::shared_ptr<ndn::Face> m_nlsrFace;
230 InterestManager m_im;
231 DataManager m_dm;
232 SequencingManager m_sm;
233 KeyManager m_km;
akmhoque5a44dd42014-03-12 18:11:32 -0500234 bool isDaemonProcess;
akmhoque05d5fcf2014-04-15 14:58:45 -0500235 string m_configFileName;
236 int m_apiPort;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600237
akmhoque05d5fcf2014-04-15 14:58:45 -0500238 Lsdb m_nlsrLsdb;
239 RoutingTable m_routingTable;
240 Npt m_npt;
241 Fib m_fib;
242 SyncLogicHandler m_slh;
243 NlsrLogger m_nlsrLogger;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600244
akmhoque05d5fcf2014-04-15 14:58:45 -0500245 long int m_adjBuildCount;
246 bool isBuildAdjLsaSheduled;
247 bool isRouteCalculationScheduled;
248 bool 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