28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<KeyLocator>));
32 static_assert(std::is_base_of<tlv::Error, KeyLocator::Error>::value,
33 "KeyLocator::Error must inherit from tlv::Error");
36 : m_type(KeyLocator_None)
50 template<encoding::Tag TAG>
57 size_t totalLength = 0;
66 totalLength += encoder.prependBlock(m_keyDigest);
69 BOOST_THROW_EXCEPTION(
Error(
"Unsupported KeyLocator type"));
72 totalLength += encoder.prependVarNumber(totalLength);
91 m_wire = buffer.block();
99 BOOST_THROW_EXCEPTION(
Error(
"Unexpected TLV type during KeyLocator decoding"));
138 BOOST_THROW_EXCEPTION(
Error(
"KeyLocator type is not Name"));
156 BOOST_THROW_EXCEPTION(
Error(
"KeyLocator type is not KeyDigest"));
165 BOOST_THROW_EXCEPTION(
Error(
"expecting KeyDigest block"));
169 m_keyDigest = keyDigest;
192 switch (keyLocator.
getType()) {
194 return os <<
"Name=" << keyLocator.
getName();
197 const size_t MAX_DIGEST_OCTETS_TO_SHOW = 5;
199 os <<
"KeyDigest=" <<
toHex(digest.
value(), digest.
value_size()).substr(0, MAX_DIGEST_OCTETS_TO_SHOW * 2);
200 if (digest.
value_size() > MAX_DIGEST_OCTETS_TO_SHOW) {
209 return os <<
"Unknown";
212 return os <<
"Unknown";
bool hasWire() const
Check if the Block has fully encoded wire.
Copyright (c) 2011-2015 Regents of the University of California.
std::string toHex(const uint8_t *buffer, size_t length, bool wantUpperCase)
Return a string containing the hex representation of the bytes in buffer.
const Block & getKeyDigest() const
get KeyDigest element
size_t value_size() const
Get size of TLV-VALUE aka TLV-LENGTH.
std::ostream & operator<<(std::ostream &os, const Data &data)
KeyLocator & setName(const Name &name)
set Name element
const Name & getName() const
get Name element
void wireDecode(const Block &wire)
decode from wire encoding
void parse() const
Parse TLV-VALUE into sub elements.
KeyLocator & setKeyDigest(const Block &keyDigest)
set KeyDigest element
Represents a TLV element of NDN packet format.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
KeyLocator()
construct an empty KeyLocator
indicates KeyLocator contains a Name
const Block & wireEncode() const
const uint8_t * value() const
Get pointer to TLV-VALUE.
const element_container & elements() const
Get container of sub elements.
a concept check for TLV abstraction with .wireEncode method
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block copying TLV-VALUE from raw buffer.
indicates KeyLocator is empty (internal use only)
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Exclude)
void reset()
Reset wire buffer of the element.
Represents an absolute name.
indicates KeyLocator contains an unknown element
KeyLocator & clear()
clear KeyLocator
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend wire encoding
indicates KeyLocator contains a KeyDigest
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
void wireDecode(const Block &wire)
Decode name from wire encoding.
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
void clear()
Remove all components.
bool operator==(const KeyLocator &other) const
EncodingImpl< EncoderTag > EncodingBuffer
uint32_t type() const
Get TLV-TYPE.
EncodingImpl< EstimatorTag > EncodingEstimator
shared_ptr< const Buffer > ConstBufferPtr