NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 "manager-base.hpp"
30 #include <ndn-cxx/management/nfd-face-status.hpp>
31 #include <ndn-cxx/management/nfd-face-query-filter.hpp>
32 #include "face/face.hpp"
33 
34 namespace nfd {
35 
36 class FaceTable;
38 class ProtocolFactory;
39 
44 class FaceManager : public ManagerBase
45 {
46 public:
47  FaceManager(FaceTable& faceTable,
48  Dispatcher& dispatcher,
49  CommandValidator& validator);
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  destroyFace(const Name& topPrefix, const Interest& interest,
65  const ControlParameters& parameters,
66  const ndn::mgmt::CommandContinuation& done);
67 
68  void
69  enableLocalControl(const Name& topPrefix, const Interest& interest,
70  const ControlParameters& parameters,
71  const ndn::mgmt::CommandContinuation& done);
72 
73  void
74  disableLocalControl(const Name& topPrefix, const Interest& interest,
75  const ControlParameters& parameters,
76  const ndn::mgmt::CommandContinuation& done);
77 
78 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // helpers for ControlCommand
79  void
80  afterCreateFaceSuccess(ControlParameters& parameters,
81  const shared_ptr<Face>& newFace,
82  const ndn::mgmt::CommandContinuation& done);
83 
84  void
85  afterCreateFaceFailure(const std::string& reason,
86  const ndn::mgmt::CommandContinuation& done);
87 
88  Face*
89  findFaceForLocalControl(const Interest& request,
90  const ControlParameters& parameters,
91  const ndn::mgmt::CommandContinuation& done);
92 
93 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // StatusDataset
94  void
95  listFaces(const Name& topPrefix, const Interest& interest,
97 
98  void
99  listChannels(const Name& topPrefix, const Interest& interest,
101 
102  void
103  queryFaces(const Name& topPrefix, const Interest& interest,
105 
106 private: // helpers for StatusDataset handler
107  bool
108  doesMatchFilter(const ndn::nfd::FaceQueryFilter& filter, shared_ptr<Face> face);
109 
112  static ndn::nfd::FaceStatus
113  collectFaceStatus(const Face& face, const time::steady_clock::TimePoint& now);
114 
118  template<typename FaceTraits>
119  static void
120  collectFaceProperties(const Face& face, FaceTraits& traits);
121 
122 private: // NotificationStream
123  void
124  afterFaceAdded(shared_ptr<Face> face,
125  const ndn::mgmt::PostNotification& post);
126 
127  void
128  afterFaceRemoved(shared_ptr<Face> face,
129  const ndn::mgmt::PostNotification& post);
130 
131 private: // configuration
132  void
133  processConfig(const ConfigSection& configSection, bool isDryRun,
134  const std::string& filename);
135 
136  void
137  processSectionUnix(const ConfigSection& configSection, bool isDryRun);
138 
139  void
140  processSectionTcp(const ConfigSection& configSection, bool isDryRun);
141 
142  void
143  processSectionUdp(const ConfigSection& configSection, bool isDryRun,
144  const std::vector<NetworkInterfaceInfo>& nicList);
145 
146  void
147  processSectionEther(const ConfigSection& configSection, bool isDryRun,
148  const std::vector<NetworkInterfaceInfo>& nicList);
149 
150  void
151  processSectionWebSocket(const ConfigSection& configSection, bool isDryRun);
152 
154  std::map<std::string /*protocol*/, shared_ptr<ProtocolFactory>> m_factories;
155 
156 private:
157  FaceTable& m_faceTable;
158  signal::ScopedConnection m_faceAddConn;
159  signal::ScopedConnection m_faceRemoveConn;
160 };
161 
162 } // namespace nfd
163 
164 #endif // NFD_DAEMON_MGMT_FACE_MANAGER_HPP
void setConfigFile(ConfigFile &configFile)
Subscribe to face_system section for the config file.
time_point TimePoint
Definition: time.hpp:108
a collection of common functions shared by all NFD managers, such as communicating with the dispatche...
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
represents a dispatcher on server side of NFD Management protocol
Definition: dispatcher.hpp:129
represents an Interest packet
Definition: interest.hpp:45
container of all Faces
Definition: face-table.hpp:38
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
disconnects a Connection automatically upon destruction
represents Face status
boost::property_tree::ptree ConfigSection
FaceTable
Definition: face-table.cpp:34
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
represents Face Query Filter
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:39
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
FaceManager(FaceTable &faceTable, Dispatcher &dispatcher, CommandValidator &validator)
implement the Face Management of NFD Management Protocol.