Represents an Interest packet. More...
#include <ndn-cxx/interest.hpp>
Classes | |
class | Error |
class | Nonce |
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... | |
InputBuffers | extractSignedRanges () const |
Extract ranges of Interest covered by the signature in Packet Specification v0.3. More... | |
Block | getApplicationParameters () const |
Get the ApplicationParameters. More... | |
bool | getCanBePrefix () const noexcept |
Check whether the CanBePrefix element is present. More... | |
uint64_t | getCongestionMark () const |
get the value of the CongestionMark tag More... | |
const DelegationList & | getForwardingHint () const noexcept |
optional< uint8_t > | getHopLimit () const noexcept |
time::milliseconds | getInterestLifetime () const noexcept |
bool | getMustBeFresh () const noexcept |
Check whether the MustBeFresh element is present. More... | |
const Name & | getName () const noexcept |
Nonce | getNonce () const |
Get nonce value. More... | |
optional< SignatureInfo > | getSignatureInfo () const |
Get the InterestSignatureInfo. More... | |
Block | getSignatureValue () const |
Get the InterestSignatureValue. More... | |
template<typename T > | |
shared_ptr< T > | getTag () const |
get a tag item More... | |
bool | hasApplicationParameters () const noexcept |
Return whether this Interest has any ApplicationParameters. More... | |
bool | hasNonce () const noexcept |
Check if the Nonce element is present. More... | |
bool | hasWire () const noexcept |
Check if this instance has cached wire encoding. More... | |
bool | isParametersDigestValid () const |
Check if the ParametersSha256DigestComponent in the name is valid. More... | |
bool | isSigned () const noexcept |
Return whether the Interest is signed. More... | |
bool | matchesData (const Data &data) const |
Check if Interest can be satisfied by data . More... | |
bool | matchesInterest (const Interest &other) const |
Check if this Interest matches other . 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 &block) |
Set ApplicationParameters from a Block. More... | |
Interest & | setApplicationParameters (const uint8_t *value, size_t length) |
Set ApplicationParameters by copying from a raw buffer. More... | |
Interest & | setApplicationParameters (ConstBufferPtr value) |
Set ApplicationParameters from a shared buffer. More... | |
Interest & | setCanBePrefix (bool canBePrefix) |
Add or remove CanBePrefix element. More... | |
void | setCongestionMark (uint64_t mark) |
set the CongestionMark tag to the specified value More... | |
Interest & | setForwardingHint (const DelegationList &value) |
Interest & | setHopLimit (optional< uint8_t > hopLimit) |
Set the Interest's hop limit. More... | |
Interest & | setInterestLifetime (time::milliseconds lifetime) |
Set the Interest's lifetime. More... | |
Interest & | setMustBeFresh (bool mustBeFresh) |
Add or remove MustBeFresh element. More... | |
Interest & | setName (const Name &name) |
Set the Interest's name. More... | |
Interest & | setNonce (optional< Nonce > nonce) |
Set the Interest's nonce. More... | |
Interest & | setSignatureInfo (const SignatureInfo &info) |
Set the InterestSignatureInfo. More... | |
Interest & | setSignatureValue (ConstBufferPtr value) |
Set the InterestSignatureValue. More... | |
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 . More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
Prepend wire encoding to encoder . More... | |
const Block & | wireEncode () const |
Encode into a Block. More... | |
Static Public Member Functions | |
static bool | getAutoCheckParametersDigest () |
static void | setAutoCheckParametersDigest (bool b) |
static void | setDefaultCanBePrefix (bool canBePrefix) |
Declare the default CanBePrefix setting of the application. More... | |
Represents an Interest packet.
Definition at line 50 of file interest.hpp.
|
explicit |
Construct an Interest with given name
and lifetime
.
std::invalid_argument | name is invalid or 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 54 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.
InputBuffers ndn::Interest::extractSignedRanges | ( | ) | const |
Extract ranges of Interest covered by the signature in Packet Specification v0.3.
Definition at line 640 of file interest.cpp.
|
inline |
Get the ApplicationParameters.
If the element is not present, an invalid Block will be returned.
Definition at line 344 of file interest.hpp.
|
inlinestatic |
Definition at line 448 of file interest.hpp.
|
inlinenoexcept |
Check whether the CanBePrefix element is present.
Definition at line 208 of file interest.hpp.
|
inherited |
get the value of the CongestionMark tag
Definition at line 28 of file packet-base.cpp.
|
inlinenoexcept |
Definition at line 245 of file interest.hpp.
|
inlinenoexcept |
Definition at line 315 of file interest.hpp.
|
inlinenoexcept |
Definition at line 303 of file interest.hpp.
|
inlinenoexcept |
Check whether the MustBeFresh element is present.
Definition at line 228 of file interest.hpp.
|
inlinenoexcept |
Definition at line 174 of file interest.hpp.
Interest::Nonce ndn::Interest::getNonce | ( | ) | const |
Get nonce value.
If nonce was not present, it is added and assigned a random value.
Definition at line 410 of file interest.cpp.
optional< SignatureInfo > ndn::Interest::getSignatureInfo | ( | ) | const |
Get the InterestSignatureInfo.
nullopt | InterestSignatureInfo is not present |
Definition at line 546 of file interest.cpp.
Block ndn::Interest::getSignatureValue | ( | ) | const |
Get the InterestSignatureValue.
If the element is not present, an invalid Block will be returned.
Definition at line 590 of file interest.cpp.
|
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.
|
inlinenoexcept |
Return whether this Interest has any ApplicationParameters.
Definition at line 331 of file interest.hpp.
|
inlinenoexcept |
Check if the Nonce element is present.
Definition at line 275 of file interest.hpp.
|
inlinenoexcept |
Check if this instance has cached wire encoding.
Definition at line 141 of file interest.hpp.
bool ndn::Interest::isParametersDigestValid | ( | ) | const |
Check if the ParametersSha256DigestComponent in the name is valid.
Returns true if there is a single ParametersSha256DigestComponent in the name and the digest value is correct, or if there is no ParametersSha256DigestComponent in the name and the Interest does not contain any parameters. Returns false otherwise.
Definition at line 674 of file interest.cpp.
|
noexcept |
Return whether the Interest is signed.
Definition at line 536 of file interest.cpp.
bool ndn::Interest::matchesData | ( | const Data & | data | ) | const |
Check if Interest can be satisfied by data
.
This method considers Name, CanBePrefix, and MustBeFresh. However, MustBeFresh processing is limited to rejecting Data with zero/omitted FreshnessPeriod.
Definition at line 333 of file interest.cpp.
bool ndn::Interest::matchesInterest | ( | const Interest & | other | ) | const |
Check if this Interest matches other
.
Two Interests match if both have the same Name, CanBePrefix, and MustBeFresh.
Definition at line 365 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 265 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 430 of file interest.cpp.
|
inherited |
remove tag item
Definition at line 93 of file tag-host.hpp.
Set ApplicationParameters from a Block.
block | TLV block to be used as ApplicationParameters; must be valid |
If the block's TLV-TYPE is tlv::ApplicationParameters, it will be used directly as this Interest's ApplicationParameters element. Otherwise, the block will be nested into an ApplicationParameters element.
This function will also recompute the value of the ParametersSha256DigestComponent in the Interest's name. If the name does not contain a ParametersSha256DigestComponent, one will be appended to it.
Definition at line 480 of file interest.cpp.
Interest & ndn::Interest::setApplicationParameters | ( | const uint8_t * | value, |
size_t | length | ||
) |
Set ApplicationParameters by copying from a raw buffer.
value | points to a buffer from which the TLV-VALUE of the parameters will be copied; may be nullptr if length is zero |
length | size of the buffer |
This function will also recompute the value of the ParametersSha256DigestComponent in the Interest's name. If the name does not contain a ParametersSha256DigestComponent, one will be appended to it.
Definition at line 498 of file interest.cpp.
Interest & ndn::Interest::setApplicationParameters | ( | ConstBufferPtr | value | ) |
Set ApplicationParameters from a shared buffer.
value | buffer containing the TLV-VALUE of the parameters; must not be nullptr |
This function will also recompute the value of the ParametersSha256DigestComponent in the Interest's name. If the name does not contain a ParametersSha256DigestComponent, one will be appended to it.
Definition at line 511 of file interest.cpp.
|
inlinestatic |
Definition at line 454 of file interest.hpp.
|
inline |
Add or remove CanBePrefix element.
canBePrefix | whether CanBePrefix element should be present. |
Definition at line 217 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 200 of file interest.hpp.
Interest & ndn::Interest::setForwardingHint | ( | const DelegationList & | value | ) |
Definition at line 393 of file interest.cpp.
Interest & ndn::Interest::setHopLimit | ( | optional< uint8_t > | hopLimit | ) |
Set the Interest's hop limit.
Use setHopLimit(nullopt)
to remove any hop limit from the Interest.
Definition at line 457 of file interest.cpp.
Interest & ndn::Interest::setInterestLifetime | ( | time::milliseconds | lifetime | ) |
Set the Interest's lifetime.
std::invalid_argument | lifetime is negative |
Definition at line 443 of file interest.cpp.
|
inline |
Add or remove MustBeFresh element.
mustBeFresh | whether MustBeFresh element should be present. |
Definition at line 237 of file interest.hpp.
Set the Interest's name.
std::invalid_argument | name is invalid |
Definition at line 375 of file interest.cpp.
Set the Interest's nonce.
Use setNonce(nullopt)
to remove any nonce from the Interest.
Definition at line 420 of file interest.cpp.
Interest & ndn::Interest::setSignatureInfo | ( | const SignatureInfo & | info | ) |
Set the InterestSignatureInfo.
Definition at line 556 of file interest.cpp.
Interest & ndn::Interest::setSignatureValue | ( | ConstBufferPtr | value | ) |
Set the InterestSignatureValue.
value | Buffer containing the TLV-VALUE of the InterestSignatureValue; must not be nullptr |
Error | InterestSignatureInfo is unset |
InterestSignatureInfo must be set before setting InterestSignatureValue
Definition at line 600 of file interest.cpp.
|
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 |
Return a URI-like string that represents the Interest.
The string always starts with getName().toUri()
. After the name, if any of the Interest's CanBePrefix, MustBeFresh, Nonce, InterestLifetime, or HopLimit fields are present, their textual representation is appended as a query string. Example: "/test/name?MustBeFresh&Nonce=123456"
Definition at line 323 of file interest.cpp.
Interest & ndn::Interest::unsetApplicationParameters | ( | ) |
Remove the ApplicationParameters element from this Interest.
This function will also remove any InterestSignatureInfo and InterestSignatureValue elements in the Interest, as well as any ParametersSha256DigestComponents in the Interest's name.
Definition at line 524 of file interest.cpp.
void ndn::Interest::wireDecode | ( | const Block & | wire | ) |
Decode from wire
.
Definition at line 187 of file interest.cpp.
size_t ndn::Interest::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Prepend wire encoding to encoder
.
Definition at line 89 of file interest.cpp.
const Block & ndn::Interest::wireEncode | ( | ) | const |
Encode into a Block.
Definition at line 171 of file interest.cpp.