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 FinalBlockId More... | |
time::milliseconds | getFreshnessPeriod () const |
return FreshnessPeriod More... | |
uint32_t | getType () const |
return 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) |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
const Block & | wireEncode () const |
A 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.
ndn::MetaInfo::MetaInfo | ( | ) |
Definition at line 34 of file meta-info.cpp.
|
explicit |
Create from wire encoding.
Definition at line 40 of file meta-info.cpp.
Add an app-defined MetaInfo item.
Error | if block has type not in the application range (http://named-data.net/doc/ndn-tlv/types.html) |
Definition at line 92 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 (http://named-data.net/doc/ndn-tlv/types.html) |
Definition at line 116 of file meta-info.cpp.
const std::list< Block > & ndn::MetaInfo::getAppMetaInfo | ( | ) | const |
Get all app-defined MetaInfo items.
Definition at line 73 of file meta-info.cpp.
|
inline |
return FinalBlockId
Definition at line 121 of file meta-info.hpp.
|
inline |
return FreshnessPeriod
If FreshnessPeriod element is omitted, returns DEFAULT_FRESHNESS_PERIOD
.
Definition at line 107 of file meta-info.hpp.
|
inline |
return ContentType
If ContentType element is omitted, returns tlv::ContentType_Blob
.
Definition at line 91 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 103 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 (http://named-data.net/doc/ndn-tlv/types.html) |
Definition at line 79 of file meta-info.cpp.
MetaInfo & ndn::MetaInfo::setFinalBlock | ( | optional< name::Component > | finalBlockId | ) |
set FinalBlockId
Definition at line 65 of file meta-info.cpp.
MetaInfo & ndn::MetaInfo::setFreshnessPeriod | ( | time::milliseconds | freshnessPeriod | ) |
set FreshnessPeriod
std::invalid_argument | specified FreshnessPeriod is negative |
Definition at line 54 of file meta-info.cpp.
MetaInfo & ndn::MetaInfo::setType | ( | uint32_t | type | ) |
set ContentType
type | a number defined in tlv::ContentTypeValue |
Definition at line 46 of file meta-info.cpp.
void ndn::MetaInfo::wireDecode | ( | const Block & | wire | ) |
Definition at line 179 of file meta-info.cpp.
size_t ndn::MetaInfo::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Definition at line 125 of file meta-info.cpp.
const Block & ndn::MetaInfo::wireEncode | ( | ) | const |
Definition at line 163 of file meta-info.cpp.