face: drop direct FIB management

refs #2533

Change-Id: I33c1c8873498048970f7a485be9f6e021b286c8b
diff --git a/src/detail/face-impl.hpp b/src/detail/face-impl.hpp
index c13906a..cb5b3bc 100644
--- a/src/detail/face-impl.hpp
+++ b/src/detail/face-impl.hpp
@@ -196,40 +196,17 @@
   {
     using namespace nfd;
 
-    typedef void (Controller::*Registrator)
-      (const ControlParameters&,
-       const Controller::CommandSucceedCallback&,
-       const Controller::CommandFailCallback&,
-       const CommandOptions&);
+    ControlParameters params;
+    params.setName(prefix);
+    params.setFlags(flags);
 
-    ControlParameters registerParameters, unregisterParameters;
-    registerParameters.setName(prefix);
-    unregisterParameters.setName(prefix);
+    auto prefixToRegister = make_shared<RegisteredPrefix>(prefix, filter, options);
 
-    Registrator registrator, unregistrator;
-    if (!m_face.m_isDirectNfdFibManagementRequested) {
-      registrator = static_cast<Registrator>(&Controller::start<RibRegisterCommand>);
-      unregistrator = static_cast<Registrator>(&Controller::start<RibUnregisterCommand>);
-
-      registerParameters.setFlags(flags);
-    }
-    else {
-      registrator = static_cast<Registrator>(&Controller::start<FibAddNextHopCommand>);
-      unregistrator = static_cast<Registrator>(&Controller::start<FibRemoveNextHopCommand>);
-    }
-
-    RegisteredPrefix::Unregistrator boundUnregistrator =
-        bind(unregistrator, m_face.m_nfdController.get(), unregisterParameters, _1, _2,
-                  options);
-
-    shared_ptr<RegisteredPrefix> prefixToRegister =
-      make_shared<RegisteredPrefix>(prefix, filter, boundUnregistrator);
-
-    ((*m_face.m_nfdController).*registrator)(registerParameters,
-                                             bind(&Impl::afterPrefixRegistered, this,
-                                                  prefixToRegister, onSuccess),
-                                             bind(onFailure, prefixToRegister->getPrefix(), _2),
-                                             options);
+    m_face.m_nfdController->start<RibRegisterCommand>(params,
+                                                      bind(&Impl::afterPrefixRegistered, this,
+                                                           prefixToRegister, onSuccess),
+                                                      bind(onFailure, prefixToRegister->getPrefix(), _2),
+                                                      options);
 
     return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get());
   }
@@ -255,22 +232,29 @@
                         const UnregisterPrefixSuccessCallback& onSuccess,
                         const UnregisterPrefixFailureCallback& onFailure)
   {
-    RegisteredPrefixTable::iterator i = std::find_if(m_registeredPrefixTable.begin(),
-                                                     m_registeredPrefixTable.end(),
-                                                     MatchRegisteredPrefixId(registeredPrefixId));
-    if (i != m_registeredPrefixTable.end())
-      {
-        const shared_ptr<InterestFilterRecord>& filter = (*i)->getFilter();
-        if (static_cast<bool>(filter))
-          {
-            // it was a combined operation
-            m_interestFilterTable.remove(filter);
-          }
-        (*i)->unregister(bind(&Impl::finalizeUnregisterPrefix, this, i, onSuccess),
-                         bind(onFailure, _2));
+    using namespace nfd;
+    auto i = std::find_if(m_registeredPrefixTable.begin(),
+                          m_registeredPrefixTable.end(),
+                          MatchRegisteredPrefixId(registeredPrefixId));
+    if (i != m_registeredPrefixTable.end()) {
+      RegisteredPrefix& record = **i;
+
+      const shared_ptr<InterestFilterRecord>& filter = record.getFilter();
+
+      if (filter != nullptr) {
+        // it was a combined operation
+        m_interestFilterTable.remove(filter);
       }
+
+      ControlParameters params;
+      params.setName(record.getPrefix());
+      m_face.m_nfdController->start<RibUnregisterCommand>(params,
+                                                          bind(&Impl::finalizeUnregisterPrefix, this, i, onSuccess),
+                                                          bind(onFailure, _2),
+                                                          record.getCommandOptions());
+    }
     else {
-      if (static_cast<bool>(onFailure)) {
+      if (onFailure != nullptr) {
         onFailure("Unrecognized PrefixId");
       }
     }
diff --git a/src/detail/registered-prefix.hpp b/src/detail/registered-prefix.hpp
index cfa3983..6e9beb4 100644
--- a/src/detail/registered-prefix.hpp
+++ b/src/detail/registered-prefix.hpp
@@ -27,13 +27,11 @@
 #include "../interest.hpp"
 
 #include "interest-filter-record.hpp"
+#include "management/nfd-command-options.hpp"
+#include "management/nfd-control-parameters.hpp"
 
 namespace ndn {
 
-namespace nfd {
-class ControlParameters;
-}
-
 class RegisteredPrefix : noncopyable
 {
 public:
@@ -45,23 +43,12 @@
    */
   typedef function<void(uint32_t/*code*/,const std::string&/*reason*/)> FailureCallback;
 
-  /// @brief Function that should be called to unregister prefix
-  typedef function<void(const SuccessCallback& onSuccess,
-                        const FailureCallback& onFailure)> Unregistrator;
-
-  RegisteredPrefix(const Name& prefix,
-                   const Unregistrator& unregistrator)
-    : m_prefix(prefix)
-    , m_unregistrator(unregistrator)
-  {
-  }
-
   RegisteredPrefix(const Name& prefix,
                    const shared_ptr<InterestFilterRecord>& filter,
-                   const Unregistrator& unregistrator)
+                   const nfd::CommandOptions& options)
     : m_prefix(prefix)
     , m_filter(filter)
-    , m_unregistrator(unregistrator)
+    , m_options(options)
   {
   }
 
@@ -77,19 +64,16 @@
     return m_filter;
   }
 
-  void
-  unregister(const SuccessCallback& onSuccess,
-             const FailureCallback& onFailure)
+  const nfd::CommandOptions&
+  getCommandOptions() const
   {
-    if (static_cast<bool>(m_unregistrator)) {
-      m_unregistrator(onSuccess, onFailure);
-    }
+    return m_options;
   }
 
 private:
   Name m_prefix;
   shared_ptr<InterestFilterRecord> m_filter;
-  Unregistrator m_unregistrator;
+  nfd::CommandOptions m_options;
 };
 
 /**