29 const uint64_t ConfParameter::SYNC_VERSION = 9;
31 static std::unique_ptr<ndn::security::CertificateFetcherDirectFetch>
34 auto fetcher = std::make_unique<ndn::security::CertificateFetcherDirectFetch>(face);
35 fetcher->setSendDirectInterestOnly(
true);
40 const std::string& confFileName)
41 : m_confFileName(confFileName)
59 , m_prefixUpdateValidator(std::make_unique<
ndn::security::CertificateFetcherDirectFetch>(face))
60 , m_keyChain(keyChain)
73 NLSR_LOG_INFO(
"Hello Interest retry number: " << m_interestRetryNumber);
74 NLSR_LOG_INFO(
"Hello Interest resend second: " << m_interestResendTime);
75 NLSR_LOG_INFO(
"Info Interest interval: " << m_infoInterestInterval);
77 NLSR_LOG_INFO(
"FIB Entry refresh time: " << m_lsaRefreshTime * 2);
80 NLSR_LOG_INFO(
"Max Faces Per Prefix: " << m_maxFacesPerPrefix);
85 for (
auto const& value: m_corTheta) {
92 NLSR_LOG_INFO(
"Adjacency LSA build interval: " << m_adjLsaBuildInterval);
93 NLSR_LOG_INFO(
"Routing calculation interval: " << m_routingCalcInterval);
99 m_network = networkName;
101 m_syncPrefix.append(
"localhop");
102 m_syncPrefix.append(m_network);
103 m_syncPrefix.append(
"nlsr");
104 m_syncPrefix.append(
"sync");
105 m_syncPrefix.appendVersion(SYNC_VERSION);
107 m_lsaPrefix.append(
"localhop");
108 m_lsaPrefix.append(m_network);
109 m_lsaPrefix.append(
"nlsr");
110 m_lsaPrefix.append(
"LSA");
117 m_validator.loadAnchor(
"Authoritative-Certificate", ndn::security::Certificate(cert));
118 m_prefixUpdateValidator.loadAnchor(
"Authoritative-Certificate", ndn::security::Certificate(cert));
121 std::shared_ptr<ndn::security::Certificate>
126 ndn::Name nlsrInstanceName(m_routerPrefix);
127 nlsrInstanceName.append(
"nlsr");
130 m_keyChain.deleteIdentity(m_keyChain.getPib().getIdentity(nlsrInstanceName));
132 catch (
const std::exception& e) {
136 ndn::security::Identity nlsrInstanceIdentity;
138 nlsrInstanceIdentity = m_keyChain.createIdentity(nlsrInstanceName);
140 catch (
const std::exception& e) {
142 NLSR_LOG_ERROR(
"Unable to create identity, NLSR will run without security!");
143 NLSR_LOG_ERROR(
"Can be ignored if running in non-production environments.");
146 auto certificate = std::make_shared<ndn::security::Certificate>();
147 auto nlsrInstanceKey = nlsrInstanceIdentity.getDefaultKey();
148 ndn::Name certificateName = nlsrInstanceKey.getName();
149 certificateName.append(
"NA");
150 certificateName.appendVersion();
152 certificate->setName(certificateName);
155 certificate->setContentType(ndn::tlv::ContentType_Key);
156 certificate->setFreshnessPeriod(365_days);
159 certificate->setContent(nlsrInstanceKey.getPublicKey().data(),
160 nlsrInstanceKey.getPublicKey().size());
163 ndn::SignatureInfo signatureInfo;
164 signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(ndn::time::system_clock::TimePoint(),
165 ndn::time::system_clock::now()
169 m_keyChain.sign(*certificate,
170 ndn::security::SigningInfo(m_keyChain.getPib().getIdentity(m_routerPrefix))
171 .setSignatureInfo(signatureInfo));
173 catch (
const std::exception& e) {
174 NLSR_LOG_ERROR(
"Router's " << e.what() <<
", NLSR is running without security. " <<
175 "If security is enabled in the configuration, NLSR will not converge.");
179 m_signingInfo = ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_ID,
void writeLog()
Dump the current state of all attributes to the log.
uint32_t getRouterDeadInterval() const
void loadCertToValidator(const ndn::security::Certificate &cert)
ConfParameter(ndn::Face &face, ndn::KeyChain &keyChain, const std::string &confFileName="nlsr.conf")
const ndn::time::seconds & getLsaInterestLifetime() const
std::shared_ptr< ndn::security::Certificate > initializeKey()
void setNetwork(const ndn::Name &networkName)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
#define NLSR_LOG_DEBUG(x)
#define INIT_LOGGER(name)
#define NLSR_LOG_ERROR(x)
#define NLSR_LOG_TRACE(x)
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California,...
@ SYNC_INTEREST_LIFETIME_DEFAULT
static std::unique_ptr< ndn::security::CertificateFetcherDirectFetch > makeCertificateFetcher(ndn::Face &face)
@ ROUTING_CALC_INTERVAL_DEFAULT
@ LSA_REFRESH_TIME_DEFAULT
@ FACE_DATASET_FETCH_INTERVAL_DEFAULT
@ ADJ_LSA_BUILD_INTERVAL_DEFAULT
@ LSA_INTEREST_LIFETIME_DEFAULT
@ HYPERBOLIC_STATE_DRY_RUN
@ SYNC_PROTOCOL_CHRONOSYNC
@ MAX_FACES_PER_PREFIX_MIN