NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
remote-registrator.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_RIB_REMOTE_REGISTRATOR_HPP
27 #define NFD_RIB_REMOTE_REGISTRATOR_HPP
28 
29 #include "rib.hpp"
30 #include "core/config-file.hpp"
31 #include "rib-status-publisher.hpp"
32 
33 #include <unordered_map>
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 
48 class RemoteRegistrator : noncopyable
49 {
50 public:
51  class Error : public std::runtime_error
52  {
53  public:
54  explicit
55  Error(const std::string& what)
56  : std::runtime_error(what)
57  {
58  }
59  };
60 
62  ndn::KeyChain& keyChain,
63  Rib& rib);
64 
66 
72  void
73  loadConfig(const ConfigSection& configSection);
74 
79  void
80  enable();
81 
86  void
87  disable();
88 
98  void
99  registerPrefix(const Name& prefix);
100 
110  void
111  unregisterPrefix(const Name& prefix);
112 
113 private:
123  std::pair<Name, size_t>
124  findIdentityForRegistration(const Name& prefix);
125 
131  void
132  startRegistration(const ndn::nfd::ControlParameters& parameters,
133  const ndn::nfd::CommandOptions& options,
134  int nRetries);
135 
141  void
142  startUnregistration(const ndn::nfd::ControlParameters& parameters,
143  const ndn::nfd::CommandOptions& options,
144  int nRetries);
155  void
156  onRegSuccess(const ndn::nfd::ControlParameters& parameters,
157  const ndn::nfd::CommandOptions& options);
158 
171  void
172  onRegFailure(uint32_t code, const std::string& reason,
173  const ndn::nfd::ControlParameters& parameters,
174  const ndn::nfd::CommandOptions& options,
175  int nRetries);
176 
177  void
178  onUnregSuccess(const ndn::nfd::ControlParameters& parameters,
179  const ndn::nfd::CommandOptions& options);
180 
193  void
194  onUnregFailure(uint32_t code, const std::string& reason,
195  const ndn::nfd::ControlParameters& parameters,
196  const ndn::nfd::CommandOptions& options,
197  int nRetries);
198 
204  void
205  redoRegistration();
206 
212  void
213  clearRefreshEvents();
214 
225  typedef std::unordered_map<Name, scheduler::EventId> RegisteredList;
226  typedef RegisteredList::iterator RegisteredEntryIt;
227  typedef RegisteredList::value_type RegisteredEntry;
228  RegisteredList m_regEntries;
229 
230 private:
231  ndn::nfd::Controller& m_nfdController;
232  ndn::KeyChain& m_keyChain;
233  Rib& m_rib;
234  ndn::util::signal::ScopedConnection m_afterInsertConnection;
235  ndn::util::signal::ScopedConnection m_afterEraseConnection;
236  ndn::nfd::ControlParameters m_controlParameters;
237  ndn::nfd::CommandOptions m_commandOptions;
238  time::seconds m_refreshInterval;
239  bool m_hasConnectedHub;
240  int m_nRetries;
241 
242  static const Name LOCAL_REGISTRATION_PREFIX; // /localhost
243  static const Name REMOTE_HUB_PREFIX; // /localhop/nfd
244  static const name::Component IGNORE_COMMPONENT; // rib
245 };
246 
247 } // namespace rib
248 } // namespace nfd
249 
250 #endif // NFD_RIB_REMOTE_REGISTRATOR_HPP
represents the RIB
Definition: rib.hpp:45
represents parameters in a ControlCommand request or response
void registerPrefix(const Name &prefix)
register a prefix to remote hub(s).
void unregisterPrefix(const Name &prefix)
unregister a prefix from remote hub(s).
void disable()
disable remote registration/unregistration.
STL namespace.
void loadConfig(const ConfigSection &configSection)
load the "remote_register" section from config file
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:38
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
define the RemoteRegistrator class, which handles the registration/unregistration to remote hub(s)...
Component holds a read-only name component value.
RemoteRegistrator(ndn::nfd::Controller &controller, ndn::KeyChain &keyChain, Rib &rib)
void enable()
enable remote registration/unregistration.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:39