All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Static Public Member Functions | List of all members
ndn::ConfigRule Class Reference

A ConfigRule represents a rule configuration section, used by ConfigValidator. More...

#include <config-rule.hpp>

Public Member Functions

 ConfigRule (const std::string &id, bool isForInterest)
 Create a ConfigRule with empty filters and checkers. More...
 
const std::string & getId () const
 Get the rule ID. More...
 
bool getIsForInterest () const
 Get the isForInterest flag. More...
 
void addFilter (const ptr_lib::shared_ptr< ConfigFilter > &filter)
 Add the ConfigFilter to the list of filters. More...
 
void addChecker (const ptr_lib::shared_ptr< ConfigChecker > &checker)
 Add the ConfigChecker to the list of checkers. More...
 
bool match (bool isForInterest, const Name &packetName)
 Check if the packet name matches the rule's filter. More...
 
bool check (bool isForInterest, const Name &packetName, const Name &keyLocatorName, const ptr_lib::shared_ptr< ValidationState > &state)
 Check if the packet satisfies the rule's condition. More...
 

Static Public Member Functions

static ptr_lib::shared_ptr
< ConfigRule
create (const BoostInfoTree &configSection)
 Create a rule from configuration section. More...
 

Detailed Description

A ConfigRule represents a rule configuration section, used by ConfigValidator.

Constructor & Destructor Documentation

ndn::ConfigRule::ConfigRule ( const std::string &  id,
bool  isForInterest 
)
inline

Create a ConfigRule with empty filters and checkers.

Parameters
idThe rule ID from the configuration section.
isForInterestTrue if the rule is for an Interest packet, false if it is for a Data packet.

Member Function Documentation

void ndn::ConfigRule::addChecker ( const ptr_lib::shared_ptr< ConfigChecker > &  checker)
inline

Add the ConfigChecker to the list of checkers.

Parameters
checkerThe ConfigChecker.
void ndn::ConfigRule::addFilter ( const ptr_lib::shared_ptr< ConfigFilter > &  filter)
inline

Add the ConfigFilter to the list of filters.

Parameters
filterThe ConfigFilter.
bool ndn::ConfigRule::check ( bool  isForInterest,
const Name packetName,
const Name keyLocatorName,
const ptr_lib::shared_ptr< ValidationState > &  state 
)

Check if the packet satisfies the rule's condition.

Parameters
isForInterestTrue if packetName is for an Interest, false if for a Data packet.
packetNameThe packet name. For a signed interest, the last two components are skipped but not removed.
keyLocatorNameThe KeyLocator's name.
stateThis calls state.fail() if the packet is invalid.
Returns
True if further signature verification is needed, or false if the packet is immediately determined to be invalid in which case this calls state.fail() with the proper code and message.
Exceptions
ValidatorConfigErrorif the supplied isForInterest doesn't match the one for which the rule is designed.
static ptr_lib::shared_ptr<ConfigRule> ndn::ConfigRule::create ( const BoostInfoTree configSection)
static

Create a rule from configuration section.

Parameters
configSectionThe section containing the definition of the rule, e.g. one of <validator.rule>.
Returns
A new ConfigRule created from the configuration
const std::string& ndn::ConfigRule::getId ( ) const
inline

Get the rule ID.

Returns
The rule ID.
bool ndn::ConfigRule::getIsForInterest ( ) const
inline

Get the isForInterest flag.

Returns
True if the rule is for an Interest packet, false if it is for a Data packet.
bool ndn::ConfigRule::match ( bool  isForInterest,
const Name packetName 
)

Check if the packet name matches the rule's filter.

If no filters were added, the rule matches everything.

Parameters
isForInterestTrue if packetName is for an Interest, false if for a Data packet.
packetNameThe packet name. For a signed interest, the last two components are skipped but not removed. True if at least one filter matches the packet name, false if none of the filters match the packet name.
Exceptions
ValidatorConfigErrorif the supplied isForInterest doesn't match the one for which the rule is designed.

The documentation for this class was generated from the following file: