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-2021 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_CXX_SECURITY_VALIDATOR_CONFIG_RULE_HPP
23 #define NDN_CXX_SECURITY_VALIDATOR_CONFIG_RULE_HPP
24 
27 
28 namespace ndn {
29 namespace security {
30 inline 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 
72  bool
73  match(uint32_t pktType, const Name& pktName, const shared_ptr<ValidationState>& state) const;
74 
90  bool
91  check(uint32_t pktType, tlv::SignatureTypeValue sigType, const Name& pktName, const Name& klName,
92  const shared_ptr<ValidationState>& state) const;
93 
94 public:
102  static unique_ptr<Rule>
103  create(const ConfigSection& configSection, const std::string& configFilename);
104 
106  std::string m_id;
107  uint32_t m_pktType;
108  std::vector<unique_ptr<Filter>> m_filters;
109  std::vector<unique_ptr<Checker>> m_checkers;
110 };
111 
112 } // namespace validator_config
113 } // inline namespace v2
114 } // namespace security
115 } // namespace ndn
116 
117 #endif // NDN_CXX_SECURITY_VALIDATOR_CONFIG_RULE_HPP
Rule(const std::string &id, uint32_t pktType)
Definition: rule.cpp:35
Copyright (c) 2011-2015 Regents of the University of California.
bool match(uint32_t pktType, const Name &pktName, const shared_ptr< ValidationState > &state) const
check if the packet name matches rule&#39;s filter
Definition: rule.cpp:54
const std::string & getId() const
Definition: rule.hpp:42
ndn security ValidationState
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&#39;s condition.
Definition: rule.cpp:77
static unique_ptr< Rule > create(const ConfigSection &configSection, const std::string &configFilename)
create a rule from configuration section
Definition: rule.cpp:107
std::vector< unique_ptr< Checker > > m_checkers
Definition: rule.hpp:109
void addFilter(unique_ptr< Filter > filter)
Definition: rule.cpp:42
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
Represents an absolute name.
Definition: name.hpp:41
SignatureTypeValue
SignatureType values.
Definition: tlv.hpp:132
boost::property_tree::ptree ConfigSection
Definition: common.hpp:36
void addChecker(unique_ptr< Checker > checker)
Definition: rule.cpp:48
std::vector< unique_ptr< Filter > > m_filters
Definition: rule.hpp:108