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"
33 #include "delegation-set.hpp"
51 : name_(name), getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
54 interestLifetimeMilliseconds_ = interestLifetimeMilliseconds;
62 : name_(name), getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
68 : name_(interest.name_), minSuffixComponents_(interest.minSuffixComponents_),
69 maxSuffixComponents_(interest.maxSuffixComponents_),
70 keyLocator_(interest.keyLocator_), exclude_(interest.exclude_),
71 childSelector_(interest.childSelector_),
72 mustBeFresh_(interest.mustBeFresh_),
73 interestLifetimeMilliseconds_(interest.interestLifetimeMilliseconds_),
74 nonce_(interest.nonce_), getNonceChangeCount_(0),
75 forwardingHint_(interest.forwardingHint_),
76 linkWireEncoding_(interest.linkWireEncoding_),
77 linkWireEncodingFormat_(interest.linkWireEncodingFormat_),
78 selectedDelegationIndex_(interest.selectedDelegationIndex_),
81 if (interest.link_.get())
82 link_.set(ptr_lib::make_shared<Link>(*interest.link_.get()));
84 setDefaultWireEncoding
92 : getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
135 (
const uint8_t *input,
size_t inputLength,
149 wireDecode(&input[0], input.size(), wireFormat);
186 getName() {
return name_.get(); }
189 getName()
const {
return name_.get(); }
192 getMinSuffixComponents()
const {
return minSuffixComponents_; }
195 getMaxSuffixComponents()
const {
return maxSuffixComponents_; }
206 return maxSuffixComponents_ != 1;
210 getKeyLocator()
const {
return keyLocator_.get(); }
213 getKeyLocator() {
return keyLocator_.get(); }
216 getExclude() {
return exclude_.get(); }
219 getExclude()
const {
return exclude_.get(); }
222 getChildSelector()
const {
return childSelector_; }
232 getInterestLifetimeMilliseconds()
const {
return interestLifetimeMilliseconds_; }
272 return link_.get() || !linkWireEncoding_.
isNull();
284 DEPRECATED_IN_NDN_CPP
getLink();
341 minSuffixComponents_ = minSuffixComponents;
355 maxSuffixComponents_ = maxSuffixComponents;
371 maxSuffixComponents_ = (canBePrefix ? -1 : 1);
384 childSelector_ = childSelector;
398 mustBeFresh_ = mustBeFresh;
412 interestLifetimeMilliseconds_ = interestLifetimeMilliseconds;
441 keyLocator_ = keyLocator;
475 forwardingHint_ = forwardingHint;
497 linkWireEncoding_ = encoding;
498 linkWireEncodingFormat_ = &wireFormat;
501 link_.set(ptr_lib::shared_ptr<Link>());
529 selectedDelegationIndex_ = selectedDelegationIndex;
544 lpPacket_ = lpPacket;
593 const_cast<Interest*
>(
this)->defaultWireEncodingFormat_ = 0;
597 return defaultWireEncoding_;
616 bool changed = name_.checkChanged();
617 changed = keyLocator_.checkChanged() || changed;
618 changed = exclude_.checkChanged() || changed;
619 changed = forwardingHint_.checkChanged() || changed;
620 changed = link_.checkChanged() || changed;
624 ++
const_cast<Interest*
>(
this)->changeCount_;
633 minSuffixComponents_ = -1;
634 maxSuffixComponents_ = -1;
637 interestLifetimeMilliseconds_ = -1.0;
638 linkWireEncodingFormat_ = 0;
639 selectedDelegationIndex_ = -1;
643 setDefaultWireEncoding
644 (
const SignedBlob& defaultWireEncoding,
645 WireFormat *defaultWireEncodingFormat)
647 defaultWireEncoding_ = defaultWireEncoding;
648 defaultWireEncodingFormat_ = defaultWireEncodingFormat;
654 ChangeCounter<Name> name_;
655 int minSuffixComponents_;
656 int maxSuffixComponents_;
657 ChangeCounter<KeyLocator> keyLocator_;
658 ChangeCounter<Exclude> exclude_;
663 uint64_t getNonceChangeCount_;
664 ChangeCounter<DelegationSet> forwardingHint_;
665 Blob linkWireEncoding_;
666 WireFormat* linkWireEncodingFormat_;
667 SharedPointerChangeCounter<Link> link_;
668 int selectedDelegationIndex_;
669 SignedBlob defaultWireEncoding_;
670 WireFormat *defaultWireEncodingFormat_;
671 uint64_t getDefaultWireEncodingChangeCount_;
672 ptr_lib::shared_ptr<LpPacket> lpPacket_;
673 uint64_t changeCount_;
const SignedBlob & getDefaultWireEncoding() const
Return a reference to the defaultWireEncoding, which was encoded with getDefaultWireEncodingFormat()...
Definition: interest.hpp:587
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:114
Interest & setCanBePrefix(int canBePrefix)
Set the CanBePrefix flag.
Definition: interest.hpp:367
DelegationSet & getForwardingHint()
Get the forwarding hint object which you can modify to add or remove forwarding hints.
Definition: interest.hpp:258
Interest & setInterestLifetimeMilliseconds(Milliseconds interestLifetimeMilliseconds)
Set the interest lifetime.
Definition: interest.hpp:410
Interest & setKeyLocator(const KeyLocator &keyLocator)
Set this interest to use a copy of the given KeyLocator object.
Definition: interest.hpp:439
void set(const InterestLite &interestLite, WireFormat &wireFormat)
Clear this interest, and set the values by copying from interestLite.
Definition: interest.cpp:100
Blob DEPRECATED_IN_NDN_CPP getLinkWireEncoding(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Get the wire encoding of the link object.
Definition: interest.cpp:338
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object (or a child object) is changed...
Definition: interest.hpp:613
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:396
Interest & setMinSuffixComponents(int minSuffixComponents)
Set the min suffix components count.
Definition: interest.hpp:339
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:61
uint64_t getIncomingFaceId() const
Get the incoming face ID according to the incoming packet header.
Definition: interest.cpp:62
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:50
int DEPRECATED_IN_NDN_CPP getSelectedDelegationIndex() const
Get the selected delegation index.
Definition: interest.hpp:309
const Blob & getNonce() const
Return the nonce value from the incoming interest.
Definition: interest.hpp:240
Interest & setForwardingHint(const DelegationSet &forwardingHint)
Set this interest to use a copy of the given DelegationSet object as the forwarding hint...
Definition: interest.hpp:473
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:157
Interest & setChildSelector(int childSelector)
Set the child selector.
Definition: interest.hpp:382
A DelegationSet holds a list of DelegationSet::Delegation entries which is used as the content of a L...
Definition: delegation-set.hpp:38
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
An Interest holds a Name and other fields for an interest.
Definition: interest.hpp:43
std::string toUri() const
Encode the name according to the "NDN URI Scheme".
Definition: interest.cpp:192
Interest & setExclude(const Exclude &exclude)
Set this interest to use a copy of the given Exclude object.
Definition: interest.hpp:455
Interest()
Create a new Interest with an empty name and "none" for all values.
Definition: interest.hpp:91
Interest &DEPRECATED_IN_NDN_CPP unsetLink()
Clear the link wire encoding and link object so that getLink() returns null.
Definition: interest.hpp:513
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:147
bool getCanBePrefix() const
Get the CanBePrefix flag.
Definition: interest.hpp:202
Interest &DEPRECATED_IN_NDN_CPP setLinkWireEncoding(Blob encoding, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Set the link wire encoding bytes, without decoding them.
Definition: interest.hpp:494
Interest & setName(const Name &name)
Set the interest name.
Definition: interest.hpp:325
Interest &DEPRECATED_IN_NDN_CPP setSelectedDelegationIndex(int selectedDelegationIndex)
Set the selected delegation index.
Definition: interest.hpp:527
Interest & setMaxSuffixComponents(int maxSuffixComponents)
Set the max suffix components count.
Definition: interest.hpp:353
bool DEPRECATED_IN_NDN_CPP 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:270
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:226
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:421
Link *DEPRECATED_IN_NDN_CPP getLink()
Get the link object.
Definition: interest.cpp:317
WireFormat * getDefaultWireEncodingFormat() const
Get the WireFormat which is used by getDefaultWireEncoding().
Definition: interest.hpp:606
Definition: key-locator.hpp:35
bool getMustBeFresh() const
Return true if the content must be fresh.
Definition: interest.hpp:229
void refreshNonce()
Update the bytes of the nonce with new random values.
Definition: interest.cpp:351
Interest & setLpPacket(const ptr_lib::shared_ptr< LpPacket > &lpPacket)
An internal library method to set the LpPacket for an incoming packet.
Definition: interest.hpp:542
The Link class extends Data and represents a Link instance where the Data content is an encoded deleg...
Definition: link.hpp:35
SignedBlob wireEncode(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Encode this Interest for a particular wire format.
Definition: interest.cpp:136
bool matchesData(const Data &data, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Check if the given Data packet can satisfy this Interest.
Definition: interest.cpp:247