26 struct PendingInterestId;
27 struct RegisteredPrefixId;
32 typedef function<void(const Interest&, Data&)>
OnData;
42 typedef function<void (const Name&, const Interest&)>
OnInterest;
57 class Error :
public std::runtime_error
62 : std::runtime_error(what)
125 Face(
const std::string& host,
const std::string& port =
"6363");
133 Face(
const shared_ptr<Transport>& transport);
142 Face(
const shared_ptr<Transport>& transport,
161 const PendingInterestId*
176 const PendingInterestId*
210 const RegisteredPrefixId*
259 processEvents(
const time::milliseconds& timeout = time::milliseconds::zero(),
260 bool keepThread =
false);
278 shared_ptr<boost::asio::io_service>
287 boost::asio::io_service&
299 construct(
const shared_ptr<Transport>& transport,
300 const shared_ptr<boost::asio::io_service>&
ioService);
303 isSupportedNfdProtocol(
const std::string& protocol);
306 isSupportedNrdProtocol(
const std::string& protocol);
309 isSupportedNdndProtocol(
const std::string& protocol);
311 class ProcessEventsTimeout
315 typedef std::list<shared_ptr<PendingInterest> > PendingInterestTable;
316 typedef std::list<shared_ptr<RegisteredPrefix> > RegisteredPrefixTable;
319 asyncExpressInterest(
const shared_ptr<const Interest>& interest,
323 asyncRemovePendingInterest(
const PendingInterestId* pendingInterestId);
326 asyncUnsetInterestFilter(
const RegisteredPrefixId* registeredPrefixId);
329 finalizeUnsetInterestFilter(RegisteredPrefixTable::iterator item);
332 onReceiveElement(
const Block& wire);
338 fireProcessEventsTimeout(
const boost::system::error_code& error);
341 satisfyPendingInterests(
Data& data);
344 processInterestFilters(
Interest& interest);
350 shared_ptr<boost::asio::io_service> m_ioService;
351 shared_ptr<boost::asio::io_service::work> m_ioServiceWork;
352 shared_ptr<monotonic_deadline_timer> m_pitTimeoutCheckTimer;
353 bool m_pitTimeoutCheckTimerActive;
354 shared_ptr<monotonic_deadline_timer> m_processEventsTimeoutTimer;
356 shared_ptr<Transport> m_transport;
358 PendingInterestTable m_pendingInterestTable;
359 RegisteredPrefixTable m_registeredPrefixTable;
361 shared_ptr<Controller> m_fwController;
367 Face::isSupportedNfdProtocol(
const std::string& protocol)
369 return protocol ==
"nfd-0.1";
373 Face::isSupportedNrdProtocol(
const std::string& protocol)
375 return protocol ==
"nrd-0.1";
379 Face::isSupportedNdndProtocol(
const std::string& protocol)
381 return protocol ==
"ndnd-tlv-0.7";
386 #endif // NDN_FACE_HPP
Error(const std::string &what)
An Interest holds a Name and other fields for an interest.
function< void(const Interest &)> OnTimeout
An OnTimeout function object is used to pass a callback to expressInterest.
function< void(const Name &, const Interest &)> OnInterest
An OnInterest function object is used to pass a callback to registerPrefix.
Face()
Create a new Face using the default transport (UnixTransport)
void setController(const shared_ptr< Controller > &controller)
Set controller used for prefix registration.
const RegisteredPrefixId * setInterestFilter(const Name &prefix, const OnInterest &onInterest, const OnSetInterestFilterFailed &onSetInterestFilterFailed)
Register prefix with the connected NDN hub and call onInterest when a matching interest is received...
shared_ptr< boost::asio::io_service > ioService()
Get shared_ptr of the IO service object.
void shutdown()
Shutdown face operations.
function< void(const Name &, const std::string &)> OnSetInterestFilterFailed
An OnRegisterFailed function object is used to report when registerPrefix fails.
Abstraction to communicate with local or remote NDN forwarder.
A Name holds an array of Name::Component and represents an NDN name.
const PendingInterestId * expressInterest(const Interest &interest, const OnData &onData, const OnTimeout &onTimeout=OnTimeout())
Express Interest.
void unsetInterestFilter(const RegisteredPrefixId *registeredPrefixId)
Remove the registered prefix entry with the registeredPrefixId from the pending interest table...
boost::asio::io_service & getIoService()
Get reference to IO service object.
function< void(const Interest &, Data &)> OnData
An OnData function object is used to pass a callback to expressInterest.
void processEvents(const time::milliseconds &timeout=time::milliseconds::zero(), bool keepThread=false)
Process any data to receive or call timeout callbacks.
void removePendingInterest(const PendingInterestId *pendingInterestId)
Remove the pending interest entry with the pendingInterestId from the pending interest table...
void put(const Data &data)
Publish data packet.