Added preliminary code for registerPrefix.
diff --git a/ndn-cpp/node.cpp b/ndn-cpp/node.cpp
index 5bee365..1461dbf 100644
--- a/ndn-cpp/node.cpp
+++ b/ndn-cpp/node.cpp
@@ -6,7 +6,6 @@
 #include <sys/time.h>
 #include "encoding/binary-xml-decoder.hpp"
 #include "c/encoding/binary-xml.h"
-#include "data.hpp"
 #include "node.hpp"
 
 using namespace std;
@@ -21,54 +20,23 @@
   gettimeofday(&t, NULL);
   return t.tv_sec * 1000.0 + t.tv_usec / 1000.0;
 }
-  
-Node::PitEntry::PitEntry(const ptr_lib::shared_ptr<const Interest> &interest, const OnData &onData, const OnTimeout &onTimeout)
-: interest_(interest), onData_(onData), onTimeout_(onTimeout)
-{
-  // Set up timeoutTime_.
-  if (interest_->getInterestLifetimeMilliseconds() >= 0.0)
-    timeoutTimeMilliseconds_ = getNowMilliseconds() + interest_->getInterestLifetimeMilliseconds();
-  else
-    // No timeout.
-    timeoutTimeMilliseconds_ = -1.0;
-  
-  // Set up interestStruct_.
-  // TODO: Doesn't this belong in the Interest class?
-  nameComponents_.reserve(interest_->getName().getComponentCount());
-  excludeEntries_.reserve(interest_->getExclude().getEntryCount());
-  ndn_Interest_init
-    (&interestStruct_, &nameComponents_[0], nameComponents_.capacity(), &excludeEntries_[0], excludeEntries_.capacity());
-  interest_->get(interestStruct_);  
-}
 
-bool Node::PitEntry::checkTimeout(Node *parent, double nowMilliseconds)
+void Node::construct()
 {
-  if (timeoutTimeMilliseconds_ >= 0.0 && nowMilliseconds >= timeoutTimeMilliseconds_) {
-    if (onTimeout_) {
-      // Ignore all exceptions.
-      try {
-        onTimeout_(interest_);
-      }
-      catch (...) { }
-    }
-    
-    return true;
-  }
-  else
-    return false;
+  ndndIdFetcherInterest_ = Interest(Name("/%C1.M.S.localhost/%C1.M.SRV/ndnd/KEY"), 4000.0);
 }
 
 void Node::expressInterest(const Interest &interest, const OnData &onData, const OnTimeout &onTimeout)
 {
+  // TODO: Properly check if we are already connected to the expected host.
+  if (!transport_->getIsConnected())
+    transport_->connect(*connectionInfo_, *this);
+  
   shared_ptr<PitEntry> pitEntry(new PitEntry(shared_ptr<const Interest>(new Interest(interest)), onData, onTimeout));
   pit_.push_back(pitEntry);
   
   shared_ptr<vector<unsigned char> > encoding = pitEntry->getInterest()->wireEncode();  
   
-  // TODO: Properly check if we are already connected to the expected host.
-  if (!transport_->getIsConnected())
-    transport_->connect(*connectionInfo_, *this);
-  
   transport_->send(*encoding);
 }
 
@@ -84,6 +52,38 @@
     expressInterest(Interest(name, 4000.0), onData, onTimeout);
 }
 
+void Node::registerPrefix(const Name &prefix, const OnInterest &onInterest, int flags)
+{
+  if (ndndId_.size() == 0) {
+    // First fetch the ndndId of the connected hub.
+    NdndIdFetcher fetcher(make_shared<NdndIdFetcher::Info>(this, prefix, onInterest, flags));
+    // It is OK for func_lib::function make a copy of the function object because the Info is in a shared_ptr.
+    expressInterest(ndndIdFetcherInterest_, fetcher, fetcher);
+  }
+  else
+    registerPrefixHelper(prefix, onInterest, flags);
+}
+
+void Node::NdndIdFetcher::operator()(const ptr_lib::shared_ptr<const Interest> &interest, const ptr_lib::shared_ptr<Data> &ndndIdData)
+{
+  if (ndndIdData->getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0) {
+    // Set the ndndId_ and continue.
+    info_->node_.ndndId_ = ndndIdData->getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest();
+    info_->node_.registerPrefixHelper(info_->prefix_, info_->onInterest_, info_->flags_);
+  }
+  // TODO: else need to log not getting the ndndId.
+}
+
+void Node::NdndIdFetcher::operator()(const ptr_lib::shared_ptr<const Interest> &timedOutInterest)
+{
+  // TODO: Log the timeout.
+}
+
+void Node::registerPrefixHelper(const Name &prefix, const OnInterest &onInterest, int flags)
+{
+  throw logic_error("need to finish implementing registerPrefix");
+}
+
 void Node::processEvents()
 {
   transport_->processEvents();
@@ -146,5 +146,41 @@
     
 	return iResult;
 }
+  
+Node::PitEntry::PitEntry(const ptr_lib::shared_ptr<const Interest> &interest, const OnData &onData, const OnTimeout &onTimeout)
+: interest_(interest), onData_(onData), onTimeout_(onTimeout)
+{
+  // Set up timeoutTime_.
+  if (interest_->getInterestLifetimeMilliseconds() >= 0.0)
+    timeoutTimeMilliseconds_ = getNowMilliseconds() + interest_->getInterestLifetimeMilliseconds();
+  else
+    // No timeout.
+    timeoutTimeMilliseconds_ = -1.0;
+  
+  // Set up interestStruct_.
+  // TODO: Doesn't this belong in the Interest class?
+  nameComponents_.reserve(interest_->getName().getComponentCount());
+  excludeEntries_.reserve(interest_->getExclude().getEntryCount());
+  ndn_Interest_init
+    (&interestStruct_, &nameComponents_[0], nameComponents_.capacity(), &excludeEntries_[0], excludeEntries_.capacity());
+  interest_->get(interestStruct_);  
+}
+
+bool Node::PitEntry::checkTimeout(Node *parent, double nowMilliseconds)
+{
+  if (timeoutTimeMilliseconds_ >= 0.0 && nowMilliseconds >= timeoutTimeMilliseconds_) {
+    if (onTimeout_) {
+      // Ignore all exceptions.
+      try {
+        onTimeout_(interest_);
+      }
+      catch (...) { }
+    }
+    
+    return true;
+  }
+  else
+    return false;
+}
 
 }