NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
face-manager.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_MGMT_FACE_MANAGER_HPP
27 #define NFD_DAEMON_MGMT_FACE_MANAGER_HPP
28 
29 #include "nfd-manager-base.hpp"
30 #include <ndn-cxx/mgmt/nfd/face-status.hpp>
31 #include <ndn-cxx/mgmt/nfd/face-query-filter.hpp>
32 #include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
33 #include "face/face.hpp"
34 
35 namespace nfd {
36 
37 class FaceTable;
39 class ProtocolFactory;
40 
46 {
47 public:
48  FaceManager(FaceTable& faceTable,
49  Dispatcher& dispatcher,
50  CommandAuthenticator& authenticator);
51 
55  void
56  setConfigFile(ConfigFile& configFile);
57 
58 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // ControlCommand
59  void
60  createFace(const Name& topPrefix, const Interest& interest,
61  const ControlParameters& parameters,
62  const ndn::mgmt::CommandContinuation& done);
63 
64  void
65  updateFace(const Name& topPrefix, const Interest& interest,
66  const ControlParameters& parameters,
67  const ndn::mgmt::CommandContinuation& done);
68 
69  void
70  destroyFace(const Name& topPrefix, const Interest& interest,
71  const ControlParameters& parameters,
72  const ndn::mgmt::CommandContinuation& done);
73 
77  void
78  enableLocalControl(const Name& topPrefix, const Interest& interest,
79  const ControlParameters& parameters,
80  const ndn::mgmt::CommandContinuation& done);
81 
85  void
86  disableLocalControl(const Name& topPrefix, const Interest& interest,
87  const ControlParameters& parameters,
88  const ndn::mgmt::CommandContinuation& done);
89 
90 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // helpers for ControlCommand
91  void
92  afterCreateFaceSuccess(const ControlParameters& parameters,
93  const shared_ptr<Face>& newFace,
94  const ndn::mgmt::CommandContinuation& done);
95 
96  void
97  afterCreateFaceFailure(uint32_t status,
98  const std::string& reason,
99  const ndn::mgmt::CommandContinuation& done);
100 
101  Face*
102  findFaceForLocalControl(const Interest& request,
103  const ControlParameters& parameters,
104  const ndn::mgmt::CommandContinuation& done);
105 
106  static void
107  setLinkServiceOptions(Face& face,
108  const ControlParameters& parameters,
109  ControlParameters& response);
110 
111 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // StatusDataset
112  void
113  listFaces(const Name& topPrefix, const Interest& interest,
115 
116  void
117  listChannels(const Name& topPrefix, const Interest& interest,
119 
120  void
121  queryFaces(const Name& topPrefix, const Interest& interest,
123 
124 private: // helpers for StatusDataset handler
125  bool
126  matchFilter(const ndn::nfd::FaceQueryFilter& filter, const Face& face);
127 
130  static ndn::nfd::FaceStatus
131  collectFaceStatus(const Face& face, const time::steady_clock::TimePoint& now);
132 
136  template<typename FaceTraits>
137  static void
138  collectFaceProperties(const Face& face, FaceTraits& traits);
139 
140 private: // NotificationStream
141  void
142  notifyFaceEvent(const Face& face, ndn::nfd::FaceEventKind kind);
143 
144  void
145  connectFaceStateChangeSignal(const Face& face);
146 
147 private: // configuration
148  void
149  processConfig(const ConfigSection& configSection, bool isDryRun,
150  const std::string& filename);
151 
152  void
153  processSectionUnix(const ConfigSection& configSection, bool isDryRun);
154 
155  void
156  processSectionTcp(const ConfigSection& configSection, bool isDryRun);
157 
158  void
159  processSectionUdp(const ConfigSection& configSection, bool isDryRun,
160  const std::vector<NetworkInterfaceInfo>& nicList);
161 
162  void
163  processSectionEther(const ConfigSection& configSection, bool isDryRun,
164  const std::vector<NetworkInterfaceInfo>& nicList);
165 
166  void
167  processSectionWebSocket(const ConfigSection& configSection, bool isDryRun);
168 
170  std::map<std::string /*protocol*/, shared_ptr<ProtocolFactory>> m_factories;
171  FaceTable& m_faceTable;
172  std::map<FaceId, signal::ScopedConnection> m_faceStateChangeConn;
173 
174 private:
175  ndn::mgmt::PostNotification m_postNotification;
176  signal::ScopedConnection m_faceAddConn;
177  signal::ScopedConnection m_faceRemoveConn;
178 };
179 
180 } // namespace nfd
181 
182 #endif // NFD_DAEMON_MGMT_FACE_MANAGER_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40
void setConfigFile(ConfigFile &configFile)
Subscribe to face_system section for the config file.
time_point TimePoint
Definition: time.hpp:120
represents parameters in a ControlCommand request or response
std::function< void(const Block &notification)> PostNotification
a function to post a notification
Definition: dispatcher.hpp:123
generalization of a network interface
Definition: face.hpp:67
represents a dispatcher on server side of NFD Management protocol
Definition: dispatcher.hpp:129
configuration file parsing utility
Definition: config-file.hpp:50
represents an Interest packet
Definition: interest.hpp:42
container of all faces
Definition: face-table.hpp:37
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
disconnects a Connection automatically upon destruction
represents Face status
Definition: face-status.hpp:37
boost::property_tree::ptree ConfigSection
FaceTable
Definition: face-table.cpp:34
Name abstraction to represent an absolute name.
Definition: name.hpp:46
FaceManager(FaceTable &faceTable, Dispatcher &dispatcher, CommandAuthenticator &authenticator)
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
Definition: dispatcher.hpp:95
represents Face Query Filter
provides ControlCommand authorization according to NFD configuration file
NetworkInterfaceInfo
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
provides a context for generating response to a StatusDataset request
a collection of common functions shared by all NFD managers, such as communicating with the dispatche...
implement the Face Management of NFD Management Protocol.