// Queue type was mandatory.
"queue-type": "kea-ring6"
}
+ // missing data-directory
},
// Logging configuration begins here.
identifier is explicitly specified in the configuration.</para>
</section>
+ <section xml:id="data-directory">
+ <title>DHCPv6 data directory</title>
+ <para>The Kea DHCPv6 server puts the server identifier file and the
+ default memory lease file into its data directory. By default
+ this directory is <filename><userinput>prefix</userinput>/var/kea</filename>
+ but this location can be changed using the
+ <command>data-directory</command> global parameter as in:
+<screen>
+"Dhcp6": {
+ "data-directory": <userinput>/var/tmp/kea-server6</userinput>,
+ ...
+}
+</screen>
+ </para>
+ </section>
+
<section xml:id="stateless-dhcp6">
<title>Stateless DHCPv6 (Information-Request Message)</title>
<para>Typically DHCPv6 is used to assign both addresses and options. These
-// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
namespace test {
BaseServerTest::BaseServerTest()
- : original_datadir_(CfgMgr::instance().getDataDir()) {
- CfgMgr::instance().setDataDir(TEST_DATA_BUILDDIR);
+ : original_datadir_(CfgMgr::instance().getCurrentCfg()->getDataDir()) {
+ CfgMgr::instance().getStagingCfg()->setDataDir(TEST_DATA_BUILDDIR);
}
BaseServerTest::~BaseServerTest() {
// Remove default lease file.
std::ostringstream s2;
- s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases4.csv";
+ s2 << CfgMgr::instance().getStagingCfg()->getDataDir()
+ << "/" << "kea-leases4.csv";
static_cast<void>(::remove(s2.str().c_str()));
// Revert to original data directory.
- CfgMgr::instance().setDataDir(original_datadir_);
+ CfgMgr::instance().getStagingCfg()->setDataDir(original_datadir_);
// Revert to unit test logging, in case the test reconfigured it.
isc::log::initLogger();
-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// Regenerate server identifier if needed.
try {
- const std::string duid_file = CfgMgr::instance().getDataDir() + "/" +
+ const std::string duid_file =
+ CfgMgr::instance().getStagingCfg()->getDataDir() + "/" +
std::string(SERVER_DUID_FILE);
DuidPtr duid = CfgMgr::instance().getStagingCfg()->getCfgDUID()->create(duid_file);
server_->serverid_.reset(new Option(Option::V6, D6O_SERVERID, duid->getDuid()));
namespace {
+/// @brief Checks if specified directory exists.
+///
+/// @param dir_path Path to a directory.
+/// @throw BadValue If the directory does not exist or is not a directory.
+void dirExists(const string& dir_path) {
+ struct stat statbuf;
+ if (stat(dir_path.c_str(), &statbuf) < 0) {
+ isc_throw(BadValue, "Bad directory '" << dir_path
+ << "': " << strerror(errno));
+ }
+ if ((statbuf.st_mode & S_IFMT) != S_IFDIR) {
+ isc_throw(BadValue, "'" << dir_path << "' is not a directory");
+ }
+}
+
/// @brief Parser for list of RSOO options
///
/// This parser handles a Dhcp6/relay-supplied-options entry. It contains a
///
/// Currently this method sets the following global parameters:
///
+ /// - data-directory
/// - decline-probation-period
/// - dhcp4o6-port
/// - user-context
/// or having incorrect values.
void parse(const SrvConfigPtr& srv_config, const ConstElementPtr& global) {
+ // Set the data directory for server id file.
+ if (global->contains("data-directory")) {
+ srv_config->setDataDir(getString(global, "data-directory"));
+ }
+
// Set the probation period for decline handling.
uint32_t probation_period =
getUint32(global, "decline-probation-period");
// with the parser code debugability, so I decided to keep it as a
// series of independent ifs.
+ if (config_pair.first == "data-directory") {
+ // Specific check for this global parameter.
+ dirExists(config_pair.second->stringValue());
+ continue;
+ }
+
if (config_pair.first == "option-def") {
// This is converted to SimpleParser and is handled already above.
continue;
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
+/// Check that not existent data directory returns an error.
+TEST_F(Dhcp6ParserTest, notExistDataDir) {
+
+ string config_txt = "{\n"
+ "\"data-directory\": \"/does-not-exist--\"\n"
+ "}";
+ ConstElementPtr config;
+ ASSERT_NO_THROW(config = parseDHCP6(config_txt));
+
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, config));
+
+ // returned value should be 1 (error)
+ int rcode;
+ ConstElementPtr comment = parseAnswer(rcode, status);
+ EXPECT_EQ(1, rcode);
+ string text;
+ ASSERT_NO_THROW(text = comment->stringValue());
+ EXPECT_EQ("Bad directory '/does-not-exist--': No such file or directory",
+ text);
+}
+
+/// Check that not a directory data directory returns an error.
+TEST_F(Dhcp6ParserTest, notDirDataDir) {
+
+ string config_txt = "{\n"
+ "\"data-directory\": \"/dev/null\"\n"
+ "}";
+ ConstElementPtr config;
+ ASSERT_NO_THROW(config = parseDHCP6(config_txt));
+
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, config));
+
+ // returned value should be 1 (error)
+ int rcode;
+ ConstElementPtr comment = parseAnswer(rcode, status);
+ EXPECT_EQ(1, rcode);
+ string text;
+ ASSERT_NO_THROW(text = comment->stringValue());
+ EXPECT_EQ("'/dev/null' is not a directory", text);
+}
+
+/// Check that a valid data directory is accepted.
+TEST_F(Dhcp6ParserTest, testDataDir) {
+
+ string datadir(TEST_DATA_BUILDDIR);
+ string config_txt = "{\n"
+ "\"data-directory\": \"" + datadir + "\"\n"
+ "}";
+ ConstElementPtr config;
+ ASSERT_NO_THROW(config = parseDHCP6(config_txt));
+ extractConfig(config_txt);
+
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, config));
+
+ // returned value should be 0 (success);
+ checkResult(status, 0);
+
+ // The value of data-directory was updated.
+ EXPECT_EQ(datadir, CfgMgr::instance().getStagingCfg()->getDataDir());
+ EXPECT_NE(datadir, CfgMgr::instance().getCurrentCfg()->getDataDir());
+}
+
/// Check that the decline-probation-period value has a default value if not
/// specified explicitly.
TEST_F(Dhcp6ParserTest, declineTimerDefault) {
-// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
const char* BaseServerTest::DUID_FILE = "kea-dhcp6-serverid";
BaseServerTest::BaseServerTest()
- : original_datadir_(CfgMgr::instance().getDataDir()) {
- CfgMgr::instance().setDataDir(TEST_DATA_BUILDDIR);
+ : original_datadir_(CfgMgr::instance().getCurrentCfg()->getDataDir()) {
+ CfgMgr::instance().getStagingCfg()->setDataDir(TEST_DATA_BUILDDIR);
}
BaseServerTest::~BaseServerTest() {
// Remove test DUID file.
std::ostringstream s;
- s << CfgMgr::instance().getDataDir() << "/" << DUID_FILE;
+ s << CfgMgr::instance().getStagingCfg()->getDataDir()
+ << "/" << DUID_FILE;
static_cast<void>(::remove(s.str().c_str()));
// Remove default lease file.
std::ostringstream s2;
- s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases6.csv";
+ s2 << CfgMgr::instance().getStagingCfg()->getDataDir()
+ << "/" << "kea-leases6.csv";
static_cast<void>(::remove(s2.str().c_str()));
// Revert to original data directory.
- CfgMgr::instance().setDataDir(original_datadir_);
+ CfgMgr::instance().getStagingCfg()->setDataDir(original_datadir_);
// Revert to unit test logging in case the test reconfigured logging.
isc::log::initLogger();
" }\n",
// CONFIGURATION 43
"{\n"
+" \"data-directory\": \"/tmp/k430/src/bin/dhcp6/tests\"\n"
+" }\n",
+ // CONFIGURATION 44
+"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" \"re-detect\": false\n"
" },\n"
" \"subnet6\": [ ]\n"
" }\n",
- // CONFIGURATION 44
+ // CONFIGURATION 45
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" },\n"
" \"subnet6\": [ ]\n"
" }\n",
- // CONFIGURATION 45
+ // CONFIGURATION 46
"{\n"
" \"decline-probation-period\": 12345,\n"
" \"interfaces-config\": {\n"
" },\n"
" \"subnet6\": [ ]\n"
" }\n",
- // CONFIGURATION 46
+ // CONFIGURATION 47
"{\n"
" \"expired-leases-processing\": {\n"
" \"flush-reclaimed-timer-wait-time\": 35,\n"
" },\n"
" \"subnet6\": [ ]\n"
" }\n",
- // CONFIGURATION 47
+ // CONFIGURATION 48
"{\n"
" \"client-classes\": [\n"
" {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 48
+ // CONFIGURATION 49
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 49
+ // CONFIGURATION 50
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 50
+ // CONFIGURATION 51
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 51
+ // CONFIGURATION 52
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 52
+ // CONFIGURATION 53
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 53
+ // CONFIGURATION 54
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 54
+ // CONFIGURATION 55
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 55
+ // CONFIGURATION 56
"{\n"
" \"hosts-databases\": [\n"
" {\n"
" \"renew-timer\": 1000,\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 56
+ // CONFIGURATION 57
"{\n"
" \"comment\": \"A DHCPv6 server\",\n"
" \"client-classes\": [\n"
" }\n"
" ]\n"
" }\n",
- // CONFIGURATION 57
+ // CONFIGURATION 58
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 58
+ // CONFIGURATION 59
"{\n"
" \"config-control\": {\n"
" \"config-databases\": [\n"
" }\n",
// CONFIGURATION 43
"{\n"
+" \"data-directory\": \"/tmp/k430/src/bin/dhcp6/tests\",\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" \"enable-updates\": false,\n"
" \"hooks-libraries\": [ ],\n"
" \"host-reservation-identifiers\": [ \"hw-address\", \"duid\" ],\n"
" \"interfaces-config\": {\n"
-" \"interfaces\": [ \"*\" ],\n"
+" \"interfaces\": [ ],\n"
" \"re-detect\": false\n"
" },\n"
" \"lease-database\": {\n"
" }\n",
// CONFIGURATION 45
"{\n"
-" \"decline-probation-period\": 12345,\n"
+" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" \"enable-updates\": false,\n"
" \"generated-prefix\": \"myhost\",\n"
" }\n",
// CONFIGURATION 46
"{\n"
+" \"decline-probation-period\": 12345,\n"
+" \"dhcp-ddns\": {\n"
+" \"enable-updates\": false,\n"
+" \"generated-prefix\": \"myhost\",\n"
+" \"hostname-char-replacement\": \"\",\n"
+" \"hostname-char-set\": \"\",\n"
+" \"max-queue-size\": 1024,\n"
+" \"ncr-format\": \"JSON\",\n"
+" \"ncr-protocol\": \"UDP\",\n"
+" \"override-client-update\": false,\n"
+" \"override-no-update\": false,\n"
+" \"qualifying-suffix\": \"\",\n"
+" \"replace-client-name\": \"never\",\n"
+" \"sender-ip\": \"0.0.0.0\",\n"
+" \"sender-port\": 0,\n"
+" \"server-ip\": \"127.0.0.1\",\n"
+" \"server-port\": 53001\n"
+" },\n"
+" \"dhcp-queue-control\": {\n"
+" \"capacity\": 500,\n"
+" \"enable-queue\": false,\n"
+" \"queue-type\": \"kea-ring6\"\n"
+" },\n"
+" \"dhcp4o6-port\": 0,\n"
+" \"expired-leases-processing\": {\n"
+" \"flush-reclaimed-timer-wait-time\": 25,\n"
+" \"hold-reclaimed-time\": 3600,\n"
+" \"max-reclaim-leases\": 100,\n"
+" \"max-reclaim-time\": 250,\n"
+" \"reclaim-timer-wait-time\": 10,\n"
+" \"unwarned-reclaim-cycles\": 5\n"
+" },\n"
+" \"hooks-libraries\": [ ],\n"
+" \"host-reservation-identifiers\": [ \"hw-address\", \"duid\" ],\n"
+" \"interfaces-config\": {\n"
+" \"interfaces\": [ \"*\" ],\n"
+" \"re-detect\": false\n"
+" },\n"
+" \"lease-database\": {\n"
+" \"type\": \"memfile\"\n"
+" },\n"
+" \"mac-sources\": [ \"any\" ],\n"
+" \"option-data\": [ ],\n"
+" \"option-def\": [ ],\n"
+" \"relay-supplied-options\": [ \"65\" ],\n"
+" \"sanity-checks\": {\n"
+" \"lease-checks\": \"warn\"\n"
+" },\n"
+" \"server-id\": {\n"
+" \"enterprise-id\": 0,\n"
+" \"htype\": 0,\n"
+" \"identifier\": \"\",\n"
+" \"persist\": true,\n"
+" \"time\": 0,\n"
+" \"type\": \"LLT\"\n"
+" },\n"
+" \"shared-networks\": [ ],\n"
+" \"subnet6\": [ ]\n"
+" }\n",
+ // CONFIGURATION 47
+"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" \"enable-updates\": false,\n"
" \"shared-networks\": [ ],\n"
" \"subnet6\": [ ]\n"
" }\n",
- // CONFIGURATION 47
+ // CONFIGURATION 48
"{\n"
" \"client-classes\": [\n"
" {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 48
+ // CONFIGURATION 49
"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 49
+ // CONFIGURATION 50
"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 50
+ // CONFIGURATION 51
"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 51
+ // CONFIGURATION 52
"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 52
+ // CONFIGURATION 53
"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 53
+ // CONFIGURATION 54
"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 54
+ // CONFIGURATION 55
"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 55
+ // CONFIGURATION 56
"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" \"subnet6\": [ ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 56
+ // CONFIGURATION 57
"{\n"
" \"comment\": \"A DHCPv6 server\",\n"
" \"client-classes\": [\n"
" ],\n"
" \"subnet6\": [ ]\n"
" }\n",
- // CONFIGURATION 57
+ // CONFIGURATION 58
"{\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
- // CONFIGURATION 58
+ // CONFIGURATION 59
"{\n"
" \"config-control\": {\n"
" \"config-databases\": [\n"
return (cfg_mgr);
}
-std::string CfgMgr::getDataDir() const {
- return (datadir_);
-}
-
-void
-CfgMgr::setDataDir(const std::string& datadir) {
- datadir_ = datadir;
-}
-
void
CfgMgr::setD2ClientConfig(D2ClientConfigPtr& new_config) {
ensureCurrentAllocated();
}
}
-CfgMgr::CfgMgr()
- : datadir_(DHCP_DATA_DIR), d2_client_mgr_(), family_(AF_INET) {
- // DHCP_DATA_DIR must be set set with -DDHCP_DATA_DIR="..." in Makefile.am
- // Note: the definition of DHCP_DATA_DIR needs to include quotation marks
- // See AM_CPPFLAGS definition in Makefile.am
+CfgMgr::CfgMgr() : d2_client_mgr_(), family_(AF_INET) {
}
CfgMgr::~CfgMgr() {
/// accessing it.
static CfgMgr& instance();
- /// @brief returns path do the data directory
- ///
- /// This method returns a path to writable directory that DHCP servers
- /// can store data in.
- /// @return data directory
- std::string getDataDir() const;
-
- /// @brief Sets new data directory.
- ///
- /// @param datadir New data directory.
- void setDataDir(const std::string& datadir);
-
/// @brief Updates the DHCP-DDNS client configuration to the given value.
///
/// Passes the new configuration to the D2ClientMgr instance,
/// @param seq Source configuration sequence number.
void mergeIntoCfg(const SrvConfigPtr& taget_config, const uint32_t seq);
- /// @brief directory where data files (e.g. server-id) are stored
- std::string datadir_;
-
/// @brief Manages the DHCP-DDNS client and its configuration.
D2ClientMgr d2_client_mgr_;
-// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
std::string
Memfile_LeaseMgr::getDefaultLeaseFilePath(Universe u) const {
std::ostringstream s;
- s << CfgMgr::instance().getDataDir() << "/kea-leases";
+ // Use the staging configuration because either it is called
+ // during (re)configuration or with a fresh configuration.
+ // In both cases the right value is at least at this place.
+ s << CfgMgr::instance().getStagingCfg()->getDataDir() << "/kea-leases";
s << (u == V4 ? "4" : "6");
s << ".csv";
return (s.str());
namespace isc {
namespace dhcp {
+// DHCP_DATA_DIR must be set set with -DDHCP_DATA_DIR="..." in Makefile.am
+// Note: the definition of DHCP_DATA_DIR needs to include quotation marks
+// See AM_CPPFLAGS definition in Makefile.am
+const std::string
+SrvConfig::DEFAULT_DATA_DIR = DHCP_DATA_DIR;
+
SrvConfig::SrvConfig()
- : sequence_(0), cfg_iface_(new CfgIface()),
+ : sequence_(0), datadir_(DEFAULT_DATA_DIR), cfg_iface_(new CfgIface()),
cfg_option_def_(new CfgOptionDef()), cfg_option_(new CfgOption()),
cfg_subnets4_(new CfgSubnets4()), cfg_subnets6_(new CfgSubnets6()),
cfg_shared_networks4_(new CfgSharedNetworks4()),
}
SrvConfig::SrvConfig(const uint32_t sequence)
- : sequence_(sequence), cfg_iface_(new CfgIface()),
+ : sequence_(sequence),
+ datadir_(DEFAULT_DATA_DIR),cfg_iface_(new CfgIface()),
cfg_option_def_(new CfgOptionDef()), cfg_option_(new CfgOption()),
cfg_subnets4_(new CfgSubnets4()), cfg_subnets6_(new CfgSubnets6()),
cfg_shared_networks4_(new CfgSharedNetworks4()),
SrvConfig::copy(SrvConfig& new_config) const {
ConfigBase::copy(new_config);
+ // Replace data directory.
+ new_config.datadir_ = datadir_;
// Replace interface configuration.
new_config.cfg_iface_.reset(new CfgIface(*cfg_iface_));
// Replace option definitions.
}
// Common information is equal between objects, so check other values.
- if ((*cfg_iface_ != *other.cfg_iface_) ||
+ if ((datadir_ != other.datadir_) ||
+ (*cfg_iface_ != *other.cfg_iface_) ||
(*cfg_option_def_ != *other.cfg_option_def_) ||
(*cfg_option_ != *other.cfg_option_) ||
(*class_dictionary_ != *other.class_dictionary_) ||
addConfiguredGlobal(other_global.first, other_global.second);
}
- // A handful of values are stored as members in SrvConfig. So we'll
+ // A handful of values are stored as members in SrvConfig. So we'll
// iterate over the merged globals, setting approprate members.
for (auto merged_global : getConfiguredGlobals()->mapValue()) {
std::string name = merged_global.first;
ConstElementPtr element = merged_global.second;
try {
- if (name == "decline-probation-period") {
+ if (name == "data-directory") {
+ setDataDir(element->stringValue());
+ } if (name == "decline-probation-period") {
setDeclinePeriod(element->intValue());
}
else if (name == "echo-client-id") {
// Set user-context
contextToElement(dhcp);
+ // Set data directory if DHCPv6 and not default.
+ if ((family == AF_INET6) && (getDataDir() != DEFAULT_DATA_DIR)) {
+ dhcp->set("data-directory", Element::create(getDataDir()));
+ }
+
// Set decline-probation-period
dhcp->set("decline-probation-period",
Element::create(static_cast<long long>(decline_timer_)));
/// @return true if sequence numbers are equal.
bool sequenceEquals(const SrvConfig& other);
+ /// @brief Default data directory.
+ static const std::string DEFAULT_DATA_DIR;
+
+ /// @brief returns path do the data directory.
+ ///
+ /// This method returns a path to writable directory that DHCP servers
+ /// can store data in.
+ /// @return data directory.
+ std::string getDataDir() const {
+ return (datadir_);
+ }
+
+ /// @brief Sets new data directory.
+ ///
+ /// @param datadir New data directory.
+ void setDataDir(const std::string& datadir) {
+ datadir_ = datadir;
+ }
+
/// @brief Returns non-const pointer to interface configuration.
///
/// This function returns a non-const pointer to the interface
/// @brief Sequence number identifying the configuration.
uint32_t sequence_;
+ /// @brief directory where data files (e.g. server-id) are stored.
+ std::string datadir_;
+
/// @brief Interface configuration.
///
/// Used to select interfaces on which the DHCP server will listen to