conf-parameter.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_CONF_PARAMETER_HPP
23 #define NLSR_CONF_PARAMETER_HPP
24 
25 #include "common.hpp"
26 #include "logger.hpp"
27 #include "test-access-control.hpp"
28 #include "adjacency-list.hpp"
29 #include "name-prefix-list.hpp"
31 
32 #include <iostream>
33 #include <boost/cstdint.hpp>
34 #include <ndn-cxx/face.hpp>
35 #include <ndn-cxx/security/validator-config.hpp>
36 #include <ndn-cxx/security/v2/certificate-fetcher-direct-fetch.hpp>
37 #include <ndn-cxx/util/time.hpp>
38 
39 namespace nlsr {
40 
41 enum {
45 };
46 
47 enum {
50 };
51 
52 enum {
56 };
57 
58 enum {
62 };
63 
64 enum {
68 };
69 
70 
71 enum {
75 };
76 
77 enum {
81 };
82 
83 enum {
87 };
88 
89 enum {
93 };
94 
95 enum {
99 };
100 
101 enum {
105 };
106 
112 };
113 
114 enum {
118 };
119 
132 {
133 
134 public:
135  ConfParameter(ndn::Face& face, const std::string& confFileName = "nlsr.conf");
136 
137  const std::string&
139  {
140  return m_confFileName;
141  }
142 
143  void
144  setNetwork(const ndn::Name& networkName);
145 
146  const ndn::Name&
147  getNetwork() const
148  {
149  return m_network;
150  }
151 
152  void
153  setRouterName(const ndn::Name& routerName)
154  {
155  m_routerName = routerName;
156  }
157 
158  const ndn::Name&
160  {
161  return m_routerName;
162  }
163 
164  void
165  setSiteName(const ndn::Name& siteName)
166  {
167  m_siteName = siteName;
168  }
169 
170  const ndn::Name&
171  getSiteName() const
172  {
173  return m_siteName;
174  }
175 
176  void
178  {
179  m_routerPrefix = m_network;
180  m_routerPrefix.append(m_siteName);
181  m_routerPrefix.append(m_routerName);
182 
183  m_syncUserPrefix = m_lsaPrefix;
184  m_syncUserPrefix.append(m_siteName);
185  m_syncUserPrefix.append(m_routerName);
186  }
187 
188  const ndn::Name&
190  {
191  return m_routerPrefix;
192  }
193 
194  const ndn::Name&
196  {
197  return m_syncUserPrefix;
198  }
199 
200  const ndn::Name&
202  {
203  return m_syncPrefix;
204  }
205 
206  const ndn::Name&
207  getLsaPrefix() const
208  {
209  return m_lsaPrefix;
210  }
211 
212  void
213  setLsaRefreshTime(uint32_t lrt)
214  {
215  m_lsaRefreshTime = lrt;
216  }
217 
218  uint32_t
220  {
221  return m_syncProtocol;
222  }
223 
224  void
225  setSyncProtocol(int32_t syncProtocol)
226  {
227  if (syncProtocol == SYNC_PROTOCOL_CHRONOSYNC || syncProtocol == SYNC_PROTOCOL_PSYNC) {
228  m_syncProtocol = syncProtocol;
229  }
230  }
231 
232  uint32_t
234  {
235  return m_lsaRefreshTime;
236  }
237 
238  void
239  setLsaInterestLifetime(const ndn::time::seconds& lifetime)
240  {
241  m_lsaInterestLifetime = lifetime;
242  }
243 
244  const ndn::time::seconds&
246  {
247  return m_lsaInterestLifetime;
248  }
249 
250  void
251  setAdjLsaBuildInterval(uint32_t interval)
252  {
253  m_adjLsaBuildInterval = interval;
254  }
255 
256  uint32_t
258  {
259  return m_adjLsaBuildInterval;
260  }
261 
262  void
263  setRoutingCalcInterval(uint32_t interval)
264  {
265  m_routingCalcInterval = interval;
266  }
267 
268  uint32_t
270  {
271  return m_routingCalcInterval;
272  }
273 
274  void
275  setRouterDeadInterval(uint32_t rdt)
276  {
277  m_routerDeadInterval = rdt;
278  }
279 
280  uint32_t
282  {
283  return m_routerDeadInterval;
284  }
285 
286  void
287  setFaceDatasetFetchTries(uint32_t count)
288  {
289  m_faceDatasetFetchTries = count;
290  }
291 
292  uint32_t
294  {
295  return m_faceDatasetFetchTries;
296  }
297 
298  void
299  setFaceDatasetFetchInterval(uint32_t interval)
300  {
301  m_faceDatasetFetchInterval = ndn::time::seconds(interval);
302  }
303 
304  const ndn::time::seconds
306  {
307  return m_faceDatasetFetchInterval;
308  }
309 
310  void
312  {
313  m_interestRetryNumber = irn;
314  }
315 
316  uint32_t
318  {
319  return m_interestRetryNumber;
320  }
321 
322  void
323  setInterestResendTime(uint32_t irt)
324  {
325  m_interestResendTime = irt;
326  }
327 
328  uint32_t
330  {
331  return m_interestResendTime;
332  }
333 
334  uint32_t
336  {
337  return m_infoInterestInterval;
338  }
339 
340  void
342  {
343  m_infoInterestInterval = iii;
344  }
345 
346  void
347  setHyperbolicState(int32_t ihc)
348  {
349  m_hyperbolicState = ihc;
350  }
351 
352  int32_t
354  {
355  return m_hyperbolicState;
356  }
357 
358  bool
359  setCorR(double cr)
360  {
361  if ( cr >= 0 ) {
362  m_corR = cr;
363  return true;
364  }
365  return false;
366  }
367 
368  double
369  getCorR() const
370  {
371  return m_corR;
372  }
373 
374  void
375  setCorTheta(const std::vector<double>& ct)
376  {
377  m_corTheta = ct;
378  }
379 
380  std::vector<double>
381  getCorTheta() const
382  {
383  return m_corTheta;
384  }
385 
386  void
387  setMaxFacesPerPrefix(uint32_t mfpp)
388  {
389  m_maxFacesPerPrefix = mfpp;
390  }
391 
392  uint32_t
394  {
395  return m_maxFacesPerPrefix;
396  }
397 
398  void
399  setStateFileDir(const std::string& ssfd)
400  {
401  m_stateFileDir = ssfd;
402  }
403 
404  const std::string&
406  {
407  return m_stateFileDir;
408  }
409 
410  void
411  setConfFileNameDynamic(const std::string& confFileDynamic)
412  {
413  m_confFileNameDynamic = confFileDynamic;
414  }
415 
416  const std::string&
418  {
419  return m_confFileNameDynamic;
420  }
421 
422  void
423  setSyncInterestLifetime(uint32_t syncInterestLifetime)
424  {
425  m_syncInterestLifetime = ndn::time::milliseconds(syncInterestLifetime);
426  }
427 
428  const ndn::time::milliseconds&
430  {
431  return m_syncInterestLifetime;
432  }
433 
436  {
437  return m_adjl;
438  }
439 
442  {
443  return m_npl;
444  }
445 
446  ndn::security::ValidatorConfig&
448  {
449  return m_validator;
450  }
451 
452  ndn::security::ValidatorConfig&
454  {
455  return m_prefixUpdateValidator;
456  }
457 
460  {
461  return m_certStore;
462  }
463 
466  void
467  writeLog();
468 
469 private:
470  std::string m_confFileName;
471  ndn::Name m_routerName;
472  ndn::Name m_siteName;
473  ndn::Name m_network;
474 
475  ndn::Name m_routerPrefix;
476  ndn::Name m_syncUserPrefix;
477 
478  ndn::Name m_syncPrefix;
479  ndn::Name m_lsaPrefix;
480 
481  uint32_t m_lsaRefreshTime;
482 
483  uint32_t m_adjLsaBuildInterval;
484  uint32_t m_routingCalcInterval;
485 
486  uint32_t m_faceDatasetFetchTries;
487  ndn::time::seconds m_faceDatasetFetchInterval;
488 
489  ndn::time::seconds m_lsaInterestLifetime;
490  uint32_t m_routerDeadInterval;
491 
492  uint32_t m_interestRetryNumber;
493  uint32_t m_interestResendTime;
494 
495  uint32_t m_infoInterestInterval;
496 
497  int32_t m_hyperbolicState;
498  double m_corR;
499  std::vector<double> m_corTheta;
500 
501  uint32_t m_maxFacesPerPrefix;
502 
503  std::string m_stateFileDir;
504 
505  ndn::time::milliseconds m_syncInterestLifetime;
506 
507  int32_t m_syncProtocol;
508 
509  std::string m_confFileNameDynamic;
510 
512  static const uint64_t SYNC_VERSION;
513 
514  AdjacencyList m_adjl;
515  NamePrefixList m_npl;
516  ndn::security::ValidatorConfig m_validator;
517  ndn::security::ValidatorConfig m_prefixUpdateValidator;
518  security::CertificateStore m_certStore;
519 };
520 
521 } // namespace nlsr
522 
523 #endif // NLSR_CONF_PARAMETER_HPP
uint32_t getInterestResendTime() const
ConfParameter(ndn::Face &face, const std::string &confFileName="nlsr.conf")
ndn::security::ValidatorConfig & getValidator()
A class to house all the configuration parameters for NLSR.
const ndn::time::milliseconds & getSyncInterestLifetime() const
Store certificates for names.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
double getCorR() const
void setLsaInterestLifetime(const ndn::time::seconds &lifetime)
void setStateFileDir(const std::string &ssfd)
const std::string & getConfFileNameDynamic() const
void setMaxFacesPerPrefix(uint32_t mfpp)
const std::string & getConfFileName()
void setRoutingCalcInterval(uint32_t interval)
void setNetwork(const ndn::Name &networkName)
AdjacencyList & getAdjacencyList()
void setAdjLsaBuildInterval(uint32_t interval)
void setSiteName(const ndn::Name &siteName)
uint32_t getInfoInterestInterval() const
ndn::security::ValidatorConfig & getPrefixUpdateValidator()
const ndn::Name & getRouterPrefix() const
void setInterestResendTime(uint32_t irt)
void setInfoInterestInterval(uint32_t iii)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
const ndn::time::seconds & getLsaInterestLifetime() const
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
void setCorTheta(const std::vector< double > &ct)
const ndn::Name & getSyncPrefix() const
uint32_t getInterestRetryNumber() const
uint32_t getMaxFacesPerPrefix() const
std::vector< double > getCorTheta() const
const ndn::Name & getLsaPrefix() const
void setSyncInterestLifetime(uint32_t syncInterestLifetime)
const std::string & getStateFileDir() const
void setSyncProtocol(int32_t syncProtocol)
void setRouterName(const ndn::Name &routerName)
void setFaceDatasetFetchInterval(uint32_t interval)
uint32_t getLsaRefreshTime() const
void setInterestRetryNumber(uint32_t irn)
bool setCorR(double cr)
uint32_t getSyncProtocol() const
Copyright (c) 2014-2019, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
uint32_t getAdjLsaBuildInterval() const
void setConfFileNameDynamic(const std::string &confFileDynamic)
void setRouterDeadInterval(uint32_t rdt)
NamePrefixList & getNamePrefixList()
security::CertificateStore & getCertStore()
void setLsaRefreshTime(uint32_t lrt)
uint32_t getFaceDatasetFetchTries() const
const ndn::Name & getNetwork() const
const ndn::Name & getSyncUserPrefix() const
void setHyperbolicState(int32_t ihc)
void setFaceDatasetFetchTries(uint32_t count)
const ndn::Name & getRouterName() const
int32_t getHyperbolicState() const
uint32_t getRoutingCalcInterval() const
const ndn::Name & getSiteName() const
const ndn::time::seconds getFaceDatasetFetchInterval() const
uint32_t getRouterDeadInterval() const
void writeLog()
Dump the current state of all attributes to the log.