Represents an Interest packet. More...
#include <ndn-cxx/interest.hpp>
Classes | |
class | Error |
Public Member Functions | |
Interest (const Name &name=Name(), time::milliseconds lifetime=DEFAULT_INTEREST_LIFETIME) | |
Construct an Interest with given name and lifetime . More... | |
Interest (const Block &wire) | |
Construct an Interest by decoding from wire . More... | |
const Block & | getApplicationParameters () const |
bool | getCanBePrefix () const |
Check whether the CanBePrefix element is present. More... | |
int | getChildSelector () const |
uint64_t | getCongestionMark () const |
get the value of the CongestionMark tag More... | |
const Exclude & | getExclude () const |
const DelegationList & | getForwardingHint () const |
time::milliseconds | getInterestLifetime () const |
int | getMaxSuffixComponents () const |
int | getMinSuffixComponents () const |
bool | getMustBeFresh () const |
Check whether the MustBeFresh element is present. More... | |
const Name & | getName () const |
uint32_t | getNonce () const |
Get nonce value. More... | |
const KeyLocator & | getPublisherPublicKeyLocator () const |
const Selectors & | getSelectors () const |
template<typename T > | |
shared_ptr< T > | getTag () const |
get a tag item More... | |
bool | hasApplicationParameters () const |
bool | hasNonce () const |
Check if the Nonce element is present. More... | |
bool | hasSelectors () const |
Check if Interest has any selector present. More... | |
bool | hasWire () const |
Check if this instance has cached wire encoding. More... | |
bool | matchesData (const Data &data) const |
Check if Interest can be satisfied by data . More... | |
bool | matchesInterest (const Interest &other) const |
Check if Interest matches other interest. More... | |
bool | matchesName (const Name &name) const |
Check if Interest, including selectors, matches the given name . More... | |
template<typename Modifier > | |
Interest & | modifyForwardingHint (const Modifier &modifier) |
Modify ForwardingHint in-place. More... | |
void | refreshNonce () |
Change nonce value. More... | |
template<typename T > | |
void | removeTag () const |
remove tag item More... | |
Interest & | setApplicationParameters (const Block ¶meters) |
Set ApplicationParameters from a Block. More... | |
Interest & | setApplicationParameters (const uint8_t *buffer, size_t bufferSize) |
Copy ApplicationParameters from raw buffer. More... | |
Interest & | setApplicationParameters (ConstBufferPtr buffer) |
Set ApplicationParameters from a wire buffer. More... | |
Interest & | setCanBePrefix (bool canBePrefix) |
Add or remove CanBePrefix element. More... | |
Interest & | setChildSelector (int childSelector) |
void | setCongestionMark (uint64_t mark) |
set the CongestionMark tag to the specified value More... | |
Interest & | setExclude (const Exclude &exclude) |
Interest & | setForwardingHint (const DelegationList &value) |
Interest & | setInterestLifetime (time::milliseconds lifetime) |
Set Interest's lifetime. More... | |
Interest & | setMaxSuffixComponents (int maxSuffixComponents) |
Interest & | setMinSuffixComponents (int minSuffixComponents) |
Interest & | setMustBeFresh (bool mustBeFresh) |
Add or remove MustBeFresh element. More... | |
Interest & | setName (const Name &name) |
Interest & | setNonce (uint32_t nonce) |
Set nonce value. More... | |
Interest & | setPublisherPublicKeyLocator (const KeyLocator &keyLocator) |
Interest & | setSelectors (const Selectors &selectors) |
template<typename T > | |
void | setTag (shared_ptr< T > tag) const |
set a tag item More... | |
std::string | toUri () const |
Return a URI-like string that represents the Interest. More... | |
Interest & | unsetApplicationParameters () |
Remove the ApplicationParameters element from this Interest. More... | |
void | wireDecode (const Block &wire) |
Decode from wire in NDN Packet Format v0.2 or v0.3. More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
Prepend wire encoding to encoder . More... | |
const Block & | wireEncode () const |
Encode to a Block . More... | |
Static Public Member Functions | |
static void | setDefaultCanBePrefix (bool canBePrefix) |
Declare the default CanBePrefix setting of the application. More... | |
Friends | |
bool | operator== (const Interest &lhs, const Interest &rhs) |
Represents an Interest packet.
Definition at line 44 of file interest.hpp.
|
explicit |
Construct an Interest with given name
and lifetime
.
std::invalid_argument | lifetime is negative |
Interest::shared_from_this()
, Interest must be created using make_shared
. Otherwise, shared_from_this()
will trigger undefined behavior. Definition at line 50 of file interest.cpp.
|
explicit |
Construct an Interest by decoding from wire
.
Interest::shared_from_this()
, Interest must be created using make_shared
. Otherwise, shared_from_this()
will trigger undefined behavior. Definition at line 64 of file interest.cpp.
|
inline |
Definition at line 297 of file interest.hpp.
|
inline |
Check whether the CanBePrefix element is present.
This is a getter for the CanBePrefix element as defined in NDN Packet Format v0.3. In this implementation, it is mapped to the closest v0.2 semantics: MaxSuffixComponents=1 means CanBePrefix is absent.
Definition at line 174 of file interest.hpp.
|
inline |
Definition at line 430 of file interest.hpp.
|
inherited |
get the value of the CongestionMark tag
Definition at line 28 of file packet-base.cpp.
|
inline |
Definition at line 414 of file interest.hpp.
|
inline |
Definition at line 223 of file interest.hpp.
|
inline |
Definition at line 279 of file interest.hpp.
|
inline |
Definition at line 382 of file interest.hpp.
|
inline |
Definition at line 366 of file interest.hpp.
|
inline |
Check whether the MustBeFresh element is present.
This is a getter for the MustBeFresh element as defined in NDN Packet Format v0.3. In this implementation, it is mapped to the closest v0.2 semantics and appears as MustBeFresh element under Selectors.
Definition at line 202 of file interest.hpp.
|
inline |
Definition at line 134 of file interest.hpp.
uint32_t ndn::Interest::getNonce | ( | ) | const |
Get nonce value.
If nonce was not present, it is added and assigned a random value.
Definition at line 549 of file interest.cpp.
|
inline |
Definition at line 398 of file interest.hpp.
|
inline |
Definition at line 350 of file interest.hpp.
|
inherited |
get a tag item
T | type of the tag, which must be a subclass of ndn::Tag |
nullptr | if no Tag of type T is stored |
Definition at line 66 of file tag-host.hpp.
|
inline |
Definition at line 291 of file interest.hpp.
|
inline |
Check if the Nonce element is present.
Definition at line 253 of file interest.hpp.
|
inline |
Check if Interest has any selector present.
Definition at line 343 of file interest.hpp.
|
inline |
Check if this instance has cached wire encoding.
Definition at line 90 of file interest.hpp.
bool ndn::Interest::matchesData | ( | const Data & | data | ) | const |
Check if Interest can be satisfied by data
.
This method considers Name, MinSuffixComponents, MaxSuffixComponents, PublisherPublicKeyLocator, and Exclude. This method does not consider ChildSelector and MustBeFresh.
Definition at line 457 of file interest.cpp.
bool ndn::Interest::matchesInterest | ( | const Interest & | other | ) | const |
Check if Interest matches other
interest.
Interest matches other
if both have the same name, selectors, and link. Other fields (e.g., Nonce) may be different.
Definition at line 539 of file interest.cpp.
bool ndn::Interest::matchesName | ( | const Name & | name | ) | const |
Check if Interest, including selectors, matches the given name
.
name | The name to be matched. If this is a Data name, it shall contain the implicit digest component |
Definition at line 430 of file interest.cpp.
|
inline |
Modify ForwardingHint in-place.
Modifier | a unary function that accepts DelegationList& |
This is equivalent to, but more efficient (avoids copying) than:
Definition at line 243 of file interest.hpp.
void ndn::Interest::refreshNonce | ( | ) |
Change nonce value.
If the Nonce element is present, the new nonce value will differ from the old value. If the Nonce element is not present, this method does nothing.
Definition at line 566 of file interest.cpp.
|
inherited |
remove tag item
Definition at line 93 of file tag-host.hpp.
Set ApplicationParameters from a Block.
If the block is default-constructed, this will set a zero-length ApplicationParameters element. Else, if the block's TLV-TYPE is ApplicationParameters, it will be used directly as this Interest's ApplicationParameters element. Else, the block will be nested into an ApplicationParameters element.
Definition at line 599 of file interest.cpp.
Interest & ndn::Interest::setApplicationParameters | ( | const uint8_t * | buffer, |
size_t | bufferSize | ||
) |
Copy ApplicationParameters from raw buffer.
buffer | pointer to the first octet of parameters |
bufferSize | size of the raw buffer |
Definition at line 615 of file interest.cpp.
Interest & ndn::Interest::setApplicationParameters | ( | ConstBufferPtr | buffer | ) |
Set ApplicationParameters from a wire buffer.
buffer | buffer containing the parameters, must not be nullptr |
Definition at line 626 of file interest.cpp.
|
inline |
Add or remove CanBePrefix element.
canBePrefix | whether CanBePrefix element should be present. |
This is a setter for the CanBePrefix element as defined in NDN Packet Format v0.3. In this implementation, it is mapped to the closest v0.2 semantics: MaxSuffixComponents=1 means CanBePrefix is absent.
Definition at line 187 of file interest.hpp.
|
inline |
Definition at line 437 of file interest.hpp.
|
inherited |
set the CongestionMark tag to the specified value
Definition at line 41 of file packet-base.cpp.
|
inlinestatic |
Declare the default CanBePrefix setting of the application.
As part of transitioning to NDN Packet Format v0.3, the default setting for CanBePrefix will be changed from "true" to "false". Application developers are advised to review all Interests expressed by their application and decide what CanBePrefix setting is appropriate for each Interest, to avoid breaking changes when the transition occurs. Application may either set CanBePrefix on a per-Interest basis, or declare a default CanBePrefix setting for all Interests expressed by the application using this function. If an application neither declares a default nor sets CanBePrefix on every Interest, Interest::wireEncode will print a one-time warning message.
Definition at line 162 of file interest.hpp.
Definition at line 421 of file interest.hpp.
Interest & ndn::Interest::setForwardingHint | ( | const DelegationList & | value | ) |
Definition at line 591 of file interest.cpp.
Interest & ndn::Interest::setInterestLifetime | ( | time::milliseconds | lifetime | ) |
Set Interest's lifetime.
std::invalid_argument | lifetime is negative |
Definition at line 580 of file interest.cpp.
|
inline |
Definition at line 389 of file interest.hpp.
|
inline |
Definition at line 373 of file interest.hpp.
|
inline |
Add or remove MustBeFresh element.
mustBeFresh | whether MustBeFresh element should be present. |
This is a setter for the MustBeFresh element as defined in NDN Packet Format v0.3. In this implementation, it is mapped to the closest v0.2 semantics and appears as MustBeFresh element under Selectors.
Definition at line 215 of file interest.hpp.
Definition at line 140 of file interest.hpp.
Interest & ndn::Interest::setNonce | ( | uint32_t | nonce | ) |
Set nonce value.
Definition at line 558 of file interest.cpp.
|
inline |
Definition at line 405 of file interest.hpp.
Definition at line 357 of file interest.hpp.
|
inherited |
set a tag item
T | type of the tag, which must be a subclass of ndn::Tag |
Definition at line 79 of file tag-host.hpp.
std::string ndn::Interest::toUri | ( | ) | const |
Interest & ndn::Interest::unsetApplicationParameters | ( | ) |
Remove the ApplicationParameters element from this Interest.
Definition at line 637 of file interest.cpp.
void ndn::Interest::wireDecode | ( | const Block & | wire | ) |
Decode from wire
in NDN Packet Format v0.2 or v0.3.
Definition at line 231 of file interest.cpp.
size_t ndn::Interest::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Prepend wire encoding to encoder
.
Definition at line 90 of file interest.cpp.
const Block & ndn::Interest::wireEncode | ( | ) | const |
Encode to a Block
.
Encodes into NDN Packet Format v0.3 if ApplicationParameters element is present, in which case Selectors are not encoded. Otherwise, encodes into NDN Packet Format v0.2.
Definition at line 215 of file interest.cpp.
Definition at line 647 of file interest.cpp.