23 #include "../../face.hpp" 24 #include "../../security/key-chain.hpp" 25 #include "../../util/segment-fetcher.hpp" 37 ValidatorNull Controller::s_validatorNull;
41 , m_keyChain(keyChain)
42 , m_validator(validator)
47 Controller::startCommand(
const shared_ptr<ControlCommand>& command,
58 Name requestName = command->getRequestName(options.
getPrefix(), parameters);
65 this->processCommandResponse(data, command, onSuccess, onFailure);
68 onFailure(
ControlResponse(Controller::ERROR_NACK,
"network Nack received"));
71 onFailure(
ControlResponse(Controller::ERROR_TIMEOUT,
"request timed out"));
76 Controller::processCommandResponse(
const Data& data,
77 const shared_ptr<ControlCommand>& command,
82 [=] (
const shared_ptr<const Data>& data) {
83 this->processValidatedCommandResponse(*data, command, onSuccess, onFailure);
85 [=] (
const shared_ptr<const Data>&,
const std::string& msg) {
92 Controller::processValidatedCommandResponse(
const Data& data,
93 const shared_ptr<ControlCommand>& command,
106 uint32_t code = response.
getCode();
122 command->validateResponse(parameters);
129 onSuccess(parameters);
133 Controller::fetchDataset(
const Name& prefix,
134 const std::function<
void(
const ConstBufferPtr&)>& processResponse,
142 bind(&Controller::processDatasetFetchError,
this, onFailure, _1, _2));
147 uint32_t code, std::string msg)
149 switch (static_cast<SegmentFetcher::ErrorCode>(code)) {
153 case SegmentFetcher::ErrorCode::INTEREST_TIMEOUT:
156 case SegmentFetcher::ErrorCode::DATA_HAS_NO_SEGMENT:
159 case SegmentFetcher::ErrorCode::SEGMENT_VALIDATION_FAIL:
164 case SegmentFetcher::ErrorCode::NACK_ERROR:
virtual void wireDecode(const Block &wire) final
void validate(const Data &data, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed)
Validate Data and call either onValidated or onValidationFailed.
Copyright (c) 2011-2015 Regents of the University of California.
security::KeyChain & m_keyChain
represents parameters in a ControlCommand request or response
const Block & getContent() const
Get content Block.
const Block & getBody() const
const security::SigningInfo & getSigningInfo() const
The packet signing interface.
Utility class to fetch latest version of the segmented data.
const time::milliseconds & getTimeout() const
represents an Interest packet
function< void(const ControlResponse &)> CommandFailCallback
a callback on command failure
void sign(Data &data, const SigningInfo ¶ms=DEFAULT_SIGNING_INFO)
Sign data according to the supplied signing information.
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
ndn::mgmt::ControlResponse ControlResponse
contains options for ControlCommand execution
Copyright (c) 2011-2015 Regents of the University of California.
provides the interfaces for packet validation.
Provide a communication channel with local or remote NDN forwarder.
static const uint32_t ERROR_VALIDATION
error code for response validation failure
Name abstraction to represent an absolute name.
static void fetch(Face &face, const Interest &baseInterest, Validator &validator, const CompleteCallback &completeCallback, const ErrorCallback &errorCallback)
Initiate segment fetching.
Controller(Face &face, security::KeyChain &keyChain, security::Validator &validator=s_validatorNull)
construct a Controller that uses face for transport, and uses the passed KeyChain to sign commands ...
const Name & getPrefix() const
void wireDecode(const Block &block)
Block blockFromValue() const
security::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
shared_ptr< const Buffer > ConstBufferPtr
Interest & setInterestLifetime(const time::milliseconds &interestLifetime)
represents an error in TLV encoding or decoding
static const uint32_t ERROR_SERVER
error code for server error
static const uint32_t ERROR_NACK
error code for network Nack
function< void(uint32_t code, const std::string &reason)> DatasetFailCallback
a callback on dataset retrieval failure