25 #ifndef NDN_SECURITY_CONF_RULE_HPP
26 #define NDN_SECURITY_CONF_RULE_HPP
36 template<
class Packet>
41 Rule(
const std::string&
id)
60 m_filters.push_back(filter);
66 m_checkers.push_back(checker);
72 if (m_filters.empty())
75 for (FilterList::iterator it = m_filters.begin();
76 it != m_filters.end(); it++)
78 if (!(*it)->match(packet))
95 template<
class Val
idatedCallback,
class Val
idationFailureCallback>
98 const ValidatedCallback& onValidated,
99 const ValidationFailureCallback& onValidationFailed)
101 bool hasPendingResult =
false;
102 for (CheckerList::iterator it = m_checkers.begin(); it != m_checkers.end(); it++) {
103 int8_t result = (*it)->check(packet);
105 onValidated(packet.shared_from_this());
108 else if (result == 0)
109 hasPendingResult =
true;
111 if (hasPendingResult) {
115 onValidationFailed(packet.shared_from_this(),
"Packet cannot pass any checkers.");
121 typedef std::vector<shared_ptr<Filter>> FilterList;
122 typedef std::vector<shared_ptr<Checker>> CheckerList;
125 FilterList m_filters;
126 CheckerList m_checkers;
133 #endif // NDN_SECURITY_CONF_RULE_HPP
Copyright (c) 2013-2016 Regents of the University of California.
const std::string & getId()
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
bool match(const Packet &packet)
void addFilter(const shared_ptr< Filter > &filter)
Rule(const std::string &id)
void addChecker(const shared_ptr< Checker > &checker)
int8_t check(const Packet &packet, const ValidatedCallback &onValidated, const ValidationFailureCallback &onValidationFailed)
check if packet satisfies certain condition