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-2018 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_FILTER_HPP
23 #define NDN_SECURITY_V2_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 namespace v2 {
34 namespace validator_config {
35 
43 class Filter : noncopyable
44 {
45 public:
46  virtual
47  ~Filter() = default;
48 
49  bool
50  match(uint32_t pktType, const Name& pktName);
51 
52 public:
60  static unique_ptr<Filter>
61  create(const ConfigSection& configSection, const std::string& configFilename);
62 
63 private:
64  static unique_ptr<Filter>
65  createNameFilter(const ConfigSection& configSection, const std::string& configFilename);
66 
67 private:
68  virtual bool
69  matchName(const Name& pktName) = 0;
70 };
71 
90 class RelationNameFilter : public Filter
91 {
92 public:
93  RelationNameFilter(const Name& name, NameRelation relation);
94 
95 private:
96  bool
97  matchName(const Name& pktName) override;
98 
99 private:
100  Name m_name;
101  NameRelation m_relation;
102 };
103 
123 class RegexNameFilter : public Filter
124 {
125 public:
126  explicit
127  RegexNameFilter(const Regex& regex);
128 
129 private:
130  bool
131  matchName(const Name& pktName) override;
132 
133 private:
134  Regex m_regex;
135 };
136 
137 } // namespace validator_config
138 } // namespace v2
139 } // namespace security
140 } // namespace ndn
141 
142 #endif // NDN_SECURITY_V2_VALIDATOR_CONFIG_FILTER_HPP
ndn::security::v2::validator_config::Filter::create
static unique_ptr< Filter > create(const ConfigSection &configSection, const std::string &configFilename)
Create a filter from the configuration section.
Definition: filter.cpp:76
ndn::RegexTopMatcher
Definition: regex-top-matcher.hpp:35
ndn::security::v2::validator_config::RegexNameFilter
Filter to check that packet name matches the specified regular expression.
Definition: filter.hpp:124
ndn::security::v2::validator_config::RelationNameFilter
Check that name is in relation to the packet name.
Definition: filter.hpp:91
ndn::security::v2::validator_config::Filter::match
bool match(uint32_t pktType, const Name &pktName)
Definition: filter.cpp:37
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
common.hpp
name-relation.hpp
ndn::security::v2::validator_config::Filter
Filter is one of the classes used by ValidatorConfig.
Definition: filter.hpp:44
regex.hpp
ndn::security::v2::validator_config::Filter::~Filter
virtual ~Filter()=default
interest.hpp
ndn::security::v2::validator_config::NameRelation
NameRelation
Definition: name-relation.hpp:33
data.hpp
ndn::name
Definition: name-component-types.hpp:33
ndn::security::v2::validator_config::RegexNameFilter::RegexNameFilter
RegexNameFilter(const Regex &regex)
Definition: filter.cpp:64
ndn::security::v2::validator_config::ConfigSection
boost::property_tree::ptree ConfigSection
Definition: common.hpp:36
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::security::v2::validator_config::RelationNameFilter::RelationNameFilter
RelationNameFilter(const Name &name, NameRelation relation)
Definition: filter.cpp:52