nlsr: Add dispatcher to NLSR class

refs: #3930

Change-Id: I69d3a1a87558118ea25258f08f7441e0d7ebe73d
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 4cde488..fbd067b 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -71,6 +71,7 @@
                             m_keyChain,
                             m_certificateCache,
                             m_certStore)
+  , m_dispatcher(m_nlsrFace, m_keyChain, m_signingInfo)
   , m_faceMonitor(m_nlsrFace)
   , m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
 {
@@ -197,6 +198,12 @@
   _LOG_DEBUG("Default NLSR identity: " << m_signingInfo.getSignerName());
   setInfoInterestFilter();
   setLsaInterestFilter();
+  try {
+    m_dispatcher.addTopPrefix(LOCALHOST_PREFIX, true, m_signingInfo);
+  }
+  catch (const std::exception& e) {
+    _LOG_ERROR("Error setting top-level prefix in dispatcher: " << e.what() << "\n");
+  }
 
   // Set event intervals
   setFirstHelloInterval(m_confParam.getFirstHelloInterval());
diff --git a/src/nlsr.hpp b/src/nlsr.hpp
index cb2ff51..8080485 100644
--- a/src/nlsr.hpp
+++ b/src/nlsr.hpp
@@ -31,6 +31,7 @@
 #include <ndn-cxx/util/scheduler.hpp>
 #include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
 #include <ndn-cxx/mgmt/nfd/face-monitor.hpp>
+#include <ndn-cxx/mgmt/dispatcher.hpp>
 
 #include "adjacency-list.hpp"
 #include "common.hpp"
@@ -288,6 +289,12 @@
     return m_prefixUpdateProcessor;
   }
 
+  ndn::mgmt::Dispatcher&
+  getDispatcher()
+  {
+    return m_dispatcher;
+  }
+
   void
   createFace(const std::string& faceUri,
              const CommandSucceedCallback& onSuccess,
@@ -385,6 +392,7 @@
   ndn::security::SigningInfo m_signingInfo;
   ndn::Name m_defaultCertName;
   update::PrefixUpdateProcessor m_prefixUpdateProcessor;
+  ndn::mgmt::Dispatcher m_dispatcher;
 
   ndn::nfd::FaceMonitor m_faceMonitor;