update: use NFD RIB control command definitions from ndn-cxx

And make validateParameters() static

Change-Id: I981bf3c8d5ba7b2ef7ef8292de5ec54bb7cc0c3b
diff --git a/src/update/manager-base.hpp b/src/update/manager-base.hpp
index 557a015..db6ef62 100644
--- a/src/update/manager-base.hpp
+++ b/src/update/manager-base.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2022,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -22,16 +22,14 @@
 #ifndef NLSR_MANAGER_BASE_HPP
 #define NLSR_MANAGER_BASE_HPP
 
+#include "lsdb.hpp"
 #include "name-prefix-list.hpp"
 #include "test-access-control.hpp"
-#include "lsdb.hpp"
-#include "nfd-rib-commands.hpp"
-#include "prefix-update-commands.hpp"
 
 #include <ndn-cxx/face.hpp>
 #include <ndn-cxx/interest.hpp>
-#include <ndn-cxx/mgmt/nfd/control-command.hpp>
 #include <ndn-cxx/mgmt/dispatcher.hpp>
+#include <ndn-cxx/mgmt/nfd/control-command.hpp>
 #include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
 #include <ndn-cxx/mgmt/nfd/control-response.hpp>
 
@@ -56,19 +54,19 @@
     using std::runtime_error::runtime_error;
   };
 
+protected:
   ManagerBase(ndn::mgmt::Dispatcher& m_dispatcher, const std::string& module);
 
-protected:
-  /*! \brief generate the relative prefix for a handler by appending the verb name to the module name
+  /*! \brief Generate the relative prefix for a handler by appending the verb name to the module name.
    */
   ndn::PartialName
   makeRelPrefix(const std::string& verb) const;
 
 PUBLIC_WITH_TESTS_ELSE_PROTECTED:
-  /*! \brief validate the parameters for a given command
-    */
+  /*! \brief Validate the parameters for a given command.
+   */
   template<typename T>
-  bool
+  static bool
   validateParameters(const ndn::mgmt::ControlParameters& parameters)
   {
     const auto* castParams = dynamic_cast<const ndn::nfd::ControlParameters*>(&parameters);
diff --git a/src/update/nfd-rib-command-processor.cpp b/src/update/nfd-rib-command-processor.cpp
index 2570797..f4d191b 100644
--- a/src/update/nfd-rib-command-processor.cpp
+++ b/src/update/nfd-rib-command-processor.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -21,8 +21,7 @@
 
 #include "nfd-rib-command-processor.hpp"
 
-namespace nlsr {
-namespace update {
+namespace nlsr::update {
 
 NfdRibCommandProcessor::NfdRibCommandProcessor(ndn::mgmt::Dispatcher& dispatcher,
                                                NamePrefixList& namePrefixList,
@@ -31,14 +30,13 @@
 {
   m_dispatcher.addControlCommand<ndn::nfd::ControlParameters>(makeRelPrefix("register"),
     ndn::mgmt::makeAcceptAllAuthorization(),
-    std::bind(&NfdRibCommandProcessor::validateParameters<NfdRibRegisterCommand>, this, _1),
+    [] (const auto& p) { return validateParameters<ndn::nfd::RibRegisterCommand>(p); },
     std::bind(&NfdRibCommandProcessor::advertiseAndInsertPrefix, this, _1, _2, _3, _4));
 
   m_dispatcher.addControlCommand<ndn::nfd::ControlParameters>(makeRelPrefix("unregister"),
     ndn::mgmt::makeAcceptAllAuthorization(),
-    std::bind(&NfdRibCommandProcessor::validateParameters<NfdRibUnregisterCommand>, this, _1),
+    [] (const auto& p) { return validateParameters<ndn::nfd::RibUnregisterCommand>(p); },
     std::bind(&NfdRibCommandProcessor::withdrawAndRemovePrefix, this, _1, _2, _3, _4));
 }
 
-} // namespace update
-} // namespace nlsr
+} // namespace nlsr::update
diff --git a/src/update/nfd-rib-command-processor.hpp b/src/update/nfd-rib-command-processor.hpp
index 4b6ca5c..351e375 100644
--- a/src/update/nfd-rib-command-processor.hpp
+++ b/src/update/nfd-rib-command-processor.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  The University of Memphis,
+/*
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -17,20 +17,14 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
 
-#ifndef UPDATE_NFD_RIB_COMMAND_PROCESSOR_HPP
-#define UPDATE_NFD_RIB_COMMAND_PROCESSOR_HPP
+#ifndef NLSR_UPDATE_NFD_RIB_COMMAND_PROCESSOR_HPP
+#define NLSR_UPDATE_NFD_RIB_COMMAND_PROCESSOR_HPP
 
 #include "manager-base.hpp"
-#include "route/fib.hpp"
-#include "nfd-rib-commands.hpp"
 
-#include <ndn-cxx/encoding/tlv-nfd.hpp>
-
-
-namespace nlsr {
-namespace update {
+namespace nlsr::update {
 
 class NfdRibCommandProcessor : public CommandManagerBase
 {
@@ -40,7 +34,6 @@
                          Lsdb& lsdb);
 };
 
-} // namespace update
-} // namespace nlsr
+} // namespace nlsr::update
 
-#endif // UPDATE_NFD_RIB_COMMAND_PROCESSOR_HPP
+#endif // NLSR_UPDATE_NFD_RIB_COMMAND_PROCESSOR_HPP
diff --git a/src/update/nfd-rib-commands.cpp b/src/update/nfd-rib-commands.cpp
deleted file mode 100644
index fd2c2af..0000000
--- a/src/update/nfd-rib-commands.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  The University of Memphis,
- *                           Regents of the University of California,
- *                           Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "nfd-rib-commands.hpp"
-
-namespace nlsr {
-namespace update {
-
-NfdRibRegisterCommand::NfdRibRegisterCommand()
-  : ControlCommand("nlsr", "register")
-{
-  m_requestValidator.required(ndn::nfd::CONTROL_PARAMETER_NAME);
-  m_requestValidator.optional(ndn::nfd::CONTROL_PARAMETER_ORIGIN);
-}
-
-NfdRibUnregisterCommand::NfdRibUnregisterCommand()
-  : ControlCommand("nlsr", "unregister")
-{
-  m_requestValidator.required(ndn::nfd::CONTROL_PARAMETER_NAME);
-  m_requestValidator.optional(ndn::nfd::CONTROL_PARAMETER_ORIGIN);
-}
-
-} // namespace update
-} // namespace nlsr
diff --git a/src/update/nfd-rib-commands.hpp b/src/update/nfd-rib-commands.hpp
deleted file mode 100644
index b259b7e..0000000
--- a/src/update/nfd-rib-commands.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  The University of Memphis,
- *                           Regents of the University of California,
- *                           Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
-
-/*! \file
- * Define parameters for NFD RIB commands
- *
- * When validating an NFD RIB command, NLSR is only concerned with the
- * name in the command. However, a request is rejected if it has
- * unsolicited fields, so the origin, which is set by NFD's RIB, must
- * be considered optional. We consider these to be secure because they
- * are currently only received over the localhost prefix. These serve
- * to support NFD RIB to NLSR route readvertising.
- *
- * \sa NfdRibCommandProcessor
- * \sa nlsr::Nlsr::LOCALHOST_PREFIX
- * \sa nlsr::Nlsr::getDispatcher
- */
-
-#ifndef UPDATE_NFD_RIB_COMMANDS_HPP
-#define UPDATE_NFD_RIB_COMMANDS_HPP
-
-#include <ndn-cxx/mgmt/nfd/control-command.hpp>
-
-namespace nlsr {
-namespace update {
-
-class NfdRibRegisterCommand : public ndn::nfd::ControlCommand
-{
-public:
-  NfdRibRegisterCommand();
-};
-
-class NfdRibUnregisterCommand : public ndn::nfd::ControlCommand
-{
-public:
-  NfdRibUnregisterCommand();
-};
-
-} // namespace update
-} // namespace nlsr
-
-#endif // UPDATE_NFD_RIB_COMMANDS_HPP
diff --git a/src/update/prefix-update-processor.cpp b/src/update/prefix-update-processor.cpp
index c36b408..6edfae7 100644
--- a/src/update/prefix-update-processor.cpp
+++ b/src/update/prefix-update-processor.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2022,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -23,16 +23,15 @@
 #include "logger.hpp"
 #include "lsdb.hpp"
 #include "nlsr.hpp"
+#include "prefix-update-commands.hpp"
 
 #include <ndn-cxx/face.hpp>
 #include <ndn-cxx/mgmt/nfd/control-response.hpp>
 
 #include <boost/algorithm/string.hpp>
-#include <algorithm>
 #include <fstream>
 
-namespace nlsr {
-namespace update {
+namespace nlsr::update {
 
 INIT_LOGGER(update.PrefixUpdateProcessor);
 
@@ -67,14 +66,12 @@
 
   m_dispatcher.addControlCommand<ndn::nfd::ControlParameters>(makeRelPrefix("advertise"),
     makeAuthorization(),
-    std::bind(&PrefixUpdateProcessor::validateParameters<AdvertisePrefixCommand>,
-                this, _1),
+    [] (const auto& p) { return validateParameters<AdvertisePrefixCommand>(p); },
     std::bind(&PrefixUpdateProcessor::advertiseAndInsertPrefix, this, _1, _2, _3, _4));
 
   m_dispatcher.addControlCommand<ndn::nfd::ControlParameters>(makeRelPrefix("withdraw"),
     makeAuthorization(),
-    std::bind(&PrefixUpdateProcessor::validateParameters<WithdrawPrefixCommand>,
-                this, _1),
+    [] (const auto& p) { return validateParameters<WithdrawPrefixCommand>(p); },
     std::bind(&PrefixUpdateProcessor::withdrawAndRemovePrefix, this, _1, _2, _3, _4));
 }
 
@@ -193,5 +190,4 @@
   return addOrDeletePrefix(prefix, false);
 }
 
-} // namespace update
-} // namespace nlsr
+} // namespace nlsr::update
diff --git a/src/update/prefix-update-processor.hpp b/src/update/prefix-update-processor.hpp
index 1864d0f..9230f0b 100644
--- a/src/update/prefix-update-processor.hpp
+++ b/src/update/prefix-update-processor.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2022,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -23,14 +23,12 @@
 #define NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP
 
 #include "manager-base.hpp"
-#include "prefix-update-commands.hpp"
 
 #include <ndn-cxx/security/key-chain.hpp>
 
 #include <boost/property_tree/ptree.hpp>
 
-namespace nlsr {
-namespace update {
+namespace nlsr::update {
 
 using ConfigSection = boost::property_tree::ptree;
 
@@ -93,7 +91,6 @@
   const std::string& m_confFileNameDynamic;
 };
 
-} // namespace update
-} // namespace nlsr
+} // namespace nlsr::update
 
 #endif // NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP