NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
filter.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_FILTER_HPP
23 #define NDN_CXX_SECURITY_VALIDATOR_CONFIG_FILTER_HPP
24 
25 #include "ndn-cxx/data.hpp"
26 #include "ndn-cxx/interest.hpp"
29 #include "ndn-cxx/util/regex.hpp"
30 
31 namespace ndn {
32 namespace security {
33 inline namespace v2 {
34 
35 class ValidationState;
36 
37 namespace validator_config {
38 
46 class Filter : noncopyable
47 {
48 public:
49  virtual
50  ~Filter() = default;
51 
52  bool
53  match(uint32_t pktType, const Name& pktName, const shared_ptr<ValidationState>& state);
54 
55 public:
63  static unique_ptr<Filter>
64  create(const ConfigSection& configSection, const std::string& configFilename);
65 
66 private:
67  static unique_ptr<Filter>
68  createNameFilter(const ConfigSection& configSection, const std::string& configFilename);
69 
70 private:
71  virtual bool
72  matchName(const Name& pktName) = 0;
73 };
74 
93 class RelationNameFilter : public Filter
94 {
95 public:
96  RelationNameFilter(const Name& name, NameRelation relation);
97 
98 private:
99  bool
100  matchName(const Name& pktName) override;
101 
102 private:
103  Name m_name;
104  NameRelation m_relation;
105 };
106 
126 class RegexNameFilter : public Filter
127 {
128 public:
129  explicit
130  RegexNameFilter(const Regex& regex);
131 
132 private:
133  bool
134  matchName(const Name& pktName) override;
135 
136 private:
137  Regex m_regex;
138 };
139 
140 } // namespace validator_config
141 } // inline namespace v2
142 } // namespace security
143 } // namespace ndn
144 
145 #endif // NDN_CXX_SECURITY_VALIDATOR_CONFIG_FILTER_HPP
bool match(uint32_t pktType, const Name &pktName, const shared_ptr< ValidationState > &state)
Definition: filter.cpp:38
Copyright (c) 2011-2015 Regents of the University of California.
ndn security ValidationState
Filter to check that packet name matches the specified regular expression.
Definition: filter.hpp:126
Represents an absolute name.
Definition: name.hpp:41
static unique_ptr< Filter > create(const ConfigSection &configSection, const std::string &configFilename)
Create a filter from the configuration section.
Definition: filter.cpp:91
boost::property_tree::ptree ConfigSection
Definition: common.hpp:36
Check that name is in relation to the packet name.
Definition: filter.hpp:93
Filter is one of the classes used by ValidatorConfig.
Definition: filter.hpp:46