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 . 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... | |
bool | hasParameters () const |
const Block & | getParameters () const |
Interest & | setParameters (const Block ¶meters) |
Set parameters from a Block. More... | |
Interest & | setParameters (const uint8_t *buffer, size_t bufferSize) |
Copy parameters from raw buffer. More... | |
Interest & | setParameters (ConstBufferPtr buffer) |
Set parameters from a wire buffer. More... | |
Interest & | unsetParameters () |
Remove the Parameters element from this Interest. More... | |
bool | hasSelectors () const |
Check if Interest has any selector present. More... | |
const Selectors & | getSelectors () const |
Interest & | setSelectors (const Selectors &selectors) |
int | getMinSuffixComponents () const |
Interest & | setMinSuffixComponents (int minSuffixComponents) |
int | getMaxSuffixComponents () const |
Interest & | setMaxSuffixComponents (int maxSuffixComponents) |
const KeyLocator & | getPublisherPublicKeyLocator () const |
Interest & | setPublisherPublicKeyLocator (const KeyLocator &keyLocator) |
const Exclude & | getExclude () const |
Interest & | setExclude (const Exclude &exclude) |
int | getChildSelector () const |
Interest & | setChildSelector (int childSelector) |
Public Member Functions inherited from ndn::PacketBase | |
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... | |
Public Member Functions inherited from ndn::TagHost | |
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... | |
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 46 of file interest.cpp.
References setCanBePrefix().
|
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 60 of file interest.cpp.
References wireDecode().
size_t ndn::Interest::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Prepend wire encoding to encoder
.
Definition at line 70 of file interest.cpp.
References hasParameters().
Referenced by ndn::Face::Impl::asyncExpressInterest(), ndn::Face::Impl::asyncPutNack(), 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
.
Encodes into NDN Packet Format v0.3 if Parameters element is present. In this case, Selectors are not encoded. Otherwise, encodes into NDN Packet Format v0.2.
Definition at line 202 of file interest.cpp.
References ndn::Block::hasWire().
void ndn::Interest::wireDecode | ( | const Block & | wire | ) |
Decode from wire
in NDN Packet Format v0.2 or v0.3.
Definition at line 218 of file interest.cpp.
References getNonce(), hasNonce(), ndn::tlv::Interest, ndn::Block::parse(), setNonce(), ndn::to_string(), and ndn::Block::type().
Referenced by Interest().
|
inline |
Check if this instance has cached wire encoding.
Definition at line 90 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 418 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 445 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 529 of file interest.cpp.
References getName(), and getSelectors().
Referenced by ndn::Face::Impl::nackPendingInterests().
|
inline |
Definition at line 134 of file interest.hpp.
Referenced by nfd::fw::SelfLearningStrategy::afterReceiveNack(), ndn::Face::Impl::asyncExpressInterest(), ndn::Face::Impl::asyncPutNack(), 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(), ns3::ndn::Consumer::OnNack(), ndn::operator<<(), ndn::security::parse(), ndn::InMemoryStorage::selectChild(), ndn::mgmt::StatusDatasetContext::setPrefix(), ndn::security::v2::KeyChain::sign(), ndn::mgmt::StatusDatasetContext::StatusDatasetContext(), ndn::security::v2::Validator::validate(), and nfd::fw::wouldViolateScope().
Definition at line 140 of file interest.hpp.
References ndn::Block::reset().
Referenced by ndn::security::v2::KeyChain::sign().
|
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.
|
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.
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 187 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setMaxSuffixComponents().
Referenced by Interest(), and ndn::security::CommandInterestSigner::makeCommandInterest().
|
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.
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 215 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setMustBeFresh().
|
inline |
Definition at line 223 of file interest.hpp.
Referenced by nfd::fw::Strategy::lookupFib().
Interest & ndn::Interest::setForwardingHint | ( | const DelegationList & | value | ) |
Definition at line 581 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 243 of file interest.hpp.
References ndn::Block::reset().
|
inline |
Check if the Nonce element is present.
Definition at line 253 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 539 of file interest.cpp.
References ndn::random::generateWord32().
Referenced by ndn::operator<<(), refreshNonce(), nfd::pit::OutRecord::setIncomingNack(), nfd::pit::FaceRecord::update(), and wireDecode().
Interest & ndn::Interest::setNonce | ( | uint32_t | nonce | ) |
Set nonce value.
Definition at line 548 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 556 of file interest.cpp.
References ndn::random::generateWord32(), getNonce(), hasNonce(), and setNonce().
Referenced by ndn::security::v2::CertificateFetcherDirectFetch::doFetch().
|
inline |
Definition at line 279 of file interest.hpp.
Referenced by ndn::operator<<(), and nfd::pit::FaceRecord::update().
Interest & ndn::Interest::setInterestLifetime | ( | time::milliseconds | lifetime | ) |
Set Interest's lifetime.
std::invalid_argument | lifetime is negative |
Definition at line 570 of file interest.cpp.
References ndn::Block::reset().
|
inline |
Definition at line 291 of file interest.hpp.
References ndn::Block::empty().
Referenced by wireEncode().
|
inline |
Definition at line 297 of file interest.hpp.
Set parameters from a Block.
If the block's TLV-TYPE is Parameters, it will be used directly as this Interest's Parameters element. If the block's TLV-TYPE is not Parameters, it will be nested into a Parameters element.
Definition at line 589 of file interest.cpp.
References ndn::tlv::Parameters, ndn::Block::reset(), and ndn::Block::type().
Interest & ndn::Interest::setParameters | ( | const uint8_t * | buffer, |
size_t | bufferSize | ||
) |
Copy parameters from raw buffer.
buffer | pointer to the first octet of parameters |
bufferSize | size of the raw buffer |
Definition at line 602 of file interest.cpp.
References ndn::encoding::makeBinaryBlock(), ndn::tlv::Parameters, and ndn::Block::reset().
Interest & ndn::Interest::setParameters | ( | ConstBufferPtr | buffer | ) |
Set parameters from a wire buffer.
buffer | containing the Interest parameters |
Definition at line 610 of file interest.cpp.
References ndn::tlv::Parameters, and ndn::Block::reset().
Interest & ndn::Interest::unsetParameters | ( | ) |
Remove the Parameters element from this Interest.
Definition at line 618 of file interest.cpp.
References ndn::Block::reset().
|
inline |
Check if Interest has any selector present.
Definition at line 340 of file interest.hpp.
References ndn::Selectors::empty().
|
inline |
Definition at line 347 of file interest.hpp.
Referenced by nfd::pit::Entry::canMatch(), and matchesInterest().
Definition at line 354 of file interest.hpp.
References ndn::Block::reset().
|
inline |
Definition at line 363 of file interest.hpp.
References ndn::Selectors::getMinSuffixComponents().
Referenced by matchesData(), matchesName(), and ndn::operator<<().
|
inline |
Definition at line 370 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setMinSuffixComponents().
|
inline |
Definition at line 379 of file interest.hpp.
References ndn::Selectors::getMaxSuffixComponents().
Referenced by matchesData(), matchesName(), and ndn::operator<<().
|
inline |
Definition at line 386 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setMaxSuffixComponents().
|
inline |
Definition at line 395 of file interest.hpp.
References ndn::Selectors::getPublisherPublicKeyLocator().
Referenced by matchesData().
|
inline |
Definition at line 402 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setPublisherPublicKeyLocator().
|
inline |
Definition at line 411 of file interest.hpp.
References ndn::Selectors::getExclude().
Referenced by matchesData(), matchesName(), and ndn::operator<<().
Definition at line 418 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setExclude().
|
inline |
Definition at line 427 of file interest.hpp.
References ndn::Selectors::getChildSelector().
Referenced by nfd::cs::Cs::find(), ndn::operator<<(), and ndn::InMemoryStorage::selectChild().
|
inline |
Definition at line 434 of file interest.hpp.
References ndn::Block::reset(), and ndn::Selectors::setChildSelector().
Definition at line 628 of file interest.cpp.