From: Marcin Siodelski Date: Tue, 12 May 2015 12:22:25 +0000 (+0200) Subject: [3747] Renamed ignore-client-id to record-client-id and reversed values. X-Git-Tag: trac3867_base~2^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dca41228db79b4e86bc02e3fde054a530de2bba8;p=thirdparty%2Fkea.git [3747] Renamed ignore-client-id to record-client-id and reversed values. --- diff --git a/src/bin/dhcp4/dhcp4.spec b/src/bin/dhcp4/dhcp4.spec index 5014d5b015..6dd86dcf12 100644 --- a/src/bin/dhcp4/dhcp4.spec +++ b/src/bin/dhcp4/dhcp4.spec @@ -74,10 +74,10 @@ "item_default": true }, - { "item_name": "ignore-client-id", + { "item_name": "record-client-id", "item_type": "boolean", "item_optional": true, - "item_default": false + "item_default": true }, { "item_name": "option-def", @@ -275,10 +275,10 @@ "item_default": "0.0.0.0" }, - { "item_name": "ignore-client-id", + { "item_name": "record-client-id", "item_type": "boolean", "item_optional": true, - "item_default": false + "item_default": true }, { "item_name": "pool", diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index ce6fbfc8db..c52489112f 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -194,7 +194,7 @@ protected: parser = new RelayInfoParser(config_id, relay_info_, Option::V4); } else if (config_id.compare("option-data") == 0) { parser = new OptionDataListParser(config_id, options_, AF_INET); - } else if (config_id.compare("ignore-client-id") == 0) { + } else if (config_id.compare("record-client-id") == 0) { parser = new BooleanParser(config_id, boolean_values_); } else { isc_throw(NotImplemented, "unsupported parameter: " << config_id); @@ -252,26 +252,26 @@ protected: Subnet4Ptr subnet4(new Subnet4(addr, len, t1, t2, valid, subnet_id)); subnet_ = subnet4; - // ignore-client-id - isc::util::OptionalValue ignore_client_id; + // record-client-id + isc::util::OptionalValue record_client_id; try { - ignore_client_id = boolean_values_->getParam("ignore-client-id"); + record_client_id = boolean_values_->getParam("record-client-id"); } catch (...) { // Ignore because this parameter is optional and it may be specified // in the global scope. } - // If the ignore-client-id wasn't specified as a subnet specific parameter + // If the record-client-id wasn't specified as a subnet specific parameter // check if there is global value specified. - if (!ignore_client_id.isSpecified()) { + if (!record_client_id.isSpecified()) { // If not specified, use false. - ignore_client_id.specify(globalContext()->boolean_values_-> - getOptionalParam("ignore-client-id", false)); + record_client_id.specify(globalContext()->boolean_values_-> + getOptionalParam("record-client-id", true)); } - // Set the ignore-client-id value for the subnet. - subnet4->setIgnoreClientId(ignore_client_id.get()); + // Set the record-client-id value for the subnet. + subnet4->setRecordClientId(record_client_id.get()); // next-server try { @@ -397,7 +397,7 @@ namespace dhcp { parser = new BooleanParser(config_id, globalContext()->boolean_values_); } else if (config_id.compare("dhcp-ddns") == 0) { parser = new D2ClientConfigParser(config_id); - } else if (config_id.compare("ignore-client-id") == 0) { + } else if (config_id.compare("record-client-id") == 0) { parser = new BooleanParser(config_id, globalContext()->boolean_values_); } else { isc_throw(DhcpConfigError, diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index 84a96d809b..96dd7346d3 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -1102,9 +1102,9 @@ TEST_F(Dhcp4ParserTest, echoClientId) { CfgMgr::instance().echoClientId(true); } -// This test checks that the global ignore-client-id parameter is optional +// This test checks that the global record-client-id parameter is optional // and that values under the subnet are used. -TEST_F(Dhcp4ParserTest, ignoreClientIdNoGlobal) { +TEST_F(Dhcp4ParserTest, recordClientIdNoGlobal) { ConstElementPtr status; std::string config = "{ " + genIfaceConfig() + "," + @@ -1112,12 +1112,12 @@ TEST_F(Dhcp4ParserTest, ignoreClientIdNoGlobal) { "\"renew-timer\": 1000, " "\"subnet4\": [ " "{" - " \"ignore-client-id\": true," + " \"record-client-id\": true," " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ]," " \"subnet\": \"192.0.2.0/24\"" "}," "{" - " \"ignore-client-id\": false," + " \"record-client-id\": false," " \"pools\": [ { \"pool\": \"192.0.3.1 - 192.0.3.100\" } ]," " \"subnet\": \"192.0.3.0/24\"" "} ]," @@ -1130,26 +1130,26 @@ TEST_F(Dhcp4ParserTest, ignoreClientIdNoGlobal) { CfgSubnets4Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets4(); Subnet4Ptr subnet1 = cfg->selectSubnet(IOAddress("192.0.2.1")); ASSERT_TRUE(subnet1); - EXPECT_TRUE(subnet1->getIgnoreClientId()); + EXPECT_TRUE(subnet1->getRecordClientId()); Subnet4Ptr subnet2 = cfg->selectSubnet(IOAddress("192.0.3.1")); ASSERT_TRUE(subnet2); - EXPECT_FALSE(subnet2->getIgnoreClientId()); + EXPECT_FALSE(subnet2->getRecordClientId()); } -// This test checks that the global ignore-client-id parameter is used +// This test checks that the global record-client-id parameter is used // when there is no such parameter under subnet and that the parameter // specified for a subnet overrides the global setting. -TEST_F(Dhcp4ParserTest, ignoreClientIdGlobal) { +TEST_F(Dhcp4ParserTest, recordClientIdGlobal) { ConstElementPtr status; std::string config = "{ " + genIfaceConfig() + "," + "\"rebind-timer\": 2000, " "\"renew-timer\": 1000, " - "\"ignore-client-id\": true," + "\"record-client-id\": true," "\"subnet4\": [ " "{" - " \"ignore-client-id\": false," + " \"record-client-id\": false," " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ]," " \"subnet\": \"192.0.2.0/24\"" "}," @@ -1166,11 +1166,11 @@ TEST_F(Dhcp4ParserTest, ignoreClientIdGlobal) { CfgSubnets4Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets4(); Subnet4Ptr subnet1 = cfg->selectSubnet(IOAddress("192.0.2.1")); ASSERT_TRUE(subnet1); - EXPECT_FALSE(subnet1->getIgnoreClientId()); + EXPECT_FALSE(subnet1->getRecordClientId()); Subnet4Ptr subnet2 = cfg->selectSubnet(IOAddress("192.0.3.1")); ASSERT_TRUE(subnet2); - EXPECT_TRUE(subnet2->getIgnoreClientId()); + EXPECT_TRUE(subnet2->getRecordClientId()); } // This test checks if it is possible to override global values diff --git a/src/lib/dhcpsrv/subnet.cc b/src/lib/dhcpsrv/subnet.cc index f92d8ea921..aeff33831b 100644 --- a/src/lib/dhcpsrv/subnet.cc +++ b/src/lib/dhcpsrv/subnet.cc @@ -180,7 +180,7 @@ Subnet4::Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length, const Triplet& valid_lifetime, const SubnetID id) : Subnet(prefix, length, t1, t2, valid_lifetime, RelayInfo(IOAddress("0.0.0.0")), id), - siaddr_(IOAddress("0.0.0.0")), ignore_client_id_(false) { + siaddr_(IOAddress("0.0.0.0")), record_client_id_(true) { if (!prefix.isV4()) { isc_throw(BadValue, "Non IPv4 prefix " << prefix.toText() << " specified in subnet4"); diff --git a/src/lib/dhcpsrv/subnet.h b/src/lib/dhcpsrv/subnet.h index 87dedd6fd3..14723ba063 100644 --- a/src/lib/dhcpsrv/subnet.h +++ b/src/lib/dhcpsrv/subnet.h @@ -543,20 +543,20 @@ public: isc::asiolink::IOAddress getSiaddr() const; /// @brief Sets the flag indicating if the client identifier should be - /// ignored in the client's message. + /// recorded in the lease database. /// /// @param ignore If this value is true, the client identifiers are ignored /// in the messages from the clients for this subnet. - void setIgnoreClientId(const bool ignore) { - ignore_client_id_ = ignore; + void setRecordClientId(const bool record) { + record_client_id_ = record; } /// @brief Returns the flag indicating if the client identifiers should - /// be ignored for this subnet. + /// be recorded in the lease database. /// - /// @return true if client identifiers should be ignored, false otherwise. - bool getIgnoreClientId() const { - return (ignore_client_id_); + /// @return true if client identifiers should be recorded, false otherwise. + bool getRecordClientId() const { + return (record_client_id_); } private: @@ -578,8 +578,8 @@ private: /// @brief siaddr value for this subnet isc::asiolink::IOAddress siaddr_; - /// @brief Should server ignore client identifiers. - bool ignore_client_id_; + /// @brief Should server record client identifiers. + bool record_client_id_; }; /// @brief A pointer to a @c Subnet4 object diff --git a/src/lib/dhcpsrv/tests/subnet_unittest.cc b/src/lib/dhcpsrv/tests/subnet_unittest.cc index 3f879daa2e..a153209c4a 100644 --- a/src/lib/dhcpsrv/tests/subnet_unittest.cc +++ b/src/lib/dhcpsrv/tests/subnet_unittest.cc @@ -116,20 +116,20 @@ TEST(Subnet4Test, siaddr) { BadValue); } -// Checks if the ignore-client-id flag can be set and retrieved. -TEST(Subnet4Test, ignoreClientId) { +// Checks if the record-client-id flag can be set and retrieved. +TEST(Subnet4Test, recordClientId) { Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000); - // By default the flag should be set to false. - EXPECT_FALSE(subnet.getIgnoreClientId()); + // By default the flag should be set to true. + EXPECT_TRUE(subnet.getRecordClientId()); // Modify it and retrieve. - subnet.setIgnoreClientId(true); - EXPECT_TRUE(subnet.getIgnoreClientId()); + subnet.setRecordClientId(false); + EXPECT_FALSE(subnet.getRecordClientId()); // Modify again. - subnet.setIgnoreClientId(false); - EXPECT_FALSE(subnet.getIgnoreClientId()); + subnet.setRecordClientId(true); + EXPECT_TRUE(subnet.getRecordClientId()); } TEST(Subnet4Test, Pool4InSubnet4) {