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

An MetaInfo holds the meta info which is signed inside the data packet. More...

#include <meta-info.hpp>

Classes

class  Error
 

Public Member Functions

 MetaInfo ()
 
 MetaInfo (const Block &block)
 Create from wire encoding. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder) const
 
const BlockwireEncode () const
 
void wireDecode (const Block &wire)
 
uint32_t getType () const
 return ContentType More...
 
MetaInfosetType (uint32_t type)
 set ContentType More...
 
time::milliseconds getFreshnessPeriod () const
 return FreshnessPeriod More...
 
MetaInfosetFreshnessPeriod (time::milliseconds freshnessPeriod)
 set FreshnessPeriod More...
 
const optional< name::Component > & getFinalBlock () const
 return FinalBlockId More...
 
MetaInfosetFinalBlock (optional< name::Component > finalBlockId)
 set FinalBlockId More...
 
NDN_CXX_DEPRECATED name::Component getFinalBlockId () const
 return FinalBlockId More...
 
NDN_CXX_DEPRECATED MetaInfosetFinalBlockId (const name::Component &finalBlockId)
 set FinalBlockId More...
 
const std::list< Block > & getAppMetaInfo () const
 Get all app-defined MetaInfo items. More...
 
MetaInfosetAppMetaInfo (const std::list< Block > &info)
 Set app-defined MetaInfo items. More...
 
MetaInfoaddAppMetaInfo (const Block &block)
 Add an app-defined MetaInfo item. More...
 
bool removeAppMetaInfo (uint32_t tlvType)
 Remove a first app-defined MetaInfo item with type tlvType. More...
 
const BlockfindAppMetaInfo (uint32_t tlvType) const
 Find a first app-defined MetaInfo item of type tlvType. More...
 
bool operator== (const MetaInfo &other) const
 
bool operator!= (const MetaInfo &other) const
 

Detailed Description

An MetaInfo holds the meta info which is signed inside the data packet.

The class allows experimentation with application-defined meta information blocks, which slightly violates NDN-TLV specification. When using the application-defined meta information blocks be aware that this may result in packet drop (NFD and previous versions of ndn-cxx will gracefully accept such packet).

The following definition of MetaInfo block is assumed in this implementation (compared to the NDN-TLV spec, definition extended to allow optional AppMetaInfo TLV blocks):

MetaInfo ::= META-INFO-TYPE TLV-LENGTH
               ContentType?
               FreshnessPeriod?
               FinalBlockId?
               AppMetaInfo*

AppMetaInfo ::= any TLV block with type in the restricted application range [128, 252]

Note that AppMetaInfo blocks are application-defined and must have TLV type from the restricted application range [128, 252].

Definition at line 58 of file meta-info.hpp.

Constructor & Destructor Documentation

◆ MetaInfo() [1/2]

ndn::MetaInfo::MetaInfo ( )

Definition at line 35 of file meta-info.cpp.

◆ MetaInfo() [2/2]

ndn::MetaInfo::MetaInfo ( const Block block)
explicit

Create from wire encoding.

Definition at line 41 of file meta-info.cpp.

References wireDecode().

Member Function Documentation

◆ wireEncode() [1/2]

◆ wireEncode() [2/2]

const Block & ndn::MetaInfo::wireEncode ( ) const

Definition at line 180 of file meta-info.cpp.

References ndn::Block::hasWire().

Referenced by operator==().

◆ wireDecode()

◆ getType()

uint32_t ndn::MetaInfo::getType ( ) const
inline

return ContentType

If ContentType element is omitted, returns tlv::ContentType_Blob.

Definition at line 95 of file meta-info.hpp.

Referenced by ndn::Data::getContentType(), and ndn::operator<<().

◆ setType()

MetaInfo & ndn::MetaInfo::setType ( uint32_t  type)

set ContentType

Parameters
typea number defined in tlv::ContentTypeValue

Definition at line 47 of file meta-info.cpp.

References ndn::Block::reset().

Referenced by ndn::Data::setContentType().

◆ getFreshnessPeriod()

time::milliseconds ndn::MetaInfo::getFreshnessPeriod ( ) const
inline

return FreshnessPeriod

If FreshnessPeriod element is omitted, returns DEFAULT_FRESHNESS_PERIOD.

Definition at line 111 of file meta-info.hpp.

Referenced by ndn::Data::getFreshnessPeriod(), and ndn::operator<<().

◆ setFreshnessPeriod()

MetaInfo & ndn::MetaInfo::setFreshnessPeriod ( time::milliseconds  freshnessPeriod)

set FreshnessPeriod

Exceptions
std::invalid_argumentspecified FreshnessPeriod is negative

Definition at line 55 of file meta-info.cpp.

References ndn::Block::reset().

Referenced by ndn::Data::setFreshnessPeriod().

◆ getFinalBlock()

const optional<name::Component>& ndn::MetaInfo::getFinalBlock ( ) const
inline

return FinalBlockId

Definition at line 125 of file meta-info.hpp.

Referenced by ndn::Data::getFinalBlock(), getFinalBlockId(), and ndn::operator<<().

◆ setFinalBlock()

MetaInfo & ndn::MetaInfo::setFinalBlock ( optional< name::Component finalBlockId)

set FinalBlockId

Definition at line 66 of file meta-info.cpp.

References ndn::Block::reset().

Referenced by ndn::Data::setFinalBlock(), and setFinalBlockId().

◆ getFinalBlockId()

NDN_CXX_DEPRECATED name::Component ndn::MetaInfo::getFinalBlockId ( ) const
inline

return FinalBlockId

Deprecated:
use getFinalBlock

If FinalBlockId element is omitted, returns a default-constructed name::Component. This is indistinguishable from having an empty GenericNameComponent as FinalBlockId.

Definition at line 143 of file meta-info.hpp.

References getFinalBlock().

Referenced by ndn::Data::getFinalBlockId().

◆ setFinalBlockId()

MetaInfo & ndn::MetaInfo::setFinalBlockId ( const name::Component finalBlockId)

set FinalBlockId

Deprecated:
use setFinalBlock

Passing a default-constructed name::Component removes FinalBlockId element. This API does not support adding an empty GenericNameComponent as FinalBlockId.

Definition at line 74 of file meta-info.cpp.

References ndn::name::Component::empty(), ndn::name::Component::isGeneric(), ndn::nullopt, and setFinalBlock().

Referenced by ndn::Data::setFinalBlockId().

◆ getAppMetaInfo()

const std::list< Block > & ndn::MetaInfo::getAppMetaInfo ( ) const

Get all app-defined MetaInfo items.

Note
Warning: Experimental API, which may change or disappear in the future
If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock is called before *AppMetaInfo, all app-defined blocks will be lost

Definition at line 83 of file meta-info.cpp.

Referenced by ndn::operator<<().

◆ setAppMetaInfo()

MetaInfo & ndn::MetaInfo::setAppMetaInfo ( const std::list< Block > &  info)

Set app-defined MetaInfo items.

This method will replace all existing app-defined MetaInfo items, if they existed.

Exceptions
Errorif some block in info has type not in the application range (http://named-data.net/doc/ndn-tlv/types.html)
Note
Warning: Experimental API, which may change or disappear in the future
If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock is called before *AppMetaInfo, all app-defined blocks will be lost

Definition at line 89 of file meta-info.cpp.

References ndn::Block::reset().

◆ addAppMetaInfo()

MetaInfo & ndn::MetaInfo::addAppMetaInfo ( const Block block)

Add an app-defined MetaInfo item.

Exceptions
Errorif block has type not in the application range (http://named-data.net/doc/ndn-tlv/types.html)
Note
Warning: Experimental API, which may change or disappear in the future
If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock is called before *AppMetaInfo, all app-defined blocks will be lost

Definition at line 103 of file meta-info.cpp.

References ndn::Block::reset(), and ndn::Block::type().

◆ removeAppMetaInfo()

bool ndn::MetaInfo::removeAppMetaInfo ( uint32_t  tlvType)

Remove a first app-defined MetaInfo item with type tlvType.

Returns
true if an item was deleted
Note
Warning: Experimental API, which may change or disappear in the future
If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock is called before *AppMetaInfo, all app-defined blocks will be lost

Definition at line 115 of file meta-info.cpp.

References ndn::Block::reset(), and tlvType.

◆ findAppMetaInfo()

const Block * ndn::MetaInfo::findAppMetaInfo ( uint32_t  tlvType) const

Find a first app-defined MetaInfo item of type tlvType.

Returns
NULL if an item is not found, otherwise const pointer to the item
Exceptions
Errorif tlvType is not in the application range (http://named-data.net/doc/ndn-tlv/types.html)
Note
Warning: Experimental API, which may change or disappear in the future
If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock is called before *AppMetaInfo, all app-defined blocks will be lost

Definition at line 129 of file meta-info.cpp.

References tlvType.

◆ operator==()

bool ndn::MetaInfo::operator== ( const MetaInfo other) const
inline

Definition at line 251 of file meta-info.hpp.

References wireEncode().

◆ operator!=()

bool ndn::MetaInfo::operator!= ( const MetaInfo other) const
inline

Definition at line 257 of file meta-info.hpp.


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