#include <rule.hpp>
Public Member Functions | |
Rule (const std::string &id, uint32_t pktType) | |
const std::string & | getId () const |
uint32_t | getPktType () const |
void | addFilter (unique_ptr< Filter > filter) |
void | addChecker (unique_ptr< Checker > checker) |
bool | match (uint32_t pktType, const Name &pktName, const shared_ptr< ValidationState > &state) const |
check if the packet name matches rule's filter More... | |
bool | check (uint32_t pktType, tlv::SignatureTypeValue sigType, const Name &pktName, const Name &klName, const shared_ptr< ValidationState > &state) const |
Check if packet satisfies rule's condition. More... | |
Static Public Member Functions | |
static unique_ptr< Rule > | create (const ConfigSection &configSection, const std::string &configFilename) |
create a rule from configuration section More... | |
Public Attributes | |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE | __pad0__: std::string m_id |
uint32_t | m_pktType |
std::vector< unique_ptr< Filter > > | m_filters |
std::vector< unique_ptr< Checker > > | m_checkers |
ndn::security::v2::validator_config::Rule::Rule | ( | const std::string & | id, |
uint32_t | pktType | ||
) |
|
inline |
|
inline |
Definition at line 48 of file rule.hpp.
References addChecker(), addFilter(), check(), create(), m_pktType, match(), and NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE.
void ndn::security::v2::validator_config::Rule::addFilter | ( | unique_ptr< Filter > | filter | ) |
Definition at line 42 of file rule.cpp.
References m_filters, and nonstd::optional_lite::std11::move().
Referenced by getPktType().
void ndn::security::v2::validator_config::Rule::addChecker | ( | unique_ptr< Checker > | checker | ) |
Definition at line 48 of file rule.cpp.
References m_checkers, and nonstd::optional_lite::std11::move().
Referenced by getPktType().
bool ndn::security::v2::validator_config::Rule::match | ( | uint32_t | pktType, |
const Name & | pktName, | ||
const shared_ptr< ValidationState > & | state | ||
) | const |
check if the packet name matches rule's filter
If no filters were added, the rule matches everything.
pktType | tlv::Interest or tlv::Data |
pktName | packet name, for signed Interests the last two components are not removed |
state | The associated validation state |
true | If at least one filter matches pktName |
false | If none of the filters match pktName |
Error | the supplied pktType doesn't match one for which the rule is designed |
Definition at line 54 of file rule.cpp.
References m_filters, m_pktType, NDN_LOG_TRACE, NDN_THROW, and ndn::to_string().
Referenced by getPktType().
bool ndn::security::v2::validator_config::Rule::check | ( | uint32_t | pktType, |
tlv::SignatureTypeValue | sigType, | ||
const Name & | pktName, | ||
const Name & | klName, | ||
const shared_ptr< ValidationState > & | state | ||
) | const |
Check if packet satisfies rule's condition.
pktType | tlv::Interest or tlv::Data |
sigType | Signature type |
pktName | packet name, for signed Interests the last two components are not removed |
klName | KeyLocator name |
state | Validation state |
false | packet violates all checkers. fail() will have been called on state with proper code and message. |
true | packet satisfies at least one checker, further validation is needed. |
Error | the supplied pktType doesn't match one for which the rule is designed. |
Definition at line 77 of file rule.cpp.
References m_checkers, m_pktType, nonstd::optional_lite::std11::move(), NDN_LOG_TRACE, NDN_THROW, ndn::security::v2::ValidationError::POLICY_ERROR, and ndn::to_string().
Referenced by getPktType().
|
static |
create a rule from configuration section
configSection | The section containing the definition of checker. |
configFilename | The configuration file name. |
Definition at line 107 of file rule.cpp.
References ndn::security::v2::validator_config::Filter::create(), ndn::security::v2::validator_config::Checker::create(), ndn::tlv::Data, ndn::tlv::Interest, and NDN_THROW.
Referenced by getPktType(), and ndn::security::v2::validator_config::ValidationPolicyConfig::load().
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::v2::validator_config::Rule::__pad0__ |
uint32_t ndn::security::v2::validator_config::Rule::m_pktType |
Definition at line 107 of file rule.hpp.
Referenced by check(), getPktType(), and match().
std::vector<unique_ptr<Filter> > ndn::security::v2::validator_config::Rule::m_filters |
Definition at line 108 of file rule.hpp.
Referenced by addFilter(), and match().
std::vector<unique_ptr<Checker> > ndn::security::v2::validator_config::Rule::m_checkers |
Definition at line 109 of file rule.hpp.
Referenced by addChecker(), and check().