NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
auto-prefix-propagator.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_RIB_AUTO_PREFIX_PROPAGATOR_HPP
27 #define NFD_RIB_AUTO_PREFIX_PROPAGATOR_HPP
28 
29 #include "rib.hpp"
30 #include "core/config-file.hpp"
31 #include "rib-status-publisher.hpp"
32 #include "propagated-entry.hpp"
33 
34 #include <ndn-cxx/security/key-chain.hpp>
35 #include <ndn-cxx/management/nfd-controller.hpp>
36 #include <ndn-cxx/management/nfd-control-command.hpp>
37 #include <ndn-cxx/management/nfd-control-parameters.hpp>
38 #include <ndn-cxx/management/nfd-command-options.hpp>
39 #include <ndn-cxx/util/signal.hpp>
40 
41 namespace nfd {
42 namespace rib {
43 
77 class AutoPrefixPropagator : noncopyable
78 {
79 public:
80  class Error : public std::runtime_error
81  {
82  public:
83  explicit
84  Error(const std::string& what)
85  : std::runtime_error(what)
86  {
87  }
88  };
89 
91  ndn::KeyChain& keyChain,
92  Rib& rib);
98  void
99  loadConfig(const ConfigSection& configSection);
100 
104  void
105  enable();
106 
110  void
111  disable();
112 
123  typedef std::unordered_map<Name, PropagatedEntry> PropagatedEntryList;
124  typedef PropagatedEntryList::iterator PropagatedEntryIt;
125 
132  struct PrefixPropagationParameters
133  {
134  bool isValid;
135  ndn::nfd::ControlParameters parameters;
136  ndn::nfd::CommandOptions options;
137  };
138 
152  PrefixPropagationParameters
153  getPrefixPropagationParameters(const Name& localRibPrefix);
154 
163  bool
164  doesCurrentPropagatedPrefixWork(const Name& prefix);
165 
179  void
180  redoPropagation(PropagatedEntryIt entryIt,
181  const ndn::nfd::ControlParameters& parameters,
182  const ndn::nfd::CommandOptions& options,
183  time::seconds retryWaitTime);
184 
185 private:
205  void
206  startPropagation(const ndn::nfd::ControlParameters& parameters,
207  const ndn::nfd::CommandOptions& options,
208  time::seconds retryWaitTime);
209 
217  void
218  startRevocation(const ndn::nfd::ControlParameters& parameters,
219  const ndn::nfd::CommandOptions& options,
220  time::seconds retryWaitTime);
221 
231  void
232  afterInsertRibEntry(const Name& prefix);
233 
244  void
245  afterEraseRibEntry(const Name& prefix);
246 
247 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // PropagatedEntry state changes
256  void
257  afterRibInsert(const ndn::nfd::ControlParameters& parameters,
258  const ndn::nfd::CommandOptions& options);
259 
268  void
269  afterRibErase(const ndn::nfd::ControlParameters& parameters,
270  const ndn::nfd::CommandOptions& options);
271 
279  void
280  afterHubConnect();
281 
289  void
290  afterHubDisconnect();
291 
311  void
312  afterPropagateSucceed(const ndn::nfd::ControlParameters& parameters,
313  const ndn::nfd::CommandOptions& options,
314  const ndn::Scheduler::Event& refreshEvent);
315 
331  void
332  afterPropagateFail(uint32_t code, const std::string& reason,
333  const ndn::nfd::ControlParameters& parameters,
334  const ndn::nfd::CommandOptions& options,
335  time::seconds retryWaitTime,
336  const ndn::Scheduler::Event& retryEvent);
337 
352  void
353  afterRevokeSucceed(const ndn::nfd::ControlParameters& parameters,
354  const ndn::nfd::CommandOptions& options,
355  time::seconds retryWaitTime);
356 
365  void
366  afterRevokeFail(uint32_t code, const std::string& reason,
367  const ndn::nfd::ControlParameters& parameters,
368  const ndn::nfd::CommandOptions& options);
369 
380  void
381  onRefreshTimer(const ndn::nfd::ControlParameters& parameters,
382  const ndn::nfd::CommandOptions& options);
383 
395  void
396  onRetryTimer(const ndn::nfd::ControlParameters& parameters,
397  const ndn::nfd::CommandOptions& options,
398  time::seconds retryWaitTime);
399 
401  ndn::nfd::Controller& m_nfdController;
402  ndn::KeyChain& m_keyChain;
403  Rib& m_rib;
404  ndn::util::signal::ScopedConnection m_afterInsertConnection;
405  ndn::util::signal::ScopedConnection m_afterEraseConnection;
406  ndn::nfd::ControlParameters m_controlParameters;
407  ndn::nfd::CommandOptions m_commandOptions;
408  time::seconds m_refreshInterval;
409  time::seconds m_baseRetryWait;
410  time::seconds m_maxRetryWait;
411  bool m_hasConnectedHub;
412  PropagatedEntryList m_propagatedEntries;
413 };
414 
415 } // namespace rib
416 } // namespace nfd
417 
418 #endif // NFD_RIB_AUTO_PREFIX_PROPAGATOR_HPP
represents the RIB
Definition: rib.hpp:45
represents parameters in a ControlCommand request or response
The packet signing interface.
Definition: key-chain.hpp:48
STL namespace.
void disable()
disable automatic prefix propagation
Table::const_iterator iterator
Definition: cs-internal.hpp:41
contains options for ControlCommand execution
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
void loadConfig(const ConfigSection &configSection)
load the "auto_prefix_propagate" section from config file
disconnects a Connection automatically upon destruction
NFD Management protocol - ControlCommand client.
boost::property_tree::ptree ConfigSection
Name abstraction to represent an absolute name.
Definition: name.hpp:46
void enable()
enable automatic prefix propagation
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:39
AutoPrefixPropagator(ndn::nfd::Controller &controller, ndn::KeyChain &keyChain, Rib &rib)
provides automatic prefix propagation feature