shared_ptr<ndn::Transport> Nrd::getLocalNfdTransport() { ConfigSection config; if (!m_configFile.empty()) { // Any format errors should have been caught already // If error is thrown at this point, it is development error boost::property_tree::read_info(m_configFile, config); } else config = m_configSection; if (config.get_child_optional("face_system.unix")) { // unix socket enabled auto&& socketPath = config.get<std::string>("face_system.unix.path", "/var/run/nfd.sock"); // default socketPath should be the same as in FaceManager::processSectionUnix return make_shared<ndn::UnixTransport>(socketPath); } else if (config.get_child_optional("face_system.tcp") && config.get<std::string>("face_system.tcp.listen", "yes") == "yes") { // tcp is enabled auto&& port = config.get<std::string>("face_system.tcp.port", "6363"); // default port should be the same as in FaceManager::processSectionTcp return make_shared<ndn::TcpTransport>("localhost", port); } else { throw Error("No transport is available to communicate with NFD"); } }
static void onConfig(const ConfigSection& section, bool isDryRun, const std::string&) { // log // { // ; default_level specifies the logging level for modules // ; that are not explicitly named. All debugging levels // ; listed above the selected value are enabled. // // default_level INFO // // ; You may also override the default for specific modules: // // FibManager DEBUG // Forwarder WARN // } auto defaultLevel = ndn::util::LogLevel::INFO; auto item = section.get_child_optional("default_level"); if (item) { defaultLevel = parseLogLevel(*item, "default_level"); } if (!isDryRun) { // default_level applies only to NFD loggers ndn::util::Logging::setLevel("nfd.*", defaultLevel); } for (const auto& i : section) { if (i.first == "default_level") { // do nothing } else { auto level = parseLogLevel(i.second, i.first); if (!isDryRun) { if (i.first.find('.') == std::string::npos) // backward compat: assume unqualified logger names refer to NFD loggers ndn::util::Logging::setLevel("nfd." + i.first, level); else ndn::util::Logging::setLevel(i.first, level); } } } }