28 #include <boost/lexical_cast.hpp> 43 , m_keyChain(keyChain)
44 , m_validator(validator)
50 Controller::startCommand(
const shared_ptr<ControlCommand>& command,
52 const CommandSucceedCallback& onSuccess1,
53 const CommandFailCallback& onFailure1,
61 Name requestName = command->getRequestName(options.
getPrefix(), parameters);
67 this->processCommandResponse(data, command, onSuccess, onFailure);
78 Controller::processCommandResponse(
const Data& data,
79 const shared_ptr<ControlCommand>& command,
80 const CommandSucceedCallback& onSuccess,
81 const CommandFailCallback& onFailure)
84 [=] (
const Data& data) {
85 this->processValidatedCommandResponse(data, command, onSuccess, onFailure);
87 [=] (
const Data& data,
const security::v2::ValidationError& error) {
94 Controller::processValidatedCommandResponse(
const Data& data,
95 const shared_ptr<ControlCommand>& command,
96 const CommandSucceedCallback& onSuccess,
97 const CommandFailCallback& onFailure)
101 response.
wireDecode(data.getContent().blockFromValue());
103 catch (
const tlv::Error& e) {
108 uint32_t code = response.getCode();
118 catch (
const tlv::Error& e) {
124 command->validateResponse(parameters);
126 catch (
const ControlCommand::ArgumentError& e) {
131 onSuccess(parameters);
135 Controller::fetchDataset(
const Name& prefix,
136 const std::function<
void(
const ConstBufferPtr&)>& processResponse,
137 const DatasetFailCallback& onFailure,
138 const CommandOptions& options)
141 baseInterest.setInterestLifetime(options.getTimeout());
144 bind(&Controller::processDatasetFetchError,
this, onFailure, _1, _2));
148 Controller::processDatasetFetchError(
const DatasetFailCallback& onFailure,
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.
The interface of signing key management.
represents parameters in a ControlCommand request or response
security::CommandInterestSigner m_signer
const security::SigningInfo & getSigningInfo() const
static shared_ptr< SegmentFetcher > fetch(Face &face, const Interest &baseInterest, security::v2::Validator &validator, const CompleteCallback &completeCallback, const ErrorCallback &errorCallback)
Initiates segment fetching.
Utility class to fetch latest version of the segmented data.
const time::milliseconds & getTimeout() const
function< void(const ControlResponse &)> CommandFailCallback
a callback on command failure
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
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.
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.
const Name & getPrefix() const
void wireDecode(const Block &block)
security::v2::Validator & m_validator
Interest & setInterestLifetime(time::milliseconds lifetime)
Set Interest's lifetime.
const PendingInterestId * expressInterest(const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout)
Express Interest.
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
shared_ptr< const Buffer > ConstBufferPtr