26 #include <boost/lexical_cast.hpp>
32 , m_keyChain(keyChain)
33 , m_validator(validator)
46 Controller::startCommand(
const shared_ptr<ControlCommand>& command,
59 processCommandResponse(data, command, onSuccess, onFailure);
64 "received Nack: " + boost::lexical_cast<std::string>(nack.getReason())));
73 Controller::processCommandResponse(
const Data& data,
74 const shared_ptr<ControlCommand>& command,
80 processValidatedCommandResponse(d, command, onSuccess, onFailure);
82 [=] (
const Data&,
const auto& error) {
90 Controller::processValidatedCommandResponse(
const Data& data,
91 const shared_ptr<ControlCommand>& command,
97 response.
wireDecode(data.getContent().blockFromValue());
99 catch (
const tlv::Error& e) {
115 catch (
const tlv::Error& e) {
122 command->validateResponse(parameters);
124 catch (
const ControlCommand::ArgumentError& e) {
131 onSuccess(parameters);
135 Controller::fetchDataset(
const Name& prefix,
138 const CommandOptions& options)
141 fetcherOptions.
maxTimeout = options.getTimeout();
144 fetcher->onComplete.connect(processResponse);
146 fetcher->onError.connect([onFailure] (uint32_t code,
const std::string& msg) {
147 processDatasetFetchError(onFailure, code, msg);
152 fetcher->onComplete.connect([
this, it] (
auto&&...) {
m_fetchers.erase(it); });
153 fetcher->onError.connect([
this, it] (
auto&&...) {
m_fetchers.erase(it); });
158 uint32_t code, std::string msg)
160 BOOST_ASSERT(onFailure);
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:
Represents a Data packet.
Provide a communication channel with local or remote NDN forwarder.
PendingInterestHandle expressInterest(const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout)
Express an Interest.
Represents an Interest packet.
Interest & setName(const Name &name)
Set the Interest name.
Interest & setInterestLifetime(time::milliseconds lifetime)
Set the Interest's lifetime.
static shared_ptr< SegmentFetcher > start(Face &face, const Interest &baseInterest, security::Validator &validator, const Options &options={})
Initiates segment fetching.
ErrorCode
Error codes passed to onError.
SegmentFetcherOptions Options
Represents a Network Nack.
void wireDecode(const Block &block)
Contains options for ControlCommand execution.
const Name & getPrefix() const
Returns the command prefix.
time::milliseconds getTimeout() const
Returns the command timeout.
const security::SigningInfo & getSigningInfo() const
Returns the signing parameters.
Represents parameters in a ControlCommand request or response.
void wireDecode(const Block &wire) final
Controller(Face &face, KeyChain &keyChain, security::Validator &validator=security::getAcceptAllValidator())
Construct a Controller that uses face as transport and keyChain to sign commands.
@ ERROR_LBOUND
Inclusive lower bound of error codes.
@ ERROR_VALIDATION
Error code for response validation failure.
@ ERROR_SERVER
Error code for server error.
@ ERROR_NACK
Error code for network Nack.
@ ERROR_TIMEOUT
Error code for timeout.
security::InterestSigner m_signer
security::Validator & m_validator
std::set< shared_ptr< SegmentFetcher > > m_fetchers
void makeSignedInterest(Interest &interest, SigningInfo params=SigningInfo(), uint32_t signingFlags=WantNonce|WantTime)
Signs an Interest (following Packet Specification v0.3 or newer)
The main interface for signing key management.
Interface for validating data and interest packets.
void validate(const Data &data, const DataValidationSuccessCallback &successCb, const DataValidationFailureCallback &failureCb)
Asynchronously validate data.
std::function< void(const ControlResponse &)> CommandFailureCallback
Callback on command failure.
std::function< void(uint32_t code, const std::string &reason)> DatasetFailureCallback
Callback on dataset retrieval failure.
std::function< void(const ControlParameters &)> CommandSuccessCallback
Callback on command success.
Contains classes and functions related to the NFD Management protocol.
mgmt::ControlResponse ControlResponse
std::shared_ptr< const Buffer > ConstBufferPtr
time::milliseconds maxTimeout
Maximum allowed time between successful receipt of segments.