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 
42 class Controller : noncopyable
43 {
44 public:
47  typedef function<void(const ControlParameters&)> CommandSucceedCallback;
48 
51  typedef function<void(uint32_t/*code*/,const std::string&/*reason*/)> CommandFailCallback;
52 
56  Controller(Face& face, KeyChain& keyChain);
57 
60  template<typename Command>
61  void
62  start(const ControlParameters& parameters,
63  const CommandSucceedCallback& onSuccess,
64  const CommandFailCallback& onFailure,
65  const CommandOptions& options = CommandOptions())
66  {
67  shared_ptr<ControlCommand> command = make_shared<Command>();
68  this->startCommand(command, parameters, onSuccess, onFailure, options);
69  }
70 
71 private:
72  void
73  startCommand(const shared_ptr<ControlCommand>& command,
74  const ControlParameters& parameters,
75  const CommandSucceedCallback& onSuccess,
76  const CommandFailCallback& onFailure,
77  const CommandOptions& options);
78 
79  void
80  processCommandResponse(const Data& data,
81  const shared_ptr<ControlCommand>& command,
82  const CommandSucceedCallback& onSuccess,
83  const CommandFailCallback& onFailure);
84 
85 public:
88  static const uint32_t ERROR_TIMEOUT;
89 
92  static const uint32_t ERROR_NACK;
93 
96  static const uint32_t ERROR_SERVER;
97 
100  static const uint32_t ERROR_LBOUND;
101 
102 protected:
105 };
106 
107 } // namespace nfd
108 } // namespace ndn
109 
110 #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
The packet signing interface.
Definition: key-chain.hpp:48
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:40
Abstraction to communicate with local or remote NDN forwarder.
Definition: face.hpp:119
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
static const uint32_t ERROR_NACK
error code for network Nack