NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
rule.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2017 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_SECURITY_V2_VALIDATOR_CONFIG_RULE_HPP
23 #define NDN_SECURITY_V2_VALIDATOR_CONFIG_RULE_HPP
24 
25 #include "filter.hpp"
26 #include "checker.hpp"
27 
28 namespace ndn {
29 namespace security {
30 namespace v2 {
31 
32 class ValidationState;
33 
34 namespace validator_config {
35 
36 class Rule : noncopyable
37 {
38 public:
39  Rule(const std::string& id, uint32_t pktType);
40 
41  const std::string&
42  getId() const
43  {
44  return m_id;
45  }
46 
47  uint32_t
48  getPktType() const
49  {
50  return m_pktType;
51  }
52 
53  void
54  addFilter(unique_ptr<Filter> filter);
55 
56  void
57  addChecker(unique_ptr<Checker> checker);
58 
71  bool
72  match(uint32_t pktType, const Name& pktName) const;
73 
87  bool
88  check(uint32_t pktType, const Name& pktName, const Name& klName, const shared_ptr<ValidationState>& state) const;
89 
90 public:
98  static unique_ptr<Rule>
99  create(const ConfigSection& configSection, const std::string& configFilename);
100 
102  std::string m_id;
103  uint32_t m_pktType;
104  std::vector<unique_ptr<Filter>> m_filters;
105  std::vector<unique_ptr<Checker>> m_checkers;
106 };
107 
108 } // namespace validator_config
109 } // namespace v2
110 } // namespace security
111 } // namespace ndn
112 
113 #endif // NDN_SECURITY_V2_VALIDATOR_CONFIG_RULE_HPP
Rule(const std::string &id, uint32_t pktType)
Definition: rule.cpp:34
Copyright (c) 2011-2015 Regents of the University of California.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
const std::string & getId() const
Definition: rule.hpp:42
static unique_ptr< Rule > create(const ConfigSection &configSection, const std::string &configFilename)
create a rule from configuration section
Definition: rule.cpp:99
bool check(uint32_t pktType, const Name &pktName, const Name &klName, const shared_ptr< ValidationState > &state) const
check if packet satisfies rule&#39;s condition
Definition: rule.cpp:76
std::vector< unique_ptr< Checker > > m_checkers
Definition: rule.hpp:105
void addFilter(unique_ptr< Filter > filter)
Definition: rule.cpp:41
Represents an absolute name.
Definition: name.hpp:42
ndn security v2 ValidationState
boost::property_tree::ptree ConfigSection
Definition: common.hpp:35
void addChecker(unique_ptr< Checker > checker)
Definition: rule.cpp:47
std::vector< unique_ptr< Filter > > m_filters
Definition: rule.hpp:104
bool match(uint32_t pktType, const Name &pktName) const
check if the packet name matches rule&#39;s filter
Definition: rule.cpp:53