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 "
75 "`" + data.
getName().toUri() +
"` (" + e.what() +
")"});
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() +
"`"});
#define NDN_LOG_DEBUG_DEPTH(x)
Represents a Data packet.
const Name & getName() const noexcept
Get name.
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.
Represents an Interest packet.
represents a Network Nack
NackReason getReason() const
EventId schedule(time::nanoseconds after, EventCallback callback)
Schedule a one-time event after the specified delay.
CertificateFetcherFromNetwork(Face &face)
void doFetch(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation) override
Asynchronous certificate fetching implementation.
void dataCallback(const Data &data, const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Callback invoked when certificate is retrieved.
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.
void timeoutCallback(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Callback invoked when interest for fetching certificate times out.
Interface used by the validator to fetch missing certificates.
void fetch(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Asynchronously fetch certificate.
std::function< void(const Certificate &cert, const shared_ptr< ValidationState > &state)> ValidationContinuation
Represents an NDN certificate following the version 2.0 format.
represents an error in TLV encoding or decoding
#define NDN_LOG_INIT(name)
Define a non-member log module.