27 #include <boost/lexical_cast.hpp> 42 , m_keyChain(keyChain)
43 , m_validator(validator)
49 Controller::startCommand(
const shared_ptr<ControlCommand>& command,
55 Name requestName = command->getRequestName(options.
getPrefix(), parameters);
61 processCommandResponse(data, command, onSuccess, onFailure);
65 onFailure(
ControlResponse(Controller::ERROR_NACK,
"network Nack received"));
69 onFailure(
ControlResponse(Controller::ERROR_TIMEOUT,
"request timed out"));
74 Controller::processCommandResponse(
const Data& data,
75 const shared_ptr<ControlCommand>& command,
80 [=] (
const Data& data) {
81 processValidatedCommandResponse(data, command, onSuccess, onFailure);
83 [=] (
const Data&,
const auto& error) {
91 Controller::processValidatedCommandResponse(
const Data& data,
92 const shared_ptr<ControlCommand>& command,
106 uint32_t code = response.
getCode();
124 command->validateResponse(parameters);
133 onSuccess(parameters);
137 Controller::fetchDataset(
const Name& prefix,
146 if (processResponse) {
147 fetcher->onComplete.connect(processResponse);
150 fetcher->onError.connect([=] (uint32_t code,
const std::string& msg) {
151 processDatasetFetchError(onFailure, code, msg);
158 uint32_t code, std::string msg)
160 BOOST_ASSERT(onFailure);
162 switch (static_cast<SegmentFetcher::ErrorCode>(code)) {
166 case SegmentFetcher::ErrorCode::INTEREST_TIMEOUT:
169 case SegmentFetcher::ErrorCode::DATA_HAS_NO_SEGMENT:
170 case SegmentFetcher::ErrorCode::FINALBLOCKID_NOT_SEGMENT:
173 case SegmentFetcher::ErrorCode::SEGMENT_VALIDATION_FAIL:
178 case SegmentFetcher::ErrorCode::NACK_ERROR:
void wireDecode(const Block &wire) final
Copyright (c) 2013-2017 Regents of the University of California.
represents parameters in a ControlCommand request or response
security::CommandInterestSigner m_signer
function< void(const ControlResponse &)> CommandFailCallback
a callback on command failure
const Block & getBody() const
function< void(uint32_t code, const std::string &reason)> DatasetFailCallback
a callback on dataset retrieval failure
time::milliseconds maxTimeout
maximum allowed time between successful receipt of segments
Utility class to fetch the latest version of a segmented object.
Represents an Interest packet.
const Name & getPrefix() const
static const uint32_t ERROR_TIMEOUT
error code for timeout
represents a Network Nack
static const uint32_t ERROR_LBOUND
inclusive lower bound of error codes
mgmt::ControlResponse ControlResponse
Block blockFromValue() const
contains options for ControlCommand execution
static shared_ptr< SegmentFetcher > start(Face &face, const Interest &baseInterest, security::v2::Validator &validator, const Options &options=Options())
Initiates segment fetching.
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.
Represents an absolute name.
function< void(const ControlParameters &)> CommandSucceedCallback
a callback on command success
void wireDecode(const Block &block)
const Block & getContent() const
Get Content.
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.
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
shared_ptr< const Buffer > ConstBufferPtr