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-TLV 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, ImplicitSha256DigestComponent = 1,
  NameComponent = 8, Selectors = 9, Nonce = 10, InterestLifetime = 12,
  ForwardingHint = 30, MinSuffixComponents = 13, MaxSuffixComponents = 14, PublisherPublicKeyLocator = 15,
  Exclude = 16, ChildSelector = 17, MustBeFresh = 18, Any = 19,
  MetaInfo = 20, Content = 21, SignatureInfo = 22, SignatureValue = 23,
  ContentType = 24, FreshnessPeriod = 25, FinalBlockId = 26, SignatureType = 27,
  KeyLocator = 28, KeyDigest = 29, LinkPreference = 30, LinkDelegation = 31,
  AppPrivateBlock1 = 128, AppPrivateBlock2 = 32767
}
 TLV-TYPE numbers defined in NDN Packet Format. 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)
 
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...
 

Detailed Description

Namespace defining NDN-TLV related constants and procedures.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

TLV-TYPE numbers defined in NDN Packet Format.

See also
https://named-data.net/doc/ndn-tlv/types.html
Enumerator
Interest 
Data 
Name 
ImplicitSha256DigestComponent 
NameComponent 
Selectors 
Nonce 
InterestLifetime 
ForwardingHint 
MinSuffixComponents 
MaxSuffixComponents 
PublisherPublicKeyLocator 
Exclude 
ChildSelector 
MustBeFresh 
Any 
MetaInfo 
Content 
SignatureInfo 
SignatureValue 
ContentType 
FreshnessPeriod 
FinalBlockId 
SignatureType 
KeyLocator 
KeyDigest 
LinkPreference 
LinkDelegation 
AppPrivateBlock1 
AppPrivateBlock2 

Definition at line 63 of file tlv.hpp.

◆ SignatureTypeValue

Enumerator
DigestSha256 
SignatureSha256WithRsa 
SignatureSha256WithEcdsa 

Definition at line 97 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 110 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 123 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.

◆ 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 354 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 373 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 387 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 403 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 414 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 422 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 450 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 467 of file tlv.hpp.

Referenced by nfd::face::LpReliability::piggyback().

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