29 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Interest>));
33 static_assert(std::is_base_of<tlv::Error, Interest::Error>::value,
34 "Interest::Error must inherit from tlv::Error");
37 : m_interestLifetime(time::milliseconds::min())
44 , m_interestLifetime(time::milliseconds::min())
51 , m_interestLifetime(interestLifetime)
68 return *
reinterpret_cast<const uint32_t*
>(m_nonce.
value());
79 std::memcpy(const_cast<uint8_t*>(m_nonce.
value()), &nonce,
sizeof(nonce));
83 reinterpret_cast<const uint8_t*>(&nonce),
97 uint32_t newNonce = oldNonce;
98 while (newNonce == oldNonce)
134 size_t interestNameLength = m_name.
size();
136 size_t fullNameLength = dataName.
size() + 1;
140 size_t minSuffixComponents = hasMinSuffixComponents ?
142 if (!(interestNameLength + minSuffixComponents <= fullNameLength))
147 if (hasMaxSuffixComponents &&
152 if (interestNameLength == fullNameLength) {
172 if (interestNameLength == fullNameLength - 1) {
200 if (!publisherPublicKeyLocator.
empty()) {
207 if (publisherPublicKeyLocator.
wireEncode() != *it) {
223 template<encoding::Tag TAG>
227 size_t totalLength = 0;
243 m_selectedDelegationIndex);
245 totalLength += encoder.prependBlock(m_link);
262 totalLength += encoder.prependBlock(m_nonce);
273 totalLength += encoder.prependVarNumber(totalLength);
279 Interest::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder)
const;
282 Interest::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder)
const;
317 BOOST_THROW_EXCEPTION(
Error(
"Unexpected TLV number when decoding Interest"));
343 m_linkCached.reset();
356 BOOST_THROW_EXCEPTION(
Error(
"Interest contains SelectedDelegation, but no LINK object"));
360 m_selectedDelegationIndex =
static_cast<size_t>(selectedDelegation);
363 BOOST_THROW_EXCEPTION(
Error(
"Invalid selected delegation index when decoding Interest"));
382 m_linkCached = make_shared<Link>(m_link);
384 return *m_linkCached;
386 BOOST_THROW_EXCEPTION(
Error(
"There is no encapsulated link object"));
394 BOOST_THROW_EXCEPTION(
Error(
"The given link does not have a wire format"));
397 m_linkCached.reset();
406 m_linkCached.reset();
420 BOOST_THROW_EXCEPTION(
Error(
"There is no encapsulated selected delegation"));
430 m_selectedDelegationIndex = delegationIndex;
433 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Invalid selected delegation name"));
441 if (delegationIndex >=
Link(m_link).getDelegations().size()) {
442 BOOST_THROW_EXCEPTION(
Error(
"Invalid selected delegation index"));
444 m_selectedDelegationIndex = delegationIndex;
485 os << delim <<
"ndn.Nonce=" << interest.
getNonce();
489 os << delim <<
"ndn.Exclude=" << interest.
getExclude();
void wireDecode(const Block &wire)
Decode the input from wire format.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend wire encoding
int getMinSuffixComponents() const
bool hasSelectedDelegation() const
Check whether the Interest includes a selected delegation.
int getMaxSuffixComponents() const
const Name & getName() const
Copyright (c) 2013-2016 Regents of the University of California.
bool matchesName(const Name &name) const
Check if Interest, including selectors, matches the given name.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Helper to prepend TLV block type type containing non-negative integer value.
void setSelectedDelegation(const Name &delegationName)
Set the selected delegation.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
static std::tuple< uint32_t, Name > getDelegationFromWire(const Block &block, size_t index)
gets the delegation at index from block
EncodingImpl< EstimatorTag > EncodingEstimator
element_const_iterator find(uint32_t type) const
void refreshNonce()
Refresh nonce.
std::ostream & operator<<(std::ostream &os, const Data &data)
bool hasSelectors() const
const Block & wireEncode() const
Encode to a wire format.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Class representing a wire element of NDN-TLV packet format.
represents an Interest packet
const time::milliseconds & getInterestLifetime() const
int getChildSelector() const
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
Name getSelectedDelegation() const
Get the name of the selected delegation.
uint32_t getNonce() const
Get Interest's nonce.
const Link & getLink() const
Get the link object for this interest.
const Name & getName() const
Get name of the Data packet.
void unsetSelectedDelegation()
Unset the selected delegation.
element_const_iterator elements_end() const
uint32_t generateWord32()
Generate a non-cryptographically-secure random integer in the range [0, 2^32)
a concept check for TLV abstraction with .wireEncode method
static ssize_t countDelegationsFromWire(const Block &block)
Interest()
Create a new Interest with an empty name (ndn:/)
bool isExcluded(const name::Component &comp) const
Check if name component is excluded.
void setLink(const Block &link)
Set the link object for this interest.
const Selectors & getSelectors() const
represents a Link instance
EncodingImpl< EncoderTag > EncodingBuffer
int getMustBeFresh() const
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block type type with value from a buffer value of size length.
Interest & setNonce(uint32_t nonce)
Set Interest's nonce.
const Exclude & getExclude() const
const Block & get(uint32_t type) const
Get the first subelement of the requested type.
element_container::const_iterator element_const_iterator
size_t size() const
Get the number of components.
void reset()
Reset wire buffer of the element.
Name abstraction to represent an absolute name.
size_t value_size() const
bool matchesData(const Data &data) const
Check if Interest can be satisfied by data.
void unsetLink()
Delete the link object for this interest.
void parse() const
Parse wire buffer into subblocks.
void wireDecode(const Block &wire)
Decode from the wire format.
bool matchesInterest(const Interest &other) const
Check if Interest matches other interest.
const Signature & getSignature() const
bool hasLink() const
Check whether the Interest contains a Link object.
const Block & getInfo() const
Get SignatureInfo in the wire format.
static ssize_t findDelegationFromWire(const Block &block, const Name &delegationName)
finds index of a delegation with delegationName from block
bool hasWire() const
Check if the Block has fully encoded wire.
bool isPrefixOf(const Name &name) const
Check if the N components of this name are the same as the first N components of the given name...
const uint8_t * value() const
const KeyLocator & getPublisherPublicKeyLocator() const
const time::milliseconds DEFAULT_INTEREST_LIFETIME
default value for InterestLifetime
const Name & getFullName() const
Get full name of Data packet, including the implicit digest.
void wireDecode(const Block &wire)
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
const Component & get(ssize_t i) const
Get the component at the given index.
const size_t INVALID_SELECTED_DELEGATION_INDEX
bool isImplicitSha256Digest() const
Check if the component is ImplicitSha256DigestComponent.
A Signature is storage for the signature-related information (info and value) in a Data packet...
bool hasNonce() const
Check if Nonce set.