All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ndnd-controller.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
7 #ifndef NDN_MANAGEMENT_NDND_CONTROLLER_HPP
8 #define NDN_MANAGEMENT_NDND_CONTROLLER_HPP
9 
10 #include "controller.hpp"
11 
12 namespace ndn {
13 namespace ndnd {
14 
15 class FaceInstance;
16 class ForwardingEntry;
17 
18 /*
19  * @brief Class implementing Face and Prefix management operations for ndnd-tlv
20  *
21  * ndnd::Control should be used when connecting to ndnd-tlv daemon
22  */
24 {
25 public:
26  typedef function<void(const ForwardingEntry&)> PrefixOperationSucceedCallback;
27  typedef function<void(const FaceInstance&)> FaceOperationSucceedCallback;
28 
32  Controller(Face& face);
33 
34  virtual void
35  selfRegisterPrefix(const Name& prefixToRegister,
36  const SuccessCallback& onSuccess,
37  const FailCallback& onFail);
38 
39  virtual void
40  selfDeregisterPrefix(const Name& prefixToRegister,
41  const SuccessCallback& onSuccess,
42  const FailCallback& onFail);
43 
44 protected:
45  void
46  startFaceAction(const FaceInstance& entry,
47  const FaceOperationSucceedCallback& onSuccess,
48  const FailCallback& onFailure);
49 
50  void
52  const PrefixOperationSucceedCallback& onSuccess,
53  const FailCallback& onFailure);
54 
55 private:
56  void
57  onNdnidFetched(const Interest& interest, Data& data);
58 
59  void
60  recordSelfRegisteredFaceId(const ForwardingEntry& entry,
61  const SuccessCallback& onSuccess);
62 
63  void
64  processFaceActionResponse(Data& data,
65  const FaceOperationSucceedCallback& onSuccess,
66  const FailCallback& onFail);
67 
68  void
69  processPrefixActionResponse(Data& data,
70  const PrefixOperationSucceedCallback& onSuccess,
71  const FailCallback& onFail);
72 
73 private:
74  Face& m_face;
75  Block m_ndndId;
76  int64_t m_faceId; // internal face ID (needed for prefix de-registration)
77 
78  struct FilterRequest
79  {
80  FilterRequest(const Name& prefixToRegister,
81  const SuccessCallback& onSuccess,
82  const FailCallback& onFailure)
83  : m_prefixToRegister(prefixToRegister)
84  , m_onSuccess(onSuccess)
85  , m_onFailure(onFailure)
86  {
87  }
88 
89  Name m_prefixToRegister;
90  SuccessCallback m_onSuccess;
91  FailCallback m_onFailure;
92  };
93 
94  typedef std::list<FilterRequest> FilterRequestList;
95  FilterRequestList m_filterRequests;
96 };
97 
98 } // namespace ndnd
99 } // namespace ndn
100 
101 #endif // NDN_MANAGEMENT_NDND_CONTROLLER_HPP
virtual void selfDeregisterPrefix(const Name &prefixToRegister, const SuccessCallback &onSuccess, const FailCallback &onFail)
function< void(const FaceInstance &)> FaceOperationSucceedCallback
function< void()> SuccessCallback
Definition: controller.hpp:23
Class representing wire element of the NDN packet.
Definition: block.hpp:26
An Interest holds a Name and other fields for an interest.
Definition: interest.hpp:24
Controller(Face &face)
Construct ndnd::Control object.
void startFaceAction(const FaceInstance &entry, const FaceOperationSucceedCallback &onSuccess, const FailCallback &onFailure)
void startPrefixAction(const ForwardingEntry &entry, const PrefixOperationSucceedCallback &onSuccess, const FailCallback &onFailure)
virtual void selfRegisterPrefix(const Name &prefixToRegister, const SuccessCallback &onSuccess, const FailCallback &onFail)
function< void(const std::string &)> FailCallback
Definition: controller.hpp:24
An ForwardingEntry holds an action and Name prefix and other fields for an forwarding entry...
Abstraction to communicate with local or remote NDN forwarder.
Definition: face.hpp:54
An FaceInstance holds an action and Name prefix and other fields for an forwarding entry...
function< void(const ForwardingEntry &)> PrefixOperationSucceedCallback
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:26