22 #ifndef NDN_INTEREST_HPP
23 #define NDN_INTEREST_HPP
26 #include "publisher-public-key-digest.hpp"
27 #include "key-locator.hpp"
28 #include "c/interest-types.h"
29 #include "encoding/wire-format.hpp"
30 #include "util/signed-blob.hpp"
31 #include "util/change-counter.hpp"
32 #include "exclude.hpp"
50 DEPRECATED_IN_NDN_CPP
Interest(
const Name& name,
int minSuffixComponents,
int maxSuffixComponents,
59 DEPRECATED_IN_NDN_CPP
Interest(
const Name& name,
int minSuffixComponents,
int maxSuffixComponents,
67 DEPRECATED_IN_NDN_CPP
Interest(
const Name& name,
int minSuffixComponents,
int maxSuffixComponents,
68 const KeyLocator& keyLocator,
const Exclude& exclude,
int childSelector,
int answerOriginKind,
77 : name_(name), getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
80 interestLifetimeMilliseconds_ = interestLifetimeMilliseconds;
88 : name_(name), getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
94 : name_(interest.name_), minSuffixComponents_(interest.minSuffixComponents_),
95 maxSuffixComponents_(interest.maxSuffixComponents_),
96 publisherPublicKeyDigest_(interest.publisherPublicKeyDigest_),
97 keyLocator_(interest.keyLocator_), exclude_(interest.exclude_),
98 childSelector_(interest.childSelector_),
99 answerOriginKind_(interest.answerOriginKind_),
100 scope_(interest.scope_),
101 interestLifetimeMilliseconds_(interest.interestLifetimeMilliseconds_),
102 nonce_(interest.nonce_), getNonceChangeCount_(0), changeCount_(0)
104 setDefaultWireEncoding
105 (interest.defaultWireEncoding_, interest.defaultWireEncodingFormat_);
112 : getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
117 Interest& operator=(
const Interest& interest);
155 (
const uint8_t *input,
size_t inputLength,
169 wireDecode(&input[0], input.size(), wireFormat);
192 getName() {
return name_.get(); }
195 getName()
const {
return name_.get(); }
198 getMinSuffixComponents()
const {
return minSuffixComponents_; }
201 getMaxSuffixComponents()
const {
return maxSuffixComponents_; }
207 PublisherPublicKeyDigest&
218 getKeyLocator()
const {
return keyLocator_.get(); }
221 getKeyLocator() {
return keyLocator_.get(); }
224 getExclude() {
return exclude_.get(); }
227 getExclude()
const {
return exclude_.get(); }
230 getChildSelector()
const {
return childSelector_; }
246 if (answerOriginKind_ < 0)
249 return (answerOriginKind_ & ndn_Interest_ANSWER_STALE) == 0;
253 getScope()
const {
return scope_; }
256 getInterestLifetimeMilliseconds()
const {
return interestLifetimeMilliseconds_; }
269 const_cast<Interest*
>(
this)->nonce_ =
Blob();
270 const_cast<Interest*
>(
this)->getNonceChangeCount_ =
getChangeCount();
353 if (answerOriginKind_ < 0) {
357 answerOriginKind_ = ndn_Interest_ANSWER_STALE;
364 answerOriginKind_ &= ~ndn_Interest_ANSWER_STALE;
367 answerOriginKind_ |= ndn_Interest_ANSWER_STALE;
424 keyLocator_ = keyLocator;
464 const_cast<Interest*
>(
this)->defaultWireEncoding_ =
SignedBlob();
465 const_cast<Interest*
>(
this)->defaultWireEncodingFormat_ = 0;
466 const_cast<Interest*
>(
this)->getDefaultWireEncodingChangeCount_ =
getChangeCount();
469 return defaultWireEncoding_;
488 bool changed = name_.checkChanged();
489 changed = publisherPublicKeyDigest_.checkChanged() || changed;
490 changed = keyLocator_.checkChanged() || changed;
491 changed = exclude_.checkChanged() || changed;
495 ++
const_cast<Interest*
>(
this)->changeCount_;
504 minSuffixComponents_ = -1;
505 maxSuffixComponents_ = -1;
507 answerOriginKind_ = -1;
509 interestLifetimeMilliseconds_ = -1.0;
513 setDefaultWireEncoding
514 (
const SignedBlob& defaultWireEncoding,
515 WireFormat *defaultWireEncodingFormat)
517 defaultWireEncoding_ = defaultWireEncoding;
518 defaultWireEncodingFormat_ = defaultWireEncodingFormat;
524 ChangeCounter<Name> name_;
525 int minSuffixComponents_;
526 int maxSuffixComponents_;
529 ChangeCounter<PublisherPublicKeyDigest> publisherPublicKeyDigest_;
530 ChangeCounter<KeyLocator> keyLocator_;
531 ChangeCounter<Exclude> exclude_;
533 int answerOriginKind_;
537 uint64_t getNonceChangeCount_;
538 SignedBlob defaultWireEncoding_;
539 WireFormat *defaultWireEncodingFormat_;
540 uint64_t getDefaultWireEncodingChangeCount_;
541 uint64_t changeCount_;
const SignedBlob & getDefaultWireEncoding() const
Return a reference to the defaultWireEncoding, which was encoded with getDefaultWireEncodingFormat()...
Definition: interest.hpp:459
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:111
Copyright (C) 2013-2015 Regents of the University of California.
Definition: common.hpp:35
Interest & setInterestLifetimeMilliseconds(Milliseconds interestLifetimeMilliseconds)
Set the interest lifetime.
Definition: interest.hpp:393
Interest & setScope(int scope)
Set the interest scope.
Definition: interest.hpp:379
Interest & setKeyLocator(const KeyLocator &keyLocator)
Set this interest to use a copy of the given KeyLocator object.
Definition: interest.hpp:422
int childSelector
-1 for none
Definition: interest-types.h:79
PublisherPublicKeyDigest &DEPRECATED_IN_NDN_CPP getPublisherPublicKeyDigest()
Definition: interest.hpp:208
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object (or a child object) is changed...
Definition: interest.hpp:485
struct ndn_Blob nonce
The blob whose value is a pointer to a pre-allocated buffer.
Definition: interest-types.h:83
A PublisherPublicKeyDigest holds the publisher public key digest value, if any.
Definition: publisher-public-key-digest.hpp:37
ndn_Milliseconds interestLifetimeMilliseconds
-1.0 for none
Definition: interest-types.h:82
Interest & setMustBeFresh(bool mustBeFresh)
Set the MustBeFresh flag.
Definition: interest.hpp:351
Interest & setMinSuffixComponents(int minSuffixComponents)
Set the min suffix components count.
Definition: interest.hpp:304
An Exclude holds a vector of Exclude::Entry.
Definition: exclude.hpp:36
Interest(const Name &name)
Create a new Interest with the given name and "none" for other values.
Definition: interest.hpp:87
Interest(const Name &name, Milliseconds interestLifetimeMilliseconds)
Create a new Interest with the given name and interest lifetime and "none" for other values...
Definition: interest.hpp:76
An ndn_Interest holds an ndn_Name and other fields for an interest.
Definition: interest-types.h:70
int scope
-1 for none
Definition: interest-types.h:81
const Blob & getNonce() const
Return the nonce value from the incoming interest.
Definition: interest.hpp:264
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:42
int minSuffixComponents
-1 for none
Definition: interest-types.h:72
void wireDecode(const Blob &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Decode the input using a particular wire format and update this Interest.
Definition: interest.cpp:149
Interest & setChildSelector(int childSelector)
Set the child selector.
Definition: interest.hpp:331
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
An Interest holds a Name and other fields for an interest.
Definition: interest.hpp:41
std::string toUri() const
Encode the name according to the "NDN URI Scheme".
Definition: interest.cpp:184
Interest & setExclude(const Exclude &exclude)
Set this interest to use a copy of the given Exclude object.
Definition: interest.hpp:438
Interest()
Create a new Interest with an empty name and "none" for all values.
Definition: interest.hpp:111
int DEPRECATED_IN_NDN_CPP getAnswerOriginKind() const
Definition: interest.cpp:246
const PublisherPublicKeyDigest &DEPRECATED_IN_NDN_CPP getPublisherPublicKeyDigest() const
Definition: interest.hpp:215
void wireDecode(const std::vector< uint8_t > &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Decode the input using a particular wire format and update this Interest.
Definition: interest.hpp:167
Interest & setName(const Name &name)
Set the interest name.
Definition: interest.hpp:290
Interest & setMaxSuffixComponents(int maxSuffixComponents)
Set the max suffix components count.
Definition: interest.hpp:318
Interest &DEPRECATED_IN_NDN_CPP setAnswerOriginKind(int answerOriginKind)
Definition: interest.cpp:256
bool matchesName(const Name &name) const
Check if this Interest's name matches the given name (using Name::match) and the given name also conf...
Definition: interest.cpp:225
A SignedBlob extends Blob to keep the offsets of a signed portion (e.g., the bytes of Data packet)...
Definition: signed-blob.hpp:34
int maxSuffixComponents
-1 for none
Definition: interest-types.h:73
Interest &DEPRECATED_IN_NDN_CPP setNonce(const Blob &nonce)
Definition: interest.hpp:404
WireFormat * getDefaultWireEncodingFormat() const
Get the WireFormat which is used by getDefaultWireEncoding().
Definition: interest.hpp:478
Definition: key-locator.hpp:36
bool getMustBeFresh() const
Return true if the content must be fresh.
Definition: interest.hpp:243
void set(const struct ndn_Interest &interestStruct)
Clear this interest, and set the values by copying from the interest struct.
Definition: interest.cpp:91
SignedBlob wireEncode(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Encode this Interest for a particular wire format.
Definition: interest.cpp:128