51 : m_keyChain(keyChain)
55 Interest::setAutoCheckParametersDigest(
false);
58 Nfd::Nfd(
const std::string& configFile, ndn::KeyChain& keyChain)
61 m_configFile = configFile;
67 m_configSection = config;
80 m_faceTable = make_unique<FaceTable>();
84 m_faceSystem = make_unique<face::FaceSystem>(*m_faceTable, m_netmon);
85 m_forwarder = make_unique<Forwarder>(*m_faceTable);
87 initializeManagement();
91 m_netmon->onNetworkStateChanged.connect([
this] {
94 m_reloadConfigEvent =
getScheduler().schedule(5_s, [
this] {
95 NFD_LOG_INFO(
"Network change detected, reloading face section of the config file...");
96 reloadConfigFileFaceSection();
102 Nfd::configureLogging()
107 if (!m_configFile.empty()) {
108 config.parse(m_configFile,
true);
109 config.parse(m_configFile,
false);
123 if (sectionName ==
"rib" || sectionName ==
"log") {
133 Nfd::initializeManagement()
138 m_dispatcher = make_unique<ndn::mgmt::Dispatcher>(*m_internalClientFace, m_keyChain);
141 m_forwarderStatusManager = make_unique<ForwarderStatusManager>(*m_forwarder, *m_dispatcher);
142 m_faceManager = make_unique<FaceManager>(*m_faceSystem, *m_dispatcher, *m_authenticator);
143 m_fibManager = make_unique<FibManager>(m_forwarder->getFib(), *m_faceTable,
144 *m_dispatcher, *m_authenticator);
145 m_csManager = make_unique<CsManager>(m_forwarder->getCs(), m_forwarder->getCounters(),
146 *m_dispatcher, *m_authenticator);
147 m_strategyChoiceManager = make_unique<StrategyChoiceManager>(m_forwarder->getStrategyChoice(),
148 *m_dispatcher, *m_authenticator);
153 m_forwarder->setConfigFile(config);
155 TablesConfigSection tablesConfig(*m_forwarder);
156 tablesConfig.setConfigFile(config);
158 m_authenticator->setConfigFile(config);
159 m_faceSystem->setConfigFile(config);
162 if (!m_configFile.empty()) {
163 config.parse(m_configFile,
true);
164 config.parse(m_configFile,
false);
171 tablesConfig.ensureConfigured();
174 Name topPrefix(
"/localhost/nfd");
175 fib::Entry* entry = m_forwarder->getFib().insert(topPrefix).first;
176 m_forwarder->getFib().addOrUpdateNextHop(*entry, *m_internalFace, 0);
177 m_dispatcher->addTopPrefix(topPrefix,
false);
188 m_forwarder->setConfigFile(config);
193 m_authenticator->setConfigFile(config);
194 m_faceSystem->setConfigFile(config);
196 if (!m_configFile.empty()) {
197 config.
parse(m_configFile,
false);
205 Nfd::reloadConfigFileFaceSection()
209 m_faceSystem->setConfigFile(config);
211 if (!m_configFile.empty()) {
212 config.parse(m_configFile,
false);
static shared_ptr< CommandAuthenticator > create()
Configuration file parsing utility.
static void throwErrorOnUnknownSection(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
void parse(const std::string &filename, bool isDryRun)
static void ignoreUnknownSection(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
Class representing the NFD instance.
void initialize()
Perform initialization of NFD instance.
Nfd(const std::string &configFile, ndn::KeyChain &keyChain)
Create NFD instance using an absolute or relative path to a configuration file.
void reloadConfigFile()
Reload configuration file and apply updates (if any).
Handles the tables configuration file section.
void setConfigFile(ConfigFile &configFile)
#define NFD_LOG_INIT(name)
std::tuple< shared_ptr< Face >, shared_ptr< ndn::Face > > makeInternalFace(ndn::KeyChain &clientKeyChain)
Make a pair of forwarder-side face and client-side face that are connected to each other.
constexpr FaceId FACEID_NULL
Identifies the NullFace that drops every packet.
constexpr FaceId FACEID_CONTENT_STORE
Identifies a packet comes from the ContentStore.
constexpr FaceId FACEID_INTERNAL_FACE
Identifies the InternalFace used in management.
shared_ptr< Face > makeNullFace(const FaceUri &uri)
Returns a Face that has no underlying transport and drops every packet.
void setConfigFile(ConfigFile &config)
void setConfigFile(ConfigFile &config)
ndn::Scheduler & getScheduler()
Returns the global Scheduler instance for the calling thread.
boost::property_tree::ptree ConfigSection
A configuration file section.
const std::string INTERNAL_CONFIG
static void ignoreRibAndLogSections(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
boost::asio::io_context & getGlobalIoService()
Returns the global io_context instance for the calling thread.