41 : m_faceTable(faceTable)
42 , m_netmon(std::move(netmon))
44 auto pfCtorParams = this->makePFCtorParams();
50 m_netdevBound = make_unique<NetdevBound>(pfCtorParams, *
this);
54 FaceSystem::makePFCtorParams()
56 auto addFace = [
this] (
auto face) { m_faceTable.
add(std::move(face)); };
57 return {addFace, m_netmon};
62 std::set<const ProtocolFactory*>
65 std::set<const ProtocolFactory*> factories;
66 for (
const auto& p : m_factories) {
67 factories.insert(p.second.get());
75 auto found = m_factories.find(
id);
76 return found == m_factories.end() ? nullptr : found->second.get();
82 auto found = m_factoryByScheme.find(scheme);
83 return found == m_factoryByScheme.end() ? nullptr : found->second;
89 return m_factoryByScheme.count(scheme) > 0;
96 processConfig(std::forward<decltype(args)>(args)...);
101 FaceSystem::processConfig(
const ConfigSection& configSection,
bool isDryRun,
const std::string&)
103 ConfigContext context;
104 context.isDryRun = isDryRun;
107 auto generalSection = configSection.get_child_optional(
CFGSEC_GENERAL);
108 if (generalSection) {
109 for (
const auto& pair : *generalSection) {
110 const std::string& key = pair.first;
111 if (key ==
"enable_congestion_marking") {
121 for (
const auto& [sectionName, factory] : m_factories) {
122 std::set<std::string> oldProvidedSchemes = factory->getProvidedSchemes();
123 factory->processConfig(configSection.get_child_optional(sectionName), context);
126 for (
const auto& scheme : factory->getProvidedSchemes()) {
127 m_factoryByScheme[scheme] = factory.get();
128 if (oldProvidedSchemes.erase(scheme) == 0) {
130 " provides " << scheme <<
" FaceUri scheme");
133 for (
const auto& scheme : oldProvidedSchemes) {
134 m_factoryByScheme.erase(scheme);
136 " no longer provides " << scheme <<
" FaceUri scheme");
143 m_netdevBound->processConfig(netdevBoundSection, context);
146 std::set<std::string> seenSections;
147 for (
const auto& pair : configSection) {
148 const std::string& sectionName = pair.first;
151 if (!seenSections.insert(sectionName).second) {
152 NDN_THROW(ConfigFile::Error(
"Duplicate section " +
CFGSEC_FACESYSTEM +
"." + sectionName));
156 m_factories.count(sectionName) > 0) {
160 NDN_THROW(ConfigFile::Error(
"Unrecognized option " +
CFGSEC_FACESYSTEM +
"." + sectionName));
Configuration file parsing utility.
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
Setup notification of configuration file sections.
static bool parseYesNo(const ConfigSection &node, const std::string &key, const std::string §ionName)
Parse a config option that can be either "yes" or "no".
void add(shared_ptr< Face > face)
Add a face.
std::set< const ProtocolFactory * > listProtocolFactories() const
Returns all ProtocolFactory objects owned by the face system.
ProtocolFactory * getFactoryById(const std::string &id) const
FaceSystem(FaceTable &faceTable, shared_ptr< ndn::net::NetworkMonitor > netmon)
bool hasFactoryForScheme(const std::string &scheme) const
ProtocolFactory * getFactoryByScheme(const std::string &scheme) const
void setConfigFile(ConfigFile &configFile)
Register handler for the face_system section of NFD's configuration file.
Provides support for an underlying protocol.
static std::set< std::string > listRegistered()
Get all registered protocol factory IDs.
static unique_ptr< ProtocolFactory > create(const std::string &id, const CtorParams ¶ms)
Create a protocol factory instance.
#define NFD_LOG_INIT(name)
const std::string CFGSEC_FACESYSTEM
const std::string CFGSEC_GENERAL
const std::string CFGSEC_GENERAL_FQ
const std::string CFGSEC_NETDEVBOUND
boost::property_tree::ptree ConfigSection
A configuration file section.
Parameters to ProtocolFactory constructor.