22 #ifndef NDN_CXX_INTEREST_HPP 23 #define NDN_CXX_INTEREST_HPP 34 #include <boost/endian/conversion.hpp> 57 class Nonce final :
public std::array<uint8_t, 4>
59 using Base = std::array<uint8_t, 4>;
67 boost::endian::native_to_big_inplace(n);
68 std::memcpy(data(), &n,
sizeof(n));
71 Nonce(uint8_t n1, uint8_t n2, uint8_t n3, uint8_t n4) noexcept
86 return static_cast<const Base&
>(lhs) == static_cast<const Base&>(rhs);
92 return static_cast<const Base&
>(lhs) != static_cast<const Base&>(rhs);
122 template<encoding::Tag TAG>
141 return m_wire.hasWire();
188 return m_canBePrefix;
197 m_canBePrefix = canBePrefix;
207 return m_mustBeFresh;
216 m_mustBeFresh = mustBeFresh;
224 return m_forwardingHint;
235 return m_nonce.has_value();
263 return m_interestLifetime;
291 return !m_parameters.empty();
304 if (m_parameters.empty())
307 return m_parameters.front();
350 [[deprecated(
"use the overload that takes a span<>")]]
387 optional<SignatureInfo>
422 return s_autoCheckParametersDigest;
428 s_autoCheckParametersDigest = b;
443 setApplicationParametersInternal(
Block parameters);
446 computeParametersDigest()
const;
456 addOrReplaceParametersDigestComponent();
465 findParametersDigestComponent(
const Name& name);
467 std::vector<Block>::const_iterator
468 findFirstParameter(uint32_t type)
const;
471 static bool s_autoCheckParametersDigest;
474 std::vector<Name> m_forwardingHint;
475 mutable optional<Nonce> m_nonce;
477 optional<uint8_t> m_hopLimit;
478 bool m_canBePrefix =
false;
479 bool m_mustBeFresh =
false;
487 std::vector<Block> m_parameters;
489 mutable Block m_wire;
499 #endif // NDN_CXX_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.
Copyright (c) 2011-2015 Regents of the University of California.
static bool getAutoCheckParametersDigest()
Represents a SignatureInfo or InterestSignatureInfo TLV element.
Interest & setMustBeFresh(bool mustBeFresh)
Add or remove MustBeFresh element.
span< const Name > getForwardingHint() const noexcept
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)
bool hasApplicationParameters() const noexcept
Return whether this Interest has any ApplicationParameters.
bool matchesInterest(const Interest &other) const
Check if this Interest matches other.
InputBuffers extractSignedRanges() const
Extract ranges of Interest covered by the signature in Packet Specification v0.3. ...
Represents a TLV element of the NDN packet format.
Represents an Interest packet.
Nonce(uint32_t n) noexcept
Interest & setNonce(optional< Nonce > nonce)
Set the Interest's nonce.
optional< SignatureInfo > getSignatureInfo() const
Get the InterestSignatureInfo.
Interest & setSignatureValue(ConstBufferPtr value)
Set the InterestSignatureValue.
#define NDN_CXX_NODISCARD
base class to allow simple management of packet tags
Interest & setForwardingHint(std::vector< Name > value)
Nonce getNonce() const
Get nonce value.
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
Represents an absolute name.
static void setAutoCheckParametersDigest(bool b)
void wireDecode(const Block &wire)
Decode from wire.
Interest & setHopLimit(optional< uint8_t > hopLimit)
Set the Interest's hop limit.
Block getSignatureValue() const
Get the InterestSignatureValue.
Interest & setSignatureInfo(const SignatureInfo &info)
Set the InterestSignatureInfo.
bool hasWire() const noexcept
Check if this instance has cached wire encoding.
const Name & getName() const noexcept
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
void printHex(std::ostream &os, uint64_t num, bool wantUpperCase)
Output the hex representation of num to the output stream os.
friend bool operator!=(const Nonce &lhs, const Nonce &rhs) noexcept
Interest(const Name &name={}, time::milliseconds lifetime=DEFAULT_INTEREST_LIFETIME)
Construct an Interest with given name and lifetime.
Interest & unsetApplicationParameters()
Remove the ApplicationParameters element from this Interest.
Represents a Data packet.
Interest & setApplicationParameters(const Block &block)
Set ApplicationParameters from a Block.
Error(const char *expectedType, uint32_t actualType)
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Interest)
represents an error in TLV encoding or decoding
friend bool operator==(const Nonce &lhs, const Nonce &rhs) noexcept
bool isSigned() const noexcept
Return whether the Interest is signed.
Interest & setCanBePrefix(bool canBePrefix)
Add or remove CanBePrefix element.
Nonce(uint8_t n1, uint8_t n2, uint8_t n3, uint8_t n4) noexcept
shared_ptr< const Buffer > ConstBufferPtr
boost::chrono::milliseconds milliseconds
Interest & setName(const Name &name)
Set the Interest's name.
Block getApplicationParameters() const
Get the ApplicationParameters.