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) 42 const shared_ptr<ValidationState>& state,
47 dataCallback(data, certRequest, state, continueValidation);
50 nackCallback(nack, certRequest, state, continueValidation);
53 timeoutCallback(certRequest, state, continueValidation);
58 CertificateFetcherFromNetwork::dataCallback(
const Data& data,
59 const shared_ptr<CertificateRequest>& certRequest,
60 const shared_ptr<ValidationState>& state,
61 const ValidationContinuation& continueValidation)
70 return state->fail({ValidationError::Code::MALFORMED_CERT,
"Fetched a malformed certificate " 73 continueValidation(cert, state);
77 CertificateFetcherFromNetwork::nackCallback(
const lp::Nack& nack,
78 const shared_ptr<CertificateRequest>& certRequest,
79 const shared_ptr<ValidationState>& state,
80 const ValidationContinuation& continueValidation)
83 << certRequest->m_interest.getName());
85 --certRequest->m_nRetriesLeft;
86 if (certRequest->m_nRetriesLeft >= 0) {
88 fetch(certRequest, state, continueValidation);
91 state->fail({ValidationError::Code::CANNOT_RETRIEVE_CERT,
"Cannot fetch certificate after all " 92 "retries `" + certRequest->m_interest.getName().toUri() +
"`"});
97 CertificateFetcherFromNetwork::timeoutCallback(
const shared_ptr<CertificateRequest>& certRequest,
98 const shared_ptr<ValidationState>& state,
99 const ValidationContinuation& continueValidation)
101 NDN_LOG_DEBUG_DEPTH(
"Timeout while fetching certificate " << certRequest->m_interest.getName()
104 --certRequest->m_nRetriesLeft;
105 if (certRequest->m_nRetriesLeft >= 0) {
106 fetch(certRequest, state, continueValidation);
109 state->fail({ValidationError::Code::CANNOT_RETRIEVE_CERT,
"Cannot fetch certificate after all " 110 "retries `" + certRequest->m_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
represents a Network Nack
NackReason getReason() const
#define NDN_LOG_INIT(name)
declare a log module
#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 PendingInterestId * expressInterest(const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout)
Express Interest.
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.