Represents a TLV element of NDN packet format. More...
#include <block.hpp>
Classes | |
class | Error |
Public Types | |
using | element_container = std::vector< Block > |
using | element_iterator = element_container::iterator |
using | element_const_iterator = element_container::const_iterator |
Public Member Functions | |
Block () | |
Create an empty Block. More... | |
Block (const Block &) | |
Copy constructor. More... | |
Block & | operator= (const Block &) |
Copy assignment operator. More... | |
Block (Block &&) noexcept | |
Move constructor. More... | |
Block & | operator= (Block &&) noexcept |
Move assignment operator. More... | |
Block (const EncodingBuffer &buffer) | |
Parse Block from an EncodingBuffer. More... | |
Block (const ConstBufferPtr &buffer) | |
Parse Block from a wire Buffer. More... | |
Block (ConstBufferPtr buffer, Buffer::const_iterator begin, Buffer::const_iterator end, bool verifyLength=true) | |
Parse Block within boundaries of a wire Buffer. More... | |
Block (const Block &block, Buffer::const_iterator begin, Buffer::const_iterator end, bool verifyLength=true) | |
Parse Block within boundaries of an existing Block, reusing underlying wire Buffer. More... | |
Block (ConstBufferPtr buffer, uint32_t type, Buffer::const_iterator begin, Buffer::const_iterator end, Buffer::const_iterator valueBegin, Buffer::const_iterator valueEnd) | |
Create a Block from a wire Buffer without parsing. More... | |
Block (const uint8_t *buf, size_t bufSize) | |
Parse Block from a raw buffer. More... | |
Block (uint32_t type) | |
Create an empty Block with specified TLV-TYPE. More... | |
Block (uint32_t type, ConstBufferPtr value) | |
Create a Block with specified TLV-TYPE and TLV-VALUE. More... | |
Block (uint32_t type, const Block &value) | |
Create a Block with specified TLV-TYPE and TLV-VALUE. More... | |
bool | empty () const |
Check if the Block is empty. More... | |
bool | hasWire () const |
Check if the Block has fully encoded wire. More... | |
void | reset () |
Reset wire buffer of the element. More... | |
void | resetWire () |
Reset wire buffer but keep TLV-TYPE and sub elements (if any) More... | |
Buffer::const_iterator | begin () const |
Get begin iterator of encoded wire. More... | |
Buffer::const_iterator | end () const |
Get end iterator of encoded wire. More... | |
const uint8_t * | wire () const |
Get pointer to encoded wire. More... | |
size_t | size () const |
Get size of encoded wire, including Type-Length-Value. More... | |
shared_ptr< const Buffer > | getBuffer () const |
Get underlying buffer. More... | |
uint32_t | type () const |
Get TLV-TYPE. More... | |
bool | hasValue () const |
Get begin iterator of TLV-VALUE. More... | |
Buffer::const_iterator | value_begin () const |
Get begin iterator of TLV-VALUE. More... | |
Buffer::const_iterator | value_end () const |
Get end iterator of TLV-VALUE. More... | |
const uint8_t * | value () const |
Get pointer to TLV-VALUE. More... | |
size_t | value_size () const |
Get size of TLV-VALUE aka TLV-LENGTH. More... | |
Block | blockFromValue () const |
void | parse () const |
Parse TLV-VALUE into sub elements. More... | |
void | encode () |
Encode sub elements into TLV-VALUE. More... | |
const Block & | get (uint32_t type) const |
Get the first sub element of specified TLV-TYPE. More... | |
element_const_iterator | find (uint32_t type) const |
Find the first sub element of specified TLV-TYPE. More... | |
void | remove (uint32_t type) |
Remove all sub elements of specified TLV-TYPE. More... | |
element_iterator | erase (element_const_iterator position) |
Erase a sub element. More... | |
element_iterator | erase (element_const_iterator first, element_const_iterator last) |
Erase a range of sub elements. More... | |
void | push_back (const Block &element) |
Append a sub element. More... | |
element_iterator | insert (element_const_iterator pos, const Block &element) |
Insert a sub element. More... | |
const element_container & | elements () const |
Get container of sub elements. More... | |
element_const_iterator | elements_begin () const |
Equivalent to elements().begin() More... | |
element_const_iterator | elements_end () const |
Equivalent to elements().end() More... | |
size_t | elements_size () const |
Equivalent to elements().size() More... | |
operator boost::asio::const_buffer () const | |
Implicit conversion to const_buffer. More... | |
Static Public Member Functions | |
static Block | fromStream (std::istream &is) |
Parse Block from an input stream. More... | |
static std::tuple< bool, Block > | fromBuffer (ConstBufferPtr buffer, size_t offset) |
Try to parse Block from a wire buffer. More... | |
static std::tuple< bool, Block > | fromBuffer (const uint8_t *buf, size_t bufSize) |
Try to parse Block from a raw buffer. More... | |
Protected Attributes | |
shared_ptr< const Buffer > | m_buffer |
underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields More... | |
Buffer::const_iterator | m_begin |
Buffer::const_iterator | m_end |
Buffer::const_iterator | m_valueBegin |
Buffer::const_iterator | m_valueEnd |
uint32_t | m_type = std::numeric_limits<uint32_t>::max() |
TLV-TYPE. More... | |
size_t | m_size = 0 |
total size including Type-Length-Value More... | |
element_container | m_elements |
sub elements More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Block &block) |
Print block to os . More... | |
Represents a TLV element of NDN packet format.
using ndn::Block::element_container = std::vector<Block> |
using ndn::Block::element_iterator = element_container::iterator |
using ndn::Block::element_const_iterator = element_container::const_iterator |
|
default |
Create an empty Block.
Referenced by blockFromValue(), fromBuffer(), and fromStream().
|
default |
Copy constructor.
|
inlinedefaultnoexcept |
Move constructor.
|
explicit |
Parse Block from an EncodingBuffer.
buffer | an EncodingBuffer containing one TLV element |
tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE |
|
explicit |
ndn::Block::Block | ( | ConstBufferPtr | buffer, |
Buffer::const_iterator | begin, | ||
Buffer::const_iterator | end, | ||
bool | verifyLength = true |
||
) |
Parse Block within boundaries of a wire Buffer.
buffer | a Buffer containing an TLV element at [begin ,end ) |
begin | begin position of the TLV element within buffer |
end | end position of the TLV element within buffer |
verifyLength | if true, check TLV-LENGTH equals size of TLV-VALUE |
std::invalid_argument | buffer is empty, or [begin ,end ) range are not within buffer |
tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE |
ndn::Block::Block | ( | const Block & | block, |
Buffer::const_iterator | begin, | ||
Buffer::const_iterator | end, | ||
bool | verifyLength = true |
||
) |
Parse Block within boundaries of an existing Block, reusing underlying wire Buffer.
block | a Block whose buffer contains an TLV element at [begin ,end ) |
begin | begin position of the TLV element within block |
end | end position of the TLV element within block |
verifyLength | if true, check TLV-LENGTH equals size of TLV-VALUE |
std::invalid_argument | [begin ,end ) range are not within block |
tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE |
ndn::Block::Block | ( | ConstBufferPtr | buffer, |
uint32_t | type, | ||
Buffer::const_iterator | begin, | ||
Buffer::const_iterator | end, | ||
Buffer::const_iterator | valueBegin, | ||
Buffer::const_iterator | valueEnd | ||
) |
Create a Block from a wire Buffer without parsing.
buffer | a Buffer containing an TLV element at [begin ,end ) |
type | TLV-TYPE |
begin | begin position of the TLV element within buffer |
end | end position of the TLV element within buffer |
valueBegin | begin position of TLV-VALUE within buffer |
valueEnd | end position of TLV-VALUE within buffer |
ndn::Block::Block | ( | const uint8_t * | buf, |
size_t | bufSize | ||
) |
Parse Block from a raw buffer.
buf | pointer to the first octet of an TLV element |
bufSize | size of the raw buffer; may be more than size of the TLV element |
tlv::Error | Type-Length parsing fails, or size of TLV-VALUE exceeds bufSize |
Definition at line 108 of file block.cpp.
References end(), m_begin, m_buffer, m_end, m_size, m_type, m_valueBegin, m_valueEnd, ndn::tlv::readType(), and ndn::tlv::readVarNumber().
|
explicit |
ndn::Block::Block | ( | uint32_t | type, |
ConstBufferPtr | value | ||
) |
Create a Block with specified TLV-TYPE and TLV-VALUE.
type | TLV-TYPE |
value | a Buffer containing the TLV-VALUE |
Definition at line 138 of file block.cpp.
References m_size, m_type, ndn::tlv::sizeOfVarNumber(), and value_size().
ndn::Block::Block | ( | uint32_t | type, |
const Block & | value | ||
) |
Create a Block with specified TLV-TYPE and TLV-VALUE.
type | TLV-TYPE |
value | a Block to be nested as TLV-VALUE |
Definition at line 149 of file block.cpp.
References m_size, m_type, ndn::tlv::sizeOfVarNumber(), and value_size().
|
static |
Parse Block from an input stream.
tlv::Error | TLV-LENGTH is zero or exceeds upper bound |
Definition at line 161 of file block.cpp.
References begin(), Block(), end(), ndn::MAX_SIZE_OF_BLOCK_FROM_STREAM, ndn::tlv::readType(), ndn::tlv::readVarNumber(), ndn::tlv::sizeOfVarNumber(), and type().
Referenced by ns3::ndn::BlockHeader::Deserialize().
|
static |
Try to parse Block from a wire buffer.
buffer | a Buffer containing an TLV element at offset offset |
offset | begin position of the TLV element within buffer |
Definition at line 193 of file block.cpp.
References begin(), Block(), ndn::tlv::readType(), ndn::tlv::readVarNumber(), and type().
Referenced by ndn::nfd::parseDatasetVector(), nfd::face::WebSocketTransport::receiveMessage(), and nfd::face::EthernetTransport::receivePayload().
|
static |
Try to parse Block from a raw buffer.
buf | pointer to the first octet of an TLV element |
bufSize | size of the raw buffer; may be more than size of the TLV element |
Definition at line 219 of file block.cpp.
References Block(), end(), ndn::tlv::readType(), ndn::tlv::readVarNumber(), and type().
|
inline |
Check if the Block is empty.
A Block is "empty" only if it is default-constructed. A Block with zero-length TLV-VALUE is not considered empty.
Definition at line 187 of file block.hpp.
References m_type.
Referenced by ndn::Interest::hasParameters(), ndn::operator<<(), and size().
bool ndn::Block::hasWire | ( | ) | const |
Check if the Block has fully encoded wire.
A Block has fully encoded wire if the underlying buffer exists and contains full Type-Length-Value instead of just TLV-VALUE field.
Definition at line 249 of file block.cpp.
References m_begin, m_buffer, and m_end.
Referenced by ndn::encoding::Encoder::appendBlock(), begin(), ndn::name::Component::compare(), encode(), end(), ndn::Data::getContent(), ndn::Data::getFullName(), ndn::Interest::hasWire(), ndn::Name::hasWire(), ndn::Data::hasWire(), ndn::encoding::Encoder::prependBlock(), ndn::encoding::Estimator::prependBlock(), wire(), ndn::security::ValidityPeriod::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::nfd::FaceEventNotification::wireEncode(), ndn::nfd::FaceStatus::wireEncode(), ndn::nfd::ChannelStatus::wireEncode(), ndn::nfd::StrategyChoice::wireEncode(), ndn::nfd::CsInfo::wireEncode(), ndn::nfd::FaceQueryFilter::wireEncode(), ndn::nfd::ForwarderStatus::wireEncode(), ndn::Selectors::wireEncode(), ndn::mgmt::ControlResponse::wireEncode(), ndn::lp::NackHeader::wireEncode(), ndn::nfd::NextHopRecord::wireEncode(), ndn::SignatureInfo::wireEncode(), ndn::Exclude::wireEncode(), ndn::lp::CachePolicy::wireEncode(), ndn::KeyLocator::wireEncode(), ndn::Interest::wireEncode(), ndn::MetaInfo::wireEncode(), ndn::Data::wireEncode(), ndn::security::ValidityPeriod::wireEncode(), ndn::nfd::ControlParameters::wireEncode(), ndn::security::v2::AdditionalDescription::wireEncode(), ndn::nfd::Route::wireEncode(), ndn::Name::wireEncode(), ndn::nfd::FibEntry::wireEncode(), ndn::name::Component::wireEncode(), and ndn::nfd::RibEntry::wireEncode().
void ndn::Block::reset | ( | ) |
Reset wire buffer of the element.
Definition at line 255 of file block.cpp.
References m_elements, m_type, and resetWire().
Referenced by ndn::MetaInfo::addAppMetaInfo(), ndn::nfd::FibEntry::addNextHopRecord(), ndn::nfd::RibEntry::addRoute(), ndn::SignatureInfo::appendTypeSpecificTlv(), ndn::KeyLocator::clear(), ndn::Exclude::clear(), ndn::nfd::FibEntry::clearNextHopRecords(), ndn::nfd::RibEntry::clearRoutes(), ndn::Exclude::excludeAfter(), ndn::Exclude::excludeOne(), ndn::Interest::modifyForwardingHint(), ndn::MetaInfo::removeAppMetaInfo(), ndn::Data::resetWire(), ndn::MetaInfo::setAppMetaInfo(), ndn::nfd::FaceStatus::setBaseCongestionMarkingInterval(), ndn::nfd::ControlParameters::setBaseCongestionMarkingInterval(), ndn::mgmt::ControlResponse::setBody(), ndn::Interest::setCanBePrefix(), ndn::nfd::CsInfo::setCapacity(), ndn::nfd::ControlParameters::setCapacity(), ndn::Selectors::setChildSelector(), ndn::Interest::setChildSelector(), ndn::mgmt::ControlResponse::setCode(), ndn::nfd::NextHopRecord::setCost(), ndn::nfd::Route::setCost(), ndn::nfd::ControlParameters::setCost(), ndn::nfd::ControlParameters::setCount(), ndn::nfd::ForwarderStatus::setCurrentTimestamp(), ndn::nfd::FaceStatus::setDefaultCongestionThreshold(), ndn::nfd::ControlParameters::setDefaultCongestionThreshold(), ndn::nfd::CsInfo::setEnableAdmit(), ndn::nfd::CsInfo::setEnableServe(), ndn::Selectors::setExclude(), ndn::Interest::setExclude(), ndn::nfd::FaceStatus::setExpirationPeriod(), ndn::nfd::Route::setExpirationPeriod(), ndn::nfd::ControlParameters::setExpirationPeriod(), ndn::nfd::FaceTraits< FaceEventNotification >::setFaceId(), ndn::nfd::NextHopRecord::setFaceId(), ndn::nfd::Route::setFaceId(), ndn::nfd::FaceQueryFilter::setFaceId(), ndn::nfd::ControlParameters::setFaceId(), ndn::nfd::FaceTraits< FaceEventNotification >::setFacePersistency(), ndn::nfd::FaceQueryFilter::setFacePersistency(), ndn::nfd::ControlParameters::setFacePersistency(), ndn::nfd::FaceTraits< FaceEventNotification >::setFaceScope(), ndn::nfd::FaceQueryFilter::setFaceScope(), ndn::MetaInfo::setFinalBlock(), ndn::nfd::FaceTraits< FaceEventNotification >::setFlagBit(), ndn::nfd::Route::setFlags(), ndn::nfd::FaceTraits< FaceEventNotification >::setFlags(), ndn::nfd::ControlParameters::setFlags(), ndn::Interest::setForwardingHint(), ndn::MetaInfo::setFreshnessPeriod(), ndn::Interest::setInterestLifetime(), ndn::SignatureInfo::setKeyLocator(), ndn::nfd::FaceEventNotification::setKind(), ndn::nfd::FaceTraits< FaceEventNotification >::setLinkType(), ndn::nfd::FaceQueryFilter::setLinkType(), ndn::nfd::ChannelStatus::setLocalUri(), ndn::nfd::FaceTraits< FaceEventNotification >::setLocalUri(), ndn::nfd::FaceQueryFilter::setLocalUri(), ndn::nfd::ControlParameters::setLocalUri(), ndn::nfd::ControlParameters::setMask(), ndn::Selectors::setMaxSuffixComponents(), ndn::Interest::setMaxSuffixComponents(), ndn::Selectors::setMinSuffixComponents(), ndn::Interest::setMinSuffixComponents(), ndn::nfd::FaceStatus::setMtu(), ndn::nfd::ControlParameters::setMtu(), ndn::Selectors::setMustBeFresh(), ndn::Interest::setMustBeFresh(), ndn::nfd::StrategyChoice::setName(), ndn::nfd::ControlParameters::setName(), ndn::Interest::setName(), ndn::nfd::RibEntry::setName(), ndn::nfd::ForwarderStatus::setNCsEntries(), ndn::nfd::CsInfo::setNEntries(), ndn::nfd::FibEntry::setNextHopRecords(), ndn::nfd::ForwarderStatus::setNfdVersion(), ndn::nfd::ForwarderStatus::setNFibEntries(), ndn::nfd::CsInfo::setNHits(), ndn::nfd::FaceStatus::setNInBytes(), ndn::nfd::ForwarderStatus::setNInData(), ndn::nfd::FaceStatus::setNInData(), ndn::nfd::ForwarderStatus::setNInInterests(), ndn::nfd::FaceStatus::setNInInterests(), ndn::nfd::ForwarderStatus::setNInNacks(), ndn::nfd::FaceStatus::setNInNacks(), ndn::nfd::ForwarderStatus::setNMeasurementsEntries(), ndn::nfd::CsInfo::setNMisses(), ndn::nfd::ForwarderStatus::setNNameTreeEntries(), ndn::Interest::setNonce(), ndn::nfd::FaceStatus::setNOutBytes(), ndn::nfd::ForwarderStatus::setNOutData(), ndn::nfd::FaceStatus::setNOutData(), ndn::nfd::ForwarderStatus::setNOutInterests(), ndn::nfd::FaceStatus::setNOutInterests(), ndn::nfd::ForwarderStatus::setNOutNacks(), ndn::nfd::FaceStatus::setNOutNacks(), ndn::nfd::ForwarderStatus::setNPitEntries(), ndn::nfd::ForwarderStatus::setNSatisfiedInterests(), ndn::nfd::ForwarderStatus::setNUnsatisfiedInterests(), ndn::nfd::Route::setOrigin(), ndn::nfd::ControlParameters::setOrigin(), ndn::Interest::setParameters(), ndn::security::ValidityPeriod::setPeriod(), ndn::lp::CachePolicy::setPolicy(), ndn::nfd::FibEntry::setPrefix(), ndn::Selectors::setPublisherPublicKeyLocator(), ndn::Interest::setPublisherPublicKeyLocator(), ndn::lp::NackHeader::setReason(), ndn::nfd::FaceTraits< FaceEventNotification >::setRemoteUri(), ndn::nfd::FaceQueryFilter::setRemoteUri(), ndn::nfd::RibEntry::setRoutes(), ndn::Interest::setSelectors(), ndn::SignatureInfo::setSignatureType(), ndn::nfd::ForwarderStatus::setStartTimestamp(), ndn::nfd::StrategyChoice::setStrategy(), ndn::nfd::ControlParameters::setStrategy(), ndn::mgmt::ControlResponse::setText(), ndn::MetaInfo::setType(), ndn::nfd::ControlParameters::setUri(), ndn::nfd::FaceQueryFilter::setUriScheme(), ndn::nfd::FaceStatus::unsetBaseCongestionMarkingInterval(), ndn::nfd::ControlParameters::unsetBaseCongestionMarkingInterval(), ndn::nfd::ControlParameters::unsetCapacity(), ndn::nfd::ControlParameters::unsetCost(), ndn::nfd::ControlParameters::unsetCount(), ndn::nfd::FaceStatus::unsetDefaultCongestionThreshold(), ndn::nfd::ControlParameters::unsetDefaultCongestionThreshold(), ndn::nfd::FaceStatus::unsetExpirationPeriod(), ndn::nfd::Route::unsetExpirationPeriod(), ndn::nfd::ControlParameters::unsetExpirationPeriod(), ndn::nfd::FaceQueryFilter::unsetFaceId(), ndn::nfd::ControlParameters::unsetFaceId(), ndn::nfd::FaceQueryFilter::unsetFacePersistency(), ndn::nfd::ControlParameters::unsetFacePersistency(), ndn::nfd::FaceQueryFilter::unsetFaceScope(), ndn::nfd::ControlParameters::unsetFlags(), ndn::SignatureInfo::unsetKeyLocator(), ndn::nfd::FaceQueryFilter::unsetLinkType(), ndn::nfd::ControlParameters::unsetLocalUri(), ndn::nfd::ControlParameters::unsetMask(), ndn::nfd::FaceStatus::unsetMtu(), ndn::nfd::ControlParameters::unsetMtu(), ndn::nfd::ControlParameters::unsetName(), ndn::nfd::ControlParameters::unsetOrigin(), ndn::Interest::unsetParameters(), ndn::nfd::ControlParameters::unsetStrategy(), ndn::nfd::ControlParameters::unsetUri(), and ndn::SignatureInfo::unsetValidityPeriod().
void ndn::Block::resetWire | ( | ) |
Reset wire buffer but keep TLV-TYPE and sub elements (if any)
Definition at line 264 of file block.cpp.
References m_begin, m_buffer, m_end, m_valueBegin, and m_valueEnd.
Referenced by ndn::Name::deepCopy(), erase(), insert(), push_back(), remove(), and reset().
Buffer::const_iterator ndn::Block::begin | ( | ) | const |
Get begin iterator of encoded wire.
Definition at line 271 of file block.cpp.
References hasWire(), and m_begin.
Referenced by fromBuffer(), fromStream(), parse(), and ndn::lp::Packet::wireDecode().
Buffer::const_iterator ndn::Block::end | ( | ) | const |
Get end iterator of encoded wire.
Definition at line 280 of file block.cpp.
References hasWire(), and m_end.
Referenced by Block(), fromBuffer(), fromStream(), parse(), and ndn::lp::Packet::wireDecode().
const uint8_t * ndn::Block::wire | ( | ) | const |
Get pointer to encoded wire.
Definition at line 289 of file block.cpp.
References hasWire(), and m_begin.
Referenced by ndn::mgmt::StatusDatasetContext::append(), ndn::encoding::Encoder::appendBlock(), ndn::util::Sqlite3Statement::bind(), ndn::name::Component::compare(), nfd::name_tree::computeHash(), nfd::name_tree::computeHashes(), ndn::Data::getFullName(), ndn::util::Sha256::operator<<(), ndn::encoding::Encoder::prependBlock(), ndn::io::saveBlock(), ndn::util::DummyClientFace::Transport::send(), nfd::face::InternalClientTransport::send(), and ndn::name::Component::wireDecode().
size_t ndn::Block::size | ( | ) | const |
Get size of encoded wire, including Type-Length-Value.
Definition at line 298 of file block.cpp.
References empty(), and m_size.
Referenced by ndn::mgmt::StatusDatasetContext::append(), ndn::encoding::Encoder::appendBlock(), ndn::util::Sqlite3Statement::bind(), ndn::WireEncodable< X >::BOOST_CONCEPT_USAGE(), ndn::name::Component::compare(), nfd::name_tree::computeHash(), nfd::name_tree::computeHashes(), nfd::face::LpFragmenter::fragmentPacket(), ndn::Data::getFullName(), ndn::name::detail::ComponentType::getSuccessorImpl(), nfd::face::StreamTransport< boost::asio::local::stream_protocol >::handleReceive(), ndn::util::Sha256::operator<<(), ndn::security::parse(), ndn::nfd::parseDatasetVector(), nfd::face::LpReliability::piggyback(), ndn::encoding::Encoder::prependBlock(), ndn::encoding::Estimator::prependBlock(), nfd::face::DatagramTransport< boost::asio::ip::udp, Multicast >::receiveDatagram(), ndn::io::saveBlock(), ndn::util::DummyClientFace::Transport::send(), nfd::face::InternalClientTransport::send(), and ndn::Data::wireEncode().
|
inline |
|
inline |
Get TLV-TYPE.
Definition at line 249 of file block.hpp.
References m_type.
Referenced by ndn::MetaInfo::addAppMetaInfo(), ndn::Name::append(), ndn::encoding::Encoder::appendBlock(), ndn::name::Component::compare(), ndn::lp::DecodeHelper< TlvType, EmptyValue >::decode(), ndn::lp::DecodeHelper< TlvType, uint64_t >::decode(), ndn::lp::DecodeHelper< TlvType, std::pair< Buffer::const_iterator, Buffer::const_iterator > >::decode(), ndn::lp::FieldDecl< LOCATION, VALUE, TYPE, REPEATABLE, DECODER_TAG, ENCODER_TAG >::decode(), ndn::name::Component::equals(), find(), nfd::face::LpFragmenter::fragmentPacket(), fromBuffer(), ndn::name::Component::fromEscapedString(), fromStream(), get(), ndn::name::Component::getSuccessor(), ndn::name::detail::ComponentType::getSuccessorImpl(), ndn::name::Component::isGeneric(), ndn::name::detail::Sha256ComponentType::match(), ndn::operator<<(), ndn::operator==(), parse(), nfd::face::LpReliability::piggyback(), ndn::encoding::Encoder::prependBlock(), ndn::encoding::Estimator::prependBlock(), ndn::encoding::readNonNegativeIntegerAs(), remove(), ndn::Data::setContent(), ndn::KeyLocator::setKeyDigest(), ndn::Interest::setParameters(), ndn::Signature::setValue(), ndn::name::Component::toUri(), ndn::lp::Packet::wireDecode(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::lp::PrefixAnnouncementHeader::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::Selectors::wireDecode(), ndn::lp::NackHeader::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::SignatureInfo::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::Exclude::wireDecode(), ndn::DelegationList::wireDecode(), ndn::Interest::wireDecode(), ndn::KeyLocator::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::nfd::ControlParameters::wireDecode(), ndn::security::ValidityPeriod::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::nfd::Route::wireDecode(), ndn::Name::wireDecode(), ndn::nfd::FibEntry::wireDecode(), ndn::nfd::RibEntry::wireDecode(), ndn::name::Component::wireEncode(), and ndn::name::detail::ComponentType::writeUri().
|
inline |
Get begin iterator of TLV-VALUE.
This property reflects whether the underlying buffer contains TLV-VALUE. If this is false, TLV-VALUE has zero-length. If this is true, TLV-VALUE may be zero-length.
Definition at line 260 of file block.hpp.
References m_buffer.
Referenced by blockFromValue(), value(), and value_size().
|
inline |
Get begin iterator of TLV-VALUE.
Definition at line 269 of file block.hpp.
References m_valueBegin.
Referenced by ndn::security::v2::KeyChain::addCertificate(), ndn::lp::DecodeHelper< TlvType, std::pair< Buffer::const_iterator, Buffer::const_iterator > >::decode(), ndn::name::Component::equals(), parse(), ndn::encoding::readNonNegativeInteger(), ndn::name::Component::toNumberWithMarker(), and ndn::name::detail::ComponentType::writeUriEscapedValue().
|
inline |
Get end iterator of TLV-VALUE.
Definition at line 278 of file block.hpp.
References m_valueEnd.
Referenced by ndn::security::v2::KeyChain::addCertificate(), ndn::lp::DecodeHelper< TlvType, std::pair< Buffer::const_iterator, Buffer::const_iterator > >::decode(), ndn::name::Component::equals(), parse(), ndn::encoding::readNonNegativeInteger(), ndn::name::Component::toNumberWithMarker(), and ndn::name::detail::ComponentType::writeUriEscapedValue().
const uint8_t * ndn::Block::value | ( | ) | const |
Get pointer to TLV-VALUE.
Definition at line 310 of file block.cpp.
References hasValue(), and m_valueBegin.
Referenced by ndn::security::pib::PibMemory::addCertificate(), ndn::security::pib::PibSqlite3::addCertificate(), ndn::encoding::Encoder::appendBlock(), ndn::name::Component::compare(), ndn::lp::DecodeHelper< TlvType, uint64_t >::decode(), ndn::name::Component::fromTimestamp(), ndn::name::Component::getSuccessor(), ndn::name::detail::ComponentType::getSuccessorImpl(), ndn::name::Component::isNumberWithMarker(), ndn::operator<<(), ndn::operator==(), ndn::security::parse(), ndn::encoding::Encoder::prependBlock(), ndn::encoding::Estimator::prependBlock(), ndn::encoding::readDouble(), ndn::encoding::readString(), ndn::name::Component::toTimestamp(), ndn::security::verifySignature(), ndn::name::Component::wireEncode(), and ndn::name::detail::ComponentType::writeUriEscapedValue().
size_t ndn::Block::value_size | ( | ) | const |
Get size of TLV-VALUE aka TLV-LENGTH.
Definition at line 316 of file block.cpp.
References hasValue(), m_valueBegin, and m_valueEnd.
Referenced by ndn::security::pib::PibMemory::addCertificate(), ndn::security::pib::PibSqlite3::addCertificate(), ndn::encoding::Encoder::appendBlock(), Block(), ndn::name::Component::compare(), ndn::lp::DecodeHelper< TlvType, EmptyValue >::decode(), ndn::lp::DecodeHelper< TlvType, uint64_t >::decode(), ndn::lp::DecodeHelper< TlvType, std::pair< Buffer::const_iterator, Buffer::const_iterator > >::decode(), ndn::name::Component::empty(), ndn::name::Component::equals(), ndn::name::detail::ComponentType::getSuccessorImpl(), ndn::name::Component::isNumber(), ndn::name::Component::isNumberWithMarker(), ndn::name::detail::Sha256ComponentType::match(), ndn::operator<<(), ndn::operator==(), ndn::security::parse(), parse(), ndn::encoding::Encoder::prependBlock(), ndn::encoding::Estimator::prependBlock(), ndn::encoding::readDouble(), ndn::encoding::readNonNegativeInteger(), ndn::encoding::readString(), ndn::name::Component::toNumberWithMarker(), ndn::security::verifySignature(), ndn::name::Component::wireEncode(), and ndn::name::detail::ComponentType::writeUriEscapedValue().
Block ndn::Block::blockFromValue | ( | ) | const |
Definition at line 322 of file block.cpp.
References Block(), hasValue(), m_valueBegin, and m_valueEnd.
Referenced by nfd::ManagerBase::extractRequester().
void ndn::Block::parse | ( | ) | const |
Parse TLV-VALUE into sub elements.
tlv::Error | TLV-VALUE is not a sequence of TLV elements |
Definition at line 333 of file block.cpp.
References begin(), end(), m_buffer, m_elements, ndn::tlv::readType(), ndn::tlv::readVarNumber(), ndn::to_string(), type(), value_begin(), value_end(), and value_size().
Referenced by ndn::MetadataObject::MetadataObject(), ndn::Name::Name(), ndn::PrefixAnnouncement::PrefixAnnouncement(), ndn::lp::Packet::wireDecode(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::lp::PrefixAnnouncementHeader::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::Selectors::wireDecode(), ndn::lp::NackHeader::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::SignatureInfo::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::Exclude::wireDecode(), ndn::DelegationList::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::Interest::wireDecode(), ndn::KeyLocator::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::Data::wireDecode(), ndn::nfd::ControlParameters::wireDecode(), ndn::security::ValidityPeriod::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::nfd::Route::wireDecode(), ndn::Name::wireDecode(), ndn::nfd::FibEntry::wireDecode(), ndn::nfd::RibEntry::wireDecode(), ndn::security::ValidityPeriod::wireEncode(), ndn::security::v2::AdditionalDescription::wireEncode(), and ndn::Name::wireEncode().
void ndn::Block::encode | ( | ) |
Encode sub elements into TLV-VALUE.
Definition at line 361 of file block.cpp.
References hasWire().
Referenced by ndn::Data::getContent(), ndn::util::DummyClientFace::Transport::receive(), ndn::mgmt::ControlResponse::setBody(), ndn::security::v2::KeyChain::sign(), ndn::PrefixAnnouncement::toData(), ndn::lp::Packet::wireEncode(), and ndn::mgmt::ControlResponse::wireEncode().
const Block & ndn::Block::get | ( | uint32_t | type | ) | const |
Get the first sub element of specified TLV-TYPE.
Error | sub element of type does not exist |
Definition at line 422 of file block.cpp.
References find(), m_elements, m_type, ndn::to_string(), and type().
Referenced by ndn::MetadataObject::MetadataObject(), ndn::PrefixAnnouncement::PrefixAnnouncement(), and ndn::lp::PrefixAnnouncementHeader::wireDecode().
Block::element_const_iterator ndn::Block::find | ( | uint32_t | type | ) | const |
Find the first sub element of specified TLV-TYPE.
Definition at line 434 of file block.cpp.
References m_elements, and type().
Referenced by ndn::name::Component::fromEscapedString(), get(), ndn::Interest::matchesData(), ndn::PrefixAnnouncement::PrefixAnnouncement(), ndn::Selectors::wireDecode(), and ndn::nfd::ControlParameters::wireDecode().
void ndn::Block::remove | ( | uint32_t | type | ) |
Remove all sub elements of specified TLV-TYPE.
Definition at line 441 of file block.cpp.
References m_elements, resetWire(), and type().
Referenced by ndn::lp::Packet::clear().
Block::element_iterator ndn::Block::erase | ( | Block::element_const_iterator | position | ) |
Erase a sub element.
Definition at line 451 of file block.cpp.
References m_elements, and resetWire().
Referenced by ndn::lp::Packet::remove().
Block::element_iterator ndn::Block::erase | ( | Block::element_const_iterator | first, |
Block::element_const_iterator | last | ||
) |
Erase a range of sub elements.
Definition at line 458 of file block.cpp.
References m_elements, and resetWire().
void ndn::Block::push_back | ( | const Block & | element | ) |
Append a sub element.
Definition at line 465 of file block.cpp.
References m_elements, and resetWire().
Referenced by ndn::Name::append(), ndn::PrefixAnnouncement::toData(), and ndn::mgmt::ControlResponse::wireEncode().
Block::element_iterator ndn::Block::insert | ( | Block::element_const_iterator | pos, |
const Block & | element | ||
) |
Insert a sub element.
pos | position of new sub element |
element | new sub element |
Definition at line 472 of file block.cpp.
References m_elements, and resetWire().
Referenced by ndn::lp::Packet::add().
|
inline |
Get container of sub elements.
Definition at line 361 of file block.hpp.
References m_elements.
Referenced by ndn::Name::at(), ndn::Name::begin(), ndn::Name::empty(), ndn::Name::end(), nfd::face::LpFragmenter::fragmentPacket(), ndn::lp::Packet::get(), ndn::Name::get(), ndn::lp::Packet::list(), ndn::PrefixAnnouncement::PrefixAnnouncement(), ndn::lp::Packet::wireDecode(), ndn::DelegationList::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::KeyLocator::wireDecode(), ndn::security::ValidityPeriod::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), and ndn::lp::Packet::wireEncode().
|
inline |
Equivalent to elements().begin()
Definition at line 369 of file block.hpp.
References m_elements.
Referenced by ndn::lp::Packet::add(), ndn::lp::Packet::count(), ndn::operator<<(), ndn::lp::Packet::remove(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::lp::NackHeader::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::SignatureInfo::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::Exclude::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::KeyLocator::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::Data::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::nfd::Route::wireDecode(), ndn::nfd::FibEntry::wireDecode(), and ndn::nfd::RibEntry::wireDecode().
|
inline |
Equivalent to elements().end()
Definition at line 377 of file block.hpp.
References m_elements.
Referenced by ndn::lp::Packet::add(), ndn::lp::Packet::count(), ndn::Interest::matchesData(), ndn::operator<<(), ndn::PrefixAnnouncement::PrefixAnnouncement(), ndn::lp::Packet::remove(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::Selectors::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::SignatureInfo::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::Exclude::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::Data::wireDecode(), ndn::nfd::ControlParameters::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::nfd::Route::wireDecode(), ndn::nfd::FibEntry::wireDecode(), and ndn::nfd::RibEntry::wireDecode().
|
inline |
Equivalent to elements().size()
Definition at line 385 of file block.hpp.
References m_elements.
Referenced by ndn::lp::Packet::empty(), ndn::Name::size(), ndn::lp::NackHeader::wireDecode(), ndn::Exclude::wireDecode(), ndn::security::ValidityPeriod::wireDecode(), and ndn::security::v2::AdditionalDescription::wireDecode().
ndn::Block::operator boost::asio::const_buffer | ( | ) | const |
|
friend |
Print block
to os
.
Default-constructed block is printed as: [invalid]
. Zero-length block is printed as: TT[empty]
, where TT is TLV-TYPE in decimal. Non-zero-length block on which Block::parse
is not called is printed as: TT[LL]=VVVV
, where LL is TLV-LENGTH in decimal, and VVVV is TLV-VALUE is hexadecimal. Block on which Block::parse
has been called in printed as: TT[LL]={SUB,SUB}
, where SUB is a sub-element printed using this format.
|
protected |
underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields
If m_buffer is nullptr, this is an empty Block with TLV-TYPE given in m_type. Otherwise,
Definition at line 422 of file block.hpp.
Referenced by Block(), getBuffer(), hasValue(), hasWire(), parse(), and resetWire().
|
protected |
|
protected |
|
protected |
Definition at line 426 of file block.hpp.
Referenced by Block(), blockFromValue(), resetWire(), value(), value_begin(), and value_size().
|
protected |
Definition at line 427 of file block.hpp.
Referenced by Block(), blockFromValue(), resetWire(), value_end(), and value_size().
|
protected |
|
protected |
|
mutableprotected |
sub elements
This field is valid only if parse() has been executed.
Definition at line 441 of file block.hpp.
Referenced by elements(), elements_begin(), elements_end(), elements_size(), erase(), find(), get(), insert(), ndn::operator<<(), parse(), push_back(), remove(), and reset().