blob: 8b325fe8377b57f25c08af06259f9c8f8cd19608 [file] [log] [blame]
akmhoque87347a32014-01-31 11:00:44 -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
akmhoque204e7542014-01-31 16:08:25 -06008#include "nlsr_conf_param.hpp"
9#include "nlsr_adl.hpp"
10#include "nlsr_npl.hpp"
akmhoque147f4992014-01-31 15:52:49 -060011#include "nlsr_im.hpp"
12#include "nlsr_dm.hpp"
akmhoquebd7c8e62014-02-01 14:57:40 -060013#include "nlsr_lsdb.hpp"
akmhoque87347a32014-01-31 11:00:44 -060014
15
16using namespace ndn;
17using namespace std;
18
19class nlsr
20{
akmhoque147f4992014-01-31 15:52:49 -060021public:
akmhoque87347a32014-01-31 11:00:44 -060022 nlsr()
23 : io(ndn::make_shared<boost::asio::io_service>())
akmhoque147f4992014-01-31 15:52:49 -060024 , nlsrFace(io)
akmhoque87347a32014-01-31 11:00:44 -060025 , scheduler(*io)
26 , configFileName()
27 , confParam()
28 , adl()
29 , npl()
akmhoque147f4992014-01-31 15:52:49 -060030 , im()
31 , dm()
akmhoquebd7c8e62014-02-01 14:57:40 -060032 , nlsrLsdb()
33 , nameLsaSeq(0)
34 , adjLsaSeq(0)
35 , corLsaSeq(0)
akmhoquecd552472014-02-01 21:22:16 -060036 , adjBuildCount(0)
37 , isBuildAdjLsaSheduled(0)
38 , isRouteCalculationScheduled(0)
39 , isRoutingTableCalculating(0)
akmhoque87347a32014-01-31 11:00:44 -060040 {
41 isDaemonProcess=false;
42 configFileName="nlsr.conf";
43 }
44
akmhoquebd7c8e62014-02-01 14:57:40 -060045 nlsr(string confFile, uint32_t nlsn, uint32_t alsn, uint32_t clsn)
46 : io(ndn::make_shared<boost::asio::io_service>())
47 , nlsrFace(io)
48 , scheduler(*io)
49 , configFileName()
50 , confParam()
51 , adl()
52 , npl()
53 , im()
54 , dm()
55 , nlsrLsdb()
akmhoquecd552472014-02-01 21:22:16 -060056 , adjBuildCount(0)
57 , isBuildAdjLsaSheduled(0)
58 , isRouteCalculationScheduled(0)
59 , isRoutingTableCalculating(0)
akmhoquebd7c8e62014-02-01 14:57:40 -060060 {
61 isDaemonProcess=false;
62 configFileName=confFile;
63 nameLsaSeq=nlsn;
64 adjLsaSeq=alsn;
65 corLsaSeq=clsn;
66 }
67
akmhoque87347a32014-01-31 11:00:44 -060068 void nlsrRegistrationFailed(const ptr_lib::shared_ptr<const Name>&);
akmhoque87347a32014-01-31 11:00:44 -060069
70 void setInterestFilterNlsr(const string& name);
akmhoque87347a32014-01-31 11:00:44 -060071 void startEventLoop();
72
73 int usage(const string& progname);
74
akmhoque147f4992014-01-31 15:52:49 -060075 string getConfFileName()
76 {
akmhoque87347a32014-01-31 11:00:44 -060077 return configFileName;
78 }
79
akmhoque147f4992014-01-31 15:52:49 -060080 void setConfFileName(const string& fileName)
81 {
82 configFileName=fileName;
83 }
akmhoque87347a32014-01-31 11:00:44 -060084
akmhoque147f4992014-01-31 15:52:49 -060085 bool isSetDaemonProcess()
86 {
87 return isDaemonProcess;
88 }
akmhoque87347a32014-01-31 11:00:44 -060089
akmhoque147f4992014-01-31 15:52:49 -060090 void setIsDaemonProcess(bool value)
91 {
92 isDaemonProcess=value;
93 }
akmhoque87347a32014-01-31 11:00:44 -060094
akmhoquea8cd6b92014-01-31 20:13:26 -060095 ConfParameter& getConfParameter(){
96 return confParam;
97 }
98
99 Adl& getAdl(){
100 return adl;
101 }
102
103 Npl& getNpl(){
104 return npl;
105 }
106
107 ndn::shared_ptr<boost::asio::io_service>& getIo()
108 {
109 return io;
110 }
111
112 ndn::Scheduler& getScheduler(){
113 return scheduler;
114 }
115
116 ndn::Face& getNlsrFace(){
117 return nlsrFace;
118 }
119
120 ndn::KeyChain& getKeyChain(){
121 return kChain;
122 }
123
124 interestManager& getIm(){
125 return im;
126 }
127
128 DataManager& getDm(){
129 return dm;
130 }
akmhoquebd7c8e62014-02-01 14:57:40 -0600131
132 Lsdb& getLsdb(){
133 return nlsrLsdb;
134 }
135
136 uint32_t getNameLsaSeq()
137 {
138 return nameLsaSeq;
139 }
140
141 void setNameLsaSeq(uint32_t nlsn){
142 nameLsaSeq=nlsn;
143 }
144
145 uint32_t getAdjLsaSeq()
146 {
147 return adjLsaSeq;
148 }
149
150 void setAdjLsaSeq(uint32_t alsn){
151 adjLsaSeq=alsn;
152 }
153
154 uint32_t getCorLsaSeq()
155 {
156 return corLsaSeq;
157 }
158
159 void setCorLsaSeq(uint32_t clsn){
160 corLsaSeq=clsn;
161 }
akmhoquecd552472014-02-01 21:22:16 -0600162
163 long int getAdjBuildCount()
164 {
165 return adjBuildCount;
166 }
167
168 void incrementAdjBuildCount()
169 {
170 adjBuildCount++;
171 }
172
173 void setAdjBuildCount(long int abc)
174 {
175 adjBuildCount=abc;
176 }
177
178 int getIsBuildAdjLsaSheduled()
179 {
180 return isBuildAdjLsaSheduled;
181 }
182
183 void setIsBuildAdjLsaSheduled(int iabls)
184 {
185 isBuildAdjLsaSheduled=iabls;
186 }
187
akmhoquea8cd6b92014-01-31 20:13:26 -0600188private:
akmhoque87347a32014-01-31 11:00:44 -0600189 ConfParameter confParam;
190 Adl adl;
191 Npl npl;
akmhoque87347a32014-01-31 11:00:44 -0600192 ndn::shared_ptr<boost::asio::io_service> io;
193 ndn::Scheduler scheduler;
194 ndn::Face nlsrFace;
195 ndn::KeyChain kChain;
akmhoque147f4992014-01-31 15:52:49 -0600196 interestManager im;
197 DataManager dm;
akmhoque87347a32014-01-31 11:00:44 -0600198 bool isDaemonProcess;
199 string configFileName;
akmhoquebd7c8e62014-02-01 14:57:40 -0600200 Lsdb nlsrLsdb;
201 uint32_t nameLsaSeq;
202 uint32_t adjLsaSeq;
203 uint32_t corLsaSeq;
akmhoquecd552472014-02-01 21:22:16 -0600204
205 long int adjBuildCount;
206 int isBuildAdjLsaSheduled;
207 int isRouteCalculationScheduled;
208 int isRoutingTableCalculating;
akmhoquebd7c8e62014-02-01 14:57:40 -0600209
akmhoque87347a32014-01-31 11:00:44 -0600210
211};
212
213#endif