NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
rib-manager.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_RIB_RIB_MANAGER_HPP
27 #define NFD_RIB_RIB_MANAGER_HPP
28 
29 #include "rib.hpp"
30 #include "core/config-file.hpp"
31 #include "core/manager-base.hpp"
33 #include "fib-updater.hpp"
34 
35 #include <ndn-cxx/encoding/buffer-stream.hpp>
36 #include <ndn-cxx/security/validator-config.hpp>
37 #include <ndn-cxx/mgmt/nfd/face-monitor.hpp>
38 #include <ndn-cxx/mgmt/nfd/controller.hpp>
39 #include <ndn-cxx/mgmt/nfd/control-command.hpp>
40 #include <ndn-cxx/mgmt/nfd/control-response.hpp>
41 #include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
42 
43 namespace nfd {
44 namespace rib {
45 
49 
51 
53 {
54 public:
55  class Error : public std::runtime_error
56  {
57  public:
58  explicit
59  Error(const std::string& what)
60  : std::runtime_error(what)
61  {
62  }
63  };
64 
65 public:
66  RibManager(Dispatcher& dispatcher, ndn::Face& face, ndn::KeyChain& keyChain);
67 
68  ~RibManager();
69 
70  void
72 
73  void
75 
76  void
77  setConfigFile(ConfigFile& configFile);
78 
79  void
80  onRibUpdateSuccess(const RibUpdate& update);
81 
82  void
83  onRibUpdateFailure(const RibUpdate& update, uint32_t code, const std::string& error);
84 
85 private: // initialization helpers
86  void
87  onConfig(const ConfigSection& configSection, bool isDryRun, const std::string& filename);
88 
89  void
90  registerTopPrefix(const Name& topPrefix);
91 
92 private: // ControlCommand and StatusDataset
93  void
94  registerEntry(const Name& topPrefix, const Interest& interest,
95  ControlParameters parameters,
96  const ndn::mgmt::CommandContinuation& done);
97 
98  void
99  unregisterEntry(const Name& topPrefix, const Interest& interest,
100  ControlParameters parameters,
101  const ndn::mgmt::CommandContinuation& done);
102 
103  void
104  listEntries(const Name& topPrefix, const Interest& interest,
106 
107  void
108  setFaceForSelfRegistration(const Interest& request, ControlParameters& parameters);
109 
111  makeAuthorization(const std::string& verb) override;
112 
113 private: // Face monitor
114  void
115  fetchActiveFaces();
116 
117  void
118  onFetchActiveFacesFailure(uint32_t code, const std::string& reason);
119 
120  void
121  onFaceDestroyedEvent(uint64_t faceId);
122 
124  void
125  scheduleActiveFaceFetch(const time::seconds& timeToWait);
126 
132  void
133  removeInvalidFaces(const std::vector<ndn::nfd::FaceStatus>& activeFaces);
134 
140  void
141  onNotification(const FaceEventNotification& notification);
142 
143 private:
144  void
145  onCommandPrefixAddNextHopSuccess(const Name& prefix,
146  const ndn::nfd::ControlParameters& result);
147 
148  void
149  onCommandPrefixAddNextHopError(const Name& name, const ndn::nfd::ControlResponse& response);
150 
151  void
152  onEnableLocalFieldsSuccess();
153 
154  void
155  onEnableLocalFieldsError(const ndn::nfd::ControlResponse& response);
156 
157 private:
158  ndn::Face& m_face;
159  ndn::KeyChain& m_keyChain;
160  ndn::nfd::Controller m_nfdController;
161  ndn::nfd::FaceMonitor m_faceMonitor;
162  ndn::ValidatorConfig m_localhostValidator;
163  ndn::ValidatorConfig m_localhopValidator;
164  bool m_isLocalhopEnabled;
165  AutoPrefixPropagator m_prefixPropagator;
166 
168  Rib m_rib;
169  FibUpdater m_fibUpdater;
170 
171 private:
172  static const Name LOCAL_HOST_TOP_PREFIX;
173  static const Name LOCAL_HOP_TOP_PREFIX;
174  static const std::string MGMT_MODULE_NAME;
175  static const Name FACES_LIST_DATASET_PREFIX;
176  static const time::seconds ACTIVE_FACE_FETCH_INTERVAL;
177  scheduler::EventId m_activeFaceFetchEvent;
178 
179  typedef std::set<uint64_t> FaceIdSet;
182  FaceIdSet m_registeredFaces;
183 
184  std::function<void(const Name& topPrefix)> m_addTopPrefix;
185 };
186 
187 } // namespace rib
188 } // namespace nfd
189 
190 #endif // NFD_RIB_RIB_MANAGER_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40
Error(const std::string &what)
Definition: rib-manager.hpp:59
a collection of common functions shared by all NFD managers and RIB manager, such as communicating wi...
represents the Routing Information Base
Definition: rib.hpp:56
represents parameters in a ControlCommand request or response
represents a dispatcher on server side of NFD Management protocol
Definition: dispatcher.hpp:129
The validator which can be set up via a configuration file.
configuration file parsing utility
Definition: config-file.hpp:50
The packet signing interface.
Definition: key-chain.hpp:47
base class of NFD ControlCommand
STL namespace.
RibManager(Dispatcher &dispatcher, ndn::Face &face, ndn::KeyChain &keyChain)
Definition: rib-manager.cpp:45
computes FibUpdates based on updates to the RIB and sends them to NFD
Definition: fib-updater.hpp:41
represents a Face status change notification
represents an Interest packet
Definition: interest.hpp:42
A subscriber for Face status change notification stream.
void onRibUpdateSuccess(const RibUpdate &update)
std::shared_ptr< ns3::EventId > EventId
Definition: scheduler.hpp:39
ndn::mgmt::ControlResponse ControlResponse
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
Provide a communication channel with local or remote NDN forwarder.
Definition: face.hpp:125
NFD Management protocol client.
Definition: controller.hpp:51
boost::property_tree::ptree ConfigSection
Name abstraction to represent an absolute name.
Definition: name.hpp:46
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
Definition: dispatcher.hpp:95
ControlCommand response.
provides a context for generating response to a StatusDataset request
provides automatic prefix propagation feature
std::function< void(const Name &prefix, const Interest &interest, const ControlParameters *params, const AcceptContinuation &accept, const RejectContinuation &reject)> Authorization
a function that performs authorization
Definition: dispatcher.hpp:77
void onRibUpdateFailure(const RibUpdate &update, uint32_t code, const std::string &error)
void setConfigFile(ConfigFile &configFile)