conf-parameter.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2020, The University of Memphis,
4  * Regents of the University of California,
5  * Arizona Board of Regents.
6  *
7  * This file is part of NLSR (Named-data Link State Routing).
8  * See AUTHORS.md for complete list of NLSR authors and contributors.
9  *
10  * NLSR is free software: you can redistribute it and/or modify it under the terms
11  * of the GNU General Public License as published by the Free Software Foundation,
12  * either version 3 of the License, or (at your option) any later version.
13  *
14  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
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"
30 
31 #include <boost/cstdint.hpp>
32 #include <ndn-cxx/face.hpp>
33 #include <ndn-cxx/security/validator-config.hpp>
34 #include <ndn-cxx/security/certificate-fetcher-direct-fetch.hpp>
35 #include <ndn-cxx/util/time.hpp>
36 
37 namespace nlsr {
38 
39 enum {
43 };
44 
45 enum {
48 };
49 
50 enum {
54 };
55 
56 enum {
60 };
61 
62 enum {
66 };
67 
68 
69 enum {
73 };
74 
75 enum {
79 };
80 
81 enum {
85 };
86 
87 enum {
91 };
92 
93 enum {
97 };
98 
99 enum {
103 };
104 
110 };
111 
112 enum {
116 };
117 
130 {
131 
132 public:
133  ConfParameter(ndn::Face& face, ndn::KeyChain& keyChain,
134  const std::string& confFileName = "nlsr.conf");
135 
136  const std::string&
138  {
139  return m_confFileName;
140  }
141 
142  void
143  setNetwork(const ndn::Name& networkName);
144 
145  const ndn::Name&
146  getNetwork() const
147  {
148  return m_network;
149  }
150 
151  void
152  setRouterName(const ndn::Name& routerName)
153  {
154  m_routerName = routerName;
155  }
156 
157  const ndn::Name&
159  {
160  return m_routerName;
161  }
162 
163  void
164  setSiteName(const ndn::Name& siteName)
165  {
166  m_siteName = siteName;
167  }
168 
169  const ndn::Name&
170  getSiteName() const
171  {
172  return m_siteName;
173  }
174 
175  void
177  {
178  m_routerPrefix = m_network;
179  m_routerPrefix.append(m_siteName);
180  m_routerPrefix.append(m_routerName);
181 
182  m_syncUserPrefix = m_lsaPrefix;
183  m_syncUserPrefix.append(m_siteName);
184  m_syncUserPrefix.append(m_routerName);
185  }
186 
187  const ndn::Name&
189  {
190  return m_routerPrefix;
191  }
192 
193  const ndn::Name&
195  {
196  return m_syncUserPrefix;
197  }
198 
199  const ndn::Name&
201  {
202  return m_syncPrefix;
203  }
204 
205  const ndn::Name&
206  getLsaPrefix() const
207  {
208  return m_lsaPrefix;
209  }
210 
211  void
212  setLsaRefreshTime(uint32_t lrt)
213  {
214  m_lsaRefreshTime = lrt;
215  }
216 
217  uint32_t
219  {
220  return m_syncProtocol;
221  }
222 
223  void
224  setSyncProtocol(int32_t syncProtocol)
225  {
226  if (syncProtocol == SYNC_PROTOCOL_CHRONOSYNC || syncProtocol == SYNC_PROTOCOL_PSYNC) {
227  m_syncProtocol = syncProtocol;
228  }
229  }
230 
231  uint32_t
233  {
234  return m_lsaRefreshTime;
235  }
236 
237  void
238  setLsaInterestLifetime(const ndn::time::seconds& lifetime)
239  {
240  m_lsaInterestLifetime = lifetime;
241  }
242 
243  const ndn::time::seconds&
245  {
246  return m_lsaInterestLifetime;
247  }
248 
249  void
250  setAdjLsaBuildInterval(uint32_t interval)
251  {
252  m_adjLsaBuildInterval = interval;
253  }
254 
255  uint32_t
257  {
258  return m_adjLsaBuildInterval;
259  }
260 
261  void
262  setRoutingCalcInterval(uint32_t interval)
263  {
264  m_routingCalcInterval = interval;
265  }
266 
267  uint32_t
269  {
270  return m_routingCalcInterval;
271  }
272 
273  void
274  setRouterDeadInterval(uint32_t rdt)
275  {
276  m_routerDeadInterval = rdt;
277  }
278 
279  uint32_t
281  {
282  return m_routerDeadInterval;
283  }
284 
285  void
286  setFaceDatasetFetchTries(uint32_t count)
287  {
288  m_faceDatasetFetchTries = count;
289  }
290 
291  uint32_t
293  {
294  return m_faceDatasetFetchTries;
295  }
296 
297  void
298  setFaceDatasetFetchInterval(uint32_t interval)
299  {
300  m_faceDatasetFetchInterval = ndn::time::seconds(interval);
301  }
302 
303  const ndn::time::seconds
305  {
306  return m_faceDatasetFetchInterval;
307  }
308 
309  void
311  {
312  m_interestRetryNumber = irn;
313  }
314 
315  uint32_t
317  {
318  return m_interestRetryNumber;
319  }
320 
321  void
322  setInterestResendTime(uint32_t irt)
323  {
324  m_interestResendTime = irt;
325  }
326 
327  uint32_t
329  {
330  return m_interestResendTime;
331  }
332 
333  uint32_t
335  {
336  return m_infoInterestInterval;
337  }
338 
339  void
341  {
342  m_infoInterestInterval = iii;
343  }
344 
345  void
346  setHyperbolicState(int32_t ihc)
347  {
348  m_hyperbolicState = ihc;
349  }
350 
351  int32_t
353  {
354  return m_hyperbolicState;
355  }
356 
357  bool
358  setCorR(double cr)
359  {
360  if ( cr >= 0 ) {
361  m_corR = cr;
362  return true;
363  }
364  return false;
365  }
366 
367  double
368  getCorR() const
369  {
370  return m_corR;
371  }
372 
373  void
374  setCorTheta(const std::vector<double>& ct)
375  {
376  m_corTheta = ct;
377  }
378 
379  std::vector<double>
380  getCorTheta() const
381  {
382  return m_corTheta;
383  }
384 
385  void
386  setMaxFacesPerPrefix(uint32_t mfpp)
387  {
388  m_maxFacesPerPrefix = mfpp;
389  }
390 
391  uint32_t
393  {
394  return m_maxFacesPerPrefix;
395  }
396 
397  void
398  setStateFileDir(const std::string& ssfd)
399  {
400  m_stateFileDir = ssfd;
401  }
402 
403  const std::string&
405  {
406  return m_stateFileDir;
407  }
408 
409  void
410  setConfFileNameDynamic(const std::string& confFileDynamic)
411  {
412  m_confFileNameDynamic = confFileDynamic;
413  }
414 
415  const std::string&
417  {
418  return m_confFileNameDynamic;
419  }
420 
421  void
422  setSyncInterestLifetime(uint32_t syncInterestLifetime)
423  {
424  m_syncInterestLifetime = ndn::time::milliseconds(syncInterestLifetime);
425  }
426 
427  const ndn::time::milliseconds&
429  {
430  return m_syncInterestLifetime;
431  }
432 
435  {
436  return m_adjl;
437  }
438 
441  {
442  return m_npl;
443  }
444 
445  ndn::security::ValidatorConfig&
447  {
448  return m_validator;
449  }
450 
451  ndn::security::ValidatorConfig&
453  {
454  return m_prefixUpdateValidator;
455  }
456 
457  const ndn::security::SigningInfo&
459  {
460  return m_signingInfo;
461  }
462 
463  void
464  addCertPath(const std::string& certPath)
465  {
466  m_certs.insert(certPath);
467  }
468 
469  const std::unordered_set<std::string>&
470  getIdCerts() const
471  {
472  return m_certs;
473  }
474 
475  const ndn::KeyChain&
476  getKeyChain() const
477  {
478  return m_keyChain;
479  }
480 
481  shared_ptr<ndn::security::Certificate>
482  initializeKey();
483 
484  void
485  loadCertToValidator(const ndn::security::Certificate& cert);
486 
489  void
490  writeLog();
491 
493  std::string m_confFileName;
494  std::string m_confFileNameDynamic;
495 private:
496  ndn::Name m_routerName;
497  ndn::Name m_siteName;
498  ndn::Name m_network;
499 
500  ndn::Name m_routerPrefix;
501  ndn::Name m_syncUserPrefix;
502 
503  ndn::Name m_syncPrefix;
504  ndn::Name m_lsaPrefix;
505 
506  uint32_t m_lsaRefreshTime;
507 
508  uint32_t m_adjLsaBuildInterval;
509  uint32_t m_routingCalcInterval;
510 
511  uint32_t m_faceDatasetFetchTries;
512  ndn::time::seconds m_faceDatasetFetchInterval;
513 
514  ndn::time::seconds m_lsaInterestLifetime;
515  uint32_t m_routerDeadInterval;
516 
517  uint32_t m_interestRetryNumber;
518  uint32_t m_interestResendTime;
519 
520  uint32_t m_infoInterestInterval;
521 
522  int32_t m_hyperbolicState;
523  double m_corR;
524  std::vector<double> m_corTheta;
525 
526  uint32_t m_maxFacesPerPrefix;
527 
528  std::string m_stateFileDir;
529 
530  ndn::time::milliseconds m_syncInterestLifetime;
531 
532  int32_t m_syncProtocol;
533 
535  static const uint64_t SYNC_VERSION;
536 
537  AdjacencyList m_adjl;
538  NamePrefixList m_npl;
539  ndn::security::ValidatorConfig m_validator;
540  ndn::security::ValidatorConfig m_prefixUpdateValidator;
541  ndn::security::SigningInfo m_signingInfo;
542  std::unordered_set<std::string> m_certs;
543  ndn::KeyChain& m_keyChain;
544 };
545 
546 } // namespace nlsr
547 
548 #endif // NLSR_CONF_PARAMETER_HPP
shared_ptr< ndn::security::Certificate > initializeKey()
ndn::security::ValidatorConfig & getValidator()
A class to house all the configuration parameters for NLSR.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
uint32_t getAdjLsaBuildInterval() const
uint32_t getLsaRefreshTime() const
const std::string & getStateFileDir() const
void setLsaInterestLifetime(const ndn::time::seconds &lifetime)
void setStateFileDir(const std::string &ssfd)
void setMaxFacesPerPrefix(uint32_t mfpp)
const std::string & getConfFileName()
void setRoutingCalcInterval(uint32_t interval)
void setNetwork(const ndn::Name &networkName)
const ndn::security::SigningInfo & getSigningInfo() const
AdjacencyList & getAdjacencyList()
void setAdjLsaBuildInterval(uint32_t interval)
void setSiteName(const ndn::Name &siteName)
ndn::security::ValidatorConfig & getPrefixUpdateValidator()
const ndn::Name & getSyncUserPrefix() const
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.
uint32_t getSyncProtocol() const
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)
double getCorR() const
uint32_t getInterestRetryNumber() const
void setSyncInterestLifetime(uint32_t syncInterestLifetime)
const ndn::Name & getRouterName() const
void setSyncProtocol(int32_t syncProtocol)
const ndn::Name & getSiteName() const
uint32_t getFaceDatasetFetchTries() const
uint32_t getRoutingCalcInterval() const
void setRouterName(const ndn::Name &routerName)
void setFaceDatasetFetchInterval(uint32_t interval)
void setInterestRetryNumber(uint32_t irn)
const ndn::Name & getSyncPrefix() const
uint32_t getMaxFacesPerPrefix() const
const ndn::KeyChain & getKeyChain() const
const ndn::Name & getNetwork() const
int32_t getHyperbolicState() const
void addCertPath(const std::string &certPath)
bool setCorR(double cr)
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
void setConfFileNameDynamic(const std::string &confFileDynamic)
void setRouterDeadInterval(uint32_t rdt)
NamePrefixList & getNamePrefixList()
void setLsaRefreshTime(uint32_t lrt)
const std::string & getConfFileNameDynamic() const
const std::unordered_set< std::string > & getIdCerts() const
void setHyperbolicState(int32_t ihc)
void setFaceDatasetFetchTries(uint32_t count)
const ndn::time::seconds getFaceDatasetFetchInterval() const
const ndn::time::milliseconds & getSyncInterestLifetime() const
void loadCertToValidator(const ndn::security::Certificate &cert)
const ndn::Name & getLsaPrefix() const
ConfParameter(ndn::Face &face, ndn::KeyChain &keyChain, const std::string &confFileName="nlsr.conf")
uint32_t getRouterDeadInterval() const
uint32_t getInterestResendTime() const
std::vector< double > getCorTheta() const
uint32_t getInfoInterestInterval() const
void writeLog()
Dump the current state of all attributes to the log.