31 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Interest>));
32 BOOST_CONCEPT_ASSERT((WireEncodable<Interest>));
33 BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<Interest>));
34 BOOST_CONCEPT_ASSERT((WireDecodable<Interest>));
35 static_assert(std::is_base_of<tlv::Error, Interest::Error>::value,
36 "Interest::Error must inherit from tlv::Error");
40 , m_interestLifetime(interestLifetime)
42 if (interestLifetime < time::milliseconds::zero()) {
43 BOOST_THROW_EXCEPTION(std::invalid_argument(
"InterestLifetime must be >= 0"));
54 template<encoding::Tag TAG>
58 size_t totalLength = 0;
70 if (m_forwardingHint.
size() > 0) {
71 totalLength += m_forwardingHint.
wireEncode(encoder);
83 totalLength += encoder.prependByteArray(reinterpret_cast<uint8_t*>(&nonce),
sizeof(nonce));
84 totalLength += encoder.prependVarNumber(
sizeof(nonce));
85 totalLength += encoder.prependVarNumber(
tlv::Nonce);
95 totalLength += encoder.prependVarNumber(totalLength);
125 BOOST_THROW_EXCEPTION(
Error(
"Unexpected TLV number when decoding Interest"));
141 BOOST_THROW_EXCEPTION(
Error(
"Nonce element is missing"));
144 if (val->value_size() !=
sizeof(nonce)) {
145 BOOST_THROW_EXCEPTION(
Error(
"Nonce element is malformed"));
147 std::memcpy(&nonce, val->value(),
sizeof(nonce));
172 std::ostringstream os;
209 size_t interestNameLength = m_name.
size();
211 size_t fullNameLength = dataName.
size() + 1;
215 size_t minSuffixComponents = hasMinSuffixComponents ?
217 if (!(interestNameLength + minSuffixComponents <= fullNameLength))
222 if (hasMaxSuffixComponents &&
227 if (interestNameLength == fullNameLength) {
247 if (interestNameLength == fullNameLength - 1) {
275 if (!publisherPublicKeyLocator.
empty()) {
282 if (publisherPublicKeyLocator.
wireEncode() != *it) {
324 uint32_t newNonce = oldNonce;
325 while (newNonce == oldNonce)
334 if (interestLifetime < time::milliseconds::zero()) {
335 BOOST_THROW_EXCEPTION(std::invalid_argument(
"InterestLifetime must be >= 0"));
337 m_interestLifetime = interestLifetime;
345 m_forwardingHint = value;
381 os << delim <<
"ndn.Nonce=" << interest.
getNonce();
385 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
int getMaxSuffixComponents() const
const Name & getName() const
Copyright (c) 2013-2017 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)
Prepend a TLV element containing a non-negative integer.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
element_const_iterator find(uint32_t type) const
Find the first sub element of specified TLV-TYPE.
void refreshNonce()
Refresh nonce.
std::ostream & operator<<(std::ostream &os, const Data &data)
element_container::const_iterator element_const_iterator
bool hasSelectors() const
const Signature & getSignature() const
Get Signature.
const int DEFAULT_CHILD_SELECTOR
const Block & wireEncode() const
Encode to a wire format.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Represents a TLV element of NDN packet format.
represents an Interest packet
std::string toUri() const
Encode the name according to the NDN URI Scheme.
int getChildSelector() const
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
uint32_t getNonce() const
Get nonce.
uint32_t generateWord32()
Generate a non-cryptographically-secure random integer in the range [0, 2^32)
Interest(const Name &name=Name(), time::milliseconds interestLifetime=DEFAULT_INTEREST_LIFETIME)
Create a new Interest with the given name and interest lifetime.
bool isExcluded(const name::Component &comp) const
Check if name component is excluded.
void wireDecode(const Block &block, bool wantSort=true)
decode a DelegationList
const Selectors & getSelectors() const
int getMustBeFresh() const
Interest & setNonce(uint32_t nonce)
Set nonce.
const Exclude & getExclude() const
const Block & get(uint32_t type) const
Get the first sub element of specified TLV-TYPE.
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
size_t size() const
Get number of components.
size_t size() const noexcept
void reset()
Reset wire buffer of the element.
Represents an absolute name.
bool isPrefixOf(const Name &other) const
Check if this name is a prefix of another name.
bool matchesData(const Data &data) const
Check if Interest can be satisfied by data.
void parse() const
Parse TLV-VALUE into sub elements.
uint32_t type() const
Get TLV-TYPE.
void wireDecode(const Block &wire)
Decode from the wire format.
bool matchesInterest(const Interest &other) const
Check if Interest matches other interest.
const Name & getName() const
Get name.
Interest & setInterestLifetime(time::milliseconds interestLifetime)
Set Interest's lifetime.
const Block & getInfo() const
Get SignatureInfo as wire format.
bool hasWire() const
Check if the Block has fully encoded wire.
represents a list of Delegations
Interest & setForwardingHint(const DelegationList &value)
const KeyLocator & getPublisherPublicKeyLocator() const
const time::milliseconds DEFAULT_INTEREST_LIFETIME
default value for InterestLifetime
element_const_iterator elements_end() const
Equivalent to elements().end()
time::milliseconds getInterestLifetime() const
const Name & getFullName() const
Get full name including implicit digest.
void wireDecode(const Block &wire)
Decode name from wire encoding.
Represents a Data packet.
const Component & get(ssize_t i) const
Get the component at the given index.
EncodingImpl< EncoderTag > EncodingBuffer
size_t wireEncode(EncodingImpl< TAG > &encoder, uint32_t type=tlv::ForwardingHint) const
encode into wire format
EncodingImpl< EstimatorTag > EncodingEstimator
bool isImplicitSha256Digest() const
Check if the component is ImplicitSha256DigestComponent.
Holds SignatureInfo and SignatureValue in a Data packet.
bool hasNonce() const
Check if Nonce set.