36 : m_faceSystem(faceSystem)
37 , m_addFace(params.addFace)
38 , m_netmon(params.netmon)
46 std::vector<Rule> rules;
49 for (
const auto& pair : *configSection) {
50 const std::string& key = pair.first;
53 rules.push_back(parseRule(ruleIndex++, value));
57 "Unrecognized option face_system.netdev_bound." + key));
68 for (
size_t i = 0; i < rules.size(); ++i) {
69 const Rule& rule = rules[i];
70 for (
const FaceUri& remote : rule.remotes) {
71 std::string devScheme = remote.
getScheme() +
"+dev";
74 i,
"scheme " + devScheme +
" for " + remote.
toString() +
" is unavailable"));
78 NFD_LOG_DEBUG(
"processConfig: processed " << rules.size() <<
" rules");
81 std::map<Key, shared_ptr<Face>> oldFaces;
82 oldFaces.swap(m_faces);
92 NetdevBound::parseRule(
int index,
const ConfigSection& confRule)
const 96 bool hasWhitelist =
false;
97 bool hasBlacklist =
false;
98 for (
const auto& pair : confRule) {
99 const std::string& key = pair.first;
101 if (key ==
"remote") {
103 rule.remotes.emplace_back(value.get_value<std::string>());
106 BOOST_THROW_EXCEPTION(RuleParseError(index,
"invalid remote FaceUri", ex.what()));
108 if (!rule.remotes.back().isCanonical()) {
109 BOOST_THROW_EXCEPTION(RuleParseError(index,
"remote FaceUri is not canonical"));
112 else if (key ==
"whitelist") {
114 BOOST_THROW_EXCEPTION(RuleParseError(index,
"duplicate whitelist"));
117 rule.netifPredicate.parseWhitelist(value);
119 catch (
const ConfigFile::Error& ex) {
120 BOOST_THROW_EXCEPTION(RuleParseError(index,
"invalid whitelist", ex.what()));
124 else if (key ==
"blacklist") {
126 BOOST_THROW_EXCEPTION(RuleParseError(index,
"duplicate blacklist"));
129 rule.netifPredicate.parseBlacklist(value);
131 catch (
const ConfigFile::Error& ex) {
132 BOOST_THROW_EXCEPTION(RuleParseError(index,
"invalid blacklist", ex.what()));
137 BOOST_THROW_EXCEPTION(RuleParseError(index,
"unrecognized option " + key));
141 if (rule.remotes.empty()) {
142 BOOST_THROW_EXCEPTION(RuleParseError(index,
"remote FaceUri is missing"));
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)
process face_system.netdev_bound config section
std::string toString() const
write as a string
entry point of the face system
ndn security validator_config Rule
boost::optional< const ConfigSection & > OptionalConfigSection
an optional config file section
Copyright (c) 2011-2015 Regents of the University of California.
manages netdev-bound faces
Parameters to ProtocolFactory constructor.
boost::property_tree::ptree ConfigSection
a config file section
NetdevBound(const ProtocolFactoryCtorParams ¶ms, const FaceSystem &faceSystem)
represents the underlying protocol and address used by a Face
bool hasFactoryForScheme(const std::string &scheme) const
context for processing a config section in ProtocolFactory
const std::string & getScheme() const
get scheme (protocol)
#define NFD_LOG_INIT(name)