24 #include <ndn-cxx/security/signing-helpers.hpp>
30 static std::unique_ptr<ndn::security::CertificateFetcherDirectFetch>
33 auto fetcher = std::make_unique<ndn::security::CertificateFetcherDirectFetch>(face);
34 fetcher->setSendDirectInterestOnly(
true);
39 const std::string& confFileName)
40 : m_confFileName(confFileName)
57 , m_prefixUpdateValidator(std::make_unique<ndn::security::CertificateFetcherDirectFetch>(face))
58 , m_keyChain(keyChain)
71 NLSR_LOG_INFO(
"Hello Interest retry number: " << m_interestRetryNumber);
72 NLSR_LOG_INFO(
"Hello Interest resend second: " << m_interestResendTime);
73 NLSR_LOG_INFO(
"Info Interest interval: " << m_infoInterestInterval);
75 NLSR_LOG_INFO(
"FIB Entry refresh time: " << m_lsaRefreshTime * 2);
78 NLSR_LOG_INFO(
"Max Faces Per Prefix: " << m_maxFacesPerPrefix);
83 for (
auto const& value: m_corTheta) {
90 NLSR_LOG_INFO(
"Adjacency LSA build interval: " << m_adjLsaBuildInterval);
91 NLSR_LOG_INFO(
"Routing calculation interval: " << m_routingCalcInterval);
97 m_network = networkName;
100 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::optional<ndn::security::Certificate>
124 using namespace ndn::security;
127 Identity routerIdentity;
129 routerIdentity = m_keyChain.getPib().getIdentity(m_routerPrefix);
131 catch (
const Pib::Error&) {
132 NLSR_LOG_ERROR(
"Router identity " << m_routerPrefix <<
" not found. "
133 "NLSR is running without security. "
134 "If security is enabled in the configuration, NLSR will not converge.");
137 catch (
const std::invalid_argument& e) {
143 auto instanceName = ndn::Name(m_routerPrefix).append(
"nlsr");
145 m_keyChain.deleteIdentity(m_keyChain.getPib().getIdentity(instanceName));
147 catch (
const Pib::Error&) {
150 catch (
const std::invalid_argument& e) {
152 const std::string exceptionText = e.what();
153 if (exceptionText.find(
"does not match identity") == std::string::npos) {
160 auto key = m_keyChain.createIdentity(instanceName).getDefaultKey();
161 auto cert = m_keyChain.makeCertificate(key, signingByIdentity(routerIdentity));
162 m_keyChain.setDefaultCertificate(key, cert);
164 m_signingInfo = signingByCertificate(cert);
std::optional< ndn::security::Certificate > initializeKey()
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
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.
static std::unique_ptr< ndn::security::CertificateFetcherDirectFetch > makeCertificateFetcher(ndn::Face &face)
@ LSA_REFRESH_TIME_DEFAULT
@ ROUTING_CALC_INTERVAL_DEFAULT
@ MAX_FACES_PER_PREFIX_MIN
@ FACE_DATASET_FETCH_INTERVAL_DEFAULT
@ ADJ_LSA_BUILD_INTERVAL_DEFAULT
@ HYPERBOLIC_STATE_DRY_RUN
@ LSA_INTEREST_LIFETIME_DEFAULT
@ SYNC_INTEREST_LIFETIME_DEFAULT