mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[3747] Renamed ignore-client-id to record-client-id and reversed values.
This commit is contained in:
@@ -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",
|
||||
|
@@ -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<bool> ignore_client_id;
|
||||
// record-client-id
|
||||
isc::util::OptionalValue<bool> 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,
|
||||
|
@@ -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
|
||||
|
@@ -180,7 +180,7 @@ Subnet4::Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length,
|
||||
const Triplet<uint32_t>& 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");
|
||||
|
@@ -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
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user