22 #ifndef NDN_INTEREST_HPP
23 #define NDN_INTEREST_HPP
27 #include "key-locator.hpp"
28 #include "lite/interest-lite.hpp"
29 #include "encoding/wire-format.hpp"
30 #include "util/signed-blob.hpp"
31 #include "util/change-counter.hpp"
32 #include "exclude.hpp"
50 : name_(name), getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
53 interestLifetimeMilliseconds_ = interestLifetimeMilliseconds;
61 : name_(name), getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
67 : name_(interest.name_), minSuffixComponents_(interest.minSuffixComponents_),
68 maxSuffixComponents_(interest.maxSuffixComponents_),
69 keyLocator_(interest.keyLocator_), exclude_(interest.exclude_),
70 childSelector_(interest.childSelector_),
71 mustBeFresh_(interest.mustBeFresh_),
72 interestLifetimeMilliseconds_(interest.interestLifetimeMilliseconds_),
73 nonce_(interest.nonce_), getNonceChangeCount_(0),
74 linkWireEncoding_(interest.linkWireEncoding_),
75 linkWireEncodingFormat_(interest.linkWireEncodingFormat_),
76 selectedDelegationIndex_(interest.selectedDelegationIndex_),
79 if (interest.link_.get())
80 link_.set(ptr_lib::make_shared<Link>(*interest.link_.get()));
82 setDefaultWireEncoding
90 : getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
133 (
const uint8_t *input,
size_t inputLength,
147 wireDecode(&input[0], input.size(), wireFormat);
184 getName() {
return name_.get(); }
187 getName()
const {
return name_.get(); }
190 getMinSuffixComponents()
const {
return minSuffixComponents_; }
193 getMaxSuffixComponents()
const {
return maxSuffixComponents_; }
196 getKeyLocator()
const {
return keyLocator_.get(); }
199 getKeyLocator() {
return keyLocator_.get(); }
202 getExclude() {
return exclude_.get(); }
205 getExclude()
const {
return exclude_.get(); }
208 getChildSelector()
const {
return childSelector_; }
218 getInterestLifetimeMilliseconds()
const {
return interestLifetimeMilliseconds_; }
246 return link_.get() || !linkWireEncoding_.
isNull();
312 minSuffixComponents_ = minSuffixComponents;
326 maxSuffixComponents_ = maxSuffixComponents;
339 childSelector_ = childSelector;
353 mustBeFresh_ = mustBeFresh;
367 interestLifetimeMilliseconds_ = interestLifetimeMilliseconds;
396 keyLocator_ = keyLocator;
433 linkWireEncoding_ = encoding;
434 linkWireEncodingFormat_ = &wireFormat;
437 link_.set(ptr_lib::shared_ptr<Link>());
463 selectedDelegationIndex_ = selectedDelegationIndex;
478 lpPacket_ = lpPacket;
527 const_cast<Interest*
>(
this)->defaultWireEncodingFormat_ = 0;
531 return defaultWireEncoding_;
550 bool changed = name_.checkChanged();
551 changed = keyLocator_.checkChanged() || changed;
552 changed = exclude_.checkChanged() || changed;
553 changed = link_.checkChanged() || changed;
557 ++
const_cast<Interest*
>(
this)->changeCount_;
566 minSuffixComponents_ = -1;
567 maxSuffixComponents_ = -1;
570 interestLifetimeMilliseconds_ = -1.0;
571 linkWireEncodingFormat_ = 0;
572 selectedDelegationIndex_ = -1;
576 setDefaultWireEncoding
577 (
const SignedBlob& defaultWireEncoding,
578 WireFormat *defaultWireEncodingFormat)
580 defaultWireEncoding_ = defaultWireEncoding;
581 defaultWireEncodingFormat_ = defaultWireEncodingFormat;
587 ChangeCounter<Name> name_;
588 int minSuffixComponents_;
589 int maxSuffixComponents_;
590 ChangeCounter<KeyLocator> keyLocator_;
591 ChangeCounter<Exclude> exclude_;
596 uint64_t getNonceChangeCount_;
597 Blob linkWireEncoding_;
598 WireFormat* linkWireEncodingFormat_;
599 SharedPointerChangeCounter<Link> link_;
600 int selectedDelegationIndex_;
601 SignedBlob defaultWireEncoding_;
602 WireFormat *defaultWireEncodingFormat_;
603 uint64_t getDefaultWireEncodingChangeCount_;
604 ptr_lib::shared_ptr<LpPacket> lpPacket_;
605 uint64_t changeCount_;
const SignedBlob & getDefaultWireEncoding() const
Return a reference to the defaultWireEncoding, which was encoded with getDefaultWireEncodingFormat()...
Definition: interest.hpp:521
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:112
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
Interest & setInterestLifetimeMilliseconds(Milliseconds interestLifetimeMilliseconds)
Set the interest lifetime.
Definition: interest.hpp:365
Interest & setKeyLocator(const KeyLocator &keyLocator)
Set this interest to use a copy of the given KeyLocator object.
Definition: interest.hpp:394
void set(const InterestLite &interestLite, WireFormat &wireFormat)
Clear this interest, and set the values by copying from interestLite.
Definition: interest.cpp:90
Blob getLinkWireEncoding(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Get the wire encoding of the link object.
Definition: interest.cpp:317
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object (or a child object) is changed...
Definition: interest.hpp:547
An InterestLite holds a NameLite and other fields for an interest.
Definition: interest-lite.hpp:35
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:310
bool isNull() const
Check if the array pointer is null.
Definition: blob.hpp:172
An Exclude holds a vector of Exclude::Entry.
Definition: exclude.hpp:33
Interest(const Name &name)
Create a new Interest with the given name and "none" for other values.
Definition: interest.hpp:60
uint64_t getIncomingFaceId() const
Get the incoming face ID according to the incoming packet header.
Definition: interest.cpp:59
Interest & setLinkWireEncoding(Blob encoding, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Set the link wire encoding bytes, without decoding them.
Definition: interest.hpp:430
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:49
Interest & unsetLink()
Clear the link wire encoding and link object so that getLink() returns null.
Definition: interest.hpp:448
bool hasLink() const
Check if this interest has a link object (or a link wire encoding which can be decoded to make the li...
Definition: interest.hpp:244
int getSelectedDelegationIndex() const
Get the selected delegation index.
Definition: interest.hpp:280
const Blob & getNonce() const
Return the nonce value from the incoming interest.
Definition: interest.hpp:226
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
void wireDecode(const Blob &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Decode the input using a particular wire format and update this Interest.
Definition: interest.cpp:136
Interest & setChildSelector(int childSelector)
Set the child selector.
Definition: interest.hpp:337
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:42
std::string toUri() const
Encode the name according to the "NDN URI Scheme".
Definition: interest.cpp:171
Interest & setExclude(const Exclude &exclude)
Set this interest to use a copy of the given Exclude object.
Definition: interest.hpp:410
Interest()
Create a new Interest with an empty name and "none" for all values.
Definition: interest.hpp:89
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:145
Interest & setName(const Name &name)
Set the interest name.
Definition: interest.hpp:296
Interest & setMaxSuffixComponents(int maxSuffixComponents)
Set the max suffix components count.
Definition: interest.hpp:324
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:205
A SignedBlob extends Blob to keep the offsets of a signed portion (e.g., the bytes of Data packet)...
Definition: signed-blob.hpp:34
Interest &DEPRECATED_IN_NDN_CPP setNonce(const Blob &nonce)
Definition: interest.hpp:376
Link * getLink()
Get the link object.
Definition: interest.cpp:296
WireFormat * getDefaultWireEncodingFormat() const
Get the WireFormat which is used by getDefaultWireEncoding().
Definition: interest.hpp:540
Definition: key-locator.hpp:35
bool getMustBeFresh() const
Return true if the content must be fresh.
Definition: interest.hpp:215
void refreshNonce()
Update the bytes of the nonce with new random values.
Definition: interest.cpp:330
Interest & setLpPacket(const ptr_lib::shared_ptr< LpPacket > &lpPacket)
An internal library method to set the LpPacket for an incoming packet.
Definition: interest.hpp:476
The Link class extends Data and represents a Link instance where the Data content is an encoded deleg...
Definition: link.hpp:35
Interest & setSelectedDelegationIndex(int selectedDelegationIndex)
Set the selected delegation index.
Definition: interest.hpp:461
SignedBlob wireEncode(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Encode this Interest for a particular wire format.
Definition: interest.cpp:115
bool matchesData(const Data &data, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Check if the given Data packet can satisfy this Interest.
Definition: interest.cpp:226