NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
validation-policy-command-interest.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_VALIDATION_POLICY_COMMAND_INTEREST_HPP
23 #define NDN_CXX_SECURITY_VALIDATION_POLICY_COMMAND_INTEREST_HPP
24 
26 
27 #include <boost/multi_index_container.hpp>
28 #include <boost/multi_index/ordered_index.hpp>
29 #include <boost/multi_index/sequenced_index.hpp>
30 #include <boost/multi_index/key_extractors.hpp>
31 
32 namespace ndn {
33 namespace security {
34 inline namespace v2 {
35 
43 {
44 public:
45  class Options
46  {
47  public:
49  {
50  }
51 
52  public:
67 
83  ssize_t maxRecords = 1000;
84 
93  };
94 
101  explicit
102  ValidationPolicyCommandInterest(unique_ptr<ValidationPolicy> inner,
103  const Options& options = {});
104 
105 protected:
106  void
107  checkPolicy(const Data& data, const shared_ptr<ValidationState>& state,
108  const ValidationContinuation& continueValidation) override;
109 
110  void
111  checkPolicy(const Interest& interest, const shared_ptr<ValidationState>& state,
112  const ValidationContinuation& continueValidation) override;
113 
114 private:
115  void
116  cleanup();
117 
118  std::tuple<bool, Name, time::system_clock::TimePoint>
119  parseCommandInterest(const Interest& interest, const shared_ptr<ValidationState>& state) const;
120 
121  bool
122  checkTimestamp(const shared_ptr<ValidationState>& state,
123  const Name& keyName, time::system_clock::TimePoint timestamp);
124 
125  void
126  insertNewRecord(const Name& keyName, time::system_clock::TimePoint timestamp);
127 
128 private:
129  Options m_options;
130 
131  struct LastTimestampRecord
132  {
133  Name keyName;
135  time::steady_clock::TimePoint lastRefreshed;
136  };
137 
138  using Container = boost::multi_index_container<
139  LastTimestampRecord,
140  boost::multi_index::indexed_by<
141  boost::multi_index::ordered_unique<
142  boost::multi_index::member<LastTimestampRecord, Name, &LastTimestampRecord::keyName>
143  >,
144  boost::multi_index::sequenced<>
145  >
146  >;
147  using Index = Container::nth_index<0>::type;
148  using Queue = Container::nth_index<1>::type;
149 
150  Container m_container;
151  Index& m_index;
152  Queue& m_queue;
153 };
154 
155 } // inline namespace v2
156 } // namespace security
157 } // namespace ndn
158 
159 #endif // NDN_CXX_SECURITY_VALIDATION_POLICY_COMMAND_INTEREST_HPP
Copyright (c) 2011-2015 Regents of the University of California.
Represents an Interest packet.
Definition: interest.hpp:48
void checkPolicy(const Data &data, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation) override
Check data against the policy.
Abstraction that implements validation policy for Data and Interest packets.
Validation policy for stop-and-wait command Interests.
std::function< void(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state)> ValidationContinuation
Represents an absolute name.
Definition: name.hpp:41
time::nanoseconds recordLifetime
max lifetime of a last timestamp record
ssize_t maxRecords
max number of distinct public keys of which to record the last timestamp
Represents a Data packet.
Definition: data.hpp:37
boost::chrono::nanoseconds nanoseconds
Definition: time.hpp:50
time_point TimePoint
Definition: time.hpp:203
time_point TimePoint
Definition: time.hpp:233
ValidationPolicyCommandInterest(unique_ptr< ValidationPolicy > inner, const Options &options={})
constructor