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,
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,
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,
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.
The certificate following the certificate format naming convention.
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
Catch-all error for security policy errors that don't fit in other categories.
NackReason getReason() const
std::string toUri() const
Get URI representation of the name.
#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 Name & getName() const
Get name.
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.