diff --git a/daemon/mgmt/general-config-section.cpp b/daemon/mgmt/general-config-section.cpp index ce589092..ed6f99e8 100644 --- a/daemon/mgmt/general-config-section.cpp +++ b/daemon/mgmt/general-config-section.cpp @@ -35,67 +35,6 @@ namespace general { NFD_LOG_INIT("GeneralConfigSection"); -const ndn::Name -RouterName::getName() const -{ - ndn::Name routerName; - - if (network.empty() || site.empty() || router.empty()) - { - return routerName; - } - - routerName = network; - routerName.append(site); - routerName.append(ROUTER_MARKER); - routerName.append(router); - - return routerName; -} - -const ndn::PartialName RouterName::ROUTER_MARKER("%C1.Router"); - -static RouterName& -getRouterNameInstance() -{ - static RouterName routerName; - return routerName; -} - -ndn::PartialName -loadPartialNameFromSection(const ConfigSection& section, const std::string& key) -{ - ndn::PartialName value; - - try - { - value = section.get(key); - - if (value.empty()) - { - BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"router_name." + key + "\"" - " in \"general\" section")); - } - } - catch (const boost::property_tree::ptree_error& error) - { - BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"router_name." + key + "\"" - " in \"general\" section")); - } - - return value; -} - -void -processSectionRouterName(const ConfigSection& section, bool isDryRun) -{ - RouterName& routerName = getRouterNameInstance(); - - routerName.network = loadPartialNameFromSection(section, "network"); - routerName.site = loadPartialNameFromSection(section, "site"); - routerName.router = loadPartialNameFromSection(section, "router"); -} - static void onConfig(const ConfigSection& configSection, bool isDryRun, @@ -105,13 +44,6 @@ onConfig(const ConfigSection& configSection, // { // ; user "ndn-user" // ; group "ndn-user" - // - // ; router_name - // ; { - // ; network ndn - // ; site edu/site - // ; router router/name - // ; } // } std::string user; @@ -161,14 +93,6 @@ onConfig(const ConfigSection& configSection, NFD_LOG_TRACE("using user \"" << user << "\" group \"" << group << "\""); PrivilegeHelper::initialize(user, group); - - boost::optional routerNameSection = - configSection.get_child_optional("router_name"); - - if (routerNameSection) - { - processSectionRouterName(*routerNameSection, isDryRun); - } } void @@ -177,12 +101,6 @@ setConfigFile(ConfigFile& configFile) configFile.addSectionHandler("general", &onConfig); } -const RouterName& -getRouterName() -{ - return getRouterNameInstance(); -} - } // namespace general } // namespace nfd diff --git a/daemon/mgmt/general-config-section.hpp b/daemon/mgmt/general-config-section.hpp index e86abd22..6ce54738 100644 --- a/daemon/mgmt/general-config-section.hpp +++ b/daemon/mgmt/general-config-section.hpp @@ -25,8 +25,6 @@ #ifndef NFD_MGMT_GENERAL_CONFIG_SECTION_HPP #define NFD_MGMT_GENERAL_CONFIG_SECTION_HPP -#include - namespace nfd { class ConfigFile; @@ -36,33 +34,6 @@ namespace general { void setConfigFile(ConfigFile& configFile); -class RouterName -{ -public: - /** - * \brief Return the router name constructed from the network, site, and - * router variables. - * - * The router name is constructed in the following manner: - * //// - * - * \return The constructed router name if the network, site, and router - * configuration options are non-empty; otherwise, an empty ndn::Name. - */ - const ndn::Name - getName() const; - -public: - ndn::PartialName network; - ndn::PartialName site; - ndn::PartialName router; - - static const ndn::PartialName ROUTER_MARKER; -}; - -const RouterName& -getRouterName(); - } // namespace general } // namespace nfd diff --git a/nfd.conf.sample.in b/nfd.conf.sample.in index bb4d8393..fa229b42 100644 --- a/nfd.conf.sample.in +++ b/nfd.conf.sample.in @@ -7,18 +7,6 @@ general ; user ndn-user ; group ndn-user - - ; The router_name section specifies the name components used - ; to build this router's name. The router name is constructed - ; using the configuration options in the following manner: - ; ///<%C1.Router>/ - - ; router_name - ; { - ; network ndn ; the network to which this router belongs - ; site edu/site ; the site to which this router belongs - ; router router/name ; name used to uniquely identify this router under the site - ; } } log diff --git a/tests/daemon/mgmt/general-config-section.t.cpp b/tests/daemon/mgmt/general-config-section.t.cpp index 3428624d..debd2b88 100644 --- a/tests/daemon/mgmt/general-config-section.t.cpp +++ b/tests/daemon/mgmt/general-config-section.t.cpp @@ -60,8 +60,6 @@ BOOST_AUTO_TEST_CASE(DefaultConfig) general::setConfigFile(configFile); BOOST_CHECK_NO_THROW(configFile.parse(CONFIG, true, "test-general-config-section")); - - BOOST_CHECK(getRouterName().getName().empty()); } #ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE @@ -151,159 +149,6 @@ BOOST_AUTO_TEST_CASE(InvalidGroupConfig) bind(&checkExceptionMessage, _1, expected)); } -BOOST_AUTO_TEST_CASE(RouterNameConfig) -{ - const std::string CONFIG = - "general\n" - "{\n" - " router_name\n" - " {\n" - " network ndn\n" - " site edu/site\n" - " router router/name\n" - " }\n" - "}\n"; - - ConfigFile configFile; - general::setConfigFile(configFile); - - BOOST_CHECK_NO_THROW(configFile.parse(CONFIG, true, "test-general-config-section")); - - BOOST_CHECK_EQUAL(getRouterName().network, ndn::PartialName("ndn")); - BOOST_CHECK_EQUAL(getRouterName().site, ndn::PartialName("edu/site")); - BOOST_CHECK_EQUAL(getRouterName().router, ndn::PartialName("router/name")); - BOOST_CHECK_EQUAL(getRouterName().getName(), ndn::Name("/ndn/edu/site/%C1.Router/router/name")); -} - -BOOST_AUTO_TEST_CASE(NoNetworkConfig) -{ - const std::string CONFIG = - "general\n" - "{\n" - " router_name\n" - " {\n" - " site edu/site\n" - " router router/name\n" - " }\n" - "}\n"; - - ConfigFile configFile; - general::setConfigFile(configFile); - - const std::string expected = "Invalid value for \"router_name.network\" in \"general\" section"; - BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"), - ConfigFile::Error, - bind(&checkExceptionMessage, _1, expected)); -} - -BOOST_AUTO_TEST_CASE(NoSiteConfig) -{ - const std::string CONFIG = - "general\n" - "{\n" - " router_name\n" - " {\n" - " network ndn\n" - " router router/name\n" - " }\n" - "}\n"; - - ConfigFile configFile; - general::setConfigFile(configFile); - - const std::string expected = "Invalid value for \"router_name.site\" in \"general\" section"; - BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"), - ConfigFile::Error, - bind(&checkExceptionMessage, _1, expected)); -} - -BOOST_AUTO_TEST_CASE(NoRouterConfig) -{ - const std::string CONFIG = - "general\n" - "{\n" - " router_name\n" - " {\n" - " network ndn\n" - " site edu/site\n" - " }\n" - "}\n"; - - ConfigFile configFile; - general::setConfigFile(configFile); - - const std::string expected = "Invalid value for \"router_name.router\" in \"general\" section"; - BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"), - ConfigFile::Error, - bind(&checkExceptionMessage, _1, expected)); -} - -BOOST_AUTO_TEST_CASE(InvalidNetworkConfig) -{ - const std::string CONFIG = - "general\n" - "{\n" - " router_name\n" - " {\n" - " network\n" - " site edu/site\n" - " router router/name\n" - " }\n" - "}\n"; - - ConfigFile configFile; - general::setConfigFile(configFile); - - const std::string expected = "Invalid value for \"router_name.network\" in \"general\" section"; - BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"), - ConfigFile::Error, - bind(&checkExceptionMessage, _1, expected)); -} - -BOOST_AUTO_TEST_CASE(InvalidSiteConfig) -{ - const std::string CONFIG = - "general\n" - "{\n" - " router_name\n" - " {\n" - " network ndn\n" - " site\n" - " router router/name\n" - " }\n" - "}\n"; - - ConfigFile configFile; - general::setConfigFile(configFile); - - const std::string expected = "Invalid value for \"router_name.site\" in \"general\" section"; - BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"), - ConfigFile::Error, - bind(&checkExceptionMessage, _1, expected)); -} - -BOOST_AUTO_TEST_CASE(InvalidRouterConfig) -{ - const std::string CONFIG = - "general\n" - "{\n" - " router_name\n" - " {\n" - " network ndn\n" - " site edu/site\n" - " router\n" - " }\n" - "}\n"; - - ConfigFile configFile; - general::setConfigFile(configFile); - - const std::string expected = "Invalid value for \"router_name.router\" in \"general\" section"; - BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"), - ConfigFile::Error, - bind(&checkExceptionMessage, _1, expected)); -} - BOOST_AUTO_TEST_SUITE_END() } // namespace tests