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, 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  SignatureTypeValue : uint16_t { DigestSha256 = 0, SignatureSha256WithRsa = 1, SignatureSha256WithEcdsa = 3 }
 
enum  {
  ValidityPeriod = 253, NotBefore = 254, NotAfter = 255, AdditionalDescription = 258,
  DescriptionEntry = 512, DescriptionKey = 513, DescriptionValue = 514
}
 TLV-TYPE numbers for SignatureInfo features. More...
 
enum  ContentTypeValue { ContentType_Blob = 0, ContentType_Link = 1, ContentType_Key = 2, ContentType_Nack = 3 }
 indicates a possible value of ContentType field More...
 

Functions

std::ostream & operator<< (std::ostream &os, SignatureTypeValue signatureType)
 
constexpr bool isCriticalType (uint32_t type)
 Determine whether a TLV-TYPE is "critical" for evolvability purpose. More...
 
template<typename Iterator >
bool readVarNumber (Iterator &begin, const Iterator &end, uint64_t &number)
 Read VAR-NUMBER in NDN-TLV encoding. More...
 
template<typename Iterator >
bool readType (Iterator &begin, const Iterator &end, uint32_t &type)
 Read TLV-TYPE. More...
 
template<typename Iterator >
uint64_t readVarNumber (Iterator &begin, const Iterator &end)
 Read VAR-NUMBER in NDN-TLV encoding. More...
 
template<typename Iterator >
uint32_t readType (Iterator &begin, const Iterator &end)
 Read TLV Type. More...
 
constexpr size_t sizeOfVarNumber (uint64_t number)
 Get number of bytes necessary to hold value of 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, const Iterator &end)
 Read nonNegativeInteger in NDN-TLV encoding. More...
 
constexpr size_t sizeOfNonNegativeInteger (uint64_t integer)
 Get number of bytes necessary to hold value of nonNegativeInteger. More...
 
size_t writeNonNegativeInteger (std::ostream &os, uint64_t integer)
 Write nonNegativeInteger to the specified stream. More...
 

Variables

constexpr int NameComponent NDN_CXX_DEPRECATED = 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 
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 63 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 99 of file tlv.hpp.

◆ SignatureTypeValue

Enumerator
DigestSha256 
SignatureSha256WithRsa 
SignatureSha256WithEcdsa 

Definition at line 111 of file tlv.hpp.

◆ anonymous enum

anonymous enum

TLV-TYPE numbers for SignatureInfo features.

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

Definition at line 124 of file tlv.hpp.

◆ ContentTypeValue

indicates a possible value of ContentType field

Enumerator
ContentType_Blob 

indicates content is the actual data bits

ContentType_Link 

indicates content is another name which identifies actual data content

ContentType_Key 

indicates content is a public key

ContentType_Nack 

indicates a producer generated NACK

Definition at line 137 of file tlv.hpp.

Function Documentation

◆ operator<<()

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

Definition at line 28 of file tlv.cpp.

References DigestSha256, SignatureSha256WithEcdsa, and SignatureSha256WithRsa.

◆ 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 160 of file tlv.hpp.

Referenced by ndn::Data::wireDecode().

◆ readVarNumber() [1/2]

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

Read VAR-NUMBER in NDN-TLV encoding.

Template Parameters
Iteratoran iterator or pointer whose value is assignable to uint8_t
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
Note
This call never throws exceptions

Definition at line 378 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,
const Iterator &  end,
uint32_t &  type 
)

Read TLV-TYPE.

Template Parameters
Iteratoran iterator or pointer whose value is assignable to uint8_t
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 call never throws exceptions
This call is largely equivalent to tlv::readVarNumber, but it will return false if type is larger than 2^32-1 (TLV-TYPE in this library is implemented as uint32_t)

Definition at line 397 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,
const Iterator &  end 
)

Read VAR-NUMBER in NDN-TLV encoding.

Template Parameters
Iteratoran iterator or pointer whose value is assignable to uint8_t
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 411 of file tlv.hpp.

References readVarNumber().

◆ readType() [2/2]

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

Read TLV Type.

Template Parameters
Iteratoran iterator or pointer whose value is assignable to uint8_t
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::ErrorVAR-NUMBER cannot be read
Note
This call is largely equivalent to tlv::readVarNumber, but exception will be thrown if type is larger than 2^32-1 (TLV-TYPE in this library is implemented as uint32_t)

Definition at line 427 of file tlv.hpp.

References readVarNumber().

◆ sizeOfVarNumber()

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

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

Definition at line 438 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 446 of file tlv.hpp.

◆ readNonNegativeInteger()

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

Read nonNegativeInteger in NDN-TLV encoding.

Template Parameters
Iteratoran iterator or pointer whose value is assignable to uint8_t
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 474 of file tlv.hpp.

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

◆ sizeOfNonNegativeInteger()

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

Get number of bytes necessary to hold value of nonNegativeInteger.

Definition at line 491 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 499 of file tlv.hpp.

Variable Documentation

◆ NDN_CXX_DEPRECATED

constexpr int NameComponent ndn::tlv::NDN_CXX_DEPRECATED = GenericNameComponent

Definition at line 109 of file tlv.hpp.