32 #define NDN_LOG_DEBUG_DEPTH(x) NDN_LOG_DEBUG(std::string(state->getDepth() + 1, '>') << " " << x) 33 #define NDN_LOG_TRACE_DEPTH(x) NDN_LOG_TRACE(std::string(state->getDepth() + 1, '>') << " " << x) 37 , m_scheduler(face.getIoService())
43 const shared_ptr<ValidationState>& state,
48 dataCallback(data, certRequest, state, continueValidation);
51 nackCallback(nack, certRequest, state, continueValidation);
54 timeoutCallback(certRequest, state, continueValidation);
59 CertificateFetcherFromNetwork::dataCallback(
const Data& data,
60 const shared_ptr<CertificateRequest>& certRequest,
61 const shared_ptr<ValidationState>& state,
62 const ValidationContinuation& continueValidation)
71 return state->fail({ValidationError::Code::MALFORMED_CERT,
"Fetched a malformed certificate " 74 continueValidation(cert, state);
78 CertificateFetcherFromNetwork::nackCallback(
const lp::Nack& nack,
79 const shared_ptr<CertificateRequest>& certRequest,
80 const shared_ptr<ValidationState>& state,
81 const ValidationContinuation& continueValidation)
84 << certRequest->interest.getName());
86 --certRequest->nRetriesLeft;
87 if (certRequest->nRetriesLeft >= 0) {
89 [=] { fetch(certRequest, state, continueValidation); });
90 certRequest->waitAfterNack *= 2;
93 state->fail({ValidationError::Code::CANNOT_RETRIEVE_CERT,
"Cannot fetch certificate after all " 94 "retries `" + certRequest->interest.getName().toUri() +
"`"});
99 CertificateFetcherFromNetwork::timeoutCallback(
const shared_ptr<CertificateRequest>& certRequest,
100 const shared_ptr<ValidationState>& state,
101 const ValidationContinuation& continueValidation)
103 NDN_LOG_DEBUG_DEPTH(
"Timeout while fetching certificate " << certRequest->interest.getName()
106 --certRequest->nRetriesLeft;
107 if (certRequest->nRetriesLeft >= 0) {
108 fetch(certRequest, state, continueValidation);
111 state->fail({ValidationError::Code::CANNOT_RETRIEVE_CERT,
"Cannot fetch certificate after all " 112 "retries `" + certRequest->interest.getName().toUri() +
"`"});
Copyright (c) 2011-2015 Regents of the University of California.
std::string toUri() const
Get URI representation of the name.
The certificate following the certificate format naming convention.
const Name & getName() const
Get name.
Interface used by the validator to fetch missing certificates.
Represents an Interest packet.
std::function< void(const Certificate &cert, const shared_ptr< ValidationState > &state)> ValidationContinuation
EventId scheduleEvent(time::nanoseconds after, const 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.
PendingInterestHandle expressInterest(const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout)
Express Interest.
#define NDN_LOG_INIT(name)
declare a log module
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.