NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
22 #ifndef NDN_SECURITY_V2_VALIDATION_POLICY_COMMAND_INTEREST_HPP
23 #define NDN_SECURITY_V2_VALIDATION_POLICY_COMMAND_INTEREST_HPP
24 
25 #include "validation-policy.hpp"
26 #include <boost/multi_index_container.hpp>
27 #include <boost/multi_index/ordered_index.hpp>
28 #include <boost/multi_index/sequenced_index.hpp>
29 #include <boost/multi_index/key_extractors.hpp>
30 
31 namespace ndn {
32 namespace security {
33 namespace v2 {
34 
42 {
43 public:
44  class Options
45  {
46  public:
48  {
49  }
50 
51  public:
65  time::nanoseconds gracePeriod = time::seconds(120);
66 
82  ssize_t maxRecords = 1000;
83 
91  time::nanoseconds recordLifetime = time::hours(1);
92  };
93 
100  explicit
101  ValidationPolicyCommandInterest(unique_ptr<ValidationPolicy> inner,
102  const Options& options = {});
103 
104 protected:
105  void
106  checkPolicy(const Data& data, const shared_ptr<ValidationState>& state,
107  const ValidationContinuation& continueValidation) override;
108 
109  void
110  checkPolicy(const Interest& interest, const shared_ptr<ValidationState>& state,
111  const ValidationContinuation& continueValidation) override;
112 
113 private:
114  void
115  cleanup();
116 
117  std::tuple<bool, Name, uint64_t>
118  parseCommandInterest(const Interest& interest, const shared_ptr<ValidationState>& state) const;
119 
120  bool
121  checkTimestamp(const shared_ptr<ValidationState>& state,
122  const Name& keyName, uint64_t timestamp);
123 
124  void
125  insertNewRecord(const Interest& interest, const Name& keyName,
126  uint64_t timestamp);
127 
128 private:
129  unique_ptr<ValidationPolicy> m_innerPolicy;
130  Options m_options;
131 
132  struct LastTimestampRecord
133  {
134  Name keyName;
135  uint64_t timestamp;
136  time::steady_clock::TimePoint lastRefreshed;
137  };
138 
139  typedef boost::multi_index_container<
140  LastTimestampRecord,
141  boost::multi_index::indexed_by<
142  boost::multi_index::ordered_unique<
143  boost::multi_index::member<LastTimestampRecord, Name, &LastTimestampRecord::keyName>
144  >,
145  boost::multi_index::sequenced<>
146  >
147  > Container;
148  typedef Container::nth_index<0>::type Index;
149  typedef Container::nth_index<1>::type Queue;
150 
151  Container m_container;
152  Index& m_index;
153  Queue& m_queue;
154 };
155 
156 } // namespace v2
157 } // namespace security
158 } // namespace ndn
159 
160 
161 #endif // NDN_SECURITY_V2_VALIDATION_POLICY_COMMAND_INTEREST_HPP
time_point TimePoint
Definition: time.hpp:120
Copyright (c) 2011-2015 Regents of the University of California.
represents an Interest packet
Definition: interest.hpp:42
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.
Catch-all error for security policy errors that don&#39;t fit in other categories.
Definition: base.hpp:79
std::function< void(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state)> ValidationContinuation
Represents an absolute name.
Definition: name.hpp:42
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:35
ValidationPolicyCommandInterest(unique_ptr< ValidationPolicy > inner, const Options &options={})
constructor