35 #define NDN_LOG_DEBUG_DEPTH(x) NDN_LOG_DEBUG(std::string(state->getDepth() + 1, '>') << " " << x) 36 #define NDN_LOG_TRACE_DEPTH(x) NDN_LOG_TRACE(std::string(state->getDepth() + 1, '>') << " " << x) 40 , m_scheduler(face.getIoService())
46 const shared_ptr<ValidationState>& state,
51 dataCallback(data, certRequest, state, continueValidation);
54 nackCallback(nack, certRequest, state, continueValidation);
57 timeoutCallback(certRequest, state, continueValidation);
63 const shared_ptr<CertificateRequest>&,
64 const shared_ptr<ValidationState>& state,
74 return state->fail({ValidationError::Code::MALFORMED_CERT,
"Fetched a malformed certificate " 77 continueValidation(cert, state);
82 const shared_ptr<CertificateRequest>& certRequest,
83 const shared_ptr<ValidationState>& state,
87 << certRequest->interest.getName());
89 --certRequest->nRetriesLeft;
90 if (certRequest->nRetriesLeft >= 0) {
92 [=] { fetch(certRequest, state, continueValidation); });
93 certRequest->waitAfterNack *= 2;
96 state->fail({ValidationError::Code::CANNOT_RETRIEVE_CERT,
"Cannot fetch certificate after all " 97 "retries `" + certRequest->interest.getName().toUri() +
"`"});
103 const shared_ptr<ValidationState>& state,
106 NDN_LOG_DEBUG_DEPTH(
"Timeout while fetching certificate " << certRequest->interest.getName()
109 --certRequest->nRetriesLeft;
110 if (certRequest->nRetriesLeft >= 0) {
111 fetch(certRequest, state, continueValidation);
114 state->fail({ValidationError::Code::CANNOT_RETRIEVE_CERT,
"Cannot fetch certificate after all " 115 "retries `" + certRequest->interest.getName().toUri() +
"`"});
Copyright (c) 2011-2015 Regents of the University of California.
Represents an NDN certificate following the version 2.0 format.
Interface used by the validator to fetch missing certificates.
void nackCallback(const lp::Nack &nack, const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Callback invoked when interest for fetching certificate gets NACKed.
Represents an Interest packet.
std::function< void(const Certificate &cert, const shared_ptr< ValidationState > &state)> ValidationContinuation
EventId schedule(time::nanoseconds after, EventCallback callback)
Schedule a one-time event after the specified delay.
represents a Network Nack
NackReason getReason() const
#define NDN_LOG_DEBUG_DEPTH(x)
void fetch(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Asynchronously fetch certificate.
CertificateFetcherFromNetwork(Face &face)
Provide a communication channel with local or remote NDN forwarder.
const Name & getName() const noexcept
Get name.
void dataCallback(const Data &data, const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Callback invoked when certificate is retrieved.
PendingInterestHandle expressInterest(const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout)
Express Interest.
void toUri(std::ostream &os, name::UriFormat format=name::UriFormat::DEFAULT) const
Write URI representation of the name to the output stream.
#define NDN_LOG_INIT(name)
declare a log module
void timeoutCallback(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Callback invoked when interest for fetching certificate times out.
Represents a Data packet.
represents an error in TLV encoding or decoding
void doFetch(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation) override
Asynchronous certificate fetching implementation.