Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Face: Added static inline method getMaxNdnPacketSize(). Note that exp…
Browse files Browse the repository at this point in the history
…ressInterest can throw an exception if exceeded. Refs #1921.
  • Loading branch information
jefft0 committed Mar 10, 2015
1 parent 69c757c commit 35a491e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/ndn-cpp/face.hpp
Expand Up @@ -93,6 +93,8 @@ class Face {
* This copies the function object, so you may need to use func_lib::ref() as appropriate.
* @param wireFormat A WireFormat object used to encode the message. If omitted, use WireFormat getDefaultWireFormat().
* @return The pending interest ID which can be used with removePendingInterest.
* @throw runtime_error If the encoded interest size exceeds
* getMaxNdnPacketSize().
*/
uint64_t
expressInterest
Expand All @@ -110,6 +112,8 @@ class Face {
* This copies the function object, so you may need to use func_lib::ref() as appropriate.
* @param wireFormat A WireFormat object used to encode the message. If omitted, use WireFormat getDefaultWireFormat().
* @return The pending interest ID which can be used with removePendingInterest.
* @throw runtime_error If the encoded interest size exceeds
* getMaxNdnPacketSize().
*/
uint64_t
expressInterest
Expand All @@ -126,6 +130,7 @@ class Face {
* This copies the function object, so you may need to use func_lib::ref() as appropriate.
* @param wireFormat A WireFormat object used to encode the message. If omitted, use WireFormat getDefaultWireFormat().
* @return The pending interest ID which can be used with removePendingInterest.
* @throw runtime_error If the encoded interest size exceeds getMaxNdnPacketSize().
*/
uint64_t
expressInterest
Expand Down Expand Up @@ -242,6 +247,16 @@ class Face {
void
shutdown();

/**
* 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()].
* @return The maximum NDN packet size.
*/
static size_t
getMaxNdnPacketSize() { return MAX_NDN_PACKET_SIZE; }

private:
Node *node_;
KeyChain* commandKeyChain_;
Expand Down
12 changes: 12 additions & 0 deletions src/node.hpp
Expand Up @@ -54,6 +54,8 @@ class Node : public ElementListener {
* This copies the function object, so you may need to use func_lib::ref() as appropriate.
* @param wireFormat A WireFormat object used to encode the message.
* @return The pending interest ID which can be used with removePendingInterest.
* @throw runtime_error If the encoded interest size exceeds
* getMaxNdnPacketSize().
*/
uint64_t
expressInterest(const Interest& interest, const OnData& onData, const OnTimeout& onTimeout, WireFormat& wireFormat);
Expand Down Expand Up @@ -143,6 +145,16 @@ class Node : public ElementListener {
void
shutdown();

/**
* 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()].
* @return The maximum NDN packet size.
*/
static size_t
getMaxNdnPacketSize() { return MAX_NDN_PACKET_SIZE; }

private:
class PendingInterest {
public:
Expand Down

0 comments on commit 35a491e

Please sign in to comment.