29 #include "core/logger-factory.hpp" 48 Nfd::Nfd(
const std::string& configFile, ndn::KeyChain& keyChain)
49 : m_configFile(configFile)
50 , m_keyChain(keyChain)
56 : m_configSection(config)
57 , m_keyChain(keyChain)
76 initializeManagement();
78 m_forwarder->getFaceTable().addReserved(make_shared<NullFace>(),
FACEID_NULL);
79 m_forwarder->getFaceTable().addReserved(make_shared<NullFace>(
FaceUri(
"contentstore://")),
89 NFD_LOG_INFO(
"Network change detected, reloading face section of the config file...");
90 this->reloadConfigFileFaceSection();
96 Nfd::initializeLogging()
99 LoggerFactory::getInstance().setConfigFile(config);
101 if (!m_configFile.empty()) {
102 config.
parse(m_configFile,
true);
103 config.
parse(m_configFile,
false);
106 config.
parse(m_configSection,
true, INTERNAL_CONFIG);
107 config.
parse(m_configSection,
false, INTERNAL_CONFIG);
118 if (sectionName ==
"rib" || sectionName ==
"log") {
128 Nfd::initializeManagement()
130 m_internalFace = make_shared<InternalFace>();
132 m_fibManager.reset(
new FibManager(m_forwarder->getFib(),
134 m_internalFace, m_keyChain));
136 m_faceManager.reset(
new FaceManager(m_forwarder->getFaceTable(), m_internalFace, m_keyChain));
139 m_internalFace, m_keyChain));
141 m_statusServer.reset(
new StatusServer(m_internalFace, *m_forwarder, m_keyChain));
147 m_forwarder->getPit(),
148 m_forwarder->getFib(),
149 m_forwarder->getStrategyChoice(),
150 m_forwarder->getMeasurements());
153 m_internalFace->getValidator().setConfigFile(config);
157 m_faceManager->setConfigFile(config);
160 if (!m_configFile.empty()) {
161 config.
parse(m_configFile,
true);
162 config.
parse(m_configFile,
false);
165 config.
parse(m_configSection,
true, INTERNAL_CONFIG);
166 config.
parse(m_configSection,
false, INTERNAL_CONFIG);
169 tablesConfig.ensureTablesAreConfigured();
172 shared_ptr<fib::Entry> entry = m_forwarder->getFib().insert(
"/localhost/nfd").first;
173 entry->addNextHop(m_internalFace, 0);
189 m_forwarder->getPit(),
190 m_forwarder->getFib(),
191 m_forwarder->getStrategyChoice(),
192 m_forwarder->getMeasurements());
196 m_internalFace->getValidator().setConfigFile(config);
197 m_faceManager->setConfigFile(config);
199 if (!m_configFile.empty()) {
200 config.
parse(m_configFile,
false);
203 config.
parse(m_configSection,
false, INTERNAL_CONFIG);
208 Nfd::reloadConfigFileFaceSection()
212 m_faceManager->setConfigFile(config);
214 if (!m_configFile.empty()) {
215 config.
parse(m_configFile,
false);
218 config.
parse(m_configSection,
false, INTERNAL_CONFIG);
const FaceId FACEID_INTERNAL_FACE
identifies the InternalFace used in management
Nfd(const std::string &configFile, ndn::KeyChain &keyChain)
Create NFD instance using absolute or relative path to configFile.
static const std::string INTERNAL_CONFIG
represents the underlying protocol and address used by a Face
void setConfigFile(ConfigFile &configFile)
static void ignoreRibAndLogSections(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
#define NFD_LOG_INFO(expression)
void reloadConfigFile()
Reload configuration file and apply update (if any)
static void throwErrorOnUnknownSection(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
Copyright (c) 2011-2015 Regents of the University of California.
Signal< NetworkMonitor > onNetworkStateChanged
boost::property_tree::ptree ConfigSection
EventId schedule(const time::nanoseconds &after, const std::function< void()> &event)
schedule an event
shared_ptr< Face > getFace(FaceId id) const
get existing Face
const FaceId FACEID_NULL
identifies the NullFace that drops every packet
void initialize()
Perform initialization of NFD instance After initialization, NFD instance can be started by invoking ...
#define NFD_LOG_INIT(name)
const FaceId FACEID_CONTENT_STORE
identifies a packet comes from the ContentStore, in LocalControlHeader incomingFaceId ...
static void ignoreUnknownSection(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
boost::asio::io_service & getGlobalIoService()
void parse(const std::string &filename, bool isDryRun)
void setConfigFile(ConfigFile &configFile)