NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
certificate-fetcher-direct-fetch.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2019 Regents of the University of California.
4
*
5
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6
*
7
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU Lesser General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later version.
10
*
11
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14
*
15
* You should have received copies of the GNU General Public License and GNU Lesser
16
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17
* <http://www.gnu.org/licenses/>.
18
*
19
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20
*/
21
22
#include "
ndn-cxx/security/v2/certificate-fetcher-direct-fetch.hpp
"
23
#include "
ndn-cxx/face.hpp
"
24
#include "
ndn-cxx/lp/tags.hpp
"
25
26
namespace
ndn
{
27
namespace
security {
28
namespace
v2 {
29
30
CertificateFetcherDirectFetch::CertificateFetcherDirectFetch
(
Face
& face)
31
:
CertificateFetcherFromNetwork
(face)
32
{
33
}
34
35
void
36
CertificateFetcherDirectFetch::setSendDirectInterestOnly
(
bool
wantDirectInterestOnly)
37
{
38
m_wantDirectInterestOnly = wantDirectInterestOnly;
39
}
40
41
void
42
CertificateFetcherDirectFetch::doFetch
(
const
shared_ptr<CertificateRequest>& keyRequest,
43
const
shared_ptr<ValidationState>& state,
44
const
ValidationContinuation
& continueValidation)
45
{
46
auto
interestState = dynamic_pointer_cast<InterestValidationState>(state);
47
uint64_t incomingFaceId = 0;
48
if
(interestState !=
nullptr
) {
49
auto
incomingFaceIdTag = interestState->getOriginalInterest().getTag<
lp::IncomingFaceIdTag
>();
50
if
(incomingFaceIdTag !=
nullptr
) {
51
incomingFaceId = incomingFaceIdTag->
get
();
52
}
53
}
54
else
{
55
auto
dataState = dynamic_pointer_cast<DataValidationState>(state);
56
auto
incomingFaceIdTag = dataState->getOriginalData().getTag<
lp::IncomingFaceIdTag
>();
57
if
(incomingFaceIdTag !=
nullptr
) {
58
incomingFaceId = incomingFaceIdTag->
get
();
59
}
60
}
61
if
(incomingFaceId != 0) {
62
Interest
directInterest(keyRequest->interest);
63
directInterest.
refreshNonce
();
64
directInterest.
setTag
(make_shared<lp::NextHopFaceIdTag>(incomingFaceId));
65
66
if
(!m_wantDirectInterestOnly) {
67
// disable callbacks
68
m_face
.
expressInterest
(directInterest,
nullptr
,
nullptr
,
nullptr
);
69
}
70
else
{
71
m_face
.
expressInterest
(directInterest,
72
[=] (
const
Interest
& interest,
const
Data
& data) {
73
dataCallback
(data, keyRequest, state, continueValidation);
74
},
75
[=] (
const
Interest
& interest,
const
lp::Nack
& nack) {
76
nackCallback
(nack, keyRequest, state, continueValidation);
77
},
78
[=] (
const
Interest
& interest) {
79
timeoutCallback
(keyRequest, state, continueValidation);
80
});
81
}
82
}
83
84
if
(!m_wantDirectInterestOnly) {
85
// send infrastructure Interest
86
CertificateFetcherFromNetwork::doFetch
(keyRequest, state, continueValidation);
87
}
88
else
if
(incomingFaceId == 0) {
89
state->fail({ValidationError::Code::CANNOT_RETRIEVE_CERT,
90
"Cannot direct fetch certificate as IncomingFaceId tag is not set"
});
91
}
92
}
93
94
}
// namespace v2
95
}
// namespace security
96
}
// namespace ndn
ndn::security::v2::CertificateFetcherFromNetwork
Fetch missing keys from the network.
Definition:
certificate-fetcher-from-network.hpp:41
ndn::security::v2::CertificateFetcherFromNetwork::m_face
Face & m_face
Definition:
certificate-fetcher-from-network.hpp:79
certificate-fetcher-direct-fetch.hpp
ndn::security::v2::CertificateFetcherDirectFetch::doFetch
void doFetch(const shared_ptr< CertificateRequest > &keyRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation) override
Asynchronous certificate fetching implementation.
Definition:
certificate-fetcher-direct-fetch.cpp:42
ndn::Face::expressInterest
PendingInterestHandle expressInterest(const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout)
Express Interest.
Definition:
face.cpp:121
ndn::SimpleTag
provides a tag type for simple types
Definition:
tag.hpp:59
ndn::TagHost::setTag
void setTag(shared_ptr< T > tag) const
set a tag item
Definition:
tag-host.hpp:79
ndn::Face
Provide a communication channel with local or remote NDN forwarder.
Definition:
face.hpp:90
ndn::Interest::refreshNonce
void refreshNonce()
Change nonce value.
Definition:
interest.cpp:420
ndn::security::v2::CertificateFetcherFromNetwork::nackCallback
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.
Definition:
certificate-fetcher-from-network.cpp:78
ndn::Interest
Represents an Interest packet.
Definition:
interest.hpp:44
ndn::Data
Represents a Data packet.
Definition:
data.hpp:36
ndn::security::v2::CertificateFetcherDirectFetch::setSendDirectInterestOnly
void setSendDirectInterestOnly(bool wantDirectInterestOnly)
If wantDirectInterestOnly, only the direct Interest will be sent out.
Definition:
certificate-fetcher-direct-fetch.cpp:36
ndn::security::v2::CertificateFetcher::ValidationContinuation
std::function< void(const Certificate &cert, const shared_ptr< ValidationState > &state)> ValidationContinuation
Definition:
certificate-fetcher.hpp:43
ndn::security::v2::CertificateFetcherFromNetwork::doFetch
void doFetch(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation) override
Asynchronous certificate fetching implementation.
Definition:
certificate-fetcher-from-network.cpp:42
face.hpp
ndn::SimpleTag::get
constexpr const T & get() const noexcept
Definition:
tag.hpp:86
ndn::lp::Nack
represents a Network Nack
Definition:
nack.hpp:39
ndn::security::v2::CertificateFetcherFromNetwork::timeoutCallback
void timeoutCallback(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Callback invoked when interest for fetching certificate times out.
Definition:
certificate-fetcher-from-network.cpp:99
tags.hpp
ndn::security::v2::CertificateFetcherFromNetwork::dataCallback
void dataCallback(const Data &data, const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Callback invoked when certificate is retrieved.
Definition:
certificate-fetcher-from-network.cpp:59
ndn::security::v2::CertificateFetcherDirectFetch::CertificateFetcherDirectFetch
CertificateFetcherDirectFetch(Face &face)
Definition:
certificate-fetcher-direct-fetch.cpp:30
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndnSIM
ndn-cxx
ndn-cxx
security
v2
certificate-fetcher-direct-fetch.cpp
Generated on Mon Jun 1 2020 22:32:15 for ndnSIM by
1.8.18