-
Notifications
You must be signed in to change notification settings - Fork 36
/
conf-parameter.hpp
547 lines (448 loc) · 9.99 KB
/
conf-parameter.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
* This file is part of NLSR (Named-data Link State Routing).
* See AUTHORS.md for complete list of NLSR authors and contributors.
*
* NLSR is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NLSR_CONF_PARAMETER_HPP
#define NLSR_CONF_PARAMETER_HPP
#include "common.hpp"
#include "test-access-control.hpp"
#include "adjacency-list.hpp"
#include "name-prefix-list.hpp"
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/security/validator-config.hpp>
#include <ndn-cxx/security/certificate-fetcher-direct-fetch.hpp>
#include <optional>
namespace nlsr {
enum class SyncProtocol {
CHRONOSYNC,
PSYNC,
SVS,
};
enum {
LSA_REFRESH_TIME_MIN = 240,
LSA_REFRESH_TIME_DEFAULT = 1800,
LSA_REFRESH_TIME_MAX = 7200
};
enum {
LSA_INTEREST_LIFETIME_MIN = 1,
LSA_INTEREST_LIFETIME_DEFAULT = 4,
LSA_INTEREST_LIFETIME_MAX = 60
};
enum {
ADJ_LSA_BUILD_INTERVAL_MIN = 5,
ADJ_LSA_BUILD_INTERVAL_DEFAULT = 10,
ADJ_LSA_BUILD_INTERVAL_MAX = 30
};
enum {
ROUTING_CALC_INTERVAL_MIN = 0,
ROUTING_CALC_INTERVAL_DEFAULT = 15,
ROUTING_CALC_INTERVAL_MAX = 15
};
enum {
FACE_DATASET_FETCH_TRIES_MIN = 1,
FACE_DATASET_FETCH_TRIES_MAX = 10,
FACE_DATASET_FETCH_TRIES_DEFAULT = 3
};
enum {
FACE_DATASET_FETCH_INTERVAL_MIN = 1800,
FACE_DATASET_FETCH_INTERVAL_MAX = 5400,
FACE_DATASET_FETCH_INTERVAL_DEFAULT = 3600
};
enum {
HELLO_RETRIES_MIN = 1,
HELLO_RETRIES_DEFAULT = 3,
HELLO_RETRIES_MAX = 15
};
enum {
HELLO_TIMEOUT_MIN = 1,
HELLO_TIMEOUT_DEFAULT = 1,
HELLO_TIMEOUT_MAX = 15
};
enum {
HELLO_INTERVAL_MIN = 30,
HELLO_INTERVAL_DEFAULT = 60,
HELLO_INTERVAL_MAX =90
};
enum {
MAX_FACES_PER_PREFIX_MIN = 0,
MAX_FACES_PER_PREFIX_DEFAULT = 0,
MAX_FACES_PER_PREFIX_MAX = 60
};
enum HyperbolicState {
HYPERBOLIC_STATE_OFF = 0,
HYPERBOLIC_STATE_ON = 1,
HYPERBOLIC_STATE_DRY_RUN = 2,
HYPERBOLIC_STATE_DEFAULT = 0
};
enum {
SYNC_INTEREST_LIFETIME_MIN = 1000,
SYNC_INTEREST_LIFETIME_DEFAULT = 60000,
SYNC_INTEREST_LIFETIME_MAX = 120000,
};
/*! \brief A class to house all the configuration parameters for NLSR.
*
* This class is conceptually a singleton (but not mechanically) which
* is just a collection of attributes that serve as a
* separation-of-data for NLSR's configuration variables. NLSR refers
* to an instance of this class for all its configuration
* parameters. This object is typically populated by a
* ConfFileProcessor reading a configuration file.
*
* \sa nlsr::ConfFileProcessor
*/
class ConfParameter
{
public:
ConfParameter(ndn::Face& face, ndn::KeyChain& keyChain,
const std::string& confFileName = "nlsr.conf");
const std::string&
getConfFileName()
{
return m_confFileName;
}
void
setNetwork(const ndn::Name& networkName);
const ndn::Name&
getNetwork() const
{
return m_network;
}
void
setRouterName(const ndn::Name& routerName)
{
m_routerName = routerName;
}
const ndn::Name&
getRouterName() const
{
return m_routerName;
}
void
setSiteName(const ndn::Name& siteName)
{
m_siteName = siteName;
}
const ndn::Name&
getSiteName() const
{
return m_siteName;
}
void
buildRouterAndSyncUserPrefix()
{
m_routerPrefix = m_network;
m_routerPrefix.append(m_siteName);
m_routerPrefix.append(m_routerName);
m_syncUserPrefix = m_lsaPrefix;
m_syncUserPrefix.append(m_siteName);
m_syncUserPrefix.append(m_routerName);
}
const ndn::Name&
getRouterPrefix() const
{
return m_routerPrefix;
}
const ndn::Name&
getSyncUserPrefix() const
{
return m_syncUserPrefix;
}
const ndn::Name&
getSyncPrefix() const
{
return m_syncPrefix;
}
const ndn::Name&
getLsaPrefix() const
{
return m_lsaPrefix;
}
void
setLsaRefreshTime(uint32_t lrt)
{
m_lsaRefreshTime = lrt;
}
SyncProtocol
getSyncProtocol() const
{
return m_syncProtocol;
}
void
setSyncProtocol(SyncProtocol syncProtocol)
{
m_syncProtocol = syncProtocol;
}
uint32_t
getLsaRefreshTime() const
{
return m_lsaRefreshTime;
}
void
setLsaInterestLifetime(const ndn::time::seconds& lifetime)
{
m_lsaInterestLifetime = lifetime;
}
const ndn::time::seconds&
getLsaInterestLifetime() const
{
return m_lsaInterestLifetime;
}
void
setAdjLsaBuildInterval(uint32_t interval)
{
m_adjLsaBuildInterval = interval;
}
uint32_t
getAdjLsaBuildInterval() const
{
return m_adjLsaBuildInterval;
}
void
setRoutingCalcInterval(uint32_t interval)
{
m_routingCalcInterval = interval;
}
uint32_t
getRoutingCalcInterval() const
{
return m_routingCalcInterval;
}
void
setRouterDeadInterval(uint32_t rdt)
{
m_routerDeadInterval = rdt;
}
uint32_t
getRouterDeadInterval() const
{
return m_routerDeadInterval;
}
void
setFaceDatasetFetchTries(uint32_t count)
{
m_faceDatasetFetchTries = count;
}
uint32_t
getFaceDatasetFetchTries() const
{
return m_faceDatasetFetchTries;
}
void
setFaceDatasetFetchInterval(uint32_t interval)
{
m_faceDatasetFetchInterval = ndn::time::seconds(interval);
}
const ndn::time::seconds
getFaceDatasetFetchInterval() const
{
return m_faceDatasetFetchInterval;
}
void
setInterestRetryNumber(uint32_t irn)
{
m_interestRetryNumber = irn;
}
uint32_t
getInterestRetryNumber() const
{
return m_interestRetryNumber;
}
void
setInterestResendTime(uint32_t irt)
{
m_interestResendTime = irt;
}
uint32_t
getInterestResendTime() const
{
return m_interestResendTime;
}
uint32_t
getInfoInterestInterval() const
{
return m_infoInterestInterval;
}
void
setInfoInterestInterval(uint32_t iii)
{
m_infoInterestInterval = iii;
}
void
setHyperbolicState(int32_t ihc)
{
m_hyperbolicState = ihc;
}
int32_t
getHyperbolicState() const
{
return m_hyperbolicState;
}
bool
setCorR(double cr)
{
if ( cr >= 0 ) {
m_corR = cr;
return true;
}
return false;
}
double
getCorR() const
{
return m_corR;
}
void
setCorTheta(const std::vector<double>& ct)
{
m_corTheta = ct;
}
std::vector<double>
getCorTheta() const
{
return m_corTheta;
}
void
setMaxFacesPerPrefix(uint32_t mfpp)
{
m_maxFacesPerPrefix = mfpp;
}
uint32_t
getMaxFacesPerPrefix() const
{
return m_maxFacesPerPrefix;
}
void
setStateFileDir(const std::string& ssfd)
{
m_stateFileDir = ssfd;
}
const std::string&
getStateFileDir() const
{
return m_stateFileDir;
}
void
setConfFileNameDynamic(const std::string& confFileDynamic)
{
m_confFileNameDynamic = confFileDynamic;
}
const std::string&
getConfFileNameDynamic() const
{
return m_confFileNameDynamic;
}
void
setSyncInterestLifetime(uint32_t syncInterestLifetime)
{
m_syncInterestLifetime = ndn::time::milliseconds(syncInterestLifetime);
}
const ndn::time::milliseconds&
getSyncInterestLifetime() const
{
return m_syncInterestLifetime;
}
AdjacencyList&
getAdjacencyList()
{
return m_adjl;
}
NamePrefixList&
getNamePrefixList()
{
return m_npl;
}
ndn::security::ValidatorConfig&
getValidator()
{
return m_validator;
}
ndn::security::ValidatorConfig&
getPrefixUpdateValidator()
{
return m_prefixUpdateValidator;
}
const ndn::security::SigningInfo&
getSigningInfo() const
{
return m_signingInfo;
}
void
addCertPath(const std::string& certPath)
{
m_certs.insert(certPath);
}
const std::unordered_set<std::string>&
getIdCerts() const
{
return m_certs;
}
const ndn::KeyChain&
getKeyChain() const
{
return m_keyChain;
}
std::optional<ndn::security::Certificate>
initializeKey();
void
loadCertToValidator(const ndn::security::Certificate& cert);
/*! \brief Dump the current state of all attributes to the log.
*/
void
writeLog();
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
std::string m_confFileName;
std::string m_confFileNameDynamic;
private:
ndn::Name m_routerName;
ndn::Name m_siteName;
ndn::Name m_network;
ndn::Name m_routerPrefix;
ndn::Name m_syncUserPrefix;
ndn::Name m_syncPrefix;
ndn::Name m_lsaPrefix;
uint32_t m_lsaRefreshTime;
uint32_t m_adjLsaBuildInterval;
uint32_t m_routingCalcInterval;
uint32_t m_faceDatasetFetchTries;
ndn::time::seconds m_faceDatasetFetchInterval;
ndn::time::seconds m_lsaInterestLifetime;
uint32_t m_routerDeadInterval;
uint32_t m_interestRetryNumber;
uint32_t m_interestResendTime;
uint32_t m_infoInterestInterval;
int32_t m_hyperbolicState;
double m_corR;
std::vector<double> m_corTheta;
uint32_t m_maxFacesPerPrefix;
std::string m_stateFileDir;
ndn::time::milliseconds m_syncInterestLifetime;
SyncProtocol m_syncProtocol = SyncProtocol::PSYNC;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
// must be incremented when breaking changes are made to sync
static constexpr uint64_t SYNC_VERSION = 11;
AdjacencyList m_adjl;
NamePrefixList m_npl;
ndn::security::ValidatorConfig m_validator;
ndn::security::ValidatorConfig m_prefixUpdateValidator;
ndn::security::SigningInfo m_signingInfo;
std::unordered_set<std::string> m_certs;
ndn::KeyChain& m_keyChain;
};
} // namespace nlsr
#endif // NLSR_CONF_PARAMETER_HPP