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

Namespace defining NDN-TLV related constants and procedures. More...

Namespaces

 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,
  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, SelectedDelegation = 32,
  AppPrivateBlock1 = 128, AppPrivateBlock2 = 32767
}
 
enum  SignatureTypeValue { DigestSha256 = 0, SignatureSha256WithRsa = 1, SignatureSha256WithEcdsa = 3 }
 
enum  {
  ValidityPeriod = 253, NotBefore = 254, NotAfter = 255, AdditionalDescription = 258,
  DescriptionEntry = 512, DescriptionKey = 513, DescriptionValue = 514
}
 TLV codes 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

template<class InputIterator >
bool readVarNumber (InputIterator &begin, const InputIterator &end, uint64_t &number)
 Read VAR-NUMBER in NDN-TLV encoding. More...
 
template<class InputIterator >
bool readType (InputIterator &begin, const InputIterator &end, uint32_t &type)
 Read TLV Type. More...
 
template<class InputIterator >
uint64_t readVarNumber (InputIterator &begin, const InputIterator &end)
 Read VAR-NUMBER in NDN-TLV encoding. More...
 
template<class InputIterator >
uint32_t readType (InputIterator &begin, const InputIterator &end)
 Read TLV Type. More...
 
size_t sizeOfVarNumber (uint64_t varNumber)
 Get number of bytes necessary to hold value of VAR-NUMBER. More...
 
size_t writeVarNumber (std::ostream &os, uint64_t varNumber)
 Write VAR-NUMBER to the specified stream. More...
 
template<class InputIterator >
uint64_t readNonNegativeInteger (size_t size, InputIterator &begin, const InputIterator &end)
 Read nonNegativeInteger in NDN-TLV encoding. More...
 
size_t sizeOfNonNegativeInteger (uint64_t varNumber)
 Get number of bytes necessary to hold value of nonNegativeInteger. More...
 
size_t writeNonNegativeInteger (std::ostream &os, uint64_t varNumber)
 Write nonNegativeInteger to the specified stream. More...
 
template<>
bool readVarNumber< std::istream_iterator< uint8_t > > (std::istream_iterator< uint8_t > &begin, const std::istream_iterator< uint8_t > &end, uint64_t &value)
 
template<>
uint64_t readNonNegativeInteger< std::istream_iterator< uint8_t > > (size_t size, std::istream_iterator< uint8_t > &begin, const std::istream_iterator< uint8_t > &end)
 

Detailed Description

Namespace defining NDN-TLV related constants and procedures.

Enumeration Type Documentation

§ anonymous enum

anonymous enum
Enumerator
Interest 
Data 
Name 
ImplicitSha256DigestComponent 
NameComponent 
Selectors 
Nonce 
InterestLifetime 
MinSuffixComponents 
MaxSuffixComponents 
PublisherPublicKeyLocator 
Exclude 
ChildSelector 
MustBeFresh 
Any 
MetaInfo 
Content 
SignatureInfo 
SignatureValue 
ContentType 
FreshnessPeriod 
FinalBlockId 
SignatureType 
KeyLocator 
KeyDigest 
LinkPreference 
LinkDelegation 
SelectedDelegation 
AppPrivateBlock1 
AppPrivateBlock2 

Definition at line 60 of file tlv.hpp.

§ SignatureTypeValue

Enumerator
DigestSha256 
SignatureSha256WithRsa 
SignatureSha256WithEcdsa 

Definition at line 95 of file tlv.hpp.

§ anonymous enum

anonymous enum

TLV codes for SignatureInfo features.

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

Definition at line 105 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

Warning
Experimental. Not defined in NDN-TLV spec.

Definition at line 119 of file tlv.hpp.

Function Documentation

§ readVarNumber() [1/2]

template<class InputIterator >
bool ndn::tlv::readVarNumber ( InputIterator &  begin,
const InputIterator &  end,
uint64_t &  number 
)
inline

Read VAR-NUMBER in NDN-TLV encoding.

Parameters
[in]beginBegin (pointer or iterator) of the buffer
[in]endEnd (pointer or iterator) of the buffer
[out]numberRead number
Exceptions
Thiscall never throws exception
Returns
true if number successfully read from input, false otherwise

Definition at line 243 of file tlv.hpp.

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

§ readType() [1/2]

template<class InputIterator >
bool ndn::tlv::readType ( InputIterator &  begin,
const InputIterator &  end,
uint32_t &  type 
)
inline

Read TLV Type.

Parameters
[in]beginBegin (pointer or iterator) of the buffer
[in]endEnd (pointer or iterator) of the buffer
[out]typeRead type number
Exceptions
Thiscall never throws exception

This call is largely equivalent to tlv::readVarNumber, but exception will be thrown if type is larger than 2^32-1 (type in this library is implemented as uint32_t)

Definition at line 288 of file tlv.hpp.

References readVarNumber().

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

§ readVarNumber() [2/2]

template<class InputIterator >
uint64_t ndn::tlv::readVarNumber ( InputIterator &  begin,
const InputIterator &  end 
)
inline

Read VAR-NUMBER in NDN-TLV encoding.

Exceptions
Thiscall will throw ndn::tlv::Error (aka std::runtime_error) if number cannot be read

Note that after call finished, begin will point to the first byte after the read VAR-NUMBER

Definition at line 303 of file tlv.hpp.

References ndn::tlv::Error::Error(), and readVarNumber().

§ readType() [2/2]

template<class InputIterator >
uint32_t ndn::tlv::readType ( InputIterator &  begin,
const InputIterator &  end 
)
inline

Read TLV Type.

Exceptions
Thiscall will throw ndn::tlv::Error (aka std::runtime_error) if number cannot be read

This call is largely equivalent to tlv::readVarNumber, but exception will be thrown if type is larger than 2^32-1 (type in this library is implemented as uint32_t)

Definition at line 376 of file tlv.hpp.

References ndn::tlv::Error::Error(), and readVarNumber().

§ sizeOfVarNumber()

size_t ndn::tlv::sizeOfVarNumber ( uint64_t  varNumber)
inline

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

Definition at line 388 of file tlv.hpp.

Referenced by ndn::Block::Block().

§ writeVarNumber()

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

Write VAR-NUMBER to the specified stream.

Definition at line 405 of file tlv.hpp.

Referenced by ndn::Block::encode().

§ readNonNegativeInteger()

template<class InputIterator >
uint64_t ndn::tlv::readNonNegativeInteger ( size_t  size,
InputIterator &  begin,
const InputIterator &  end 
)
inline

Read nonNegativeInteger in NDN-TLV encoding.

This call will throw ndn::tlv::Error (aka std::runtime_error) if number cannot be read

Note that after call finished, begin will point to the first byte after the read VAR-NUMBER

How many bytes will be read is directly controlled by the size parameter, which can be either 1, 2, 4, or 8. If the value of size is different, then an exception will be thrown.

Definition at line 433 of file tlv.hpp.

References ndn::tlv::Error::Error().

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

§ sizeOfNonNegativeInteger()

size_t ndn::tlv::sizeOfNonNegativeInteger ( uint64_t  varNumber)
inline

Get number of bytes necessary to hold value of nonNegativeInteger.

Definition at line 542 of file tlv.hpp.

§ writeNonNegativeInteger()

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

Write nonNegativeInteger to the specified stream.

Definition at line 560 of file tlv.hpp.

§ readVarNumber< std::istream_iterator< uint8_t > >()

template<>
bool ndn::tlv::readVarNumber< std::istream_iterator< uint8_t > > ( std::istream_iterator< uint8_t > &  begin,
const std::istream_iterator< uint8_t > &  end,
uint64_t &  value 
)
inline

Definition at line 318 of file tlv.hpp.

§ readNonNegativeInteger< std::istream_iterator< uint8_t > >()

template<>
uint64_t ndn::tlv::readNonNegativeInteger< std::istream_iterator< uint8_t > > ( size_t  size,
std::istream_iterator< uint8_t > &  begin,
const std::istream_iterator< uint8_t > &  end 
)
inline

Definition at line 478 of file tlv.hpp.

References ndn::tlv::Error::Error().