Represents an Interest packet. More...
#include <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... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
Prepend wire encoding to encoder in NDN Packet Format v0.2. More... | |
const Block & | wireEncode () const |
Encode to a Block . More... | |
void | wireDecode (const Block &wire) |
Decode from wire in NDN Packet Format v0.2 or v0.3. More... | |
bool | hasWire () const |
Check if this instance has cached wire encoding. More... | |
std::string | toUri () const |
Return a URI-like string that represents the Interest. More... | |
bool | matchesName (const Name &name) const |
Check if Interest, including selectors, matches the given name . 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... | |
const Name & | getName () const |
Interest & | setName (const Name &name) |
bool | getCanBePrefix () const |
Check whether the CanBePrefix element is present. More... | |
Interest & | setCanBePrefix (bool canBePrefix) |
Add or remove CanBePrefix element. More... | |
bool | getMustBeFresh () const |
Check whether the MustBeFresh element is present. More... | |
Interest & | setMustBeFresh (bool mustBeFresh) |
Add or remove MustBeFresh element. More... | |
const DelegationList & | getForwardingHint () const |
Interest & | setForwardingHint (const DelegationList &value) |
template<typename Modifier > | |
Interest & | modifyForwardingHint (const Modifier &modifier) |
Modify ForwardingHint in-place. More... | |
bool | hasNonce () const |
Check if the Nonce element is present. More... | |
uint32_t | getNonce () const |
Get nonce value. More... | |
Interest & | setNonce (uint32_t nonce) |
Set nonce value. More... | |
void | refreshNonce () |
Change nonce value. More... | |
time::milliseconds | getInterestLifetime () const |
Interest & | setInterestLifetime (time::milliseconds lifetime) |
Set Interest's lifetime. More... | |
NDN_CXX_DEPRECATED bool | hasSelectors () const |
Check if Interest has any selector present. More... | |
NDN_CXX_DEPRECATED const Selectors & | getSelectors () const |
NDN_CXX_DEPRECATED Interest & | setSelectors (const Selectors &selectors) |
NDN_CXX_DEPRECATED int | getMinSuffixComponents () const |
NDN_CXX_DEPRECATED Interest & | setMinSuffixComponents (int minSuffixComponents) |
NDN_CXX_DEPRECATED int | getMaxSuffixComponents () const |
NDN_CXX_DEPRECATED Interest & | setMaxSuffixComponents (int maxSuffixComponents) |
NDN_CXX_DEPRECATED const KeyLocator & | getPublisherPublicKeyLocator () const |
NDN_CXX_DEPRECATED Interest & | setPublisherPublicKeyLocator (const KeyLocator &keyLocator) |
NDN_CXX_DEPRECATED const Exclude & | getExclude () const |
NDN_CXX_DEPRECATED Interest & | setExclude (const Exclude &exclude) |
NDN_CXX_DEPRECATED int | getChildSelector () const |
NDN_CXX_DEPRECATED Interest & | setChildSelector (int childSelector) |
![]() | |
uint64_t | getCongestionMark () const |
get the value of the CongestionMark tag More... | |
void | setCongestionMark (uint64_t mark) |
set the CongestionMark tag to the specified value More... | |
![]() | |
template<typename T > | |
shared_ptr< T > | getTag () const |
get a tag item More... | |
template<typename T > | |
void | setTag (shared_ptr< T > tag) const |
set a tag item More... | |
template<typename T > | |
void | removeTag () const |
remove tag item More... | |
Represents an Interest packet.
Definition at line 42 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 38 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 47 of file interest.cpp.
References wireDecode().
size_t ndn::Interest::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Prepend wire encoding to encoder
in NDN Packet Format v0.2.
Definition at line 56 of file interest.cpp.
References ndn::DEFAULT_INTEREST_LIFETIME, getInterestLifetime(), getName(), getNonce(), getSelectors(), hasSelectors(), ndn::tlv::Interest, ndn::tlv::InterestLifetime, ndn::tlv::Nonce, ndn::encoding::prependNonNegativeIntegerBlock(), ndn::DelegationList::size(), ndn::Selectors::wireEncode(), ndn::DelegationList::wireEncode(), and ndn::Name::wireEncode().
Referenced by ns3::ndn::L3RateTracer::InNack(), ndn::operator==(), ns3::ndn::L3RateTracer::OutNack(), and ndn::util::DummyClientFace::receive().
const Block & ndn::Interest::wireEncode | ( | ) | const |
Encode to a Block
.
Normally, this function encodes to NDN Packet Format v0.2. However, if this instance has cached wire encoding (hasWire()
is true), the cached encoding is returned and it might be in v0.3 format.
Definition at line 103 of file interest.cpp.
References ndn::Block::hasWire(), and wireDecode().
void ndn::Interest::wireDecode | ( | const Block & | wire | ) |
Decode from wire
in NDN Packet Format v0.2 or v0.3.
Definition at line 119 of file interest.cpp.
References getNonce(), hasNonce(), ndn::tlv::Interest, ndn::Block::parse(), setNonce(), ndn::to_string(), and ndn::Block::type().
Referenced by Interest(), and wireEncode().
|
inline |
Check if this instance has cached wire encoding.
Definition at line 93 of file interest.hpp.
References ndn::Block::hasWire().
Referenced by ns3::ndn::L3RateTracer::InNack(), and ns3::ndn::L3RateTracer::OutNack().
std::string ndn::Interest::toUri | ( | ) | const |
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 324 of file interest.cpp.
References ndn::Exclude::empty(), getExclude(), getMaxSuffixComponents(), getMinSuffixComponents(), ndn::Exclude::isExcluded(), ndn::Name::isPrefixOf(), and ndn::Name::size().
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 351 of file interest.cpp.
References ndn::Block::elements_end(), ndn::KeyLocator::empty(), ndn::Exclude::empty(), ndn::Block::find(), ndn::Name::get(), getExclude(), ndn::Data::getFullName(), ndn::Signature::getInfo(), getMaxSuffixComponents(), getMinSuffixComponents(), ndn::Data::getName(), getPublisherPublicKeyLocator(), ndn::Data::getSignature(), ndn::Exclude::isExcluded(), ndn::name::Component::isImplicitSha256Digest(), ndn::Name::isPrefixOf(), ndn::tlv::KeyLocator, ndn::Name::size(), and ndn::KeyLocator::wireEncode().
Referenced by nfd::cs::Entry::canSatisfy(), ndn::security::v2::CertificateCache::find(), ndn::security::v2::TrustAnchorContainer::find(), and ndn::InMemoryStorage::selectChild().
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 435 of file interest.cpp.
References getName(), and getSelectors().
Referenced by face::Face::Impl::nackPendingInterests().
|
inline |
Definition at line 137 of file interest.hpp.
Referenced by nfd::pit::Entry::canMatch(), ndn::security::v2::ValidationPolicySimpleHierarchy::checkPolicy(), ndn::security::v2::validator_config::ValidationPolicyConfig::checkPolicy(), nfd::ManagerBase::extractRequester(), nfd::cs::Cs::find(), ndn::security::v2::CertificateCache::find(), ndn::security::v2::TrustAnchorContainer::find(), ndn::InMemoryStorage::find(), ndn::security::v2::getKeyLocatorName(), nfd::fw::asf::AsfMeasurements::getOrCreateNamespaceInfo(), nfd::CommandAuthenticator::makeAuthorization(), matchesInterest(), nfd::fw::Strategy::onDroppedInterest(), ndn::operator<<(), ndn::security::parse(), ndn::InMemoryStorage::selectChild(), ndn::mgmt::StatusDatasetContext::setPrefix(), ndn::security::v2::KeyChain::sign(), ndn::mgmt::StatusDatasetContext::StatusDatasetContext(), wireEncode(), and nfd::fw::wouldViolateScope().
Definition at line 143 of file interest.hpp.
References ndn::Block::reset().
Referenced by ndn::security::v2::KeyChain::sign().
|
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 157 of file interest.hpp.
References ndn::Selectors::getMaxSuffixComponents().
|
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 170 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setMaxSuffixComponents().
|
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 184 of file interest.hpp.
References ndn::Selectors::getMustBeFresh().
Referenced by nfd::cs::Entry::canSatisfy(), ndn::operator<<(), and ndn::InMemoryStorage::selectChild().
|
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 197 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setMustBeFresh().
|
inline |
Definition at line 205 of file interest.hpp.
Referenced by nfd::fw::Strategy::lookupFib().
Interest & ndn::Interest::setForwardingHint | ( | const DelegationList & | value | ) |
Definition at line 487 of file interest.cpp.
References ndn::Block::reset().
|
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 225 of file interest.hpp.
References ndn::Block::reset().
|
inline |
Check if the Nonce element is present.
Definition at line 235 of file interest.hpp.
Referenced by ndn::operator<<(), refreshNonce(), and wireDecode().
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 445 of file interest.cpp.
References ndn::random::generateWord32().
Referenced by ndn::operator<<(), refreshNonce(), nfd::pit::OutRecord::setIncomingNack(), nfd::pit::FaceRecord::update(), wireDecode(), and wireEncode().
Interest & ndn::Interest::setNonce | ( | uint32_t | nonce | ) |
Set nonce value.
Definition at line 454 of file interest.cpp.
References ndn::Block::reset().
Referenced by refreshNonce(), and wireDecode().
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 462 of file interest.cpp.
References ndn::random::generateWord32(), getNonce(), hasNonce(), and setNonce().
Referenced by ndn::security::v2::CertificateFetcherDirectFetch::doFetch().
|
inline |
Definition at line 261 of file interest.hpp.
Referenced by ndn::operator<<(), nfd::pit::FaceRecord::update(), and wireEncode().
Interest & ndn::Interest::setInterestLifetime | ( | time::milliseconds | lifetime | ) |
Set Interest's lifetime.
std::invalid_argument | lifetime is negative |
Definition at line 476 of file interest.cpp.
References ndn::Block::reset().
|
inline |
Check if Interest has any selector present.
Definition at line 277 of file interest.hpp.
References ndn::Selectors::empty().
Referenced by wireEncode().
|
inline |
Definition at line 284 of file interest.hpp.
Referenced by nfd::pit::Entry::canMatch(), matchesInterest(), and wireEncode().
|
inline |
Definition at line 291 of file interest.hpp.
References ndn::Block::reset().
|
inline |
Definition at line 300 of file interest.hpp.
References ndn::Selectors::getMinSuffixComponents().
Referenced by matchesData(), matchesName(), and ndn::operator<<().
|
inline |
Definition at line 307 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setMinSuffixComponents().
|
inline |
Definition at line 316 of file interest.hpp.
References ndn::Selectors::getMaxSuffixComponents().
Referenced by matchesData(), matchesName(), and ndn::operator<<().
|
inline |
Definition at line 323 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setMaxSuffixComponents().
|
inline |
Definition at line 332 of file interest.hpp.
References ndn::Selectors::getPublisherPublicKeyLocator().
Referenced by matchesData().
|
inline |
Definition at line 339 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setPublisherPublicKeyLocator().
|
inline |
Definition at line 348 of file interest.hpp.
References ndn::Selectors::getExclude().
Referenced by matchesData(), matchesName(), and ndn::operator<<().
|
inline |
Definition at line 355 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setExclude().
|
inline |
Definition at line 364 of file interest.hpp.
References ndn::Selectors::getChildSelector().
Referenced by nfd::cs::Cs::find(), ndn::security::v2::CertificateCache::find(), ndn::operator<<(), and ndn::InMemoryStorage::selectChild().
|
inline |
Definition at line 371 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setChildSelector().