28 #include <boost/lexical_cast.hpp> 43 , m_keyChain(keyChain)
44 , m_validator(validator)
50 Controller::startCommand(
const shared_ptr<ControlCommand>& command,
61 Name requestName = command->getRequestName(options.
getPrefix(), parameters);
67 this->processCommandResponse(data, command, onSuccess, onFailure);
70 onFailure(
ControlResponse(Controller::ERROR_NACK,
"network Nack received"));
73 onFailure(
ControlResponse(Controller::ERROR_TIMEOUT,
"request timed out"));
78 Controller::processCommandResponse(
const Data& data,
79 const shared_ptr<ControlCommand>& command,
84 [=] (
const Data& data) {
85 this->processValidatedCommandResponse(data, command, onSuccess, onFailure);
94 Controller::processValidatedCommandResponse(
const Data& data,
95 const shared_ptr<ControlCommand>& command,
108 uint32_t code = response.
getCode();
124 command->validateResponse(parameters);
131 onSuccess(parameters);
135 Controller::fetchDataset(
const Name& prefix,
136 const std::function<
void(
const ConstBufferPtr&)>& processResponse,
144 bind(&Controller::processDatasetFetchError,
this, onFailure, _1, _2));
149 uint32_t code, std::string msg)
151 switch (static_cast<SegmentFetcher::ErrorCode>(code)) {
155 case SegmentFetcher::ErrorCode::INTEREST_TIMEOUT:
158 case SegmentFetcher::ErrorCode::DATA_HAS_NO_SEGMENT:
161 case SegmentFetcher::ErrorCode::SEGMENT_VALIDATION_FAIL:
166 case SegmentFetcher::ErrorCode::NACK_ERROR:
void wireDecode(const Block &wire) final
Copyright (c) 2011-2015 Regents of the University of California.
represents parameters in a ControlCommand request or response
security::CommandInterestSigner m_signer
const Block & getBody() const
Utility class to fetch latest version of the segmented data.
represents an Interest packet
function< void(const ControlResponse &)> CommandFailCallback
a callback on command failure
const Name & getPrefix() const
static const uint32_t ERROR_TIMEOUT
error code for timeout
represents a Network Nack
function< void(const ControlParameters &)> CommandSucceedCallback
a callback on command success
static const uint32_t ERROR_LBOUND
inclusive lower bound of error codes
mgmt::ControlResponse ControlResponse
Block blockFromValue() const
contains options for ControlCommand execution
Copyright (c) 2011-2015 Regents of the University of California.
void validate(const Data &data, const DataValidationSuccessCallback &successCb, const DataValidationFailureCallback &failureCb)
Asynchronously validate data.
static void fetch(Face &face, const Interest &baseInterest, security::v2::Validator &validator, const CompleteCallback &completeCallback, const ErrorCallback &errorCallback)
Initiate segment fetching.
Provide a communication channel with local or remote NDN forwarder.
static const uint32_t ERROR_VALIDATION
error code for response validation failure
Controller(Face &face, KeyChain &keyChain, security::v2::Validator &validator=security::getAcceptAllValidator())
construct a Controller that uses face for transport, and uses the passed KeyChain to sign commands ...
Interest makeCommandInterest(const Name &name, const SigningInfo ¶ms=KeyChain::getDefaultSigningInfo())
Create CommandInterest.
Represents an absolute name.
void wireDecode(const Block &block)
Interest & setInterestLifetime(time::milliseconds interestLifetime)
Set Interest's lifetime.
Validation error code and optional detailed error message.
const Block & getContent() const
Get Content.
security::v2::Validator & m_validator
const PendingInterestId * expressInterest(const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout)
Express Interest.
represents an error in ControlParameters
Represents a Data packet.
const time::milliseconds & getTimeout() const
represents an error in TLV encoding or decoding
Interface for validating data and interest packets.
static const uint32_t ERROR_SERVER
error code for server error
static const uint32_t ERROR_NACK
error code for network Nack
const security::SigningInfo & getSigningInfo() const
function< void(uint32_t code, const std::string &reason)> DatasetFailCallback
a callback on dataset retrieval failure
shared_ptr< const Buffer > ConstBufferPtr