Public Member Functions | |
| 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 connectionInfo. More... | |
| uint64_t | expressInterest (const Interest &interest, const OnData &onData, const OnTimeout &onTimeout, WireFormat &wireFormat) |
| Send the Interest through the transport, read the entire response and call onData(interest, data). More... | |
| void | removePendingInterest (uint64_t pendingInterestId) |
| Remove the pending interest entry with the pendingInterestId from the pending interest table. More... | |
| void | makeCommandInterest (Interest &interest, KeyChain &keyChain, const Name &certificateName, WireFormat &wireFormat) |
| Append a timestamp component and a random value component to interest's name. More... | |
| uint64_t | registerPrefix (const Name &prefix, const OnInterestCallback &onInterest, const OnRegisterFailed &onRegisterFailed, 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. More... | |
| void | removeRegisteredPrefix (uint64_t registeredPrefixId) |
| Remove the registered prefix entry with the registeredPrefixId from the registered prefix table. More... | |
| uint64_t | setInterestFilter (const InterestFilter &filter, const OnInterestCallback &onInterest, Face *face) |
| Add an entry to the local interest filter table to call the onInterest callback for a matching incoming Interest. More... | |
| void | unsetInterestFilter (uint64_t interestFilterId) |
| Remove the interest filter entry which has the interestFilterId from the interest filter table. More... | |
| void | putData (const Data &data, WireFormat &wireFormat) |
| The OnInterestCallback calls this to put a Data packet which satisfies an Interest. More... | |
| void | send (const uint8_t *encoding, size_t encodingLength) |
| Send the encoded packet out through the face. More... | |
| void | processEvents () |
| Process any packets to receive and call callbacks such as onData, onInterest or onTimeout. More... | |
| const ptr_lib::shared_ptr< Transport > & | getTransport () |
| const ptr_lib::shared_ptr< const Transport::ConnectionInfo > & | getConnectionInfo () |
| void | onReceivedElement (const uint8_t *element, size_t elementLength) |
| This is called when an entire binary XML element is received. More... | |
| bool | isLocal () |
| Check if the face is local based on the current connection through the Transport; some Transport may cause network I/O (e.g. More... | |
| void | shutdown () |
Static Public Member Functions | |
| static size_t | getMaxNdnPacketSize () |
| Get the practical limit of the size of a network-layer packet. More... | |
Additional Inherited Members | |
Public Attributes inherited from ndn_ElementListener | |
| ndn_OnReceivedElement | onReceivedElement |
| see ndn_ElementListener_initialize | |
| ndn::Node::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 connectionInfo.
| transport | A shared_ptr to a Transport object used for communication. |
| transport | A shared_ptr to a Transport::ConnectionInfo to be used to connect to the transport. |
| uint64_t ndn::Node::expressInterest | ( | const Interest & | interest, |
| const OnData & | onData, | ||
| const OnTimeout & | onTimeout, | ||
| WireFormat & | wireFormat | ||
| ) |
Send the Interest through the transport, read the entire response and call onData(interest, data).
| interest | A reference to the Interest. This copies the Interest. |
| onData | A function object to call when a matching data packet is received. This copies the function object, so you may need to use func_lib::ref() as appropriate. |
| onTimeout | A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it. This copies the function object, so you may need to use func_lib::ref() as appropriate. |
| wireFormat | A WireFormat object used to encode the message. |
| runtime_error | If the encoded interest size exceeds getMaxNdnPacketSize(). |
|
inlinestatic |
Get the practical limit of the size of a network-layer packet.
If a packet is larger than this, the library or application MAY drop it. This is a static inline method wrapping a const, so you can to use as a constant, e.g.: uint8_t buffer[Face::getMaxNdnPacketSize()].
|
inline |
|
inline |
Append a timestamp component and a random value component to interest's name.
Then use the keyChain and certificateName to sign the interest. If the interest lifetime is not set, this sets it.
| interest | The interest whose name is append with components. |
| keyChain | The KeyChain object for signing interests. |
| certificateName | The certificate name for signing interests. |
| wireFormat | A WireFormat object used to encode the SignatureInfo and to encode interest name for signing. |
|
virtual |
This is called when an entire binary XML element is received.
You must extend this class to override this method.
| element | pointer to the binary XML element. This buffer is only valid during this call. If you need the data later, you must copy. |
| elementLength | length of element |
Implements ndn::ElementListener.
| void ndn::Node::processEvents | ( | ) |
Process any packets to receive and call callbacks such as onData, onInterest or onTimeout.
This returns immediately if there is no data to receive. This blocks while calling the callbacks. You should repeatedly call this from an event loop, with calls to sleep as needed so that the loop doesn’t use 100% of the CPU. Since processEvents modifies the pending interest table, your application should make sure that it calls processEvents in the same thread as expressInterest (which also modifies the pending interest table).
| This | may throw an exception for reading data or in the callback for processing the data. If you call this from an main event loop, you may want to catch and log/disregard all exceptions. |
| void ndn::Node::putData | ( | const Data & | data, |
| WireFormat & | wireFormat | ||
| ) |
The OnInterestCallback calls this to put a Data packet which satisfies an Interest.
| data | The Data packet which satisfies the interest. |
| wireFormat | A WireFormat object used to encode the Data packet. |
| runtime_error | If the encoded Data packet size exceeds getMaxNdnPacketSize(). |
| uint64_t ndn::Node::registerPrefix | ( | const Name & | prefix, |
| const OnInterestCallback & | onInterest, | ||
| const OnRegisterFailed & | onRegisterFailed, | ||
| 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.
| prefix | A reference to a Name for the prefix to register. This copies the Name. |
| onInterest | (optional) If not null, this creates an interest filter from prefix so that when an Interest is received which matches the filter, this calls the function object onInterest(prefix, interest, face, interestFilterId, filter). This copies the function object, so you may need to use func_lib::ref() as appropriate. If onInterest is null, it is ignored and you must call setInterestFilter. |
| onRegisterFailed | A function object to call if failed to retrieve the connected hub’s ID or failed to register the prefix. This calls onRegisterFailed(prefix) where prefix is the prefix given to registerPrefix. |
| flags | The flags for finer control of which interests are forwarded to the application. |
| wireFormat | A WireFormat object used to encode the message. |
| commandKeyChain | The KeyChain object for signing interests. If null, assume we are connected to a legacy NDNx forwarder. |
| commandCertificateName | The certificate name for signing interests. |
| face | The face which is passed to the onInterest callback. If onInterest is null, this is ignored. |
| void ndn::Node::removePendingInterest | ( | uint64_t | pendingInterestId | ) |
Remove the pending interest entry with the pendingInterestId from the pending interest table.
This does not affect another pending interest with a different pendingInterestId, even if it has the same interest name. If there is no entry with the pendingInterestId, do nothing.
| pendingInterestId | The ID returned from expressInterest. |
| void ndn::Node::removeRegisteredPrefix | ( | uint64_t | registeredPrefixId | ) |
Remove the registered prefix entry with the registeredPrefixId from the registered prefix table.
This does not affect another registered prefix with a different registeredPrefixId, even if it has the same prefix name. If there is no entry with the registeredPrefixId, do nothing. If an interest filter was automatically created by registerPrefix, also remove it.
| registeredPrefixId | The ID returned from registerPrefix. |
| void ndn::Node::send | ( | const uint8_t * | encoding, |
| size_t | encodingLength | ||
| ) |
Send the encoded packet out through the face.
| encoding | The array of bytes for the encoded packet to send. |
| encodingLength | The number of bytes in the encoding array. |
| runtime_error | If the encoded Data packet size exceeds getMaxNdnPacketSize(). |
|
inline |
Add an entry to the local interest filter table to call the onInterest callback for a matching incoming Interest.
This method only modifies the library's local callback table and does not register the prefix with the forwarder. It will always succeed. To register a prefix with the forwarder, use registerPrefix.
| filter | The InterestFilter with a prefix and optional regex filter used to match the name of an incoming Interest. This makes a copy of filter. |
| onInterest | When an Interest is received which matches the filter, this calls onInterest(prefix, interest, face, interestFilterId, filter). |
| face | The face which is passed to the onInterest callback. |
| void ndn::Node::unsetInterestFilter | ( | uint64_t | interestFilterId | ) |
Remove the interest filter entry which has the interestFilterId from the interest filter table.
This does not affect another interest filter with a different interestFilterId, even if it has the same prefix name. If there is no entry with the interestFilterId, do nothing.
| interestFilterId | The ID returned from setInterestFilter. |
1.8.9.1