26#include <boost/lexical_cast.hpp>
32 , m_keyChain(keyChain)
33 , m_validator(validator)
46Controller::sendCommandRequest(
Interest& interest,
48 ResponseParametersValidator checkResponse,
52 BOOST_ASSERT(checkResponse);
57 [=, check = std::move(checkResponse), success = std::move(onSuccess)] (
const auto&,
const Data& d) {
58 processCommandResponse(d, std::move(check), std::move(success), onFailure);
63 "received Nack: " + boost::lexical_cast<std::string>(nack.getReason())));
65 [onFailure] (
const Interest&) {
72Controller::processCommandResponse(
const Data& data,
73 ResponseParametersValidator checkResponse,
78 [check = std::move(checkResponse), success = std::move(onSuccess), onFailure] (
const Data& d) {
79 processValidatedCommandResponse(d, check, success, onFailure);
81 [onFailure] (
const Data&,
const auto& error) {
89Controller::processValidatedCommandResponse(
const Data& data,
90 const ResponseParametersValidator& checkResponse,
96 response.
wireDecode(data.getContent().blockFromValue());
98 catch (
const tlv::Error& e) {
112 parameters.wireDecode(response.getBody());
114 catch (
const tlv::Error& e) {
121 checkResponse(parameters);
123 catch (
const std::invalid_argument& e) {
130 onSuccess(parameters);
134Controller::fetchDataset(
const Name& prefix,
137 const CommandOptions& options)
140 fetcherOptions.
maxTimeout = options.getTimeout();
143 fetcher->onComplete.connect(processResponse);
145 fetcher->onError.connect([onFailure] (uint32_t code,
const std::string& msg) {
146 processDatasetFetchError(onFailure, code, msg);
151 fetcher->onComplete.connect([
this, it] (
auto&&...) {
m_fetchers.erase(it); });
152 fetcher->onError.connect([
this, it] (
auto&&...) {
m_fetchers.erase(it); });
157 uint32_t code, std::string msg)
159 BOOST_ASSERT(onFailure);
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.
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.
@ INTEREST_TIMEOUT
Retrieval timed out because the maximum timeout between the successful receipt of segments was exceed...
@ FINALBLOCKID_NOT_SEGMENT
A received FinalBlockId did not contain a segment component.
@ NACK_ERROR
An unrecoverable Nack was received during retrieval.
@ SEGMENT_VALIDATION_FAIL
One of the retrieved segments failed user-provided validation.
@ DATA_HAS_NO_SEGMENT
One of the retrieved Data packets lacked a segment number in the last Name component (excl....
SegmentFetcherOptions Options
Represents a Network Nack.
void wireDecode(const Block &block)
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.
Signing parameters passed to KeyChain.
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.