30 #include "core/logger-factory.hpp" 33 #include <boost/property_tree/info_parser.hpp> 35 #include <ndn-cxx/transport/unix-transport.hpp> 36 #include <ndn-cxx/transport/tcp-transport.hpp> 44 : m_configFile(configFile)
45 , m_keyChain(keyChain)
50 : m_configSection(config)
51 , m_keyChain(keyChain)
70 m_ribManager.reset(
new RibManager(*m_dispatcher, *m_face, m_keyChain));
72 ConfigFile config([] (
const std::string& filename,
const std::string& sectionName,
76 if (sectionName !=
"rib" || sectionName ==
"log") {
84 m_ribManager->setConfigFile(config);
87 if (!m_configFile.empty()) {
88 config.parse(m_configFile,
true);
89 config.parse(m_configFile,
false);
92 config.parse(m_configSection,
true, INTERNAL_CONFIG);
93 config.parse(m_configSection,
false, INTERNAL_CONFIG);
96 m_ribManager->registerWithNfd();
97 m_ribManager->enableLocalFields();
101 Service::initializeLogging()
104 LoggerFactory::getInstance().setConfigFile(config);
106 if (!m_configFile.empty()) {
107 config.
parse(m_configFile,
true);
108 config.
parse(m_configFile,
false);
111 config.
parse(m_configSection,
true, INTERNAL_CONFIG);
112 config.
parse(m_configSection,
false, INTERNAL_CONFIG);
116 shared_ptr<ndn::Transport>
117 Service::getLocalNfdTransport()
121 if (!m_configFile.empty()) {
124 boost::property_tree::read_info(m_configFile, config);
127 config = m_configSection;
129 if (config.get_child_optional(
"face_system.unix")) {
132 auto&& socketPath = config.get<std::string>(
"face_system.unix.path",
"/var/run/nfd.sock");
135 return make_shared<ndn::UnixTransport>(socketPath);
137 else if (config.get_child_optional(
"face_system.tcp") &&
138 config.get<std::string>(
"face_system.tcp.listen",
"yes") ==
"yes") {
141 auto&& port = config.get<std::string>(
"face_system.tcp.port",
"6363");
144 return make_shared<ndn::TcpTransport>(
"localhost", port);
147 BOOST_THROW_EXCEPTION(
Error(
"No transport is available to communicate with NFD"));
static const std::string INTERNAL_CONFIG
represents a dispatcher on server side of NFD Management protocol
configuration file parsing utility
The packet signing interface.
detail::SimulatorIo & getGlobalIoService()
void initialize()
Perform initialization of NFD-RIB instance.
Service(const std::string &configFile, ndn::KeyChain &keyChain)
create NFD-RIB service
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.
Provide a communication channel with local or remote NDN forwarder.
boost::property_tree::ptree ConfigSection
static void ignoreUnknownSection(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
void parse(const std::string &filename, bool isDryRun)