A 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 Block & | wireEncode () const |
void | wireDecode (const Block &wire) |
uint32_t | getType () const |
return ContentType More... | |
MetaInfo & | setType (uint32_t type) |
set ContentType More... | |
time::milliseconds | getFreshnessPeriod () const |
return FreshnessPeriod More... | |
MetaInfo & | setFreshnessPeriod (time::milliseconds freshnessPeriod) |
set FreshnessPeriod More... | |
const optional< name::Component > & | getFinalBlock () const |
return FinalBlockId More... | |
MetaInfo & | setFinalBlock (optional< name::Component > finalBlockId) |
set FinalBlockId More... | |
const std::list< Block > & | getAppMetaInfo () const |
Get all app-defined MetaInfo items. More... | |
MetaInfo & | setAppMetaInfo (const std::list< Block > &info) |
Set app-defined MetaInfo items. More... | |
MetaInfo & | addAppMetaInfo (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 Block * | findAppMetaInfo (uint32_t tlvType) const |
Find a first app-defined MetaInfo item of type tlvType . More... | |
A MetaInfo holds the meta info which is signed inside the data packet.
The class allows experimentation with application-defined meta-information elements. When using these application-defined elements, be aware that it may result in dropped packets (NFD and previous versions of ndn-cxx will gracefully accept such packets).
The following definition of the MetaInfo element is assumed in this implementation (compared to the NDN-TLV spec, the definition is extended to allow optional AppMetaInfo elements):
MetaInfo = META-INFO-TYPE TLV-LENGTH [ContentType] [FreshnessPeriod] [FinalBlockId] *AppMetaInfo
Note that AppMetaInfo elements are application-defined and must have a TLV-TYPE inside the range reserved for application use, i.e., [128, 252]
.
Definition at line 58 of file meta-info.hpp.
ndn::MetaInfo::MetaInfo | ( | ) |
Definition at line 35 of file meta-info.cpp.
|
explicit |
size_t ndn::MetaInfo::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Definition at line 126 of file meta-info.cpp.
References ndn::tlv::ContentType, ndn::tlv::ContentType_Blob, ndn::DEFAULT_FRESHNESS_PERIOD, ndn::tlv::FinalBlockId, ndn::tlv::FreshnessPeriod, ndn::tlv::MetaInfo, ndn::NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(), ndn::encoding::prependBlock(), ndn::encoding::prependNestedBlock(), and ndn::encoding::prependNonNegativeIntegerBlock().
Referenced by ndn::operator==(), and ndn::Data::wireEncode().
const Block & ndn::MetaInfo::wireEncode | ( | ) | const |
Definition at line 165 of file meta-info.cpp.
References ndn::Block::hasWire().
void ndn::MetaInfo::wireDecode | ( | const Block & | wire | ) |
Definition at line 181 of file meta-info.cpp.
References ndn::tlv::ContentType, ndn::tlv::ContentType_Blob, ndn::DEFAULT_FRESHNESS_PERIOD, ndn::Block::elements(), ndn::Block::elements_begin(), ndn::Block::elements_end(), ndn::tlv::FinalBlockId, ndn::tlv::FreshnessPeriod, nonstd::optional_lite::nullopt, ndn::Block::parse(), and ndn::encoding::readNonNegativeInteger().
Referenced by MetaInfo(), and ndn::Data::wireDecode().
|
inline |
return ContentType
If ContentType element is omitted, returns tlv::ContentType_Blob
.
Definition at line 91 of file meta-info.hpp.
References setType().
Referenced by ndn::operator<<(), and ndn::Data::setContentType().
MetaInfo & ndn::MetaInfo::setType | ( | uint32_t | type | ) |
set ContentType
type | a number defined in tlv::ContentTypeValue |
Definition at line 47 of file meta-info.cpp.
References ndn::Block::reset().
Referenced by getType(), ndn::mgmt::Dispatcher::removeTopPrefix(), and ndn::Data::setContentType().
|
inline |
return FreshnessPeriod
If FreshnessPeriod element is omitted, returns DEFAULT_FRESHNESS_PERIOD
.
Definition at line 107 of file meta-info.hpp.
References setFreshnessPeriod().
Referenced by ndn::operator<<(), and ndn::Data::setFreshnessPeriod().
MetaInfo & ndn::MetaInfo::setFreshnessPeriod | ( | time::milliseconds | freshnessPeriod | ) |
set FreshnessPeriod
std::invalid_argument | specified FreshnessPeriod is negative |
Definition at line 55 of file meta-info.cpp.
References NDN_THROW, and ndn::Block::reset().
Referenced by getFreshnessPeriod(), and ndn::Data::setFreshnessPeriod().
|
inline |
return FinalBlockId
Definition at line 121 of file meta-info.hpp.
References addAppMetaInfo(), findAppMetaInfo(), getAppMetaInfo(), info, ndn::NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(), ndn::operator<<(), removeAppMetaInfo(), setAppMetaInfo(), setFinalBlock(), and tlvType.
Referenced by ndn::operator<<(), and ndn::Data::setFinalBlock().
MetaInfo & ndn::MetaInfo::setFinalBlock | ( | optional< name::Component > | finalBlockId | ) |
set FinalBlockId
Definition at line 66 of file meta-info.cpp.
References nonstd::optional_lite::std11::move(), and ndn::Block::reset().
Referenced by ndn::mgmt::Dispatcher::addStatusDataset(), getFinalBlock(), and ndn::Data::setFinalBlock().
const std::list< Block > & ndn::MetaInfo::getAppMetaInfo | ( | ) | const |
Get all app-defined MetaInfo items.
Definition at line 74 of file meta-info.cpp.
Referenced by getFinalBlock(), and ndn::operator<<().
Set app-defined MetaInfo items.
This method will replace all existing app-defined MetaInfo items, if they existed.
Error | if some block in info has type not in the application range (https://named-data.net/doc/NDN-packet-spec/0.3/types.html) |
Definition at line 80 of file meta-info.cpp.
References info, NDN_THROW, and ndn::Block::reset().
Referenced by getFinalBlock().
Add an app-defined MetaInfo item.
Error | if block has type not in the application range (https://named-data.net/doc/NDN-packet-spec/0.3/types.html) |
Definition at line 93 of file meta-info.cpp.
References NDN_THROW, ndn::Block::reset(), and ndn::Block::type().
Referenced by getFinalBlock().
bool ndn::MetaInfo::removeAppMetaInfo | ( | uint32_t | tlvType | ) |
Remove a first app-defined MetaInfo item with type tlvType
.
Definition at line 104 of file meta-info.cpp.
References ndn::Block::reset(), and tlvType.
Referenced by getFinalBlock().
const Block * ndn::MetaInfo::findAppMetaInfo | ( | uint32_t | tlvType | ) | const |
Find a first app-defined MetaInfo item of type tlvType
.
Error | if tlvType is not in the application range (https://named-data.net/doc/NDN-packet-spec/0.3/types.html) |
Definition at line 117 of file meta-info.cpp.
References tlvType.
Referenced by getFinalBlock().