2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-02 06:55:16 +00:00

[3747] Renamed ignore-client-id to record-client-id and reversed values.

This commit is contained in:
Marcin Siodelski
2015-05-12 14:22:25 +02:00
parent 1e2bfcdc46
commit dca41228db
6 changed files with 45 additions and 45 deletions

View File

@@ -74,10 +74,10 @@
"item_default": true "item_default": true
}, },
{ "item_name": "ignore-client-id", { "item_name": "record-client-id",
"item_type": "boolean", "item_type": "boolean",
"item_optional": true, "item_optional": true,
"item_default": false "item_default": true
}, },
{ "item_name": "option-def", { "item_name": "option-def",
@@ -275,10 +275,10 @@
"item_default": "0.0.0.0" "item_default": "0.0.0.0"
}, },
{ "item_name": "ignore-client-id", { "item_name": "record-client-id",
"item_type": "boolean", "item_type": "boolean",
"item_optional": true, "item_optional": true,
"item_default": false "item_default": true
}, },
{ "item_name": "pool", { "item_name": "pool",

View File

@@ -194,7 +194,7 @@ protected:
parser = new RelayInfoParser(config_id, relay_info_, Option::V4); parser = new RelayInfoParser(config_id, relay_info_, Option::V4);
} else if (config_id.compare("option-data") == 0) { } else if (config_id.compare("option-data") == 0) {
parser = new OptionDataListParser(config_id, options_, AF_INET); 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_); parser = new BooleanParser(config_id, boolean_values_);
} else { } else {
isc_throw(NotImplemented, "unsupported parameter: " << config_id); isc_throw(NotImplemented, "unsupported parameter: " << config_id);
@@ -252,26 +252,26 @@ protected:
Subnet4Ptr subnet4(new Subnet4(addr, len, t1, t2, valid, subnet_id)); Subnet4Ptr subnet4(new Subnet4(addr, len, t1, t2, valid, subnet_id));
subnet_ = subnet4; subnet_ = subnet4;
// ignore-client-id // record-client-id
isc::util::OptionalValue<bool> ignore_client_id; isc::util::OptionalValue<bool> record_client_id;
try { try {
ignore_client_id = boolean_values_->getParam("ignore-client-id"); record_client_id = boolean_values_->getParam("record-client-id");
} catch (...) { } catch (...) {
// Ignore because this parameter is optional and it may be specified // Ignore because this parameter is optional and it may be specified
// in the global scope. // 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. // check if there is global value specified.
if (!ignore_client_id.isSpecified()) { if (!record_client_id.isSpecified()) {
// If not specified, use false. // If not specified, use false.
ignore_client_id.specify(globalContext()->boolean_values_-> record_client_id.specify(globalContext()->boolean_values_->
getOptionalParam("ignore-client-id", false)); getOptionalParam("record-client-id", true));
} }
// Set the ignore-client-id value for the subnet. // Set the record-client-id value for the subnet.
subnet4->setIgnoreClientId(ignore_client_id.get()); subnet4->setRecordClientId(record_client_id.get());
// next-server // next-server
try { try {
@@ -397,7 +397,7 @@ namespace dhcp {
parser = new BooleanParser(config_id, globalContext()->boolean_values_); parser = new BooleanParser(config_id, globalContext()->boolean_values_);
} else if (config_id.compare("dhcp-ddns") == 0) { } else if (config_id.compare("dhcp-ddns") == 0) {
parser = new D2ClientConfigParser(config_id); 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_); parser = new BooleanParser(config_id, globalContext()->boolean_values_);
} else { } else {
isc_throw(DhcpConfigError, isc_throw(DhcpConfigError,

View File

@@ -1102,9 +1102,9 @@ TEST_F(Dhcp4ParserTest, echoClientId) {
CfgMgr::instance().echoClientId(true); 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. // and that values under the subnet are used.
TEST_F(Dhcp4ParserTest, ignoreClientIdNoGlobal) { TEST_F(Dhcp4ParserTest, recordClientIdNoGlobal) {
ConstElementPtr status; ConstElementPtr status;
std::string config = "{ " + genIfaceConfig() + "," + std::string config = "{ " + genIfaceConfig() + "," +
@@ -1112,12 +1112,12 @@ TEST_F(Dhcp4ParserTest, ignoreClientIdNoGlobal) {
"\"renew-timer\": 1000, " "\"renew-timer\": 1000, "
"\"subnet4\": [ " "\"subnet4\": [ "
"{" "{"
" \"ignore-client-id\": true," " \"record-client-id\": true,"
" \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ]," " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
" \"subnet\": \"192.0.2.0/24\"" " \"subnet\": \"192.0.2.0/24\""
"}," "},"
"{" "{"
" \"ignore-client-id\": false," " \"record-client-id\": false,"
" \"pools\": [ { \"pool\": \"192.0.3.1 - 192.0.3.100\" } ]," " \"pools\": [ { \"pool\": \"192.0.3.1 - 192.0.3.100\" } ],"
" \"subnet\": \"192.0.3.0/24\"" " \"subnet\": \"192.0.3.0/24\""
"} ]," "} ],"
@@ -1130,26 +1130,26 @@ TEST_F(Dhcp4ParserTest, ignoreClientIdNoGlobal) {
CfgSubnets4Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets4(); CfgSubnets4Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets4();
Subnet4Ptr subnet1 = cfg->selectSubnet(IOAddress("192.0.2.1")); Subnet4Ptr subnet1 = cfg->selectSubnet(IOAddress("192.0.2.1"));
ASSERT_TRUE(subnet1); ASSERT_TRUE(subnet1);
EXPECT_TRUE(subnet1->getIgnoreClientId()); EXPECT_TRUE(subnet1->getRecordClientId());
Subnet4Ptr subnet2 = cfg->selectSubnet(IOAddress("192.0.3.1")); Subnet4Ptr subnet2 = cfg->selectSubnet(IOAddress("192.0.3.1"));
ASSERT_TRUE(subnet2); 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 // when there is no such parameter under subnet and that the parameter
// specified for a subnet overrides the global setting. // specified for a subnet overrides the global setting.
TEST_F(Dhcp4ParserTest, ignoreClientIdGlobal) { TEST_F(Dhcp4ParserTest, recordClientIdGlobal) {
ConstElementPtr status; ConstElementPtr status;
std::string config = "{ " + genIfaceConfig() + "," + std::string config = "{ " + genIfaceConfig() + "," +
"\"rebind-timer\": 2000, " "\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, " "\"renew-timer\": 1000, "
"\"ignore-client-id\": true," "\"record-client-id\": true,"
"\"subnet4\": [ " "\"subnet4\": [ "
"{" "{"
" \"ignore-client-id\": false," " \"record-client-id\": false,"
" \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ]," " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
" \"subnet\": \"192.0.2.0/24\"" " \"subnet\": \"192.0.2.0/24\""
"}," "},"
@@ -1166,11 +1166,11 @@ TEST_F(Dhcp4ParserTest, ignoreClientIdGlobal) {
CfgSubnets4Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets4(); CfgSubnets4Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets4();
Subnet4Ptr subnet1 = cfg->selectSubnet(IOAddress("192.0.2.1")); Subnet4Ptr subnet1 = cfg->selectSubnet(IOAddress("192.0.2.1"));
ASSERT_TRUE(subnet1); ASSERT_TRUE(subnet1);
EXPECT_FALSE(subnet1->getIgnoreClientId()); EXPECT_FALSE(subnet1->getRecordClientId());
Subnet4Ptr subnet2 = cfg->selectSubnet(IOAddress("192.0.3.1")); Subnet4Ptr subnet2 = cfg->selectSubnet(IOAddress("192.0.3.1"));
ASSERT_TRUE(subnet2); ASSERT_TRUE(subnet2);
EXPECT_TRUE(subnet2->getIgnoreClientId()); EXPECT_TRUE(subnet2->getRecordClientId());
} }
// This test checks if it is possible to override global values // This test checks if it is possible to override global values

View File

@@ -180,7 +180,7 @@ Subnet4::Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length,
const Triplet<uint32_t>& valid_lifetime, const Triplet<uint32_t>& valid_lifetime,
const SubnetID id) const SubnetID id)
: Subnet(prefix, length, t1, t2, valid_lifetime, RelayInfo(IOAddress("0.0.0.0")), 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()) { if (!prefix.isV4()) {
isc_throw(BadValue, "Non IPv4 prefix " << prefix.toText() isc_throw(BadValue, "Non IPv4 prefix " << prefix.toText()
<< " specified in subnet4"); << " specified in subnet4");

View File

@@ -543,20 +543,20 @@ public:
isc::asiolink::IOAddress getSiaddr() const; isc::asiolink::IOAddress getSiaddr() const;
/// @brief Sets the flag indicating if the client identifier should be /// @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 /// @param ignore If this value is true, the client identifiers are ignored
/// in the messages from the clients for this subnet. /// in the messages from the clients for this subnet.
void setIgnoreClientId(const bool ignore) { void setRecordClientId(const bool record) {
ignore_client_id_ = ignore; record_client_id_ = record;
} }
/// @brief Returns the flag indicating if the client identifiers should /// @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. /// @return true if client identifiers should be recorded, false otherwise.
bool getIgnoreClientId() const { bool getRecordClientId() const {
return (ignore_client_id_); return (record_client_id_);
} }
private: private:
@@ -578,8 +578,8 @@ private:
/// @brief siaddr value for this subnet /// @brief siaddr value for this subnet
isc::asiolink::IOAddress siaddr_; isc::asiolink::IOAddress siaddr_;
/// @brief Should server ignore client identifiers. /// @brief Should server record client identifiers.
bool ignore_client_id_; bool record_client_id_;
}; };
/// @brief A pointer to a @c Subnet4 object /// @brief A pointer to a @c Subnet4 object

View File

@@ -116,20 +116,20 @@ TEST(Subnet4Test, siaddr) {
BadValue); BadValue);
} }
// Checks if the ignore-client-id flag can be set and retrieved. // Checks if the record-client-id flag can be set and retrieved.
TEST(Subnet4Test, ignoreClientId) { TEST(Subnet4Test, recordClientId) {
Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000); Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000);
// By default the flag should be set to false. // By default the flag should be set to true.
EXPECT_FALSE(subnet.getIgnoreClientId()); EXPECT_TRUE(subnet.getRecordClientId());
// Modify it and retrieve. // Modify it and retrieve.
subnet.setIgnoreClientId(true); subnet.setRecordClientId(false);
EXPECT_TRUE(subnet.getIgnoreClientId()); EXPECT_FALSE(subnet.getRecordClientId());
// Modify again. // Modify again.
subnet.setIgnoreClientId(false); subnet.setRecordClientId(true);
EXPECT_FALSE(subnet.getIgnoreClientId()); EXPECT_TRUE(subnet.getRecordClientId());
} }
TEST(Subnet4Test, Pool4InSubnet4) { TEST(Subnet4Test, Pool4InSubnet4) {