blob: f6e3ba0f4d5c8f78c82ca432a6fd10f2dad9ca40 [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#ifndef NLSR_HPP
2#define NLSR_HPP
3
akmhoquec8a10f72014-04-25 18:42:55 -05004#include <ndn-cxx/face.hpp>
5#include <ndn-cxx/security/key-chain.hpp>
6#include <ndn-cxx/util/scheduler.hpp>
akmhoque298385a2014-02-13 14:13:09 -06007
akmhoque53353462014-04-22 08:43:45 -05008#include "conf-parameter.hpp"
akmhoquec8a10f72014-04-25 18:42:55 -05009#include "adjacency-list.hpp"
10#include "name-prefix-list.hpp"
akmhoque53353462014-04-22 08:43:45 -050011#include "communication/interest-manager.hpp"
12#include "communication/data-manager.hpp"
13#include "lsdb.hpp"
14#include "sequencing-manager.hpp"
15#include "route/routing-table.hpp"
akmhoquec8a10f72014-04-25 18:42:55 -050016#include "route/name-prefix-table.hpp"
akmhoque53353462014-04-22 08:43:45 -050017#include "route/fib.hpp"
Yingdi Yu0c217822014-04-24 14:22:42 -070018// #include "security/key-manager.hpp"
akmhoque53353462014-04-22 08:43:45 -050019#include "communication/sync-logic-handler.hpp"
akmhoque2bb198e2014-02-28 11:46:27 -060020
21
akmhoque53353462014-04-22 08:43:45 -050022namespace nlsr {
23
24inline static void
25NullDeleter(boost::asio::io_service* variable)
akmhoque298385a2014-02-13 14:13:09 -060026{
akmhoque53353462014-04-22 08:43:45 -050027 // do nothing
28}
akmhoque298385a2014-02-13 14:13:09 -060029
akmhoque53353462014-04-22 08:43:45 -050030class Nlsr
31{
32public:
33 Nlsr()
34 : m_io(new boost::asio::io_service)
35 , m_nlsrFace(new Face(ndn::shared_ptr<boost::asio::io_service>(&*m_io,
akmhoqueb6450b12014-04-24 00:01:03 -050036 &NullDeleter)))
akmhoque53353462014-04-22 08:43:45 -050037 , m_scheduler(*m_io)
38 , m_confParam()
akmhoquec8a10f72014-04-25 18:42:55 -050039 , m_adjacencyList()
40 , m_namePrefixList()
41 , m_interestManager(*this)
42 , m_dataManager(*this)
43 , m_sequencingManager()
Yingdi Yu0c217822014-04-24 14:22:42 -070044 // , m_km()
akmhoque53353462014-04-22 08:43:45 -050045 , m_isDaemonProcess(false)
46 , m_configFileName("nlsr.conf")
47 , m_nlsrLsdb()
48 , m_adjBuildCount(0)
49 , m_isBuildAdjLsaSheduled(false)
50 , m_isRouteCalculationScheduled(false)
51 , m_isRoutingTableCalculating(false)
52 , m_routingTable()
akmhoquec8a10f72014-04-25 18:42:55 -050053 , m_namePrefixTable()
akmhoque53353462014-04-22 08:43:45 -050054 , m_fib()
akmhoquec8a10f72014-04-25 18:42:55 -050055 , m_syncLogicHandler(m_io)
akmhoque53353462014-04-22 08:43:45 -050056 {}
akmhoque298385a2014-02-13 14:13:09 -060057
akmhoque53353462014-04-22 08:43:45 -050058 void
59 registrationFailed(const ndn::Name& name);
60
61 void
62 setInterestFilterNlsr(const string& name);
63
64 void
65 startEventLoop();
66
67 int
68 usage(const string& progname);
69
70 std::string
71 getConfFileName()
Yingdi Yu40cd1c32014-04-17 15:02:17 -070072 {
akmhoque53353462014-04-22 08:43:45 -050073 return m_configFileName;
Yingdi Yu40cd1c32014-04-17 15:02:17 -070074 }
75
akmhoque53353462014-04-22 08:43:45 -050076 void
77 setConfFileName(const string& fileName)
akmhoque5a44dd42014-03-12 18:11:32 -050078 {
akmhoque53353462014-04-22 08:43:45 -050079 m_configFileName = fileName;
80 }
akmhoque5a44dd42014-03-12 18:11:32 -050081
akmhoque53353462014-04-22 08:43:45 -050082 bool
83 getIsSetDaemonProcess()
84 {
85 return m_isDaemonProcess;
86 }
akmhoque5a44dd42014-03-12 18:11:32 -050087
akmhoque53353462014-04-22 08:43:45 -050088 void
89 setIsDaemonProcess(bool value)
90 {
91 m_isDaemonProcess = value;
92 }
akmhoque5a44dd42014-03-12 18:11:32 -050093
akmhoque53353462014-04-22 08:43:45 -050094 ConfParameter&
95 getConfParameter()
96 {
97 return m_confParam;
98 }
akmhoque5a44dd42014-03-12 18:11:32 -050099
akmhoquec8a10f72014-04-25 18:42:55 -0500100 AdjacencyList&
101 getAdjacencyList()
akmhoque53353462014-04-22 08:43:45 -0500102 {
akmhoquec8a10f72014-04-25 18:42:55 -0500103 return m_adjacencyList;
akmhoque53353462014-04-22 08:43:45 -0500104 }
akmhoque298385a2014-02-13 14:13:09 -0600105
akmhoquec8a10f72014-04-25 18:42:55 -0500106 NamePrefixList&
107 getNamePrefixList()
akmhoque53353462014-04-22 08:43:45 -0500108 {
akmhoquec8a10f72014-04-25 18:42:55 -0500109 return m_namePrefixList;
akmhoque53353462014-04-22 08:43:45 -0500110 }
akmhoque298385a2014-02-13 14:13:09 -0600111
akmhoque53353462014-04-22 08:43:45 -0500112 ndn::shared_ptr<boost::asio::io_service>&
113 getIo()
114 {
115 return m_io;
116 }
akmhoque298385a2014-02-13 14:13:09 -0600117
akmhoque53353462014-04-22 08:43:45 -0500118 ndn::Scheduler&
119 getScheduler()
120 {
121 return m_scheduler;
122 }
akmhoque298385a2014-02-13 14:13:09 -0600123
akmhoque53353462014-04-22 08:43:45 -0500124 ndn::shared_ptr<ndn::Face>
125 getNlsrFace()
126 {
127 return m_nlsrFace;
128 }
akmhoque298385a2014-02-13 14:13:09 -0600129
Yingdi Yu0c217822014-04-24 14:22:42 -0700130 // KeyManager&
131 // getKeyManager()
132 // {
133 // return m_km;
134 // }
akmhoque298385a2014-02-13 14:13:09 -0600135
akmhoque66e66182014-02-21 17:56:03 -0600136
akmhoque53353462014-04-22 08:43:45 -0500137 InterestManager&
akmhoquec8a10f72014-04-25 18:42:55 -0500138 getInterestManager()
akmhoque53353462014-04-22 08:43:45 -0500139 {
akmhoquec8a10f72014-04-25 18:42:55 -0500140 return m_interestManager;
akmhoque53353462014-04-22 08:43:45 -0500141 }
akmhoque298385a2014-02-13 14:13:09 -0600142
akmhoque53353462014-04-22 08:43:45 -0500143 DataManager&
akmhoquec8a10f72014-04-25 18:42:55 -0500144 getDataManager()
akmhoque53353462014-04-22 08:43:45 -0500145 {
akmhoquec8a10f72014-04-25 18:42:55 -0500146 return m_dataManager;
akmhoque53353462014-04-22 08:43:45 -0500147 }
akmhoque298385a2014-02-13 14:13:09 -0600148
akmhoque53353462014-04-22 08:43:45 -0500149 SequencingManager&
akmhoquec8a10f72014-04-25 18:42:55 -0500150 getSequencingManager()
akmhoque53353462014-04-22 08:43:45 -0500151 {
akmhoquec8a10f72014-04-25 18:42:55 -0500152 return m_sequencingManager;
akmhoque53353462014-04-22 08:43:45 -0500153 }
akmhoque298385a2014-02-13 14:13:09 -0600154
akmhoque53353462014-04-22 08:43:45 -0500155 Lsdb&
156 getLsdb()
157 {
158 return m_nlsrLsdb;
159 }
akmhoque298385a2014-02-13 14:13:09 -0600160
akmhoque53353462014-04-22 08:43:45 -0500161 RoutingTable&
162 getRoutingTable()
163 {
164 return m_routingTable;
165 }
akmhoque298385a2014-02-13 14:13:09 -0600166
akmhoquec8a10f72014-04-25 18:42:55 -0500167 NamePrefixTable&
168 getNamePrefixTable()
akmhoque53353462014-04-22 08:43:45 -0500169 {
akmhoquec8a10f72014-04-25 18:42:55 -0500170 return m_namePrefixTable;
akmhoque53353462014-04-22 08:43:45 -0500171 }
akmhoque298385a2014-02-13 14:13:09 -0600172
akmhoque53353462014-04-22 08:43:45 -0500173 Fib&
174 getFib()
175 {
176 return m_fib;
177 }
akmhoque298385a2014-02-13 14:13:09 -0600178
akmhoque53353462014-04-22 08:43:45 -0500179 long int
180 getAdjBuildCount()
181 {
182 return m_adjBuildCount;
183 }
akmhoque298385a2014-02-13 14:13:09 -0600184
akmhoque53353462014-04-22 08:43:45 -0500185 void
186 incrementAdjBuildCount()
187 {
188 m_adjBuildCount++;
189 }
akmhoque298385a2014-02-13 14:13:09 -0600190
akmhoque53353462014-04-22 08:43:45 -0500191 void
192 setAdjBuildCount(long int abc)
193 {
194 m_adjBuildCount = abc;
195 }
akmhoque298385a2014-02-13 14:13:09 -0600196
akmhoque53353462014-04-22 08:43:45 -0500197 int
198 getIsBuildAdjLsaSheduled()
199 {
200 return m_isBuildAdjLsaSheduled;
201 }
akmhoque298385a2014-02-13 14:13:09 -0600202
akmhoque53353462014-04-22 08:43:45 -0500203 void
204 setIsBuildAdjLsaSheduled(bool iabls)
205 {
206 m_isBuildAdjLsaSheduled = iabls;
207 }
akmhoque298385a2014-02-13 14:13:09 -0600208
akmhoque298385a2014-02-13 14:13:09 -0600209
akmhoque53353462014-04-22 08:43:45 -0500210 void
211 setApiPort(int ap)
212 {
213 m_apiPort = ap;
214 }
akmhoque298385a2014-02-13 14:13:09 -0600215
akmhoque53353462014-04-22 08:43:45 -0500216 int
217 getApiPort()
218 {
219 return m_apiPort;
220 }
akmhoque298385a2014-02-13 14:13:09 -0600221
akmhoque53353462014-04-22 08:43:45 -0500222 bool
223 getIsRoutingTableCalculating()
224 {
225 return m_isRoutingTableCalculating;
226 }
akmhoque85d88332014-02-17 21:11:21 -0600227
akmhoque53353462014-04-22 08:43:45 -0500228 void
229 setIsRoutingTableCalculating(bool irtc)
230 {
231 m_isRoutingTableCalculating = irtc;
232 }
akmhoque298385a2014-02-13 14:13:09 -0600233
akmhoque53353462014-04-22 08:43:45 -0500234 bool
235 getIsRouteCalculationScheduled()
236 {
237 return m_isRouteCalculationScheduled;
238 }
akmhoque298385a2014-02-13 14:13:09 -0600239
akmhoque53353462014-04-22 08:43:45 -0500240 void
241 setIsRouteCalculationScheduled(bool ircs)
242 {
243 m_isRouteCalculationScheduled = ircs;
244 }
akmhoque298385a2014-02-13 14:13:09 -0600245
akmhoque53353462014-04-22 08:43:45 -0500246 SyncLogicHandler&
akmhoquec8a10f72014-04-25 18:42:55 -0500247 getSyncLogicHandler()
akmhoque53353462014-04-22 08:43:45 -0500248 {
akmhoquec8a10f72014-04-25 18:42:55 -0500249 return m_syncLogicHandler;
akmhoque53353462014-04-22 08:43:45 -0500250 }
akmhoque2bb198e2014-02-28 11:46:27 -0600251
akmhoque53353462014-04-22 08:43:45 -0500252 void
253 initialize();
akmhoque1fd8c1e2014-02-19 19:41:49 -0600254
akmhoque53353462014-04-22 08:43:45 -0500255private:
256 ndn::shared_ptr<boost::asio::io_service> m_io;
257 ndn::shared_ptr<ndn::Face> m_nlsrFace;
258 ndn::Scheduler m_scheduler;
259 ConfParameter m_confParam;
akmhoquec8a10f72014-04-25 18:42:55 -0500260 AdjacencyList m_adjacencyList;
261 NamePrefixList m_namePrefixList;
262 InterestManager m_interestManager;
263 DataManager m_dataManager;
264 SequencingManager m_sequencingManager;
Yingdi Yu0c217822014-04-24 14:22:42 -0700265 // KeyManager m_km;
akmhoque53353462014-04-22 08:43:45 -0500266 bool m_isDaemonProcess;
267 string m_configFileName;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600268
akmhoque1fd8c1e2014-02-19 19:41:49 -0600269
akmhoque53353462014-04-22 08:43:45 -0500270 Lsdb m_nlsrLsdb;
akmhoque1fd8c1e2014-02-19 19:41:49 -0600271
akmhoque53353462014-04-22 08:43:45 -0500272
273 long int m_adjBuildCount;
274 bool m_isBuildAdjLsaSheduled;
275 bool m_isRouteCalculationScheduled;
276 bool m_isRoutingTableCalculating;
277
278 RoutingTable m_routingTable;
akmhoquec8a10f72014-04-25 18:42:55 -0500279 NamePrefixTable m_namePrefixTable;
akmhoque53353462014-04-22 08:43:45 -0500280 Fib m_fib;
akmhoquec8a10f72014-04-25 18:42:55 -0500281 SyncLogicHandler m_syncLogicHandler;
akmhoque53353462014-04-22 08:43:45 -0500282
283 int m_apiPort;
284
285
286};
akmhoque298385a2014-02-13 14:13:09 -0600287
akmhoqueb1710aa2014-02-19 17:13:36 -0600288} //namespace nlsr
289
akmhoque53353462014-04-22 08:43:45 -0500290#endif //NLSR_HPP