Represents a Data packet. More...
#include <data.hpp>
Classes | |
class | Error |
Public Member Functions | |
Data (const Name &name=Name()) | |
Construct an unsigned Data packet with given name and empty Content. More... | |
Data (const Block &wire) | |
Construct a Data packet by decoding from wire . More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const |
Prepend wire encoding to encoder in NDN Packet Format v0.2. More... | |
const Block & | wireEncode (EncodingBuffer &encoder, const Block &signatureValue) const |
Finalize Data packet encoding with the specified SignatureValue. More... | |
const Block & | wireEncode () const |
Encode to a Block . More... | |
void | wireDecode (const Block &wire) |
Decode from wire in NDN Packet Format v0.2 or v0.3. More... | |
bool | hasWire () const |
Check if this instance has cached wire encoding. More... | |
const Name & | getFullName () const |
Get full name including implicit digest. More... | |
const Name & | getName () const |
Get name. More... | |
Data & | setName (const Name &name) |
Set name. More... | |
const MetaInfo & | getMetaInfo () const |
Get MetaInfo. More... | |
Data & | setMetaInfo (const MetaInfo &metaInfo) |
Set MetaInfo. More... | |
const Block & | getContent () const |
Get Content. More... | |
Data & | setContent (const Block &block) |
Set Content from a block. More... | |
Data & | setContent (const uint8_t *value, size_t valueSize) |
Copy Content value from raw buffer. More... | |
Data & | setContent (const ConstBufferPtr &value) |
Set Content from wire buffer. More... | |
const Signature & | getSignature () const |
Get Signature. More... | |
Data & | setSignature (const Signature &signature) |
Set Signature. More... | |
Data & | setSignatureValue (const Block &value) |
Set SignatureValue. More... | |
uint32_t | getContentType () const |
Data & | setContentType (uint32_t type) |
time::milliseconds | getFreshnessPeriod () const |
Data & | setFreshnessPeriod (time::milliseconds freshnessPeriod) |
const optional< name::Component > & | getFinalBlock () const |
Data & | setFinalBlock (optional< name::Component > finalBlockId) |
NDN_CXX_DEPRECATED name::Component | getFinalBlockId () const |
NDN_CXX_DEPRECATED Data & | setFinalBlockId (const name::Component &finalBlockId) |
Public Member Functions inherited from ndn::PacketBase | |
uint64_t | getCongestionMark () const |
get the value of the CongestionMark tag More... | |
void | setCongestionMark (uint64_t mark) |
set the CongestionMark tag to the specified value More... | |
Public Member Functions inherited from ndn::TagHost | |
template<typename T > | |
shared_ptr< T > | getTag () const |
get a tag item More... | |
template<typename T > | |
void | setTag (shared_ptr< T > tag) const |
set a tag item More... | |
template<typename T > | |
void | removeTag () const |
remove tag item More... | |
Protected Member Functions | |
void | resetWire () |
Clear wire encoding and cached FullName. More... | |
|
explicit |
Construct a Data packet by decoding from wire
.
wire | tlv::Data element as defined in NDN Packet Format v0.2 or v0.3. It may be signed or unsigned. |
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.
References wireDecode().
size_t ndn::Data::wireEncode | ( | EncodingImpl< TAG > & | encoder, |
bool | wantUnsignedPortionOnly = false |
||
) | const |
Prepend wire encoding to encoder
in NDN Packet Format v0.2.
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). |
Error | SignatureBits are not provided and wantUnsignedPortionOnly is false. |
Definition at line 48 of file data.cpp.
References ndn::tlv::Data, getContent(), ndn::Signature::getInfo(), getMetaInfo(), getName(), ndn::Signature::getValue(), ndn::MetaInfo::wireEncode(), and ndn::Name::wireEncode().
Referenced by ndn::security::pib::PibSqlite3::addCertificate(), ndn::security::pib::detail::KeyImpl::getDefaultCertificate(), ndn::security::parse(), ndn::util::DummyClientFace::receive(), ndn::security::v2::KeyChain::sign(), and ndn::security::SafeBag::wireEncode().
const Block & ndn::Data::wireEncode | ( | EncodingBuffer & | encoder, |
const Block & | signatureValue | ||
) | const |
Finalize Data packet encoding with the specified SignatureValue.
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)
Definition at line 93 of file data.cpp.
References ndn::tlv::Data, ndn::Block::size(), and wireDecode().
const Block & ndn::Data::wireEncode | ( | ) | const |
Encode to a Block
.
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.
References ndn::Block::hasWire(), and wireDecode().
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.
References ndn::Name::clear(), ndn::tlv::Content, ndn::Block::elements(), ndn::tlv::isCriticalType(), ndn::tlv::MetaInfo, ndn::tlv::Name, ndn::Block::parse(), ndn::Signature::setInfo(), ndn::Signature::setValue(), ndn::tlv::SignatureInfo, ndn::tlv::SignatureValue, ndn::to_string(), ndn::MetaInfo::wireDecode(), and ndn::Name::wireDecode().
Referenced by Data(), ndn::Link::wireDecode(), ndn::security::SafeBag::wireDecode(), and wireEncode().
|
inline |
Check if this instance has cached wire encoding.
Definition at line 112 of file data.hpp.
References ndn::Block::hasWire().
const Name & ndn::Data::getFullName | ( | ) | const |
Get full name including implicit digest.
Definition at line 197 of file data.cpp.
References ndn::Name::appendImplicitSha256Digest(), ndn::util::Sha256::computeDigest(), ndn::Name::empty(), ndn::Block::hasWire(), ndn::Block::size(), and ndn::Block::wire().
Referenced by nfd::cs::compareDataWithData(), nfd::cs::compareQueryWithData(), ndn::InMemoryStorage::insert(), and ndn::Interest::matchesData().
|
inline |
Get name.
Definition at line 128 of file data.hpp.
Referenced by ndn::security::pib::CertificateContainer::add(), ndn::security::pib::PibMemory::addCertificate(), ndn::security::pib::PibSqlite3::addCertificate(), ndn::security::v2::KeyChain::addCertificate(), nfd::fw::Strategy::afterContentStoreHit(), nfd::fw::Strategy::afterReceiveData(), nfd::fw::asf::AsfStrategy::beforeSatisfyInterest(), nfd::fw::Strategy::beforeSatisfyInterest(), ndn::security::v2::Certificate::Certificate(), ndn::security::v2::ValidationPolicySimpleHierarchy::checkPolicy(), ndn::security::v2::validator_config::ValidationPolicyConfig::checkPolicy(), nfd::cs::compareDataWithData(), nfd::cs::compareQueryWithData(), nfd::pit::Pit::findAllDataMatches(), ndn::security::v2::Certificate::getIdentity(), ndn::security::v2::Certificate::getIssuerId(), ndn::security::v2::Certificate::getKeyId(), ndn::security::v2::Certificate::getKeyName(), ndn::security::v2::KeyChain::importSafeBag(), nfd::cs::Cs::insert(), ndn::security::v2::CertificateCache::insert(), ndn::Interest::matchesData(), ndn::security::v2::operator<<(), ndn::operator<<(), ndn::operator==(), ndn::security::pib::detail::KeyImpl::removeCertificate(), ndn::security::pib::detail::KeyImpl::setDefaultCertificate(), ndn::security::v2::KeyChain::setDefaultCertificate(), ndn::security::signingByCertificate(), and wireEncode().
Set name.
Definition at line 218 of file data.cpp.
References resetWire().
|
inline |
Get MetaInfo.
Definition at line 142 of file data.hpp.
Referenced by ndn::operator<<(), ndn::operator==(), and wireEncode().
Set MetaInfo.
Definition at line 226 of file data.cpp.
References resetWire().
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 234 of file data.cpp.
References ndn::Block::hasWire().
Referenced by ndn::security::pib::PibMemory::addCertificate(), ndn::security::pib::PibSqlite3::addCertificate(), ndn::security::v2::KeyChain::addCertificate(), ndn::security::v2::Certificate::Certificate(), ndn::security::v2::Certificate::getPublicKey(), ndn::operator<<(), ndn::operator==(), ndn::security::verifySignature(), ndn::Link::wireDecode(), and wireEncode().
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.
Definition at line 243 of file data.cpp.
References ndn::tlv::Content, resetWire(), and ndn::Block::type().
Data & ndn::Data::setContent | ( | const uint8_t * | value, |
size_t | valueSize | ||
) |
Copy Content value from raw buffer.
value | pointer to the first octet of the value |
valueSize | size of the raw buffer |
Definition at line 258 of file data.cpp.
References ndn::tlv::Content, ndn::encoding::makeBinaryBlock(), and resetWire().
Data & ndn::Data::setContent | ( | const ConstBufferPtr & | value | ) |
Set Content from wire buffer.
value | Content value, which does not need to be a TLV element |
Definition at line 266 of file data.cpp.
References ndn::tlv::Content, and resetWire().
|
inline |
Get Signature.
Definition at line 189 of file data.hpp.
Referenced by ndn::security::v2::Certificate::getExtension(), ndn::security::v2::getKeyLocatorName(), ndn::security::v2::Certificate::getValidityPeriod(), ndn::security::v2::Certificate::isValid(), ndn::Interest::matchesData(), ndn::security::v2::operator<<(), ndn::operator<<(), ndn::operator==(), and ndn::security::parse().
Set Signature.
Definition at line 274 of file data.cpp.
References resetWire().
Referenced by ndn::security::v2::KeyChain::sign().
Set SignatureValue.
Definition at line 282 of file data.cpp.
References resetWire(), and ndn::Signature::setValue().
|
inline |
Definition at line 208 of file data.hpp.
References ndn::MetaInfo::getType().
Referenced by ndn::security::v2::Certificate::Certificate(), and ndn::Link::wireDecode().
Data & ndn::Data::setContentType | ( | uint32_t | type | ) |
Definition at line 290 of file data.cpp.
References resetWire(), and ndn::MetaInfo::setType().
Referenced by ndn::security::v2::Certificate::Certificate().
|
inline |
Definition at line 217 of file data.hpp.
References ndn::MetaInfo::getFreshnessPeriod().
Referenced by ndn::security::v2::Certificate::Certificate().
Data & ndn::Data::setFreshnessPeriod | ( | time::milliseconds | freshnessPeriod | ) |
Definition at line 298 of file data.cpp.
References resetWire(), and ndn::MetaInfo::setFreshnessPeriod().
|
inline |
Definition at line 226 of file data.hpp.
References ndn::MetaInfo::getFinalBlock().
Data & ndn::Data::setFinalBlock | ( | optional< name::Component > | finalBlockId | ) |
Definition at line 306 of file data.cpp.
References resetWire(), and ndn::MetaInfo::setFinalBlock().
name::Component ndn::Data::getFinalBlockId | ( | ) | const |
getFinalBlock
Definition at line 314 of file data.cpp.
References ndn::MetaInfo::getFinalBlockId().
Data & ndn::Data::setFinalBlockId | ( | const name::Component & | finalBlockId | ) |
setFinalBlock
Definition at line 320 of file data.cpp.
References resetWire(), and ndn::MetaInfo::setFinalBlockId().
|
protected |
Clear wire encoding and cached FullName.
Definition at line 211 of file data.cpp.
References ndn::Name::clear(), and ndn::Block::reset().
Referenced by setContent(), setContentType(), setFinalBlock(), setFinalBlockId(), setFreshnessPeriod(), setMetaInfo(), setName(), setSignature(), and setSignatureValue().