// Control sockets are third.
ConstElementPtr ctrl_sockets = config->get("control-sockets");
if (ctrl_sockets) {
- auto sockets_map = ctrl_sockets->mapValue();
+ auto const& sockets_map = ctrl_sockets->mapValue();
for (auto cs = sockets_map.cbegin(); cs != sockets_map.cend(); ++cs) {
ctx->setControlSocketInfo(cs->second, cs->first);
}
[] (ConstElementPtr json, KeywordSet& set) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
extract(elem, set);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
static_cast<void>(set.insert(elem.first));
// Skip entries with free content.
if ((elem.first != "user-context") &&
[] (ElementPtr config, ElementPtr json, size_t& cnt) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
test(config, elem, cnt);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
// Skip entries with free content.
if ((elem.first == "user-context") ||
(elem.first == "parameters")) {
[] (ConstElementPtr json, KeywordSet& set) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
extract(elem, set);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
static_cast<void>(set.insert(elem.first));
// Skip entries with free content.
if ((elem.first != "user-context") &&
[] (ElementPtr config, ElementPtr json, size_t& cnt) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
test(config, elem, cnt);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
// Skip entries with free content.
if ((elem.first == "user-context") ||
(elem.first == "parameters")) {
// Check unsupported objects.
if (message.empty()) {
- for (auto obj : args->mapValue()) {
+ for (auto const& obj : args->mapValue()) {
const string& obj_name = obj.first;
if (obj_name != "Dhcp4") {
LOG_ERROR(dhcp4_logger, DHCP4_CONFIG_UNSUPPORTED_OBJECT)
// Check unsupported objects.
if (message.empty()) {
- for (auto obj : args->mapValue()) {
+ for (auto const& obj : args->mapValue()) {
const string& obj_name = obj.first;
if (obj_name != "Dhcp4") {
LOG_ERROR(dhcp4_logger, DHCP4_CONFIG_UNSUPPORTED_OBJECT)
const ClientClassDictionaryPtr& dict =
CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
const ClientClassDefListPtr& defs_ptr = dict->getClasses();
- for (auto def : *defs_ptr) {
+ for (auto const& def : *defs_ptr) {
// Only remove evaluated classes. Other classes can be
// assigned via hooks libraries and we should not remove
// them because there is no way they can be added back.
// VIVCO options at most once per vendor.
set<uint32_t> vendor_ids;
// Get what already exists in the response.
- for (auto opt : resp->getOptions(DHO_VIVCO_SUBOPTIONS)) {
+ for (auto const& opt : resp->getOptions(DHO_VIVCO_SUBOPTIONS)) {
OptionVendorClassPtr vendor_opts;
vendor_opts = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second);
if (vendor_opts) {
}
// Iterate on the configured option list.
for (auto const& copts : co_list) {
- for (OptionDescriptor desc : copts->getList(DHCP4_OPTION_SPACE,
+ for (auto const& desc : copts->getList(DHCP4_OPTION_SPACE,
DHO_VIVCO_SUBOPTIONS)) {
if (!desc.option_) {
continue;
// VIVSO options at most once per vendor.
set<uint32_t> vendor_ids;
// Get what already exists in the response.
- for (auto opt : resp->getOptions(DHO_VIVSO_SUBOPTIONS)) {
+ for (auto const& opt : resp->getOptions(DHO_VIVSO_SUBOPTIONS)) {
OptionVendorPtr vendor_opts;
vendor_opts = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
if (vendor_opts) {
}
// Iterate on the configured option list
for (auto const& copts : co_list) {
- for (OptionDescriptor desc : copts->getList(DHCP4_OPTION_SPACE,
+ for (auto const& desc : copts->getList(DHCP4_OPTION_SPACE,
DHO_VIVSO_SUBOPTIONS)) {
if (!desc.option_) {
continue;
// The server could have provided the option using client classification or
// hooks. If there're vendor info options in the response already, use them.
map<uint32_t, OptionVendorPtr> vendor_rsps;
- for (auto opt : resp->getOptions(DHO_VIVSO_SUBOPTIONS)) {
+ for (auto const& opt : resp->getOptions(DHO_VIVSO_SUBOPTIONS)) {
OptionVendorPtr vendor_rsp;
vendor_rsp = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
if (vendor_rsp) {
// Next, try to get the vendor-id from the client packet's
// vendor-specific information option (125).
map<uint32_t, OptionVendorPtr> vendor_reqs;
- for (auto opt : query->getOptions(DHO_VIVSO_SUBOPTIONS)) {
+ for (auto const& opt : query->getOptions(DHO_VIVSO_SUBOPTIONS)) {
OptionVendorPtr vendor_req;
vendor_req = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
if (vendor_req) {
// Finally, try to get the vendor-id from the client packet's
// vendor-specific class option (124).
- for (auto opt : query->getOptions(DHO_VIVCO_SUBOPTIONS)) {
+ for (auto const& opt : query->getOptions(DHO_VIVCO_SUBOPTIONS)) {
OptionVendorClassPtr vendor_class;
vendor_class = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second);
if (vendor_class) {
if (hosts_databases) {
parameter_name = "hosts-databases";
CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
- for (auto it : hosts_databases->listValue()) {
+ for (auto const& it : hosts_databases->listValue()) {
db::DbAccessParser parser;
std::string access_string;
parser.parse(access_string, it);
ConstElementPtr compatibility = mutable_cfg->get("compatibility");
if (compatibility) {
- for (auto kv : compatibility->mapValue()) {
+ for (auto const& kv : compatibility->mapValue()) {
if (!kv.second || (kv.second->getType() != Element::boolean)) {
isc_throw(DhcpConfigError,
"compatibility parameter values must be "
"0xA0B0C0D" // 0x prefix
};
- for (auto valid_hex : valid_hexes) {
+ for (auto const& valid_hex : valid_hexes) {
ConstElementPtr x;
std::string config = createConfigWithOption(valid_hex, "data");
ConstElementPtr json;
// Iterate over the valid scenarios and verify they succeed.
data::ElementPtr exp_control;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
// Clear the config
// Iterate over the incorrect scenarios and verify they
// fail as expected. Note, we use parseDHCP4() directly
// as all of the errors above are enforced by the grammar.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
// Construct the config JSON
};
// Iterate over the test scenarios.
- for (auto test : tests) {
+ for (auto const& test : tests) {
SCOPED_TRACE(test.description_);
// Create a discover packet to use
dis->setIndex(ETH1_INDEX);
// Iterate over the test scenarios.
- for (auto test = tests.begin(); test != tests.end(); ++test) {
+ for (auto const& test : tests) {
{
- SCOPED_TRACE((*test).description_);
+ SCOPED_TRACE(test.description_);
// Configure subnet's timer values
- subnet_->setT1((*test).cfg_t1_);
- subnet_->setT2((*test).cfg_t2_);
+ subnet_->setT1(test.cfg_t1_);
+ subnet_->setT2(test.cfg_t2_);
// Discover/Offer exchange with the server
Pkt4Ptr offer = srv->processDiscover(dis);
// Verify the timers are as expected.
checkAddressParams(offer, subnet_,
- (*test).exp_t1_, (*test).exp_t2_);
+ test.exp_t1_, test.exp_t2_);
}
}
}
dis->setIndex(ETH1_INDEX);
// Iterate over the test scenarios.
- for (auto test = tests.begin(); test != tests.end(); ++test) {
+ for (auto const& test : tests) {
{
- SCOPED_TRACE((*test).description_);
+ SCOPED_TRACE(test.description_);
// Configure subnet's timer values
- subnet_->setT1((*test).cfg_t1_);
- subnet_->setT2((*test).cfg_t2_);
+ subnet_->setT1(test.cfg_t1_);
+ subnet_->setT2(test.cfg_t2_);
- subnet_->setT1Percent((*test).t1_percent_);
- subnet_->setT2Percent((*test).t2_percent_);
+ subnet_->setT1Percent(test.t1_percent_);
+ subnet_->setT2Percent(test.t2_percent_);
// Discover/Offer exchange with the server
Pkt4Ptr offer = srv->processDiscover(dis);
OptionUint32Ptr opt = boost::dynamic_pointer_cast
<OptionUint32> (offer->getOption(DHO_DHCP_RENEWAL_TIME));
- if ((*test).t1_exp_value_ == not_expected) {
+ if (test.t1_exp_value_ == not_expected) {
EXPECT_FALSE(opt) << "T1 present and shouldn't be";
} else {
ASSERT_TRUE(opt) << "Required T1 option missing or it has"
" an unexpected type";
- EXPECT_EQ(opt->getValue(), (*test).t1_exp_value_);
+ EXPECT_EQ(opt->getValue(), test.t1_exp_value_);
}
// Check T2 timer
opt = boost::dynamic_pointer_cast
<OptionUint32>(offer->getOption(DHO_DHCP_REBINDING_TIME));
- if ((*test).t2_exp_value_ == not_expected) {
+ if (test.t2_exp_value_ == not_expected) {
EXPECT_FALSE(opt) << "T2 present and shouldn't be";
} else {
ASSERT_TRUE(opt) << "Required T2 option missing or it has"
" an unexpected type";
- EXPECT_EQ(opt->getValue(), (*test).t2_exp_value_);
+ EXPECT_EQ(opt->getValue(), test.t2_exp_value_);
}
}
}
"with-ddns.json",
};
vector<string> files;
- for (string example : examples) {
+ for (const string& example : examples) {
string file = path + "/" + example;
files.push_back(file);
}
- for (const auto& file: files) {
+ for (const auto& file : files) {
string label("Checking configuration from file: ");
label += file;
SCOPED_TRACE(label);
}
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.hw_str_); {
// Build a DISCOVER
Pkt4Ptr query(new Pkt4(DHCPDISCOVER, 1234));
};
// Iterate over test scenarios.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_); {
// Set and verify DDNS params flags
subnet_->setDdnsSendUpdates(scenario.send_updates_);
Pkt4Ptr resp;
OptionStringPtr hostname;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE((scenario).description_);
{
// Set the hostname option.
Pkt4Ptr resp;
OptionStringPtr hostname;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE((scenario).description_);
{
// Set the hostname option.
Pkt4Ptr resp;
OptionStringPtr hostname;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE((scenario).description_);
{
// Set the hostname option.
Pkt4Ptr resp;
Option4ClientFqdnPtr fqdn;
- for (auto scenario = scenarios.begin(); scenario != scenarios.end(); ++scenario) {
- SCOPED_TRACE((*scenario).description_);
+ for (auto const& scenario : scenarios) {
+ SCOPED_TRACE(scenario.description_);
{
// Set the hostname option.
- ASSERT_NO_THROW(client.includeHostname((*scenario).original_));
- ASSERT_NO_THROW(client.includeFQDN(0, (*scenario).original_, (*scenario).name_type_));
+ ASSERT_NO_THROW(client.includeHostname(scenario.original_));
+ ASSERT_NO_THROW(client.includeFQDN(0, scenario.original_, scenario.name_type_));
// Send the DHCPDISCOVER and make sure that the server responded.
ASSERT_NO_THROW(client.doDiscover());
// Make sure the response fqdn is what we expect.
fqdn = boost::dynamic_pointer_cast<Option4ClientFqdn>(resp->getOption(DHO_FQDN));
ASSERT_TRUE(fqdn);
- EXPECT_EQ((*scenario).sanitized_, fqdn->getDomainName());
+ EXPECT_EQ(scenario.sanitized_, fqdn->getDomainName());
}
}
}
Pkt4Ptr resp;
Option4ClientFqdnPtr fqdn;
- for (auto scenario = scenarios.begin(); scenario != scenarios.end(); ++scenario) {
- SCOPED_TRACE((*scenario).description_);
+ for (auto const& scenario : scenarios) {
+ SCOPED_TRACE(scenario.description_);
{
// Set the hostname option.
- ASSERT_NO_THROW(client.includeHostname((*scenario).original_));
- ASSERT_NO_THROW(client.includeFQDN(0, (*scenario).original_, (*scenario).name_type_));
+ ASSERT_NO_THROW(client.includeHostname(scenario.original_));
+ ASSERT_NO_THROW(client.includeFQDN(0, scenario.original_, scenario.name_type_));
// Send the DHCPDISCOVER and make sure that the server responded.
ASSERT_NO_THROW(client.doDiscover());
// Make sure the response fqdn is what we expect.
fqdn = boost::dynamic_pointer_cast<Option4ClientFqdn>(resp->getOption(DHO_FQDN));
ASSERT_TRUE(fqdn);
- EXPECT_EQ((*scenario).sanitized_, fqdn->getDomainName());
+ EXPECT_EQ(scenario.sanitized_, fqdn->getDomainName());
}
}
}
}
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.label_);
{
// Create the original leasing client.
// Checks if callouts installed on the dhcp4_srv_configured ared indeed called
// and all the necessary parameters are passed.
TEST_F(LoadUnloadDhcpv4SrvTest, Dhcpv4SrvConfigured) {
- for (string parameters : {
+ for (const string& parameters : vector<string>{
"",
R"(, "parameters": { "mode": "fail-without-error" } )",
R"(, "parameters": { "mode": "fail-with-error" } )"}) {
[] (ConstElementPtr json, KeywordSet& set) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
extract(elem, set);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
static_cast<void>(set.insert(elem.first));
// Skip entries with free content.
if ((elem.first != "user-context") &&
auto print_keys = [](const KeywordSet& keys) {
string s = "{";
bool first = true;
- for (auto key : keys) {
+ for (auto const& key : keys) {
if (first) {
first = false;
s += " ";
[] (ElementPtr config, ElementPtr json, size_t& cnt) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
test(config, elem, cnt);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
// Skip entries with free content.
if ((elem.first == "user-context") ||
(elem.first == "parameters")) {
// Let's test them one by one
int cnt = 0;
- for ( auto s : scenarios) {
+ for (auto const& s : scenarios) {
cnt++;
string cfg = generateAuthConfig(s.global, s.subnet1, s.subnet2);
ASSERT_EQ(2, classes.size());
OptionVendorClassPtr opt_class1234;
OptionVendorClassPtr opt_class5678;
- for (auto opt : classes) {
+ for (auto const& opt : classes) {
ASSERT_EQ(DHO_VIVCO_SUBOPTIONS, opt.first);
OptionVendorClassPtr opt_class =
boost::dynamic_pointer_cast<OptionVendorClass>(opt.second);
// Check unsupported objects.
if (message.empty()) {
- for (auto obj : args->mapValue()) {
+ for (auto const& obj : args->mapValue()) {
const string& obj_name = obj.first;
if (obj_name != "Dhcp6") {
LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_UNSUPPORTED_OBJECT)
// Check unsupported objects.
if (message.empty()) {
- for (auto obj : args->mapValue()) {
+ for (auto const& obj : args->mapValue()) {
const string& obj_name = obj.first;
if (obj_name != "Dhcp6") {
LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_UNSUPPORTED_OBJECT)
Lease6CollectionPtr new_leases(new Lease6Collection());
if (!ctx.new_leases_.empty()) {
// Filter out reused leases as they were not committed.
- for (auto new_lease : ctx.new_leases_) {
+ for (auto const& new_lease : ctx.new_leases_) {
if (new_lease->reuseable_valid_lft_ == 0) {
new_leases->push_back(new_lease);
}
// Do per IA lists
for (auto const& iac : ctx.ias_) {
if (!iac.old_leases_.empty()) {
- for (auto old_lease : iac.old_leases_) {
+ for (auto const& old_lease : iac.old_leases_) {
if (ctx.new_leases_.empty()) {
deleted_leases->push_back(old_lease);
continue;
// D6O_VENDOR_CLASS options at most once per vendor.
set<uint32_t> vendor_ids;
// Get what already exists in the response.
- for (auto opt : answer->getOptions(D6O_VENDOR_CLASS)) {
+ for (auto const& opt : answer->getOptions(D6O_VENDOR_CLASS)) {
OptionVendorClassPtr vendor_class;
vendor_class = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second);
if (vendor_class) {
}
// Iterate on the configured option list.
for (auto const& copts : co_list) {
- for (OptionDescriptor desc : copts->getList(DHCP6_OPTION_SPACE,
- D6O_VENDOR_CLASS)) {
+ for (auto const& desc : copts->getList(DHCP6_OPTION_SPACE, D6O_VENDOR_CLASS)) {
if (!desc.option_) {
continue;
}
// D6O_VENDOR_OPTS options at most once per vendor.
set<uint32_t> vendor_ids;
// Get what already exists in the response.
- for (auto opt : answer->getOptions(D6O_VENDOR_OPTS)) {
+ for (auto const& opt : answer->getOptions(D6O_VENDOR_OPTS)) {
OptionVendorPtr vendor_opts;
vendor_opts = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
if (vendor_opts) {
}
// Iterate on the configured option list
for (auto const& copts : co_list) {
- for (OptionDescriptor desc : copts->getList(DHCP6_OPTION_SPACE,
- D6O_VENDOR_OPTS)) {
+ for (auto const& desc : copts->getList(DHCP6_OPTION_SPACE, D6O_VENDOR_OPTS)) {
if (!desc.option_) {
continue;
}
// The server could have provided the option using client classification or
// hooks. If there're vendor info options in the response already, use them.
map<uint32_t, OptionVendorPtr> vendor_rsps;
- for (auto opt : answer->getOptions(D6O_VENDOR_OPTS)) {
+ for (auto const& opt : answer->getOptions(D6O_VENDOR_OPTS)) {
OptionVendorPtr vendor_rsp;
vendor_rsp = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
if (vendor_rsp) {
// Next, try to get the vendor-id from the client packet's
// vendor-specific information option (17).
map<uint32_t, OptionVendorPtr> vendor_reqs;
- for (auto opt : question->getOptions(D6O_VENDOR_OPTS)) {
+ for (auto const& opt : question->getOptions(D6O_VENDOR_OPTS)) {
OptionVendorPtr vendor_req;
vendor_req = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
if (vendor_req) {
// Finally, try to get the vendor-id from the client packet's vendor-class
// option (16).
- for (auto opt : question->getOptions(D6O_VENDOR_CLASS)) {
+ for (auto const& opt : question->getOptions(D6O_VENDOR_CLASS)) {
OptionVendorClassPtr vendor_class;
vendor_class = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second);
if (vendor_class) {
// Get all IAs from the answer. For each IA, holding an address we will
// create a corresponding NameChangeRequest.
- for (auto answer_ia : answer->getOptions(D6O_IA_NA)) {
+ for (auto const& answer_ia : answer->getOptions(D6O_IA_NA)) {
/// @todo IA_NA may contain multiple addresses. We should process
/// each address individually. Currently we get only one.
Option6IAAddrPtr iaaddr = boost::static_pointer_cast<
const ClientClassDictionaryPtr& dict =
CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
const ClientClassDefListPtr& defs_ptr = dict->getClasses();
- for (auto def : *defs_ptr) {
+ for (auto const& def : *defs_ptr) {
// Only remove evaluated classes. Other classes can be
// assigned via hooks libraries and we should not remove
// them because there is no way they can be added back.
// our notion of client's FQDN in the Client FQDN option.
if (answer->getType() != DHCPV6_ADVERTISE) {
Lease6Ptr lease;
- for (auto l : ctx.new_leases_) {
+ for (auto const& l : ctx.new_leases_) {
if ((l->type_ == Lease::TYPE_NA) && (l->addr_ == addr)) {
lease = l;
break;
if (hosts_databases) {
parameter_name = "hosts-databases";
CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
- for (auto it : hosts_databases->listValue()) {
+ for (auto const& it : hosts_databases->listValue()) {
db::DbAccessParser parser;
std::string access_string;
parser.parse(access_string, it);
ConstElementPtr compatibility = mutable_cfg->get("compatibility");
if (compatibility) {
- for (auto kv : compatibility->mapValue()) {
+ for (auto const& kv : compatibility->mapValue()) {
if (!kv.second || (kv.second->getType() != Element::boolean)) {
isc_throw(DhcpConfigError,
"compatibility parameter values must be "
// Iterate over the list of scenarios. Each should fail to parse with
// a specific error message.
- for (auto scenario = scenarios.begin(); scenario != scenarios.end(); ++scenario) {
+ for (auto const& scenario : scenarios) {
{
- SCOPED_TRACE((*scenario).description_);
+ SCOPED_TRACE(scenario.description_);
ConstElementPtr config;
- ASSERT_NO_THROW(config = parseDHCP6((*scenario).config_json_))
+ ASSERT_NO_THROW(config = parseDHCP6(scenario.config_json_))
<< "invalid json, broken test";
ConstElementPtr status;
EXPECT_NO_THROW(status = Dhcpv6SrvTest::configure(srv_, config));
checkResult(status, 1);
- EXPECT_EQ(comment_->stringValue(), (*scenario).exp_error_msg_);
+ EXPECT_EQ(comment_->stringValue(), scenario.exp_error_msg_);
}
}
}
"0xA0B0C0D" // 0x prefix
};
- for (auto valid_hex : valid_hexes) {
+ for (auto const& valid_hex : valid_hexes) {
ConstElementPtr x;
std::string config = createConfigWithOption(valid_hex, "data");
ConstElementPtr json;
// Iterate over the valid scenarios and verify they succeed.
data::ElementPtr exp_control;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
// Clear the config
// Iterate over the incorrect scenarios and verify they
// fail as expected. Note, we use parseDHCP6() directly
// as all of the errors above are enforced by the grammar.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
// Construct the config JSON
"with-ddns.json",
};
vector<string> files;
- for (string example : examples) {
+ for (const string& example : examples) {
string file = path + "/" + example;
files.push_back(file);
}
- for (const auto& file: files) {
+ for (const auto& file : files) {
string label("Checking configuration from file: ");
label += file;
SCOPED_TRACE(label);
sol->setIndex(ETH0_INDEX);
// Iterate over the test scenarios.
- for (auto test = tests.begin(); test != tests.end(); ++test) {
+ for (auto const& test : tests) {
{
- SCOPED_TRACE((*test).description_);
+ SCOPED_TRACE(test.description_);
// Configure subnet for the scenario
- subnet_->setT1((*test).cfg_t1_);
- subnet_->setT2((*test).cfg_t2_);
- subnet_->setCalculateTeeTimes((*test).calculate_tee_times);
- subnet_->setT1Percent((*test).t1_percent_);
- subnet_->setT2Percent((*test).t2_percent_);
+ subnet_->setT1(test.cfg_t1_);
+ subnet_->setT2(test.cfg_t2_);
+ subnet_->setCalculateTeeTimes(test.calculate_tee_times);
+ subnet_->setT1Percent(test.t1_percent_);
+ subnet_->setT2Percent(test.t2_percent_);
AllocEngine::ClientContext6 ctx;
bool drop = !srv.earlyGHRLookup(sol, ctx);
ASSERT_FALSE(drop);
checkResponse(reply, DHCPV6_ADVERTISE, 1234);
// check that IA_NA was returned and T1 and T2 are correct.
- checkIA_NA(reply, 234, (*test).t1_exp_value_, (*test).t2_exp_value_);
+ checkIA_NA(reply, 234, test.t1_exp_value_, test.t2_exp_value_);
}
}
}
subnet_->setDdnsReplaceClientNameMode(D2ClientConfig::RCM_NEVER);
// Iterate over test scenarios.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_); {
// Make sure the lease does not exist.
ASSERT_FALSE(LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
// Checks if callouts installed on the dhcp6_srv_configured ared indeed called
// and all the necessary parameters are passed.
TEST_F(LoadUnloadDhcpv6SrvTest, Dhcpv6SrvConfigured) {
- for (string parameters : {
+ for (const string& parameters : vector<string>{
"",
R"(, "parameters": { "mode": "fail-without-error" } )",
R"(, "parameters": { "mode": "fail-with-error" } )"}) {
[] (ConstElementPtr json, KeywordSet& set) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
extract(elem, set);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
static_cast<void>(set.insert(elem.first));
// Skip entries with free content.
if ((elem.first != "user-context") &&
auto print_keys = [](const KeywordSet& keys) {
string s = "{";
bool first = true;
- for (auto key : keys) {
+ for (auto const& key : keys) {
if (first) {
first = false;
s += " ";
[] (ElementPtr config, ElementPtr json, size_t& cnt) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
test(config, elem, cnt);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
// Skip entries with free content.
if ((elem.first == "user-context") ||
(elem.first == "parameters")) {
ASSERT_EQ(2, classes.size());
OptionVendorClassPtr opt_class1234;
OptionVendorClassPtr opt_class5678;
- for (auto opt : classes) {
+ for (auto const& opt : classes) {
ASSERT_EQ(D6O_VENDOR_CLASS, opt.first);
OptionVendorClassPtr opt_class =
boost::dynamic_pointer_cast<OptionVendorClass>(opt.second);
ASSERT_EQ(2, options.size());
OptionVendorPtr opt_opts1234;
OptionVendorPtr opt_opts5678;
- for (auto opt : options) {
+ for (auto const& opt : options) {
ASSERT_EQ(D6O_VENDOR_OPTS, opt.first);
OptionVendorPtr opt_opts =
boost::dynamic_pointer_cast<OptionVendor>(opt.second);
OptionVendorPtr opt_opts1234;
OptionVendorPtr opt_docsis;
OptionVendorPtr opt_opts5678;
- for (auto opt : options) {
+ for (auto const& opt : options) {
ASSERT_EQ(D6O_VENDOR_OPTS, opt.first);
OptionVendorPtr opt_opts =
boost::dynamic_pointer_cast<OptionVendor>(opt.second);
NetconfAgent::checkModules(CfgServersMapPtr const& servers /* = {} */) const {
bool faulty_model(false);
if (servers) {
- for (auto pair : *servers) {
+ for (auto const& pair : *servers) {
if (!checkModule(pair.second->getModel())) {
faulty_model = true;
}
"supported. Check logs for details.");
}
- for (auto modrev : YANG_REVISIONS) {
+ for (auto const& modrev : YANG_REVISIONS) {
auto module = modules_.find(modrev.first);
if (module == modules_.end()) {
LOG_WARN(netconf_logger, NETCONF_MODULE_MISSING_WARN)
ostringstream s;
// Then print managed servers.
- for (auto serv : *ctx->getCfgServersMap()) {
+ for (auto const& serv : *ctx->getCfgServersMap()) {
if (s.tellp() != 0) {
s << " ";
}
netconf->set("hooks-libraries", hooks_config_.toElement());
// Set managed-servers
ElementPtr servers = Element::createMap();
- for (auto serv : *servers_map_) {
+ for (auto const& serv : *servers_map_) {
ElementPtr server = serv.second->toElement();
servers->set(serv.first, server);
}
ConstElementPtr servers = global->get("managed-servers");
if (servers) {
ElementPtr mutable_servers(copy(servers, 0));
- for (auto it : mutable_servers->mapValue()) {
+ for (auto const& it : mutable_servers->mapValue()) {
ElementPtr server(copy(it.second, 0));
cnt += setServerDefaults(it.first, server);
mutable_servers->set(it.first, server);
ConstElementPtr servers = global->get("managed-servers");
if (servers) {
ElementPtr mutable_servers(copy(servers, 0));
- for (auto it : mutable_servers->mapValue()) {
+ for (auto const& it : mutable_servers->mapValue()) {
ElementPtr mutable_server = copy(it.second, 0);
cnt += SimpleParser::deriveParams(global,
mutable_server,
// get managed servers.
ConstElementPtr servers = config->get("managed-servers");
if (servers) {
- for (auto it : servers->mapValue()) {
+ for (auto const& it : servers->mapValue()) {
ServerConfigParser server_parser;
CfgServerPtr server = server_parser.parse(it.second);
ctx->getCfgServersMap()->insert(make_pair(it.first, server));
EXPECT_NE(0, globals->mapValue().size());
// Maps and lists should be excluded.
- for (auto it : globals->mapValue()) {
+ for (auto const& it : globals->mapValue()) {
if (it.first == "astring") {
ASSERT_EQ(Element::string, it.second->getType());
EXPECT_EQ("okay", it.second->stringValue());
[] (ConstElementPtr json, KeywordSet& set) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
extract(elem, set);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
static_cast<void>(set.insert(elem.first));
// Skip entries with free content.
if ((elem.first != "user-context") &&
[] (ElementPtr config, ElementPtr json, size_t& cnt) {
if (json->getType() == Element::list) {
// Handle lists.
- for (auto elem : json->listValue()) {
+ for (auto const& elem : json->listValue()) {
test(config, elem, cnt);
}
} else if (json->getType() == Element::map) {
// Handle maps.
- for (auto elem : json->mapValue()) {
+ for (auto const& elem : json->mapValue()) {
// Skip entries with free content.
if ((elem.first == "user-context") ||
(elem.first == "parameters")) {
void
PerfSocket::initSocketData() {
- for (IfacePtr iface : IfaceMgr::instance().getIfaces()) {
- for (SocketInfo s : iface->getSockets()) {
+ for (auto const& iface : IfaceMgr::instance().getIfaces()) {
+ for (auto const& s : iface->getSockets()) {
if (s.sockfd_ == sockfd_) {
ifindex_ = iface->getIndex();
addr_ = s.addr_;
TestControl::addExtraOpts(const Pkt4Ptr& pkt) {
// Add all extra options that the user may have specified.
const dhcp::OptionCollection& extra_opts = options_.getExtraOpts();
- for (auto entry : extra_opts) {
+ for (auto const& entry : extra_opts) {
mergeOptionIntoPacket(pkt, entry.second);
}
}
TestControl::addExtraOpts(const Pkt6Ptr& pkt) {
// Add all extra options that the user may have specified.
const dhcp::OptionCollection& extra_opts = options_.getExtraOpts();
- for (auto entry : extra_opts) {
+ for (auto const& entry : extra_opts) {
pkt->addOption(entry.second);
}
}
if (options->empty()) {
return;
}
- for (auto option : options->listValue()) {
+ for (auto const& option : options->listValue()) {
parseOptionConfig(option);
}
}
isc_throw(BadValue, "option element is not a map");
}
// See SimpleParser::checkKeywords
- for (auto entry : option->mapValue()) {
+ for (auto const& entry : option->mapValue()) {
if (OPTION_PARAMETERS.count(entry.first) == 0) {
isc_throw(BadValue, "unknown parameter '" << entry.first << "'");
}
FlexOptionImpl::parseSubOptions(ConstElementPtr sub_options,
OptionConfigPtr opt_cfg,
Option::Universe universe) {
- for (ConstElementPtr sub_option : sub_options->listValue()) {
+ for (auto const& sub_option : sub_options->listValue()) {
parseSubOption(sub_option, opt_cfg, universe);
}
}
isc_throw(BadValue, "sub-option element is not a map");
}
// See SimpleParser::checkKeywords
- for (auto entry : sub_option->mapValue()) {
+ for (auto const& entry : sub_option->mapValue()) {
if (SUB_OPTION_PARAMETERS.count(entry.first) == 0) {
isc_throw(BadValue, "unknown parameter '" << entry.first << "'");
}
template <typename PktType>
void process(isc::dhcp::Option::Universe universe,
PktType query, PktType response) {
- for (auto pair : getOptionConfigMap()) {
+ for (auto const& pair : getOptionConfigMap()) {
for (const OptionConfigPtr& opt_cfg : pair.second) {
const isc::dhcp::ClientClass& client_class =
opt_cfg->getClass();
}
}
}
- for (auto pair : getSubOptionConfigMap()) {
+ for (auto const& pair : getSubOptionConfigMap()) {
for (const auto& sub_pair : pair.second) {
const SubOptionConfigPtr& sub_cfg = sub_pair.second;
uint16_t sub_code = sub_cfg->getCode();
}
auto list = Element::createList();
- for (auto scope : getPartnerScopes()) {
+ for (auto const& scope : getPartnerScopes()) {
list->add(Element::create(scope));
}
report->set("last-scopes", list);
if (config_vec.empty()) {
isc_throw(ConfigError, "a list of HA configurations must not be empty");
}
- for (auto config : config_vec) {
+ for (auto const& config : config_vec) {
parseOne(config_storage, config);
}
}
rel_config->validate();
auto peer_configs = rel_config->getAllServersConfig();
- for (auto peer_config : peer_configs) {
+ for (auto const& peer_config : peer_configs) {
try {
config_storage->map(peer_config.first, rel_config);
HAConfigParser::logConfigStatus(const HAConfigMapperPtr& config_storage) {
LOG_INFO(ha_logger, HA_CONFIGURATION_SUCCESSFUL);
- for (auto config : config_storage->getAll()) {
+ for (auto const& config : config_storage->getAll()) {
// If lease updates are disabled, we want to make sure that the user
// realizes that and that he has configured some other mechanism to
// populate leases.
return;
}
std::unordered_set<std::string> server_names;
- for (auto config : configs) {
+ for (auto const& config : configs) {
// Only the hot-standby mode is supported for multiple relationships.
if (config->getHAMode() != HAConfig::HOT_STANDBY) {
isc_throw(HAConfigValidationError, "multiple HA relationships are only supported for 'hot-standby' mode");
// Create the HA service and crank up the state machine.
auto service = boost::make_shared<HAService>(id, io_service, network_state,
configs[id], server_type);
- for (auto peer_config : configs[id]->getAllServersConfig()) {
+ for (auto const& peer_config : configs[id]->getAllServersConfig()) {
services_->map(peer_config.first, service);
}
}
// Schedule a start of the services. This ensures we begin after
// the dust has settled and Kea MT mode has been firmly established.
io_service->post([&]() {
- for (auto service : services_->getAll()) {
+ for (auto const& service : services_->getAll()) {
service->startClientAndListener();
}
});
}
HAImpl::~HAImpl() {
- for (auto service : services_->getAll()) {
+ for (auto const& service : services_->getAll()) {
// Shut down the services explicitly, we need finer control
// than relying on destruction order.
service->stopClientAndListener();
// Process the status get command for each HA service.
auto ha_relationships = Element::createList();
- for (auto service : services_->getAll()) {
+ for (auto const& service : services_->getAll()) {
auto ha_relationship = Element::createMap();
ConstElementPtr ha_servers = service->processStatusGet();
ha_relationship->set("ha-servers", ha_servers);
void
HAImpl::maintenanceStartHandler(hooks::CalloutHandle& callout_handle) {
ConstElementPtr response;
- for (auto service : services_->getAll()) {
+ for (auto const& service : services_->getAll()) {
response = service->processMaintenanceStart();
int rcode = CONTROL_RESULT_SUCCESS;
static_cast<void>(parseAnswer(rcode, response));
void
HAImpl::maintenanceCancelHandler(hooks::CalloutHandle& callout_handle) {
ConstElementPtr response;
- for (auto service : services_->getAll()) {
+ for (auto const& service : services_->getAll()) {
response = service->processMaintenanceCancel();
}
callout_handle.setArgument("response", response);
mapping_[key] = obj;
auto found = false;
- for (auto o : vector_) {
+ for (auto const& o : vector_) {
if (o == obj) {
found = true;
break;
}
std::set<std::string> scopes = query_filter_.getServedScopes();
ElementPtr list = Element::createList();
- for (std::string scope : scopes) {
+ for (const std::string& scope : scopes) {
list->add(Element::create(scope));
}
local->set("scopes", list);
auto scopes = query_filter_.getServedScopes();
ElementPtr scopes_list = Element::createList();
- for (auto scope : scopes) {
+ for (auto const& scope : scopes) {
scopes_list->add(Element::create(scope));
}
arguments->set("scopes", scopes_list);
if (accept_partner2 > nfd) {
nfd = accept_partner2;
}
- for (auto reader : readers) {
+ for (auto const& reader : readers) {
if (!reader.second) {
continue;
}
readers[fd] = true;
}
}
- for (auto reader : readers) {
+ for (auto const& reader : readers) {
if (!reader.second) {
continue;
}
if (accept_partner2 >= 0) {
close(accept_partner2);
}
- for (auto reader : readers) {
+ for (auto const& reader : readers) {
if (!reader.second) {
continue;
}
std::set<std::string>
QueryFilter::getServedScopesInternal() const {
std::set<std::string> scope_set;
- for (auto scope : scopes_) {
+ for (auto const& scope : scopes_) {
if (scope.second) {
scope_set.insert(scope.first);
}
QueryFilter::loadBalanceHash(const uint8_t* key, const size_t key_len) const {
uint8_t hash = static_cast<uint8_t>(key_len);
- for (auto i = key_len; i > 0;) {
+ for (size_t i = key_len; i > 0;) {
hash = loadb_mx_tbl[hash ^ key[--i]];
}
EXPECT_EQ(500, entries.size());
// Validate that we removed expired entries, not the valid ones.
- for (auto entry : entries) {
+ for (auto const& entry : entries) {
EXPECT_EQ(1, entry.ordinal_ % 2);
}
}
// to add several more leases to the backlog to exceed the limit.
if (overflow) {
ASSERT_NO_THROW(generateTestLeases4());
- for (auto lease : leases4_) {
+ for (auto const& lease : leases4_) {
service_->lease_update_backlog_.push(LeaseUpdateBacklog::ADD, lease);
}
}
// to add several more leases to the backlog to exceed the limit.
if (overflow) {
ASSERT_NO_THROW(generateTestLeases6());
- for (auto lease : leases6_) {
+ for (auto const& lease : leases6_) {
service_->lease_update_backlog_.push(LeaseUpdateBacklog::ADD, lease);
}
}
TestHAService service(1, io_service_, network_state_, config_storage);
// Test transition from the states for which it is allowed.
- for (auto state : valid_states) {
+ for (auto const& state : valid_states) {
EXPECT_NO_THROW(service.transition(state, HAService::NOP_EVT));
// Process ha-maintenance-notify command that should transition the
};
// Make sure that the transition from the other states is not allowed.
- for (auto state : invalid_states) {
+ for (auto const& state : invalid_states) {
EXPECT_NO_THROW(service.transition(state, HAService::NOP_EVT));
EXPECT_NO_THROW(service.runModel(HAService::NOP_EVT));
}
if (!static_scopes_.empty()) {
auto json_scopes = Element::createList();
- for (auto scope : static_scopes_) {
+ for (auto const& scope : static_scopes_) {
json_scopes->add(Element::create(scope));
}
response_arguments->set("scopes", json_scopes);
<< "'";
// Now, verify that each specified scope is handled.
- for(auto scope : scopes) {
+ for(auto const& scope : scopes) {
EXPECT_TRUE(service_->query_filter_.amServingScope(scope))
<< "test failed for state '" << service_->getStateLabel(my_state.state_)
<< "'";
EXPECT_EQ(2, page_count->intValue());
// Go over each lease and verify its correctness.
- for (ConstElementPtr lease : leases->listValue()) {
+ for (auto const& lease : leases->listValue()) {
ASSERT_EQ(Element::map, lease->getType());
ASSERT_TRUE(lease->contains("ip-address"));
ConstElementPtr ip_address = lease->get("ip-address");
// Expected response string.
string exp_rsp = "NCR generated for: 192.0.2.1, hostname: myhost.example.com.";
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Fetch the lease so we can update the DDNS direction flags.
},
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Let's create a lease with scenario attributes.
EXPECT_EQ(2, page_count->intValue());
// Go over each lease and verify its correctness.
- for (ConstElementPtr lease : leases->listValue()) {
+ for (auto const& lease : leases->listValue()) {
ASSERT_EQ(Element::map, lease->getType());
ASSERT_TRUE(lease->contains("ip-address"));
ConstElementPtr ip_address = lease->get("ip-address");
// Expected response string.
string exp_rsp = "NCR generated for: 2001:db8:1::1, hostname: myhost.example.com.";
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Fetch the lease so we can update the DDNS direction flags.
},
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Let's create a lease with scenario attributes.
tossNonMatchingElements(server_selector, class_list);
- for (auto c : class_list) {
+ for (auto const& c : class_list) {
client_classes.addClass(c);
}
}
tossNonMatchingElements(server_selector, class_list);
- for (auto c : class_list) {
+ for (auto const& c : class_list) {
client_classes.addClass(c);
}
}
auto tag = getServerTag(server_selector, "creating or updating option definition");
ElementPtr record_types = Element::createList();
- for (auto field : option_def->getRecordFields()) {
+ for (auto const& field : option_def->getRecordFields()) {
record_types->add(Element::create(static_cast<int>(field)));
}
MySqlBindingPtr record_types_binding = record_types->empty() ?
void multipleUpdateDeleteQueries(T first_index, R... other_indexes) {
std::vector<T> indexes({ first_index, other_indexes... });
db::MySqlBindingCollection empty_bindings;
- for (auto index : indexes) {
+ for (auto const& index : indexes) {
conn_.updateDeleteQuery(index, empty_bindings);
}
}
tossNonMatchingElements(server_selector, class_list);
- for (auto c : class_list) {
+ for (auto const& c : class_list) {
client_classes.addClass(c);
}
}
tossNonMatchingElements(server_selector, class_list);
- for (auto c : class_list) {
+ for (auto const& c : class_list) {
client_classes.addClass(c);
}
}
in_bindings.addTempString(option_def->getEncapsulatedSpace());
ElementPtr record_types = Element::createList();
- for (auto field : option_def->getRecordFields()) {
+ for (auto const& field : option_def->getRecordFields()) {
record_types->add(Element::create(static_cast<int>(field)));
}
void multipleUpdateDeleteQueries(T first_index, R... other_indexes) {
std::vector<T> indexes({ first_index, other_indexes... });
db::PsqlBindArray in_bindings;
- for (auto index : indexes) {
+ for (auto const& index : indexes) {
updateDeleteQuery(index, in_bindings);
}
}
string
join(const ProcessEnvVars& vars) {
string result;
- for (auto var : vars) {
+ for (auto const& var : vars) {
result += var + "\n";
}
return (result);
bool
IoServiceThreadPool::checkThreadId(std::thread::id id) {
- for (auto thread : threads_) {
+ for (const auto& thread : threads_) {
if (id == thread->get_id()) {
return (true);
}
}
// Make sure that all specified parameters are supported.
- auto command_params = command->mapValue();
- for (auto param : command_params) {
+ auto const& command_params = command->mapValue();
+ for (const auto& param : command_params) {
if ((param.first != CONTROL_COMMAND) &&
(param.first != CONTROL_ARGUMENTS) &&
(param.first != CONTROL_SERVICE) &&
if (size() != other.size()) {
return (false);
}
- for (auto kv : mapValue()) {
+ for (const auto& kv : mapValue()) {
auto key = kv.first;
if (other.contains(key)) {
if (!get(key)->equals(*other.get(key))) {
// over a checking for identical entries in b or vice-versa. As elements
// are removed from a if a match is found, we choose to iterate over b to
// avoid problems with element removal affecting the iterator.
- for (auto kv : b->mapValue()) {
+ for (const auto& kv : b->mapValue()) {
auto key = kv.first;
if (a->contains(key)) {
if (a->get(key)->equals(*b->get(key))) {
}
if (element->getType() == Element::map) {
- for (auto kv : other->mapValue()) {
+ for (const auto& kv : other->mapValue()) {
auto current_key = kv.first;
auto value = boost::const_pointer_cast<Element>(kv.second);
if (value && value->getType() != Element::null) {
// If the resulting element still contains data, we need to restore the
// key parameters, so we store them here.
ElementPtr new_elements = Element::createMap();
- for (auto kv : other->mapValue()) {
+ for (const auto& kv : other->mapValue()) {
auto current_key = kv.first;
auto value = boost::const_pointer_cast<Element>(kv.second);
if (value && value->getType() != Element::null) {
}
// If the element still contains data, restore the key elements.
if (element->size()) {
- for (auto kv : new_elements->mapValue()) {
+ for (const auto& kv : new_elements->mapValue()) {
element->set(kv.first, kv.second);
}
}
}
if (element->getType() == Element::map) {
- for (auto kv : other->mapValue()) {
+ for (const auto& kv : other->mapValue()) {
auto current_key = kv.first;
auto value = boost::const_pointer_cast<Element>(kv.second);
if (value && value->getType() != Element::null) {
return (ElementPtr(new StringElement(from->stringValue())));
} else if (from_type == Element::list) {
ElementPtr result = ElementPtr(new ListElement());
- for (auto elem : from->listValue()) {
+ for (const auto& elem : from->listValue()) {
if (level == 0) {
result->add(elem);
} else {
return (result);
} else if (from_type == Element::map) {
ElementPtr result = ElementPtr(new MapElement());
- for (auto kv : from->mapValue()) {
+ for (const auto& kv : from->mapValue()) {
auto key = kv.first;
auto value = kv.second;
if (level == 0) {
void
SimpleParser::checkRequired(const SimpleRequiredKeywords& required,
ConstElementPtr scope) {
- for (auto name : required) {
+ for (const auto& name : required) {
if (scope->contains(name)) {
continue;
}
SimpleParser::checkKeywords(const SimpleKeywords& keywords,
ConstElementPtr scope) {
string spurious;
- for (auto entry : scope->mapValue()) {
+ for (const auto& entry : scope->mapValue()) {
if (keywords.count(entry.first) == 0) {
if (spurious.empty()) {
spurious = entry.first;
ElementPtr metadata = Element::createMap();
ElementPtr tags = Element::createList();
- for (auto server_tag : server_tags_) {
+ for (const auto& server_tag : server_tags_) {
tags->add(Element::create(server_tag.get()));
}
// If no particular backend is selected, call each backend and return
// the first non-null (non zero) value.
if (backend_selector.amUnspecified()) {
- for (auto backend : backends_) {
+ for (const auto& backend : backends_) {
property = ((*backend).*MethodPointer)(server_selector, input...);
if (property) {
break;
// Backend selected, find the one that matches selection.
auto backends = selectBackends(backend_selector);
if (!backends.empty()) {
- for (auto backend : backends) {
+ for (const auto& backend : backends) {
property = ((*backend).*MethodPointer)(server_selector, input...);
if (property) {
break;
PropertyCollectionType& properties,
Args... input) const {
if (backend_selector.amUnspecified()) {
- for (auto backend : backends_) {
+ for (const auto& backend : backends_) {
properties = ((*backend).*MethodPointer)(server_selector, input...);
if (!properties.empty()) {
break;
} else {
auto backends = selectBackends(backend_selector);
if (!backends.empty()) {
- for (auto backend : backends) {
+ for (const auto& backend : backends) {
properties = ((*backend).*MethodPointer)(server_selector, input...);
if (!properties.empty()) {
break;
const db::ServerSelector& server_selector,
PropertyCollectionType& properties) const {
if (backend_selector.amUnspecified()) {
- for (auto backend : backends_) {
+ for (const auto& backend : backends_) {
properties = ((*backend).*MethodPointer)(server_selector);
if (!properties.empty()) {
break;
} else {
auto backends = selectBackends(backend_selector);
if (!backends.empty()) {
- for (auto backend : backends) {
+ for (const auto& backend : backends) {
properties = ((*backend).*MethodPointer)(server_selector);
if (!properties.empty()) {
break;
}
// Go over all backends.
- for (auto backend : backends_) {
+ for (const auto& backend : backends_) {
// If backend type is specified and it is not matching,
// do not select this backend.
if ((backend_selector.getBackendType() != db::BackendSelector::Type::UNSPEC) &&
/// @return Value of the property or 0 if property doesn't exist.
virtual int getProperty(const ServerSelector&,
const std::string& property_name) const {
- for (auto property : properties_) {
+ for (const auto& property : properties_) {
if (property.first == property_name) {
return (property.second);
}
virtual int getProperty(const ServerSelector&,
const std::string& property_name,
const int property_value) const {
- for (auto property : properties_) {
+ for (const auto& property : properties_) {
if ((property.first == property_name) &&
(property.second == property_value)) {
return (property.second);
virtual PropertiesList getProperties(const ServerSelector&,
const std::string& property_name) const {
PropertiesList properties;
- for (auto property : properties_) {
+ for (const auto& property : properties_) {
if (property.first == property_name) {
properties.push_back(property);
}
DatabaseConnection::toElement(const ParameterMap& params) {
isc::data::ElementPtr result = isc::data::Element::createMap();
- for (auto param: params) {
+ for (const auto& param : params) {
std::string keyword = param.first;
std::string value = param.second;
int64_t max_row_errors = 0;
// 2. Update the copy with the passed keywords.
- for (std::pair<std::string, ConstElementPtr> param : database_config->mapValue()) {
+ for (auto const& param : database_config->mapValue()) {
try {
if ((param.first == "persist") ||
(param.first == "readonly") ||
// Construct the database access string from all keywords and values in the
// parameter map where the value is not null.
string dbaccess;
- for (auto keyval : values_) {
+ for (const auto& keyval : values_) {
if (!keyval.second.empty()) {
// Separate keyword/value pair from predecessor (if there is one).
std::set<ServerTag> tags;
// Create a set of tags from strings.
- for (auto tag : server_tags) {
+ for (const auto& tag : server_tags) {
tags.insert(ServerTag(tag));
}
"readonly=not-boolean"
};
- for (auto access_str : access_strs) {
+ for (auto const& access_str : access_strs) {
/// @todo: verify that an ERROR is logged.
ASSERT_NO_THROW(DatabaseConnection::toElementDbAccessString(access_str));
}
ElementPtr
ClientClasses::toElement() const {
ElementPtr result(Element::createList());
- for (ClientClass c : container_) {
+ for (const ClientClass& c : container_) {
result->add(Element::create(c));
}
return (result);
DUIDFactory::createLinkLayerId(std::vector<uint8_t>& identifier,
uint16_t& htype) const {
// Let's find suitable interface.
- for (IfacePtr iface : IfaceMgr::instance().getIfaces()) {
+ for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
// All the following checks could be merged into one multi-condition
// statement, but let's keep them separated as perhaps one day
// we will grow knobs to selectively turn them on or off. Also,
// parent option will be created for each suboption.
// This will guarantee that none of the options plus
// suboptions will have more than 255 bytes.
- for (auto sub_option : candidate->getMutableOptions()) {
+ for (auto const& sub_option : candidate->getMutableOptions()) {
OptionPtr data_sub_option(new Option(candidate->getUniverse(),
candidate->getType(),
OptionBuffer(0)));
// authentication information for reconfig msg
// should have zero
- for (auto i : auth_info_) {
+ for (auto const& i : auth_info_) {
buf.writeUint8(i);
}
}
/// @return Number of deleted options or option definitions.
uint64_t deleteItems(const uint64_t id) {
uint64_t num_deleted = 0;
- for (auto space : option_space_map_) {
+ for (auto const& space : option_space_map_) {
auto container = space.second;
auto& index = container->template get<OptionIdIndexTag>();
num_deleted += index.erase(id);
Pkt6::getMACFromDocsisModem() {
HWAddrPtr mac;
OptionVendorPtr vendor;
- for (auto opt : getNonCopiedOptions(D6O_VENDOR_OPTS)) {
+ for (auto const& opt : getNonCopiedOptions(D6O_VENDOR_OPTS)) {
if (opt.first != D6O_VENDOR_OPTS) {
continue;
}
// CMTS-specific options in it.
HWAddrPtr mac;
OptionVendorPtr vendor;
- for (auto opt : getAllRelayOptions(D6O_VENDOR_OPTS,
- RELAY_SEARCH_FROM_CLIENT)) {
+ for (auto const& opt : getAllRelayOptions(D6O_VENDOR_OPTS,
+ RELAY_SEARCH_FROM_CLIENT)) {
if (opt.first != D6O_VENDOR_OPTS) {
continue;
}
const bool up, const bool running,
const bool inactive4,
const bool inactive6) {
- for (IfacePtr iface : ifaces_) {
+ for (const IfacePtr& iface : ifaces_) {
if (iface->getName() == name) {
iface->flag_loopback_ = loopback;
iface->flag_up_ = up;
cout << "There are " << ifacemgr->getIfacesLst().size()
<< " interfaces." << endl;
- for (IfacePtr iface : ifacemgr->getIfacesLst()) {
+ for (const IfacePtr& iface : ifacemgr->getIfacesLst()) {
cout << " " << iface->getFullName() << endl;
}
buff_[8] = 0xa9; //rdm value
buff_[9] = 0xaa; //rdm value
buff_[10] = 0xab; //rdm value
- for ( uint8_t i = 11; i < 27; i++ ) {
+ for (uint8_t i = 11; i < 27; i++) {
buff_[i] = 0xa8; //auth info 16 bytes
}
msg->getNonCopiedAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_CLIENT);
EXPECT_EQ(3, opts0.size());
vector<OptionPtr> lopts0;
- for (auto it : opts0) {
+ for (auto const& it : opts0) {
lopts0.push_back(it.second);
}
ASSERT_EQ(3, lopts0.size());
opts = msg->getNonCopiedAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_SERVER);
EXPECT_EQ(3, opts.size());
vector<OptionPtr> lopts;
- for (auto it : opts) {
+ for (auto const& it : opts) {
lopts.push_back(it.second);
}
ASSERT_EQ(3, lopts.size());
// Check collections.
opts = msg->getNonCopiedAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_CLIENT);
lopts0.clear();
- for (auto it : opts) {
+ for (auto const& it : opts) {
lopts0.push_back(it.second);
}
ASSERT_EQ(3, lopts0.size());
EXPECT_TRUE(lopts0[2] == relay1_opt1);
opts = msg->getAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_CLIENT);
lopts.clear();
- for (auto it : opts) {
+ for (auto const& it : opts) {
lopts.push_back(it.second);
}
ASSERT_EQ(3, lopts.size());
// Check collections.
opts = msg->getNonCopiedAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_SERVER);
lopts0.clear();
- for (auto it : opts) {
+ for (auto const& it : opts) {
lopts0.push_back(it.second);
}
ASSERT_EQ(3, lopts0.size());
EXPECT_TRUE(lopts0[2] == relay3_opt1);
opts = msg->getAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_SERVER);
lopts.clear();
- for (auto it : opts) {
+ for (auto const& it : opts) {
lopts.push_back(it.second);
}
ASSERT_EQ(3, lopts.size());
// The hosts can be used by the server to return reserved options to
// the DHCP client. Such options must be encapsulated (i.e., they must
// include suboptions).
- for (auto host : ctx.hosts_) {
+ for (auto const& host : ctx.hosts_) {
host.second->encapsulateOptions();
}
}
// our shared network.
Lease6Collection leases;
while (subnet) {
- for (auto l : all_leases) {
+ for (auto const& l : all_leases) {
if ((l)->subnet_id_ == subnet->getID()) {
leases.push_back(l);
}
hosts = HostMgr::instance().getAll4(ctx.subnet_->getID(), address);
}
- for (auto host : hosts) {
+ for (auto const& host : hosts) {
for (const AllocEngine::IdentifierPair& id_pair : ctx.host_identifiers_) {
// If we find the matching host we know that this address is reserved
// for us and we can return immediately.
// The hosts can be used by the server to return reserved options to
// the DHCP client. Such options must be encapsulated (i.e., they must
// include suboptions).
- for (auto host : ctx.hosts_) {
+ for (auto const& host : ctx.hosts_) {
host.second->encapsulateOptions();
}
}
// },..]
//
ElementPtr extended_info = Element::createList();
- for (auto relay : ctx.query_->relay_info_) {
+ for (auto const& relay : ctx.query_->relay_info_) {
ElementPtr relay_elem = Element::createMap();
relay_elem->set("hop", ElementPtr(new IntElement(relay.hop_count_)));
relay_elem->set("link", ElementPtr(new StringElement(relay.linkaddr_.toText())));
.arg(subnet_id).arg(address.toText());
ConstHostCollection hosts;
- for (auto host : getAll4(address)) {
+ for (auto const& host : getAll4(address)) {
if (host->getIPv4SubnetID() == subnet_id) {
LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS4_HOST)
if (addr.isV4()) {
HostContainerIndex4& idx = hosts_.get<4>();
// Delete IPv4 reservation and host.
- for (auto host : getAll4(subnet_id, addr)) {
+ for (auto const& host : getAll4(subnet_id, addr)) {
erased_hosts += idx.erase(host->getHostId());
}
erased_addresses = erased_hosts;
bool
CfgIface::multipleAddressesPerInterfaceActive() {
- for (IfacePtr iface : IfaceMgr::instance().getIfaces()) {
+ for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
if (iface->countActive4() > 1) {
return (true);
}
void
CfgIface::setState(const uint16_t family, const bool inactive,
const bool loopback_inactive) const {
- for (IfacePtr iface : IfaceMgr::instance().getIfaces()) {
+ for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
bool iface_inactive = iface->flag_loopback_ ? loopback_inactive : inactive;
if (family == AF_INET) {
iface->inactive4_ = iface_inactive;
CfgIface::setIfaceAddrsState(const uint16_t family, const bool active,
Iface& iface) const {
// Activate/deactivate all addresses.
- for (Iface::Address addr : iface.getAddresses()) {
+ for (const Iface::Address& addr : iface.getAddresses()) {
if (addr.get().getFamily() == family) {
iface.setActive(addr.get(), active);
}
// Hierarchical nature of the options configuration requires that
// we go over all options and decapsulate them before removing
// any of them. Let's walk over the existing option spaces.
- for (auto space_name : getOptionSpaceNames()) {
+ for (auto const& space_name : getOptionSpaceNames()) {
// Get all options for the option space.
auto options = getAll(space_name);
for (auto option_it = options->begin(); option_it != options->end();
// Iterate over this config's definitions in each space.
// If either a definition's name or code already exist in
// that space in "other", skip it. Otherwise, add it to "other".
- for (auto space : option_definitions_.getOptionSpaceNames()) {
- for (auto my_def : *(getAll(space))) {
- if ((other.get(space, my_def->getName())) ||
- (other.get(space, my_def->getCode()))) {
+ for (auto const& space : option_definitions_.getOptionSpaceNames()) {
+ for (auto const& tmp_def : *(getAll(space))) {
+ if ((other.get(space, tmp_def->getName())) ||
+ (other.get(space, tmp_def->getCode()))) {
// Already in "other" so skip it.
continue;
}
// Not in "other" so add it.
- other.add(my_def);
+ other.add(tmp_def);
}
}
void
CfgSubnets4::initAllocatorsAfterConfigure() {
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
subnet->initAllocatorsAfterConfigure();
}
}
void
CfgSubnets6::initAllocatorsAfterConfigure() {
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
subnet->initAllocatorsAfterConfigure();
}
}
}
void
-ClientClassDictionary::addClass(ClientClassDefPtr& class_def) {
+ClientClassDictionary::addClass(const ClientClassDefPtr& class_def) {
if (!class_def) {
isc_throw(BadValue, "ClientClassDictionary::addClass "
" - class definition cannot be null");
void
ClientClassDictionary::initMatchExpr(uint16_t family) {
std::queue<ExpressionPtr> expressions;
- for (auto c : *list_) {
+ for (auto const& c : *list_) {
if (!c->getTest().empty()) {
ExpressionPtr match_expr = boost::make_shared<Expression>();
ExpressionParser parser;
}
// All expressions successfully initialized. Let's set them for the
// client classes in the dictionary.
- for (auto c : *list_) {
+ for (auto const& c : *list_) {
if (!c->getTest().empty()) {
c->setMatchExpr(expressions.front());
expressions.pop();
void
ClientClassDictionary::createOptions(const CfgOptionDefPtr& external_defs) {
- for (auto c : *list_) {
+ for (auto const& c : *list_) {
// If the class has no options, skip it.
CfgOptionPtr class_options = c->getCfgOption();
if (!class_options || class_options->empty()) {
if (this != &rhs) {
list_->clear();
map_->clear();
- for (auto cclass : *(rhs.list_)) {
+ for (auto const& cclass : *(rhs.list_)) {
ClientClassDefPtr copy(new ClientClassDef(*cclass));
addClass(copy);
}
///
/// @throw DuplicateClientClassDef if class already exists within the
/// dictionary, BadValue if the pointer is empty.
- void addClass(ClientClassDefPtr& class_def);
+ void addClass(const ClientClassDefPtr& class_def);
/// @brief Fetches the class definition for a given class name
///
// unordered_set. Also, elminate the expired leases and those
// in the expired-reclaimed state.
unordered_set<IOAddress, IOAddress::Hash> leased_addresses;
- for (auto lease : leases) {
+ for (auto const& lease : leases) {
if ((lease->getType() == pool_type_) && (!lease->expired()) && (!lease->stateExpiredReclaimed())) {
leased_addresses.insert(lease->addr_);
}
}
// For each pool, check if the address is in the leases list.
size_t free_lease_count = 0;
- for (auto pool : pools) {
+ for (auto const& pool : pools) {
// Create the pool permutation so the resulting lease queue is no
// particular order.
IPRangePermutation perm(AddressRange(pool->getFirstAddress(), pool->getLastAddress()));
// unordered_set. Also, elminate the expired leases and those
// in the expired-reclaimed state.
unordered_set<IOAddress, IOAddress::Hash> leased_prefixes;
- for (auto lease : leases) {
+ for (auto const& lease : leases) {
if ((lease->getType() == Lease::TYPE_PD) && (!lease->expired()) && (!lease->stateExpiredReclaimed())) {
leased_prefixes.insert(lease->addr_);
}
}
// For each pool, check if the prefix is in the leases list.
size_t free_lease_count = 0;
- for (auto pool : pools) {
+ for (auto const& pool : pools) {
auto pool6 = boost::dynamic_pointer_cast<Pool6>(pool);
if (!pool6) {
continue;
HostDataSourceFactory::printRegistered() {
std::stringstream txt;
- for (auto x : map_) {
+ for (auto const& x : map_) {
txt << x.first << " ";
}
identifier_len);
}
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
ConstHostCollection hosts_plus =
source->getAll(identifier_type, identifier_begin, identifier_len);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
hosts = getCfgHosts()->getAll4(subnet_id);
}
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
ConstHostCollection hosts_plus = source->getAll4(subnet_id);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
hosts = getCfgHosts()->getAll6(subnet_id);
}
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
ConstHostCollection hosts_plus = source->getAll6(subnet_id);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
hosts = getCfgHosts()->getAllbyHostname(hostname);
}
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
ConstHostCollection hosts_plus = source->getAllbyHostname(hostname);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
hosts = getCfgHosts()->getAllbyHostname4(hostname, subnet_id);
}
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
ConstHostCollection hosts_plus = source->getAllbyHostname4(hostname,
subnet_id);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
hosts = getCfgHosts()->getAllbyHostname6(hostname, subnet_id);
}
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
ConstHostCollection hosts_plus = source->getAllbyHostname6(hostname,
subnet_id);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
hosts = getCfgHosts()->getAll4(address);
}
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
ConstHostCollection hosts_plus = source->getAll4(address);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
// Try to find a host in each configured backend. We return as soon
// as we find first hit.
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
host = source->get4(subnet_id, identifier_type,
identifier_begin, identifier_len);
HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4)
.arg(subnet_id)
.arg(address.toText());
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
host = source->get4(subnet_id, address);
if (host && host->getNegative()) {
return (ConstHostPtr());
.arg(subnet_id)
.arg(address.toText());
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
auto hosts_plus = source->getAll4(subnet_id, address);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_MGR_ALTERNATE_GET6_PREFIX)
.arg(prefix.toText())
.arg(static_cast<int>(prefix_len));
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
host = source->get6(prefix, prefix_len);
if (host && host->getNegative()) {
return (ConstHostPtr());
.arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
identifier_len));
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
host = source->get6(subnet_id, identifier_type,
identifier_begin, identifier_len);
HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_ADDRESS6)
.arg(subnet_id)
.arg(addr.toText());
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
host = source->get6(subnet_id, addr);
if (host && host->getNegative()) {
return (ConstHostPtr());
.arg(subnet_id)
.arg(address.toText());
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
auto hosts_plus = source->getAll6(subnet_id, address);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
}
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
- for (auto source : alternate_sources_) {
+ for (auto const&source : alternate_sources_) {
ConstHostCollection hosts_plus = source->getAll6(address);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
}
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
source->add(host);
}
}
"no hosts-database configured.");
}
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
bool alternate_erased = source->del(subnet_id, addr);
erased = alternate_erased || erased;
}
"no hosts-database configured.");
}
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
if (source->del4(subnet_id, identifier_type,
identifier_begin, identifier_len)) {
success = true;
"no hosts-database configured.");
}
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
if (source->del6(subnet_id, identifier_type,
identifier_begin, identifier_len)) {
success = true;
HostMgr::setIPReservationsUnique(const bool unique) {
// Iterate over the alternate sources first, because they may include those
// for which the new setting is not supported.
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
if (!source->setIPReservationsUnique(unique)) {
// One of the sources does not support this new mode of operation.
// Let's log a warning and back off the changes to the default
ip_reservations_unique_ = true;
LOG_WARN(hosts_logger, HOSTS_MGR_NON_UNIQUE_IP_UNSUPPORTED)
.arg(source->getType());
- for (auto source : alternate_sources_) {
+ for (auto const& source : alternate_sources_) {
source->setIPReservationsUnique(true);
}
return (false);
}
verifying = "relay-agent-info";
- for (auto elem : extended_info->mapValue()) {
+ for (auto const& elem : extended_info->mapValue()) {
if ((elem.first != "sub-options") &&
(elem.first != "remote-id") &&
(elem.first != "relay-id") &&
}
verifying = (upgraded ? "relays" : "relay-info");
- for (auto elem : relay->mapValue()) {
+ for (auto const& elem : relay->mapValue()) {
if ((elem.first != "hop") &&
(elem.first != "link") &&
(elem.first != "peer") &&
}
// Return all leases being within the page size.
- for (auto it : sorted) {
+ for (auto const& it : sorted) {
collection.push_back(Lease4Ptr(new Lease4(*it.second)));
if (collection.size() >= page_size.page_size_) {
break;
++pages;
start_addr = leases.back()->addr_;
- for (auto lease : leases) {
+ for (auto const& lease : leases) {
ConstElementPtr previous_user_context = lease->getContext();
vector<uint8_t> previous_relay_id = lease->relay_id_;
vector<uint8_t> previous_remote_id = lease->remote_id_;
/// @brief Destructor.
~NetworkStateImpl() {
- for (auto origin : disabled_by_origin_) {
+ for (auto const& origin : disabled_by_origin_) {
destroyTimer(origin);
}
}
bool
NetworkState::isDelayedEnableService() const {
- for (auto origin : impl_->disabled_by_origin_) {
+ for (auto const& origin : impl_->disabled_by_origin_) {
if (TimerMgr::instance()->isTimerRegistered(impl_->getTimerName(origin))) {
return (true);
}
"max-preferred-lifetime" };
// Iterate over the specified parameters and check if they are all supported.
- for (auto name_value_pair : class_def_cfg->mapValue()) {
+ for (auto const& name_value_pair : class_def_cfg->mapValue()) {
if ((supported_params.count(name_value_pair.first) > 0) ||
((family == AF_INET) && (supported_params_v4.count(name_value_pair.first) > 0)) ||
((family != AF_INET) && (supported_params_v6.count(name_value_pair.first) > 0))) {
try {
// Gather those parameters that are common for both IPv4 and IPv6
// reservations.
- BOOST_FOREACH(auto element, reservation_data->mapValue()) {
+ BOOST_FOREACH(auto const& element, reservation_data->mapValue()) {
// Check if we support this parameter.
if (!isSupportedParameter(element.first)) {
isc_throw(DhcpConfigError, "unsupported configuration"
host->setIPv4SubnetID(subnet_id);
- BOOST_FOREACH(auto element, reservation_data->mapValue()) {
+ BOOST_FOREACH(auto const& element, reservation_data->mapValue()) {
// For 'option-data' element we will use another parser which
// already returns errors with position appended, so don't
// surround it with try-catch.
host->setIPv6SubnetID(subnet_id);
- BOOST_FOREACH(auto element, reservation_data->mapValue()) {
+ BOOST_FOREACH(auto const& element, reservation_data->mapValue()) {
// Parse option values. Note that the configuration option parser
// returns errors with position information appended, so there is no
// need to surround it with try-clause (and rethrow with position
++pages;
start_addr = leases.back()->addr_;
- for (auto lease : leases) {
+ for (auto const& lease : leases) {
ConstElementPtr previous_user_context = lease->getContext();
vector<uint8_t> previous_relay_id = lease->relay_id_;
vector<uint8_t> previous_remote_id = lease->remote_id_;
// All pools have been exhausted. We will start offering the same
// addresses from these pools. We need to reset the permutations
// of the exhausted pools.
- for (auto e : exhausted) {
+ for (auto const& e : exhausted) {
getPoolState(pools[e])->getPermutation()->reset();
}
// Get random pool from those we just reset.
// All pools have been exhausted. We will start offering the same
// prefixes from these pools. We need to reset the permutations
// of the exhausted pools.
- for (auto e : exhausted) {
+ for (auto const& e : exhausted) {
getPoolState(pools[e])->getPermutation()->reset();
}
// Get random pool from those we just reset.
ResourceHandler::~ResourceHandler() {
lock_guard<mutex> lock_(mutex_);
- for (auto res : owned_) {
+ for (auto const& res : owned_) {
unLockInternal(res->type_, res->addr_);
}
owned_.clear();
}
// Iterate over the "other" globals, adding/overwriting them into
// this config's list of globals.
- for (auto other_global : other.getConfiguredGlobals()->valuesMap()) {
+ for (auto const& other_global : other.getConfiguredGlobals()->valuesMap()) {
addConfiguredGlobal(other_global.first, other_global.second);
}
// A handful of values are stored as members in SrvConfig. So we'll
// iterate over the merged globals, setting appropriate members.
- for (auto merged_global : getConfiguredGlobals()->valuesMap()) {
+ for (auto const& merged_global : getConfiguredGlobals()->valuesMap()) {
std::string name = merged_global.first;
ConstElementPtr element = merged_global.second;
try {
{ "hostname-char-replacement", "hostname-char-replacement" }
};
- for (auto param : params) {
+ for (auto const& param : params) {
if (d2_elem->contains(param.from_name)) {
if (!srv_elem->contains(param.to_name)) {
// No global value for it already, so let's add it.
(Lease::TYPE_V4, shared_from_this()));
setAllocationState(Lease::TYPE_V4, SubnetAllocationStatePtr());
- for (auto pool : pools_) {
+ for (auto const& pool : pools_) {
pool->setAllocationState(PoolRandomAllocationState::create(pool));
}
(Lease::TYPE_V4, shared_from_this()));
setAllocationState(Lease::TYPE_V4, SubnetAllocationStatePtr());
- for (auto pool : pools_) {
+ for (auto const& pool : pools_) {
pool->setAllocationState(PoolFreeLeaseQueueAllocationState::create(pool));
}
setAllocationState(Lease::TYPE_V4,
SubnetIterativeAllocationState::create(shared_from_this()));
- for (auto pool : pools_) {
+ for (auto const& pool : pools_) {
pool->setAllocationState(PoolIterativeAllocationState::create(pool));
}
}
setAllocationState(Lease::TYPE_PD, SubnetIterativeAllocationState::create(shared_from_this()));
}
// Create allocation states for NA pools.
- for (auto pool : pools_) {
+ for (auto const& pool : pools_) {
if (allocator_type == "random") {
pool->setAllocationState(PoolRandomAllocationState::create(pool));
} else {
}
}
// Create allocation states for TA pools.
- for (auto pool : pools_ta_) {
+ for (auto const& pool : pools_ta_) {
if (allocator_type == "random") {
pool->setAllocationState(PoolRandomAllocationState::create(pool));
} else {
}
}
// Create allocation states for PD pools.
- for (auto pool : pools_pd_) {
+ for (auto const& pool : pools_pd_) {
if (pd_allocator_type == "random") {
pool->setAllocationState(PoolRandomAllocationState::create(pool));
} else if (pd_allocator_type == "flq") {
// Iterate over the test scenarios.
ElementPtr orig_context;
ElementPtr exp_context;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Create the original user context from JSON.
// Iterate over the test scenarios.
Lease4Ptr lease;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
ElementPtr exp_context;
Lease4Ptr lease;
// Iterate over the test scenarios.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// If we have a MAC address this scenario is for a new client.
};
// Iterate over the scenarios and verify the correct outcome.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.desc_); {
// Create a context;
AllocEngine::ClientContext4 ctx(subnet_, ClientIdPtr(), hwaddr_,
ctx.query_.reset(new Pkt4(DHCPDISCOVER, 1234));
// Add client classes (if any)
- for (auto class_name : scenario.classes_) {
+ for (auto const& class_name : scenario.classes_) {
ctx.query_->addClass(class_name);
}
};
// Iterate over the scenarios and verify the correct outcome.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.desc_); {
// Create a context;
AllocEngine::ClientContext4 ctx(subnet_, ClientIdPtr(), hwaddr_,
ctx.query_.reset(new Pkt4(DHCPDISCOVER, 1234));
// Add client classes (if any)
- for (auto class_name : scenario.classes_) {
+ for (auto const& class_name : scenario.classes_) {
if (class_name == "BOOTP") {
ctx.query_->addClass(class_name);
} else {
};
// Iterate over the scenarios and verify the correct outcome.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.desc_); {
// Create a context;
AllocEngine::ClientContext4 ctx(subnet_, ClientIdPtr(), hwaddr_,
ctx.query_.reset(new Pkt4(DHCPDISCOVER, 1234));
// Add client classes (if any)
- for (auto class_name : scenario.classes_) {
+ for (auto const& class_name : scenario.classes_) {
ctx.query_->addClass(class_name);
}
// Iterate over the test scenarios.
ElementPtr orig_context;
ElementPtr exp_context;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Create the original user context from JSON.
// Iterate over the test scenarios.
DuidPtr current_duid;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
ElementPtr exp_context;
// Iterate over the test scenarios.
DuidPtr current_duid;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
Pkt6Ptr pkt;
};
// Iterate over the scenarios and verify the correct outcome.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.desc_); {
// Create a context;
AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", true,
Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234)));
// Add client classes (if any)
- for (auto class_name : scenario.classes_) {
+ for (auto const& class_name : scenario.classes_) {
ctx.query_->addClass(class_name);
}
};
// Iterate over the scenarios and verify the correct outcome.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.desc_); {
// Create a context;
AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", true,
Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234)));
// Add client classes (if any)
- for (auto class_name : scenario.classes_) {
+ for (auto const& class_name : scenario.classes_) {
ctx.query_->addClass(class_name);
}
};
// Iterate over the scenarios and verify the correct outcome.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.desc_); {
// Set the subnet's preferred-lifetime triplet.
subnet_->setPreferred(scenario.subnet_pref_);
AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", true,
Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234)));
// Add client classes (if any)
- for (auto class_name : scenario.classes_) {
+ for (auto const& class_name : scenario.classes_) {
string subclass(TemplateClientClassDef::SPAWN_CLASS_PREFIX);
subclass += class_name;
subclass += "_value";
};
// Iterate over the scenarios and verify the correct outcome.
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.desc_); {
// Create a context;
AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", true,
Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234)));
// Add client classes (if any)
- for (auto class_name : scenario.classes_) {
+ for (auto const& class_name : scenario.classes_) {
string subclass(TemplateClientClassDef::SPAWN_CLASS_PREFIX);
subclass += class_name;
subclass += "_value";
ASSERT_EQ(exp_valid, network->getValid().get()) << " network valid lifetime wrong";
const Subnet4SimpleCollection* subnets = network->getAllSubnets();
ASSERT_EQ(exp_subnets.size(), subnets->size()) << " wrong number of subnets";
- for (auto exp_id : exp_subnets) {
+ for (auto const& exp_id : exp_subnets) {
ASSERT_TRUE(network->getSubnet(exp_id))
<< " did not find expected subnet: " << exp_id;
}
ASSERT_EQ(exp_valid, network->getValid().get()) << " network valid lifetime wrong";
const Subnet6SimpleCollection* subnets = network->getAllSubnets();
ASSERT_EQ(exp_subnets.size(), subnets->size()) << " wrong number of subnets";
- for (auto exp_id : exp_subnets) {
+ for (auto const& exp_id : exp_subnets) {
ASSERT_TRUE(network->getSubnet(exp_id))
<< " did not find expected subnet: " << exp_id;
}
}
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.desc_); {
std::stringstream oss;
oss << "{ \"name\": \"foo\"";
}
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.desc_); {
std::stringstream oss;
oss << "{ \"name\": \"foo\"";
ASSERT_THROW(dictionary->initMatchExpr(AF_INET), std::exception);
// Ensure that no classes have their match expressions modified.
- for (auto c : (*dictionary->getClasses())) {
+ for (auto const& c : (*dictionary->getClasses())) {
EXPECT_FALSE(c->getMatchExpr());
}
}
ASSERT_THROW(dictionary->initMatchExpr(AF_INET), std::exception);
// Ensure that no classes have their match expressions modified.
- for (auto c : (*dictionary->getClasses())) {
+ for (auto const& c : (*dictionary->getClasses())) {
EXPECT_FALSE(c->getMatchExpr());
}
}
}
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
subnet_->setDdnsReplaceClientNameMode(scenario.mode_);
}
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
subnet_->setDdnsReplaceClientNameMode(scenario.mode_);
}
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
Option4ClientFqdn request(0, Option4ClientFqdn::RCODE_CLIENT(),
};
Option6ClientFqdnPtr response;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
Option6ClientFqdn request(0, scenario.client_name_, scenario.name_type_);
"0x0c000301C0000302" // upper or lower case digits
};
- for (auto hex_str : valid_hexes) {
+ for (auto const& hex_str : valid_hexes) {
ostringstream os;
os <<
"{ \n"
};
// Iterate over our test scenarios
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
// Build the configuration text.
// Iterate over the valid scenarios and verify they succeed.
ConstElementPtr config_elems;
ConstElementPtr queue_control;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
// Construct the config JSON
// Iterate over the valid scenarios and verify they succeed.
ConstElementPtr config_elems;
ConstElementPtr queue_control;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
// Construct the config JSON
EXPECT_TRUE(candidate.isV4Zero());
auto i = 0;
- for (auto address_lease : leases) {
+ for (auto const& address_lease : leases) {
if (i % 2) {
EXPECT_TRUE(lease_mgr.deleteLease(address_lease.second));
}
EXPECT_TRUE(candidate.isV4Zero());
auto i = 0;
- for (auto address_lease : leases) {
+ for (auto const& address_lease : leases) {
if (i % 2) {
auto lease = address_lease.second;
lease->state_ = Lease::STATE_EXPIRED_RECLAIMED;
EXPECT_TRUE(candidate.isV6Zero());
auto i = 0;
- for (auto address_lease : leases) {
+ for (auto const& address_lease : leases) {
if (i % 2) {
EXPECT_TRUE(lease_mgr.deleteLease(address_lease.second));
}
EXPECT_TRUE(candidate.isV6Zero());
auto i = 0;
- for (auto address_lease : leases) {
+ for (auto const& address_lease : leases) {
if (i % 2) {
auto lease = address_lease.second;
lease->state_ = Lease::STATE_EXPIRED_RECLAIMED;
EXPECT_TRUE(candidate.isV6Zero());
auto i = 0;
- for (auto address_lease : leases) {
+ for (auto const& address_lease : leases) {
if (i % 2) {
EXPECT_TRUE(lease_mgr.deleteLease(address_lease.second));
}
EXPECT_TRUE(candidate.isV6Zero());
auto i = 0;
- for (auto address_lease : leases) {
+ for (auto const& address_lease : leases) {
if (i % 2) {
auto lease = address_lease.second;
lease->state_ = Lease::STATE_EXPIRED_RECLAIMED;
std::ostringstream os;
os << v4_hdr_;
- for (auto row : rows) {
+ for (auto const& row : rows) {
os << row;
}
std::ostringstream os;
os << v6_hdr_;
- for (auto row : rows) {
+ for (auto const& row : rows) {
os << row;
}
Lease4Ptr lease(new Lease4());
ElementPtr orig_context;
ElementPtr exp_context;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Create the original user context from JSON.
Lease4Ptr lease(new Lease4());
ElementPtr user_context;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Create the original user context from JSON.
Lease6Ptr lease(new Lease6());
ElementPtr orig_context;
ElementPtr exp_context;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Create the original user context from JSON.
Lease6Ptr lease(new Lease6());
ElementPtr user_context;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
// Create the user context from JSON.
ElementPtr ctx = Element::createMap();
if (classes.size()) {
ElementPtr clist = Element::createList();
- for (auto client_class : classes ) {
+ for (auto const& client_class : classes ) {
clist->add(Element::create(client_class));
}
EXPECT_EQ(classes.size(), clc_.size(ltype));
auto expected_count = expected_counts.begin();
- for (auto client_class : classes) {
+ for (auto const& client_class : classes) {
size_t count;
ASSERT_NO_THROW_LOG(count = clc_.getClassCount(client_class, ltype));
EXPECT_EQ(count, *expected_count) << ", count is wrong for client_class: " << client_class;
std::list<size_t> expected_new_counts, const Lease::Type& ltype) {
// Start the map with a count of one for all the old classes.
clc_.clear();
- for (auto client_class : old_classes) {
+ for (auto const& client_class : old_classes) {
ASSERT_NO_THROW_LOG(clc_.setClassCount(client_class, 1, ltype));
}
// Verify class counts for the old lease's classes are right.
auto expected_count = expected_old_counts.begin();
- for (auto client_class : old_classes) {
+ for (auto const& client_class : old_classes) {
size_t count;
ASSERT_NO_THROW_LOG(count = clc_.getClassCount(client_class, ltype));
EXPECT_EQ(count, *expected_count)
// Verify class counts for the new lease's classes are right.
expected_count = expected_new_counts.begin();
- for (auto client_class : new_classes) {
+ for (auto const& client_class : new_classes) {
size_t count;
ASSERT_NO_THROW_LOG(count = clc_.getClassCount(client_class, ltype));
EXPECT_EQ(count, *expected_count)
};
// Iterate over the invalid scenarios.
- for (auto scenario : invalid_scenarios) {
+ for (auto const& scenario : invalid_scenarios) {
// Construct the lease and context.
lease = leaseFactory(Lease::TYPE_V4);
ElementPtr ctx;
};
// Iterate over the scenarios.
- for (auto scenario : valid_scenarios) {
+ for (auto const& scenario : valid_scenarios) {
// Construct the lease and context.
lease = leaseFactory(Lease::TYPE_V4);
if (!scenario.ctx_json_.empty()) {
};
// Bake all the leases.
- for ( auto recipe : recipes ) {
+ for (auto const& recipe : recipes) {
ElementPtr ctx = makeContextWithClasses(recipe.classes_);
ASSERT_TRUE(makeLease4(recipe.address_, 777, recipe.state_, ctx));
}
};
// Bake all the leases.
- for ( auto recipe : recipes ) {
+ for (auto const& recipe : recipes) {
ElementPtr ctx = makeContextWithClasses(recipe.classes_);
ASSERT_TRUE(makeLease6(recipe.ltype_, recipe.address_, recipe.prefix_len_, 777, recipe.state_, ctx));
}
// Iterate over the valid scenarios and verify they succeed.
ConstElementPtr config_elems;
ConstElementPtr multi_threading_config;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
SrvConfig srv_config;
// Iterate over the valid scenarios and verify they succeed.
ConstElementPtr config_elems;
ConstElementPtr queue_control;
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SCOPED_TRACE(scenario.description_);
{
SrvConfig srv_config;
}
};
- for (auto scenario : scenarios) {
+ for (auto const& scenario : scenarios) {
SrvConfig conf(32);
ElementPtr input_cfg;
ConstElementPtr exp_cfg;
GenericConfigBackendDHCPv4Test::getAllSubnets4Test() {
// Insert test subnets into the database. Note that the second subnet will
// overwrite the first subnet as they use the same ID.
- for (auto subnet : test_subnets_) {
+ for (auto const& subnet : test_subnets_) {
cbptr_->createUpdateSubnet4(ServerSelector::ALL(), subnet);
// That subnet overrides the first subnet so the audit entry should
test_subnets_[3]->setSharedNetworkName("level2");
// Store shared networks in the database.
- for (auto network : test_networks_) {
+ for (auto const& network : test_networks_) {
cbptr_->createUpdateSharedNetwork4(ServerSelector::ALL(), network);
}
// Store subnets in the database.
- for (auto subnet : test_subnets_) {
+ for (auto const& subnet : test_subnets_) {
cbptr_->createUpdateSubnet4(ServerSelector::ALL(), subnet);
}
GenericConfigBackendDHCPv4Test::getAllSharedNetworks4Test() {
// Insert test shared networks into the database. Note that the second shared
// network will overwrite the first shared network as they use the same name.
- for (auto network : test_networks_) {
+ for (auto const& network : test_networks_) {
cbptr_->createUpdateSharedNetwork4(ServerSelector::ALL(), network);
// That shared network overrides the first one so the audit entry should
// option definition will overwrite the first option definition as they use
// the same code and space.
size_t updates_num = 0;
- for (auto option_def : test_option_defs_) {
+ for (auto const& option_def : test_option_defs_) {
cbptr_->createUpdateOptionDef4(ServerSelector::ALL(), option_def);
// That option definition overrides the first one so the audit entry should
ASSERT_EQ(2, subnets.size());
// Verify that the subnets returned are as expected.
- for (auto subnet : subnets) {
+ for (auto const& subnet : subnets) {
ASSERT_EQ(1, subnet->getServerTags().size());
EXPECT_EQ("all", subnet->getServerTags().begin()->get());
if (subnet->getID() == 1024) {
GenericConfigBackendDHCPv6Test::getAllSubnets6Test() {
// Insert test subnets into the database. Note that the second subnet will
// overwrite the first subnet as they use the same ID.
- for (auto subnet : test_subnets_) {
+ for (auto const& subnet : test_subnets_) {
cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet);
// That subnet overrides the first subnet so the audit entry should
test_subnets_[3]->setSharedNetworkName("level2");
// Store shared networks in the database.
- for (auto network : test_networks_) {
+ for (auto const& network : test_networks_) {
cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(), network);
}
// Store subnets in the database.
- for (auto subnet : test_subnets_) {
+ for (auto const& subnet : test_subnets_) {
cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet);
}
GenericConfigBackendDHCPv6Test::getAllSharedNetworks6Test() {
// Insert test shared networks into the database. Note that the second shared
// network will overwrite the first shared network as they use the same name.
- for (auto network : test_networks_) {
+ for (auto const& network : test_networks_) {
cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(), network);
// That shared network overrides the first one so the audit entry should
// option definition will overwrite the first option definition as they use
// the same code and space.
size_t updates_num = 0;
- for (auto option_def : test_option_defs_) {
+ for (auto const& option_def : test_option_defs_) {
cbptr_->createUpdateOptionDef6(ServerSelector::ALL(), option_def);
// That option definition overrides the first one so the audit entry should
ASSERT_EQ(2, subnets.size());
// Verify that the subnets returned are as expected.
- for (auto subnet : subnets) {
+ for (auto const& subnet : subnets) {
ASSERT_EQ(1, subnet->getServerTags().size());
EXPECT_EQ("all", subnet->getServerTags().begin()->get());
if (subnet->getID() == 1024) {
bool got1 = false;
bool got2 = false;
bool got3 = false;
- for (auto host : from_hds) {
+ for (auto const& host : from_hds) {
if (host->getIdentifierType() == Host::IDENT_HWADDR) {
EXPECT_FALSE(got1);
got1 = true;
bool got1 = false;
bool got2 = false;
bool got3 = false;
- for (auto host : from_hds) {
+ for (auto const& host : from_hds) {
if (host->getIdentifierType() == Host::IDENT_HWADDR) {
EXPECT_FALSE(got1);
got1 = true;
bool got1 = false;
bool got2 = false;
bool got3 = false;
- for (auto host : from_hds) {
+ for (auto const& host : from_hds) {
if (host->getIdentifierType() == Host::IDENT_HWADDR) {
EXPECT_FALSE(got1);
got1 = true;
Lease4Collection page = lmptr_->getLeases4(last_address, LeasePageSize(3));
// Collect leases in a common structure. They may be out of order.
- for (Lease4Ptr lease : page) {
+ for (const Lease4Ptr& lease : page) {
all_leases.push_back(lease);
}
// Make sure that all leases that we stored in the lease database
// have been retrieved.
- for (Lease4Ptr lease : leases) {
+ for (const Lease4Ptr& lease : leases) {
bool found = false;
- for (Lease4Ptr returned_lease : all_leases) {
+ for (const Lease4Ptr& returned_lease : all_leases) {
if (lease->addr_ == returned_lease->addr_) {
found = true;
break;
Lease6Collection page = lmptr_->getLeases6(last_address, LeasePageSize(3));
// Collect leases in a common structure. They may be out of order.
- for (Lease6Ptr lease : page) {
+ for (const Lease6Ptr& lease : page) {
all_leases.push_back(lease);
}
// Make sure that all leases that we stored in the lease database
// have been retrieved.
- for (Lease6Ptr lease : leases) {
+ for (const Lease6Ptr& lease : leases) {
bool found = false;
- for (Lease6Ptr returned_lease : all_leases) {
+ for (const Lease6Ptr& returned_lease : all_leases) {
if (lease->addr_ == returned_lease->addr_) {
found = true;
break;
GenericLeaseMgrTest::countLogs(TrackingLeaseMgr::CallbackType type, SubnetID subnet_id,
Lease::Type lease_type) const {
int count = 0;
- for (auto log : logs_) {
+ for (auto const& log : logs_) {
if ((log.type == type) && (log.subnet_id == subnet_id) && (log.lease->getType() == lease_type)) {
++count;
}
ElementPtr ctx = Element::createMap();
if (classes.size()) {
ElementPtr clist = Element::createList();
- for (auto client_class : classes ) {
+ for (auto const& client_class : classes ) {
clist->add(Element::create(client_class));
}
void mergeServerTags(const StampedElementPtr& elem,
const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
elem->setServerTag(tag.get());
}
}
return (subnet->getServerTags().empty() ? subnet : Subnet4Ptr());
}
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
return (subnet);
}
return (subnet->getServerTags().empty() ? subnet : Subnet4Ptr());
}
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
return (subnet);
}
Subnet4Collection
TestConfigBackendDHCPv4::getAllSubnets4(const db::ServerSelector& server_selector) const {
Subnet4Collection subnets;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
if (server_selector.amAny()) {
subnets.insert(subnet);
continue;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
subnets.insert(subnet);
got = true;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*subnet)->hasServerTag(ServerTag(tag))) {
subnets.insert(*subnet);
got = true;
// Subnet collection does not include the index by shared network name.
// We need to iterate over the subnets and pick those that are associated
// with a shared network.
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
// Skip subnets which do not match the server selector.
if (server_selector.amUnassigned() &&
!subnet->getServerTags().empty()) {
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
got = true;
break;
return (network->getServerTags().empty() ? network : SharedNetwork4Ptr());
}
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (network->hasServerTag(ServerTag(tag))) {
return (network);
}
SharedNetwork4Collection
TestConfigBackendDHCPv4::getAllSharedNetworks4(const db::ServerSelector& server_selector) const{
SharedNetwork4Collection shared_networks;
- for (auto shared_network : shared_networks_) {
+ for (auto const& shared_network : shared_networks_) {
if (server_selector.amAny()) {
shared_networks.push_back(shared_network);
continue;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
shared_networks.push_back(shared_network);
got = true;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*shared_network)->hasServerTag(ServerTag(tag))) {
shared_networks.push_back(*shared_network);
got = true;
option_def_it != option_def_it_pair.second;
++option_def_it) {
if ((*option_def_it)->getOptionSpaceName() == space) {
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*option_def_it)->hasServerTag(ServerTag(tag))) {
return (*option_def_it);
}
TestConfigBackendDHCPv4::getAllOptionDefs4(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
OptionDefContainer option_defs;
- for (auto option_def : option_defs_) {
+ for (auto const& option_def : option_defs_) {
bool got = false;
if (server_selector.amUnassigned()) {
if (option_def->getServerTags().empty()) {
got = true;
}
} else {
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (option_def->hasServerTag(ServerTag(tag))) {
option_defs.push_back(option_def);
got = true;
auto lb = index.lower_bound(modification_time);
for (auto option_def = lb; option_def != index.end(); ++option_def) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*option_def)->hasServerTag(ServerTag(tag))) {
option_defs.push_back(*option_def);
got = true;
for (auto option_it = option_it_pair.first; option_it != option_it_pair.second;
++option_it) {
if (option_it->space_name_ == space) {
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (option_it->hasServerTag(ServerTag(tag))) {
return (OptionDescriptorPtr(new OptionDescriptor(*option_it)));
}
TestConfigBackendDHCPv4::getAllOptions4(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
OptionContainer options;
- for (auto option : options_) {
+ for (auto const& option : options_) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (option.hasServerTag(ServerTag(tag))) {
options.push_back(option);
got = true;
auto lb = index.lower_bound(modification_time);
for (auto option = lb; option != index.end(); ++option) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (option->hasServerTag(ServerTag(tag))) {
options.push_back(*option);
got = true;
auto global_range = index.equal_range(name);
for (auto global_it = global_range.first; global_it != global_range.second;
++global_it) {
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*global_it)->hasServerTag(ServerTag(tag))) {
return (*global_it);
}
TestConfigBackendDHCPv4::getAllGlobalParameters4(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
StampedValueCollection globals;
- for (auto global : globals_) {
+ for (auto const& global : globals_) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (global->hasServerTag(ServerTag(tag))) {
globals.insert(global);
got = true;
auto lb = index.lower_bound(modification_time);
for (auto global = lb; global != index.end(); ++global) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*global)->hasServerTag(ServerTag(tag))) {
globals.insert(*global);
got = true;
TestConfigBackendDHCPv4::getClientClass4(const db::ServerSelector& server_selector,
const std::string& name) const {
ClientClassDefPtr client_class;
- for (auto c : classes_) {
+ for (auto const& c : classes_) {
if (c->getName() == name) {
client_class = c;
break;
return (client_class->getServerTags().empty() ? client_class : ClientClassDefPtr());
}
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
return (client_class);
}
TestConfigBackendDHCPv4::getAllClientClasses4(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
ClientClassDictionary all_classes;
- for (auto client_class : classes_) {
+ for (auto const& client_class : classes_) {
if (server_selector.amAny()) {
all_classes.addClass(client_class);
continue;
continue;
}
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
all_classes.addClass(client_class);
got = true;
const boost::posix_time::ptime& modification_time) const {
auto tags = server_selector.getTags();
ClientClassDictionary modified_classes;
- for (auto client_class : classes_) {
+ for (auto const& client_class : classes_) {
if (client_class->getModificationTime() >= modification_time) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
modified_classes.addClass(client_class);
got = true;
mergeServerTags(client_class, server_selector);
int existing_class_index = -1;
- for (auto i = 0; i < classes_.size(); ++i) {
+ for (size_t i = 0; i < classes_.size(); ++i) {
if (classes_[i]->getName() == client_class->getName()) {
existing_class_index = i;
break;
found = true;
} else {
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
found = true;
break;
found = true;
} else {
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
found = true;
break;
const asiolink::IOAddress& pool_end_address,
const OptionDescriptorPtr& option) {
auto not_in_selected_servers = false;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
// Get the pool: if it is not here we can directly go to the next subnet.
auto pool = subnet->getPool(Lease::TYPE_V4, pool_start_address);
if (!pool) {
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
break;
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*subnet_it)->hasServerTag(ServerTag(tag))) {
got = true;
break;
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*subnet_it)->hasServerTag(ServerTag(tag))) {
got = true;
break;
TestConfigBackendDHCPv4::deleteAllSubnets4(const db::ServerSelector& server_selector) {
// Collect subnet to remove by ID.
std::list<SubnetID> ids;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
if (server_selector.amAny()) {
ids.push_back(subnet->getID());
continue;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
ids.push_back(subnet->getID());
got = true;
// Erase subnets.
uint64_t erased = 0;
auto& index = subnets_.get<SubnetSubnetIdIndexTag>();
- for (auto subnet_id : ids) {
+ for (auto const& subnet_id : ids) {
erased += index.erase(subnet_id);
}
return (erased);
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*subnet)->hasServerTag(ServerTag(tag))) {
got = true;
break;
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*network_it)->hasServerTag(ServerTag(tag))) {
got = true;
break;
TestConfigBackendDHCPv4::deleteAllSharedNetworks4(const db::ServerSelector& server_selector) {
// Collect shared network to remove.
std::list<std::string> names;
- for (auto shared_network : shared_networks_) {
+ for (auto const& shared_network : shared_networks_) {
if (server_selector.amAny()) {
names.push_back(shared_network->getName());
continue;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
names.push_back(shared_network->getName());
got = true;
// Erase shared networks.
uint64_t erased = 0;
auto& index = shared_networks_.get<SharedNetworkNameIndexTag>();
- for (auto name : names) {
+ for (auto const& name : names) {
erased += index.erase(name);
}
return (erased);
found = true;
} else {
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
found = true;
break;
found = true;
} else {
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
found = true;
break;
const uint16_t code,
const std::string& space) {
auto not_in_selected_servers = false;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
// Get the pool: if it is not here we can directly go to the next subnet.
auto pool = subnet->getPool(Lease::TYPE_V4, pool_start_address);
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
break;
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (existing_class->hasServerTag(ServerTag(tag))) {
got = true;
break;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
c = classes_.erase(c);
++count;
return (subnet->getServerTags().empty() ? subnet : Subnet6Ptr());
}
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
return (subnet);
}
return (subnet->getServerTags().empty() ? subnet : Subnet6Ptr());
}
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
return (subnet);
}
Subnet6Collection
TestConfigBackendDHCPv6::getAllSubnets6(const db::ServerSelector& server_selector) const {
Subnet6Collection subnets;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
if (server_selector.amAny()) {
subnets.insert(subnet);
continue;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
subnets.insert(subnet);
got = true;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*subnet)->hasServerTag(ServerTag(tag))) {
subnets.insert(*subnet);
got = true;
// Subnet collection does not include the index by shared network name.
// We need to iterate over the subnets and pick those that are associated
// with a shared network.
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
// Skip subnets which do not match the server selector.
if (server_selector.amUnassigned() &&
!subnet->getServerTags().empty()) {
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
got = true;
break;
return (network->getServerTags().empty() ? network : SharedNetwork6Ptr());
}
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (network->hasServerTag(ServerTag(tag))) {
return (network);
}
SharedNetwork6Collection
TestConfigBackendDHCPv6::getAllSharedNetworks6(const db::ServerSelector& server_selector) const{
SharedNetwork6Collection shared_networks;
- for (auto shared_network : shared_networks_) {
+ for (auto const& shared_network : shared_networks_) {
if (server_selector.amAny()) {
shared_networks.push_back(shared_network);
continue;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
shared_networks.push_back(shared_network);
got = true;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*shared_network)->hasServerTag(ServerTag(tag))) {
shared_networks.push_back(*shared_network);
got = true;
option_def_it != option_def_it_pair.second;
++option_def_it) {
if ((*option_def_it)->getOptionSpaceName() == space) {
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*option_def_it)->hasServerTag(ServerTag(tag))) {
return (*option_def_it);
}
TestConfigBackendDHCPv6::getAllOptionDefs6(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
OptionDefContainer option_defs;
- for (auto option_def : option_defs_) {
+ for (auto const& option_def : option_defs_) {
bool got = false;
if (server_selector.amUnassigned()) {
if (option_def->getServerTags().empty()) {
got = true;
}
} else {
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (option_def->hasServerTag(ServerTag(tag))) {
option_defs.push_back(option_def);
got = true;
auto lb = index.lower_bound(modification_time);
for (auto option_def = lb; option_def != index.end(); ++option_def) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*option_def)->hasServerTag(ServerTag(tag))) {
option_defs.push_back(*option_def);
got = true;
for (auto option_it = option_it_pair.first; option_it != option_it_pair.second;
++option_it) {
if (option_it->space_name_ == space) {
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (option_it->hasServerTag(ServerTag(tag))) {
return (OptionDescriptorPtr(new OptionDescriptor(*option_it)));
}
TestConfigBackendDHCPv6::getAllOptions6(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
OptionContainer options;
- for (auto option : options_) {
+ for (auto const& option : options_) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (option.hasServerTag(ServerTag(tag))) {
options.push_back(option);
got = true;
auto lb = index.lower_bound(modification_time);
for (auto option = lb; option != index.end(); ++option) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (option->hasServerTag(ServerTag(tag))) {
options.push_back(*option);
got = true;
auto global_range = index.equal_range(name);
for (auto global_it = global_range.first; global_it != global_range.second;
++global_it) {
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*global_it)->hasServerTag(ServerTag(tag))) {
return (*global_it);
}
TestConfigBackendDHCPv6::getAllGlobalParameters6(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
StampedValueCollection globals;
- for (auto global : globals_) {
+ for (auto const& global : globals_) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (global->hasServerTag(ServerTag(tag))) {
globals.insert(global);
got = true;
auto lb = index.lower_bound(modification_time);
for (auto global = lb; global != index.end(); ++global) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*global)->hasServerTag(ServerTag(tag))) {
globals.insert(*global);
got = true;
TestConfigBackendDHCPv6::getClientClass6(const db::ServerSelector& server_selector,
const std::string& name) const {
ClientClassDefPtr client_class;
- for (auto c : classes_) {
+ for (auto const& c : classes_) {
if (c->getName() == name) {
client_class = c;
break;
return (client_class->getServerTags().empty() ? client_class : ClientClassDefPtr());
}
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
return (client_class);
}
TestConfigBackendDHCPv6::getAllClientClasses6(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
ClientClassDictionary all_classes;
- for (auto client_class : classes_) {
+ for (auto const& client_class : classes_) {
if (server_selector.amAny()) {
all_classes.addClass(client_class);
continue;
continue;
}
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
all_classes.addClass(client_class);
got = true;
const boost::posix_time::ptime& modification_time) const {
auto tags = server_selector.getTags();
ClientClassDictionary modified_classes;
- for (auto client_class : classes_) {
+ for (auto const& client_class : classes_) {
if (client_class->getModificationTime() >= modification_time) {
bool got = false;
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
modified_classes.addClass(client_class);
got = true;
found = true;
} else {
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
found = true;
break;
found = true;
} else {
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
found = true;
break;
const asiolink::IOAddress& pool_end_address,
const OptionDescriptorPtr& option) {
auto not_in_selected_servers = false;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
// Get the pool: if it is not here we can directly go to the next subnet.
auto pool = subnet->getPool(Lease::TYPE_NA, pool_start_address);
if (!pool) {
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
break;
const uint8_t pd_pool_prefix_length,
const OptionDescriptorPtr& option) {
auto not_in_selected_servers = false;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
// Get the pd pool: if it is not here we can directly go to the next subnet.
auto pdpool = subnet->getPool(Lease::TYPE_PD, pd_pool_prefix);
if (!pdpool) {
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
break;
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*subnet_it)->hasServerTag(ServerTag(tag))) {
got = true;
break;
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*subnet_it)->hasServerTag(ServerTag(tag))) {
got = true;
break;
TestConfigBackendDHCPv6::deleteAllSubnets6(const db::ServerSelector& server_selector) {
// Collect subnet to remove by ID.
std::list<SubnetID> ids;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
if (server_selector.amAny()) {
ids.push_back(subnet->getID());
continue;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
ids.push_back(subnet->getID());
got = true;
// Erase subnets.
uint64_t erased = 0;
auto& index = subnets_.get<SubnetSubnetIdIndexTag>();
- for (auto subnet_id : ids) {
+ for (auto const& subnet_id : ids) {
erased += index.erase(subnet_id);
}
return (erased);
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*subnet)->hasServerTag(ServerTag(tag))) {
got = true;
break;
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if ((*network_it)->hasServerTag(ServerTag(tag))) {
got = true;
break;
TestConfigBackendDHCPv6::deleteAllSharedNetworks6(const db::ServerSelector& server_selector) {
// Collect shared network to remove.
std::list<std::string> names;
- for (auto shared_network : shared_networks_) {
+ for (auto const& shared_network : shared_networks_) {
if (server_selector.amAny()) {
names.push_back(shared_network->getName());
continue;
}
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
names.push_back(shared_network->getName());
got = true;
// Erase shared networks.
uint64_t erased = 0;
auto& index = shared_networks_.get<SharedNetworkNameIndexTag>();
- for (auto name : names) {
+ for (auto const& name : names) {
erased += index.erase(name);
}
return (erased);
found = true;
} else {
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
found = true;
break;
found = true;
} else {
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
found = true;
break;
const uint16_t code,
const std::string& space) {
auto not_in_selected_servers = false;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
// Get the pool: if it is not here we can directly go to the next subnet.
auto pool = subnet->getPool(Lease::TYPE_NA, pool_start_address);
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
break;
const uint16_t code,
const std::string& space) {
auto not_in_selected_servers = false;
- for (auto subnet : subnets_) {
+ for (auto const& subnet : subnets_) {
// Get the pd pool: if it is not here we can directly go to the next subnet.
auto pdpool = subnet->getPool(Lease::TYPE_PD, pd_pool_prefix);
if (!pdpool) {
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
break;
if (!server_selector.amAny()) {
bool got = false;
auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ for (auto const& tag : tags) {
if (existing_class->hasServerTag(ServerTag(tag))) {
got = true;
break;
size_t count = 0;
if (rrset) {
for (RdataIteratorPtr rit = rrset->getRdataIterator();
- !rit->isLast();
- rit->next(), ++count) {
+ !rit->isLast(); rit->next(), ++count) {
if (dynamic_cast<const rdata::generic::SOA*>(&rit->getCurrent()) ==
NULL) {
isc_throw(Unexpected, "Zone checker found bad RDATA in SOA");
}
for (RdataIteratorPtr rit = ns_rrset->getRdataIterator();
- !rit->isLast();
- rit->next()) {
+ !rit->isLast(); rit->next()) {
const rdata::generic::NS* ns_data =
dynamic_cast<const rdata::generic::NS*>(&rit->getCurrent());
if (ns_data == NULL) {
// values from the previous loop round.
parameters.reset();
- BOOST_FOREACH(auto entry_item, library_entry->mapValue()) {
+ BOOST_FOREACH(auto const& entry_item, library_entry->mapValue()) {
if (entry_item.first == "library") {
if (entry_item.second->getType() != Element::string) {
isc_throw(DhcpConfigError, "hooks library configuration"
(params->size() == 0)) {
return (names);
}
- auto map = params->mapValue();
+ auto const& map = params->mapValue();
for (auto elem = map.begin(); elem != map.end(); ++elem) {
names.push_back(elem->first);
}
// Set clients
ElementPtr clients = Element::createList();
- for (auto client : list_) {
+ for (auto const& client : list_) {
clients->add(client.toElement());
}
result->set("clients", clients);
}
// Iterate on clients.
- for (auto client : clients->listValue()) {
+ for (auto const& client : clients->listValue()) {
if (client->getType() != Element::map) {
isc_throw(DhcpConfigError, "clients items must be maps ("
<< client->getPosition() << ")");
// Iterate over JSON values and store them in a simple map.
std::map<std::string, std::string> config_values;
- for (auto config_element = json->mapValue().begin();
- config_element != json->mapValue().end();
- ++config_element) {
- ASSERT_FALSE(config_element->first.empty());
- ASSERT_TRUE(config_element->second);
- config_values[config_element->first] = config_element->second->stringValue();
+ for (auto const& config_element : json->mapValue()) {
+ ASSERT_FALSE(config_element.first.empty());
+ ASSERT_TRUE(config_element.second);
+ config_values[config_element.first] = config_element.second->stringValue();
}
// Verify the values.
appenders = log4cplus::Logger::getInstance(getRootLoggerName()).getAllAppenders();
}
- for (log4cplus::helpers::SharedObjectPtr<log4cplus::Appender> logger : appenders) {
+ for (const log4cplus::helpers::SharedObjectPtr<log4cplus::Appender>& logger : appenders) {
if (destination == OutputOption::DEST_CONSOLE &&
dynamic_cast<log4cplus::ConsoleAppender*>(logger.get())) {
return true;
checkUnusable();
// Extract native input bindings.
std::vector<MYSQL_BIND> in_bind_vec;
- for (MySqlBindingPtr in_binding : in_bindings) {
+ for (const MySqlBindingPtr& in_binding : in_bindings) {
in_bind_vec.push_back(in_binding->getMySqlBinding());
}
// Bind variables that will receive results as well.
std::vector<MYSQL_BIND> out_bind_vec;
- for (MySqlBindingPtr out_binding : out_bindings) {
+ for (const MySqlBindingPtr& out_binding : out_bindings) {
out_bind_vec.push_back(out_binding->getMySqlBinding());
}
if (!out_bind_vec.empty()) {
const MySqlBindingCollection& in_bindings) {
checkUnusable();
std::vector<MYSQL_BIND> in_bind_vec;
- for (MySqlBindingPtr in_binding : in_bindings) {
+ for (const MySqlBindingPtr& in_binding : in_bindings) {
in_bind_vec.push_back(in_binding->getMySqlBinding());
}
const MySqlBindingCollection& in_bindings) {
checkUnusable();
std::vector<MYSQL_BIND> in_bind_vec;
- for (MySqlBindingPtr in_binding : in_bindings) {
+ for (const MySqlBindingPtr& in_binding : in_bindings) {
in_bind_vec.push_back(in_binding->getMySqlBinding());
}
/// @param insert_rows Collection of rows of data to insert. Note that
/// each row is inserted as a separate statement execution.
void testInsert(const TestRowSet& insert_rows) {
- for (auto row : insert_rows ) {
+ for (const auto& row : insert_rows) {
// Set the insert parameters based on the current insert row.
PsqlBindArray in_bindings;
in_bindings.add(row.int_col);
/// @param update_rows Collection of rows of data to update.
void testUpdate(const TestRowSet& update_rows) {
size_t update_count = 0;
- for (auto row : update_rows ) {
+ for (const auto& row : update_rows) {
// Set the text value and where clause parameters based on the
// this row's values.
PsqlBindArray in_bindings;
// Insert a row for each reference value
PsqlBindArrayPtr bind_array;
PgSqlResultPtr r;
- for (auto triplet : triplets) {
+ for (auto const& triplet : triplets) {
bind_array.reset(new PsqlBindArray());
bind_array->add(triplet);
bind_array->addMin(triplet);
// Iterate over the rows, verifying each value against its reference
int row = 0;
- for (auto expected : triplets) {
+ for (auto const& expected : triplets) {
Triplet<uint32_t> fetched;
// First we test making a triplet only with default value column.
ASSERT_NO_THROW_LOG(fetched = PgSqlExchange::getTripletValue(*r, row, INT_COL));
}
// Iterate over the configured DBs and instantiate them.
- for (auto db : config_ctl->getConfigDatabases()) {
+ for (auto const& db : config_ctl->getConfigDatabases()) {
const std::string& redacted = db.redactedAccessString();
LOG_INFO(dctl_logger, DCTL_OPEN_CONFIG_DB)
.arg(redacted);
ConfigControlInfo::ConfigControlInfo(const ConfigControlInfo& other)
: config_fetch_wait_time_(other.config_fetch_wait_time_) {
- for (auto db : other.db_infos_) {
+ for (auto const& db : other.db_infos_) {
addConfigDatabase(db.getAccessString());
}
}
ConfigDbInfo new_db;
new_db.setAccessString(access_str);
- for (auto db : db_infos_) {
+ for (auto const& db : db_infos_) {
if (new_db == db) {
// we have a duplicate!
isc_throw(BadValue, "database with access parameters: "
ConfigControlInfo::toElement() const {
ElementPtr result = Element::createMap();
ElementPtr db_list = Element::createList();
- for (auto db_info : db_infos_) {
+ for (auto const& db_info : db_infos_) {
db_list->add(db_info.toElement());
}
// Check obsolete or unknown (aka unsupported) objects.
const std::string& app_name = getAppName();
std::string errmsg;
- for (auto obj : args->mapValue()) {
+ for (auto const& obj : args->mapValue()) {
const std::string& obj_name = obj.first;
if (obj_name == app_name) {
continue;
EXPECT_EQ(2, updated.size());
bool saw_create = false;
bool saw_update = false;
- for (auto entry : updated) {
+ for (auto const& entry : updated) {
EXPECT_EQ("my_object_type", entry->getObjectType());
EXPECT_EQ(5678, entry->getObjectId());
if (AuditEntry::ModificationType::CREATE == entry->getModificationType()) {
"] } \n"
};
- for (auto config : configs) {
+ for (auto const& config : configs) {
ConfigControlParser parser;
ConfigControlInfoPtr ctl_info;
"{ \"config-fetch-wait-time\": \"a-string\" }",
};
- for (auto config : configs) {
+ for (auto const& config : configs) {
ConfigControlParser parser;
// Turn the JSON config into Elements.
void
StatContext::resetAll() {
// Let's iterate over all stored statistics...
- for (auto s : stats_) {
+ for (auto const& s : stats_) {
// ... and reset each statistic.
s.second->reset();
}
StatContext::getAll() const {
ElementPtr map = Element::createMap(); // a map
// Let's iterate over all stored statistics...
- for (auto s : stats_) {
+ for (auto const& s : stats_) {
// ... and add each of them to the map.
map->set(s.first, s.second->getJSON());
}
void
StatContext::setMaxSampleAgeAll(const StatsDuration& duration) {
// Let's iterate over all stored statistics...
- for (auto s : stats_) {
+ for (auto const& s : stats_) {
// ... and set duration limit for each statistic.
s.second->setMaxSampleAge(duration);
}
///
/// Removes active clients.
virtual ~TcpListenerTest() {
- for (auto client : clients_) {
+ for (auto const& client : clients_) {
client->close();
}
}
ASSERT_EQ(num_clients, clients_.size());
size_t connection_id = 1;
- for (auto client : clients_) {
+ for (auto const& client : clients_) {
EXPECT_TRUE(client->receiveDone());
EXPECT_FALSE(client->expectedEof());
// Create the list of expected entries.
};
// Fetch the entries for this connection.
- auto entries = listener.audit_trail_->getConnectionTrail(connection_id);
+ auto const& entries = listener.audit_trail_->getConnectionTrail(connection_id);
ASSERT_EQ(expected_entries, entries);
++connection_id;
}
std::list<std::string>expected_responses{ "echo one", "echo two",
"echo three", "good bye"};
size_t connection_id = 1;
- for (auto client : clients_) {
+ for (auto const& client : clients_) {
EXPECT_TRUE(client->receiveDone());
EXPECT_FALSE(client->expectedEof());
EXPECT_EQ(expected_responses, client->getResponses());
};
// Fetch the entries for this connection.
- auto entries = listener.audit_trail_->getConnectionTrail(connection_id);
+ auto const& entries = listener.audit_trail_->getConnectionTrail(connection_id);
ASSERT_EQ(expected_entries, entries);
++connection_id;
}
ASSERT_EQ(num_clients, clients_.size());
size_t i = 0;
- for (auto client : clients_) {
+ for (auto const& client : clients_) {
if (i % 2 == 0) {
// These clients should have been accepted and received responses.
EXPECT_TRUE(client->receiveDone());
{ i+1, AuditEntry::OUTBOUND, "good bye" }
};
- auto entries = listener.audit_trail_->getConnectionTrail(i+1);
+ auto const& entries = listener.audit_trail_->getConnectionTrail(i+1);
ASSERT_EQ(expected_entries, entries);
} else {
EXPECT_TRUE(client->expectedEof());
// Verify connection recorded no audit entries.
- auto entries = listener.audit_trail_->getConnectionTrail(i+1);
+ auto const& entries = listener.audit_trail_->getConnectionTrail(i+1);
ASSERT_EQ(entries.size(), 0);
}
}
}
- for (auto scenario : scenarios ) {
+ for (auto const& scenario : scenarios ) {
SCOPED_TRACE(scenario.desc_);
std::list<TcpStreamRequestPtr> requests;
TcpStreamRequestPtr request;
- for (auto input_buf : scenario.input_buffers_) {
+ for (auto const& input_buf : scenario.input_buffers_) {
// Copy the input buffer.
std::vector<uint8_t> buf = input_buf;
ASSERT_EQ(requests.size(), scenario.expected_strings_.size());
auto exp_string = scenario.expected_strings_.begin();
- for (auto recvd_request : requests) {
+ for (auto const& recvd_request : requests) {
ASSERT_NO_THROW(recvd_request->unpack());
EXPECT_EQ(*exp_string++, recvd_request->getRequestString());
}
std::list<AuditEntry> getConnectionTrail(size_t connection_id) {
std::unique_lock<std::mutex> lck(mutex_);
std::list<AuditEntry> conn_entries;
- for (auto entry : entries_) {
+ for (auto const& entry : entries_) {
if (entry.connection_id_ == connection_id) {
conn_entries.push_back(entry);
}
std::string dump() {
std::unique_lock<std::mutex> lck(mutex_);
std::stringstream ss;
- for (auto entry : entries_) {
+ for (auto const& entry : entries_) {
ss << entry << std::endl;
}
///
/// Removes active clients.
virtual ~TlsListenerTest() {
- for (auto client : clients_) {
+ for (auto const& client : clients_) {
client->close();
}
}
ASSERT_EQ(num_clients, clients_.size());
size_t connection_id = 1;
- for (auto client : clients_) {
+ for (auto const& client : clients_) {
EXPECT_TRUE(client->receiveDone());
EXPECT_FALSE(client->expectedEof());
// Create the list of expected entries.
std::list<std::string>expected_responses{ "echo one", "echo two",
"echo three", "good bye"};
size_t connection_id = 1;
- for (auto client : clients_) {
+ for (auto const& client : clients_) {
EXPECT_TRUE(client->receiveDone());
EXPECT_FALSE(client->expectedEof());
EXPECT_EQ(expected_responses, client->getResponses());
ASSERT_EQ(num_clients, clients_.size());
size_t i = 0;
- for (auto client : clients_) {
+ for (auto const& client : clients_) {
if (i % 2 == 0) {
// These clients should have been accepted and received responses.
EXPECT_TRUE(client->receiveDone());
// signal threads that are waiting
signalThreads();
// wait for all test threads to exit
- for (auto thread : threads_) {
+ for (const auto& thread : threads_) {
thread->join();
}
// reset all threads
void checkRunHistory(uint32_t items_count) {
uint32_t count = 0;
// iterate over all threads history and count all the processed tasks
- for (auto element : history_) {
+ for (const auto& element : history_) {
count += element.second.size();
}
ASSERT_EQ(count, items_count);
isc_throw(MultiThreadingInvalidOperation, "thread pool stop called by worker thread");
}
queue_.disable();
- for (auto thread : threads_) {
+ for (const auto& thread : threads_) {
thread->join();
}
threads_.clear();
///
/// @return true if thread is owned, false otherwise
bool checkThreadId(std::thread::id id) {
- for (auto thread : threads_) {
+ for (const auto& thread : threads_) {
if (id == thread->get_id()) {
return (true);
}
void
openTestData(const char* const datafile, ifstream& ifs) {
- vector<string>::const_iterator it = getDataPaths().begin();
- for (; it != getDataPaths().end(); ++it) {
+ for (vector<string>::const_iterator it = getDataPaths().begin();
+ it != getDataPaths().end(); ++it) {
string data_path = *it;
if (data_path.empty() || *data_path.rbegin() != '/') {
data_path.push_back('/');
if (name.empty()) {
return;
}
- for (ElementPtr down : downs) {
+ for (ElementPtr& down : downs) {
if (!down || (down->getType() != Element::map)) {
continue;
}
}
int index = step->intValue();
if (index == -1) {
- for (ElementPtr down : downs) {
+ for (ElementPtr& down : downs) {
applyDown(path, actions, down, next);
}
} else if ((index >= 0) && (index < scope->size())) {
AdaptorPool::canonizePool(ElementPtr pool) {
const string& orig = pool->get("pool")->stringValue();
vector<char> v;
- for (char ch : orig) {
+ for (auto ch : orig) {
if ((ch == ' ') || (ch == '\t') || (ch == '\n')) {
continue;
} else if (ch == '-') {
ElementPtr x;
- for (int i = 0; i<configs.size(); i++) {
+ for (int i = 0; i < configs.size(); i++) {
x.reset();
testFile(string(CFG_EXAMPLES) + "/kea4/" + configs[i], false, x);
ASSERT_TRUE(x);
"vivso.json",
//"with-ddns.json",
};
- for (string file : examples) {
+ for (const string& file : examples) {
resetSession();
string path = string(CFG_EXAMPLES) + "/kea4/" + file;
SCOPED_TRACE("\n* Tested file: " + path);
"tee-times.json",
//"with-ddns.json",
};
- for (string file : examples) {
+ for (const string& file : examples) {
resetSession();
string path = string(CFG_EXAMPLES) + "/kea6/" + file;
SCOPED_TRACE("\n* Tested file: " + path);
// This is test environment sanity check. It verifies that all configuration
// defined in yang_configs.h are sane.
TEST(YangReprTest, verifyConfigs) {
- for (auto x : TEST_CONFIGS) {
+ for (const auto& x : TEST_CONFIGS) {
sanityCheckConfig(x.first, x.second);
}
}