Represents a Data packet. More...
#include <ndn-cxx/data.hpp>
Inheritance diagram for ndn::Data:
Collaboration diagram for ndn::Data:Classes | |
| class | Error |
Public Member Functions | |
| Data (const Block &wire) | |
Construct a Data packet by decoding from wire. More... | |
| Data (const Name &name=Name()) | |
Construct an unsigned Data packet with given name and empty Content. More... | |
| InputBuffers | extractSignedRanges () const |
| Extract ranges of Data covered by the signature. More... | |
| uint64_t | getCongestionMark () const |
| Get the value of the CongestionMark tag. More... | |
| const Block & | getContent () const noexcept |
Get the Content element. More... | |
| uint32_t | getContentType () const |
| const optional< name::Component > & | getFinalBlock () const |
| time::milliseconds | getFreshnessPeriod () const |
| const Name & | getFullName () const |
| Get full name including implicit digest. More... | |
| optional< KeyLocator > | getKeyLocator () const noexcept |
Get the KeyLocator element. More... | |
| const MetaInfo & | getMetaInfo () const noexcept |
Get the MetaInfo element. More... | |
| const Name & | getName () const noexcept |
| Get the data name. More... | |
| const SignatureInfo & | getSignatureInfo () const noexcept |
Get the SignatureInfo element. More... | |
| int32_t | getSignatureType () const noexcept |
Get the SignatureType. More... | |
| const Block & | getSignatureValue () const noexcept |
Get the SignatureValue element. More... | |
| template<typename T > | |
| shared_ptr< T > | getTag () const |
| Get a tag item. More... | |
| bool | hasContent () const noexcept |
Return whether this Data has a Content element. More... | |
| bool | hasWire () const noexcept |
| Check if this instance has cached wire encoding. More... | |
| template<typename T > | |
| void | removeTag () const |
| Remove a tag item. More... | |
| void | setCongestionMark (uint64_t mark) |
| Set the CongestionMark tag to the specified value. More... | |
| Data & | setContent (const Block &block) |
Set Content from a Block. More... | |
| Data & | setContent (ConstBufferPtr value) |
Set Content from a shared buffer. More... | |
| Data & | setContent (span< const uint8_t > value) |
Set Content by copying from a contiguous sequence of bytes. More... | |
| Data & | setContentType (uint32_t type) |
| Data & | setFinalBlock (optional< name::Component > finalBlockId) |
| Data & | setFreshnessPeriod (time::milliseconds freshnessPeriod) |
| Data & | setMetaInfo (const MetaInfo &metaInfo) |
Set the MetaInfo element. More... | |
| Data & | setName (const Name &name) |
| Set the data name. More... | |
| Data & | setSignatureInfo (const SignatureInfo &info) |
Set the SignatureInfo element. More... | |
| Data & | setSignatureValue (ConstBufferPtr value) |
Set SignatureValue from a shared buffer. More... | |
| Data & | setSignatureValue (span< const uint8_t > value) |
Set SignatureValue by copying from a contiguous sequence of bytes. More... | |
| template<typename T > | |
| void | setTag (shared_ptr< T > tag) const |
| Set (add or replace) a tag item. More... | |
| Data & | unsetContent () |
Remove the Content element. More... | |
| void | wireDecode (const Block &wire) |
Decode from wire. More... | |
| const Block & | wireEncode () const |
| Encode into a Block. More... | |
| const Block & | wireEncode (EncodingBuffer &encoder, span< const uint8_t > signature) const |
| Finalize Data packet encoding with the specified signature. More... | |
| template<encoding::Tag TAG> | |
| size_t | wireEncode (EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const |
Prepend wire encoding to encoder. More... | |
Protected Member Functions | |
| void | resetWire () |
| Clear wire encoding and cached FullName. More... | |
Represents a Data packet.
Construct an unsigned Data packet with given name and empty Content.
Data::shared_from_this(), Data must be created using std::make_shared. Otherwise, shared_from_this() may trigger undefined behavior. One example where this is necessary is storing Data into a subclass of InMemoryStorage.
|
explicit |
Construct a Data packet by decoding from wire.
| wire | TLV block of type tlv::Data; may be signed or unsigned. |
Data::shared_from_this(), Data must be created using std::make_shared. Otherwise, shared_from_this() may trigger undefined behavior. One example where this is necessary is storing Data into a subclass of InMemoryStorage. | InputBuffers ndn::Data::extractSignedRanges | ( | ) | const |
Extract ranges of Data covered by the signature.
|
inherited |
Get the value of the CongestionMark tag.
Definition at line 28 of file packet-base.cpp.
|
inlinenoexcept |
Get the Content element.
If the element is not present (hasContent() == false), an invalid Block will be returned.
The value of the returned Content Block (if valid) can be accessed through
|
inline |
|
inline |
| const Name & ndn::Data::getFullName | ( | ) | const |
|
inlinenoexcept |
Get the KeyLocator element.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Get the SignatureInfo element.
|
inlinenoexcept |
Get the SignatureType.
|
inlinenoexcept |
|
inherited |
Get a tag item.
| T | type of the tag, which must be a subclass of ndn::Tag |
| nullptr | if no Tag of type T is stored |
Definition at line 67 of file tag-host.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inherited |
Remove a tag item.
Definition at line 94 of file tag-host.hpp.
|
protected |
|
inherited |
Set the CongestionMark tag to the specified value.
Definition at line 41 of file packet-base.cpp.
Set Content from a Block.
| block | TLV block to be used as Content; must be valid |
If the block's TLV-TYPE is tlv::Content, it will be used directly as this Data's Content element. Otherwise, the block will be nested into a Content element.
| Data & ndn::Data::setContent | ( | ConstBufferPtr | value | ) |
| Data & ndn::Data::setContent | ( | span< const uint8_t > | value | ) |
| Data & ndn::Data::setFinalBlock | ( | optional< name::Component > | finalBlockId | ) |
| Data & ndn::Data::setFreshnessPeriod | ( | time::milliseconds | freshnessPeriod | ) |
| Data & ndn::Data::setSignatureInfo | ( | const SignatureInfo & | info | ) |
Set the SignatureInfo element.
This is a low-level function that should not normally be called directly by applications. Instead, provide a SignatureInfo to the SigningInfo object passed to KeyChain::sign().
| Data & ndn::Data::setSignatureValue | ( | ConstBufferPtr | value | ) |
Set SignatureValue from a shared buffer.
| value | buffer containing the TLV-VALUE of the SignatureValue; must not be nullptr |
This is a low-level function that should not normally be called directly by applications. Instead, use KeyChain::sign() to sign the packet.
| Data & ndn::Data::setSignatureValue | ( | span< const uint8_t > | value | ) |
Set SignatureValue by copying from a contiguous sequence of bytes.
| value | buffer from which the TLV-VALUE of the SignatureValue will be copied |
This is a low-level function that should not normally be called directly by applications. Instead, use KeyChain::sign() to sign the packet.
|
inherited |
Set (add or replace) a tag item.
| T | type of the tag, which must be a subclass of ndn::Tag |
Definition at line 80 of file tag-host.hpp.
| Data & ndn::Data::unsetContent | ( | ) |
Remove the Content element.
| void ndn::Data::wireDecode | ( | const Block & | wire | ) |
| const Block & ndn::Data::wireEncode | ( | ) | const |
| const Block & ndn::Data::wireEncode | ( | EncodingBuffer & | encoder, |
| span< const uint8_t > | signature | ||
| ) | const |
Finalize Data packet encoding with the specified signature.
| encoder | EncodingBuffer containing Name, MetaInfo, Content, and SignatureInfo, but without SignatureValue and the outermost Type-Length of the Data element. |
| signature | Raw signature bytes, without TLV Type and Length; this will become the TLV-VALUE of the SignatureValue element added to the packet. |
This method is intended to be used in concert with wireEncode(encoder, true), e.g.:
| size_t ndn::Data::wireEncode | ( | EncodingImpl< TAG > & | encoder, |
| bool | wantUnsignedPortionOnly = false |
||
| ) | const |
Prepend wire encoding to encoder.
| encoder | EncodingEstimator or EncodingBuffer instance. |
| wantUnsignedPortionOnly | If true, prepend only Name, MetaInfo, Content, and SignatureInfo to encoder, but omit SignatureValue and the outermost TLV Type and Length of the Data element. This is intended to be used with wireEncode(EncodingBuffer&, span<const uint8_t>) const. |
| Error | Signature is not present and wantUnsignedPortionOnly is false. |