A MetaInfo holds the meta info which is signed inside the Data packet. More...
#include <ndn-cxx/meta-info.hpp>
Classes | |
class | Error |
Public Member Functions | |
MetaInfo () | |
MetaInfo (const Block &block) | |
Create from wire encoding. More... | |
MetaInfo & | addAppMetaInfo (const Block &block) |
Add an app-defined MetaInfo item. More... | |
const Block * | findAppMetaInfo (uint32_t tlvType) const |
Find a first app-defined MetaInfo item of type tlvType . More... | |
const std::list< Block > & | getAppMetaInfo () const |
Get all app-defined MetaInfo items. More... | |
const optional< name::Component > & | getFinalBlock () const |
Return the value of FinalBlockId . More... | |
time::milliseconds | getFreshnessPeriod () const |
Return the value of FreshnessPeriod . More... | |
uint32_t | getType () const |
Return the value of ContentType . More... | |
bool | removeAppMetaInfo (uint32_t tlvType) |
Remove a first app-defined MetaInfo item with type tlvType . More... | |
MetaInfo & | setAppMetaInfo (const std::list< Block > &info) |
Set app-defined MetaInfo items. More... | |
MetaInfo & | setFinalBlock (optional< name::Component > finalBlockId) |
Set FinalBlockId . More... | |
MetaInfo & | setFreshnessPeriod (time::milliseconds freshnessPeriod) |
Set FreshnessPeriod . More... | |
MetaInfo & | setType (uint32_t type) |
Set ContentType . More... | |
void | wireDecode (const Block &wire) |
const Block & | wireEncode () const |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
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 packet 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 61 of file meta-info.hpp.
ndn::MetaInfo::MetaInfo | ( | ) |
Definition at line 35 of file meta-info.cpp.
|
explicit |
Create from wire encoding.
Definition at line 41 of file meta-info.cpp.
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.
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.
const std::list< Block > & ndn::MetaInfo::getAppMetaInfo | ( | ) | const |
Get all app-defined MetaInfo items.
Definition at line 74 of file meta-info.cpp.
|
inline |
Return the value of FinalBlockId
.
Definition at line 124 of file meta-info.hpp.
|
inline |
Return the value of FreshnessPeriod
.
If the FreshnessPeriod
element is not present, returns DEFAULT_FRESHNESS_PERIOD.
Definition at line 110 of file meta-info.hpp.
|
inline |
Return the value of ContentType
.
If the ContentType
element is not present, returns tlv::ContentType_Blob.
Definition at line 94 of file meta-info.hpp.
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.
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.
MetaInfo & ndn::MetaInfo::setFinalBlock | ( | optional< name::Component > | finalBlockId | ) |
Set FinalBlockId
.
Definition at line 66 of file meta-info.cpp.
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.
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.
void ndn::MetaInfo::wireDecode | ( | const Block & | wire | ) |
Definition at line 181 of file meta-info.cpp.
const Block & ndn::MetaInfo::wireEncode | ( | ) | const |
Definition at line 165 of file meta-info.cpp.
size_t ndn::MetaInfo::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Definition at line 126 of file meta-info.cpp.