rib+tools: delete NRD

refs #3570

Change-Id: I9a6e8eb6c74ea5e09a2e724805f07ca4e58af51c
diff --git a/daemon/main.cpp b/daemon/main.cpp
index 2dd09e8..0701ff8 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "nfd.hpp"
-#include "rib/nrd.hpp"
+#include "rib/service.hpp"
 
 #include "version.hpp"
 #include "core/global-io.hpp"
@@ -120,30 +120,30 @@
     std::atomic_int retval(0);
 
     boost::asio::io_service* const mainIo = &getGlobalIoService();
-    boost::asio::io_service* nrdIo = nullptr;
+    boost::asio::io_service* ribIo = nullptr;
 
     // Mutex and conditional variable to implement synchronization between main and RIB manager
     // threads:
-    // - to block main thread until RIB manager thread starts and initializes nrdIo (to allow
+    // - to block main thread until RIB manager thread starts and initializes ribIo (to allow
     //   stopping it later)
     std::mutex m;
     std::condition_variable cv;
 
     std::string configFile = this->m_configFile; // c++11 lambda cannot capture member variables
-    boost::thread nrdThread([configFile, &retval, &nrdIo, mainIo, &cv, &m] {
+    boost::thread ribThread([configFile, &retval, &ribIo, mainIo, &cv, &m] {
         {
           std::lock_guard<std::mutex> lock(m);
-          nrdIo = &getGlobalIoService();
-          BOOST_ASSERT(nrdIo != mainIo);
+          ribIo = &getGlobalIoService();
+          BOOST_ASSERT(ribIo != mainIo);
         }
-        cv.notify_all(); // notify that nrdIo has been assigned
+        cv.notify_all(); // notify that ribIo has been assigned
 
         try {
-          ndn::KeyChain nrdKeyChain;
+          ndn::KeyChain ribKeyChain;
           // must be created inside a separate thread
-          rib::Nrd nrd(configFile, nrdKeyChain);
-          nrd.initialize();
-          getGlobalIoService().run(); // nrdIo is not thread-safe to use here
+          rib::Service ribService(configFile, ribKeyChain);
+          ribService.initialize();
+          getGlobalIoService().run(); // ribIo is not thread-safe to use here
         }
         catch (const std::exception& e) {
           NFD_LOG_FATAL(e.what());
@@ -153,15 +153,15 @@
 
         {
           std::lock_guard<std::mutex> lock(m);
-          nrdIo = nullptr;
+          ribIo = nullptr;
         }
       });
 
     {
-      // Wait to guarantee that nrdIo is properly initialized, so it can be used to terminate
+      // Wait to guarantee that ribIo is properly initialized, so it can be used to terminate
       // RIB manager thread.
       std::unique_lock<std::mutex> lock(m);
-      cv.wait(lock, [&nrdIo] { return nrdIo != nullptr; });
+      cv.wait(lock, [&ribIo] { return ribIo != nullptr; });
     }
 
     try {
@@ -177,14 +177,14 @@
     }
 
     {
-      // nrdIo is guaranteed to be alive at this point
+      // ribIo is guaranteed to be alive at this point
       std::lock_guard<std::mutex> lock(m);
-      if (nrdIo != nullptr) {
-        nrdIo->stop();
-        nrdIo = nullptr;
+      if (ribIo != nullptr) {
+        ribIo->stop();
+        ribIo = nullptr;
       }
     }
-    nrdThread.join();
+    ribThread.join();
 
     return retval;
   }
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index fedfd8a..e581095 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -164,8 +164,8 @@
      ControlParameters()
        .setName(Name(topPrefix).append(MGMT_MODULE_NAME))
        .setFaceId(0),
-     bind(&RibManager::onNrdCommandPrefixAddNextHopSuccess, this, cref(topPrefix), _1),
-     bind(&RibManager::onNrdCommandPrefixAddNextHopError, this, cref(topPrefix), _2));
+     bind(&RibManager::onCommandPrefixAddNextHopSuccess, this, cref(topPrefix), _1),
+     bind(&RibManager::onCommandPrefixAddNextHopError, this, cref(topPrefix), _2));
 
   // add top prefix to the dispatcher
   m_addTopPrefix(topPrefix);
@@ -216,8 +216,8 @@
         .setRoute(route);
 
   m_rib.beginApplyUpdate(update,
-                                bind(&RibManager::onRibUpdateSuccess, this, update),
-                                bind(&RibManager::onRibUpdateFailure, this, update, _1, _2));
+                         bind(&RibManager::onRibUpdateSuccess, this, update),
+                         bind(&RibManager::onRibUpdateFailure, this, update, _1, _2));
 
   m_registeredFaces.insert(route.faceId);
 }
@@ -245,8 +245,8 @@
         .setRoute(route);
 
   m_rib.beginApplyUpdate(update,
-                                bind(&RibManager::onRibUpdateSuccess, this, update),
-                                bind(&RibManager::onRibUpdateFailure, this, update, _1, _2));
+                         bind(&RibManager::onRibUpdateSuccess, this, update),
+                         bind(&RibManager::onRibUpdateFailure, this, update, _1, _2));
 }
 
 void
@@ -425,8 +425,8 @@
 }
 
 void
-RibManager::onNrdCommandPrefixAddNextHopSuccess(const Name& prefix,
-                                                const ndn::nfd::ControlParameters& result)
+RibManager::onCommandPrefixAddNextHopSuccess(const Name& prefix,
+                                             const ndn::nfd::ControlParameters& result)
 {
   NFD_LOG_DEBUG("Successfully registered " + prefix.toUri() + " with NFD");
 
@@ -443,7 +443,7 @@
 }
 
 void
-RibManager::onNrdCommandPrefixAddNextHopError(const Name& name, const std::string& msg)
+RibManager::onCommandPrefixAddNextHopError(const Name& name, const std::string& msg)
 {
   BOOST_THROW_EXCEPTION(Error("Error in setting interest filter (" + name.toUri() + "): " + msg));
 }
diff --git a/rib/rib-manager.hpp b/rib/rib-manager.hpp
index 7c7ff00..55ee394 100644
--- a/rib/rib-manager.hpp
+++ b/rib/rib-manager.hpp
@@ -165,11 +165,11 @@
 
 private:
   void
-  onNrdCommandPrefixAddNextHopSuccess(const Name& prefix,
-                                      const ndn::nfd::ControlParameters& result);
+  onCommandPrefixAddNextHopSuccess(const Name& prefix,
+                                   const ndn::nfd::ControlParameters& result);
 
   void
-  onNrdCommandPrefixAddNextHopError(const Name& name, const std::string& msg);
+  onCommandPrefixAddNextHopError(const Name& name, const std::string& msg);
 
   void
   onControlHeaderSuccess();
diff --git a/rib/nrd.cpp b/rib/service.cpp
similarity index 93%
rename from rib/nrd.cpp
rename to rib/service.cpp
index d723a3f..3b3798f 100644
--- a/rib/nrd.cpp
+++ b/rib/service.cpp
@@ -23,7 +23,7 @@
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "nrd.hpp"
+#include "service.hpp"
 
 #include "rib-manager.hpp"
 #include "core/config-file.hpp"
@@ -40,19 +40,19 @@
 
 static const std::string INTERNAL_CONFIG = "internal://nfd.conf";
 
-Nrd::Nrd(const std::string& configFile, ndn::KeyChain& keyChain)
+Service::Service(const std::string& configFile, ndn::KeyChain& keyChain)
   : m_configFile(configFile)
   , m_keyChain(keyChain)
 {
 }
 
-Nrd::Nrd(const ConfigSection& config, ndn::KeyChain& keyChain)
+Service::Service(const ConfigSection& config, ndn::KeyChain& keyChain)
   : m_configSection(config)
   , m_keyChain(keyChain)
 {
 }
 
-Nrd::~Nrd()
+Service::~Service()
 {
   // It is necessary to explicitly define the destructor, because some member variables
   // (e.g., unique_ptr<RibManager>) are forward-declared, but implicitly declared destructor
@@ -60,7 +60,7 @@
 }
 
 void
-Nrd::initialize()
+Service::initialize()
 {
   m_face.reset(new ndn::Face(getLocalNfdTransport(), getGlobalIoService(), m_keyChain));
   m_dispatcher.reset(new ndn::mgmt::Dispatcher(*m_face, m_keyChain));
@@ -77,7 +77,7 @@
         // do nothing
       }
       else {
-        // missing NRD section
+        // missing "rib" section handler
         ConfigFile::throwErrorOnUnknownSection(filename, sectionName, section, isDryRun);
       }
     });
@@ -98,7 +98,7 @@
 }
 
 void
-Nrd::initializeLogging()
+Service::initializeLogging()
 {
   ConfigFile config(&ConfigFile::ignoreUnknownSection);
   LoggerFactory::getInstance().setConfigFile(config);
@@ -114,7 +114,7 @@
 }
 
 shared_ptr<ndn::Transport>
-Nrd::getLocalNfdTransport()
+Service::getLocalNfdTransport()
 {
   ConfigSection config;
 
diff --git a/rib/nrd.hpp b/rib/service.hpp
similarity index 69%
rename from rib/nrd.hpp
rename to rib/service.hpp
index 0d8743d..5cb60d9 100644
--- a/rib/nrd.hpp
+++ b/rib/service.hpp
@@ -23,8 +23,8 @@
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef NFD_RIB_NRD_HPP
-#define NFD_RIB_NRD_HPP
+#ifndef NFD_RIB_SERVICE_HPP
+#define NFD_RIB_SERVICE_HPP
 
 #include "common.hpp"
 #include "core/config-file.hpp"
@@ -40,10 +40,9 @@
 class RibManager;
 
 /**
- * \brief Class representing NRD (NFD RIB Manager) instance
- * This class can be used to initialize all components of NRD
+ * \brief initializes and executes NFD-RIB service thread
  */
-class Nrd : noncopyable
+class Service : noncopyable
 {
 public:
   class Error : public std::runtime_error
@@ -57,27 +56,31 @@
   };
 
   /**
-   * \brief Create NRD instance using absolute or relative path to \p configFile
+   * \brief create NFD-RIB service
+   * \param configFile absolute or relative path of configuration file
+   * \param keyChain the KeyChain
    */
-  Nrd(const std::string& configFile, ndn::KeyChain& keyChain);
+  Service(const std::string& configFile, ndn::KeyChain& keyChain);
 
   /**
-   * \brief Create NRD instance using a parsed ConfigSection \p config
-   * This version of the constructor is more appropriate for integrated environments,
-   * such as NS-3 or android.
-   * \note When using this version of the constructor, error messages will include
-   *      "internal://nfd.conf" when referring to configuration errors.
+   * \brief create NFD-RIB service
+   * \param config parsed configuration section
+   * \param keyChain the KeyChain
+   * \note This constructor overload is more appropriate for integrated environments,
+   *       such as NS-3 or android. Error messages related to configuration file
+   *       will use "internal://nfd.conf" as configuration filename.
    */
-  Nrd(const ConfigSection& config, ndn::KeyChain& keyChain);
+  Service(const ConfigSection& config, ndn::KeyChain& keyChain);
 
   /**
    * \brief Destructor
    */
-  ~Nrd();
+  ~Service();
 
   /**
-   * \brief Perform initialization of NFD instance
-   * After initialization, NFD instance can be started by invoking run on globalIoService
+   * \brief Perform initialization of NFD-RIB instance
+   *
+   * After initialization, NFD-RIB instance can be started by running the global io_service
    */
   void
   initialize();
@@ -88,7 +91,7 @@
 
   /**
    * \brief Look into the config file and construct appropriate transport to communicate with NFD
-   * If NRD instance was initialized with config file, INFO format is assumed
+   * If NFD-RIB instance was initialized with config file, INFO format is assumed
    */
   shared_ptr<ndn::Transport>
   getLocalNfdTransport();
@@ -106,4 +109,4 @@
 } // namespace rib
 } // namespace nfd
 
-#endif // NFD_RIB_NRD_HPP
+#endif // NFD_RIB_SERVICE_HPP
diff --git a/tools/nrd.sh b/tools/nrd.sh
deleted file mode 100644
index 52e7112..0000000
--- a/tools/nrd.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!@BASH@
-
-echo "NDN RIB Management Daemon does not need to be started separately anymore"
-sleep 10
-exit 0