represents a Data packet More...
#include <data.hpp>
Classes | |
class | Error |
Public Member Functions | |
Data () | |
Create an empty Data object. More... | |
Data (const Name &name) | |
Create a new Data object with the given name. More... | |
Data (const Block &wire) | |
Create a new Data object from wire encoding. More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const |
Fast encoding or block size estimation. More... | |
const Block & | wireEncode () const |
Encode to a wire format. More... | |
const Block & | wireEncode (EncodingBuffer &encoder, const Block &signatureValue) const |
Finalize Data packet encoding with the specified SignatureValue. More... | |
void | wireDecode (const Block &wire) |
Decode from the wire format. More... | |
bool | hasWire () const |
Check if Data is already has wire encoding. More... | |
const Name & | getName () const |
Get name of the Data packet. More... | |
Data & | setName (const Name &name) |
Set name to a copy of the given Name. More... | |
const Name & | getFullName () const |
Get full name of Data packet, including the implicit digest. More... | |
const MetaInfo & | getMetaInfo () const |
Get MetaInfo block from Data packet. More... | |
Data & | setMetaInfo (const MetaInfo &metaInfo) |
Set metaInfo to a copy of the given MetaInfo. More... | |
uint32_t | getContentType () const |
Data & | setContentType (uint32_t type) |
const time::milliseconds & | getFreshnessPeriod () const |
Data & | setFreshnessPeriod (const time::milliseconds &freshnessPeriod) |
const name::Component & | getFinalBlockId () const |
Data & | setFinalBlockId (const name::Component &finalBlockId) |
const Block & | getContent () const |
Get content Block. More... | |
Data & | setContent (const uint8_t *buffer, size_t bufferSize) |
Set the content from the buffer (buffer will be copied) More... | |
Data & | setContent (const Block &block) |
Set the content from the block. More... | |
Data & | setContent (const ConstBufferPtr &contentValue) |
Set the content from the pointer to immutable buffer. More... | |
const Signature & | getSignature () const |
Data & | setSignature (const Signature &signature) |
Set the signature to a copy of the given signature. More... | |
Data & | setSignatureValue (const Block &value) |
nfd::LocalControlHeader & | getLocalControlHeader () |
const nfd::LocalControlHeader & | getLocalControlHeader () const |
uint64_t | getIncomingFaceId () const |
Data & | setIncomingFaceId (uint64_t incomingFaceId) |
nfd::LocalControlHeader::CachingPolicy | getCachingPolicy () const |
Data & | setCachingPolicy (nfd::LocalControlHeader::CachingPolicy cachingPolicy) |
bool | operator== (const Data &other) const |
bool | operator!= (const Data &other) const |
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 | onChanged () |
Clear the wire encoding. More... | |
Friends | |
class | nfd::LocalControlHeader |
ndn::Data::Data | ( | ) |
Create an empty Data object.
Note that in certain contexts that use Data::shared_from_this(), Data must be created using make_shared
:
shared_ptr<Data> data = make_shared<Data>();
Otherwise, Data::shared_from_this() will throw an exception.
Definition at line 35 of file data.cpp.
Referenced by ndn::Data::Error::Error().
ndn::Data::Data | ( | const Name & | name | ) |
|
explicit |
Create a new Data object from wire encoding.
Note that in certain contexts that use Data::shared_from_this(), Data must be created using make_shared
:
shared_ptr<Data> data = make_shared<Data>(wire);
Otherwise, Data::shared_from_this() will throw an exception.
Definition at line 45 of file data.cpp.
References wireDecode().
size_t ndn::Data::wireEncode | ( | EncodingImpl< TAG > & | encoder, |
bool | wantUnsignedPortionOnly = false |
||
) | const |
Fast encoding or block size estimation.
encoder | EncodingEstimator or EncodingBuffer instance |
wantUnsignedPortionOnly | Request only unsigned portion to be encoded in block. If true, only Name, MetaInfo, Content, and SignatureInfo blocks will be encoded into the block. Note that there will be no outer TLV header of the Data packet. |
Definition at line 52 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::SecPublicInfoSqlite3::addCertificate(), ndn::security::PibSqlite3::addCertificate(), ndn::security::KeyChain::importIdentity(), ndn::SecuredBag::SecuredBag(), nfd::MulticastUdpFace::sendData(), nfd::DatagramFace< Protocol, Addressing >::sendData(), nfd::WebSocketFace::sendData(), nfd::EthernetFace::sendData(), ndn::security::KeyChain::signWithSha256(), and ndn::Validator::verifySignature().
const Block & ndn::Data::wireEncode | ( | ) | const |
Encode to a wire format.
Definition at line 119 of file data.cpp.
References ndn::Block::hasWire(), and wireDecode().
Referenced by ndn::Link::encodeContent(), and ndn::Data::Error::Error().
const Block & ndn::Data::wireEncode | ( | EncodingBuffer & | encoder, |
const Block & | signatureValue | ||
) | const |
Finalize Data packet encoding with the specified SignatureValue.
encoder | EncodingBuffer instance, containing Name, MetaInfo, Content, and SignatureInfo (without outer TLV header of the Data packet). |
signatureValue | SignatureValue block to be added to Data packet to finalize the wire encoding |
This method is intended to be used in concert with Data::wireEncode(EncodingBuffer&, true) method to optimize Data packet wire format creation:
Data data; ... EncodingBuffer encoder; data.wireEncode(encoder, true); ... Block signatureValue = <sign_over_unsigned_portion>(encoder.buf(), encoder.size()); data.wireEncode(encoder, signatureValue)
Definition at line 106 of file data.cpp.
References ndn::tlv::Data, ndn::Block::size(), and wireDecode().
void ndn::Data::wireDecode | ( | const Block & | wire | ) |
Decode from the wire format.
Definition at line 135 of file data.cpp.
References ndn::Name::clear(), ndn::tlv::Content, ndn::Block::elements_end(), ndn::Block::find(), ndn::Block::get(), ndn::tlv::MetaInfo, ndn::tlv::Name, ndn::Block::parse(), ndn::Signature::setInfo(), ndn::Signature::setValue(), ndn::tlv::SignatureInfo, ndn::tlv::SignatureValue, ndn::MetaInfo::wireDecode(), and ndn::Name::wireDecode().
Referenced by Data(), ndn::Data::Error::Error(), ndn::Certificate::wireDecode(), ndn::Link::wireDecode(), and wireEncode().
|
inline |
Check if Data is already has wire encoding.
Definition at line 337 of file data.hpp.
Referenced by ndn::Data::Error::Error().
|
inline |
Get name of the Data packet.
Definition at line 343 of file data.hpp.
Referenced by ndn::SecPublicInfoSqlite3::addCertificate(), ndn::security::PibMemory::addCertificate(), ndn::security::PibSqlite3::addCertificate(), ndn::SecPublicInfo::addCertificateAsIdentityDefault(), ndn::SecPublicInfo::addCertificateAsKeyDefault(), ndn::SecPublicInfo::addCertificateAsSystemDefault(), ndn::CommandInterestValidator::addInterestRule(), nfd::fw::AccessStrategy::beforeSatisfyInterest(), nfd::fw::Strategy::beforeSatisfyInterest(), ndn::security::conf::KeyLocatorChecker::check(), ndn::ValidatorRegex::checkPolicy(), nfd::compare_pickInterest(), nfd::cs::compareDataWithData(), nfd::cs::compareQueryWithData(), nfd::rib::RibManager::enableLocalControlHeader(), ndn::Data::Error::Error(), ndn::util::SegmentFetcher::fetch(), nfd::Pit::findAllDataMatches(), ndn::security::Key::getPublicKey(), ndn::security::KeyChain::importIdentity(), nfd::cs::Cs::insert(), ndn::nfd::makeSigningInfoFromIdentityCertificate(), ndn::security::conf::Filter::match(), ndn::SecRuleSpecific::matchDataName(), ndn::SecRuleRelative::matchDataName(), ndn::Interest::matchesData(), ndn::Validator::onData(), ndn::operator<<(), operator==(), ndn::Certificate::printCertificate(), ndn::Face::put(), ndn::Face::registerPrefix(), ndn::security::Key::removeCertificate(), ndn::SecRuleRelative::satisfy(), ndn::security::KeyChain::selfSign(), nfd::Face::Impl::NfdFace::sendData(), ndn::security::Key::setDefaultCertificate(), ndn::Face::setInterestFilter(), ndn::IdentityCertificate::setName(), and wireEncode().
Set name to a copy of the given Name.
Definition at line 170 of file data.cpp.
References onChanged().
Referenced by ndn::Data::Error::Error(), and ndn::IdentityCertificate::setName().
const Name & ndn::Data::getFullName | ( | ) | const |
Get full name of Data packet, including the implicit digest.
Error | if Data packet doesn't have a full name yet (wire encoding has not been yet created) |
Definition at line 179 of file data.cpp.
References ndn::Name::appendImplicitSha256Digest(), ndn::Name::empty(), ndn::Block::hasWire(), ndn::crypto::sha256(), ndn::Block::size(), and ndn::Block::wire().
Referenced by nfd::cs::compareDataWithData(), nfd::cs::compareQueryWithData(), ndn::Data::Error::Error(), ndn::util::InMemoryStorage::insert(), and ndn::Interest::matchesData().
|
inline |
Get MetaInfo block from Data packet.
Definition at line 349 of file data.hpp.
Referenced by nfd::rib::RibManager::enableLocalControlHeader(), ndn::Data::Error::Error(), ndn::util::SegmentFetcher::fetch(), ndn::operator<<(), operator==(), and wireEncode().
Set metaInfo to a copy of the given MetaInfo.
Definition at line 194 of file data.cpp.
References onChanged().
Referenced by ndn::Data::Error::Error().
|
inline |
Definition at line 355 of file data.hpp.
Referenced by ndn::Link::decodeContent(), and ndn::Data::Error::Error().
Data & ndn::Data::setContentType | ( | uint32_t | type | ) |
Definition at line 203 of file data.cpp.
References onChanged(), and ndn::MetaInfo::setType().
Referenced by ndn::Certificate::encode(), ndn::Link::encodeContent(), and ndn::Data::Error::Error().
|
inline |
Definition at line 361 of file data.hpp.
Referenced by nfd::compare_pickInterest(), ndn::Data::Error::Error(), and nfd::Forwarder::~Forwarder().
Data & ndn::Data::setFreshnessPeriod | ( | const time::milliseconds & | freshnessPeriod | ) |
Definition at line 212 of file data.cpp.
References onChanged(), and ndn::MetaInfo::setFreshnessPeriod().
Referenced by ndn::Data::Error::Error(), and ndn::IdentityCertificate::IdentityCertificate().
|
inline |
Definition at line 367 of file data.hpp.
Referenced by ndn::Data::Error::Error().
Data & ndn::Data::setFinalBlockId | ( | const name::Component & | finalBlockId | ) |
Definition at line 221 of file data.cpp.
References onChanged(), and ndn::MetaInfo::setFinalBlockId().
Referenced by ndn::Data::Error::Error().
const Block & ndn::Data::getContent | ( | ) | const |
Get content Block.
To access content value, one can use value()/value_size() or value_begin()/value_end() methods of the Block class
Definition at line 230 of file data.cpp.
References ndn::tlv::Content, ndn::Block::empty(), ndn::Block::encode(), ndn::Block::hasWire(), and ndn::encoding::makeEmptyBlock().
Referenced by ndn::nfd::Controller::Controller(), ndn::Certificate::decode(), ndn::Link::decodeContent(), nfd::rib::RibManager::enableLocalControlHeader(), ndn::Data::Error::Error(), ndn::util::SegmentFetcher::fetch(), ndn::operator<<(), operator==(), and wireEncode().
Data & ndn::Data::setContent | ( | const uint8_t * | buffer, |
size_t | bufferSize | ||
) |
Set the content from the buffer (buffer will be copied)
buffer | Pointer to first byte of the buffer |
bufferSize | Size of the buffer |
Definition at line 241 of file data.cpp.
References ndn::tlv::Content, ndn::encoding::makeBinaryBlock(), and onChanged().
Referenced by ndn::Certificate::encode(), ndn::Link::encodeContent(), and ndn::Data::Error::Error().
Set the content from the block.
Depending on type of the supplied block, there are two cases:
block | The Block containing the content to assign |
Definition at line 261 of file data.cpp.
References ndn::tlv::Content, onChanged(), and ndn::Block::type().
Data & ndn::Data::setContent | ( | const ConstBufferPtr & | contentValue | ) |
Set the content from the pointer to immutable buffer.
This method will create a Block with tlv::Content and set contentValue as a payload for this block. Note that this method is very different from setContent(const Block&), since it does not require that payload should be a valid TLV element.
contentValue | The pointer to immutable buffer containing the content to assign |
Definition at line 251 of file data.cpp.
References ndn::tlv::Content, and onChanged().
|
inline |
Definition at line 373 of file data.hpp.
Referenced by ndn::SecPublicInfoSqlite3::addCertificate(), ndn::security::conf::CustomizedChecker::check(), ndn::security::conf::FixedSignerChecker::check(), ndn::ValidatorRegex::checkPolicy(), ndn::ValidatorConfig::checkPolicy(), ndn::Data::Error::Error(), ndn::Interest::matchesData(), ndn::SecRuleSpecific::matchSignerName(), ndn::SecRuleRelative::matchSignerName(), ndn::operator<<(), operator==(), ndn::Certificate::printCertificate(), ndn::SecRuleRelative::satisfy(), ndn::security::KeyChain::selfSign(), ndn::security::KeyChain::signWithSha256(), and ndn::Validator::verifySignature().
Set the signature to a copy of the given signature.
signature | The signature object which is cloned. |
Definition at line 275 of file data.cpp.
References onChanged().
Referenced by ndn::Data::Error::Error(), ndn::security::KeyChain::importIdentity(), and ndn::security::KeyChain::signWithSha256().
Definition at line 284 of file data.cpp.
References onChanged(), and ndn::Signature::setValue().
Referenced by ndn::Data::Error::Error(), and ndn::security::KeyChain::signWithSha256().
|
inline |
Definition at line 379 of file data.hpp.
Referenced by ndn::Data::Error::Error(), getCachingPolicy(), getIncomingFaceId(), nfd::cs::Cs::insert(), setCachingPolicy(), and setIncomingFaceId().
|
inline |
|
inline |
Definition at line 391 of file data.hpp.
References ndn::nfd::LocalControlHeader::getIncomingFaceId(), and getLocalControlHeader().
Referenced by ndn::Data::Error::Error().
Data & ndn::Data::setIncomingFaceId | ( | uint64_t | incomingFaceId | ) |
Definition at line 295 of file data.cpp.
References getLocalControlHeader(), and ndn::nfd::LocalControlHeader::setIncomingFaceId().
Referenced by ndn::Data::Error::Error().
|
inline |
Definition at line 397 of file data.hpp.
References ndn::nfd::LocalControlHeader::getCachingPolicy(), and getLocalControlHeader().
Referenced by ndn::Data::Error::Error().
Data & ndn::Data::setCachingPolicy | ( | nfd::LocalControlHeader::CachingPolicy | cachingPolicy | ) |
Definition at line 304 of file data.cpp.
References getLocalControlHeader(), and ndn::nfd::LocalControlHeader::setCachingPolicy().
Referenced by ndn::Data::Error::Error().
bool ndn::Data::operator== | ( | const Data & | other | ) | const |
Definition at line 325 of file data.cpp.
References getContent(), getMetaInfo(), getName(), and getSignature().
Referenced by ndn::Data::Error::Error().
bool ndn::Data::operator!= | ( | const Data & | other | ) | const |
Definition at line 334 of file data.cpp.
Referenced by ndn::Data::Error::Error().
|
protected |
Clear the wire encoding.
Definition at line 313 of file data.cpp.
References ndn::Name::clear(), and ndn::Block::reset().
Referenced by ndn::Link::encodeContent(), ndn::Data::Error::Error(), setContent(), setContentType(), setFinalBlockId(), setFreshnessPeriod(), setMetaInfo(), setName(), setSignature(), and setSignatureValue().
|
friend |