26 #include <ndn-cpp/ndn-cpp-config.h>
27 #ifdef NDN_CPP_HAVE_BOOST_ASIO
28 #include <boost/atomic.hpp>
30 #include <ndn-cpp/common.hpp>
31 #include <ndn-cpp/interest.hpp>
32 #include <ndn-cpp/data.hpp>
33 #include <ndn-cpp/forwarding-flags.hpp>
34 #include <ndn-cpp/interest-filter.hpp>
35 #include <ndn-cpp/face.hpp>
36 #include "util/command-interest-generator.hpp"
37 #include "impl/delayed-call-table.hpp"
38 #include "impl/interest-filter-table.hpp"
39 #include "impl/pending-interest-table.hpp"
40 #include "impl/registered-prefix-table.hpp"
41 #include "encoding/element-listener.hpp"
56 Node(
const ptr_lib::shared_ptr<Transport>& transport,
const ptr_lib::shared_ptr<const Transport::ConnectionInfo>& connectionInfo);
89 (uint64_t pendingInterestId,
90 const ptr_lib::shared_ptr<const Interest>& interestCopy,
122 (interest, keyChain, certificateName, wireFormat);
155 (uint64_t registeredPrefixId,
156 const ptr_lib::shared_ptr<const Name>& prefixCopy,
161 const Name& commandCertificateName,
Face* face);
169 (uint64_t registeredPrefixId,
170 const ptr_lib::shared_ptr<const Name>& prefixCopy,
177 (registeredPrefixId, prefixCopy, onInterest, onRegisterFailed,
178 onRegisterSuccess, flags, wireFormat, *face->getCommandKeyChain(),
179 face->getCommandCertificateName(), face);
215 (uint64_t interestFilterId,
216 const ptr_lib::shared_ptr<const InterestFilter>& filterCopy,
220 (interestFilterId, filterCopy, onInterest, face);
244 send(
const uint8_t *encoding,
size_t encodingLength);
261 const ptr_lib::shared_ptr<Transport>&
262 getTransport() {
return transport_; }
264 const ptr_lib::shared_ptr<const Transport::ConnectionInfo>&
265 getConnectionInfo() {
return connectionInfo_; }
276 isLocal() {
return transport_->isLocal(*connectionInfo_); }
300 delayedCallTable_.
callLater(delayMilliseconds, callback);
316 ConnectStatus_UNCONNECTED = 1,
317 ConnectStatus_CONNECT_REQUESTED = 2,
318 ConnectStatus_CONNECT_COMPLETE = 3
327 class RegisterResponse {
331 (ptr_lib::shared_ptr<RegisterResponse::Info> info,
Node& parent)
332 : info_(info), parent_(parent)
342 operator()(
const ptr_lib::shared_ptr<const Interest>& interest,
343 const ptr_lib::shared_ptr<Data>& responseData);
350 operator()(
const ptr_lib::shared_ptr<const Interest>& timedOutInterest);
354 Info(
const ptr_lib::shared_ptr<const Name>& prefix,
359 : prefix_(prefix), onRegisterFailed_(onRegisterFailed),
360 onRegisterSuccess_(onRegisterSuccess),
361 registeredPrefixId_(registeredPrefixId), onInterest_(onInterest),
366 ptr_lib::shared_ptr<const Name> prefix_;
369 uint64_t registeredPrefixId_;
375 ptr_lib::shared_ptr<Info> info_;
408 expressInterestHelper
409 (uint64_t pendingInterestId,
410 const ptr_lib::shared_ptr<const Interest>& interestCopy,
421 processInterestTimeout(ptr_lib::shared_ptr<PendingInterestTable::Entry> pendingInterest);
439 (uint64_t registeredPrefixId,
const ptr_lib::shared_ptr<const Name>& prefix,
443 KeyChain& commandKeyChain,
const Name& commandCertificateName,
452 ptr_lib::shared_ptr<Transport> transport_;
453 ptr_lib::shared_ptr<const Transport::ConnectionInfo> connectionInfo_;
458 std::vector<Face::Callback> onConnectedCallbacks_;
461 ConnectStatus connectStatus_;
463 #ifdef NDN_CPP_HAVE_BOOST_ASIO
466 boost::atomic_uint64_t lastEntryId_;
469 uint64_t lastEntryId_;
func_lib::function< void(const ptr_lib::shared_ptr< const Interest > &)> OnTimeout
An OnTimeout function object is used to pass a callback to expressInterest.
Definition: face.hpp:46
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:111
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
void setInterestFilter(uint64_t interestFilterId, const ptr_lib::shared_ptr< const InterestFilter > &filterCopy, const OnInterestCallback &onInterest, Face *face)
Add an entry to the local interest filter table to call the onInterest callback for a matching incomi...
Definition: node.hpp:215
void callLater(Milliseconds delayMilliseconds, const Face::Callback &callback)
Call callback() after the given delay.
Definition: node.hpp:298
void processEvents()
Process any packets to receive and call callbacks such as onData, onInterest or onTimeout.
Definition: node.cpp:291
The Face class provides the main methods for NDN communication.
Definition: face.hpp:86
An ElementListener extends an ndn_ElementListener struct to proved an abstract virtual onReceivedElem...
Definition: element-listener.hpp:33
A ForwardingFlags object holds the flags which specify how the forwarding daemon should forward an in...
Definition: forwarding-flags.hpp:35
func_lib::function< void(const ptr_lib::shared_ptr< const Name > &, uint64_t)> OnRegisterSuccess
An OnRegisterSuccess function object is used to report when registerPrefix succeeds.
Definition: face.hpp:78
A RegisteredPrefixTable is an internal class to hold a list of registered prefixes with information n...
Definition: registered-prefix-table.hpp:34
static size_t getMaxNdnPacketSize()
Get the practical limit of the size of a network-layer packet.
Definition: node.hpp:289
An ndn_Interest holds an ndn_Name and other fields for an interest.
Definition: interest-types.h:61
Node(const ptr_lib::shared_ptr< Transport > &transport, const ptr_lib::shared_ptr< const Transport::ConnectionInfo > &connectionInfo)
Create a new Node for communication with an NDN hub with the given Transport object and connectionInf...
Definition: node.cpp:41
void send(const uint8_t *encoding, size_t encodingLength)
Send the encoded packet out through the face.
Definition: node.cpp:137
Definition: delayed-call-table.hpp:30
void unsetInterestFilter(uint64_t interestFilterId)
Remove the interest filter entry which has the interestFilterId from the interest filter table...
Definition: node.hpp:231
KeyChain is the main class of the security library.
Definition: key-chain.hpp:45
void onReceivedElement(const uint8_t *element, size_t elementLength)
This is called when an entire element is received.
Definition: node.cpp:301
A PendingInterestTable is an internal class to hold a list of pending interests with their callbacks...
Definition: pending-interest-table.hpp:33
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
An Interest holds a Name and other fields for an interest.
Definition: interest.hpp:41
void expressInterest(uint64_t pendingInterestId, const ptr_lib::shared_ptr< const Interest > &interestCopy, const OnData &onData, const OnTimeout &onTimeout, const OnNetworkNack &onNetworkNack, WireFormat &wireFormat, Face *face)
Send the Interest through the transport, read the entire response and call onData, onTimeout or onNetworkNack as described below.
Definition: node.cpp:52
func_lib::function< void()> Callback
Face::Callback is used internally in callLater.
Definition: face.hpp:674
void makeCommandInterest(Interest &interest, KeyChain &keyChain, const Name &certificateName, WireFormat &wireFormat)
Append a timestamp component and a random value component to interest's name.
Definition: node.hpp:118
void removePendingInterest(uint64_t pendingInterestId)
Remove the pending interest entry with the pendingInterestId from the pending interest table and set ...
Definition: pending-interest-table.cpp:110
void removeRegisteredPrefix(uint64_t registeredPrefixId)
Remove the registered prefix entry with the registeredPrefixId from the registered prefix table...
Definition: node.hpp:191
func_lib::function< void(const ptr_lib::shared_ptr< const Name > &, const ptr_lib::shared_ptr< const Interest > &, Face &, uint64_t, const ptr_lib::shared_ptr< const InterestFilter > &)> OnInterestCallback
An OnInterestCallback function object is used to pass a callback to setInterestFilter and optionally ...
Definition: face.hpp:67
void callLater(Milliseconds delayMilliseconds, const Face::Callback &callback)
Call callback() after the given delay.
Definition: delayed-call-table.cpp:32
uint64_t getNextEntryId()
Get the next unique entry ID for the pending interest table, interest filter table, etc.
Definition: node.cpp:147
An InterestFilterTable is an internal class to hold a list of entries with an interest Filter and its...
Definition: interest-filter-table.hpp:33
An CommandInterestGenerator keeps track of a timestamp and generates command interests according to t...
Definition: command-interest-generator.hpp:35
void setInterestFilter(uint64_t interestFilterId, const ptr_lib::shared_ptr< const InterestFilter > &filterCopy, const OnInterestCallback &onInterest, Face *face)
Add a new entry to the table.
Definition: interest-filter-table.hpp:114
bool isLocal()
Check if the face is local based on the current connection through the Transport; some Transport may ...
Definition: node.hpp:276
func_lib::function< void(const ptr_lib::shared_ptr< const Name > &)> OnRegisterFailed
An OnRegisterFailed function object is used to report when registerPrefix fails.
Definition: face.hpp:72
void registerPrefix(uint64_t registeredPrefixId, const ptr_lib::shared_ptr< const Name > &prefixCopy, const OnInterestCallback &onInterest, const OnRegisterFailed &onRegisterFailed, const OnRegisterSuccess &onRegisterSuccess, const ForwardingFlags &flags, WireFormat &wireFormat, KeyChain &commandKeyChain, const Name &commandCertificateName, Face *face)
Register prefix with the connected NDN hub and call onInterest when a matching interest is received...
Definition: node.cpp:122
void unsetInterestFilter(uint64_t interestFilterId)
Remove the interest filter entry which has the interestFilterId from the interest filter table...
Definition: interest-filter-table.cpp:44
void removeRegisteredPrefix(uint64_t registeredPrefixId)
Remove the registered prefix entry with the registeredPrefixId from the registered prefix table...
Definition: registered-prefix-table.cpp:53
void generate(Interest &interest, KeyChain &keyChain, const Name &certificateName, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Append a timestamp component and a random value component to interest's name.
Definition: command-interest-generator.cpp:40
void removePendingInterest(uint64_t pendingInterestId)
Remove the pending interest entry with the pendingInterestId from the pending interest table...
Definition: node.hpp:101
func_lib::function< void(const ptr_lib::shared_ptr< const Interest > &, const ptr_lib::shared_ptr< Data > &)> OnData
An OnData function object is used to pass a callback to expressInterest.
Definition: face.hpp:35
func_lib::function< void(const ptr_lib::shared_ptr< const Interest > &, const ptr_lib::shared_ptr< NetworkNack > &)> OnNetworkNack
An OnNetworkNack function object is used to pass a callback to expressInterest.
Definition: face.hpp:52