Represents a Data packet.
More...
#include <ndn-cxx/data.hpp>
Represents a Data packet.
Definition at line 35 of file data.hpp.
ndn::Data::Data |
( |
const Name & |
name = Name() | ) |
|
|
explicit |
Construct an unsigned Data packet with given name
and empty Content.
- Warning
- In certain contexts that use
Data::shared_from_this()
, Data must be created using make_shared
. Otherwise, shared_from_this()
will trigger undefined behavior.
Definition at line 35 of file data.cpp.
ndn::Data::Data |
( |
const Block & |
wire | ) |
|
|
explicit |
Construct a Data packet by decoding from wire
.
- Parameters
-
wire | tlv::Data element as defined in NDN Packet Format v0.2 or v0.3. It may be signed or unsigned. |
- Warning
- In certain contexts that use
Data::shared_from_this()
, Data must be created using make_shared
. Otherwise, shared_from_this()
will trigger undefined behavior.
Definition at line 41 of file data.cpp.
uint64_t ndn::PacketBase::getCongestionMark |
( |
| ) |
const |
|
inherited |
get the value of the CongestionMark tag
Definition at line 28 of file packet-base.cpp.
const Block & ndn::Data::getContent |
( |
| ) |
const |
Get Content.
The Content value is accessible through value()/value_size() or value_begin()/value_end() methods of the Block class.
Definition at line 232 of file data.cpp.
uint32_t ndn::Data::getContentType |
( |
| ) |
const |
|
inline |
time::milliseconds ndn::Data::getFreshnessPeriod |
( |
| ) |
const |
|
inline |
const Name & ndn::Data::getFullName |
( |
| ) |
const |
Get full name including implicit digest.
- Precondition
- hasWire() == true; i.e. wireEncode() must have been called
- Exceptions
-
Definition at line 195 of file data.cpp.
const MetaInfo& ndn::Data::getMetaInfo |
( |
| ) |
const |
|
inline |
const Name& ndn::Data::getName |
( |
| ) |
const |
|
inline |
const Signature& ndn::Data::getSignature |
( |
| ) |
const |
|
inline |
template<typename T >
shared_ptr< T > ndn::TagHost::getTag |
( |
| ) |
const |
|
inherited |
get a tag item
- Template Parameters
-
T | type of the tag, which must be a subclass of ndn::Tag |
- Return values
-
nullptr | if no Tag of type T is stored |
Definition at line 66 of file tag-host.hpp.
bool ndn::Data::hasWire |
( |
| ) |
const |
|
inline |
Check if this instance has cached wire encoding.
Definition at line 108 of file data.hpp.
template<typename T >
void ndn::TagHost::removeTag |
( |
| ) |
const |
|
inherited |
remove tag item
- Note
- Tag can be removed even on a const tag host instance
Definition at line 93 of file tag-host.hpp.
void ndn::Data::resetWire |
( |
| ) |
|
|
protected |
Clear wire encoding and cached FullName.
- Note
- This does not clear the SignatureValue.
Definition at line 209 of file data.cpp.
void ndn::PacketBase::setCongestionMark |
( |
uint64_t |
mark | ) |
|
|
inherited |
set the CongestionMark tag to the specified value
Definition at line 41 of file packet-base.cpp.
Data & ndn::Data::setContent |
( |
const Block & |
block | ) |
|
Set Content from a block.
If block's TLV-TYPE is Content, it will be used directly as Data's Content element. If block's TLV-TYPE is not Content, it will be nested into a Content element.
- Returns
- a reference to this Data, to allow chaining
Definition at line 241 of file data.cpp.
Data & ndn::Data::setContent |
( |
const uint8_t * |
value, |
|
|
size_t |
valueSize |
|
) |
| |
Copy Content value from raw buffer.
- Parameters
-
value | pointer to the first octet of the value |
valueSize | size of the raw buffer |
- Returns
- a reference to this Data, to allow chaining
Definition at line 256 of file data.cpp.
Set Content from wire buffer.
- Parameters
-
value | Content value, which does not need to be a TLV element |
- Returns
- a reference to this Data, to allow chaining
Definition at line 264 of file data.cpp.
Data & ndn::Data::setContentType |
( |
uint32_t |
type | ) |
|
Data & ndn::Data::setFreshnessPeriod |
( |
time::milliseconds |
freshnessPeriod | ) |
|
Data & ndn::Data::setName |
( |
const Name & |
name | ) |
|
Set name.
- Returns
- a reference to this Data, to allow chaining
Definition at line 216 of file data.cpp.
Data & ndn::Data::setSignatureValue |
( |
const Block & |
value | ) |
|
Set SignatureValue.
- Returns
- a reference to this Data, to allow chaining
Definition at line 280 of file data.cpp.
template<typename T >
void ndn::TagHost::setTag |
( |
shared_ptr< T > |
tag | ) |
const |
|
inherited |
set a tag item
- Template Parameters
-
T | type of the tag, which must be a subclass of ndn::Tag |
- Note
- Tag can be set even on a const tag host instance
Definition at line 79 of file tag-host.hpp.
void ndn::Data::wireDecode |
( |
const Block & |
wire | ) |
|
Decode from wire
in NDN Packet Format v0.2 or v0.3.
Definition at line 122 of file data.cpp.
template<encoding::Tag TAG>
size_t ndn::Data::wireEncode |
( |
EncodingImpl< TAG > & |
encoder, |
|
|
bool |
wantUnsignedPortionOnly = false |
|
) |
| const |
Prepend wire encoding to encoder
in NDN Packet Format v0.2.
- Parameters
-
encoder | EncodingEstimator or EncodingBuffer instance |
wantUnsignedPortionOnly | If true, only prepends Name, MetaInfo, Content, and SignatureInfo to encoder , but omit SignatureValue and outmost Type-Length of Data element. This is intended to be used with wireEncode(encoder, signatureValue). |
- Exceptions
-
Error | SignatureBits are not provided and wantUnsignedPortionOnly is false. |
Definition at line 48 of file data.cpp.
const Block & ndn::Data::wireEncode |
( |
EncodingBuffer & |
encoder, |
|
|
const Block & |
signatureValue |
|
) |
| const |
Finalize Data packet encoding with the specified SignatureValue.
- Parameters
-
encoder | EncodingBuffer containing Name, MetaInfo, Content, and SignatureInfo, but without SignatureValue or outmost Type-Length of Data element |
signatureValue | SignatureValue element |
This method is intended to be used in concert with Data::wireEncode(encoder, true)
...
EncodingBuffer encoder;
data.wireEncode(encoder, true);
...
Block signatureValue = <sign_over_unsigned_portion>(encoder.buf(), encoder.size());
data.wireEncode(encoder, signatureValue)
Definition at line 93 of file data.cpp.
const Block & ndn::Data::wireEncode |
( |
| ) |
const |
Encode to a Block
.
- Precondition
- Data is signed.
Normally, this function encodes to NDN Packet Format v0.2. However, if this instance has cached wire encoding (hasWire()
is true), the cached encoding is returned and it might be in v0.3 format.
Definition at line 106 of file data.cpp.