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) {
215 template<encoding::Tag TAG>
219 size_t totalLength = 0;
235 m_selectedDelegationIndex);
237 totalLength += encoder.prependBlock(m_link);
254 totalLength += encoder.prependBlock(m_nonce);
265 totalLength += encoder.prependVarNumber(totalLength);
309 BOOST_THROW_EXCEPTION(
Error(
"Unexpected TLV number when decoding Interest"));
335 m_linkCached.reset();
348 BOOST_THROW_EXCEPTION(
Error(
"Interest contains SelectedDelegation, but no LINK object"));
352 m_selectedDelegationIndex =
static_cast<size_t>(selectedDelegation);
355 BOOST_THROW_EXCEPTION(
Error(
"Invalid selected delegation index when decoding Interest"));
374 m_linkCached = make_shared<Link>(m_link);
376 return *m_linkCached;
378 BOOST_THROW_EXCEPTION(
Error(
"There is no encapsulated link object"));
386 BOOST_THROW_EXCEPTION(
Error(
"The given link does not have a wire format"));
389 m_linkCached.reset();
398 m_linkCached.reset();
412 BOOST_THROW_EXCEPTION(
Error(
"There is no encapsulated selected delegation"));
422 m_selectedDelegationIndex = delegationIndex;
425 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Invalid selected delegation name"));
433 if (delegationIndex >=
Link(m_link).getDelegations().size()) {
434 BOOST_THROW_EXCEPTION(
Error(
"Invalid selected delegation index"));
436 m_selectedDelegationIndex = delegationIndex;
477 os << delim <<
"ndn.Nonce=" << interest.
getNonce();
481 os << delim <<
"ndn.Exclude=" << interest.
getExclude();
void wireDecode(const Block &wire)
Decode the input from wire format.
const Block & wireEncode() const
Encode to a wire format.
bool hasWire() const
Check if the Block has fully encoded wire.
Copyright (c) 2011-2015 Regents of the University of California.
int getChildSelector() const
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Helper to prepend TLV block type type containing non-negative integer value.
const Selectors & getSelectors() const
void setSelectedDelegation(const Name &delegationName)
Set the selected delegation.
const Link & getLink() const
Get the link object for this interest.
int getMustBeFresh() const
const Component & get(ssize_t i) const
Get the component at the given index.
static std::tuple< uint32_t, Name > getDelegationFromWire(const Block &block, size_t index)
gets the delegation at index from block
EncodingImpl< EstimatorTag > EncodingEstimator
void refreshNonce()
Refresh nonce.
size_t value_size() const
const Name & getName() const
Get name of the Data packet.
std::ostream & operator<<(std::ostream &os, const Data &data)
element_const_iterator elements_end() const
bool matchesName(const Name &name) const
Check if Interest, including selectors, matches the given name.
void parse() const
Parse wire buffer into subblocks.
Class representing a wire element of NDN-TLV packet format.
represents an Interest packet
const uint8_t * value() const
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
bool hasNonce() const
Check if Nonce set.
void unsetSelectedDelegation()
Unset the selected delegation.
int getMaxSuffixComponents() const
uint32_t generateWord32()
Generate a non-cryptographically-secure random integer in the range [0, 2^32)
Name getSelectedDelegation() const
Get the name of the selected delegation.
a concept check for TLV abstraction with .wireEncode method
static ssize_t countDelegationsFromWire(const Block &block)
const time::milliseconds & getInterestLifetime() const
Interest()
Create a new Interest with an empty name (ndn:/)
const KeyLocator & getPublisherPublicKeyLocator() const
void setLink(const Block &link)
Set the link object for this interest.
const Block & get(uint32_t type) const
Get the first subelement of the requested type.
represents a Link instance
EncodingImpl< EncoderTag > EncodingBuffer
element_const_iterator find(uint32_t type) 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.
uint32_t getNonce() const
Get Interest's nonce.
const Block & getInfo() const
Get SignatureInfo in the wire format.
Interest & setNonce(uint32_t nonce)
Set Interest's nonce.
bool matchesData(const Data &data) const
Check if Interest can be satisfied by data.
element_container::const_iterator element_const_iterator
bool isImplicitSha256Digest() const
Check if the component is ImplicitSha256DigestComponent.
void reset()
Reset wire buffer of the element.
Name abstraction to represent an absolute name.
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 Exclude & getExclude() const
void unsetLink()
Delete the link object for this interest.
const Name & getFullName() const
Get full name of Data packet, including the implicit digest.
size_t size() const
Get the number of components.
void wireDecode(const Block &wire)
Decode from the wire format.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend wire encoding
int getMinSuffixComponents() const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
static ssize_t findDelegationFromWire(const Block &block, const Name &delegationName)
finds index of a delegation with delegationName from block
bool hasLink() const
Check whether the Interest contains a Link object.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
const time::milliseconds DEFAULT_INTEREST_LIFETIME
default value for InterestLifetime
bool isExcluded(const name::Component &comp) const
Check if name component is excluded.
const Signature & getSignature() const
bool hasSelectedDelegation() const
Check whether the Interest includes a selected delegation.
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 size_t INVALID_SELECTED_DELEGATION_INDEX
bool hasSelectors() const
const Name & getName() const
A Signature is storage for the signature-related information (info and value) in a Data packet...