NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
validity-period.hpp
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
#ifndef NDN_SECURITY_VALIDITY_PERIOD_HPP
23
#define NDN_SECURITY_VALIDITY_PERIOD_HPP
24
25
#include "
ndn-cxx/detail/common.hpp
"
26
#include "
ndn-cxx/encoding/tlv.hpp
"
27
#include "
ndn-cxx/encoding/block.hpp
"
28
#include "
ndn-cxx/util/time.hpp
"
29
30
namespace
ndn
{
31
namespace
security {
32
33
37
class
ValidityPeriod
38
{
39
public
:
40
class
Error
:
public
tlv::Error
41
{
42
public
:
43
using
tlv::Error::Error
;
44
};
45
46
public
:
49
ValidityPeriod
();
50
53
explicit
54
ValidityPeriod
(
const
Block
& block);
55
64
ValidityPeriod
(
const
time::system_clock::TimePoint
& notBefore,
65
const
time::system_clock::TimePoint
& notAfter);
66
71
bool
72
isValid
(
const
time::system_clock::TimePoint
& now =
time::system_clock::now
())
const
;
73
82
ValidityPeriod
&
83
setPeriod
(
const
time::system_clock::TimePoint
& notBefore,
84
const
time::system_clock::TimePoint
& notAfter);
85
88
std::pair<time::system_clock::TimePoint, time::system_clock::TimePoint>
89
getPeriod
()
const
;
90
93
template
<encoding::Tag TAG>
94
size_t
95
wireEncode
(
EncodingImpl<TAG>
& encoder)
const
;
96
99
const
Block
&
100
wireEncode
()
const
;
101
105
void
106
wireDecode
(
const
Block
& wire);
107
108
private
:
// EqualityComparable concept
109
// NOTE: the following "hidden friend" operators are available via
110
// argument-dependent lookup only and must be defined inline.
111
112
friend
bool
113
operator==
(
const
ValidityPeriod
& lhs,
const
ValidityPeriod
& rhs)
114
{
115
return
!(lhs != rhs);
116
}
117
118
friend
bool
119
operator!=
(
const
ValidityPeriod
& lhs,
const
ValidityPeriod
& rhs)
120
{
121
return
lhs.m_notBefore != rhs.m_notBefore ||
122
lhs.m_notAfter != rhs.m_notAfter;
123
}
124
125
private
:
126
typedef
boost::chrono::time_point<time::system_clock, time::seconds> TimePoint;
127
128
TimePoint m_notBefore;
129
TimePoint m_notAfter;
130
131
mutable
Block
m_wire;
132
};
133
134
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS
(
ValidityPeriod
);
135
136
std::ostream&
137
operator<<
(std::ostream& os,
const
ValidityPeriod
& period);
138
139
}
// namespace security
140
}
// namespace ndn
141
142
#endif // NDN_SECURITY_VALIDITY_PERIOD_HPP
common.hpp
Common includes and macros used throughout the library.
ndn::time::system_clock::TimePoint
time_point TimePoint
Definition:
time.hpp:195
ndn::security::ValidityPeriod::operator==
friend bool operator==(const ValidityPeriod &lhs, const ValidityPeriod &rhs)
Definition:
validity-period.hpp:113
tlv.hpp
block.hpp
ndn::time::system_clock::now
static time_point now() noexcept
Definition:
time.cpp:46
ndn::security::ValidityPeriod::getPeriod
std::pair< time::system_clock::TimePoint, time::system_clock::TimePoint > getPeriod() const
Get the stored validity period.
Definition:
validity-period.cpp:141
ndn::security::ValidityPeriod::setPeriod
ValidityPeriod & setPeriod(const time::system_clock::TimePoint ¬Before, const time::system_clock::TimePoint ¬After)
Set validity period [notBefore, notAfter].
Definition:
validity-period.cpp:130
ndn::security::ValidityPeriod::ValidityPeriod
ValidityPeriod()
Set validity period [UNIX epoch + 1 nanosecond, UNIX epoch] that is always invalid.
Definition:
validity-period.cpp:42
ndn::security::ValidityPeriod::wireDecode
void wireDecode(const Block &wire)
Decode ValidityPeriod from TLV block.
Definition:
validity-period.cpp:96
ndn::security::ValidityPeriod::Error
Definition:
validity-period.hpp:41
ndn::security::ValidityPeriod
Abstraction of validity period.
Definition:
validity-period.hpp:38
ndn::security::operator<<
std::ostream & operator<<(std::ostream &os, const SigningInfo &si)
Definition:
signing-info.cpp:201
ndn::security::ValidityPeriod::wireEncode
const Block & wireEncode() const
Encode ValidityPeriod into TLV block.
Definition:
validity-period.cpp:78
ndn::encoding::EncodingImpl
Definition:
encoding-buffer-fwd.hpp:36
ndn::security::ValidityPeriod::isValid
bool isValid(const time::system_clock::TimePoint &now=time::system_clock::now()) const
Check if now falls within the validity period.
Definition:
validity-period.cpp:147
ndn::Block
Represents a TLV element of NDN packet format.
Definition:
block.hpp:43
ndn::security::NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(SafeBag)
ndn::security::ValidityPeriod::operator!=
friend bool operator!=(const ValidityPeriod &lhs, const ValidityPeriod &rhs)
Definition:
validity-period.hpp:119
time.hpp
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition:
tlv.hpp:53
ndn::tlv::Error::Error
Error(const char *expectedType, uint32_t actualType)
Definition:
tlv.cpp:27
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndnSIM
ndn-cxx
ndn-cxx
security
validity-period.hpp
Generated on Mon Jun 1 2020 22:32:15 for ndnSIM by
1.8.18