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

Namespace defining NDN Packet Format related constants and procedures. More...

Namespaces

 detail
 
 nfd
 
 security
 

Classes

class  Error
 represents an error in TLV encoding or decoding More...
 

Enumerations

enum  {
  Interest = 5, Data = 6, Name = 7, GenericNameComponent = 8,
  ImplicitSha256DigestComponent = 1, ParametersSha256DigestComponent = 2, CanBePrefix = 33, MustBeFresh = 18,
  ForwardingHint = 30, Nonce = 10, InterestLifetime = 12, HopLimit = 34,
  Parameters = 35, MetaInfo = 20, Content = 21, SignatureInfo = 22,
  SignatureValue = 23, ContentType = 24, FreshnessPeriod = 25, FinalBlockId = 26,
  SignatureType = 27, KeyLocator = 28, KeyDigest = 29, LinkDelegation = 31,
  LinkPreference = 30, NameComponentMin = 1, NameComponentMax = 65535, AppPrivateBlock1 = 128,
  AppPrivateBlock2 = 32767
}
 TLV-TYPE numbers defined in NDN Packet Format v0.3. More...
 
enum  {
  Selectors = 9, MinSuffixComponents = 13, MaxSuffixComponents = 14, PublisherPublicKeyLocator = 15,
  Exclude = 16, ChildSelector = 17, Any = 19
}
 TLV-TYPE numbers defined in NDN Packet Format v0.2 but not in v0.3. More...
 
enum  {
  KeywordNameComponent = 32, SegmentNameComponent = 33, ByteOffsetNameComponent = 34, VersionNameComponent = 35,
  TimestampNameComponent = 36, SequenceNumNameComponent = 37
}
 TLV-TYPE numbers for typed name components. More...
 
enum  SignatureTypeValue : uint16_t { DigestSha256 = 0, SignatureSha256WithRsa = 1, SignatureSha256WithEcdsa = 3, SignatureHmacWithSha256 = 4 }
 SignatureType values. More...
 
enum  {
  ValidityPeriod = 253, NotBefore = 254, NotAfter = 255, AdditionalDescription = 258,
  DescriptionEntry = 512, DescriptionKey = 513, DescriptionValue = 514
}
 TLV-TYPE numbers for SignatureInfo features. More...
 
enum  ContentTypeValue : uint32_t {
  ContentType_Blob = 0, ContentType_Link = 1, ContentType_Key = 2, ContentType_Nack = 3,
  ContentType_Manifest = 4, ContentType_PrefixAnn = 5, ContentType_Flic = 1024
}
 ContentType values. More...
 

Functions

std::ostream & operator<< (std::ostream &os, SignatureTypeValue st)
 
std::ostream & operator<< (std::ostream &os, ContentTypeValue ct)
 
constexpr bool isCriticalType (uint32_t type)
 Determine whether a TLV-TYPE is "critical" for evolvability purpose. More...
 
template<typename Iterator >
bool readVarNumber (Iterator &begin, Iterator end, uint64_t &number) noexcept
 Read VAR-NUMBER in NDN-TLV encoding. More...
 
template<typename Iterator >
bool readType (Iterator &begin, Iterator end, uint32_t &type) noexcept
 Read TLV-TYPE. More...
 
template<typename Iterator >
uint64_t readVarNumber (Iterator &begin, Iterator end)
 Read VAR-NUMBER in NDN-TLV encoding. More...
 
template<typename Iterator >
uint32_t readType (Iterator &begin, Iterator end)
 Read TLV-TYPE. More...
 
constexpr size_t sizeOfVarNumber (uint64_t number) noexcept
 Get the number of bytes necessary to hold the value of number encoded as VAR-NUMBER. More...
 
size_t writeVarNumber (std::ostream &os, uint64_t number)
 Write VAR-NUMBER to the specified stream. More...
 
template<typename Iterator >
uint64_t readNonNegativeInteger (size_t size, Iterator &begin, Iterator end)
 Read nonNegativeInteger in NDN-TLV encoding. More...
 
constexpr size_t sizeOfNonNegativeInteger (uint64_t integer) noexcept
 Get the number of bytes necessary to hold the value of integer encoded as nonNegativeInteger. More...
 
size_t writeNonNegativeInteger (std::ostream &os, uint64_t integer)
 Write nonNegativeInteger to the specified stream. More...
 

Variables

constexpr int NameComponent = GenericNameComponent
 

Detailed Description

Namespace defining NDN Packet Format related constants and procedures.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

TLV-TYPE numbers defined in NDN Packet Format v0.3.

See also
https://named-data.net/doc/NDN-packet-spec/current/types.html
Enumerator
Interest 
Data 
Name 
GenericNameComponent 
ImplicitSha256DigestComponent 
ParametersSha256DigestComponent 
CanBePrefix 
MustBeFresh 
ForwardingHint 
Nonce 
InterestLifetime 
HopLimit 
Parameters 
MetaInfo 
Content 
SignatureInfo 
SignatureValue 
ContentType 
FreshnessPeriod 
FinalBlockId 
SignatureType 
KeyLocator 
KeyDigest 
LinkDelegation 
LinkPreference 
NameComponentMin 
NameComponentMax 
AppPrivateBlock1 
AppPrivateBlock2 

Definition at line 61 of file tlv.hpp.

◆ anonymous enum

anonymous enum

TLV-TYPE numbers defined in NDN Packet Format v0.2 but not in v0.3.

See also
https://named-data.net/doc/NDN-packet-spec/0.2.1/types.html
Enumerator
Selectors 
MinSuffixComponents 
MaxSuffixComponents 
PublisherPublicKeyLocator 
Exclude 
ChildSelector 
Any 

Definition at line 98 of file tlv.hpp.

◆ anonymous enum

anonymous enum

TLV-TYPE numbers for typed name components.

See also
https://redmine.named-data.net/projects/ndn-tlv/wiki/NameComponentType
Enumerator
KeywordNameComponent 
SegmentNameComponent 
ByteOffsetNameComponent 
VersionNameComponent 
TimestampNameComponent 
SequenceNumNameComponent 

Definition at line 114 of file tlv.hpp.

◆ SignatureTypeValue

SignatureType values.

See also
https://named-data.net/doc/NDN-packet-spec/current/signature.html
Enumerator
DigestSha256 
SignatureSha256WithRsa 
SignatureSha256WithEcdsa 
SignatureHmacWithSha256 

Definition at line 126 of file tlv.hpp.

◆ anonymous enum

anonymous enum

TLV-TYPE numbers for SignatureInfo features.

See also
docs/specs/certificate-format.rst
Enumerator
ValidityPeriod 
NotBefore 
NotAfter 
AdditionalDescription 
DescriptionEntry 
DescriptionKey 
DescriptionValue 

Definition at line 139 of file tlv.hpp.

◆ ContentTypeValue

enum ndn::tlv::ContentTypeValue : uint32_t

ContentType values.

See also
https://redmine.named-data.net/projects/ndn-tlv/wiki/ContentType
Enumerator
ContentType_Blob 

payload

ContentType_Link 

another name that identifies the actual data content

ContentType_Key 

public key, certificate

ContentType_Nack 

application-level nack

ContentType_Manifest 
ContentType_PrefixAnn 

prefix announcement

ContentType_Flic 

File-Like ICN Collection.

Definition at line 153 of file tlv.hpp.

Function Documentation

◆ operator<<() [1/2]

std::ostream & ndn::tlv::operator<< ( std::ostream &  os,
SignatureTypeValue  st 
)

◆ operator<<() [2/2]

std::ostream & ndn::tlv::operator<< ( std::ostream &  os,
ContentTypeValue  ct 
)

◆ isCriticalType()

constexpr bool ndn::tlv::isCriticalType ( uint32_t  type)

Determine whether a TLV-TYPE is "critical" for evolvability purpose.

See also
https://named-data.net/doc/NDN-packet-spec/0.3/tlv.html#considerations-for-evolvability-of-tlv-based-encoding

Definition at line 171 of file tlv.hpp.

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

◆ readVarNumber() [1/2]

template<typename Iterator >
bool ndn::tlv::readVarNumber ( Iterator &  begin,
Iterator  end,
uint64_t &  number 
)
noexcept

Read VAR-NUMBER in NDN-TLV encoding.

Template Parameters
Iteratoran iterator or pointer that dereferences to uint8_t or compatible type
Parameters
[in,out]beginBegin of the buffer, will be incremented to point to the first byte after the read VAR-NUMBER
[in]endEnd of the buffer
[out]numberRead VAR-NUMBER
Returns
true if number was successfully read from input, false otherwise

Definition at line 387 of file tlv.hpp.

Referenced by ndn::Block::Block(), ndn::Block::fromBuffer(), ndn::Block::fromStream(), ndn::Block::parse(), readType(), and readVarNumber().

◆ readType() [1/2]

template<typename Iterator >
bool ndn::tlv::readType ( Iterator &  begin,
Iterator  end,
uint32_t &  type 
)
noexcept

Read TLV-TYPE.

Template Parameters
Iteratoran iterator or pointer that dereferences to uint8_t or compatible type
Parameters
[in,out]beginBegin of the buffer, will be incremented to point to the first byte after the read TLV-TYPE
[in]endEnd of the buffer
[out]typeRead TLV-TYPE
Returns
true if TLV-TYPE was successfully read from input, false otherwise
Note
This function is largely equivalent to readVarNumber(), except that it returns false if the TLV-TYPE is larger than 2^32-1 (TLV-TYPE in this library is implemented as uint32_t)

Definition at line 406 of file tlv.hpp.

References readVarNumber().

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

◆ readVarNumber() [2/2]

template<typename Iterator >
uint64_t ndn::tlv::readVarNumber ( Iterator &  begin,
Iterator  end 
)

Read VAR-NUMBER in NDN-TLV encoding.

Template Parameters
Iteratoran iterator or pointer that dereferences to uint8_t or compatible type
Parameters
[in,out]beginBegin of the buffer, will be incremented to point to the first byte after the read VAR-NUMBER
[in]endEnd of the buffer
Exceptions
tlv::ErrorVAR-NUMBER cannot be read

Definition at line 420 of file tlv.hpp.

References readVarNumber().

◆ readType() [2/2]

template<typename Iterator >
uint32_t ndn::tlv::readType ( Iterator &  begin,
Iterator  end 
)

Read TLV-TYPE.

Template Parameters
Iteratoran iterator or pointer that dereferences to uint8_t or compatible type
Parameters
[in,out]beginBegin of the buffer, will be incremented to point to the first byte after the read TLV-TYPE
[in]endEnd of the buffer
Exceptions
tlv::ErrorTLV-TYPE cannot be read
Note
This function is largely equivalent to readVarNumber(), except that it throws if the TLV-TYPE is larger than 2^32-1 (TLV-TYPE in this library is implemented as uint32_t)

Definition at line 437 of file tlv.hpp.

References readVarNumber().

◆ sizeOfVarNumber()

constexpr size_t ndn::tlv::sizeOfVarNumber ( uint64_t  number)
noexcept

Get the number of bytes necessary to hold the value of number encoded as VAR-NUMBER.

Definition at line 448 of file tlv.hpp.

Referenced by ndn::Block::Block(), ndn::Block::fromStream(), and nfd::face::LpReliability::piggyback().

◆ writeVarNumber()

size_t ndn::tlv::writeVarNumber ( std::ostream &  os,
uint64_t  number 
)
inline

Write VAR-NUMBER to the specified stream.

Returns
length of written VAR-NUMBER

Definition at line 456 of file tlv.hpp.

◆ readNonNegativeInteger()

template<typename Iterator >
uint64_t ndn::tlv::readNonNegativeInteger ( size_t  size,
Iterator &  begin,
Iterator  end 
)

Read nonNegativeInteger in NDN-TLV encoding.

Template Parameters
Iteratoran iterator or pointer that dereferences to uint8_t or compatible type
Parameters
[in]sizesize of the nonNegativeInteger
[in,out]beginBegin of the buffer, will be incremented to point to the first byte after the read nonNegativeInteger
[in]endEnd of the buffer
Exceptions
tlv::Errornumber cannot be read
Note
How many bytes to read is directly controlled by size, which can be either 1, 2, 4, or 8. If size differs from std::distance(begin, end), tlv::Error exception will be thrown.

Definition at line 484 of file tlv.hpp.

Referenced by ndn::encoding::readNonNegativeInteger(), and ndn::name::Component::toNumberWithMarker().

◆ sizeOfNonNegativeInteger()

constexpr size_t ndn::tlv::sizeOfNonNegativeInteger ( uint64_t  integer)
noexcept

Get the number of bytes necessary to hold the value of integer encoded as nonNegativeInteger.

Definition at line 501 of file tlv.hpp.

◆ writeNonNegativeInteger()

size_t ndn::tlv::writeNonNegativeInteger ( std::ostream &  os,
uint64_t  integer 
)
inline

Write nonNegativeInteger to the specified stream.

Returns
length of written nonNegativeInteger

Definition at line 509 of file tlv.hpp.

Variable Documentation

◆ NameComponent

constexpr int ndn::tlv::NameComponent = GenericNameComponent

Definition at line 109 of file tlv.hpp.