35 : m_faceSystem(faceSystem)
36 , m_addFace(params.addFace)
37 , m_netmon(params.netmon)
45 std::vector<Rule> rules;
48 for (
const auto& [key, value] : *configSection) {
50 rules.push_back(parseRule(ruleIndex++, value));
53 NDN_THROW(
ConfigFile::Error(
"Unrecognized option face_system.netdev_bound." + key));
64 for (
size_t i = 0; i < rules.size(); ++i) {
65 const Rule& rule = rules[i];
66 for (
const FaceUri& remote : rule.remotes) {
67 std::string devScheme = remote.getScheme() +
"+dev";
70 remote.toString() +
" is unavailable"));
74 NFD_LOG_DEBUG(
"processConfig: processed " << rules.size() <<
" rules");
77 std::map<Key, shared_ptr<Face>> oldFaces;
78 oldFaces.swap(m_faces);
88 NetdevBound::parseRule(
int index,
const ConfigSection& confRule)
const
92 bool hasWhitelist =
false;
93 bool hasBlacklist =
false;
94 for (
const auto& [key, value] : confRule) {
95 if (key ==
"remote") {
97 rule.remotes.emplace_back(value.get_value<std::string>());
99 catch (
const FaceUri::Error&) {
100 NDN_THROW_NESTED(RuleParseError(index,
"invalid remote FaceUri"));
102 if (!rule.remotes.back().isCanonical()) {
103 NDN_THROW(RuleParseError(index,
"remote FaceUri is not canonical"));
106 else if (key ==
"whitelist") {
108 NDN_THROW(RuleParseError(index,
"duplicate whitelist"));
111 rule.netifPredicate.parseWhitelist(value);
113 catch (
const ConfigFile::Error&) {
114 NDN_THROW_NESTED(RuleParseError(index,
"invalid whitelist"));
118 else if (key ==
"blacklist") {
120 NDN_THROW(RuleParseError(index,
"duplicate blacklist"));
123 rule.netifPredicate.parseBlacklist(value);
125 catch (
const ConfigFile::Error&) {
126 NDN_THROW_NESTED(RuleParseError(index,
"invalid blacklist"));
131 NDN_THROW(RuleParseError(index,
"unrecognized option " + key));
135 if (rule.remotes.empty()) {
136 NDN_THROW(RuleParseError(index,
"remote FaceUri is missing"));
Context for processing a config section in ProtocolFactory.
Entry point of NFD's face system.
bool hasFactoryForScheme(const std::string &scheme) const
NetdevBound(const ProtocolFactoryCtorParams ¶ms, const FaceSystem &faceSystem)
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)
Process face_system.netdev_bound config section.
#define NFD_LOG_INIT(name)
boost::optional< const ConfigSection & > OptionalConfigSection
An optional configuration file section.
boost::property_tree::ptree ConfigSection
A configuration file section.
Parameters to ProtocolFactory constructor.