In Face.registerPrefix, need to pass keyChain, signerName, etc. so that it can sign the Data packet with the ForwardingEntry.
diff --git a/ndn-cpp/node.hpp b/ndn-cpp/node.hpp
index 80d32a4..256e3aa 100644
--- a/ndn-cpp/node.hpp
+++ b/ndn-cpp/node.hpp
@@ -31,8 +31,14 @@
typedef func_lib::function<void
(const ptr_lib::shared_ptr<const Name>&, const ptr_lib::shared_ptr<const Interest>&, Transport&)> OnInterest;
+/**
+ * An OnRegisterFailed function object is used to report when registerPrefix fails.
+ */
+typedef func_lib::function<void(const ptr_lib::shared_ptr<const Name>&)> OnRegisterFailed;
+
class Face;
-
+class KeyChain;
+
class Node : public ElementListener {
public:
/**
@@ -58,10 +64,19 @@
* @param prefix A reference to a Name for the prefix to register. This copies the Name.
* @param onInterest A function object to call when a matching interest is received. This copies the function object, so you may need to
* use func_lib::ref() as appropriate.
+ * @param 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.
+ * @param keyChain The KeyChain object whose signData is called to sign the Data packet with the ForwardingEntry to register the prefix.
+ * @param signerName The signing identity or certificate name, depending on byKeyName. This is used to sign the Data packet
+ * with the ForwardingEntry to register the prefix.This copies the function object, so you may need to use func_lib::ref() as appropriate.
+ * @param byKeyName If true, the signerName is the key name, otherwise it is the certificate name. If omitted, the default is true.
* @param flags The flags for finer control of which interests are forward to the application.
+ * @param wireFormat A WireFormat object used to encode the input. If omitted, use WireFormat getDefaultWireFormat().
*/
void
- registerPrefix(const Name& prefix, const OnInterest& onInterest, int flags);
+ registerPrefix
+ (const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, KeyChain &keyChain,
+ const Name& signerName, bool byKeyName, int flags, WireFormat& wireFormat);
/**
* Process any data to receive. For each element received, call onReceivedElement.
@@ -188,15 +203,22 @@
class Info {
public:
- Info(Node *node, const Name& prefix, const OnInterest& onInterest, int flags)
- : node_(*node), prefix_(prefix), onInterest_(onInterest), flags_(flags)
+ Info(Node *node, const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed,
+ KeyChain &keyChain, const Name& signerName, bool byKeyName, int flags, WireFormat& wireFormat)
+ : node_(*node), prefix_(new Name(prefix)), onInterest_(onInterest), onRegisterFailed_(onRegisterFailed),
+ keyChain_(keyChain), signerName_(new Name(signerName)), byKeyName_(byKeyName), flags_(flags), wireFormat_(wireFormat)
{
}
Node& node_;
- Name prefix_;
+ ptr_lib::shared_ptr<const Name> prefix_;
const OnInterest onInterest_;
+ const OnRegisterFailed onRegisterFailed_;
+ KeyChain &keyChain_;
+ ptr_lib::shared_ptr<const Name> signerName_;
+ bool byKeyName_;
int flags_;
+ WireFormat& wireFormat_;
};
private:
@@ -210,7 +232,7 @@
* @return The index in pit_ of the pit entry, or -1 if not found.
*/
int
- getEntryIndexForExpressedInterest(const Name& name);
+ getEntryIndexForExpressedInterest(const Name& name);
/**
* Find the first entry from the registeredPrefixTable_ where the entry prefix is the longest that matches name.
@@ -219,15 +241,22 @@
*/
PrefixEntry*
getEntryForRegisteredPrefix(const Name& name);
-
+
/**
* Do the work of registerPrefix once we know we are connected with an ndndId_.
* @param prefix
* @param onInterest
+ * @param onRegisterFailed
+ * @param keyChain
+ * @param signerName
+ * @param byKeyName
* @param flags
- */
+ * @param wireFormat
+ */
void
- registerPrefixHelper(const Name& prefix, const OnInterest& onInterest, int flags);
+ registerPrefixHelper
+ (const ptr_lib::shared_ptr<const Name>& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed,
+ KeyChain &keyChain, const ptr_lib::shared_ptr<const Name>& signerName, bool byKeyName, int flags, WireFormat& wireFormat);
ptr_lib::shared_ptr<Transport> transport_;
ptr_lib::shared_ptr<const Transport::ConnectionInfo> connectionInfo_;