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-2021, 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 <ndn-cxx/face.hpp>
32 #include <ndn-cxx/security/validator-config.hpp>
33 #include <ndn-cxx/security/certificate-fetcher-direct-fetch.hpp>
34 
35 namespace nlsr {
36 
37 enum {
41 };
42 
44 #ifdef HAVE_CHRONOSYNC
45  SYNC_PROTOCOL_CHRONOSYNC,
46 #endif
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 public:
132  ConfParameter(ndn::Face& face, ndn::KeyChain& keyChain,
133  const std::string& confFileName = "nlsr.conf");
134 
135  const std::string&
137  {
138  return m_confFileName;
139  }
140 
141  void
142  setNetwork(const ndn::Name& networkName);
143 
144  const ndn::Name&
145  getNetwork() const
146  {
147  return m_network;
148  }
149 
150  void
151  setRouterName(const ndn::Name& routerName)
152  {
153  m_routerName = routerName;
154  }
155 
156  const ndn::Name&
158  {
159  return m_routerName;
160  }
161 
162  void
163  setSiteName(const ndn::Name& siteName)
164  {
165  m_siteName = siteName;
166  }
167 
168  const ndn::Name&
169  getSiteName() const
170  {
171  return m_siteName;
172  }
173 
174  void
176  {
177  m_routerPrefix = m_network;
178  m_routerPrefix.append(m_siteName);
179  m_routerPrefix.append(m_routerName);
180 
181  m_syncUserPrefix = m_lsaPrefix;
182  m_syncUserPrefix.append(m_siteName);
183  m_syncUserPrefix.append(m_routerName);
184  }
185 
186  const ndn::Name&
188  {
189  return m_routerPrefix;
190  }
191 
192  const ndn::Name&
194  {
195  return m_syncUserPrefix;
196  }
197 
198  const ndn::Name&
200  {
201  return m_syncPrefix;
202  }
203 
204  const ndn::Name&
205  getLsaPrefix() const
206  {
207  return m_lsaPrefix;
208  }
209 
210  void
211  setLsaRefreshTime(uint32_t lrt)
212  {
213  m_lsaRefreshTime = lrt;
214  }
215 
218  {
219  return m_syncProtocol;
220  }
221 
222  void
224  {
225  m_syncProtocol = syncProtocol;
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  setRoutingCalcInterval(uint32_t interval)
260  {
261  m_routingCalcInterval = interval;
262  }
263 
264  uint32_t
266  {
267  return m_routingCalcInterval;
268  }
269 
270  void
271  setRouterDeadInterval(uint32_t rdt)
272  {
273  m_routerDeadInterval = rdt;
274  }
275 
276  uint32_t
278  {
279  return m_routerDeadInterval;
280  }
281 
282  void
283  setFaceDatasetFetchTries(uint32_t count)
284  {
285  m_faceDatasetFetchTries = count;
286  }
287 
288  uint32_t
290  {
291  return m_faceDatasetFetchTries;
292  }
293 
294  void
295  setFaceDatasetFetchInterval(uint32_t interval)
296  {
297  m_faceDatasetFetchInterval = ndn::time::seconds(interval);
298  }
299 
300  const ndn::time::seconds
302  {
303  return m_faceDatasetFetchInterval;
304  }
305 
306  void
308  {
309  m_interestRetryNumber = irn;
310  }
311 
312  uint32_t
314  {
315  return m_interestRetryNumber;
316  }
317 
318  void
319  setInterestResendTime(uint32_t irt)
320  {
321  m_interestResendTime = irt;
322  }
323 
324  uint32_t
326  {
327  return m_interestResendTime;
328  }
329 
330  uint32_t
332  {
333  return m_infoInterestInterval;
334  }
335 
336  void
338  {
339  m_infoInterestInterval = iii;
340  }
341 
342  void
343  setHyperbolicState(int32_t ihc)
344  {
345  m_hyperbolicState = ihc;
346  }
347 
348  int32_t
350  {
351  return m_hyperbolicState;
352  }
353 
354  bool
355  setCorR(double cr)
356  {
357  if ( cr >= 0 ) {
358  m_corR = cr;
359  return true;
360  }
361  return false;
362  }
363 
364  double
365  getCorR() const
366  {
367  return m_corR;
368  }
369 
370  void
371  setCorTheta(const std::vector<double>& ct)
372  {
373  m_corTheta = ct;
374  }
375 
376  std::vector<double>
377  getCorTheta() const
378  {
379  return m_corTheta;
380  }
381 
382  void
383  setMaxFacesPerPrefix(uint32_t mfpp)
384  {
385  m_maxFacesPerPrefix = mfpp;
386  }
387 
388  uint32_t
390  {
391  return m_maxFacesPerPrefix;
392  }
393 
394  void
395  setStateFileDir(const std::string& ssfd)
396  {
397  m_stateFileDir = ssfd;
398  }
399 
400  const std::string&
402  {
403  return m_stateFileDir;
404  }
405 
406  void
407  setConfFileNameDynamic(const std::string& confFileDynamic)
408  {
409  m_confFileNameDynamic = confFileDynamic;
410  }
411 
412  const std::string&
414  {
415  return m_confFileNameDynamic;
416  }
417 
418  void
419  setSyncInterestLifetime(uint32_t syncInterestLifetime)
420  {
421  m_syncInterestLifetime = ndn::time::milliseconds(syncInterestLifetime);
422  }
423 
424  const ndn::time::milliseconds&
426  {
427  return m_syncInterestLifetime;
428  }
429 
432  {
433  return m_adjl;
434  }
435 
438  {
439  return m_npl;
440  }
441 
442  ndn::security::ValidatorConfig&
444  {
445  return m_validator;
446  }
447 
448  ndn::security::ValidatorConfig&
450  {
451  return m_prefixUpdateValidator;
452  }
453 
454  const ndn::security::SigningInfo&
456  {
457  return m_signingInfo;
458  }
459 
460  void
461  addCertPath(const std::string& certPath)
462  {
463  m_certs.insert(certPath);
464  }
465 
466  const std::unordered_set<std::string>&
467  getIdCerts() const
468  {
469  return m_certs;
470  }
471 
472  const ndn::KeyChain&
473  getKeyChain() const
474  {
475  return m_keyChain;
476  }
477 
478  std::shared_ptr<ndn::security::Certificate>
479  initializeKey();
480 
481  void
482  loadCertToValidator(const ndn::security::Certificate& cert);
483 
486  void
487  writeLog();
488 
490  std::string m_confFileName;
491  std::string m_confFileNameDynamic;
492 
493 private:
494  ndn::Name m_routerName;
495  ndn::Name m_siteName;
496  ndn::Name m_network;
497 
498  ndn::Name m_routerPrefix;
499  ndn::Name m_syncUserPrefix;
500 
501  ndn::Name m_syncPrefix;
502  ndn::Name m_lsaPrefix;
503 
504  uint32_t m_lsaRefreshTime;
505 
506  uint32_t m_adjLsaBuildInterval;
507  uint32_t m_routingCalcInterval;
508 
509  uint32_t m_faceDatasetFetchTries;
510  ndn::time::seconds m_faceDatasetFetchInterval;
511 
512  ndn::time::seconds m_lsaInterestLifetime;
513  uint32_t m_routerDeadInterval;
514 
515  uint32_t m_interestRetryNumber;
516  uint32_t m_interestResendTime;
517 
518  uint32_t m_infoInterestInterval;
519 
520  int32_t m_hyperbolicState;
521  double m_corR;
522  std::vector<double> m_corTheta;
523 
524  uint32_t m_maxFacesPerPrefix;
525 
526  std::string m_stateFileDir;
527 
528  ndn::time::milliseconds m_syncInterestLifetime;
529 
530  SyncProtocol m_syncProtocol;
531 
533  static const uint64_t SYNC_VERSION;
534 
535  AdjacencyList m_adjl;
536  NamePrefixList m_npl;
537  ndn::security::ValidatorConfig m_validator;
538  ndn::security::ValidatorConfig m_prefixUpdateValidator;
539  ndn::security::SigningInfo m_signingInfo;
540  std::unordered_set<std::string> m_certs;
541  ndn::KeyChain& m_keyChain;
542 };
543 
544 } // namespace nlsr
545 
546 #endif // NLSR_CONF_PARAMETER_HPP
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.
const ndn::time::seconds & getLsaInterestLifetime() const
void setCorTheta(const std::vector< double > &ct)
SyncProtocol getSyncProtocol() const
double getCorR() const
uint32_t getInterestRetryNumber() const
void setSyncInterestLifetime(uint32_t syncInterestLifetime)
const ndn::Name & getRouterName() const
const ndn::Name & getSiteName() const
void setSyncProtocol(SyncProtocol syncProtocol)
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)
std::shared_ptr< ndn::security::Certificate > initializeKey()
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.