represents an Interest packet More...
#include <interest.hpp>
Classes | |
class | Error |
Public Member Functions | |
Interest (const Name &name=Name(), time::milliseconds interestLifetime=DEFAULT_INTEREST_LIFETIME) | |
Create a new Interest with the given name and interest lifetime. More... | |
Interest (const Block &wire) | |
Create from wire encoding. More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
Fast encoding or block size estimation. More... | |
const Block & | wireEncode () const |
Encode to a wire format. More... | |
void | wireDecode (const Block &wire) |
Decode from the wire format. More... | |
bool | hasWire () const |
Check if already has wire. More... | |
std::string | toUri () const |
Encode the name according to the NDN URI Scheme. 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 | hasNonce () const |
Check if Nonce set. More... | |
uint32_t | getNonce () const |
Get nonce. More... | |
Interest & | setNonce (uint32_t nonce) |
Set nonce. More... | |
void | refreshNonce () |
Refresh nonce. More... | |
time::milliseconds | getInterestLifetime () const |
Interest & | setInterestLifetime (time::milliseconds interestLifetime) |
Set Interest's lifetime. More... | |
const DelegationList & | getForwardingHint () const |
Interest & | setForwardingHint (const DelegationList &value) |
template<typename Modifier > | |
Interest & | modifyForwardingHint (const Modifier &modifier) |
modify ForwardingHint in-place More... | |
bool | hasSelectors () const |
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) |
int | getMustBeFresh () const |
Interest & | setMustBeFresh (bool mustBeFresh) |
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... | |
represents an Interest packet
Definition at line 42 of file interest.hpp.
|
explicit |
Create a new Interest with the given name and interest lifetime.
std::invalid_argument | InterestLifetime is negative |
make_shared
. Otherwise, .shared_from_this() will trigger undefined behavior. Definition at line 38 of file interest.cpp.
Referenced by ndn::Interest::Error::Error().
|
explicit |
Create from wire encoding.
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 |
Fast encoding or block size estimation.
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::NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(), 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(), ndn::util::DummyClientFace::receive(), and nfd::face::GenericLinkService::setOptions().
const Block & ndn::Interest::wireEncode | ( | ) | const |
Encode to a wire format.
Definition at line 103 of file interest.cpp.
References ndn::Block::hasWire(), and wireDecode().
Referenced by ndn::Interest::Error::Error().
void ndn::Interest::wireDecode | ( | const Block & | wire | ) |
Decode from the wire format.
Definition at line 119 of file interest.cpp.
References ndn::DEFAULT_INTEREST_LIFETIME, ndn::Block::elements_end(), ndn::Block::find(), ndn::tlv::ForwardingHint, ndn::Block::get(), ndn::tlv::Interest, ndn::tlv::InterestLifetime, websocketpp::lib::asio::milliseconds(), ndn::tlv::Name, ndn::tlv::Nonce, ndn::Block::parse(), ndn::encoding::readNonNegativeInteger(), ndn::tlv::Selectors, ndn::Block::type(), ndn::Selectors::wireDecode(), ndn::DelegationList::wireDecode(), and ndn::Name::wireDecode().
Referenced by ndn::Interest::Error::Error(), Interest(), and wireEncode().
|
inline |
Check if already has wire.
Definition at line 93 of file interest.hpp.
References matchesData(), matchesInterest(), matchesName(), and toUri().
Referenced by ns3::ndn::L3RateTracer::InNack(), and ns3::ndn::L3RateTracer::OutNack().
std::string ndn::Interest::toUri | ( | ) | const |
Encode the name according to the NDN URI Scheme.
If there are interest selectors, this method will append "?" and add the selectors as a query string. For example, "/test/name?ndn.ChildSelector=1"
Definition at line 170 of file interest.cpp.
Referenced by hasWire().
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 180 of file interest.cpp.
References ndn::Exclude::empty(), getExclude(), getMaxSuffixComponents(), getMinSuffixComponents(), ndn::Exclude::isExcluded(), ndn::Name::isPrefixOf(), and ndn::Name::size().
Referenced by hasWire().
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 207 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(), hasWire(), 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 291 of file interest.cpp.
References getName(), and getSelectors().
Referenced by hasWire(), and face::Face::Impl::nackPendingInterests().
|
inline |
Definition at line 139 of file interest.hpp.
Referenced by ndn::mgmt::Dispatcher::addStatusDataset(), nfd::fw::asf::AsfStrategy::afterReceiveNack(), nfd::pit::Entry::canMatch(), ndn::security::v2::ValidationPolicySimpleHierarchy::checkPolicy(), ndn::security::v2::validator_config::ValidationPolicyConfig::checkPolicy(), ndn::security::v2::ValidationPolicyCommandInterest::checkPolicy(), ndn::util::DummyClientFace::DummyClientFace(), nfd::ManagerBase::extractRequester(), ndn::util::SegmentFetcher::fetch(), nfd::cs::Cs::find(), ndn::security::v2::CertificateCache::find(), ndn::security::v2::TrustAnchorContainer::find(), ndn::InMemoryStorage::find(), nfd::Forwarder::Forwarder(), ndn::security::v2::getKeyLocatorName(), nfd::fw::asf::AsfMeasurements::getOrCreateNamespaceInfo(), nfd::CommandAuthenticator::makeAuthorization(), matchesInterest(), ndn::operator<<(), ndn::security::parse(), nfd::pit::Pit::Pit(), ndn::mgmt::Dispatcher::removeTopPrefix(), ndn::InMemoryStorage::selectChild(), nfd::FaceManager::setConfigFile(), ndn::mgmt::StatusDatasetContext::setPrefix(), ndn::security::v2::KeyChain::sign(), ndn::mgmt::StatusDatasetContext::StatusDatasetContext(), ndn::util::NotificationSubscriberBase::stop(), wireEncode(), nfd::fw::wouldViolateScope(), and ndn::security::v2::InterestValidationState::~InterestValidationState().
Definition at line 145 of file interest.hpp.
Referenced by ndn::util::SegmentFetcher::fetch(), and ndn::security::v2::KeyChain::sign().
|
inline |
Check if Nonce set.
Definition at line 155 of file interest.hpp.
References getNonce(), websocketpp::lib::asio::milliseconds(), refreshNonce(), and setNonce().
Referenced by ndn::util::SegmentFetcher::fetch(), ndn::operator<<(), and refreshNonce().
uint32_t ndn::Interest::getNonce | ( | ) | const |
Get nonce.
If nonce was not set before this call, it will be automatically assigned to a random value
Definition at line 301 of file interest.cpp.
References ndn::random::generateWord32().
Referenced by nfd::fw::asf::AsfStrategy::afterReceiveNack(), nfd::Forwarder::Forwarder(), hasNonce(), ndn::operator<<(), refreshNonce(), nfd::pit::OutRecord::setIncomingNack(), nfd::pit::FaceRecord::update(), and wireEncode().
Interest & ndn::Interest::setNonce | ( | uint32_t | nonce | ) |
Set nonce.
Definition at line 310 of file interest.cpp.
References ndn::Block::reset().
Referenced by hasNonce(), and refreshNonce().
void ndn::Interest::refreshNonce | ( | ) |
Refresh nonce.
It's guaranteed that new nonce value differs from the existing one.
If nonce is already set, it will be updated to a different random value. If nonce is not set, this method does nothing.
Definition at line 318 of file interest.cpp.
References ndn::random::generateWord32(), getNonce(), hasNonce(), and setNonce().
Referenced by nfd::fw::asf::AsfStrategy::afterReceiveNack(), ndn::security::v2::CertificateFetcherDirectFetch::doFetch(), ndn::util::SegmentFetcher::fetch(), and hasNonce().
|
inline |
Definition at line 183 of file interest.hpp.
References websocketpp::lib::asio::milliseconds(), and setInterestLifetime().
Referenced by ndn::operator<<(), nfd::pit::FaceRecord::update(), and wireEncode().
Interest & ndn::Interest::setInterestLifetime | ( | time::milliseconds | interestLifetime | ) |
Set Interest's lifetime.
std::invalid_argument | specified lifetime is < 0 |
Definition at line 332 of file interest.cpp.
References ndn::Block::reset().
Referenced by ndn::nfd::Controller::Controller(), ndn::security::v2::CertificateBundleFetcher::doFetch(), and getInterestLifetime().
|
inline |
Definition at line 196 of file interest.hpp.
References setForwardingHint().
Referenced by nfd::Forwarder::Forwarder(), and nfd::fw::Strategy::lookupFib().
Interest & ndn::Interest::setForwardingHint | ( | const DelegationList & | value | ) |
Definition at line 343 of file interest.cpp.
References ndn::Block::reset().
Referenced by getForwardingHint().
|
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 216 of file interest.hpp.
|
inline |
Definition at line 228 of file interest.hpp.
Referenced by wireEncode().
|
inline |
Definition at line 234 of file interest.hpp.
Referenced by nfd::pit::Entry::canMatch(), matchesInterest(), and wireEncode().
Definition at line 240 of file interest.hpp.
|
inline |
Definition at line 248 of file interest.hpp.
Referenced by matchesData(), matchesName(), and ndn::operator<<().
|
inline |
Definition at line 254 of file interest.hpp.
References setMinSuffixComponents().
Referenced by setMinSuffixComponents().
|
inline |
Definition at line 262 of file interest.hpp.
Referenced by matchesData(), matchesName(), and ndn::operator<<().
|
inline |
Definition at line 268 of file interest.hpp.
References setMaxSuffixComponents().
Referenced by setMaxSuffixComponents().
|
inline |
Definition at line 276 of file interest.hpp.
Referenced by matchesData().
|
inline |
Definition at line 282 of file interest.hpp.
References setPublisherPublicKeyLocator().
Referenced by setPublisherPublicKeyLocator().
|
inline |
Definition at line 290 of file interest.hpp.
Referenced by matchesData(), matchesName(), and ndn::operator<<().
|
inline |
Definition at line 304 of file interest.hpp.
Referenced by nfd::cs::Cs::find(), ndn::security::v2::CertificateCache::find(), ndn::operator<<(), and ndn::InMemoryStorage::selectChild().
|
inline |
Definition at line 310 of file interest.hpp.
References setChildSelector().
Referenced by ndn::security::v2::CertificateBundleFetcher::doFetch(), ndn::util::SegmentFetcher::fetch(), and setChildSelector().
|
inline |
Definition at line 318 of file interest.hpp.
Referenced by nfd::cs::Entry::canSatisfy(), nfd::insertNonceToDnl(), ndn::operator<<(), and ndn::InMemoryStorage::selectChild().
|
inline |
Definition at line 324 of file interest.hpp.
References websocketpp::lib::asio::milliseconds(), ndn::NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(), ndn::operator<<(), and setMustBeFresh().
Referenced by ndn::security::v2::CertificateBundleFetcher::doFetch(), ndn::util::SegmentFetcher::fetch(), and setMustBeFresh().