NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::Block Class Reference

Represents a TLV element of NDN packet format. More...

#include <block.hpp>

Inheritance diagram for ndn::Block:
Collaboration diagram for ndn::Block:

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 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 BuffergetBuffer () 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 Blockget (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_containerelements () 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, BlockfromBuffer (ConstBufferPtr buffer, size_t offset)
 Try to parse Block from a wire buffer. More...
 
static std::tuple< bool, BlockfromBuffer (const uint8_t *buf, size_t bufSize)
 Try to parse Block from a raw buffer. More...
 

Protected Attributes

shared_ptr< const Bufferm_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
 TLV-TYPE. More...
 
uint32_t m_size
 total size including Type-Length-Value More...
 
element_container m_elements
 sub elements More...
 

Detailed Description

Represents a TLV element of NDN packet format.

See also
https://named-data.net/doc/ndn-tlv/tlv.html

Definition at line 42 of file block.hpp.

Member Typedef Documentation

◆ element_container

using ndn::Block::element_container = std::vector<Block>

Definition at line 45 of file block.hpp.

◆ element_iterator

using ndn::Block::element_iterator = element_container::iterator

Definition at line 46 of file block.hpp.

◆ element_const_iterator

using ndn::Block::element_const_iterator = element_container::const_iterator

Definition at line 47 of file block.hpp.

Constructor & Destructor Documentation

◆ Block() [1/10]

ndn::Block::Block ( )

Create an empty Block.

Definition at line 50 of file block.cpp.

Referenced by blockFromValue(), fromBuffer(), ndn::name::Component::fromImplicitSha256Digest(), and fromStream().

◆ Block() [2/10]

ndn::Block::Block ( const EncodingBuffer &  buffer)
explicit

Parse Block from an EncodingBuffer.

Parameters
bufferan EncodingBuffer containing one TLV element
Exceptions
tlv::ErrorType-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE

Definition at line 56 of file block.cpp.

◆ Block() [3/10]

ndn::Block::Block ( const ConstBufferPtr buffer)
explicit

Parse Block from a wire Buffer.

Parameters
buffera Buffer containing one TLV element
Note
This constructor takes shared ownership of buffer.
Exceptions
tlv::ErrorType-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE

Definition at line 61 of file block.cpp.

◆ Block() [4/10]

ndn::Block::Block ( ConstBufferPtr  buffer,
Buffer::const_iterator  begin,
Buffer::const_iterator  end,
bool  verifyLength = true 
)

Parse Block within boundaries of a wire Buffer.

Parameters
buffera Buffer containing an TLV element at [begin,end)
beginbegin position of the TLV element within buffer
endend position of the TLV element within buffer
verifyLengthif true, check TLV-LENGTH equals size of TLV-VALUE
Exceptions
std::invalid_argumentbuffer is empty, or [begin,end) range are not within buffer
tlv::ErrorType-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE
Note
This overload automatically detects TLV-TYPE and position of TLV-VALUE.

Definition at line 66 of file block.cpp.

References m_buffer, m_type, m_valueBegin, m_valueEnd, ndn::tlv::readType(), and ndn::tlv::readVarNumber().

◆ Block() [5/10]

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.

Parameters
blocka Block whose buffer contains an TLV element at [begin,end)
beginbegin position of the TLV element within block
endend position of the TLV element within block
verifyLengthif true, check TLV-LENGTH equals size of TLV-VALUE
Exceptions
std::invalid_argument[begin,end) range are not within block
tlv::ErrorType-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE

Definition at line 95 of file block.cpp.

◆ Block() [6/10]

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.

Parameters
buffera Buffer containing an TLV element at [begin,end)
typeTLV-TYPE
beginbegin position of the TLV element within buffer
endend position of the TLV element within buffer
valueBeginbegin position of TLV-VALUE within buffer
valueEndend position of TLV-VALUE within buffer

Definition at line 101 of file block.cpp.

◆ Block() [7/10]

ndn::Block::Block ( const uint8_t *  buf,
size_t  bufSize 
)

Parse Block from a raw buffer.

Parameters
bufpointer to the first octet of an TLV element
bufSizesize of the raw buffer; may be more than size of the TLV element
Exceptions
tlv::ErrorType-Length parsing fails, or size of TLV-VALUE exceeds bufSize
Note
This overload copies the TLV element into an internal wire buffer.

Definition at line 114 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().

◆ Block() [8/10]

ndn::Block::Block ( uint32_t  type)
explicit

Create an empty Block with specified TLV-TYPE.

Parameters
typeTLV-TYPE

Definition at line 135 of file block.cpp.

◆ Block() [9/10]

ndn::Block::Block ( uint32_t  type,
ConstBufferPtr  value 
)

Create a Block with specified TLV-TYPE and TLV-VALUE.

Parameters
typeTLV-TYPE
valuea Buffer containing the TLV-VALUE

Definition at line 141 of file block.cpp.

References m_size, m_type, ndn::tlv::sizeOfVarNumber(), and value_size().

◆ Block() [10/10]

ndn::Block::Block ( uint32_t  type,
const Block value 
)

Create a Block with specified TLV-TYPE and TLV-VALUE.

Parameters
typeTLV-TYPE
valuea Block to be nested as TLV-VALUE

Definition at line 152 of file block.cpp.

References m_size, m_type, ndn::tlv::sizeOfVarNumber(), and value_size().

Member Function Documentation

◆ fromStream()

Block ndn::Block::fromStream ( std::istream &  is)
static

Parse Block from an input stream.

Exceptions
tlv::ErrorTLV-LENGTH is zero or exceeds upper bound
Warning
If decoding fails, bytes are still consumed from the input stream.

Definition at line 164 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().

◆ fromBuffer() [1/2]

std::tuple< bool, Block > ndn::Block::fromBuffer ( ConstBufferPtr  buffer,
size_t  offset 
)
static

Try to parse Block from a wire buffer.

Parameters
buffera Buffer containing an TLV element at offset offset
offsetbegin position of the TLV element within buffer
Note
This function does not throw exceptions upon decoding failure.
Returns
true and the Block if parsing succeeds; otherwise false

Definition at line 196 of file block.cpp.

References begin(), Block(), ndn::tlv::readType(), ndn::tlv::readVarNumber(), and type().

Referenced by ndn::nfd::parseDatasetVector(), ndn::StreamTransportImpl< BaseTransport, Protocol >::processAllReceived(), nfd::face::WebSocketTransport::receiveMessage(), and nfd::face::EthernetTransport::receivePayload().

◆ fromBuffer() [2/2]

std::tuple< bool, Block > ndn::Block::fromBuffer ( const uint8_t *  buf,
size_t  bufSize 
)
static

Try to parse Block from a raw buffer.

Parameters
bufpointer to the first octet of an TLV element
bufSizesize of the raw buffer; may be more than size of the TLV element
Note
This function does not throw exceptions upon decoding failure.
This overload copies the TLV element into an internal wire buffer.
Returns
true and the Block if parsing succeeds; otherwise false

Definition at line 221 of file block.cpp.

References Block(), end(), ndn::tlv::readType(), ndn::tlv::readVarNumber(), and type().

◆ empty()

bool ndn::Block::empty ( ) const
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 173 of file block.hpp.

References m_type.

Referenced by size().

◆ hasWire()

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 251 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::Data::hasWire(), ndn::Name::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::mgmt::ControlResponse::wireEncode(), ndn::Selectors::wireEncode(), ndn::lp::NackHeader::wireEncode(), ndn::Exclude::wireEncode(), ndn::SignatureInfo::wireEncode(), ndn::nfd::NextHopRecord::wireEncode(), ndn::lp::CachePolicy::wireEncode(), ndn::Interest::wireEncode(), ndn::KeyLocator::wireEncode(), ndn::MetaInfo::wireEncode(), ndn::Data::wireEncode(), ndn::nfd::ControlParameters::wireEncode(), ndn::security::ValidityPeriod::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().

◆ reset()

void ndn::Block::reset ( )

Reset wire buffer of the element.

Postcondition
empty() == true

Definition at line 257 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::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::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::setFinalBlockId(), 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::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::FaceStatus::setNInData(), ndn::nfd::ForwarderStatus::setNInData(), ndn::nfd::FaceStatus::setNInInterests(), ndn::nfd::ForwarderStatus::setNInInterests(), ndn::nfd::FaceStatus::setNInNacks(), ndn::nfd::ForwarderStatus::setNInNacks(), ndn::nfd::ForwarderStatus::setNMeasurementsEntries(), ndn::nfd::CsInfo::setNMisses(), ndn::nfd::ForwarderStatus::setNNameTreeEntries(), ndn::Interest::setNonce(), ndn::nfd::FaceStatus::setNOutBytes(), ndn::nfd::FaceStatus::setNOutData(), ndn::nfd::ForwarderStatus::setNOutData(), ndn::nfd::FaceStatus::setNOutInterests(), ndn::nfd::ForwarderStatus::setNOutInterests(), ndn::nfd::FaceStatus::setNOutNacks(), ndn::nfd::ForwarderStatus::setNOutNacks(), ndn::nfd::ForwarderStatus::setNPitEntries(), ndn::nfd::Route::setOrigin(), ndn::nfd::ControlParameters::setOrigin(), 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::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::ControlParameters::unsetName(), ndn::nfd::ControlParameters::unsetOrigin(), ndn::nfd::ControlParameters::unsetStrategy(), ndn::nfd::ControlParameters::unsetUri(), and ndn::SignatureInfo::unsetValidityPeriod().

◆ resetWire()

void ndn::Block::resetWire ( )

Reset wire buffer but keep TLV-TYPE and sub elements (if any)

Postcondition
hasWire() == false
hasValue() == false

Definition at line 266 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().

◆ begin()

Buffer::const_iterator ndn::Block::begin ( ) const

Get begin iterator of encoded wire.

Precondition
hasWire() == true

Definition at line 273 of file block.cpp.

References hasWire(), and m_begin.

Referenced by fromBuffer(), fromStream(), parse(), and ndn::lp::Packet::wireDecode().

◆ end()

Buffer::const_iterator ndn::Block::end ( ) const

Get end iterator of encoded wire.

Precondition
hasWire() == true

Definition at line 282 of file block.cpp.

References hasWire(), and m_end.

Referenced by Block(), fromBuffer(), fromStream(), parse(), and ndn::lp::Packet::wireDecode().

◆ wire()

◆ size()

◆ getBuffer()

shared_ptr<const Buffer> ndn::Block::getBuffer ( ) const
inline

Get underlying buffer.

Definition at line 226 of file block.hpp.

References m_buffer.

◆ type()

uint32_t ndn::Block::type ( ) const
inline

Get TLV-TYPE.

Definition at line 235 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, std::pair< Buffer::const_iterator, Buffer::const_iterator > >::decode(), ndn::lp::FieldDecl< LOCATION, VALUE, TYPE, REPEATABLE >::decode(), ndn::name::Component::equals(), find(), nfd::face::LpFragmenter::fragmentPacket(), fromBuffer(), fromStream(), get(), ndn::name::Component::getSuccessor(), ndn::name::Component::isGeneric(), ndn::name::Component::isImplicitSha256Digest(), 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::Signature::setValue(), ndn::name::Component::toUri(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::lp::Packet::wireDecode(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::lp::PrefixAnnouncement::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::lp::NackHeader::wireDecode(), ndn::Selectors::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::Exclude::wireDecode(), ndn::DelegationList::wireDecode(), ndn::SignatureInfo::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::Interest::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::KeyLocator::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(), and ndn::name::Component::wireEncode().

◆ hasValue()

bool ndn::Block::hasValue ( ) const
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 246 of file block.hpp.

References m_buffer.

Referenced by blockFromValue(), value(), and value_size().

◆ value_begin()

◆ value_end()

◆ value()

◆ value_size()

◆ blockFromValue()

Block ndn::Block::blockFromValue ( ) const

Definition at line 324 of file block.cpp.

References Block(), hasValue(), m_valueBegin, and m_valueEnd.

Referenced by nfd::ManagerBase::extractRequester(), and ndn::MetaInfo::wireDecode().

◆ parse()

void ndn::Block::parse ( ) const

Parse TLV-VALUE into sub elements.

Postcondition
elements() reflects sub elements found in TLV-VALUE
Exceptions
tlv::ErrorTLV-VALUE is not a sequence of TLV elements
Note
This method does not perform recursive parsing.
This method has no effect if elements() is already populated.
This method is not really const, but it does not modify any data.

Definition at line 335 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::Name::Name(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::lp::Packet::wireDecode(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::lp::PrefixAnnouncement::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::lp::NackHeader::wireDecode(), ndn::Selectors::wireDecode(), ndn::Exclude::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::SignatureInfo::wireDecode(), ndn::DelegationList::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::Interest::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::KeyLocator::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().

◆ encode()

void ndn::Block::encode ( )

Encode sub elements into TLV-VALUE.

Postcondition
TLV-VALUE contains sub elements from elements()

Definition at line 363 of file block.cpp.

References hasWire().

Referenced by ndn::util::DummyClientFace::Transport::receive(), ndn::mgmt::ControlResponse::setBody(), ndn::security::v2::KeyChain::sign(), ndn::lp::Packet::wireEncode(), and ndn::mgmt::ControlResponse::wireEncode().

◆ get()

const Block & ndn::Block::get ( uint32_t  type) const

Get the first sub element of specified TLV-TYPE.

Precondition
parse() has been executed
Exceptions
Errorsub element of type does not exist

Definition at line 417 of file block.cpp.

References find(), m_elements, m_type, ndn::to_string(), and type().

Referenced by ndn::lp::PrefixAnnouncement::wireDecode(), ndn::Interest::wireDecode(), and ndn::Data::wireDecode().

◆ find()

Block::element_const_iterator ndn::Block::find ( uint32_t  type) const

Find the first sub element of specified TLV-TYPE.

Precondition
parse() has been executed
Returns
iterator in elements() to the found sub element, otherwise elements_end()

Definition at line 429 of file block.cpp.

References m_elements, and type().

Referenced by get(), ndn::Interest::matchesData(), ndn::Selectors::wireDecode(), ndn::Interest::wireDecode(), ndn::Data::wireDecode(), and ndn::nfd::ControlParameters::wireDecode().

◆ remove()

void ndn::Block::remove ( uint32_t  type)

Remove all sub elements of specified TLV-TYPE.

Precondition
parse() has been executed
Postcondition
find(type) == elements_end()

Definition at line 436 of file block.cpp.

References m_elements, resetWire(), and type().

Referenced by ndn::lp::Packet::clear().

◆ erase() [1/2]

Block::element_iterator ndn::Block::erase ( Block::element_const_iterator  position)

Erase a sub element.

Definition at line 446 of file block.cpp.

References m_elements, and resetWire().

Referenced by ndn::lp::Packet::remove().

◆ erase() [2/2]

Erase a range of sub elements.

Definition at line 460 of file block.cpp.

References m_elements, and resetWire().

◆ push_back()

void ndn::Block::push_back ( const Block element)

Append a sub element.

Definition at line 476 of file block.cpp.

References m_elements, and resetWire().

Referenced by ndn::Name::append(), and ndn::mgmt::ControlResponse::wireEncode().

◆ insert()

Block::element_iterator ndn::Block::insert ( Block::element_const_iterator  pos,
const Block element 
)

Insert a sub element.

Parameters
posposition of new sub element
elementnew sub element
Returns
iterator in elements() to the new sub element

Definition at line 483 of file block.cpp.

References m_elements, and resetWire().

Referenced by ndn::lp::Packet::add().

◆ elements()

◆ elements_begin()

◆ elements_end()

◆ elements_size()

◆ operator boost::asio::const_buffer()

ndn::Block::operator boost::asio::const_buffer ( ) const

Implicit conversion to const_buffer.

Definition at line 498 of file block.cpp.

Member Data Documentation

◆ m_buffer

shared_ptr<const Buffer> ndn::Block::m_buffer
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,

  • [m_valueBegin, m_valueEnd) point to TLV-VALUE within m_buffer.
  • If m_begin != m_end, [m_begin,m_end) point to Type-Length-Value of this Block within m_buffer. Otherwise, m_buffer does not contain TLV-TYPE and TLV-LENGTH fields.

Definition at line 403 of file block.hpp.

Referenced by Block(), getBuffer(), hasValue(), hasWire(), parse(), and resetWire().

◆ m_begin

Buffer::const_iterator ndn::Block::m_begin
protected
See also
m_buffer

Definition at line 404 of file block.hpp.

Referenced by begin(), Block(), hasWire(), resetWire(), and wire().

◆ m_end

Buffer::const_iterator ndn::Block::m_end
protected
See also
m_buffer

Definition at line 405 of file block.hpp.

Referenced by Block(), end(), hasWire(), and resetWire().

◆ m_valueBegin

Buffer::const_iterator ndn::Block::m_valueBegin
protected
See also
m_buffer

Definition at line 407 of file block.hpp.

Referenced by Block(), blockFromValue(), resetWire(), value(), value_begin(), and value_size().

◆ m_valueEnd

Buffer::const_iterator ndn::Block::m_valueEnd
protected
See also
m_buffer

Definition at line 408 of file block.hpp.

Referenced by Block(), blockFromValue(), resetWire(), value_end(), and value_size().

◆ m_type

uint32_t ndn::Block::m_type
protected

TLV-TYPE.

Definition at line 410 of file block.hpp.

Referenced by Block(), empty(), get(), reset(), and type().

◆ m_size

uint32_t ndn::Block::m_size
protected

total size including Type-Length-Value

This field is valid only if empty() is false.

Definition at line 416 of file block.hpp.

Referenced by Block(), and size().

◆ m_elements

element_container ndn::Block::m_elements
mutableprotected

sub elements

This field is valid only if parse() has been executed.

Definition at line 422 of file block.hpp.

Referenced by elements(), elements_begin(), elements_end(), elements_size(), erase(), find(), get(), insert(), parse(), push_back(), remove(), and reset().


The documentation for this class was generated from the following files: