NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
+
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Typedefs
a
b
c
d
e
f
i
l
m
n
o
p
q
r
s
t
u
v
Enumerations
+
Enumerator
a
b
c
d
e
f
h
i
k
l
m
n
o
p
q
r
s
u
v
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
+
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
~
+
Variables
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
q
r
s
t
u
w
+
Typedefs
a
b
c
d
e
f
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
+
Enumerator
a
d
e
f
g
i
k
l
m
n
p
r
s
u
w
+
Related Functions
b
c
d
f
i
k
l
n
o
p
s
+
Files
File List
+
File Members
+
All
a
b
c
d
e
f
g
h
k
l
m
n
p
r
s
u
v
w
+
Functions
c
f
h
m
r
s
u
w
+
Variables
a
c
d
g
k
l
n
p
r
s
Typedefs
+
Macros
b
d
e
l
m
n
p
r
s
u
v
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
certificate-cache-ttl.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24
#include "
certificate-cache-ttl.hpp
"
25
26
namespace
ndn
{
27
28
CertificateCacheTtl::CertificateCacheTtl
(boost::asio::io_service& io,
29
const
time::seconds& defaultTtl
/* = time::seconds(3600)*/
)
30
: m_defaultTtl(defaultTtl)
31
, m_scheduler(io)
32
{
33
}
34
35
CertificateCacheTtl::~CertificateCacheTtl
()
36
{
37
}
38
39
void
40
CertificateCacheTtl::insertCertificate
(shared_ptr<const IdentityCertificate> certificate)
41
{
42
m_scheduler
.
scheduleEvent
(time::seconds(0), [
this
, certificate] { this->insert(certificate); });
43
}
44
45
shared_ptr<const IdentityCertificate>
46
CertificateCacheTtl::getCertificate
(
const
Name
& certificateName)
47
{
48
Cache::iterator
it =
m_cache
.find(certificateName);
49
if
(it !=
m_cache
.end())
50
return
it->second.first;
51
else
52
return
shared_ptr<IdentityCertificate>();
53
}
54
55
void
56
CertificateCacheTtl::reset
()
57
{
58
m_scheduler
.
scheduleEvent
(time::seconds(0), [
this
] { this->removeAll(); });
59
}
60
61
size_t
62
CertificateCacheTtl::getSize
()
63
{
64
return
m_cache
.size();
65
}
66
67
void
68
CertificateCacheTtl::insert(shared_ptr<const IdentityCertificate> certificate)
69
{
70
time::milliseconds expire = (certificate->getFreshnessPeriod() >= time::seconds::zero() ?
71
certificate->getFreshnessPeriod() :
m_defaultTtl
);
72
73
Name
index = certificate->getName().
getPrefix
(-1);
74
75
Cache::iterator
it =
m_cache
.find(index);
76
if
(it !=
m_cache
.end())
77
m_scheduler
.
cancelEvent
(it->second.second);
78
79
EventId
eventId =
m_scheduler
.
scheduleEvent
(expire,
80
bind(&CertificateCacheTtl::remove,
81
this
, certificate->getName()));
82
83
m_cache
[index] = std::make_pair(certificate, eventId);
84
}
85
86
void
87
CertificateCacheTtl::remove(
const
Name
& certificateName)
88
{
89
Name
name
= certificateName.
getPrefix
(-1);
90
Cache::iterator
it =
m_cache
.find(name);
91
if
(it !=
m_cache
.end())
92
m_cache
.erase(it);
93
}
94
95
void
96
CertificateCacheTtl::removeAll()
97
{
98
for
(
Cache::iterator
it =
m_cache
.begin(); it !=
m_cache
.end(); it++)
99
m_scheduler
.
cancelEvent
(it->second.second);
100
101
m_cache
.clear();
102
}
103
104
}
// namespace ndn
ndn::Name::getPrefix
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix (PartialName) of the name, containing first nComponents components.
Definition:
name.hpp:249
ndn::CertificateCacheTtl::reset
virtual void reset()
Definition:
certificate-cache-ttl.cpp:56
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::CertificateCacheTtl::insertCertificate
virtual void insertCertificate(shared_ptr< const IdentityCertificate > certificate)
Definition:
certificate-cache-ttl.cpp:40
ndn::CertificateCacheTtl::getSize
virtual size_t getSize()
Definition:
certificate-cache-ttl.cpp:62
ndn::util::scheduler::Scheduler::scheduleEvent
EventId scheduleEvent(const time::nanoseconds &after, const Event &event)
Schedule one time event after the specified delay.
Definition:
scheduler.cpp:85
ndn::util::scheduler::Scheduler::cancelEvent
void cancelEvent(const EventId &eventId)
Cancel scheduled event.
Definition:
scheduler.cpp:106
nfd::cs::iterator
Table::const_iterator iterator
Definition:
cs-internal.hpp:41
ndn::util::scheduler::EventId
std::shared_ptr< ns3::EventId > EventId
Definition:
scheduler.hpp:39
ndn::CertificateCacheTtl::m_cache
Cache m_cache
Definition:
certificate-cache-ttl.hpp:75
ndn::CertificateCacheTtl::~CertificateCacheTtl
virtual ~CertificateCacheTtl()
Definition:
certificate-cache-ttl.cpp:35
certificate-cache-ttl.hpp
ndn::Name
Name abstraction to represent an absolute name.
Definition:
name.hpp:46
ndn::CertificateCacheTtl::getCertificate
virtual shared_ptr< const IdentityCertificate > getCertificate(const Name &certificateNameWithoutVersion)
Definition:
certificate-cache-ttl.cpp:46
ndn::CertificateCacheTtl::CertificateCacheTtl
CertificateCacheTtl(boost::asio::io_service &io, const time::seconds &defaultTtl=time::seconds(3600))
Definition:
certificate-cache-ttl.cpp:28
ndn::CertificateCacheTtl::m_scheduler
Scheduler m_scheduler
Definition:
certificate-cache-ttl.hpp:76
ndn::CertificateCacheTtl::m_defaultTtl
time::seconds m_defaultTtl
Definition:
certificate-cache-ttl.hpp:74
ndn::name
Definition:
name-component.cpp:37
ndnSIM
ndn-cxx
src
security
certificate-cache-ttl.cpp
Generated on Sat Nov 12 2016 16:02:52 for ndnSIM by
1.8.12