From: Marcin Siodelski Date: Tue, 17 Nov 2015 14:48:04 +0000 (+0100) Subject: [3874] Use DUID configuration parser in the global configuration. X-Git-Tag: trac4231_base~39^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e5cdb3410b9ba4350f92bc16cf09aacf9092cf50;p=thirdparty%2Fkea.git [3874] Use DUID configuration parser in the global configuration. --- diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index c7bf0de63f..d65428a750 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -701,6 +702,8 @@ DhcpConfigParser* createGlobal6DhcpConfigParser(const std::string& config_id, parser = new ControlSocketParser(config_id); } else if (config_id.compare("expired-leases-processing") == 0) { parser = new ExpirationConfigParser(); + } else if (config_id.compare("server-id") == 0) { + parser = new DUIDConfigParser(); } else { isc_throw(DhcpConfigError, "unsupported global configuration parameter: " diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc index e00c9c9809..fb3a8a6f1b 100644 --- a/src/bin/dhcp6/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc @@ -349,4 +349,39 @@ TEST_F(JSONFileBackendTest, timers) { EXPECT_FALSE(lease_reclaimed); } +// This test verifies that the DUID type can be selected. +TEST_F(JSONFileBackendTest, serverId) { + string config = + "{ \"Dhcp6\": {" + "\"interfaces-config\": {" + " \"interfaces\": [ ]" + "}," + "\"lease-database\": {" + " \"type\": \"memfile\"," + " \"persist\": false" + "}," + "\"server-id\": {" + " \"type\": \"EN\"," + " \"enterprise-id\": 1234" + "}," + "\"rebind-timer\": 2000, " + "\"renew-timer\": 1000, " + "\"subnet6\": [ ]," + "\"preferred-lifetime\": 3000, " + "\"valid-lifetime\": 4000 }" + "}"; + writeFile(TEST_FILE, config); + + // Create an instance of the server and intialize it. + boost::scoped_ptr srv; + ASSERT_NO_THROW(srv.reset(new ControlledDhcpv6Srv(0))); + ASSERT_NO_THROW(srv->init(TEST_FILE)); + + // Check that DUID configuration is affected. + ConstCfgDUIDPtr duid_cfg = CfgMgr::instance().getCurrentCfg()->getCfgDUID(); + ASSERT_TRUE(duid_cfg); + EXPECT_EQ(DUID::DUID_EN, duid_cfg->getType()); + EXPECT_EQ(1234, duid_cfg->getEnterpriseId()); +} + } // End of anonymous namespace