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 enum {
74 };
75 
76 
77 enum {
81 };
82 
83 enum {
87 };
88 
89 enum {
93 };
94 
95 enum {
99 };
100 
101 enum {
105 };
106 
107 enum {
111 };
112 
118 };
119 
120 enum {
124 };
125 
138 {
139 
140 public:
141  ConfParameter(ndn::Face& face, const std::string& confFileName = "nlsr.conf");
142 
143  const std::string&
145  {
146  return m_confFileName;
147  }
148 
149  void
150  setNetwork(const ndn::Name& networkName);
151 
152  const ndn::Name&
153  getNetwork() const
154  {
155  return m_network;
156  }
157 
158  void
159  setRouterName(const ndn::Name& routerName)
160  {
161  m_routerName = routerName;
162  }
163 
164  const ndn::Name&
166  {
167  return m_routerName;
168  }
169 
170  void
171  setSiteName(const ndn::Name& siteName)
172  {
173  m_siteName = siteName;
174  }
175 
176  const ndn::Name&
177  getSiteName() const
178  {
179  return m_siteName;
180  }
181 
182  void
184  {
185  m_routerPrefix = m_network;
186  m_routerPrefix.append(m_siteName);
187  m_routerPrefix.append(m_routerName);
188  }
189 
190  const ndn::Name&
192  {
193  return m_routerPrefix;
194  }
195 
196  const ndn::Name&
198  {
199  return m_syncPrefix;
200  }
201 
202  const ndn::Name&
203  getLsaPrefix() const
204  {
205  return m_lsaPrefix;
206  }
207 
208  void
209  setLsaRefreshTime(uint32_t lrt)
210  {
211  m_lsaRefreshTime = lrt;
212  }
213 
214  uint32_t
216  {
217  return m_syncProtocol;
218  }
219 
220  void
221  setSyncProtocol(int32_t syncProtocol)
222  {
223  if (syncProtocol == SYNC_PROTOCOL_CHRONOSYNC || syncProtocol == SYNC_PROTOCOL_PSYNC) {
224  m_syncProtocol = syncProtocol;
225  }
226  }
227 
228  uint32_t
230  {
231  return m_lsaRefreshTime;
232  }
233 
234  void
235  setLsaInterestLifetime(const ndn::time::seconds& lifetime)
236  {
237  m_lsaInterestLifetime = lifetime;
238  }
239 
240  const ndn::time::seconds&
242  {
243  return m_lsaInterestLifetime;
244  }
245 
246  void
247  setAdjLsaBuildInterval(uint32_t interval)
248  {
249  m_adjLsaBuildInterval = interval;
250  }
251 
252  uint32_t
254  {
255  return m_adjLsaBuildInterval;
256  }
257 
258  void
259  setFirstHelloInterval(uint32_t interval)
260  {
261  m_firstHelloInterval = interval;
262  }
263 
264  uint32_t
266  {
267  return m_firstHelloInterval;
268  }
269 
270  void
271  setRoutingCalcInterval(uint32_t interval)
272  {
273  m_routingCalcInterval = interval;
274  }
275 
276  uint32_t
278  {
279  return m_routingCalcInterval;
280  }
281 
282  void
283  setRouterDeadInterval(uint32_t rdt)
284  {
285  m_routerDeadInterval = rdt;
286  }
287 
288  uint32_t
290  {
291  return m_routerDeadInterval;
292  }
293 
294  void
295  setFaceDatasetFetchTries(uint32_t count)
296  {
297  m_faceDatasetFetchTries = count;
298  }
299 
300  uint32_t
302  {
303  return m_faceDatasetFetchTries;
304  }
305 
306  void
307  setFaceDatasetFetchInterval(uint32_t interval)
308  {
309  m_faceDatasetFetchInterval = ndn::time::seconds(interval);
310  }
311 
312  const ndn::time::seconds
314  {
315  return m_faceDatasetFetchInterval;
316  }
317 
318  void
320  {
321  m_interestRetryNumber = irn;
322  }
323 
324  uint32_t
326  {
327  return m_interestRetryNumber;
328  }
329 
330  void
331  setInterestResendTime(uint32_t irt)
332  {
333  m_interestResendTime = irt;
334  }
335 
336  uint32_t
338  {
339  return m_interestResendTime;
340  }
341 
342  uint32_t
344  {
345  return m_infoInterestInterval;
346  }
347 
348  void
350  {
351  m_infoInterestInterval = iii;
352  }
353 
354  void
355  setHyperbolicState(int32_t ihc)
356  {
357  m_hyperbolicState = ihc;
358  }
359 
360  int32_t
362  {
363  return m_hyperbolicState;
364  }
365 
366  bool
367  setCorR(double cr)
368  {
369  if ( cr >= 0 ) {
370  m_corR = cr;
371  return true;
372  }
373  return false;
374  }
375 
376  double
377  getCorR() const
378  {
379  return m_corR;
380  }
381 
382  void
383  setCorTheta(const std::vector<double>& ct)
384  {
385  m_corTheta = ct;
386  }
387 
388  std::vector<double>
389  getCorTheta() const
390  {
391  return m_corTheta;
392  }
393 
394  void
395  setMaxFacesPerPrefix(uint32_t mfpp)
396  {
397  m_maxFacesPerPrefix = mfpp;
398  }
399 
400  uint32_t
402  {
403  return m_maxFacesPerPrefix;
404  }
405 
406  void
407  setStateFileDir(const std::string& ssfd)
408  {
409  m_stateFileDir = ssfd;
410  }
411 
412  const std::string&
414  {
415  return m_stateFileDir;
416  }
417 
418  void
419  setConfFileNameDynamic(const std::string& confFileDynamic)
420  {
421  m_confFileNameDynamic = confFileDynamic;
422  }
423 
424  const std::string&
426  {
427  return m_confFileNameDynamic;
428  }
429 
430  void
431  setSyncInterestLifetime(uint32_t syncInterestLifetime)
432  {
433  m_syncInterestLifetime = ndn::time::milliseconds(syncInterestLifetime);
434  }
435 
436  const ndn::time::milliseconds&
438  {
439  return m_syncInterestLifetime;
440  }
441 
444  {
445  return m_adjl;
446  }
447 
450  {
451  return m_npl;
452  }
453 
454  ndn::security::ValidatorConfig&
456  {
457  return m_validator;
458  }
459 
460  ndn::security::ValidatorConfig&
462  {
463  return m_prefixUpdateValidator;
464  }
465 
468  {
469  return m_certStore;
470  }
471 
474  void
475  writeLog();
476 
477 private:
478  std::string m_confFileName;
479  ndn::Name m_routerName;
480  ndn::Name m_siteName;
481  ndn::Name m_network;
482 
483  ndn::Name m_routerPrefix;
484  ndn::Name m_lsaRouterPrefix;
485 
486  ndn::Name m_syncPrefix;
487  ndn::Name m_lsaPrefix;
488 
489  uint32_t m_lsaRefreshTime;
490 
491  uint32_t m_adjLsaBuildInterval;
492  uint32_t m_firstHelloInterval;
493  uint32_t m_routingCalcInterval;
494 
495  uint32_t m_faceDatasetFetchTries;
496  ndn::time::seconds m_faceDatasetFetchInterval;
497 
498  ndn::time::seconds m_lsaInterestLifetime;
499  uint32_t m_routerDeadInterval;
500 
501  uint32_t m_interestRetryNumber;
502  uint32_t m_interestResendTime;
503 
504  uint32_t m_infoInterestInterval;
505 
506  int32_t m_hyperbolicState;
507  double m_corR;
508  std::vector<double> m_corTheta;
509 
510  uint32_t m_maxFacesPerPrefix;
511 
512  std::string m_stateFileDir;
513 
514  ndn::time::milliseconds m_syncInterestLifetime;
515 
516  int32_t m_syncProtocol;
517 
518  std::string m_confFileNameDynamic;
519 
521  static const uint64_t SYNC_VERSION;
522 
523  AdjacencyList m_adjl;
524  NamePrefixList m_npl;
525  ndn::security::ValidatorConfig m_validator;
526  ndn::security::ValidatorConfig m_prefixUpdateValidator;
527  security::CertificateStore m_certStore;
528 };
529 
530 } // namespace nlsr
531 
532 #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-2018, 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()
void setFirstHelloInterval(uint32_t interval)
security::CertificateStore & getCertStore()
uint32_t getFirstHelloInterval() const
void setLsaRefreshTime(uint32_t lrt)
uint32_t getFaceDatasetFetchTries() const
const ndn::Name & getNetwork() 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.