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"
49 : name_(name), getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
52 interestLifetimeMilliseconds_ = interestLifetimeMilliseconds;
60 : name_(name), getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
66 : name_(interest.name_), minSuffixComponents_(interest.minSuffixComponents_),
67 maxSuffixComponents_(interest.maxSuffixComponents_),
68 keyLocator_(interest.keyLocator_), exclude_(interest.exclude_),
69 childSelector_(interest.childSelector_),
70 mustBeFresh_(interest.mustBeFresh_),
71 interestLifetimeMilliseconds_(interest.interestLifetimeMilliseconds_),
72 nonce_(interest.nonce_), getNonceChangeCount_(0),
73 linkWireEncoding_(interest.linkWireEncoding_),
74 linkWireEncodingFormat_(interest.linkWireEncodingFormat_),
75 selectedDelegationIndex_(interest.selectedDelegationIndex_),
78 if (interest.link_.get())
79 link_.set(ptr_lib::make_shared<Link>(*interest.link_.get()));
81 setDefaultWireEncoding
89 : getNonceChangeCount_(0), changeCount_(0), getDefaultWireEncodingChangeCount_(0)
132 (
const uint8_t *input,
size_t inputLength,
146 wireDecode(&input[0], input.size(), wireFormat);
183 getName() {
return name_.get(); }
186 getName()
const {
return name_.get(); }
189 getMinSuffixComponents()
const {
return minSuffixComponents_; }
192 getMaxSuffixComponents()
const {
return maxSuffixComponents_; }
195 getKeyLocator()
const {
return keyLocator_.get(); }
198 getKeyLocator() {
return keyLocator_.get(); }
201 getExclude() {
return exclude_.get(); }
204 getExclude()
const {
return exclude_.get(); }
207 getChildSelector()
const {
return childSelector_; }
217 getInterestLifetimeMilliseconds()
const {
return interestLifetimeMilliseconds_; }
245 return link_.get() || !linkWireEncoding_.
isNull();
311 minSuffixComponents_ = minSuffixComponents;
325 maxSuffixComponents_ = maxSuffixComponents;
338 childSelector_ = childSelector;
352 mustBeFresh_ = mustBeFresh;
366 interestLifetimeMilliseconds_ = interestLifetimeMilliseconds;
395 keyLocator_ = keyLocator;
432 linkWireEncoding_ = encoding;
433 linkWireEncodingFormat_ = &wireFormat;
436 link_.set(ptr_lib::shared_ptr<Link>());
462 selectedDelegationIndex_ = selectedDelegationIndex;
477 lpPacket_ = lpPacket;
510 const_cast<Interest*
>(
this)->defaultWireEncodingFormat_ = 0;
514 return defaultWireEncoding_;
533 bool changed = name_.checkChanged();
534 changed = keyLocator_.checkChanged() || changed;
535 changed = exclude_.checkChanged() || changed;
536 changed = link_.checkChanged() || changed;
540 ++
const_cast<Interest*
>(
this)->changeCount_;
549 minSuffixComponents_ = -1;
550 maxSuffixComponents_ = -1;
553 interestLifetimeMilliseconds_ = -1.0;
554 linkWireEncodingFormat_ = 0;
555 selectedDelegationIndex_ = -1;
559 setDefaultWireEncoding
560 (
const SignedBlob& defaultWireEncoding,
561 WireFormat *defaultWireEncodingFormat)
563 defaultWireEncoding_ = defaultWireEncoding;
564 defaultWireEncodingFormat_ = defaultWireEncodingFormat;
570 ChangeCounter<Name> name_;
571 int minSuffixComponents_;
572 int maxSuffixComponents_;
573 ChangeCounter<KeyLocator> keyLocator_;
574 ChangeCounter<Exclude> exclude_;
579 uint64_t getNonceChangeCount_;
580 Blob linkWireEncoding_;
581 WireFormat* linkWireEncodingFormat_;
582 SharedPointerChangeCounter<Link> link_;
583 int selectedDelegationIndex_;
584 SignedBlob defaultWireEncoding_;
585 WireFormat *defaultWireEncodingFormat_;
586 uint64_t getDefaultWireEncodingChangeCount_;
587 ptr_lib::shared_ptr<LpPacket> lpPacket_;
588 uint64_t changeCount_;
const SignedBlob & getDefaultWireEncoding() const
Return a reference to the defaultWireEncoding, which was encoded with getDefaultWireEncodingFormat()...
Definition: interest.hpp:504
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:111
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
Interest & setInterestLifetimeMilliseconds(Milliseconds interestLifetimeMilliseconds)
Set the interest lifetime.
Definition: interest.hpp:364
Interest & setKeyLocator(const KeyLocator &keyLocator)
Set this interest to use a copy of the given KeyLocator object.
Definition: interest.hpp:393
void set(const InterestLite &interestLite, WireFormat &wireFormat)
Clear this interest, and set the values by copying from interestLite.
Definition: interest.cpp:89
Blob getLinkWireEncoding(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Get the wire encoding of the link object.
Definition: interest.cpp:246
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object (or a child object) is changed...
Definition: interest.hpp:530
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:350
Interest & setMinSuffixComponents(int minSuffixComponents)
Set the min suffix components count.
Definition: interest.hpp:309
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:59
uint64_t getIncomingFaceId() const
Get the incoming face ID according to the incoming packet header.
Definition: interest.cpp:58
Interest & setLinkWireEncoding(Blob encoding, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Set the link wire encoding bytes, without decoding them.
Definition: interest.hpp:429
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:48
Interest & unsetLink()
Clear the link wire encoding and link object so that getLink() returns null.
Definition: interest.hpp:447
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:243
int getSelectedDelegationIndex() const
Get the selected delegation index.
Definition: interest.hpp:279
const Blob & getNonce() const
Return the nonce value from the incoming interest.
Definition: interest.hpp:225
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:135
Interest & setChildSelector(int childSelector)
Set the child selector.
Definition: interest.hpp:336
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:170
Interest & setExclude(const Exclude &exclude)
Set this interest to use a copy of the given Exclude object.
Definition: interest.hpp:409
Interest()
Create a new Interest with an empty name and "none" for all values.
Definition: interest.hpp:88
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:144
Interest & setName(const Name &name)
Set the interest name.
Definition: interest.hpp:295
Interest & setMaxSuffixComponents(int maxSuffixComponents)
Set the max suffix components count.
Definition: interest.hpp:323
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:204
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:375
Link * getLink()
Get the link object.
Definition: interest.cpp:225
WireFormat * getDefaultWireEncodingFormat() const
Get the WireFormat which is used by getDefaultWireEncoding().
Definition: interest.hpp:523
Definition: key-locator.hpp:35
bool getMustBeFresh() const
Return true if the content must be fresh.
Definition: interest.hpp:214
void refreshNonce()
Update the bytes of the nonce with new random values.
Definition: interest.cpp:259
Interest & setLpPacket(const ptr_lib::shared_ptr< LpPacket > &lpPacket)
An internal library method to set the LpPacket for an incoming packet.
Definition: interest.hpp:475
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:460
SignedBlob wireEncode(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Encode this Interest for a particular wire format.
Definition: interest.cpp:114