22 #ifndef NDN_INTEREST_HPP 23 #define NDN_INTEREST_HPP 30 #include <boost/logic/tribool.hpp> 59 Interest(
const Name& name =
Name(), time::milliseconds lifetime = DEFAULT_INTEREST_LIFETIME);
71 template<encoding::Tag TAG>
90 return m_wire.hasWire();
149 s_defaultCanBePrefix = canBePrefix;
157 return m_canBePrefix;
166 m_canBePrefix = canBePrefix;
168 m_isCanBePrefixSet =
true;
177 return m_mustBeFresh;
186 m_mustBeFresh = mustBeFresh;
194 return m_forwardingHint;
210 template<
typename Modifier>
214 modifier(m_forwardingHint);
224 return m_nonce.has_value();
250 return m_interestLifetime;
275 return !m_parameters.empty();
281 if (m_parameters.empty())
284 return m_parameters.front();
338 return s_autoCheckParametersDigest;
344 s_autoCheckParametersDigest = b;
359 setApplicationParametersInternal(
Block parameters);
362 computeParametersDigest()
const;
372 addOrReplaceParametersDigestComponent();
381 findParametersDigestComponent(
const Name& name);
383 #ifdef NDN_CXX_HAVE_TESTS 386 static bool s_errorIfCanBePrefixUnset;
387 #endif // NDN_CXX_HAVE_TESTS 390 static boost::logic::tribool s_defaultCanBePrefix;
391 static bool s_autoCheckParametersDigest;
395 mutable optional<uint32_t> m_nonce;
396 time::milliseconds m_interestLifetime;
397 optional<uint8_t> m_hopLimit;
398 mutable bool m_isCanBePrefixSet =
false;
399 bool m_canBePrefix =
true;
400 bool m_mustBeFresh =
false;
408 std::vector<Block> m_parameters;
410 mutable Block m_wire;
420 #endif // NDN_INTEREST_HPP bool isParametersDigestValid() const
Check if the ParametersSha256DigestComponent in the name is valid.
bool getMustBeFresh() const noexcept
Check whether the MustBeFresh element is present.
const Block & wireEncode() const
Encode into a Block according to NDN Packet Format v0.3.
static bool getAutoCheckParametersDigest()
Interest & modifyForwardingHint(const Modifier &modifier)
Modify ForwardingHint in-place.
Interest & setMustBeFresh(bool mustBeFresh)
Add or remove MustBeFresh element.
std::string toUri() const
Return a URI-like string that represents the Interest.
void refreshNonce()
Change nonce value.
bool getCanBePrefix() const noexcept
Check whether the CanBePrefix element is present.
std::ostream & operator<<(std::ostream &os, const Data &data)
Interest(const Name &name=Name(), time::milliseconds lifetime=DEFAULT_INTEREST_LIFETIME)
Construct an Interest with given name and lifetime.
bool hasApplicationParameters() const noexcept
bool matchesInterest(const Interest &other) const
Check if this Interest matches other.
Interest & setApplicationParameters(const Block ¶meters)
Set ApplicationParameters from a Block.
Represents a TLV element of NDN packet format.
Represents an Interest packet.
#define NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
const DelegationList & getForwardingHint() const noexcept
uint32_t getNonce() const
Get nonce value.
#define NDN_CXX_NODISCARD
Interest & setNonce(uint32_t nonce)
Set nonce value.
base class to allow simple management of packet tags
bool matchesData(const Data &data) const
Check if Interest can be satisfied by data.
bool hasNonce() const noexcept
Check if the Nonce element is present.
optional< uint8_t > getHopLimit() const noexcept
static void setDefaultCanBePrefix(bool canBePrefix)
Declare the default CanBePrefix setting of the application.
Represents an absolute name.
static void setAutoCheckParametersDigest(bool b)
bool hasWire() const
Check if this instance has cached wire encoding.
void wireDecode(const Block &wire)
Decode from wire according to NDN Packet Format v0.3.
Interest & setHopLimit(optional< uint8_t > hopLimit)
Set the Interest's hop limit.
const Name & getName() const noexcept
represents a list of Delegations
Interest & setForwardingHint(const DelegationList &value)
Interest & setInterestLifetime(time::milliseconds lifetime)
Set the Interest's lifetime.
const time::milliseconds DEFAULT_INTEREST_LIFETIME
default value for InterestLifetime
time::milliseconds getInterestLifetime() const noexcept
Interest & unsetApplicationParameters()
Remove the ApplicationParameters element from this Interest.
Represents a Data packet.
Error(const char *expectedType, uint32_t actualType)
represents an error in TLV encoding or decoding
Interest & setCanBePrefix(bool canBePrefix)
Add or remove CanBePrefix element.
shared_ptr< const Buffer > ConstBufferPtr
Interest & setName(const Name &name)
Set the Interest's name.
Block getApplicationParameters() const