core: move nfd-specific files to daemon/
Refs: #4922
Change-Id: I2243dbb87c63f9cbaf7d7051d7a0d4bca2f9fdb5
diff --git a/daemon/mgmt/command-authenticator.cpp b/daemon/mgmt/command-authenticator.cpp
index 913c74f..c146962 100644
--- a/daemon/mgmt/command-authenticator.cpp
+++ b/daemon/mgmt/command-authenticator.cpp
@@ -24,7 +24,7 @@
*/
#include "command-authenticator.hpp"
-#include "core/logger.hpp"
+#include "common/logger.hpp"
#include <ndn-cxx/tag.hpp>
#include <ndn-cxx/security/v2/certificate-fetcher-offline.hpp>
diff --git a/daemon/mgmt/command-authenticator.hpp b/daemon/mgmt/command-authenticator.hpp
index 5589187..9f136a8 100644
--- a/daemon/mgmt/command-authenticator.hpp
+++ b/daemon/mgmt/command-authenticator.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,7 +26,7 @@
#ifndef NFD_DAEMON_MGMT_COMMAND_AUTHENTICATOR_HPP
#define NFD_DAEMON_MGMT_COMMAND_AUTHENTICATOR_HPP
-#include "core/config-file.hpp"
+#include "common/config-file.hpp"
#include <ndn-cxx/mgmt/dispatcher.hpp>
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index b7b22f2..9b36410 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -25,7 +25,7 @@
#include "face-manager.hpp"
-#include "core/logger.hpp"
+#include "common/logger.hpp"
#include "face/generic-link-service.hpp"
#include "face/protocol-factory.hpp"
#include "fw/face-table.hpp"
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index 8fef3a3..1f0d173 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -25,7 +25,7 @@
#include "fib-manager.hpp"
-#include "core/logger.hpp"
+#include "common/logger.hpp"
#include "fw/face-table.hpp"
#include "table/fib.hpp"
@@ -66,7 +66,7 @@
NFD_LOG_DEBUG("fib/add-nexthop(" << prefix << ',' << faceId << ',' << cost <<
"): FAIL prefix-too-long");
return done(ControlResponse(414, "FIB entry prefix cannot exceed " +
- ndn::to_string(Fib::getMaxDepth()) + " components"));
+ to_string(Fib::getMaxDepth()) + " components"));
}
Face* face = m_faceTable.get(faceId);
diff --git a/daemon/mgmt/general-config-section.cpp b/daemon/mgmt/general-config-section.cpp
index 732074b..de9c611 100644
--- a/daemon/mgmt/general-config-section.cpp
+++ b/daemon/mgmt/general-config-section.cpp
@@ -24,7 +24,7 @@
*/
#include "general-config-section.hpp"
-#include "core/privilege-helper.hpp"
+#include "common/privilege-helper.hpp"
namespace nfd {
namespace general {
diff --git a/daemon/mgmt/general-config-section.hpp b/daemon/mgmt/general-config-section.hpp
index a70bc48..cd9089d 100644
--- a/daemon/mgmt/general-config-section.hpp
+++ b/daemon/mgmt/general-config-section.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,10 +23,10 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NFD_MGMT_GENERAL_CONFIG_SECTION_HPP
-#define NFD_MGMT_GENERAL_CONFIG_SECTION_HPP
+#ifndef NFD_DAEMON_MGMT_GENERAL_CONFIG_SECTION_HPP
+#define NFD_DAEMON_MGMT_GENERAL_CONFIG_SECTION_HPP
-#include "core/config-file.hpp"
+#include "common/config-file.hpp"
namespace nfd {
namespace general {
@@ -37,4 +37,4 @@
} // namespace general
} // namespace nfd
-#endif // NFD_MGMT_GENERAL_CONFIG_SECTION_HPP
+#endif // NFD_DAEMON_MGMT_GENERAL_CONFIG_SECTION_HPP
diff --git a/daemon/mgmt/log-config-section.cpp b/daemon/mgmt/log-config-section.cpp
new file mode 100644
index 0000000..9d8168c
--- /dev/null
+++ b/daemon/mgmt/log-config-section.cpp
@@ -0,0 +1,96 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology,
+ * The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "log-config-section.hpp"
+
+#include <ndn-cxx/util/logger.hpp>
+#include <ndn-cxx/util/logging.hpp>
+
+namespace nfd {
+namespace log {
+
+static ndn::util::LogLevel
+parseLogLevel(const ConfigSection& item, const std::string& key)
+{
+ try {
+ return ndn::util::parseLogLevel(item.get_value<std::string>());
+ }
+ catch (const std::invalid_argument&) {
+ NDN_THROW_NESTED(ConfigFile::Error("Invalid log level for '" + key + "' in section 'log'"));
+ }
+}
+
+static void
+onConfig(const ConfigSection& section, bool isDryRun, const std::string&)
+{
+ // log
+ // {
+ // ; default_level specifies the logging level for modules
+ // ; that are not explicitly named. All debugging levels
+ // ; listed above the selected value are enabled.
+ //
+ // default_level INFO
+ //
+ // ; You may also override the default for specific modules:
+ //
+ // FibManager DEBUG
+ // Forwarder WARN
+ // }
+
+ auto defaultLevel = ndn::util::LogLevel::INFO;
+ auto item = section.get_child_optional("default_level");
+ if (item) {
+ defaultLevel = parseLogLevel(*item, "default_level");
+ }
+ if (!isDryRun) {
+ // default_level applies only to NFD loggers
+ ndn::util::Logging::setLevel("nfd.*", defaultLevel);
+ }
+
+ for (const auto& i : section) {
+ if (i.first == "default_level") {
+ // do nothing
+ }
+ else {
+ auto level = parseLogLevel(i.second, i.first);
+ if (!isDryRun) {
+ if (i.first.find('.') == std::string::npos)
+ // backward compat: assume unqualified logger names refer to NFD loggers
+ ndn::util::Logging::setLevel("nfd." + i.first, level);
+ else
+ ndn::util::Logging::setLevel(i.first, level);
+ }
+ }
+ }
+}
+
+void
+setConfigFile(ConfigFile& config)
+{
+ config.addSectionHandler("log", &onConfig);
+}
+
+} // namespace log
+} // namespace nfd
diff --git a/daemon/mgmt/log-config-section.hpp b/daemon/mgmt/log-config-section.hpp
new file mode 100644
index 0000000..e7e4022
--- /dev/null
+++ b/daemon/mgmt/log-config-section.hpp
@@ -0,0 +1,40 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology,
+ * The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NFD_DAEMON_MGMT_LOG_CONFIG_SECTION_HPP
+#define NFD_DAEMON_MGMT_LOG_CONFIG_SECTION_HPP
+
+#include "common/config-file.hpp"
+
+namespace nfd {
+namespace log {
+
+void
+setConfigFile(ConfigFile& config);
+
+} // namespace log
+} // namespace nfd
+
+#endif // NFD_DAEMON_MGMT_LOG_CONFIG_SECTION_HPP
diff --git a/daemon/mgmt/rib-manager.cpp b/daemon/mgmt/rib-manager.cpp
index a790775..383c47f 100644
--- a/daemon/mgmt/rib-manager.cpp
+++ b/daemon/mgmt/rib-manager.cpp
@@ -25,10 +25,10 @@
#include "rib-manager.hpp"
-#include "core/fib-max-depth.hpp"
-#include "core/logger.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
+#include "common/logger.hpp"
#include "rib/rib.hpp"
+#include "table/fib.hpp"
#include <ndn-cxx/lp/tags.hpp>
#include <ndn-cxx/mgmt/nfd/face-status.hpp>
@@ -217,8 +217,8 @@
ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done)
{
- if (parameters.getName().size() > FIB_MAX_DEPTH) {
- done(ControlResponse(414, "Route prefix cannot exceed " + ndn::to_string(FIB_MAX_DEPTH) +
+ if (parameters.getName().size() > Fib::getMaxDepth()) {
+ done(ControlResponse(414, "Route prefix cannot exceed " + to_string(Fib::getMaxDepth()) +
" components"));
return;
}
diff --git a/daemon/mgmt/rib-manager.hpp b/daemon/mgmt/rib-manager.hpp
index 6888024..a5e663f 100644
--- a/daemon/mgmt/rib-manager.hpp
+++ b/daemon/mgmt/rib-manager.hpp
@@ -27,7 +27,6 @@
#define NFD_DAEMON_MGMT_RIB_MANAGER_HPP
#include "manager-base.hpp"
-#include "core/config-file.hpp"
#include "rib/route.hpp"
#include <ndn-cxx/mgmt/nfd/controller.hpp>
diff --git a/daemon/mgmt/strategy-choice-manager.cpp b/daemon/mgmt/strategy-choice-manager.cpp
index bebe1a0..169ce2e 100644
--- a/daemon/mgmt/strategy-choice-manager.cpp
+++ b/daemon/mgmt/strategy-choice-manager.cpp
@@ -25,7 +25,7 @@
#include "strategy-choice-manager.hpp"
-#include "core/logger.hpp"
+#include "common/logger.hpp"
#include "table/strategy-choice.hpp"
#include <ndn-cxx/mgmt/nfd/strategy-choice.hpp>
diff --git a/daemon/mgmt/tables-config-section.hpp b/daemon/mgmt/tables-config-section.hpp
index 932df2c..c2cfec5 100644
--- a/daemon/mgmt/tables-config-section.hpp
+++ b/daemon/mgmt/tables-config-section.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,11 +23,11 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NFD_MGMT_TABLES_CONFIG_SECTION_HPP
-#define NFD_MGMT_TABLES_CONFIG_SECTION_HPP
+#ifndef NFD_DAEMON_MGMT_TABLES_CONFIG_SECTION_HPP
+#define NFD_DAEMON_MGMT_TABLES_CONFIG_SECTION_HPP
+#include "common/config-file.hpp"
#include "fw/forwarder.hpp"
-#include "core/config-file.hpp"
namespace nfd {
@@ -101,4 +101,4 @@
} // namespace nfd
-#endif // NFD_MGMT_TABLES_CONFIG_SECTION_HPP
+#endif // NFD_DAEMON_MGMT_TABLES_CONFIG_SECTION_HPP