NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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-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_FILTER_HPP
23 #define NDN_SECURITY_V2_VALIDATOR_CONFIG_FILTER_HPP
24 
25 #include "common.hpp"
26 #include "name-relation.hpp"
27 #include "../../../interest.hpp"
28 #include "../../../data.hpp"
29 #include "../../../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
Copyright (c) 2011-2015 Regents of the University of California.
Filter to check that packet name matches the specified regular expression.
Definition: filter.hpp:123
Catch-all error for security policy errors that don&#39;t fit in other categories.
Definition: base.hpp:79
bool match(uint32_t pktType, const Name &pktName)
Definition: filter.cpp:37
Represents an absolute name.
Definition: name.hpp:42
static unique_ptr< Filter > create(const ConfigSection &configSection, const std::string &configFilename)
Create a filter from the configuration section.
Definition: filter.cpp:76
boost::property_tree::ptree ConfigSection
Definition: common.hpp:35
Check that name is in relation to the packet name.
Definition: filter.hpp:90
Filter is one of the classes used by ValidatorConfig.
Definition: filter.hpp:43