Provide a communication channel with local or remote NDN forwarder. More...
#include <face.hpp>
Classes | |
class | Error |
class | Impl |
implementation detail of Face More... | |
class | OversizedPacketError |
Exception thrown when attempting to send a packet over size limit. More... | |
Public Member Functions | |
Face (shared_ptr< Transport > transport=nullptr) | |
Create Face using given transport (or default transport if omitted) More... | |
Face (DummyIoService &ioService) | |
Create Face using default transport and given io_service. More... | |
Face (shared_ptr< Transport > transport, KeyChain &keyChain) | |
Create Face using given transport and KeyChain. More... | |
virtual | ~Face () |
PendingInterestHandle | expressInterest (const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout) |
Express Interest. More... | |
void | removePendingInterest (const PendingInterestId *pendingInterestId) |
void | removeAllPendingInterests () |
Cancel all previously expressed Interests. More... | |
size_t | getNPendingInterests () const |
Get number of pending Interests. More... | |
RegisteredPrefixHandle | setInterestFilter (const InterestFilter &filter, const InterestCallback &onInterest, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT) |
Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More... | |
RegisteredPrefixHandle | setInterestFilter (const InterestFilter &filter, const InterestCallback &onInterest, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT) |
Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More... | |
InterestFilterHandle | setInterestFilter (const InterestFilter &filter, const InterestCallback &onInterest) |
Set InterestFilter to dispatch incoming matching interest to onInterest callback. More... | |
RegisteredPrefixHandle | registerPrefix (const Name &prefix, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT) |
Register prefix with the connected NDN forwarder. More... | |
void | unsetInterestFilter (const RegisteredPrefixId *registeredPrefixId) |
void | unsetInterestFilter (const InterestFilterId *interestFilterId) |
void | unregisterPrefix (const RegisteredPrefixId *registeredPrefixId, const UnregisterPrefixSuccessCallback &onSuccess, const UnregisterPrefixFailureCallback &onFailure) |
void | put (Data data) |
Publish data packet. More... | |
void | put (lp::Nack nack) |
Send a network NACK. More... | |
void | processEvents (time::milliseconds timeout=time::milliseconds::zero(), bool keepThread=false) |
Process any data to receive or call timeout callbacks. More... | |
void | shutdown () |
Shutdown face operations. More... | |
DummyIoService & | getIoService () |
Public Attributes | |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED | __pad0__: shared_ptr<Transport> getTransport() const { return m_transport |
Protected Member Functions | |
virtual void | doProcessEvents (time::milliseconds timeout, bool keepThread) |
Provide a communication channel with local or remote NDN forwarder.
|
explicit |
Create Face using given transport (or default transport if omitted)
transport | the transport for lower layer communication. If nullptr, a default transport will be used. The default transport is determined from a FaceUri in NDN_CLIENT_TRANSPORT environ, a FaceUri in configuration file 'transport' key, or UnixTransport. |
ConfigFile::Error | transport is nullptr, and the configuration file cannot be parsed or specifies an unsupported protocol |
Definition at line 67 of file face.cpp.
References ns3::ndn::StackHelper::getKeyChain().
|
explicit |
Create Face using default transport and given io_service.
Usage examples:
or
ioService | A reference to boost::io_service object that should control all IO operations. |
ConfigFile::Error | the configuration file cannot be parsed or specifies an unsupported protocol |
Definition at line 62 of file face.cpp.
References ns3::ndn::StackHelper::getKeyChain().
Create Face using given transport and KeyChain.
transport | the transport for lower layer communication. If nullptr, a default transport will be used. |
keyChain | the KeyChain to sign commands |
ConfigFile::Error | transport is nullptr, and the configuration file cannot be parsed or specifies an unsupported protocol |
Definition at line 72 of file face.cpp.
References nonstd::optional_lite::std11::move().
|
virtualdefault |
PendingInterestHandle ndn::Face::expressInterest | ( | const Interest & | interest, |
const DataCallback & | afterSatisfied, | ||
const NackCallback & | afterNacked, | ||
const TimeoutCallback & | afterTimeout | ||
) |
Express Interest.
interest | the Interest; a copy will be made, so that the caller is not required to maintain the argument unchanged |
afterSatisfied | function to be invoked if Data is returned |
afterNacked | function to be invoked if Network NACK is returned |
afterTimeout | function to be invoked if neither Data nor Network NACK is returned within InterestLifetime |
OversizedPacketError | encoded Interest size exceeds MAX_NDN_PACKET_SIZE |
Definition at line 121 of file face.cpp.
References IO_CAPTURE_WEAK_IMPL, and IO_CAPTURE_WEAK_IMPL_END.
Referenced by ndn::security::v2::CertificateFetcherFromNetwork::doFetch(), and ndn::security::v2::CertificateFetcherDirectFetch::doFetch().
|
inline |
void ndn::Face::removeAllPendingInterests | ( | ) |
Cancel all previously expressed Interests.
Definition at line 147 of file face.cpp.
References IO_CAPTURE_WEAK_IMPL, and IO_CAPTURE_WEAK_IMPL_END.
size_t ndn::Face::getNPendingInterests | ( | ) | const |
RegisteredPrefixHandle ndn::Face::setInterestFilter | ( | const InterestFilter & | filter, |
const InterestCallback & | onInterest, | ||
const RegisterPrefixFailureCallback & | onFailure, | ||
const security::SigningInfo & | signingInfo = security::SigningInfo() , |
||
uint64_t | flags = nfd::ROUTE_FLAG_CHILD_INHERIT |
||
) |
Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.
This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.
filter | Interest filter (prefix part will be registered with the forwarder) |
onInterest | A callback to be called when a matching interest is received |
onFailure | A callback to be called when prefixRegister command fails |
signingInfo | Signing parameters. When omitted, a default parameters used in the signature will be used. |
flags | Prefix registration flags |
Definition at line 177 of file face.cpp.
Referenced by ndn::mgmt::Dispatcher::addTopPrefix().
RegisteredPrefixHandle ndn::Face::setInterestFilter | ( | const InterestFilter & | filter, |
const InterestCallback & | onInterest, | ||
const RegisterPrefixSuccessCallback & | onSuccess, | ||
const RegisterPrefixFailureCallback & | onFailure, | ||
const security::SigningInfo & | signingInfo = security::SigningInfo() , |
||
uint64_t | flags = nfd::ROUTE_FLAG_CHILD_INHERIT |
||
) |
Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.
This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.
filter | Interest filter (prefix part will be registered with the forwarder) |
onInterest | A callback to be called when a matching interest is received |
onSuccess | A callback to be called when prefixRegister command succeeds |
onFailure | A callback to be called when prefixRegister command fails |
signingInfo | Signing parameters. When omitted, a default parameters used in the signature will be used. |
flags | Prefix registration flags |
Definition at line 185 of file face.cpp.
References ndn::InterestFilter::getPrefix(), and ndn::nfd::CommandOptions::setSigningInfo().
InterestFilterHandle ndn::Face::setInterestFilter | ( | const InterestFilter & | filter, |
const InterestCallback & | onInterest | ||
) |
Set InterestFilter to dispatch incoming matching interest to onInterest callback.
filter | Interest filter |
onInterest | A callback to be called when a matching interest is received |
This method modifies library's FIB only, and does not register the prefix with the forwarder. It will always succeed. To register prefix with the forwarder, use registerPrefix, or use the setInterestFilter overload taking two callbacks.
Definition at line 199 of file face.cpp.
References IO_CAPTURE_WEAK_IMPL, and IO_CAPTURE_WEAK_IMPL_END.
RegisteredPrefixHandle ndn::Face::registerPrefix | ( | const Name & | prefix, |
const RegisterPrefixSuccessCallback & | onSuccess, | ||
const RegisterPrefixFailureCallback & | onFailure, | ||
const security::SigningInfo & | signingInfo = security::SigningInfo() , |
||
uint64_t | flags = nfd::ROUTE_FLAG_CHILD_INHERIT |
||
) |
Register prefix with the connected NDN forwarder.
This method only modifies forwarder's RIB and does not associate any onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to the right callbacks.
prefix | A prefix to register with the connected NDN forwarder |
onSuccess | A callback to be called when prefixRegister command succeeds |
onFailure | A callback to be called when prefixRegister command fails |
signingInfo | Signing parameters. When omitted, a default parameters used in the signature will be used. |
flags | Prefix registration flags |
Definition at line 219 of file face.cpp.
References nonstd::optional_lite::nullopt, and ndn::nfd::CommandOptions::setSigningInfo().
Referenced by ndn::mgmt::Dispatcher::addTopPrefix().
|
inline |
|
inline |
|
inline |
void ndn::Face::put | ( | Data | data | ) |
Publish data packet.
data | the Data; a copy will be made, so that the caller is not required to maintain the argument unchanged |
This method can be called to satisfy incoming Interests, or to add Data packet into the cache of the local NDN forwarder if forwarder is configured to accept unsolicited Data.
OversizedPacketError | encoded Data size exceeds MAX_NDN_PACKET_SIZE |
Definition at line 161 of file face.cpp.
References IO_CAPTURE_WEAK_IMPL, and IO_CAPTURE_WEAK_IMPL_END.
Referenced by ndn::util::NotificationStream< Notification >::postNotification().
void ndn::Face::put | ( | lp::Nack | nack | ) |
Send a network NACK.
nack | the Nack; a copy will be made, so that the caller is not required to maintain the argument unchanged |
OversizedPacketError | encoded Nack size exceeds MAX_NDN_PACKET_SIZE |
Definition at line 169 of file face.cpp.
References IO_CAPTURE_WEAK_IMPL, and IO_CAPTURE_WEAK_IMPL_END.
|
inline |
Process any data to receive or call timeout callbacks.
This call will block forever (default timeout == 0) to process IO on the face. To exit cleanly on a producer, unset any Interest filters with unsetInterestFilter() and wait for processEvents() to return. To exit after an error, one can call shutdown(). In consumer applications, processEvents() will return when all expressed Interests have been satisfied, Nacked, or timed out. To terminate earlier, a consumer application should cancel all previously expressed and still-pending Interests.
If a positive timeout is specified, then processEvents() will exit after this timeout, provided it is not stopped earlier with shutdown() or when all active events finish. processEvents() can be called repeatedly, if desired.
If a negative timeout is specified, then processEvents will not block and will process only pending events.
timeout | maximum time to block the thread |
keepThread | Keep thread in a blocked state (in event processing), even when there are no outstanding events (e.g., no Interest/Data is expected). If timeout is zero and this parameter is true, the only way to stop processEvents() is to call shutdown(). |
OversizedPacketError | encoded packet size exceeds MAX_NDN_PACKET_SIZE |
Definition at line 398 of file face.hpp.
References doProcessEvents().
void ndn::Face::shutdown | ( | ) |
Shutdown face operations.
This method cancels all pending operations and closes connection to NDN Forwarder.
Note that this method does not stop the io_service if it is shared between multiple Faces or with other IO objects (e.g., Scheduler).
Definition at line 249 of file face.cpp.
References IO_CAPTURE_WEAK_IMPL, and IO_CAPTURE_WEAK_IMPL_END.
|
inline |
|
protectedvirtual |
Definition at line 244 of file face.cpp.
Referenced by processEvents().
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED ndn::Face::__pad0__ |