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 "face/face.hpp"
33 
34 namespace nfd {
35 
36 class FaceTable;
37 class NetworkInterfaceInfo;
38 class ProtocolFactory;
39 
45 {
46 public:
47  FaceManager(FaceTable& faceTable,
48  Dispatcher& dispatcher,
49  CommandAuthenticator& authenticator);
50 
54  void
55  setConfigFile(ConfigFile& configFile);
56 
57 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // ControlCommand
58  void
59  createFace(const Name& topPrefix, const Interest& interest,
60  const ControlParameters& parameters,
61  const ndn::mgmt::CommandContinuation& done);
62 
63  void
64  updateFace(const Name& topPrefix, const Interest& interest,
65  const ControlParameters& parameters,
66  const ndn::mgmt::CommandContinuation& done);
67 
68  void
69  destroyFace(const Name& topPrefix, const Interest& interest,
70  const ControlParameters& parameters,
71  const ndn::mgmt::CommandContinuation& done);
72 
76  void
77  enableLocalControl(const Name& topPrefix, const Interest& interest,
78  const ControlParameters& parameters,
79  const ndn::mgmt::CommandContinuation& done);
80 
84  void
85  disableLocalControl(const Name& topPrefix, const Interest& interest,
86  const ControlParameters& parameters,
87  const ndn::mgmt::CommandContinuation& done);
88 
89 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // helpers for ControlCommand
90  void
91  afterCreateFaceSuccess(const ControlParameters& parameters,
92  const shared_ptr<Face>& newFace,
93  const ndn::mgmt::CommandContinuation& done);
94 
95  void
96  afterCreateFaceFailure(uint32_t status,
97  const std::string& reason,
98  const ndn::mgmt::CommandContinuation& done);
99 
100  Face*
101  findFaceForLocalControl(const Interest& request,
102  const ControlParameters& parameters,
103  const ndn::mgmt::CommandContinuation& done);
104 
105  static void
106  setLinkServiceOptions(Face& face,
107  const ControlParameters& parameters,
108  ControlParameters& response);
109 
110 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // StatusDataset
111  void
112  listFaces(const Name& topPrefix, const Interest& interest,
113  ndn::mgmt::StatusDatasetContext& context);
114 
115  void
116  listChannels(const Name& topPrefix, const Interest& interest,
117  ndn::mgmt::StatusDatasetContext& context);
118 
119  void
120  queryFaces(const Name& topPrefix, const Interest& interest,
121  ndn::mgmt::StatusDatasetContext& context);
122 
123 private: // helpers for StatusDataset handler
124  bool
125  matchFilter(const ndn::nfd::FaceQueryFilter& filter, const Face& face);
126 
129  static ndn::nfd::FaceStatus
130  collectFaceStatus(const Face& face, const time::steady_clock::TimePoint& now);
131 
135  template<typename FaceTraits>
136  static void
137  collectFaceProperties(const Face& face, FaceTraits& traits);
138 
139 private: // NotificationStream
140  void
141  notifyAddFace(const Face& face);
142 
143  void
144  notifyRemoveFace(const Face& face);
145 
146 private: // configuration
147  void
148  processConfig(const ConfigSection& configSection, bool isDryRun,
149  const std::string& filename);
150 
151  void
152  processSectionUnix(const ConfigSection& configSection, bool isDryRun);
153 
154  void
155  processSectionTcp(const ConfigSection& configSection, bool isDryRun);
156 
157  void
158  processSectionUdp(const ConfigSection& configSection, bool isDryRun,
159  const std::vector<NetworkInterfaceInfo>& nicList);
160 
161  void
162  processSectionEther(const ConfigSection& configSection, bool isDryRun,
163  const std::vector<NetworkInterfaceInfo>& nicList);
164 
165  void
166  processSectionWebSocket(const ConfigSection& configSection, bool isDryRun);
167 
169  std::map<std::string /*protocol*/, shared_ptr<ProtocolFactory>> m_factories;
170  FaceTable& m_faceTable;
171 
172 private:
173  ndn::mgmt::PostNotification m_postNotification;
174  signal::ScopedConnection m_faceAddConn;
175  signal::ScopedConnection m_faceRemoveConn;
176 };
177 
178 } // namespace nfd
179 
180 #endif // NFD_DAEMON_MGMT_FACE_MANAGER_HPP
configuration file parsing utility
Definition: config-file.hpp:50
container of all faces
Definition: face-table.hpp:37
implement the Face Management of NFD Management Protocol.
provides ControlCommand authorization according to NFD configuration file
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
a collection of common functions shared by all NFD managers, such as communicating with the dispatche...
boost::property_tree::ptree ConfigSection
Definition: config-file.hpp:35
void setConfigFile(ConfigFile &configFile)
Subscribe to face_system section for the config file.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:39
FaceManager(FaceTable &faceTable, Dispatcher &dispatcher, CommandAuthenticator &authenticator)