ndn::tlv Namespace Reference

Contains constants and low-level functions related to the NDN packet format. More...

Namespaces

 detail
 
 nfd
 
 security
 

Classes

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

Enumerations

enum  : uint32_t {
  Invalid = 0 ,
  Interest = 5 ,
  Data = 6 ,
  Name = 7 ,
  GenericNameComponent = 8 ,
  ImplicitSha256DigestComponent = 1 ,
  ParametersSha256DigestComponent = 2 ,
  KeywordNameComponent = 32 ,
  SegmentNameComponent = 50 ,
  ByteOffsetNameComponent = 52 ,
  VersionNameComponent = 54 ,
  TimestampNameComponent = 56 ,
  SequenceNumNameComponent = 58 ,
  CanBePrefix = 33 ,
  MustBeFresh = 18 ,
  ForwardingHint = 30 ,
  Nonce = 10 ,
  InterestLifetime = 12 ,
  HopLimit = 34 ,
  ApplicationParameters = 36 ,
  InterestSignatureInfo = 44 ,
  InterestSignatureValue = 46 ,
  MetaInfo = 20 ,
  Content = 21 ,
  SignatureInfo = 22 ,
  SignatureValue = 23 ,
  ContentType = 24 ,
  FreshnessPeriod = 25 ,
  FinalBlockId = 26 ,
  SignatureType = 27 ,
  KeyLocator = 28 ,
  KeyDigest = 29 ,
  SignatureNonce = 38 ,
  SignatureTime = 40 ,
  SignatureSeqNum = 42 ,
  ValidityPeriod = 253 ,
  NotBefore = 254 ,
  NotAfter = 255 ,
  AdditionalDescription = 258 ,
  DescriptionEntry = 512 ,
  DescriptionKey = 513 ,
  DescriptionValue = 514 ,
  NameComponentMin = 1 ,
  NameComponentMax = 65535 ,
  AppPrivateBlock1 = 128 ,
  AppPrivateBlock2 = 32768
}
 TLV-TYPE numbers defined in NDN Packet Format v0.3. 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...
 
enum  SignatureTypeValue : uint16_t {
  DigestSha256 = 0 ,
  SignatureSha256WithRsa = 1 ,
  SignatureSha256WithEcdsa = 3 ,
  SignatureHmacWithSha256 = 4 ,
  SignatureEd25519 = 5 ,
  NullSignature = 200
}
 SignatureType values. More...
 

Functions

constexpr bool isCriticalType (uint32_t type) noexcept
 Determine whether a TLV-TYPE is "critical" for evolvability purpose. More...
 
std::ostream & operator<< (std::ostream &os, ContentTypeValue ct)
 
std::ostream & operator<< (std::ostream &os, SignatureTypeValue st)
 
template<typename Iterator >
constexpr uint64_t readNonNegativeInteger (size_t size, Iterator &begin, Iterator end)
 Read a NonNegativeInteger in NDN-TLV encoding. More...
 
template<typename Iterator >
constexpr uint32_t readType (Iterator &begin, Iterator end)
 Read TLV-TYPE. More...
 
template<typename Iterator >
constexpr bool readType (Iterator &begin, Iterator end, uint32_t &type) noexcept
 Read TLV-TYPE. More...
 
template<typename Iterator >
constexpr uint64_t readVarNumber (Iterator &begin, Iterator end)
 Read VAR-NUMBER in NDN-TLV encoding. More...
 
template<typename Iterator >
constexpr bool readVarNumber (Iterator &begin, Iterator end, uint64_t &number) noexcept
 Read VAR-NUMBER 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...
 
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 writeNonNegativeInteger (std::ostream &os, uint64_t integer)
 Write a NonNegativeInteger to the specified stream. More...
 
size_t writeVarNumber (std::ostream &os, uint64_t number)
 Write VAR-NUMBER to the specified stream. More...
 

Detailed Description

Contains constants and low-level functions related to the NDN packet format.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : uint32_t

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

See also
https://docs.named-data.net/NDN-packet-spec/0.3/types.html
https://redmine.named-data.net/projects/ndn-tlv/wiki/NameComponentType
Enumerator
Invalid 
Interest 
Data 
Name 
GenericNameComponent 
ImplicitSha256DigestComponent 
ParametersSha256DigestComponent 
KeywordNameComponent 
SegmentNameComponent 
ByteOffsetNameComponent 
VersionNameComponent 
TimestampNameComponent 
SequenceNumNameComponent 
CanBePrefix 
MustBeFresh 
ForwardingHint 
Nonce 
InterestLifetime 
HopLimit 
ApplicationParameters 
InterestSignatureInfo 
InterestSignatureValue 
MetaInfo 
Content 
SignatureInfo 
SignatureValue 
ContentType 
FreshnessPeriod 
FinalBlockId 
SignatureType 
KeyLocator 
KeyDigest 
SignatureNonce 
SignatureTime 
SignatureSeqNum 
ValidityPeriod 
NotBefore 
NotAfter 
AdditionalDescription 
DescriptionEntry 
DescriptionKey 
DescriptionValue 
NameComponentMin 
NameComponentMax 
AppPrivateBlock1 
AppPrivateBlock2 

Definition at line 66 of file tlv.hpp.

◆ ContentTypeValue

enum ndn::tlv::ContentTypeValue : uint32_t

ContentType values.

See also
https://docs.named-data.net/NDN-packet-spec/0.3/data.html#contenttype
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 144 of file tlv.hpp.

◆ SignatureTypeValue

SignatureType values.

See also
https://docs.named-data.net/NDN-packet-spec/0.3/signature.html#signaturetype
https://redmine.named-data.net/projects/ndn-tlv/wiki/SignatureType
Enumerator
DigestSha256 
SignatureSha256WithRsa 
SignatureSha256WithEcdsa 
SignatureHmacWithSha256 
SignatureEd25519 
NullSignature 

Definition at line 127 of file tlv.hpp.

Function Documentation

◆ isCriticalType()

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

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

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

Definition at line 162 of file tlv.hpp.

◆ operator<<() [1/2]

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

Definition at line 53 of file tlv.cpp.

◆ operator<<() [2/2]

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

Definition at line 33 of file tlv.cpp.

◆ readNonNegativeInteger()

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

Read a 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 414 of file tlv.hpp.

◆ readType() [1/2]

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

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 zero or larger than 2^32-1 (maximum allowed by the packet format).

Definition at line 394 of file tlv.hpp.

◆ readType() [2/2]

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

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 zero or larger than 2^32-1 (maximum allowed by the packet format).

Definition at line 367 of file tlv.hpp.

◆ readVarNumber() [1/2]

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

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

◆ readVarNumber() [2/2]

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

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

◆ sizeOfNonNegativeInteger()

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

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

Definition at line 430 of file tlv.hpp.

◆ sizeOfVarNumber()

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

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

Definition at line 405 of file tlv.hpp.

◆ writeNonNegativeInteger()

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

Write a NonNegativeInteger to the specified stream.

Returns
Length of written NonNegativeInteger.

Definition at line 113 of file tlv.cpp.

◆ writeVarNumber()

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

Write VAR-NUMBER to the specified stream.

Returns
Length of written VAR-NUMBER.

Definition at line 86 of file tlv.cpp.