NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
nfd-controller.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_MANAGEMENT_NFD_CONTROLLER_HPP
23 #define NDN_MANAGEMENT_NFD_CONTROLLER_HPP
24 
25 #include "nfd-control-command.hpp"
26 #include "../face.hpp"
27 #include "../security/key-chain.hpp"
28 #include "nfd-command-options.hpp"
29 
30 namespace ndn {
31 namespace nfd {
32 
41 class Controller : noncopyable
42 {
43 public:
46  typedef function<void(const ControlParameters&)> CommandSucceedCallback;
47 
50  typedef function<void(uint32_t/*code*/,const std::string&/*reason*/)> CommandFailCallback;
51 
55  Controller(Face& face, KeyChain& keyChain);
56 
59  template<typename Command>
60  void
61  start(const ControlParameters& parameters,
62  const CommandSucceedCallback& onSuccess,
63  const CommandFailCallback& onFailure,
64  const CommandOptions& options = CommandOptions())
65  {
66  shared_ptr<ControlCommand> command = make_shared<Command>();
67  this->startCommand(command, parameters, onSuccess, onFailure, options);
68  }
69 
70 private:
71  void
72  startCommand(const shared_ptr<ControlCommand>& command,
73  const ControlParameters& parameters,
74  const CommandSucceedCallback& onSuccess,
75  const CommandFailCallback& onFailure,
76  const CommandOptions& options);
77 
78  void
79  processCommandResponse(const Data& data,
80  const shared_ptr<ControlCommand>& command,
81  const CommandSucceedCallback& onSuccess,
82  const CommandFailCallback& onFailure);
83 
84 public:
88  static const uint32_t ERROR_TIMEOUT;
89 
92  static const uint32_t ERROR_SERVER;
93 
96  static const uint32_t ERROR_LBOUND;
97 
98 protected:
100  KeyChain& m_keyChain;
101 };
102 
103 } // namespace nfd
104 } // namespace ndn
105 
106 #endif // NDN_MANAGEMENT_NFD_CONTROLLER_HPP
void start(const ControlParameters &parameters, const CommandSucceedCallback &onSuccess, const CommandFailCallback &onFailure, const CommandOptions &options=CommandOptions())
start command execution
Copyright (c) 2011-2015 Regents of the University of California.
represents parameters in a ControlCommand request or response
static const uint32_t ERROR_TIMEOUT
error code for timeout
function< void(const ControlParameters &)> CommandSucceedCallback
a callback on command success
static const uint32_t ERROR_LBOUND
inclusive lower bound of error codes
contains options for ControlCommand execution
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
Abstraction to communicate with local or remote NDN forwarder.
Definition: face.hpp:100
NFD Management protocol - ControlCommand client.
function< void(uint32_t, const std::string &)> CommandFailCallback
a callback on command failure
Controller(Face &face, KeyChain &keyChain)
construct a Controller that uses face for transport, and uses the passed KeyChain to sign commands ...
represents a Data packet
Definition: data.hpp:39
static const uint32_t ERROR_SERVER
error code for server error