NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::security::ValidityPeriod Class Reference

Represents a ValidityPeriod TLV element. More...

#include <validity-period.hpp>

Classes

class  Error
 

Public Member Functions

 ValidityPeriod ()
 Set validity period [UNIX epoch + 1 nanosecond, UNIX epoch] that is always invalid. More...
 
 ValidityPeriod (const Block &block)
 Create validity period from block. More...
 
 ValidityPeriod (const time::system_clock::TimePoint &notBefore, const time::system_clock::TimePoint &notAfter)
 Create validity period [notBefore, notAfter]. More...
 
bool isValid (const time::system_clock::TimePoint &now=time::system_clock::now()) const
 Check if now falls within the validity period. More...
 
ValidityPeriodsetPeriod (const time::system_clock::TimePoint &notBefore, const time::system_clock::TimePoint &notAfter)
 Set validity period [notBefore, notAfter]. More...
 
std::pair< time::system_clock::TimePoint, time::system_clock::TimePointgetPeriod () const
 Get the stored validity period. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder) const
 Fast encoding or block size estimation. More...
 
const BlockwireEncode () const
 Encode ValidityPeriod into TLV block. More...
 
void wireDecode (const Block &wire)
 Decode ValidityPeriod from TLV block. More...
 

Static Public Member Functions

static ValidityPeriod makeRelative (time::seconds validFrom, time::seconds validUntil, const time::system_clock::TimePoint &now=time::system_clock::now())
 Construct ValidityPeriod relative to a timepoint. More...
 

Friends

bool operator== (const ValidityPeriod &lhs, const ValidityPeriod &rhs)
 
bool operator!= (const ValidityPeriod &lhs, const ValidityPeriod &rhs)
 

Detailed Description

Represents a ValidityPeriod TLV element.

See also
NDN Certificate Format

Definition at line 37 of file validity-period.hpp.

Constructor & Destructor Documentation

◆ ValidityPeriod() [1/3]

ndn::security::ValidityPeriod::ValidityPeriod ( )

Set validity period [UNIX epoch + 1 nanosecond, UNIX epoch] that is always invalid.

Definition at line 49 of file validity-period.cpp.

Referenced by makeRelative().

◆ ValidityPeriod() [2/3]

ndn::security::ValidityPeriod::ValidityPeriod ( const Block block)
explicit

Create validity period from block.

Definition at line 63 of file validity-period.cpp.

References wireDecode().

◆ ValidityPeriod() [3/3]

ndn::security::ValidityPeriod::ValidityPeriod ( const time::system_clock::TimePoint notBefore,
const time::system_clock::TimePoint notAfter 
)

Create validity period [notBefore, notAfter].

Parameters
notBeforeexclusive beginning of the validity period range
notAfterexclusive end of the validity period range
Note
The supplied time points will be rounded up to the whole seconds:
  • notBefore is rounded up the next whole second
  • notAfter is truncated to the previous whole second

Definition at line 55 of file validity-period.cpp.

Member Function Documentation

◆ makeRelative()

ValidityPeriod ndn::security::ValidityPeriod::makeRelative ( time::seconds  validFrom,
time::seconds  validUntil,
const time::system_clock::TimePoint now = time::system_clock::now() 
)
static

Construct ValidityPeriod relative to a timepoint.

Parameters
validFromNotBefore is computed as now+validFrom . This should be negative to construct a ValidityPeriod that includes now .
validUntilNotAfter is computed as now+validTo . This should be positive to construct a ValidityPeriod that includes now .
nowReference timepoint. Default is current system clock timestamp.

Definition at line 43 of file validity-period.cpp.

References ValidityPeriod().

Referenced by ndn::security::v2::parseLocatorUri().

◆ isValid()

bool ndn::security::ValidityPeriod::isValid ( const time::system_clock::TimePoint now = time::system_clock::now()) const

Check if now falls within the validity period.

Parameters
nowTime point to check if it falls within the period
Returns
periodBegin <= now and now <= periodEnd

Definition at line 154 of file validity-period.cpp.

Referenced by ndn::security::v2::Certificate::isValid().

◆ setPeriod()

ValidityPeriod & ndn::security::ValidityPeriod::setPeriod ( const time::system_clock::TimePoint notBefore,
const time::system_clock::TimePoint notAfter 
)

Set validity period [notBefore, notAfter].

Parameters
notBeforeexclusive beginning of the validity period range
notAfterexclusive end of the validity period range
Note
The supplied time points will be rounded up to the whole seconds:
  • notBefore is rounded up the next whole second
  • notAfter is truncated to the previous whole second

Definition at line 137 of file validity-period.cpp.

References ndn::Block::reset().

◆ getPeriod()

std::pair< time::system_clock::TimePoint, time::system_clock::TimePoint > ndn::security::ValidityPeriod::getPeriod ( ) const

Get the stored validity period.

Definition at line 148 of file validity-period.cpp.

Referenced by ndn::security::v2::CertificateCache::insert(), ndn::security::v2::operator<<(), and ndn::security::operator<<().

◆ wireEncode() [1/2]

template<encoding::Tag TAG>
size_t ndn::security::ValidityPeriod::wireEncode ( EncodingImpl< TAG > &  encoder) const

◆ wireEncode() [2/2]

const Block & ndn::security::ValidityPeriod::wireEncode ( ) const

Encode ValidityPeriod into TLV block.

Definition at line 85 of file validity-period.cpp.

References ndn::Block::hasWire(), and ndn::Block::parse().

◆ wireDecode()

Friends And Related Function Documentation

◆ operator==

bool operator== ( const ValidityPeriod lhs,
const ValidityPeriod rhs 
)
friend

Definition at line 124 of file validity-period.hpp.

◆ operator!=

bool operator!= ( const ValidityPeriod lhs,
const ValidityPeriod rhs 
)
friend

Definition at line 130 of file validity-period.hpp.


The documentation for this class was generated from the following files: