summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/dhcpsrv')
-rw-r--r--src/lib/dhcpsrv/alloc_engine.cc84
-rw-r--r--src/lib/dhcpsrv/cb_ctl_dhcp.h8
-rw-r--r--src/lib/dhcpsrv/cb_ctl_dhcp4.cc55
-rw-r--r--src/lib/dhcpsrv/cb_ctl_dhcp6.cc59
-rw-r--r--src/lib/dhcpsrv/cfg_db_access.cc1
-rw-r--r--src/lib/dhcpsrv/cfg_globals.cc21
-rw-r--r--src/lib/dhcpsrv/cfg_host_operations.cc5
-rw-r--r--src/lib/dhcpsrv/cfg_hosts.cc79
-rw-r--r--src/lib/dhcpsrv/cfg_hosts_util.cc7
-rw-r--r--src/lib/dhcpsrv/cfg_iface.cc44
-rw-r--r--src/lib/dhcpsrv/cfg_mac_source.cc16
-rw-r--r--src/lib/dhcpsrv/cfg_option.cc26
-rw-r--r--src/lib/dhcpsrv/cfg_option.h8
-rw-r--r--src/lib/dhcpsrv/cfg_option_def.cc62
-rw-r--r--src/lib/dhcpsrv/cfg_rsoo.cc5
-rw-r--r--src/lib/dhcpsrv/cfg_shared_networks.h31
-rw-r--r--src/lib/dhcpsrv/cfg_subnets6.cc4
-rw-r--r--src/lib/dhcpsrv/client_class_def.cc37
-rw-r--r--src/lib/dhcpsrv/d2_client_mgr.h9
-rw-r--r--src/lib/dhcpsrv/dhcp4o6_ipc.cc10
-rw-r--r--src/lib/dhcpsrv/host.cc56
-rw-r--r--src/lib/dhcpsrv/host_data_source_factory.cc1
-rw-r--r--src/lib/dhcpsrv/host_mgr.cc2
-rw-r--r--src/lib/dhcpsrv/lease_file_loader.h6
-rw-r--r--src/lib/dhcpsrv/lease_mgr.cc17
-rw-r--r--src/lib/dhcpsrv/lease_mgr_factory.cc1
-rw-r--r--src/lib/dhcpsrv/memfile_lease_mgr.cc84
-rw-r--r--src/lib/dhcpsrv/mysql_host_data_source.cc14
-rw-r--r--src/lib/dhcpsrv/mysql_lease_mgr.cc5
-rw-r--r--src/lib/dhcpsrv/network.cc9
-rw-r--r--src/lib/dhcpsrv/parsers/client_class_def_parser.cc6
-rw-r--r--src/lib/dhcpsrv/parsers/dhcp_parsers.cc143
-rw-r--r--src/lib/dhcpsrv/parsers/dhcp_queue_control_parser.cc1
-rw-r--r--src/lib/dhcpsrv/parsers/duid_config_parser.cc1
-rw-r--r--src/lib/dhcpsrv/parsers/expiration_config_parser.cc1
-rw-r--r--src/lib/dhcpsrv/parsers/host_reservation_parser.cc24
-rw-r--r--src/lib/dhcpsrv/parsers/host_reservations_list_parser.h3
-rw-r--r--src/lib/dhcpsrv/parsers/ifaces_config_parser.cc5
-rw-r--r--src/lib/dhcpsrv/parsers/option_data_parser.cc3
-rw-r--r--src/lib/dhcpsrv/parsers/shared_network_parser.cc32
-rw-r--r--src/lib/dhcpsrv/parsers/shared_networks_list_parser.h5
-rw-r--r--src/lib/dhcpsrv/parsers/simple_parser4.cc11
-rw-r--r--src/lib/dhcpsrv/parsers/simple_parser6.cc14
-rw-r--r--src/lib/dhcpsrv/pgsql_host_data_source.cc14
-rw-r--r--src/lib/dhcpsrv/pgsql_lease_mgr.cc5
-rw-r--r--src/lib/dhcpsrv/pool.cc5
-rw-r--r--src/lib/dhcpsrv/shared_network.cc28
-rw-r--r--src/lib/dhcpsrv/srv_config.cc54
-rw-r--r--src/lib/dhcpsrv/tests/alloc_engine_utils.cc20
-rw-r--r--src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc9
-rw-r--r--src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc15
-rw-r--r--src/lib/dhcpsrv/tests/cfg_option_def_unittest.cc12
-rw-r--r--src/lib/dhcpsrv/tests/cfg_option_unittest.cc51
-rw-r--r--src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc59
-rw-r--r--src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc63
-rw-r--r--src/lib/dhcpsrv/tests/client_class_def_unittest.cc4
-rw-r--r--src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc8
-rw-r--r--src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc8
-rw-r--r--src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc16
-rw-r--r--src/lib/dhcpsrv/tests/host_unittest.cc34
-rw-r--r--src/lib/dhcpsrv/tests/pool_unittest.cc28
-rw-r--r--src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc23
-rw-r--r--src/lib/dhcpsrv/tests/srv_config_unittest.cc28
-rw-r--r--src/lib/dhcpsrv/tests/subnet_unittest.cc35
-rw-r--r--src/lib/dhcpsrv/tests/timer_mgr_unittest.cc10
-rw-r--r--src/lib/dhcpsrv/testutils/generic_backend_unittest.cc32
-rw-r--r--src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc36
-rw-r--r--src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc36
-rw-r--r--src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc47
-rw-r--r--src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc190
-rw-r--r--src/lib/dhcpsrv/testutils/host_data_source_utils.cc11
-rw-r--r--src/lib/dhcpsrv/testutils/memory_host_data_source.cc137
-rw-r--r--src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc45
-rw-r--r--src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc135
-rw-r--r--src/lib/dhcpsrv/timer_mgr.cc5
-rw-r--r--src/lib/dhcpsrv/tracking_lease_mgr.cc4
76 files changed, 1044 insertions, 1178 deletions
diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc
index 111a3a9347..810409fe4b 100644
--- a/src/lib/dhcpsrv/alloc_engine.cc
+++ b/src/lib/dhcpsrv/alloc_engine.cc
@@ -388,9 +388,9 @@ AllocEngine::findReservation(ClientContext6& ctx) {
// Store the hosts in the temporary map, because some hosts may
// belong to subnets outside of the shared network. We'll need
// to eliminate them.
- for (auto host = hosts.begin(); host != hosts.end(); ++host) {
- if ((*host)->getIPv6SubnetID() != SUBNET_ID_GLOBAL) {
- host_map[(*host)->getIPv6SubnetID()] = *host;
+ for (auto const& host : hosts) {
+ if (host->getIPv6SubnetID() != SUBNET_ID_GLOBAL) {
+ host_map[host->getIPv6SubnetID()] = host;
}
}
}
@@ -621,7 +621,7 @@ AllocEngine::allocateLeases6(ClientContext6& ctx) {
// If there are any leases allocated, let's store in them in the
// IA context so as they are available when we process subsequent
// IAs.
- BOOST_FOREACH(Lease6Ptr lease, leases) {
+ for (auto const& lease : leases) {
ctx.addAllocatedResource(lease->addr_, lease->prefixlen_);
ctx.new_leases_.push_back(lease);
}
@@ -1148,7 +1148,7 @@ AllocEngine::allocateReservedLeases6(ClientContext6& ctx,
// We want to avoid allocating new lease for an IA if there is already
// a valid lease for which client has reservation. So, we first check if
// we already have a lease for a reserved address or prefix.
- BOOST_FOREACH(const Lease6Ptr& lease, existing_leases) {
+ for (auto const& lease : existing_leases) {
if ((lease->valid_lft_ != 0)) {
if ((ctx.hosts_.count(lease->subnet_id_) > 0) &&
ctx.hosts_[lease->subnet_id_]->hasReservation(makeIPv6Resrv(*lease))) {
@@ -1218,7 +1218,7 @@ AllocEngine::allocateReservedLeases6(ClientContext6& ctx,
// Get the IPv6 reservations of specified type.
const IPv6ResrvRange& reservs = host->getIPv6Reservations(type);
- BOOST_FOREACH(IPv6ResrvTuple type_lease_tuple, reservs) {
+ BOOST_FOREACH(auto const& type_lease_tuple, reservs) {
// We do have a reservation for address or prefix.
const IOAddress& addr = type_lease_tuple.second.getPrefix();
uint8_t prefix_len = type_lease_tuple.second.getPrefixLen();
@@ -1318,7 +1318,7 @@ AllocEngine::allocateGlobalReservedLeases6(ClientContext6& ctx,
// We want to avoid allocating a new lease for an IA if there is already
// a valid lease for which client has reservation. So, we first check if
// we already have a lease for a reserved address or prefix.
- BOOST_FOREACH(const Lease6Ptr& lease, existing_leases) {
+ for (auto const& lease : existing_leases) {
if ((lease->valid_lft_ != 0) &&
(ghost->hasReservation(makeIPv6Resrv(*lease)))) {
// We found existing lease for a reserved address or prefix.
@@ -1357,7 +1357,7 @@ AllocEngine::allocateGlobalReservedLeases6(ClientContext6& ctx,
IPv6Resrv::TYPE_NA : IPv6Resrv::TYPE_PD;
const IPv6ResrvRange& reservs = ghost->getIPv6Reservations(type);
- BOOST_FOREACH(IPv6ResrvTuple type_lease_tuple, reservs) {
+ BOOST_FOREACH(auto const& type_lease_tuple, reservs) {
// We do have a reservation for address or prefix.
const IOAddress& addr = type_lease_tuple.second.getPrefix();
uint8_t prefix_len = type_lease_tuple.second.getPrefixLen();
@@ -1468,7 +1468,7 @@ AllocEngine::removeNonmatchingReservedLeases6(ClientContext6& ctx,
// so the operation shouldn't be that expensive.
Lease6Collection copy = existing_leases;
- BOOST_FOREACH(const Lease6Ptr& candidate, copy) {
+ for (auto const& candidate : copy) {
// If we have reservation we should check if the reservation is for
// the candidate lease. If so, we simply accept the lease.
IPv6Resrv resv = makeIPv6Resrv(*candidate);
@@ -1576,7 +1576,7 @@ AllocEngine::removeNonmatchingReservedNoHostLeases6(ClientContext6& ctx,
// so the operation shouldn't be that expensive.
Lease6Collection copy = existing_leases;
- BOOST_FOREACH(const Lease6Ptr& candidate, copy) {
+ for (auto const& candidate : copy) {
// Lease can be allocated to us from a dynamic pool, but we must
// check if this lease belongs to any allowed pool. If it does,
// we can proceed to checking the next lease.
@@ -1657,7 +1657,7 @@ AllocEngine::removeNonreservedLeases6(ClientContext6& ctx,
lease != existing_leases.end(); ++lease) {
// If there is reservation for this keep it.
- IPv6Resrv resv = makeIPv6Resrv(*(*lease));
+ IPv6Resrv resv = makeIPv6Resrv(**lease);
if (ctx.hasGlobalReservation(resv) ||
((ctx.hosts_.count((*lease)->subnet_id_) > 0) &&
(ctx.hosts_[(*lease)->subnet_id_]->hasReservation(resv)))) {
@@ -1883,9 +1883,8 @@ AllocEngine::getLifetimes6(ClientContext6& ctx, uint32_t& preferred, uint32_t& v
// Iterate over the assigned class definitions.
int have_both = 0;
- for (auto name = classes.cbegin();
- name != classes.cend() && have_both < 2; ++name) {
- ClientClassDefPtr cl = dict->findClass(*name);
+ for (auto const& name : classes) {
+ ClientClassDefPtr cl = dict->findClass(name);
if (candidate_preferred.unspecified() &&
(cl && (!cl->getPreferred().unspecified()))) {
candidate_preferred = cl->getPreferred();
@@ -1897,6 +1896,9 @@ AllocEngine::getLifetimes6(ClientContext6& ctx, uint32_t& preferred, uint32_t& v
candidate_valid = cl->getValid();
++have_both;
}
+ if (have_both == 2) {
+ break;
+ }
}
}
@@ -2139,25 +2141,25 @@ AllocEngine::renewLeases6(ClientContext6& ctx) {
}
// Extend all existing leases that passed all checks.
- for (Lease6Collection::iterator l = leases.begin(); l != leases.end(); ++l) {
- if (ctx.currentIA().isNewResource((*l)->addr_,
- (*l)->prefixlen_)) {
+ for (auto const& l : leases) {
+ if (ctx.currentIA().isNewResource(l->addr_,
+ l->prefixlen_)) {
// This lease was just created so is already extended.
continue;
}
LOG_DEBUG(alloc_engine_logger, ALLOC_ENGINE_DBG_TRACE_DETAIL,
ALLOC_ENGINE_V6_EXTEND_LEASE)
.arg(ctx.query_->getLabel())
- .arg((*l)->typeToText((*l)->type_))
- .arg((*l)->addr_);
- extendLease6(ctx, *l);
+ .arg(l->typeToText(l->type_))
+ .arg(l->addr_);
+ extendLease6(ctx, l);
}
if (!leases.empty()) {
// If there are any leases allocated, let's store in them in the
// IA context so as they are available when we process subsequent
// IAs.
- BOOST_FOREACH(Lease6Ptr lease, leases) {
+ for (auto const& lease : leases) {
ctx.addAllocatedResource(lease->addr_, lease->prefixlen_);
ctx.new_leases_.push_back(lease);
}
@@ -2418,9 +2420,8 @@ AllocEngine::extendLease6(ClientContext6& ctx, Lease6Ptr lease) {
Lease6Collection
AllocEngine::updateLeaseData(ClientContext6& ctx, const Lease6Collection& leases) {
Lease6Collection updated_leases;
- for (Lease6Collection::const_iterator lease_it = leases.begin();
- lease_it != leases.end(); ++lease_it) {
- Lease6Ptr lease(new Lease6(**lease_it));
+ for (auto const& lease_it : leases) {
+ Lease6Ptr lease(new Lease6(*lease_it));
if (ctx.currentIA().isNewResource(lease->addr_, lease->prefixlen_)) {
// This lease was just created so is already up to date.
updated_leases.push_back(lease);
@@ -2452,14 +2453,14 @@ AllocEngine::updateLeaseData(ClientContext6& ctx, const Lease6Collection& leases
}
bool fqdn_changed = ((lease->type_ != Lease::TYPE_PD) &&
- !(lease->hasIdenticalFqdn(**lease_it)));
+ !(lease->hasIdenticalFqdn(*lease_it)));
lease->cltt_ = time(NULL);
if (!fqdn_changed) {
setLeaseReusable(lease, current_preferred_lft, ctx);
}
if (lease->reuseable_valid_lft_ == 0) {
- ctx.currentIA().changed_leases_.push_back(*lease_it);
+ ctx.currentIA().changed_leases_.push_back(lease_it);
LeaseMgrFactory::instance().updateLease6(lease);
}
@@ -2575,7 +2576,7 @@ AllocEngine::reclaimExpiredLeases6Internal(const size_t max_leases,
}
size_t leases_processed = 0;
- BOOST_FOREACH(Lease6Ptr lease, leases) {
+ for (auto const& lease : leases) {
try {
// Reclaim the lease.
@@ -2738,7 +2739,7 @@ AllocEngine::reclaimExpiredLeases4Internal(const size_t max_leases,
}
size_t leases_processed = 0;
- BOOST_FOREACH(Lease4Ptr lease, leases) {
+ for (auto const& lease : leases) {
try {
// Reclaim the lease.
@@ -3502,10 +3503,10 @@ void findClientLease(AllocEngine::ClientContext4& ctx, Lease4Ptr& client_lease)
// explicitly configured to ignore client identifiers for this subnet
// check if there is a lease within this subnet.
if (subnet->getMatchClientId()) {
- for (auto l = leases_client_id.begin(); l != leases_client_id.end(); ++l) {
- if ((*l)->subnet_id_ == subnet->getID()) {
+ for (auto const& l : leases_client_id) {
+ if (l->subnet_id_ == subnet->getID()) {
// Lease found, so stick to this lease.
- client_lease = (*l);
+ client_lease = l;
ctx.subnet_ = subnet;
return;
}
@@ -3530,9 +3531,8 @@ void findClientLease(AllocEngine::ClientContext4& ctx, Lease4Ptr& client_lease)
// Try to find the lease that matches current subnet and belongs to
// this client, so both HW address and client identifier match.
- for (Lease4Collection::const_iterator client_lease_it = leases_hw_address.begin();
- client_lease_it != leases_hw_address.end(); ++client_lease_it) {
- Lease4Ptr existing_lease = *client_lease_it;
+ for (auto const& client_lease_it : leases_hw_address) {
+ Lease4Ptr existing_lease = client_lease_it;
if ((existing_lease->subnet_id_ == subnet->getID()) &&
existing_lease->belongsToClient(ctx.hwaddr_, client_id)) {
// Found the lease of this client, so return it.
@@ -3760,9 +3760,9 @@ AllocEngine::findReservation(ClientContext4& ctx) {
// Store the hosts in the temporary map, because some hosts may
// belong to subnets outside of the shared network. We'll need
// to eliminate them.
- for (auto host = hosts.begin(); host != hosts.end(); ++host) {
- if ((*host)->getIPv4SubnetID() != SUBNET_ID_GLOBAL) {
- host_map[(*host)->getIPv4SubnetID()] = *host;
+ for (auto const& host : hosts) {
+ if (host->getIPv4SubnetID() != SUBNET_ID_GLOBAL) {
+ host_map[host->getIPv4SubnetID()] = host;
}
}
}
@@ -4172,9 +4172,8 @@ AllocEngine::getOfferLft(const ClientContext4& ctx) {
CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
// Iterate over the assigned class definitions.
- for (ClientClasses::const_iterator name = classes.cbegin();
- name != classes.cend(); ++name) {
- ClientClassDefPtr cl = dict->findClass(*name);
+ for (auto const& name : classes) {
+ ClientClassDefPtr cl = dict->findClass(name);
if (cl && (!cl->getOfferLft().unspecified())) {
offer_lft = cl->getOfferLft();
break;
@@ -4217,9 +4216,8 @@ AllocEngine::getValidLft(const ClientContext4& ctx) {
CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
// Iterate over the assigned class definitions.
- for (ClientClasses::const_iterator name = classes.cbegin();
- name != classes.cend(); ++name) {
- ClientClassDefPtr cl = dict->findClass(*name);
+ for (auto const& name : classes) {
+ ClientClassDefPtr cl = dict->findClass(name);
if (cl && (!cl->getValid().unspecified())) {
candidate_lft = cl->getValid();
break;
diff --git a/src/lib/dhcpsrv/cb_ctl_dhcp.h b/src/lib/dhcpsrv/cb_ctl_dhcp.h
index 926946de89..104fa871c2 100644
--- a/src/lib/dhcpsrv/cb_ctl_dhcp.h
+++ b/src/lib/dhcpsrv/cb_ctl_dhcp.h
@@ -45,14 +45,14 @@ protected:
void addGlobalsToConfig(SrvConfigPtr external_cfg,
data::StampedValueCollection& cb_globals) const {
auto const& index = cb_globals.get<data::StampedValueNameIndexTag>();
- for (auto cb_global = index.begin(); cb_global != index.end(); ++cb_global) {
+ for (auto const& cb_global : index) {
- if ((*cb_global)->amNull()) {
+ if (cb_global->amNull()) {
continue;
}
- external_cfg->addConfiguredGlobal((*cb_global)->getName(),
- (*cb_global)->getElementValue());
+ external_cfg->addConfiguredGlobal(cb_global->getName(),
+ cb_global->getElementValue());
}
}
};
diff --git a/src/lib/dhcpsrv/cb_ctl_dhcp4.cc b/src/lib/dhcpsrv/cb_ctl_dhcp4.cc
index 37efb8a4bc..1bc678fdca 100644
--- a/src/lib/dhcpsrv/cb_ctl_dhcp4.cc
+++ b/src/lib/dhcpsrv/cb_ctl_dhcp4.cc
@@ -13,6 +13,7 @@
#include <dhcpsrv/parsers/simple_parser4.h>
#include <hooks/callout_handle.h>
#include <hooks/hooks_manager.h>
+#include <boost/foreach.hpp>
using namespace isc::db;
using namespace isc::data;
@@ -99,37 +100,37 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
// audit entry is found.
range = index.equal_range(boost::make_tuple("dhcp4_option_def",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
- current_cfg->getCfgOptionDef()->del((*entry)->getObjectId());
+ BOOST_FOREACH(auto const& entry, range) {
+ current_cfg->getCfgOptionDef()->del(entry->getObjectId());
}
// Repeat the same for other configuration elements.
range = index.equal_range(boost::make_tuple("dhcp4_options",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
- current_cfg->getCfgOption()->del((*entry)->getObjectId());
+ BOOST_FOREACH(auto const& entry, range) {
+ current_cfg->getCfgOption()->del(entry->getObjectId());
}
range = index.equal_range(boost::make_tuple("dhcp4_client_class",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
- current_cfg->getClientClassDictionary()->removeClass((*entry)->getObjectId());
+ BOOST_FOREACH(auto const& entry, range) {
+ current_cfg->getClientClassDictionary()->removeClass(entry->getObjectId());
}
range = index.equal_range(boost::make_tuple("dhcp4_shared_network",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
- current_cfg->getCfgSharedNetworks4()->del((*entry)->getObjectId());
+ BOOST_FOREACH(auto const& entry, range) {
+ current_cfg->getCfgSharedNetworks4()->del(entry->getObjectId());
}
range = index.equal_range(boost::make_tuple("dhcp4_subnet",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
+ BOOST_FOREACH(auto const& entry, range) {
// If the deleted subnet belongs to a shared network and the
// shared network is not being removed, we need to detach the
// subnet from the shared network.
- auto subnet = current_cfg->getCfgSubnets4()->getBySubnetId((*entry)->getObjectId());
+ auto subnet = current_cfg->getCfgSubnets4()->getBySubnetId(entry->getObjectId());
if (subnet) {
// Check if the subnet belongs to a shared network.
SharedNetwork4Ptr network;
@@ -139,7 +140,7 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
network->del(subnet->getID());
}
// Actually delete the subnet from the configuration.
- current_cfg->getCfgSubnets4()->del((*entry)->getObjectId());
+ current_cfg->getCfgSubnets4()->del(entry->getObjectId());
}
}
@@ -177,11 +178,11 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
OptionDefContainer option_defs =
getMgr().getPool()->getModifiedOptionDefs4(backend_selector, server_selector,
lb_modification_time);
- for (auto option_def = option_defs.begin(); option_def != option_defs.end(); ++option_def) {
- if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option_def)->getId())) {
+ for (auto const& option_def : option_defs) {
+ if (!audit_entries.empty() && !hasObjectId(updated_entries, option_def->getId())) {
continue;
}
- external_cfg->getCfgOptionDef()->add(*option_def);
+ external_cfg->getCfgOptionDef()->add(option_def);
}
}
@@ -193,11 +194,11 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
OptionContainer options = getMgr().getPool()->getModifiedOptions4(backend_selector,
server_selector,
lb_modification_time);
- for (auto option = options.begin(); option != options.end(); ++option) {
- if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option).getId())) {
+ for (auto const& option : options) {
+ if (!audit_entries.empty() && !hasObjectId(updated_entries, option.getId())) {
continue;
}
- external_cfg->getCfgOption()->add((*option), (*option).space_name_);
+ external_cfg->getCfgOption()->add(option, option.space_name_);
}
}
@@ -257,18 +258,18 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
lb_modification_time);
}
// Iterate over all shared networks that may require reconfiguration.
- for (auto network = networks.begin(); network != networks.end(); ++network) {
- if (!allocator_changed && cb_update && !hasObjectId(updated_entries, (*network)->getId())) {
+ for (auto const& network : networks) {
+ if (!allocator_changed && cb_update && !hasObjectId(updated_entries, network->getId())) {
continue;
}
// In order to take advantage of the dynamic inheritance of global
// parameters to a shared network we need to set a callback function
// for each network to allow for fetching global parameters.
- (*network)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
+ network->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
- (*network)->setDefaultAllocatorType(global_allocator);
- external_cfg->getCfgSharedNetworks4()->add((*network));
+ network->setDefaultAllocatorType(global_allocator);
+ external_cfg->getCfgSharedNetworks4()->add(network);
}
// Next, fetch the subnets.
@@ -289,18 +290,18 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
lb_modification_time);
}
// Iterate over all subnets that may require reconfiguration.
- for (auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) {
- if (!allocator_changed && cb_update && !hasObjectId(updated_entries, (*subnet)->getID())) {
+ for (auto const& subnet : subnets) {
+ if (!allocator_changed && cb_update && !hasObjectId(updated_entries, subnet->getID())) {
continue;
}
// In order to take advantage of the dynamic inheritance of global
// parameters to a subnet we need to set a callback function for each
// subnet to allow for fetching global parameters.
- (*subnet)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
+ subnet->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
- (*subnet)->setDefaultAllocatorType(global_allocator);
- external_cfg->getCfgSubnets4()->add((*subnet));
+ subnet->setDefaultAllocatorType(global_allocator);
+ external_cfg->getCfgSubnets4()->add(subnet);
}
if (reconfig) {
diff --git a/src/lib/dhcpsrv/cb_ctl_dhcp6.cc b/src/lib/dhcpsrv/cb_ctl_dhcp6.cc
index ca74a5e531..fba428a38b 100644
--- a/src/lib/dhcpsrv/cb_ctl_dhcp6.cc
+++ b/src/lib/dhcpsrv/cb_ctl_dhcp6.cc
@@ -12,6 +12,7 @@
#include <dhcpsrv/parsers/simple_parser6.h>
#include <hooks/callout_handle.h>
#include <hooks/hooks_manager.h>
+#include <boost/foreach.hpp>
using namespace isc::db;
using namespace isc::data;
@@ -98,37 +99,37 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
// audit entry is found.
range = index.equal_range(boost::make_tuple("dhcp6_option_def",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
- current_cfg->getCfgOptionDef()->del((*entry)->getObjectId());
+ BOOST_FOREACH(auto const& entry, range) {
+ current_cfg->getCfgOptionDef()->del(entry->getObjectId());
}
// Repeat the same for other configuration elements.
range = index.equal_range(boost::make_tuple("dhcp6_options",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
- current_cfg->getCfgOption()->del((*entry)->getObjectId());
+ BOOST_FOREACH(auto const& entry, range) {
+ current_cfg->getCfgOption()->del(entry->getObjectId());
}
range = index.equal_range(boost::make_tuple("dhcp6_client_class",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
- current_cfg->getClientClassDictionary()->removeClass((*entry)->getObjectId());
+ BOOST_FOREACH(auto const& entry, range) {
+ current_cfg->getClientClassDictionary()->removeClass(entry->getObjectId());
}
range = index.equal_range(boost::make_tuple("dhcp6_shared_network",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
- current_cfg->getCfgSharedNetworks6()->del((*entry)->getObjectId());
+ BOOST_FOREACH(auto const& entry, range) {
+ current_cfg->getCfgSharedNetworks6()->del(entry->getObjectId());
}
range = index.equal_range(boost::make_tuple("dhcp6_subnet",
AuditEntry::ModificationType::DELETE));
- for (auto entry = range.first; entry != range.second; ++entry) {
+ BOOST_FOREACH(auto const& entry, range) {
// If the deleted subnet belongs to a shared network and the
// shared network is not being removed, we need to detach the
// subnet from the shared network.
- auto subnet = current_cfg->getCfgSubnets6()->getBySubnetId((*entry)->getObjectId());
+ auto subnet = current_cfg->getCfgSubnets6()->getBySubnetId(entry->getObjectId());
if (subnet) {
// Check if the subnet belongs to a shared network.
SharedNetwork6Ptr network;
@@ -138,7 +139,7 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
network->del(subnet->getID());
}
// Actually delete the subnet from the configuration.
- current_cfg->getCfgSubnets6()->del((*entry)->getObjectId());
+ current_cfg->getCfgSubnets6()->del(entry->getObjectId());
}
}
@@ -176,11 +177,11 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
OptionDefContainer option_defs =
getMgr().getPool()->getModifiedOptionDefs6(backend_selector, server_selector,
lb_modification_time);
- for (auto option_def = option_defs.begin(); option_def != option_defs.end(); ++option_def) {
- if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option_def)->getId())) {
+ for (auto const& option_def : option_defs) {
+ if (!audit_entries.empty() && !hasObjectId(updated_entries, option_def->getId())) {
continue;
}
- external_cfg->getCfgOptionDef()->add(*option_def);
+ external_cfg->getCfgOptionDef()->add(option_def);
}
}
@@ -192,11 +193,11 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
OptionContainer options = getMgr().getPool()->getModifiedOptions6(backend_selector,
server_selector,
lb_modification_time);
- for (auto option = options.begin(); option != options.end(); ++option) {
- if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option).getId())) {
+ for (auto const& option : options) {
+ if (!audit_entries.empty() && !hasObjectId(updated_entries, option.getId())) {
continue;
}
- external_cfg->getCfgOption()->add((*option), (*option).space_name_);
+ external_cfg->getCfgOption()->add(option, option.space_name_);
}
}
@@ -268,19 +269,19 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
networks = getMgr().getPool()->getModifiedSharedNetworks6(backend_selector, server_selector,
lb_modification_time);
}
- for (auto network = networks.begin(); network != networks.end(); ++network) {
- if (!allocator_changed && cb_update && !hasObjectId(updated_entries, (*network)->getId())) {
+ for (auto const& network : networks) {
+ if (!allocator_changed && cb_update && !hasObjectId(updated_entries, network->getId())) {
continue;
}
// In order to take advantage of the dynamic inheritance of global
// parameters to a shared network we need to set a callback function
// for each network to allow for fetching global parameters.
- (*network)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
+ network->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
- (*network)->setDefaultAllocatorType(global_allocator);
- (*network)->setDefaultPdAllocatorType(global_pd_allocator);
- external_cfg->getCfgSharedNetworks6()->add((*network));
+ network->setDefaultAllocatorType(global_allocator);
+ network->setDefaultPdAllocatorType(global_pd_allocator);
+ external_cfg->getCfgSharedNetworks6()->add(network);
}
// Next we fetch subnets.
@@ -301,19 +302,19 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
lb_modification_time);
}
// Iterate over all subnets that may require reconfiguration.
- for (auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) {
- if (!audit_entries.empty() && !hasObjectId(updated_entries, (*subnet)->getID())) {
+ for (auto const& subnet : subnets) {
+ if (!audit_entries.empty() && !hasObjectId(updated_entries, subnet->getID())) {
continue;
}
// In order to take advantage of the dynamic inheritance of global
// parameters to a subnet we need to set a callback function for each
// subnet to allow for fetching global parameters.
- (*subnet)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
+ subnet->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
- (*subnet)->setDefaultAllocatorType(global_allocator);
- (*subnet)->setDefaultPdAllocatorType(global_pd_allocator);
- external_cfg->getCfgSubnets6()->add((*subnet));
+ subnet->setDefaultAllocatorType(global_allocator);
+ subnet->setDefaultPdAllocatorType(global_pd_allocator);
+ external_cfg->getCfgSubnets6()->add(subnet);
}
if (reconfig) {
diff --git a/src/lib/dhcpsrv/cfg_db_access.cc b/src/lib/dhcpsrv/cfg_db_access.cc
index e3a37bfa30..37038a46be 100644
--- a/src/lib/dhcpsrv/cfg_db_access.cc
+++ b/src/lib/dhcpsrv/cfg_db_access.cc
@@ -13,7 +13,6 @@
#include <dhcpsrv/host_mgr.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <sstream>
#include <vector>
diff --git a/src/lib/dhcpsrv/cfg_globals.cc b/src/lib/dhcpsrv/cfg_globals.cc
index ed43125b33..7aab23038d 100644
--- a/src/lib/dhcpsrv/cfg_globals.cc
+++ b/src/lib/dhcpsrv/cfg_globals.cc
@@ -84,18 +84,17 @@ struct CfgGlobalsChecks {
// Build the name vector.
std::vector<std::string> names;
names.resize(CfgGlobals::SIZE);
- for (auto it = CfgGlobals::nameToIndex.cbegin();
- it != CfgGlobals::nameToIndex.cend(); ++it) {
- int idx = it->second;
+ for (auto const& it : CfgGlobals::nameToIndex) {
+ int idx = it.second;
if ((idx < 0) || (idx >= CfgGlobals::SIZE)) {
isc_throw(Unexpected, "invalid index " << idx
- << " for name " << it->first);
+ << " for name " << it.first);
}
if (!names[idx].empty()) {
isc_throw(Unexpected, "duplicated names for " << idx
<< " got " << names[idx]);
}
- names[idx] = it->first;
+ names[idx] = it.first;
}
// No name should be empty.
@@ -160,11 +159,11 @@ CfgGlobals::clear() {
const CfgGlobals::MapType
CfgGlobals::valuesMap() const {
MapType map;
- for (auto it = nameToIndex.cbegin(); it != nameToIndex.cend(); ++it) {
- int idx = it->second;
+ for (auto const& it : nameToIndex) {
+ int idx = it.second;
ConstElementPtr value = values_[idx];
if (value) {
- map.insert(make_pair(it->first, value));
+ map.insert(make_pair(it.first, value));
}
}
return (map);
@@ -173,11 +172,11 @@ CfgGlobals::valuesMap() const {
ElementPtr
CfgGlobals::toElement() const {
ElementPtr result = Element::createMap();
- for (auto it = nameToIndex.cbegin(); it != nameToIndex.cend(); ++it) {
- int idx = it->second;
+ for (auto const& it : nameToIndex) {
+ int idx = it.second;
ConstElementPtr value = values_[idx];
if (value) {
- result->set(it->first, value);
+ result->set(it.first, value);
}
}
return (result);
diff --git a/src/lib/dhcpsrv/cfg_host_operations.cc b/src/lib/dhcpsrv/cfg_host_operations.cc
index f588b9dc61..08093047b3 100644
--- a/src/lib/dhcpsrv/cfg_host_operations.cc
+++ b/src/lib/dhcpsrv/cfg_host_operations.cc
@@ -61,9 +61,8 @@ CfgHostOperations::clearIdentifierTypes() {
ElementPtr
CfgHostOperations::toElement() const {
ElementPtr result = Element::createList();
- for (IdentifierTypes::const_iterator id = identifier_types_.begin();
- id != identifier_types_.end(); ++id) {
- const std::string& name = Host::getIdentifierName(*id);
+ for (auto const& id : identifier_types_) {
+ const std::string& name = Host::getIdentifierName(id);
result->add(Element::create(name));
}
return (result);
diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc
index bee54332bc..69b924a0f9 100644
--- a/src/lib/dhcpsrv/cfg_hosts.cc
+++ b/src/lib/dhcpsrv/cfg_hosts.cc
@@ -13,6 +13,7 @@
#include <dhcpsrv/cfgmgr.h>
#include <exceptions/exceptions.h>
#include <util/encode/hex.h>
+#include <boost/foreach.hpp>
#include <ostream>
#include <string>
#include <vector>
@@ -618,13 +619,12 @@ CfgHosts::getAllInternal4(const IOAddress& address, Storage& storage) const {
const HostContainerIndex1& idx = hosts_.get<1>();
HostContainerIndex1Range r = idx.equal_range(address);
// Append each Host object to the storage.
- for (HostContainerIndex1::iterator host = r.first; host != r.second;
- ++host) {
+ BOOST_FOREACH(auto const& host, r) {
LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
HOSTS_CFG_GET_ALL_ADDRESS4_HOST)
.arg(address.toText())
- .arg((*host)->toText());
- storage.push_back(*host);
+ .arg(host->toText());
+ storage.push_back(host);
}
LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_ADDRESS4_COUNT)
@@ -647,13 +647,12 @@ CfgHosts::getAllInternal6(const IOAddress& address, Storage& storage) const {
const HostContainer6Index4& idx = hosts6_.get<4>();
HostContainer6Index4Range r = idx.equal_range(address);
// Append each Host object to the storage.
- for (HostContainer6Index4::iterator reservation = r.first; reservation != r.second;
- ++reservation) {
+ BOOST_FOREACH(auto const& reservation, r) {
LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
HOSTS_CFG_GET_ALL_ADDRESS6_HOST)
.arg(address.toText())
- .arg(reservation->host_->toText());
- storage.push_back(reservation->host_);
+ .arg(reservation.host_->toText());
+ storage.push_back(reservation.host_);
}
LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_ADDRESS6_COUNT)
@@ -685,15 +684,14 @@ CfgHosts::get4(const SubnetID& subnet_id, const IOAddress& address) const {
.arg(subnet_id).arg(address.toText());
ConstHostCollection hosts = getAll4(address);
- for (ConstHostCollection::const_iterator host = hosts.begin();
- host != hosts.end(); ++host) {
- if ((*host)->getIPv4SubnetID() == subnet_id) {
+ for (auto const& host : hosts) {
+ if (host->getIPv4SubnetID() == subnet_id) {
LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS,
HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4_HOST)
.arg(subnet_id)
.arg(address.toText())
- .arg((*host)->toText());
- return (*host);
+ .arg(host->toText());
+ return (host);
}
}
@@ -822,15 +820,14 @@ CfgHosts::getHostInternal6(const asiolink::IOAddress& prefix,
const HostContainer6Index0& idx = hosts6_.get<0>();
HostContainer6Index0Range r = make_pair(idx.lower_bound(prefix),
idx.upper_bound(prefix));
- for (HostContainer6Index0::iterator resrv = r.first; resrv != r.second;
- ++resrv) {
- if (resrv->resrv_.getPrefixLen() == prefix_len) {
+ BOOST_FOREACH(auto const& resrv, r) {
+ if (resrv.resrv_.getPrefixLen() == prefix_len) {
LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
HOSTS_CFG_GET_ONE_PREFIX_HOST)
.arg(prefix.toText())
.arg(static_cast<int>(prefix_len))
- .arg(resrv->host_->toText());
- return (resrv->host_);
+ .arg(resrv.host_->toText());
+ return (resrv.host_);
}
}
@@ -864,13 +861,13 @@ CfgHosts::getAllInternal6(const SubnetID& subnet_id,
// in all sane cases, there will be only one such host. (Each host can have
// multiple addresses reserved, but for each (address, subnet_id) there should
// be at most one host reserving it).
- for(HostContainer6Index1::iterator resrv = r.first; resrv != r.second; ++resrv) {
+ BOOST_FOREACH(auto const& resrv, r) {
LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_HOST)
.arg(subnet_id)
.arg(address.toText())
- .arg(resrv->host_->toText());
- storage.push_back(resrv->host_);
+ .arg(resrv.host_->toText());
+ storage.push_back(resrv.host_);
}
LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS,
@@ -901,11 +898,10 @@ CfgHosts::getHostInternal(const SubnetID& subnet_id, const bool subnet6,
HostPtr host;
// Iterate over the returned hosts and select those for which the
// subnet id matches.
- for (HostCollection::const_iterator host_it = hosts.begin();
- host_it != hosts.end(); ++host_it) {
+ for (auto const& host_it : hosts) {
// Check if this is IPv4 subnet or IPv6 subnet.
- SubnetID host_subnet_id = subnet6 ? (*host_it)->getIPv6SubnetID() :
- (*host_it)->getIPv4SubnetID();
+ SubnetID host_subnet_id = subnet6 ? host_it->getIPv6SubnetID() :
+ host_it->getIPv4SubnetID();
if (subnet_id == host_subnet_id) {
// If this is the first occurrence of the host for this subnet,
@@ -916,7 +912,7 @@ CfgHosts::getHostInternal(const SubnetID& subnet_id, const bool subnet6,
// result, and we don't know which reservation we should choose.
// Therefore, throw an exception.
if (!host) {
- host = *host_it;
+ host = host_it;
} else {
isc_throw(DuplicateHost, "more than one reservation found"
@@ -1066,22 +1062,21 @@ CfgHosts::add6(const HostPtr& host) {
}
// Now for each reservation, insert corresponding (address, host) tuple.
- for (IPv6ResrvIterator it = reservations.first; it != reservations.second;
- ++it) {
+ BOOST_FOREACH(auto const& it, reservations) {
if (ip_reservations_unique_) {
// If there's an entry for this (subnet-id, address), reject it.
- if (get6(host->getIPv6SubnetID(), it->second.getPrefix())) {
+ if (get6(host->getIPv6SubnetID(), it.second.getPrefix())) {
isc_throw(DuplicateHost, "failed to add address reservation for "
<< "host using the HW address '"
<< (hwaddr ? hwaddr->toText(false) : "(null)")
<< " and DUID '" << (duid ? duid->toText() : "(null)")
<< "' to the IPv6 subnet id '" << host->getIPv6SubnetID()
- << "' for address/prefix " << it->second.getPrefix()
+ << "' for address/prefix " << it.second.getPrefix()
<< ": There's already reservation for this address/prefix");
}
}
- hosts6_.insert(HostResrv6Tuple(it->second, host));
+ hosts6_.insert(HostResrv6Tuple(it.second, host));
}
}
@@ -1103,8 +1098,8 @@ CfgHosts::del(const SubnetID& subnet_id, const asiolink::IOAddress& addr) {
auto const& range = idx6.equal_range(boost::make_tuple(subnet_id, addr));
erased_addresses = boost::distance(range);
// Delete hosts.
- for (auto key = range.first; key != range.second; ++key) {
- erased_hosts += idx.erase(key->host_->getHostId());
+ BOOST_FOREACH(auto const& key, range) {
+ erased_hosts += idx.erase(key.host_->getHostId());
}
idx6.erase(range.first, range.second);
}
@@ -1137,8 +1132,8 @@ CfgHosts::del4(const SubnetID& subnet_id,
const size_t identifier_len) {
HostContainerIndex0& idx = hosts_.get<0>();
auto const t = boost::make_tuple(std::vector<uint8_t>(identifier_begin,
- identifier_begin + identifier_len),
- identifier_type);
+ identifier_begin + identifier_len),
+ identifier_type);
auto const& range = idx.equal_range(t);
size_t erased = 0;
for (auto key = range.first; key != range.second;) {
@@ -1241,14 +1236,13 @@ CfgHosts::toElement4() const {
CfgHostsList result;
// Iterate using arbitrary the index 0
const HostContainerIndex0& idx = hosts_.get<0>();
- for (HostContainerIndex0::const_iterator host = idx.begin();
- host != idx.end(); ++host) {
+ for (auto const& host : idx) {
// Convert host to element representation
- ElementPtr map = (*host)->toElement4();
+ ElementPtr map = host->toElement4();
// Push it on the list
- SubnetID subnet_id = (*host)->getIPv4SubnetID();
+ SubnetID subnet_id = host->getIPv4SubnetID();
result.add(subnet_id, map);
}
return (result.externalize());
@@ -1259,14 +1253,13 @@ CfgHosts::toElement6() const {
CfgHostsList result;
// Iterate using arbitrary the index 0
const HostContainerIndex0& idx = hosts_.get<0>();
- for (HostContainerIndex0::const_iterator host = idx.begin();
- host != idx.end(); ++host) {
+ for (auto const& host : idx) {
// Convert host to Element representation
- ElementPtr map = (*host)->toElement6();
+ ElementPtr map = host->toElement6();
// Push it on the list
- SubnetID subnet_id = (*host)->getIPv6SubnetID();
+ SubnetID subnet_id = host->getIPv6SubnetID();
result.add(subnet_id, map);
}
return (result.externalize());
diff --git a/src/lib/dhcpsrv/cfg_hosts_util.cc b/src/lib/dhcpsrv/cfg_hosts_util.cc
index 11c9e87aa2..31db3c1eec 100644
--- a/src/lib/dhcpsrv/cfg_hosts_util.cc
+++ b/src/lib/dhcpsrv/cfg_hosts_util.cc
@@ -62,11 +62,10 @@ void CfgHostsList::internalize(ConstElementPtr list) {
ElementPtr CfgHostsList::externalize() const {
ElementPtr result = Element::createList();
- for (CfgHostsMap::const_iterator item = map_.begin();
- item != map_.end(); ++item) {
+ for (auto const& item : map_) {
ElementPtr pair = Element::createMap();
- pair->set("id", Element::create(static_cast<int64_t>(item->first)));
- pair->set("reservations", item->second);
+ pair->set("id", Element::create(static_cast<int64_t>(item.first)));
+ pair->set("reservations", item.second);
result->add(pair);
}
return (result);
diff --git a/src/lib/dhcpsrv/cfg_iface.cc b/src/lib/dhcpsrv/cfg_iface.cc
index 16f523cada..fa23e54db8 100644
--- a/src/lib/dhcpsrv/cfg_iface.cc
+++ b/src/lib/dhcpsrv/cfg_iface.cc
@@ -49,7 +49,7 @@ CfgIface::equals(const CfgIface& other) const {
bool
CfgIface::multipleAddressesPerInterfaceActive() {
- for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
+ for (auto const& iface : IfaceMgr::instance().getIfaces()) {
if (iface->countActive4() > 1) {
return (true);
}
@@ -69,17 +69,15 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
bool loopback_used_ = false;
if ((family == AF_INET6) || (socket_type_ == SOCKET_UDP)) {
// Check interface set
- for (IfaceSet::const_iterator iface_name = iface_set_.begin();
- iface_name != iface_set_.end(); ++iface_name) {
- IfacePtr iface = IfaceMgr::instance().getIface(*iface_name);
+ for (auto const& iface_name : iface_set_) {
+ IfacePtr iface = IfaceMgr::instance().getIface(iface_name);
if (iface && iface->flag_loopback_) {
loopback_used_ = true;
}
}
// Check address map
- for (ExplicitAddressMap::const_iterator unicast = address_map_.begin();
- unicast != address_map_.end(); ++unicast) {
- IfacePtr iface = IfaceMgr::instance().getIface(unicast->first);
+ for (auto const& unicast : address_map_) {
+ IfacePtr iface = IfaceMgr::instance().getIface(unicast.first);
if (iface && iface->flag_loopback_) {
loopback_used_ = true;
}
@@ -112,9 +110,8 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
// If there is no wildcard interface specified, we will have to iterate
// over the names specified by the caller and enable them.
if (!wildcard_used_) {
- for (IfaceSet::const_iterator iface_name = iface_set_.begin();
- iface_name != iface_set_.end(); ++iface_name) {
- IfacePtr iface = IfaceMgr::instance().getIface(*iface_name);
+ for (auto const& iface_name : iface_set_) {
+ IfacePtr iface = IfaceMgr::instance().getIface(iface_name);
// This shouldn't really happen because we are checking the
// names of interfaces when they are being added (use()
// function). But, if someone has triggered detection of
@@ -122,7 +119,7 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
if (iface == NULL) {
isc_throw(Unexpected,
"fail to open socket on interface '"
- << *iface_name << "' as this interface doesn't"
+ << iface_name << "' as this interface doesn't"
" exist");
} else if (family == AF_INET) {
@@ -137,21 +134,20 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
// Select unicast sockets for DHCPv6 or activate specific IPv4 addresses
// for DHCPv4.
- for (ExplicitAddressMap::const_iterator unicast = address_map_.begin();
- unicast != address_map_.end(); ++unicast) {
- IfacePtr iface = IfaceMgr::instance().getIface(unicast->first);
+ for (auto const& unicast : address_map_) {
+ IfacePtr iface = IfaceMgr::instance().getIface(unicast.first);
if (iface == NULL) {
isc_throw(Unexpected,
"fail to open unicast socket on interface '"
- << unicast->first << "' as this interface doesn't"
+ << unicast.first << "' as this interface doesn't"
" exist");
}
if (family == AF_INET6) {
- iface->addUnicast(unicast->second);
+ iface->addUnicast(unicast.second);
iface->inactive6_ = false;
} else {
- iface->setActive(unicast->second, true);
+ iface->setActive(unicast.second, true);
iface->inactive4_ = false;
}
}
@@ -284,7 +280,7 @@ CfgIface::reset() {
void
CfgIface::setState(const uint16_t family, const bool inactive,
const bool loopback_inactive) const {
- for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
+ for (auto const& iface : IfaceMgr::instance().getIfaces()) {
bool iface_inactive = iface->flag_loopback_ ? loopback_inactive : inactive;
if (family == AF_INET) {
iface->inactive4_ = iface_inactive;
@@ -301,7 +297,7 @@ void
CfgIface::setIfaceAddrsState(const uint16_t family, const bool active,
Iface& iface) const {
// Activate/deactivate all addresses.
- for (const Iface::Address& addr : iface.getAddresses()) {
+ for (auto const& addr : iface.getAddresses()) {
if (addr.get().getFamily() == family) {
iface.setActive(addr.get(), active);
}
@@ -565,13 +561,11 @@ CfgIface::toElement() const {
if (wildcard_used_) {
ifaces->add(Element::create(std::string(ALL_IFACES_KEYWORD)));
}
- for (IfaceSet::const_iterator iface = iface_set_.cbegin();
- iface != iface_set_.cend(); ++iface) {
- ifaces->add(Element::create(*iface));
+ for (auto const& iface : iface_set_) {
+ ifaces->add(Element::create(iface));
}
- for (ExplicitAddressMap::const_iterator address = address_map_.cbegin();
- address != address_map_.cend(); ++address) {
- std::string spec = address->first + "/" + address->second.toText();
+ for (auto const& address : address_map_) {
+ std::string spec = address.first + "/" + address.second.toText();
ifaces->add(Element::create(spec));
}
result->set("interfaces", ifaces);
diff --git a/src/lib/dhcpsrv/cfg_mac_source.cc b/src/lib/dhcpsrv/cfg_mac_source.cc
index 7a0db260b3..8fbc9c71d3 100644
--- a/src/lib/dhcpsrv/cfg_mac_source.cc
+++ b/src/lib/dhcpsrv/cfg_mac_source.cc
@@ -55,9 +55,8 @@ uint32_t CfgMACSource::MACSourceFromText(const std::string& name) {
}
void CfgMACSource::add(uint32_t source) {
- for (CfgMACSources::const_iterator it = mac_sources_.begin();
- it != mac_sources_.end(); ++it) {
- if (*it == source) {
+ for (auto const& it : mac_sources_) {
+ if (it == source) {
isc_throw(InvalidParameter, "mac-source parameter " << source
<< "' specified twice.");
}
@@ -67,17 +66,16 @@ void CfgMACSource::add(uint32_t source) {
ElementPtr CfgMACSource::toElement() const {
ElementPtr result = Element::createList();
- for (CfgMACSources::const_iterator source = mac_sources_.cbegin();
- source != mac_sources_.cend(); ++source) {
+ for (auto const& source : mac_sources_) {
std::string name;
for (unsigned i = 0; i < sizeof(sources)/sizeof(sources[0]); ++i) {
- if (sources[i].type == *source) {
+ if (sources[i].type == source) {
name = sources[i].name;
break;
}
}
if (name.empty()) {
- isc_throw(ToElementError, "invalid MAC source: " << *source);
+ isc_throw(ToElementError, "invalid MAC source: " << source);
}
result->add(Element::create(name));
}
@@ -85,5 +83,5 @@ ElementPtr CfgMACSource::toElement() const {
return (result);
}
-};
-};
+}
+}
diff --git a/src/lib/dhcpsrv/cfg_option.cc b/src/lib/dhcpsrv/cfg_option.cc
index c4b8f47021..4b731090f4 100644
--- a/src/lib/dhcpsrv/cfg_option.cc
+++ b/src/lib/dhcpsrv/cfg_option.cc
@@ -374,16 +374,14 @@ CfgOption::del(const std::string& option_space, const uint16_t option_code) {
auto option_space_names = getOptionSpaceNames();
for (auto const& option_space_from_list : option_space_names) {
// Get all options within the particular option space.
- auto options_in_space = getAll(option_space_from_list);
- for (auto option_it = options_in_space->begin();
- option_it != options_in_space->end();
- ++option_it) {
+ auto const& options_in_space = getAll(option_space_from_list);
+ for (auto const& option_it : *options_in_space) {
// Check if the option encapsulates our option space and
// it does, try to delete our option.
- if (option_it->option_ &&
- (option_it->option_->getEncapsulatedSpace() == option_space)) {
- option_it->option_->delOption(option_code);
+ if (option_it.option_ &&
+ (option_it.option_->getEncapsulatedSpace() == option_space)) {
+ option_it.option_->delOption(option_code);
}
}
}
@@ -413,20 +411,18 @@ CfgOption::del(const uint64_t id) {
// any of them. Let's walk over the existing option spaces.
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();
- ++option_it) {
- if (!option_it->option_) {
+ auto const& options = getAll(space_name);
+ for (auto const& option_it : *options) {
+ if (!option_it.option_) {
continue;
}
// For each option within the option space we need to dereference
// any existing sub options.
- auto sub_options = option_it->option_->getOptions();
- for (auto sub = sub_options.begin(); sub != sub_options.end();
- ++sub) {
+ auto sub_options = option_it.option_->getOptions();
+ for (auto const& sub : sub_options) {
// Dereference sub option.
- option_it->option_->delOption(sub->second->getType());
+ option_it.option_->delOption(sub.second->getType());
}
}
}
diff --git a/src/lib/dhcpsrv/cfg_option.h b/src/lib/dhcpsrv/cfg_option.h
index a0c6d0b68d..fd33d8df8b 100644
--- a/src/lib/dhcpsrv/cfg_option.h
+++ b/src/lib/dhcpsrv/cfg_option.h
@@ -14,6 +14,7 @@
#include <cc/user_context.h>
#include <dhcpsrv/cfg_option_def.h>
#include <dhcpsrv/key_from_key.h>
+#include <boost/foreach.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/ordered_index.hpp>
@@ -516,7 +517,7 @@ public:
/// there is no definition matching the option code in the given space, or
/// if the definition factory invocation fails.
static bool createDescriptorOption(CfgOptionDefPtr cfg_def, const std::string& space,
- OptionDescriptor& opt_desc);
+ OptionDescriptor& opt_desc);
/// @brief Merges this configuration to another configuration.
///
@@ -646,9 +647,8 @@ public:
const OptionContainerTypeIndex& idx = options->get<1>();
OptionContainerTypeRange range = idx.equal_range(option_code);
// This code copies descriptors and can be optimized not doing this.
- for (OptionContainerTypeIndex::const_iterator od_itr = range.first;
- od_itr != range.second; ++od_itr) {
- list.push_back(*od_itr);
+ BOOST_FOREACH(auto const& od_itr, range) {
+ list.push_back(od_itr);
}
return (list);
diff --git a/src/lib/dhcpsrv/cfg_option_def.cc b/src/lib/dhcpsrv/cfg_option_def.cc
index e154d19441..f1671f3f6f 100644
--- a/src/lib/dhcpsrv/cfg_option_def.cc
+++ b/src/lib/dhcpsrv/cfg_option_def.cc
@@ -23,13 +23,11 @@ CfgOptionDef::copyTo(CfgOptionDef& new_config) const {
new_config.option_definitions_.clearItems();
const std::list<std::string>& names =
option_definitions_.getOptionSpaceNames();
- for (std::list<std::string>::const_iterator name = names.begin();
- name != names.end(); ++name) {
- OptionDefContainerPtr defs = getAll(*name);
- for (OptionDefContainer::const_iterator def = defs->begin();
- def != defs->end(); ++def) {
+ for (auto const& name : names) {
+ OptionDefContainerPtr defs = getAll(name);
+ for (auto const& def : *defs) {
OptionDefinitionPtr new_def =
- OptionDefinitionPtr(new OptionDefinition(**def));
+ OptionDefinitionPtr(new OptionDefinition(*def));
new_config.add(new_def);
}
}
@@ -49,23 +47,20 @@ CfgOptionDef::equals(const CfgOptionDef& other) const {
}
// Iterate over all option space names and get the definitions for each
// of them.
- for (std::list<std::string>::const_iterator name = names.begin();
- name != names.end(); ++name) {
+ for (auto const& name : names) {
// Get all definitions.
- OptionDefContainerPtr defs = getAll(*name);
- OptionDefContainerPtr other_defs = other.getAll(*name);
+ OptionDefContainerPtr defs = getAll(name);
+ OptionDefContainerPtr other_defs = other.getAll(name);
// Compare sizes. If they hold different number of definitions,
// they are unequal.
if (defs->size() != defs->size()) {
return (false);
}
// For each option definition, try to find one in the other object.
- for (OptionDefContainer::const_iterator def = defs->begin();
- def != defs->end(); ++def) {
- OptionDefinitionPtr
- other_def = other.get(*name, (*def)->getCode());
+ for (auto const& def : *defs) {
+ OptionDefinitionPtr other_def = other.get(name, def->getCode());
// Actually compare them.
- if (!other_def || (*other_def != **def)) {
+ if (!other_def || (*other_def != *def)) {
return (false);
}
}
@@ -175,41 +170,40 @@ CfgOptionDef::toElementWithMetadata(const bool include_metadata) const {
// Iterate through the container by names and definitions
const std::list<std::string>& names =
option_definitions_.getOptionSpaceNames();
- for (std::list<std::string>::const_iterator name = names.begin();
- name != names.end(); ++name) {
- OptionDefContainerPtr defs = getAll(*name);
- for (OptionDefContainer::const_iterator def = defs->begin();
- def != defs->end(); ++def) {
+ for (auto const& name : names) {
+ OptionDefContainerPtr defs = getAll(name);
+ for (auto const& def : *defs) {
// Get and fill the map for this definition
ElementPtr map = Element::createMap();
// Set user context
- (*def)->contextToElement(map);
+ def->contextToElement(map);
// Set space from parent iterator
- map->set("space", Element::create(*name));
+ map->set("space", Element::create(name));
// Set required items: name, code and type
- map->set("name", Element::create((*def)->getName()));
- map->set("code", Element::create((*def)->getCode()));
+ map->set("name", Element::create(def->getName()));
+ map->set("code", Element::create(def->getCode()));
std::string data_type =
- OptionDataTypeUtil::getDataTypeName((*def)->getType());
+ OptionDataTypeUtil::getDataTypeName(def->getType());
map->set("type", Element::create(data_type));
// Set the array type
- bool array_type = (*def)->getArrayType();
+ bool array_type = def->getArrayType();
map->set("array", Element::create(array_type));
// Set the encapsulate space
- std::string encapsulates = (*def)->getEncapsulatedSpace();
+ std::string encapsulates = def->getEncapsulatedSpace();
map->set("encapsulate", Element::create(encapsulates));
// Set the record field types
OptionDefinition::RecordFieldsCollection fields =
- (*def)->getRecordFields();
+ def->getRecordFields();
if (!fields.empty()) {
std::ostringstream oss;
- for (OptionDefinition::RecordFieldsCollection::const_iterator
- field = fields.begin();
- field != fields.end(); ++field) {
- if (field != fields.begin()) {
+ bool first = true;
+ for (auto const& field : fields) {
+ if (!first) {
oss << ", ";
+ } else {
+ first = false;
}
- oss << OptionDataTypeUtil::getDataTypeName(*field);
+ oss << OptionDataTypeUtil::getDataTypeName(field);
}
map->set("record-types", Element::create(oss.str()));
} else {
@@ -218,7 +212,7 @@ CfgOptionDef::toElementWithMetadata(const bool include_metadata) const {
// Include metadata if requested.
if (include_metadata) {
- map->set("metadata", (*def)->getMetadata());
+ map->set("metadata", def->getMetadata());
}
// Push on the list
diff --git a/src/lib/dhcpsrv/cfg_rsoo.cc b/src/lib/dhcpsrv/cfg_rsoo.cc
index 30f02e67c2..b9f4e4595c 100644
--- a/src/lib/dhcpsrv/cfg_rsoo.cc
+++ b/src/lib/dhcpsrv/cfg_rsoo.cc
@@ -42,9 +42,8 @@ ElementPtr
CfgRSOO::toElement() const {
ElementPtr result = Element::createList();
// We can use LibDHCP::getOptionDef(DHCP6_OPTION_SPACE, *opt) too...
- for (std::set<uint16_t>::const_iterator opt = rsoo_options_.cbegin();
- opt != rsoo_options_.cend(); ++opt) {
- const std::string& code = boost::lexical_cast<std::string>(*opt);
+ for (auto const& opt : rsoo_options_) {
+ const std::string& code = boost::lexical_cast<std::string>(opt);
result->add(Element::create(code));
}
return (result);
diff --git a/src/lib/dhcpsrv/cfg_shared_networks.h b/src/lib/dhcpsrv/cfg_shared_networks.h
index a478220171..4bf38ac50f 100644
--- a/src/lib/dhcpsrv/cfg_shared_networks.h
+++ b/src/lib/dhcpsrv/cfg_shared_networks.h
@@ -12,6 +12,7 @@
#include <cc/data.h>
#include <exceptions/exceptions.h>
#include <dhcpsrv/shared_network.h>
+#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
#include <string>
@@ -91,8 +92,8 @@ public:
// For each shared network found, dereference the subnets belonging
// to it.
- for (auto it = sn_range.first; it != sn_range.second; ++it) {
- (*it)->delAll();
+ BOOST_FOREACH(auto const& it, sn_range) {
+ it->delAll();
}
// Remove the shared networks.
@@ -123,9 +124,8 @@ public:
// Insert shared networks sorted by their names into the list.
auto const& index = networks_.template get<SharedNetworkNameIndexTag>();
- for (auto shared_network = index.begin(); shared_network != index.end();
- ++shared_network) {
- list->add((*shared_network)->toElement());
+ for (auto const& shared_network : index) {
+ list->add(shared_network->toElement());
}
return (list);
}
@@ -165,21 +165,20 @@ public:
// Iterate over the subnets to be merged. They will replace the existing
// subnets with the same id. All new subnets will be inserted into this
// configuration.
- auto other_networks = other.getAll();
- for (auto other_network = other_networks->begin();
- other_network != other_networks->end(); ++other_network) {
+ auto const& other_networks = other.getAll();
+ for (auto const& other_network : *other_networks) {
// In theory we should drop subnet assignments from "other". The
// idea being those that come from the CB should not have subnets_
// populated. We will quietly throw them away, just in case.
- (*other_network)->delAll();
+ other_network->delAll();
// Check if the other network exists in this config.
- auto existing_network = index.find((*other_network)->getName());
+ auto existing_network = index.find(other_network->getName());
if (existing_network != index.end()) {
// Somehow the same instance is in both, skip it.
- if (*existing_network == *other_network) {
+ if (*existing_network == other_network) {
continue;
}
@@ -189,9 +188,9 @@ public:
auto const subnets = (*existing_network)->getAllSubnets();
auto copy_subnets(*subnets);
- for (auto subnet = copy_subnets.cbegin(); subnet != copy_subnets.cend(); ++subnet) {
- (*existing_network)->del((*subnet)->getID());
- (*other_network)->add(*subnet);
+ for (auto const& subnet : copy_subnets) {
+ (*existing_network)->del(subnet->getID());
+ other_network->add(subnet);
}
// Now we discard the existing copy of the network.
@@ -199,10 +198,10 @@ public:
}
// Create the network's options based on the given definitions.
- (*other_network)->getCfgOption()->createOptions(cfg_def);
+ other_network->getCfgOption()->createOptions(cfg_def);
// Add the new/updated nework.
- static_cast<void>(networks_.push_back(*other_network));
+ static_cast<void>(networks_.push_back(other_network));
}
}
diff --git a/src/lib/dhcpsrv/cfg_subnets6.cc b/src/lib/dhcpsrv/cfg_subnets6.cc
index 179c5bd226..b1dcec6035 100644
--- a/src/lib/dhcpsrv/cfg_subnets6.cc
+++ b/src/lib/dhcpsrv/cfg_subnets6.cc
@@ -13,7 +13,7 @@
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/subnet_id.h>
#include <stats/stats_mgr.h>
-#include <boost/foreach.hpp>
+#include <boost/range/adaptor/reversed.hpp>
#include <string.h>
#include <sstream>
@@ -210,7 +210,7 @@ CfgSubnets6::initSelector(const Pkt6Ptr& query) {
// Initialize fields specific to relayed messages.
if (!query->relay_info_.empty()) {
- BOOST_REVERSE_FOREACH(Pkt6::RelayInfo relay, query->relay_info_) {
+ for (auto const& relay : boost::adaptors::reverse(query->relay_info_)) {
if (!relay.linkaddr_.isV6Zero() &&
!relay.linkaddr_.isV6LinkLocal()) {
selector.first_relay_linkaddr_ = relay.linkaddr_;
diff --git a/src/lib/dhcpsrv/client_class_def.cc b/src/lib/dhcpsrv/client_class_def.cc
index 168288343c..033ad36989 100644
--- a/src/lib/dhcpsrv/client_class_def.cc
+++ b/src/lib/dhcpsrv/client_class_def.cc
@@ -13,7 +13,6 @@
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/parsers/client_class_def_parser.h>
-#include <boost/foreach.hpp>
#include <queue>
@@ -55,7 +54,7 @@ ClientClassDef::ClientClassDef(const ClientClassDef& rhs)
if (rhs.match_expr_) {
match_expr_.reset(new Expression());
- *match_expr_ = *(rhs.match_expr_);
+ *match_expr_ = *rhs.match_expr_;
}
if (rhs.cfg_option_def_) {
@@ -215,7 +214,7 @@ ClientClassDef::equals(const ClientClassDef& other) const {
return ((name_ == other.name_) &&
((!match_expr_ && !other.match_expr_) ||
(match_expr_ && other.match_expr_ &&
- (*match_expr_ == *(other.match_expr_)))) &&
+ (*match_expr_ == *other.match_expr_))) &&
((!cfg_option_ && !other.cfg_option_) ||
(cfg_option_ && other.cfg_option_ &&
(*cfg_option_ == *other.cfg_option_))) &&
@@ -330,7 +329,7 @@ ClientClassDictionary::ClientClassDictionary()
ClientClassDictionary::ClientClassDictionary(const ClientClassDictionary& rhs)
: map_(new ClientClassDefMap()), list_(new ClientClassDefList()) {
- BOOST_FOREACH(ClientClassDefPtr cclass, *(rhs.list_)) {
+ for (auto const& cclass : *rhs.list_) {
ClientClassDefPtr copy(new ClientClassDef(*cclass));
addClass(copy);
}
@@ -444,15 +443,14 @@ ClientClassDictionary::dependOnClass(const std::string& name,
std::string& dependent_class) const {
// Skip previous classes as they should not depend on name.
bool found = false;
- for (ClientClassDefList::iterator this_class = list_->begin();
- this_class != list_->end(); ++this_class) {
+ for (auto const& this_class : *list_) {
if (found) {
- if ((*this_class)->dependOnClass(name)) {
- dependent_class = (*this_class)->getName();
+ if (this_class->dependOnClass(name)) {
+ dependent_class = this_class->getName();
return (true);
}
} else {
- if ((*this_class)->getName() == name) {
+ if (this_class->getName() == name) {
found = true;
}
}
@@ -552,9 +550,8 @@ ElementPtr
ClientClassDictionary::toElement() const {
ElementPtr result = Element::createList();
// Iterate on the map
- for (ClientClassDefList::const_iterator this_class = list_->begin();
- this_class != list_->cend(); ++this_class) {
- result->add((*this_class)->toElement());
+ for (auto const& this_class : *list_) {
+ result->add(this_class->toElement());
}
return (result);
}
@@ -564,7 +561,7 @@ ClientClassDictionary::operator=(const ClientClassDictionary& rhs) {
if (this != &rhs) {
list_->clear();
map_->clear();
- for (auto const& cclass : *(rhs.list_)) {
+ for (auto const& cclass : *rhs.list_) {
ClientClassDefPtr copy(new ClientClassDef(*cclass));
addClass(copy);
}
@@ -597,20 +594,18 @@ builtinPrefixes = {
bool
isClientClassBuiltIn(const ClientClass& client_class) {
- for (std::list<std::string>::const_iterator bn = builtinNames.cbegin();
- bn != builtinNames.cend(); ++bn) {
- if (client_class == *bn) {
+ for (auto const& bn : builtinNames) {
+ if (client_class == bn) {
return true;
}
}
- for (std::list<std::string>::const_iterator bt = builtinPrefixes.cbegin();
- bt != builtinPrefixes.cend(); ++bt) {
- if (client_class.size() <= bt->size()) {
+ for (auto const& bt : builtinPrefixes) {
+ if (client_class.size() <= bt.size()) {
continue;
}
- auto mis = std::mismatch(bt->cbegin(), bt->cend(), client_class.cbegin());
- if (mis.first == bt->cend()) {
+ auto mis = std::mismatch(bt.cbegin(), bt.cend(), client_class.cbegin());
+ if (mis.first == bt.cend()) {
return true;
}
}
diff --git a/src/lib/dhcpsrv/d2_client_mgr.h b/src/lib/dhcpsrv/d2_client_mgr.h
index 7b282c5c52..f2a67be94d 100644
--- a/src/lib/dhcpsrv/d2_client_mgr.h
+++ b/src/lib/dhcpsrv/d2_client_mgr.h
@@ -499,12 +499,15 @@ D2ClientMgr::adjustDomainName(const T& fqdn, T& fqdn_resp, const DdnsParams& ddn
std::vector<std::string> labels;
boost::algorithm::split(labels, raw_name, boost::is_any_of("."));
std::stringstream ss;
- for (auto label = labels.begin(); label != labels.end(); ++label ) {
- if (label != labels.begin()) {
+ bool first = true;
+ for (auto const& label : labels) {
+ if (!first) {
ss << ".";
+ } else {
+ first = false;
}
- ss << sanitizer->scrub(*label);
+ ss << sanitizer->scrub(label);
}
client_name = ss.str();
diff --git a/src/lib/dhcpsrv/dhcp4o6_ipc.cc b/src/lib/dhcpsrv/dhcp4o6_ipc.cc
index 4cfe046856..c0b882fdf6 100644
--- a/src/lib/dhcpsrv/dhcp4o6_ipc.cc
+++ b/src/lib/dhcpsrv/dhcp4o6_ipc.cc
@@ -142,9 +142,8 @@ Pkt6Ptr Dhcp4o6IpcBase::receive() {
// Get all vendor option and look for the one with the ISC enterprise id.
OptionCollection vendor_options = pkt->getOptions(D6O_VENDOR_OPTS);
- for (OptionCollection::const_iterator opt = vendor_options.begin();
- opt != vendor_options.end(); ++opt) {
- option_vendor = boost::dynamic_pointer_cast<OptionVendor>(opt->second);
+ for (auto const& opt : vendor_options) {
+ option_vendor = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
if (option_vendor) {
if (option_vendor->getVendorId() == ENTERPRISE_ID_ISC) {
break;
@@ -244,9 +243,8 @@ void Dhcp4o6IpcBase::send(const Pkt6Ptr& pkt) {
// Get all vendor option and look for the one with the ISC enterprise id.
OptionCollection vendor_options = pkt->getOptions(D6O_VENDOR_OPTS);
- for (OptionCollection::const_iterator opt = vendor_options.begin();
- opt != vendor_options.end(); ++opt) {
- option_vendor = boost::dynamic_pointer_cast<OptionVendor>(opt->second);
+ for (auto const& opt : vendor_options) {
+ option_vendor = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
if (option_vendor) {
if (option_vendor->getVendorId() == ENTERPRISE_ID_ISC) {
break;
diff --git a/src/lib/dhcpsrv/host.cc b/src/lib/dhcpsrv/host.cc
index 30ac4766a5..5c6de5b7c0 100644
--- a/src/lib/dhcpsrv/host.cc
+++ b/src/lib/dhcpsrv/host.cc
@@ -16,6 +16,7 @@
#include <util/encode/hex.h>
#include <util/strutil.h>
+#include <boost/foreach.hpp>
#include <sstream>
using namespace isc::data;
@@ -448,9 +449,8 @@ bool
Host::hasReservation(const IPv6Resrv& reservation) const {
IPv6ResrvRange reservations = getIPv6Reservations(reservation.getType());
if (std::distance(reservations.first, reservations.second) > 0) {
- for (IPv6ResrvIterator it = reservations.first;
- it != reservations.second; ++it) {
- if (it->second == reservation) {
+ BOOST_FOREACH(auto const& it, reservations) {
+ if (it.second == reservation) {
return (true);
}
}
@@ -561,9 +561,8 @@ Host::toElement4() const {
// Set client-classes
const ClientClasses& cclasses = getClientClasses4();
ElementPtr classes = Element::createList();
- for (ClientClasses::const_iterator cclass = cclasses.cbegin();
- cclass != cclasses.cend(); ++cclass) {
- classes->add(Element::create(*cclass));
+ for (auto const& cclass : cclasses) {
+ classes->add(Element::create(cclass));
}
map->set("client-classes", classes);
// Set option-data
@@ -599,19 +598,17 @@ Host::toElement6() const {
isc_throw(ToElementError, "invalid DUID type: " << id_type);
}
// Set reservations (ip-addresses)
- IPv6ResrvRange na_resv = getIPv6Reservations(IPv6Resrv::TYPE_NA);
+ const IPv6ResrvRange& na_resv = getIPv6Reservations(IPv6Resrv::TYPE_NA);
ElementPtr resvs = Element::createList();
- for (IPv6ResrvIterator resv = na_resv.first;
- resv != na_resv.second; ++resv) {
- resvs->add(Element::create(resv->second.toText()));
+ BOOST_FOREACH(auto const& resv, na_resv) {
+ resvs->add(Element::create(resv.second.toText()));
}
map->set("ip-addresses", resvs);
// Set reservations (prefixes)
- IPv6ResrvRange pd_resv = getIPv6Reservations(IPv6Resrv::TYPE_PD);
+ const IPv6ResrvRange& pd_resv = getIPv6Reservations(IPv6Resrv::TYPE_PD);
resvs = Element::createList();
- for (IPv6ResrvIterator resv = pd_resv.first;
- resv != pd_resv.second; ++resv) {
- resvs->add(Element::create(resv->second.toText()));
+ BOOST_FOREACH(auto const& resv, pd_resv) {
+ resvs->add(Element::create(resv.second.toText()));
}
map->set("prefixes", resvs);
// Set the hostname
@@ -620,9 +617,8 @@ Host::toElement6() const {
// Set client-classes
const ClientClasses& cclasses = getClientClasses6();
ElementPtr classes = Element::createList();
- for (ClientClasses::const_iterator cclass = cclasses.cbegin();
- cclass != cclasses.cend(); ++cclass) {
- classes->add(Element::create(*cclass));
+ for (auto const& cclass : cclasses) {
+ classes->add(Element::create(cclass));
}
map->set("client-classes", classes);
@@ -683,33 +679,35 @@ Host::toText() const {
s << " key=" << (key_.toText().empty() ? "(empty)" : key_.toText());
+ size_t count = 0;
+
if (ipv6_reservations_.empty()) {
s << " ipv6_reservations=(none)";
} else {
// Add all IPv6 reservations.
- for (IPv6ResrvIterator resrv = ipv6_reservations_.begin();
- resrv != ipv6_reservations_.end(); ++resrv) {
+ count = 0;
+ for (auto const& resrv : ipv6_reservations_) {
s << " ipv6_reservation"
- << std::distance(ipv6_reservations_.begin(), resrv)
- << "=" << resrv->second.toText();
+ << count++
+ << "=" << resrv.second.toText();
}
}
// Add DHCPv4 client classes.
- for (ClientClasses::const_iterator cclass = dhcp4_client_classes_.cbegin();
- cclass != dhcp4_client_classes_.cend(); ++cclass) {
+ count = 0;
+ for (auto const& cclass : dhcp4_client_classes_) {
s << " dhcp4_class"
- << std::distance(dhcp4_client_classes_.cbegin(), cclass)
- << "=" << *cclass;
+ << count++
+ << "=" << cclass;
}
// Add DHCPv6 client classes.
- for (ClientClasses::const_iterator cclass = dhcp6_client_classes_.cbegin();
- cclass != dhcp6_client_classes_.cend(); ++cclass) {
+ count = 0;
+ for (auto const& cclass : dhcp6_client_classes_) {
s << " dhcp6_class"
- << std::distance(dhcp6_client_classes_.cbegin(), cclass)
- << "=" << *cclass;
+ << count++
+ << "=" << cclass;
}
// Add negative cached.
diff --git a/src/lib/dhcpsrv/host_data_source_factory.cc b/src/lib/dhcpsrv/host_data_source_factory.cc
index 374df12c3b..8ef36ef0e2 100644
--- a/src/lib/dhcpsrv/host_data_source_factory.cc
+++ b/src/lib/dhcpsrv/host_data_source_factory.cc
@@ -20,7 +20,6 @@
#endif
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <algorithm>
#include <iostream>
diff --git a/src/lib/dhcpsrv/host_mgr.cc b/src/lib/dhcpsrv/host_mgr.cc
index 47997a968d..397cea7dd1 100644
--- a/src/lib/dhcpsrv/host_mgr.cc
+++ b/src/lib/dhcpsrv/host_mgr.cc
@@ -751,7 +751,7 @@ HostMgr::getAll6(const IOAddress& address, const HostMgrOperationTarget target)
}
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
- for (auto const&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());
}
diff --git a/src/lib/dhcpsrv/lease_file_loader.h b/src/lib/dhcpsrv/lease_file_loader.h
index b4f724a5e7..d5663fda32 100644
--- a/src/lib/dhcpsrv/lease_file_loader.h
+++ b/src/lib/dhcpsrv/lease_file_loader.h
@@ -223,11 +223,9 @@ public:
lease_file.open();
// Iterate over the storage area writing out the leases
- for (typename StorageType::const_iterator lease = storage.begin();
- lease != storage.end();
- ++lease) {
+ for (auto const& lease : storage) {
try {
- lease_file.append(**lease);
+ lease_file.append(*lease);
} catch (const isc::Exception&) {
// Close the file
lease_file.close();
diff --git a/src/lib/dhcpsrv/lease_mgr.cc b/src/lib/dhcpsrv/lease_mgr.cc
index f56a749de4..36bb07d944 100644
--- a/src/lib/dhcpsrv/lease_mgr.cc
+++ b/src/lib/dhcpsrv/lease_mgr.cc
@@ -15,7 +15,6 @@
#include <stats/stats_mgr.h>
#include <util/encode/hex.h>
-#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
#include <algorithm>
@@ -106,9 +105,8 @@ LeaseMgr::recountLeaseStats4() {
const Subnet4Collection* subnets =
CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
- for (Subnet4Collection::const_iterator subnet = subnets->begin();
- subnet != subnets->end(); ++subnet) {
- SubnetID subnet_id = (*subnet)->getID();
+ for (auto const& subnet : *subnets) {
+ SubnetID subnet_id = subnet->getID();
stats_mgr.setValue(StatsMgr::generateName("subnet", subnet_id,
"assigned-addresses"),
zero);
@@ -129,7 +127,7 @@ LeaseMgr::recountLeaseStats4() {
stats_mgr.setValue(name_rec, zero);
}
- for (auto const& pool : (*subnet)->getPools(Lease::TYPE_V4)) {
+ for (auto const& pool : subnet->getPools(Lease::TYPE_V4)) {
const std::string name_aa(StatsMgr::generateName("subnet", subnet_id,
StatsMgr::generateName("pool", pool->getID(),
"assigned-addresses")));
@@ -320,9 +318,8 @@ LeaseMgr::recountLeaseStats6() {
const Subnet6Collection* subnets =
CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
- for (Subnet6Collection::const_iterator subnet = subnets->begin();
- subnet != subnets->end(); ++subnet) {
- SubnetID subnet_id = (*subnet)->getID();
+ for (auto const& subnet : *subnets) {
+ SubnetID subnet_id = subnet->getID();
stats_mgr.setValue(StatsMgr::generateName("subnet", subnet_id,
"assigned-nas"),
zero);
@@ -353,7 +350,7 @@ LeaseMgr::recountLeaseStats6() {
zero);
}
- for (auto const& pool : (*subnet)->getPools(Lease::TYPE_NA)) {
+ for (auto const& pool : subnet->getPools(Lease::TYPE_NA)) {
const std::string& name_anas(StatsMgr::generateName("subnet", subnet_id,
StatsMgr::generateName("pool", pool->getID(),
"assigned-nas")));
@@ -383,7 +380,7 @@ LeaseMgr::recountLeaseStats6() {
}
}
- for (auto const& pool : (*subnet)->getPools(Lease::TYPE_PD)) {
+ for (auto const& pool : subnet->getPools(Lease::TYPE_PD)) {
const std::string& name_apds(StatsMgr::generateName("subnet", subnet_id,
StatsMgr::generateName("pd-pool", pool->getID(),
"assigned-pds")));
diff --git a/src/lib/dhcpsrv/lease_mgr_factory.cc b/src/lib/dhcpsrv/lease_mgr_factory.cc
index e633916d89..9b71cc1d5b 100644
--- a/src/lib/dhcpsrv/lease_mgr_factory.cc
+++ b/src/lib/dhcpsrv/lease_mgr_factory.cc
@@ -17,7 +17,6 @@
#endif
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <algorithm>
#include <iostream>
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc
index df812f144a..b94fa0dc7d 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.cc
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc
@@ -20,6 +20,7 @@
#include <util/multi_threading_mgr.h>
#include <util/pid_file.h>
+#include <boost/foreach.hpp>
#include <cstdio>
#include <cstring>
#include <errno.h>
@@ -1168,8 +1169,8 @@ Memfile_LeaseMgr::getLease4Internal(const HWAddr& hwaddr,
Lease4StorageHWAddressSubnetIdIndex::const_iterator> l
= idx.equal_range(boost::make_tuple(hwaddr.hwaddr_));
- for (auto lease = l.first; lease != l.second; ++lease) {
- collection.push_back(Lease4Ptr(new Lease4(**lease)));
+ BOOST_FOREACH(auto const& lease, l) {
+ collection.push_back(Lease4Ptr(new Lease4(*lease)));
}
}
@@ -1233,8 +1234,8 @@ Memfile_LeaseMgr::getLease4Internal(const ClientId& client_id,
Lease4StorageClientIdSubnetIdIndex::const_iterator> l
= idx.equal_range(boost::make_tuple(client_id.getClientId()));
- for (auto lease = l.first; lease != l.second; ++lease) {
- collection.push_back(Lease4Ptr(new Lease4(**lease)));
+ BOOST_FOREACH(auto const& lease, l) {
+ collection.push_back(Lease4Ptr(new Lease4(*lease)));
}
}
@@ -1294,8 +1295,8 @@ Memfile_LeaseMgr::getLeases4Internal(SubnetID subnet_id,
Lease4StorageSubnetIdIndex::const_iterator> l =
idx.equal_range(subnet_id);
- for (auto lease = l.first; lease != l.second; ++lease) {
- collection.push_back(Lease4Ptr(new Lease4(**lease)));
+ BOOST_FOREACH(auto const& lease, l) {
+ collection.push_back(Lease4Ptr(new Lease4(*lease)));
}
}
@@ -1323,8 +1324,8 @@ Memfile_LeaseMgr::getLeases4Internal(const std::string& hostname,
Lease4StorageHostnameIndex::const_iterator> l =
idx.equal_range(hostname);
- for (auto lease = l.first; lease != l.second; ++lease) {
- collection.push_back(Lease4Ptr(new Lease4(**lease)));
+ BOOST_FOREACH(auto const& lease, l) {
+ collection.push_back(Lease4Ptr(new Lease4(*lease)));
}
}
@@ -1346,8 +1347,8 @@ Memfile_LeaseMgr::getLeases4(const std::string& hostname) const {
void
Memfile_LeaseMgr::getLeases4Internal(Lease4Collection& collection) const {
- for (auto lease = storage4_.begin(); lease != storage4_.end(); ++lease) {
- collection.push_back(Lease4Ptr(new Lease4(**lease)));
+ for (auto const& lease : storage4_) {
+ collection.push_back(Lease4Ptr(new Lease4(*lease)));
}
}
@@ -1540,8 +1541,8 @@ Memfile_LeaseMgr::getLeases6Internal(SubnetID subnet_id,
Lease6StorageSubnetIdIndex::const_iterator> l =
idx.equal_range(subnet_id);
- for (auto lease = l.first; lease != l.second; ++lease) {
- collection.push_back(Lease6Ptr(new Lease6(**lease)));
+ BOOST_FOREACH(auto const& lease, l) {
+ collection.push_back(Lease6Ptr(new Lease6(*lease)));
}
}
@@ -1569,8 +1570,8 @@ Memfile_LeaseMgr::getLeases6Internal(const std::string& hostname,
Lease6StorageHostnameIndex::const_iterator> l =
idx.equal_range(hostname);
- for (auto lease = l.first; lease != l.second; ++lease) {
- collection.push_back(Lease6Ptr(new Lease6(**lease)));
+ BOOST_FOREACH(auto const& lease, l) {
+ collection.push_back(Lease6Ptr(new Lease6(*lease)));
}
}
@@ -1592,8 +1593,8 @@ Memfile_LeaseMgr::getLeases6(const std::string& hostname) const {
void
Memfile_LeaseMgr::getLeases6Internal(Lease6Collection& collection) const {
- for (auto lease = storage6_.begin(); lease != storage6_.end(); ++lease) {
- collection.push_back(Lease6Ptr(new Lease6(**lease)));
+ for (auto const& lease : storage6_) {
+ collection.push_back(Lease6Ptr(new Lease6(*lease)));
}
}
@@ -1620,8 +1621,8 @@ Memfile_LeaseMgr::getLeases6Internal(const DUID& duid,
Lease6StorageDuidIndex::const_iterator> l =
idx.equal_range(duid.getDuid());
- for (auto lease = l.first; lease != l.second; ++lease) {
- collection.push_back(Lease6Ptr(new Lease6(**lease)));
+ BOOST_FOREACH(auto const& lease, l) {
+ collection.push_back(Lease6Ptr(new Lease6(*lease)));
}
}
@@ -2589,13 +2590,13 @@ Memfile_LeaseMgr::wipeLeases4(const SubnetID& subnet_id) {
// Let's collect all leases.
Lease4Collection leases;
- for (auto lease = l.first; lease != l.second; ++lease) {
- leases.push_back(*lease);
+ BOOST_FOREACH(auto const& lease, l) {
+ leases.push_back(lease);
}
size_t num = leases.size();
- for (auto l = leases.begin(); l != leases.end(); ++l) {
- deleteLease(*l);
+ for (auto const& l : leases) {
+ deleteLease(l);
}
LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_WIPE_LEASES4_FINISHED)
.arg(subnet_id).arg(num);
@@ -2618,13 +2619,13 @@ Memfile_LeaseMgr::wipeLeases6(const SubnetID& subnet_id) {
// Let's collect all leases.
Lease6Collection leases;
- for (auto lease = l.first; lease != l.second; ++lease) {
- leases.push_back(*lease);
+ BOOST_FOREACH(auto const& lease, l) {
+ leases.push_back(lease);
}
size_t num = leases.size();
- for (auto l = leases.begin(); l != leases.end(); ++l) {
- deleteLease(*l);
+ for (auto const& l : leases) {
+ deleteLease(l);
}
LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_WIPE_LEASES6_FINISHED)
.arg(subnet_id).arg(num);
@@ -2635,10 +2636,10 @@ Memfile_LeaseMgr::wipeLeases6(const SubnetID& subnet_id) {
void
Memfile_LeaseMgr::recountClassLeases4() {
class_lease_counter_.clear();
- for (auto lease = storage4_.begin(); lease != storage4_.end(); ++lease) {
+ for (auto const& lease : storage4_) {
// Bump the appropriate accumulator
- if ((*lease)->state_ == Lease::STATE_DEFAULT) {
- class_lease_counter_.addLease(*lease);
+ if (lease->state_ == Lease::STATE_DEFAULT) {
+ class_lease_counter_.addLease(lease);
}
}
}
@@ -2646,10 +2647,10 @@ Memfile_LeaseMgr::recountClassLeases4() {
void
Memfile_LeaseMgr::recountClassLeases6() {
class_lease_counter_.clear();
- for (auto lease = storage6_.begin(); lease != storage6_.end(); ++lease) {
+ for (auto const& lease : storage6_) {
// Bump the appropriate accumulator
- if ((*lease)->state_ == Lease::STATE_DEFAULT) {
- class_lease_counter_.addLease(*lease);
+ if (lease->state_ == Lease::STATE_DEFAULT) {
+ class_lease_counter_.addLease(lease);
}
}
}
@@ -2899,13 +2900,12 @@ idToText(const OptionBuffer& id) {
std::stringstream tmp;
tmp << std::hex;
bool delim = false;
- for (std::vector<uint8_t>::const_iterator it = id.begin();
- it != id.end(); ++it) {
+ for (auto const& it : id) {
if (delim) {
tmp << ":";
}
tmp << std::setw(2) << std::setfill('0')
- << static_cast<unsigned int>(*it);
+ << static_cast<unsigned int>(it);
delim = true;
}
return (tmp.str());
@@ -3058,21 +3058,21 @@ Memfile_LeaseMgr::getLeases4ByRemoteIdInternal(const OptionBuffer& remote_id,
const Lease4StorageRemoteIdIndex& idx = storage4_.get<RemoteIdIndexTag>();
Lease4StorageRemoteIdRange er = idx.equal_range(remote_id);
// Store all convenient leases being within the page size.
- for (auto it = er.first; it != er.second; ++it) {
- const IOAddress& addr = (*it)->addr_;
+ BOOST_FOREACH(auto const& it, er) {
+ const IOAddress& addr = it->addr_;
if (addr <= lower_bound_address) {
// Not greater than lower_bound_address.
continue;
}
- if ((qry_start_time > 0) && ((*it)->cltt_ < qry_start_time)) {
+ if ((qry_start_time > 0) && (it->cltt_ < qry_start_time)) {
// Too old.
continue;
}
- if ((qry_end_time > 0) && ((*it)->cltt_ > qry_end_time)) {
+ if ((qry_end_time > 0) && (it->cltt_ > qry_end_time)) {
// Too young.
continue;
}
- sorted[addr] = *it;
+ sorted[addr] = it;
}
// Return all leases being within the page size.
@@ -3207,8 +3207,8 @@ Memfile_LeaseMgr::getLeases6ByRemoteIdInternal(const OptionBuffer& remote_id,
const RemoteIdIndex& idx = remote_id6_.get<RemoteIdIndexTag>();
RemoteIdIndexRange er = idx.equal_range(remote_id);
// Store all addresses greater than lower_bound_address.
- for (auto it = er.first; it != er.second; ++it) {
- const IOAddress& addr = (*it)->lease_addr_;
+ BOOST_FOREACH(auto const& it, er) {
+ const IOAddress& addr = it->lease_addr_;
if (addr <= lower_bound_address) {
continue;
}
diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc
index 8a84817b59..5b76e1645e 100644
--- a/src/lib/dhcpsrv/mysql_host_data_source.cc
+++ b/src/lib/dhcpsrv/mysql_host_data_source.cc
@@ -26,6 +26,7 @@
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/array.hpp>
+#include <boost/foreach.hpp>
#include <boost/pointer_cast.hpp>
#include <boost/static_assert.hpp>
@@ -3140,11 +3141,11 @@ MySqlHostDataSourceImpl::addOptions(MySqlHostContextPtr& ctx,
// For each option space retrieve all options and insert them into the
// database.
- for (auto space = option_spaces.begin(); space != option_spaces.end(); ++space) {
- OptionContainerPtr options = options_cfg->getAllCombined(*space);
+ for (auto const& space : option_spaces) {
+ OptionContainerPtr options = options_cfg->getAllCombined(space);
if (options && !options->empty()) {
- for (auto opt = options->begin(); opt != options->end(); ++opt) {
- addOption(ctx, stindex, *opt, *space, Optional<SubnetID>(), host_id);
+ for (auto const& opt : *options) {
+ addOption(ctx, stindex, opt, space, Optional<SubnetID>(), host_id);
}
}
}
@@ -3336,9 +3337,8 @@ MySqlHostDataSource::add(const HostPtr& host) {
// Insert IPv6 reservations.
IPv6ResrvRange v6resv = host->getIPv6Reservations();
if (std::distance(v6resv.first, v6resv.second) > 0) {
- for (IPv6ResrvIterator resv = v6resv.first; resv != v6resv.second;
- ++resv) {
- impl_->addResv(ctx, resv->second, host_id);
+ BOOST_FOREACH(auto const& resv, v6resv) {
+ impl_->addResv(ctx, resv.second, host_id);
}
}
diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc
index 1b71d52c57..270ea8468b 100644
--- a/src/lib/dhcpsrv/mysql_lease_mgr.cc
+++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc
@@ -4077,13 +4077,12 @@ idToText(const OptionBuffer& id) {
std::stringstream tmp;
tmp << std::hex;
bool delim = false;
- for (std::vector<uint8_t>::const_iterator it = id.begin();
- it != id.end(); ++it) {
+ for (auto const& it : id) {
if (delim) {
tmp << ":";
}
tmp << std::setw(2) << std::setfill('0')
- << static_cast<unsigned int>(*it);
+ << static_cast<unsigned int>(it);
delim = true;
}
return (tmp.str());
diff --git a/src/lib/dhcpsrv/network.cc b/src/lib/dhcpsrv/network.cc
index 14770d5658..211caa0352 100644
--- a/src/lib/dhcpsrv/network.cc
+++ b/src/lib/dhcpsrv/network.cc
@@ -128,8 +128,8 @@ Network::toElement() const {
ElementPtr relay_map = Element::createMap();
ElementPtr address_list = Element::createList();
const IOAddressList addresses = getRelayAddresses();
- for (auto address = addresses.begin(); address != addresses.end(); ++address) {
- address_list->add(Element::create((*address).toText()));
+ for (auto const& address : addresses) {
+ address_list->add(Element::create(address.toText()));
}
relay_map->set("ip-addresses", address_list);
@@ -144,9 +144,8 @@ Network::toElement() const {
const ClientClasses& classes = getRequiredClasses();
if (!classes.empty()) {
ElementPtr class_list = Element::createList();
- for (ClientClasses::const_iterator it = classes.cbegin();
- it != classes.cend(); ++it) {
- class_list->add(Element::create(*it));
+ for (auto const& it : classes) {
+ class_list->add(Element::create(it));
}
map->set("require-client-classes", class_list);
}
diff --git a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc
index 0d04293f05..dc6a7aa938 100644
--- a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc
+++ b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc
@@ -16,7 +16,6 @@
#include <asiolink/io_address.h>
#include <asiolink/io_error.h>
-#include <boost/foreach.hpp>
#include <algorithm>
#include <sstream>
@@ -131,7 +130,7 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary,
SimpleParser6::OPTION6_DEF_DEFAULTS);
OptionDefParser parser(family);
- BOOST_FOREACH(ConstElementPtr option_def, option_defs->listValue()) {
+ for (auto const& option_def : option_defs->listValue()) {
OptionDefinitionPtr def = parser.parse(option_def);
// Verify if the definition is for an option which is in a deferred
@@ -346,8 +345,7 @@ ClientClassDictionaryPtr
ClientClassDefListParser::parse(ConstElementPtr client_class_def_list,
uint16_t family, bool check_dependencies) {
ClientClassDictionaryPtr dictionary(new ClientClassDictionary());
- BOOST_FOREACH(ConstElementPtr client_class_def,
- client_class_def_list->listValue()) {
+ for (auto const& client_class_def : client_class_def_list->listValue()) {
ClientClassDefParser parser;
parser.parse(dictionary, client_class_def, family, true, check_dependencies);
}
diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc
index c064227362..e7fc071692 100644
--- a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc
+++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc
@@ -52,7 +52,7 @@ MACSourcesListConfigParser::parse(CfgMACSource& mac_sources, ConstElementPtr val
// If user specified anything, we need to get rid of that default.
mac_sources.clear();
- BOOST_FOREACH(ConstElementPtr source_elem, value->listValue()) {
+ for (auto const& source_elem : value->listValue()) {
std::string source_str = source_elem->stringValue();
try {
source = CfgMACSource::MACSourceFromText(source_str);
@@ -204,11 +204,11 @@ OptionDefParser::parse(ConstElementPtr option_def) {
isc::util::str::tokens(record_types, ",");
// Iterate over each token and add a record type into
// option definition.
- BOOST_FOREACH(std::string record_type, record_tokens) {
+ for (auto const& record_type : record_tokens) {
try {
- boost::trim(record_type);
- if (!record_type.empty()) {
- def->addRecordField(record_type);
+ auto const trim_rec = boost::trim_copy(record_type);
+ if (!trim_rec.empty()) {
+ def->addRecordField(trim_rec);
}
} catch (const Exception& ex) {
isc_throw(DhcpConfigError, "invalid record type values"
@@ -246,7 +246,7 @@ OptionDefListParser::parse(CfgOptionDefPtr storage, ConstElementPtr option_def_l
}
OptionDefParser parser(address_family_);
- BOOST_FOREACH(ConstElementPtr option_def, option_def_list->listValue()) {
+ for (auto const& option_def : option_def_list->listValue()) {
OptionDefinitionPtr def = parser.parse(option_def);
try {
storage->add(def);
@@ -304,7 +304,7 @@ RelayInfoParser::parse(const isc::dhcp::Network::RelayInfoPtr& relay_info,
"(" << getPosition("ip-addresses", relay_elem) << ")");
}
- BOOST_FOREACH(ConstElementPtr address_element, addresses->listValue()) {
+ for (auto const& address_element : addresses->listValue()) {
addAddress("ip-addresses", address_element->stringValue(),
relay_elem, relay_info);
}
@@ -505,22 +505,20 @@ PoolParser::parse(PoolStoragePtr pools,
ConstElementPtr class_list = pool_structure->get("require-client-classes");
if (class_list) {
const std::vector<data::ElementPtr>& classes = class_list->listValue();
- for (auto cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- if (((*cclass)->getType() != Element::string) ||
- (*cclass)->stringValue().empty()) {
+ for (auto const& cclass : classes) {
+ if ((cclass->getType() != Element::string) ||
+ cclass->stringValue().empty()) {
isc_throw(DhcpConfigError, "invalid class name ("
- << (*cclass)->getPosition() << ")");
+ << cclass->getPosition() << ")");
}
- pool->requireClientClass((*cclass)->stringValue());
+ pool->requireClientClass(cclass->stringValue());
}
}
}
boost::shared_ptr<OptionDataListParser>
PoolParser::createOptionDataListParser(const uint16_t address_family) const {
- auto parser = boost::make_shared<OptionDataListParser>(address_family);
- return (parser);
+ return (boost::make_shared<OptionDataListParser>(address_family));
}
//****************************** Pool4Parser *************************
@@ -540,16 +538,15 @@ Pool4Parser::poolMaker (IOAddress &min, IOAddress &max, int32_t) {
void
Pools4ListParser::parse(PoolStoragePtr pools, ConstElementPtr pools_list,
bool encapsulate_options) {
- BOOST_FOREACH(ConstElementPtr pool, pools_list->listValue()) {
- auto parser = createPoolConfigParser();
+ for (auto const& pool : pools_list->listValue()) {
+ auto const& parser = createPoolConfigParser();
parser->parse(pools, pool, AF_INET, encapsulate_options);
}
}
boost::shared_ptr<PoolParser>
Pools4ListParser::createPoolConfigParser() const {
- auto parser = boost::make_shared<Pool4Parser>();
- return (parser);
+ return (boost::make_shared<Pool4Parser>());
}
//****************************** SubnetConfigParser *************************
@@ -682,8 +679,7 @@ SubnetConfigParser::createSubnet(ConstElementPtr params) {
boost::shared_ptr<OptionDataListParser>
SubnetConfigParser::createOptionDataListParser() const {
- auto parser = boost::make_shared<OptionDataListParser>(address_family_);
- return (parser);
+ return (boost::make_shared<OptionDataListParser>(address_family_));
}
//****************************** Subnet4ConfigParser *************************
@@ -700,7 +696,7 @@ Subnet4ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
/// Parse Pools first.
ConstElementPtr pools = subnet->get("pools");
if (pools) {
- auto parser = createPoolsListParser();
+ auto const& parser = createPoolsListParser();
parser->parse(pools_, pools, encapsulate_options);
}
@@ -731,9 +727,9 @@ Subnet4ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
HostCollection hosts;
HostReservationsListParser<HostReservationParser4> parser;
parser.parse(subnet_->getID(), reservations, hosts);
- for (auto h = hosts.begin(); h != hosts.end(); ++h) {
- validateResv(sn4ptr, *h);
- CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+ for (auto const& h : hosts) {
+ validateResv(sn4ptr, h);
+ CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
}
}
@@ -890,14 +886,13 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params,
ConstElementPtr class_list = params->get("require-client-classes");
if (class_list) {
const std::vector<data::ElementPtr>& classes = class_list->listValue();
- for (auto cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- if (((*cclass)->getType() != Element::string) ||
- (*cclass)->stringValue().empty()) {
+ for (auto const& cclass : classes) {
+ if ((cclass->getType() != Element::string) ||
+ cclass->stringValue().empty()) {
isc_throw(DhcpConfigError, "invalid class name ("
- << (*cclass)->getPosition() << ")");
+ << cclass->getPosition() << ")");
}
- subnet4->requireClientClass((*cclass)->stringValue());
+ subnet4->requireClientClass(cclass->stringValue());
}
}
@@ -985,8 +980,7 @@ Subnet4ConfigParser::validateResv(const Subnet4Ptr& subnet, ConstHostPtr host) {
boost::shared_ptr<PoolsListParser>
Subnet4ConfigParser::createPoolsListParser() const {
- auto parser = boost::make_shared<Pools4ListParser>();
- return (parser);
+ return (boost::make_shared<Pools4ListParser>());
}
//**************************** Subnets4ListConfigParser **********************
@@ -1000,9 +994,9 @@ Subnets4ListConfigParser::parse(SrvConfigPtr cfg,
ConstElementPtr subnets_list,
bool encapsulate_options) {
size_t cnt = 0;
- BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
+ for (auto const& subnet_json : subnets_list->listValue()) {
- auto parser = createSubnetConfigParser();
+ auto const& parser = createSubnetConfigParser();
Subnet4Ptr subnet = parser->parse(subnet_json, encapsulate_options);
if (subnet) {
@@ -1026,9 +1020,9 @@ Subnets4ListConfigParser::parse(Subnet4Collection& subnets,
data::ConstElementPtr subnets_list,
bool encapsulate_options) {
size_t cnt = 0;
- BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
+ for (auto const& subnet_json : subnets_list->listValue()) {
- auto parser = createSubnetConfigParser();
+ auto const& parser = createSubnetConfigParser();
Subnet4Ptr subnet = parser->parse(subnet_json, encapsulate_options);
if (subnet) {
try {
@@ -1049,8 +1043,7 @@ Subnets4ListConfigParser::parse(Subnet4Collection& subnets,
boost::shared_ptr<Subnet4ConfigParser>
Subnets4ListConfigParser::createSubnetConfigParser() const {
- auto parser = boost::make_shared<Subnet4ConfigParser>(check_iface_);
- return (parser);
+ return (boost::make_shared<Subnet4ConfigParser>(check_iface_));
}
//**************************** Pool6Parser *********************************
@@ -1075,16 +1068,15 @@ Pool6Parser::poolMaker(IOAddress &min, IOAddress &max, int32_t ptype)
void
Pools6ListParser::parse(PoolStoragePtr pools, ConstElementPtr pools_list,
bool encapsulate_options) {
- BOOST_FOREACH(ConstElementPtr pool, pools_list->listValue()) {
- auto parser = createPoolConfigParser();
+ for (auto const& pool : pools_list->listValue()) {
+ auto const& parser = createPoolConfigParser();
parser->parse(pools, pool, AF_INET6, encapsulate_options);
}
}
boost::shared_ptr<PoolParser>
Pools6ListParser::createPoolConfigParser() const {
- auto parser = boost::make_shared<Pool6Parser>();
- return (parser);
+ return (boost::make_shared<Pool6Parser>());
}
//**************************** PdPoolParser ******************************
@@ -1167,14 +1159,13 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_,
if (class_list) {
const std::vector<data::ElementPtr>& classes = class_list->listValue();
- for (auto cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- if (((*cclass)->getType() != Element::string) ||
- (*cclass)->stringValue().empty()) {
+ for (auto const& cclass : classes) {
+ if ((cclass->getType() != Element::string) ||
+ cclass->stringValue().empty()) {
isc_throw(DhcpConfigError, "invalid class name ("
- << (*cclass)->getPosition() << ")");
+ << cclass->getPosition() << ")");
}
- pool_->requireClientClass((*cclass)->stringValue());
+ pool_->requireClientClass(cclass->stringValue());
}
}
@@ -1184,8 +1175,7 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_,
boost::shared_ptr<OptionDataListParser>
PdPoolParser::createOptionDataListParser() const {
- auto parser = boost::make_shared<OptionDataListParser>(AF_INET6);
- return (parser);
+ return (boost::make_shared<OptionDataListParser>(AF_INET6));
}
//**************************** PdPoolsListParser ************************
@@ -1193,16 +1183,15 @@ PdPoolParser::createOptionDataListParser() const {
void
PdPoolsListParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_list) {
// Loop through the list of pd pools.
- BOOST_FOREACH(ConstElementPtr pd_pool, pd_pool_list->listValue()) {
- auto parser = createPdPoolConfigParser();
+ for (auto const& pd_pool : pd_pool_list->listValue()) {
+ auto const& parser = createPdPoolConfigParser();
parser->parse(pools, pd_pool);
}
}
boost::shared_ptr<PdPoolParser>
PdPoolsListParser::createPdPoolConfigParser() const {
- auto parser = boost::make_shared<PdPoolParser>();
- return (parser);
+ return (boost::make_shared<PdPoolParser>());
}
//**************************** Subnet6ConfigParser ***********************
@@ -1219,12 +1208,12 @@ Subnet6ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
/// Parse all pools first.
ConstElementPtr pools = subnet->get("pools");
if (pools) {
- auto parser = createPoolsListParser();
+ auto const& parser = createPoolsListParser();
parser->parse(pools_, pools, encapsulate_options);
}
ConstElementPtr pd_pools = subnet->get("pd-pools");
if (pd_pools) {
- auto parser = createPdPoolsListParser();
+ auto const& parser = createPdPoolsListParser();
parser->parse(pools_, pd_pools);
}
@@ -1255,9 +1244,9 @@ Subnet6ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
HostCollection hosts;
HostReservationsListParser<HostReservationParser6> parser;
parser.parse(subnet_->getID(), reservations, hosts);
- for (auto h = hosts.begin(); h != hosts.end(); ++h) {
- validateResvs(sn6ptr, *h);
- CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+ for (auto const& h : hosts) {
+ validateResvs(sn6ptr, h);
+ CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
}
}
@@ -1417,14 +1406,13 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params,
ConstElementPtr class_list = params->get("require-client-classes");
if (class_list) {
const std::vector<data::ElementPtr>& classes = class_list->listValue();
- for (auto cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- if (((*cclass)->getType() != Element::string) ||
- (*cclass)->stringValue().empty()) {
+ for (auto const& cclass : classes) {
+ if ((cclass->getType() != Element::string) ||
+ cclass->stringValue().empty()) {
isc_throw(DhcpConfigError, "invalid class name ("
- << (*cclass)->getPosition() << ")");
+ << cclass->getPosition() << ")");
}
- subnet6->requireClientClass((*cclass)->stringValue());
+ subnet6->requireClientClass(cclass->stringValue());
}
}
}
@@ -1444,9 +1432,9 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params,
void
Subnet6ConfigParser::validateResvs(const Subnet6Ptr& subnet, ConstHostPtr host) {
- IPv6ResrvRange range = host->getIPv6Reservations(IPv6Resrv::TYPE_NA);
- for (auto it = range.first; it != range.second; ++it) {
- const IOAddress& address = it->second.getPrefix();
+ const IPv6ResrvRange& range = host->getIPv6Reservations(IPv6Resrv::TYPE_NA);
+ BOOST_FOREACH(auto const& it, range) {
+ const IOAddress& address = it.second.getPrefix();
if (!subnet->inRange(address)) {
isc_throw(DhcpConfigError, "specified reservation '" << address
<< "' is not within the IPv6 subnet '"
@@ -1457,14 +1445,12 @@ Subnet6ConfigParser::validateResvs(const Subnet6Ptr& subnet, ConstHostPtr host)
boost::shared_ptr<PoolsListParser>
Subnet6ConfigParser::createPoolsListParser() const {
- auto parser = boost::make_shared<Pools6ListParser>();
- return (parser);
+ return (boost::make_shared<Pools6ListParser>());
}
boost::shared_ptr<PdPoolsListParser>
Subnet6ConfigParser::createPdPoolsListParser() const {
- auto parser = boost::make_shared<PdPoolsListParser>();
- return (parser);
+ return (boost::make_shared<PdPoolsListParser>());
}
//**************************** Subnet6ListConfigParser ********************
@@ -1478,9 +1464,9 @@ Subnets6ListConfigParser::parse(SrvConfigPtr cfg,
ConstElementPtr subnets_list,
bool encapsulate_options) {
size_t cnt = 0;
- BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
+ for (auto const& subnet_json : subnets_list->listValue()) {
- auto parser = createSubnetConfigParser();
+ auto const& parser = createSubnetConfigParser();
Subnet6Ptr subnet = parser->parse(subnet_json, encapsulate_options);
// Adding a subnet to the Configuration Manager may fail if the
@@ -1502,9 +1488,9 @@ Subnets6ListConfigParser::parse(Subnet6Collection& subnets,
ConstElementPtr subnets_list,
bool encapsulate_options) {
size_t cnt = 0;
- BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
+ for (auto const& subnet_json : subnets_list->listValue()) {
- auto parser = createSubnetConfigParser();
+ auto const& parser = createSubnetConfigParser();
Subnet6Ptr subnet = parser->parse(subnet_json, encapsulate_options);
if (subnet) {
try {
@@ -1525,8 +1511,7 @@ Subnets6ListConfigParser::parse(Subnet6Collection& subnets,
boost::shared_ptr<Subnet6ConfigParser>
Subnets6ListConfigParser::createSubnetConfigParser() const {
- auto parser = boost::make_shared<Subnet6ConfigParser>(check_iface_);
- return (parser);
+ return (boost::make_shared<Subnet6ConfigParser>(check_iface_));
}
//**************************** D2ClientConfigParser **********************
diff --git a/src/lib/dhcpsrv/parsers/dhcp_queue_control_parser.cc b/src/lib/dhcpsrv/parsers/dhcp_queue_control_parser.cc
index e3bca0fff2..e9b4e1bd5b 100644
--- a/src/lib/dhcpsrv/parsers/dhcp_queue_control_parser.cc
+++ b/src/lib/dhcpsrv/parsers/dhcp_queue_control_parser.cc
@@ -10,7 +10,6 @@
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/parsers/dhcp_queue_control_parser.h>
#include <util/multi_threading_mgr.h>
-#include <boost/foreach.hpp>
#include <string>
#include <sys/types.h>
diff --git a/src/lib/dhcpsrv/parsers/duid_config_parser.cc b/src/lib/dhcpsrv/parsers/duid_config_parser.cc
index 937a542c0d..7082e04901 100644
--- a/src/lib/dhcpsrv/parsers/duid_config_parser.cc
+++ b/src/lib/dhcpsrv/parsers/duid_config_parser.cc
@@ -13,7 +13,6 @@
#include <dhcpsrv/parsers/duid_config_parser.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <exceptions/exceptions.h>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <string>
diff --git a/src/lib/dhcpsrv/parsers/expiration_config_parser.cc b/src/lib/dhcpsrv/parsers/expiration_config_parser.cc
index 3bbe333860..52d9740e86 100644
--- a/src/lib/dhcpsrv/parsers/expiration_config_parser.cc
+++ b/src/lib/dhcpsrv/parsers/expiration_config_parser.cc
@@ -11,7 +11,6 @@
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/parsers/expiration_config_parser.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
-#include <boost/foreach.hpp>
using namespace isc::data;
diff --git a/src/lib/dhcpsrv/parsers/host_reservation_parser.cc b/src/lib/dhcpsrv/parsers/host_reservation_parser.cc
index ed89b3b5f2..f71fe9c9d2 100644
--- a/src/lib/dhcpsrv/parsers/host_reservation_parser.cc
+++ b/src/lib/dhcpsrv/parsers/host_reservation_parser.cc
@@ -10,7 +10,6 @@
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/parsers/host_reservation_parser.h>
#include <dhcpsrv/parsers/option_data_parser.h>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <algorithm>
#include <sys/socket.h>
@@ -119,7 +118,7 @@ HostReservationParser::parseInternal(const SubnetID&,
try {
// Gather those parameters that are common for both IPv4 and IPv6
// reservations.
- BOOST_FOREACH(auto const& element, reservation_data->mapValue()) {
+ for (auto const& element : reservation_data->mapValue()) {
// Check if we support this parameter.
if (!isSupportedParameter(element.first)) {
isc_throw(DhcpConfigError, "unsupported configuration"
@@ -148,7 +147,7 @@ HostReservationParser::parseInternal(const SubnetID&,
// error message and include the information what identifiers
// are supported.
std::ostringstream s;
- BOOST_FOREACH(std::string param_name, getSupportedParameters(true)) {
+ for (auto const& param_name : getSupportedParameters(true)) {
if (s.tellp() != std::streampos(0)) {
s << ", ";
}
@@ -196,7 +195,7 @@ HostReservationParser4::parseInternal(const SubnetID& subnet_id,
host->setIPv4SubnetID(subnet_id);
- BOOST_FOREACH(auto const& element, reservation_data->mapValue()) {
+ for (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.
@@ -209,8 +208,8 @@ HostReservationParser4::parseInternal(const SubnetID& subnet_id,
OptionDataListParser parser(AF_INET);
parser.parse(cfg_option, element.second, encapsulate_options);
- // Everything else should be surrounded with try-catch to append
- // position.
+ // Everything else should be surrounded with try-catch to append
+ // position.
} else {
try {
if (element.first == "ip-address") {
@@ -226,8 +225,7 @@ HostReservationParser4::parseInternal(const SubnetID& subnet_id,
host->setBootFileName(element.second->stringValue());
} else if (element.first == "client-classes") {
- BOOST_FOREACH(ConstElementPtr class_element,
- element.second->listValue()) {
+ for (auto const& class_element : element.second->listValue()) {
host->addClientClass4(class_element->stringValue());
}
}
@@ -257,7 +255,7 @@ HostReservationParser6::parseInternal(const SubnetID& subnet_id,
host->setIPv6SubnetID(subnet_id);
- BOOST_FOREACH(auto const& element, reservation_data->mapValue()) {
+ for (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
@@ -272,8 +270,7 @@ HostReservationParser6::parseInternal(const SubnetID& subnet_id,
parser.parse(cfg_option, element.second, encapsulate_options);
} else if (element.first == "ip-addresses" || element.first == "prefixes") {
- BOOST_FOREACH(ConstElementPtr prefix_element,
- element.second->listValue()) {
+ for (auto const& prefix_element : element.second->listValue()) {
try {
// For the IPv6 address the prefix length is 128 and the
// value specified in the list is a reserved address.
@@ -351,8 +348,7 @@ HostReservationParser6::parseInternal(const SubnetID& subnet_id,
} else if (element.first == "client-classes") {
try {
- BOOST_FOREACH(ConstElementPtr class_element,
- element.second->listValue()) {
+ for (auto const& class_element : element.second->listValue()) {
host->addClientClass6(class_element->stringValue());
}
} catch (const std::exception& ex) {
@@ -385,7 +381,7 @@ HostReservationIdsParser::parseInternal(isc::data::ConstElementPtr ids_list) {
// Remove existing identifier types.
staging_cfg_->clearIdentifierTypes();
- BOOST_FOREACH(ConstElementPtr element, ids_list->listValue()) {
+ for (auto const& element : ids_list->listValue()) {
std::string id_name = element->stringValue();
try {
if (id_name != "auto") {
diff --git a/src/lib/dhcpsrv/parsers/host_reservations_list_parser.h b/src/lib/dhcpsrv/parsers/host_reservations_list_parser.h
index 9f6ce2f68f..fd857055e1 100644
--- a/src/lib/dhcpsrv/parsers/host_reservations_list_parser.h
+++ b/src/lib/dhcpsrv/parsers/host_reservations_list_parser.h
@@ -11,7 +11,6 @@
#include <cc/simple_parser.h>
#include <dhcpsrv/host.h>
#include <dhcpsrv/subnet_id.h>
-#include <boost/foreach.hpp>
namespace isc {
namespace dhcp {
@@ -39,7 +38,7 @@ public:
void parse(const SubnetID& subnet_id, isc::data::ConstElementPtr hr_list,
HostCollection& hosts_list) {
HostCollection hosts;
- BOOST_FOREACH(data::ConstElementPtr reservation, hr_list->listValue()) {
+ for (auto const& reservation : hr_list->listValue()) {
HostReservationParserType parser;
hosts.push_back(parser.parse(subnet_id, reservation));
}
diff --git a/src/lib/dhcpsrv/parsers/ifaces_config_parser.cc b/src/lib/dhcpsrv/parsers/ifaces_config_parser.cc
index c375b403c2..fee4484a65 100644
--- a/src/lib/dhcpsrv/parsers/ifaces_config_parser.cc
+++ b/src/lib/dhcpsrv/parsers/ifaces_config_parser.cc
@@ -9,7 +9,6 @@
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/parsers/ifaces_config_parser.h>
-#include <boost/foreach.hpp>
#include <string>
#include <sys/types.h>
@@ -21,7 +20,7 @@ namespace dhcp {
void
IfacesConfigParser::parseInterfacesList(const CfgIfacePtr& cfg_iface,
ConstElementPtr ifaces_list) {
- BOOST_FOREACH(ConstElementPtr iface, ifaces_list->listValue()) {
+ for (auto const& iface : ifaces_list->listValue()) {
std::string iface_name = iface->stringValue();
try {
cfg_iface->use(protocol_, iface_name);
@@ -50,7 +49,7 @@ IfacesConfigParser::parse(const CfgIfacePtr& cfg,
}
bool socket_type_specified = false;
- BOOST_FOREACH(ConfigPair element, ifaces_config->mapValue()) {
+ for (auto const& element : ifaces_config->mapValue()) {
try {
if (element.first == "re-detect") {
continue;
diff --git a/src/lib/dhcpsrv/parsers/option_data_parser.cc b/src/lib/dhcpsrv/parsers/option_data_parser.cc
index 6a321cde6d..87d98d92b1 100644
--- a/src/lib/dhcpsrv/parsers/option_data_parser.cc
+++ b/src/lib/dhcpsrv/parsers/option_data_parser.cc
@@ -17,7 +17,6 @@
#include <dhcpsrv/parsers/simple_parser6.h>
#include <util/encode/hex.h>
#include <util/strutil.h>
-#include <boost/foreach.hpp>
#include <boost/make_shared.hpp>
#include <limits>
#include <vector>
@@ -458,7 +457,7 @@ void OptionDataListParser::parse(const CfgOptionPtr& cfg,
isc::data::ConstElementPtr option_data_list,
bool encapsulate) {
auto option_parser = createOptionDataParser();
- BOOST_FOREACH(ConstElementPtr data, option_data_list->listValue()) {
+ for (auto const& data : option_data_list->listValue()) {
std::pair<OptionDescriptor, std::string> option =
option_parser->parse(data);
// Use the option description to keep the formatted value
diff --git a/src/lib/dhcpsrv/parsers/shared_network_parser.cc b/src/lib/dhcpsrv/parsers/shared_network_parser.cc
index ef9cc1dc00..ed196f4bfa 100644
--- a/src/lib/dhcpsrv/parsers/shared_network_parser.cc
+++ b/src/lib/dhcpsrv/parsers/shared_network_parser.cc
@@ -88,9 +88,8 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data,
parser->parse(subnets, json);
// Add all returned subnets into shared network.
- for (auto subnet = subnets.cbegin(); subnet != subnets.cend();
- ++subnet) {
- shared_network->add(*subnet);
+ for (auto const& subnet : subnets) {
+ shared_network->add(subnet);
}
}
@@ -170,14 +169,13 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data,
if (shared_network_data->contains("require-client-classes")) {
const std::vector<data::ElementPtr>& class_list =
shared_network_data->get("require-client-classes")->listValue();
- for (auto cclass = class_list.cbegin();
- cclass != class_list.cend(); ++cclass) {
- if (((*cclass)->getType() != Element::string) ||
- (*cclass)->stringValue().empty()) {
+ for (auto const& cclass : class_list) {
+ if ((cclass->getType() != Element::string) ||
+ cclass->stringValue().empty()) {
isc_throw(DhcpConfigError, "invalid class name ("
- << (*cclass)->getPosition() << ")");
+ << cclass->getPosition() << ")");
}
- shared_network->requireClientClass((*cclass)->stringValue());
+ shared_network->requireClientClass(cclass->stringValue());
}
}
@@ -344,14 +342,13 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data,
if (shared_network_data->contains("require-client-classes")) {
const std::vector<data::ElementPtr>& class_list =
shared_network_data->get("require-client-classes")->listValue();
- for (auto cclass = class_list.cbegin();
- cclass != class_list.cend(); ++cclass) {
- if (((*cclass)->getType() != Element::string) ||
- (*cclass)->stringValue().empty()) {
+ for (auto const& cclass : class_list) {
+ if ((cclass->getType() != Element::string) ||
+ cclass->stringValue().empty()) {
isc_throw(DhcpConfigError, "invalid class name ("
- << (*cclass)->getPosition() << ")");
+ << cclass->getPosition() << ")");
}
- shared_network->requireClientClass((*cclass)->stringValue());
+ shared_network->requireClientClass(cclass->stringValue());
}
}
@@ -364,9 +361,8 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data,
parser->parse(subnets, json);
// Add all returned subnets into shared network.
- for (auto subnet = subnets.cbegin(); subnet != subnets.cend();
- ++subnet) {
- shared_network->add(*subnet);
+ for (auto const& subnet : subnets) {
+ shared_network->add(subnet);
}
}
diff --git a/src/lib/dhcpsrv/parsers/shared_networks_list_parser.h b/src/lib/dhcpsrv/parsers/shared_networks_list_parser.h
index 5f49c8b097..3705ad224c 100644
--- a/src/lib/dhcpsrv/parsers/shared_networks_list_parser.h
+++ b/src/lib/dhcpsrv/parsers/shared_networks_list_parser.h
@@ -57,10 +57,9 @@ public:
const std::vector<data::ElementPtr>& networks_list =
shared_networks_list_data->listValue();
// Iterate over all networks and do the parsing.
- for (auto network_element = networks_list.cbegin();
- network_element != networks_list.cend(); ++network_element) {
+ for (auto const& network_element : networks_list) {
SharedNetworkParserType parser(check_iface_);
- auto network = parser.parse(*network_element);
+ auto network = parser.parse(network_element);
cfg->add(network);
}
} catch (const DhcpConfigError&) {
diff --git a/src/lib/dhcpsrv/parsers/simple_parser4.cc b/src/lib/dhcpsrv/parsers/simple_parser4.cc
index ce16628fbd..a7b12ead29 100644
--- a/src/lib/dhcpsrv/parsers/simple_parser4.cc
+++ b/src/lib/dhcpsrv/parsers/simple_parser4.cc
@@ -8,7 +8,6 @@
#include <dhcpsrv/parsers/simple_parser4.h>
#include <cc/data.h>
-#include <boost/foreach.hpp>
#include <iostream>
using namespace isc::data;
@@ -428,7 +427,7 @@ size_t SimpleParser4::setAllDefaults(ElementPtr global) {
// Now set option definition defaults for each specified option definition
ConstElementPtr option_defs = global->get("option-def");
if (option_defs) {
- BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) {
+ for (auto const& option_def : option_defs->listValue()) {
cnt += SimpleParser::setDefaults(option_def, OPTION4_DEF_DEFAULTS);
}
}
@@ -455,7 +454,7 @@ size_t SimpleParser4::setAllDefaults(ElementPtr global) {
// Set defaults for shared networks
ConstElementPtr shared = global->get("shared-networks");
if (shared) {
- BOOST_FOREACH(ElementPtr net, shared->listValue()) {
+ for (auto const& net : shared->listValue()) {
cnt += setDefaults(net, SHARED_NETWORK4_DEFAULTS);
@@ -512,7 +511,7 @@ size_t SimpleParser4::deriveParameters(ElementPtr global) {
// Now derive global parameters into subnets.
ConstElementPtr subnets = global->get("subnet4");
if (subnets) {
- BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
+ for (auto const& single_subnet : subnets->listValue()) {
cnt += SimpleParser::deriveParams(global, single_subnet,
INHERIT_TO_SUBNET4);
}
@@ -523,7 +522,7 @@ size_t SimpleParser4::deriveParameters(ElementPtr global) {
// subnets within derive from it.
ConstElementPtr shared = global->get("shared-networks");
if (shared) {
- BOOST_FOREACH(ElementPtr net, shared->listValue()) {
+ for (auto const& net : shared->listValue()) {
// First try to inherit the parameters from shared network,
// if defined there.
// Then try to inherit them from global.
@@ -533,7 +532,7 @@ size_t SimpleParser4::deriveParameters(ElementPtr global) {
// Now we need to go thrugh all the subnets in this net.
subnets = net->get("subnet4");
if (subnets) {
- BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
+ for (auto const& single_subnet : subnets->listValue()) {
cnt += SimpleParser::deriveParams(net, single_subnet,
INHERIT_TO_SUBNET4);
}
diff --git a/src/lib/dhcpsrv/parsers/simple_parser6.cc b/src/lib/dhcpsrv/parsers/simple_parser6.cc
index accde74d33..2c9c98f50f 100644
--- a/src/lib/dhcpsrv/parsers/simple_parser6.cc
+++ b/src/lib/dhcpsrv/parsers/simple_parser6.cc
@@ -9,8 +9,6 @@
#include <cc/data.h>
#include <dhcpsrv/parsers/simple_parser6.h>
-#include <boost/foreach.hpp>
-
using namespace isc::data;
namespace isc {
@@ -442,7 +440,7 @@ size_t SimpleParser6::setAllDefaults(ElementPtr global) {
// Now set the defaults for each specified option definition
ConstElementPtr option_defs = global->get("option-def");
if (option_defs) {
- BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) {
+ for (auto const& option_def : option_defs->listValue()) {
cnt += SimpleParser::setDefaults(option_def, OPTION6_DEF_DEFAULTS);
}
}
@@ -450,7 +448,7 @@ size_t SimpleParser6::setAllDefaults(ElementPtr global) {
// Set the defaults for option data
ConstElementPtr options = global->get("option-data");
if (options) {
- BOOST_FOREACH(ElementPtr single_option, options->listValue()) {
+ for (auto const& single_option : options->listValue()) {
cnt += SimpleParser::setDefaults(single_option, OPTION6_DEFAULTS);
}
}
@@ -471,7 +469,7 @@ size_t SimpleParser6::setAllDefaults(ElementPtr global) {
// Set defaults for shared networks
ConstElementPtr shared = global->get("shared-networks");
if (shared) {
- BOOST_FOREACH(ElementPtr net, shared->listValue()) {
+ for (auto const& net : shared->listValue()) {
cnt += setDefaults(net, SHARED_NETWORK6_DEFAULTS);
@@ -528,7 +526,7 @@ size_t SimpleParser6::deriveParameters(ElementPtr global) {
// Now derive global parameters into subnets.
ConstElementPtr subnets = global->get("subnet6");
if (subnets) {
- BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
+ for (auto const& single_subnet : subnets->listValue()) {
cnt += SimpleParser::deriveParams(global, single_subnet,
INHERIT_TO_SUBNET6);
}
@@ -539,7 +537,7 @@ size_t SimpleParser6::deriveParameters(ElementPtr global) {
// subnets within derive from it.
ConstElementPtr shared = global->get("shared-networks");
if (shared) {
- BOOST_FOREACH(ElementPtr net, shared->listValue()) {
+ for (auto const& net : shared->listValue()) {
// First try to inherit the parameters from shared network,
// if defined there.
// Then try to inherit them from global.
@@ -549,7 +547,7 @@ size_t SimpleParser6::deriveParameters(ElementPtr global) {
// Now we need to go thrugh all the subnets in this net.
subnets = net->get("subnet6");
if (subnets) {
- BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
+ for (auto const& single_subnet : subnets->listValue()) {
cnt += SimpleParser::deriveParams(net, single_subnet,
INHERIT_TO_SUBNET6);
}
diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc b/src/lib/dhcpsrv/pgsql_host_data_source.cc
index 6a88942bdc..ffe2461f1f 100644
--- a/src/lib/dhcpsrv/pgsql_host_data_source.cc
+++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc
@@ -26,6 +26,7 @@
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/array.hpp>
+#include <boost/foreach.hpp>
#include <boost/pointer_cast.hpp>
#include <boost/static_assert.hpp>
@@ -2556,11 +2557,11 @@ PgSqlHostDataSourceImpl::addOptions(PgSqlHostContextPtr& ctx,
// For each option space retrieve all options and insert them into the
// database.
- for (auto space = option_spaces.begin(); space != option_spaces.end(); ++space) {
- OptionContainerPtr options = options_cfg->getAllCombined(*space);
+ for (auto const& space : option_spaces) {
+ OptionContainerPtr options = options_cfg->getAllCombined(space);
if (options && !options->empty()) {
- for (auto opt = options->begin(); opt != options->end(); ++opt) {
- addOption(ctx, stindex, *opt, *space, Optional<SubnetID>(), host_id);
+ for (auto const& opt : *options) {
+ addOption(ctx, stindex, opt, space, Optional<SubnetID>(), host_id);
}
}
}
@@ -2709,9 +2710,8 @@ PgSqlHostDataSource::add(const HostPtr& host) {
// Insert IPv6 reservations.
IPv6ResrvRange v6resv = host->getIPv6Reservations();
if (std::distance(v6resv.first, v6resv.second) > 0) {
- for (IPv6ResrvIterator resv = v6resv.first; resv != v6resv.second;
- ++resv) {
- impl_->addResv(ctx, resv->second, host_id);
+ BOOST_FOREACH(auto const& resv, v6resv) {
+ impl_->addResv(ctx, resv.second, host_id);
}
}
diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc
index 01718d9b5b..c32d9738e6 100644
--- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc
+++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc
@@ -3205,13 +3205,12 @@ idToText(const OptionBuffer& id) {
std::stringstream tmp;
tmp << std::hex;
bool delim = false;
- for (std::vector<uint8_t>::const_iterator it = id.begin();
- it != id.end(); ++it) {
+ for (auto const& it : id) {
if (delim) {
tmp << ":";
}
tmp << std::setw(2) << std::setfill('0')
- << static_cast<unsigned int>(*it);
+ << static_cast<unsigned int>(it);
delim = true;
}
return (tmp.str());
diff --git a/src/lib/dhcpsrv/pool.cc b/src/lib/dhcpsrv/pool.cc
index 2a47333a34..876038ae17 100644
--- a/src/lib/dhcpsrv/pool.cc
+++ b/src/lib/dhcpsrv/pool.cc
@@ -125,9 +125,8 @@ Pool::toElement() const {
const ClientClasses& classes = getRequiredClasses();
if (!classes.empty()) {
ElementPtr class_list = Element::createList();
- for (ClientClasses::const_iterator it = classes.cbegin();
- it != classes.cend(); ++it) {
- class_list->add(Element::create(*it));
+ for (auto const& it : classes) {
+ class_list->add(Element::create(it));
}
map->set("require-client-classes", class_list);
}
diff --git a/src/lib/dhcpsrv/shared_network.cc b/src/lib/dhcpsrv/shared_network.cc
index 1580b18d1f..f7a72e1382 100644
--- a/src/lib/dhcpsrv/shared_network.cc
+++ b/src/lib/dhcpsrv/shared_network.cc
@@ -303,15 +303,15 @@ public:
const Lease::Type& lease_type) {
auto preferred_subnet = selected_subnet;
- for (auto s = subnets.begin(); s != subnets.end(); ++s) {
+ for (auto const& s : subnets) {
// It doesn't make sense to check the subnet against itself.
- if (preferred_subnet == (*s)) {
+ if (preferred_subnet == s) {
continue;
}
- if ((*s)->getClientClass().get() != selected_subnet->getClientClass().get()) {
+ if (s->getClientClass().get() != selected_subnet->getClientClass().get()) {
continue;
}
- auto current_subnet_state = (*s)->getAllocationState(lease_type);
+ auto current_subnet_state = s->getAllocationState(lease_type);
if (!current_subnet_state) {
continue;
}
@@ -324,7 +324,7 @@ public:
// instance.
if (current_subnet_state->getLastAllocatedTime() >
preferred_subnet_state->getLastAllocatedTime()) {
- preferred_subnet = (*s);
+ preferred_subnet = s;
}
}
return (preferred_subnet);
@@ -378,9 +378,9 @@ SharedNetwork4::del(const SubnetID& subnet_id) {
void
SharedNetwork4::delAll() {
- for (auto subnet = subnets_.cbegin(); subnet != subnets_.cend(); ++subnet) {
- (*subnet)->setSharedNetwork(NetworkPtr());
- (*subnet)->setSharedNetworkName("");
+ for (auto const& subnet : subnets_) {
+ subnet->setSharedNetwork(NetworkPtr());
+ subnet->setSharedNetworkName("");
}
subnets_.clear();
}
@@ -429,8 +429,8 @@ SharedNetwork4::toElement() const {
}
ElementPtr subnet4 = Element::createList();
- for (auto subnet = subnets_.cbegin(); subnet != subnets_.cend(); ++subnet) {
- subnet4->add((*subnet)->toElement());
+ for (auto const& subnet : subnets_) {
+ subnet4->add(subnet->toElement());
}
map->set("subnet4", subnet4);
@@ -480,8 +480,8 @@ SharedNetwork6::del(const SubnetID& subnet_id) {
void
SharedNetwork6::delAll() {
- for (auto subnet = subnets_.cbegin(); subnet != subnets_.cend(); ++subnet) {
- (*subnet)->setSharedNetwork(NetworkPtr());
+ for (auto const& subnet : subnets_) {
+ subnet->setSharedNetwork(NetworkPtr());
}
subnets_.clear();
}
@@ -518,8 +518,8 @@ SharedNetwork6::toElement() const {
}
ElementPtr subnet6 = Element::createList();
- for (auto subnet = subnets_.cbegin(); subnet != subnets_.cend(); ++subnet) {
- subnet6->add((*subnet)->toElement());
+ for (auto const& subnet : subnets_) {
+ subnet6->add(subnet->toElement());
}
map->set("subnet6", subnet6);
diff --git a/src/lib/dhcpsrv/srv_config.cc b/src/lib/dhcpsrv/srv_config.cc
index a07f964fee..ab6ee72168 100644
--- a/src/lib/dhcpsrv/srv_config.cc
+++ b/src/lib/dhcpsrv/srv_config.cc
@@ -134,9 +134,8 @@ SrvConfig::copy(SrvConfig& new_config) const {
// Replace configured hooks libraries.
new_config.hooks_config_.clear();
using namespace isc::hooks;
- for (HookLibsCollection::const_iterator it = hooks_config_.get().begin();
- it != hooks_config_.get().end(); ++it) {
- new_config.hooks_config_.add(it->first, it->second);
+ for (auto const& it : hooks_config_.get()) {
+ new_config.hooks_config_.add(it.first, it.second);
}
}
@@ -401,10 +400,10 @@ SrvConfig::extractConfiguredGlobals(isc::data::ConstElementPtr config) {
}
const std::map<std::string, ConstElementPtr>& values = config->mapValue();
- for (auto value = values.begin(); value != values.end(); ++value) {
- if (value->second->getType() != Element::list &&
- value->second->getType() != Element::map) {
- addConfiguredGlobal(value->first, value->second);
+ for (auto const& value : values) {
+ if (value.second->getType() != Element::list &&
+ value.second->getType() != Element::map) {
+ addConfiguredGlobal(value.first, value.second);
}
}
}
@@ -688,15 +687,14 @@ SrvConfig::toElement() const {
// Get plain subnets
ElementPtr plain_subnets = Element::createList();
const Subnet4Collection* subnets = cfg_subnets4_->getAll();
- for (Subnet4Collection::const_iterator subnet = subnets->cbegin();
- subnet != subnets->cend(); ++subnet) {
+ for (auto const& subnet : *subnets) {
// Skip subnets which are in a shared-network
SharedNetwork4Ptr network;
- (*subnet)->getSharedNetwork(network);
+ subnet->getSharedNetwork(network);
if (network) {
continue;
}
- ElementPtr subnet_cfg = (*subnet)->toElement();
+ ElementPtr subnet_cfg = subnet->toElement();
sn_list.push_back(subnet_cfg);
plain_subnets->add(subnet_cfg);
}
@@ -708,13 +706,11 @@ SrvConfig::toElement() const {
// Get subnets in shared network subnet lists
const std::vector<ElementPtr> networks = shared_networks->listValue();
- for (auto network = networks.cbegin();
- network != networks.cend(); ++network) {
+ for (auto const& network : networks) {
const std::vector<ElementPtr> sh_list =
- (*network)->get("subnet4")->listValue();
- for (auto subnet = sh_list.cbegin();
- subnet != sh_list.cend(); ++subnet) {
- sn_list.push_back(*subnet);
+ network->get("subnet4")->listValue();
+ for (auto const& subnet : sh_list) {
+ sn_list.push_back(subnet);
}
}
@@ -722,15 +718,14 @@ SrvConfig::toElement() const {
// Get plain subnets
ElementPtr plain_subnets = Element::createList();
const Subnet6Collection* subnets = cfg_subnets6_->getAll();
- for (Subnet6Collection::const_iterator subnet = subnets->cbegin();
- subnet != subnets->cend(); ++subnet) {
+ for (auto const& subnet : *subnets) {
// Skip subnets which are in a shared-network
SharedNetwork6Ptr network;
- (*subnet)->getSharedNetwork(network);
+ subnet->getSharedNetwork(network);
if (network) {
continue;
}
- ElementPtr subnet_cfg = (*subnet)->toElement();
+ ElementPtr subnet_cfg = subnet->toElement();
sn_list.push_back(subnet_cfg);
plain_subnets->add(subnet_cfg);
}
@@ -742,13 +737,11 @@ SrvConfig::toElement() const {
// Get subnets in shared network subnet lists
const std::vector<ElementPtr> networks = shared_networks->listValue();
- for (auto network = networks.cbegin();
- network != networks.cend(); ++network) {
+ for (auto const& network : networks) {
const std::vector<ElementPtr> sh_list =
- (*network)->get("subnet6")->listValue();
- for (auto subnet = sh_list.cbegin();
- subnet != sh_list.cend(); ++subnet) {
- sn_list.push_back(*subnet);
+ network->get("subnet6")->listValue();
+ for (auto const& subnet : sh_list) {
+ sn_list.push_back(subnet);
}
}
}
@@ -764,15 +757,14 @@ SrvConfig::toElement() const {
}
// Insert subnet reservations
- for (std::vector<ElementPtr>::const_iterator subnet = sn_list.cbegin();
- subnet != sn_list.cend(); ++subnet) {
- ConstElementPtr id = (*subnet)->get("id");
+ for (auto const& subnet : sn_list) {
+ ConstElementPtr id = subnet->get("id");
if (isNull(id)) {
isc_throw(ToElementError, "subnet has no id");
}
SubnetID subnet_id = id->intValue();
ConstElementPtr resvs = resv_list.get(subnet_id);
- (*subnet)->set("reservations", resvs);
+ subnet->set("reservations", resvs);
}
// Set expired-leases-processing
diff --git a/src/lib/dhcpsrv/tests/alloc_engine_utils.cc b/src/lib/dhcpsrv/tests/alloc_engine_utils.cc
index 0823bb3451..700d925d88 100644
--- a/src/lib/dhcpsrv/tests/alloc_engine_utils.cc
+++ b/src/lib/dhcpsrv/tests/alloc_engine_utils.cc
@@ -277,18 +277,18 @@ AllocEngine6Test::allocateTest(AllocEngine& engine, const Pool6Ptr& pool,
findReservation(engine, ctx);
EXPECT_NO_THROW(leases = engine.allocateLeases6(ctx));
- for (Lease6Collection::iterator it = leases.begin(); it != leases.end(); ++it) {
+ for (auto const& it : leases) {
// Do all checks on the lease
- checkLease6(duid_, *it, type, expected_len, in_pool, in_pool);
+ checkLease6(duid_, it, type, expected_len, in_pool, in_pool);
// Check that context has been updated with allocated addresses or
// prefixes.
- checkAllocatedResources(*it, ctx);
+ checkAllocatedResources(it, ctx);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(type,
- (*it)->addr_);
+ it->addr_);
if (!fake) {
// This is a real (REQUEST) allocation, the lease must be in the DB
EXPECT_TRUE(from_mgr) << "Lease " << from_mgr->addr_.toText()
@@ -299,7 +299,7 @@ AllocEngine6Test::allocateTest(AllocEngine& engine, const Pool6Ptr& pool,
}
// Now check that the lease in LeaseMgr has the same parameters
- detailCompareLease(*it, from_mgr);
+ detailCompareLease(it, from_mgr);
} else {
// This is a fake (SOLICIT) allocation, the lease must not be in DB
EXPECT_FALSE(from_mgr) << "Lease " << from_mgr->addr_.toText()
@@ -459,18 +459,18 @@ AllocEngine6Test::renewTest(AllocEngine& engine, const Pool6Ptr& pool,
findReservation(engine, ctx);
Lease6Collection leases = engine.renewLeases6(ctx);
- for (Lease6Collection::iterator it = leases.begin(); it != leases.end(); ++it) {
+ for (auto const& it : leases) {
// Do all checks on the lease
- checkLease6(duid_, *it, type, expected_len, in_subnet, in_pool);
+ checkLease6(duid_, it, type, expected_len, in_subnet, in_pool);
// Check that context has been updated with allocated addresses or
// prefixes.
- checkAllocatedResources(*it, ctx);
+ checkAllocatedResources(it, ctx);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(type,
- (*it)->addr_);
+ it->addr_);
// This is a real (REQUEST) allocation, the lease must be in the DB
EXPECT_TRUE(from_mgr) << "Lease " << from_mgr->addr_.toText()
@@ -481,7 +481,7 @@ AllocEngine6Test::renewTest(AllocEngine& engine, const Pool6Ptr& pool,
}
// Now check that the lease in LeaseMgr has the same parameters
- detailCompareLease(*it, from_mgr);
+ detailCompareLease(it, from_mgr);
}
return (leases);
diff --git a/src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc b/src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc
index 15b0c97f3f..2ceacdd85c 100644
--- a/src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc
+++ b/src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc
@@ -23,6 +23,7 @@
#include <hooks/callout_manager.h>
#include <hooks/hooks_manager.h>
#include <testutils/gtest_utils.h>
+#include <boost/foreach.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/make_shared.hpp>
#include <gtest/gtest.h>
@@ -176,8 +177,8 @@ public:
if (!audit_entries_.empty()) {
auto const& index = audit_entries_.get<AuditEntryObjectTypeTag>();
auto range = index.equal_range(object_type);
- for (auto it = range.first; it != range.second; ++it) {
- if (((*it)->getModificationType() != AuditEntry::ModificationType::DELETE)) {
+ BOOST_FOREACH(auto const& it, range) {
+ if (it->getModificationType() != AuditEntry::ModificationType::DELETE) {
return (true);
}
}
@@ -198,8 +199,8 @@ public:
auto const& index = audit_entries_.get<AuditEntryObjectTypeTag>();
auto range = index.equal_range(boost::make_tuple(object_type,
AuditEntry::ModificationType::DELETE));
- for (auto it = range.first; it != range.second; ++it) {
- if ((*it)->getObjectId() == object_id) {
+ BOOST_FOREACH(auto const& it, range) {
+ if (it->getObjectId() == object_id) {
return (true);
}
}
diff --git a/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc b/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
index 58c0d03a4f..177339508a 100644
--- a/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
+++ b/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
@@ -475,9 +475,8 @@ TEST_F(CfgHostsTest, getAll4ByAddress) {
HostCollection hosts = cfg.getAll4(IOAddress("192.0.2.10"));
std::set<uint32_t> subnet_ids;
- for (HostCollection::const_iterator host = hosts.begin(); host != hosts.end();
- ++host) {
- subnet_ids.insert((*host)->getIPv4SubnetID());
+ for (auto const& host : hosts) {
+ subnet_ids.insert(host->getIPv4SubnetID());
}
ASSERT_EQ(25, subnet_ids.size());
EXPECT_EQ(1, *subnet_ids.begin());
@@ -726,9 +725,8 @@ TEST_F(CfgHostsTest, deleteAll4) {
// Get all inserted hosts.
HostCollection hosts = cfg.getAll4(IOAddress::IPV4_ZERO_ADDRESS());
std::set<uint32_t> subnet_ids;
- for (HostCollection::const_iterator host = hosts.begin(); host != hosts.end();
- ++host) {
- subnet_ids.insert((*host)->getIPv4SubnetID());
+ for (auto const& host : hosts) {
+ subnet_ids.insert(host->getIPv4SubnetID());
}
// Make sure there are two unique subnets: 1 and 2.
ASSERT_EQ(2, subnet_ids.size());
@@ -741,9 +739,8 @@ TEST_F(CfgHostsTest, deleteAll4) {
// Gather the host counts again.
subnet_ids.clear();
hosts = cfg.getAll4(IOAddress::IPV4_ZERO_ADDRESS());
- for (HostCollection::const_iterator host = hosts.begin(); host != hosts.end();
- ++host) {
- subnet_ids.insert((*host)->getIPv4SubnetID());
+ for (auto const& host : hosts) {
+ subnet_ids.insert(host->getIPv4SubnetID());
}
// We should only have hosts for one subnet and it should be the subnet
// with ID of 1.
diff --git a/src/lib/dhcpsrv/tests/cfg_option_def_unittest.cc b/src/lib/dhcpsrv/tests/cfg_option_def_unittest.cc
index e79817317b..9dc92341cb 100644
--- a/src/lib/dhcpsrv/tests/cfg_option_def_unittest.cc
+++ b/src/lib/dhcpsrv/tests/cfg_option_def_unittest.cc
@@ -94,11 +94,11 @@ TEST(CfgOptionDefTest, getAllThenDelete) {
// valid codes. Also, their order should be the same as they
// were added (codes 100-109).
uint16_t code = 100;
- for (OptionDefContainer::const_iterator it = option_defs1->begin();
- it != option_defs1->end(); ++it, ++code) {
- OptionDefinitionPtr def(*it);
+ for (auto const& it : *option_defs1) {
+ OptionDefinitionPtr def(it);
ASSERT_TRUE(def);
EXPECT_EQ(code, def->getCode());
+ ++code;
}
// Sanity check that all 10 option definitions are there.
@@ -108,11 +108,11 @@ TEST(CfgOptionDefTest, getAllThenDelete) {
// Check that the option codes are valid.
code = 105;
- for (OptionDefContainer::const_iterator it = option_defs2->begin();
- it != option_defs2->end(); ++it, ++code) {
- OptionDefinitionPtr def(*it);
+ for (auto const& it : *option_defs2) {
+ OptionDefinitionPtr def(it);
ASSERT_TRUE(def);
EXPECT_EQ(code, def->getCode());
+ ++code;
}
// Let's make one more check that the empty set is returned when
diff --git a/src/lib/dhcpsrv/tests/cfg_option_unittest.cc b/src/lib/dhcpsrv/tests/cfg_option_unittest.cc
index ab3c1de824..55b0995c09 100644
--- a/src/lib/dhcpsrv/tests/cfg_option_unittest.cc
+++ b/src/lib/dhcpsrv/tests/cfg_option_unittest.cc
@@ -17,7 +17,6 @@
#include <dhcpsrv/cfg_option.h>
#include <testutils/gtest_utils.h>
#include <testutils/test_to_element.h>
-#include <boost/foreach.hpp>
#include <boost/pointer_cast.hpp>
#include <gtest/gtest.h>
#include <iterator>
@@ -278,10 +277,9 @@ TEST_F(CfgOptionTest, add) {
// Validate codes of options added to dhcp6 option space.
uint16_t expected_code = 100;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -292,10 +290,9 @@ TEST_F(CfgOptionTest, add) {
// Validate codes of options added to isc option space.
expected_code = 105;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -720,8 +717,7 @@ TEST_F(CfgOptionTest, encapsulate) {
ASSERT_EQ(19, first_level.size());
// Iterate over all first level sub-options.
- std::pair<unsigned int, OptionPtr> first_level_opt;
- BOOST_FOREACH(first_level_opt, first_level) {
+ for (auto const& first_level_opt : first_level) {
// Each option in this test comprises a single one byte field and
// should cast to OptionUint8 type.
OptionUint8Ptr first_level_uint8 = boost::dynamic_pointer_cast<
@@ -744,8 +740,7 @@ TEST_F(CfgOptionTest, encapsulate) {
// Iterate over sub-options and make sure they include the expected
// values.
- std::pair<unsigned int, OptionPtr> second_level_opt;
- BOOST_FOREACH(second_level_opt, second_level) {
+ for (auto const& second_level_opt : second_level) {
OptionUint8Ptr second_level_uint8 = boost::dynamic_pointer_cast<
OptionUint8>(second_level_opt.second);
ASSERT_TRUE(second_level_uint8);
@@ -1060,10 +1055,9 @@ TEST_F(CfgOptionTest, addNonUniqueOptions) {
// have been returned for the particular code.
ASSERT_EQ(2, distance(range.first, range.second));
// Check that returned options actually have the expected option code.
- for (OptionContainerTypeIndex::const_iterator option_desc = range.first;
- option_desc != range.second; ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(code, option_desc->option_->getType());
+ BOOST_FOREACH(auto const& option_desc, range) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(code, option_desc.option_->getType());
}
}
@@ -1186,10 +1180,9 @@ TEST_F(CfgOptionTest, addVendorOptions) {
// Validate codes of options added to dhcp6 option space.
uint16_t expected_code = 100;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -1199,10 +1192,9 @@ TEST_F(CfgOptionTest, addVendorOptions) {
// Validate codes of options added to isc option space.
expected_code = 105;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -1236,13 +1228,12 @@ TEST_F(CfgOptionTest, getVendorIdsSpaceNames) {
ASSERT_EQ(10, space_names.size());
// Check that the option space names for those vendor ids are correct.
- for (std::list<std::string>::iterator name = space_names.begin();
- name != space_names.end(); ++name) {
- uint16_t id = static_cast<uint16_t>(std::distance(space_names.begin(),
- name));
+ size_t id = 0;
+ for (auto const& name : space_names) {
std::ostringstream s;
s << "vendor-" << (100 + id);
- EXPECT_EQ(s.str(), *name);
+ EXPECT_EQ(s.str(), name);
+ id++;
}
}
diff --git a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
index d10fd8ee5e..dfe3ce4c13 100644
--- a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
+++ b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
@@ -31,6 +31,7 @@
#include <testutils/test_to_element.h>
#include <util/doubles.h>
+#include <boost/range/adaptor/reversed.hpp>
#include <gtest/gtest.h>
#include <vector>
@@ -122,29 +123,29 @@ TEST(CfgSubnets4Test, getSpecificSubnet) {
subnets.push_back(subnet3);
// Add all subnets to the configuration.
- for (auto subnet = subnets.cbegin(); subnet != subnets.cend(); ++subnet) {
- ASSERT_NO_THROW(cfg.add(*subnet)) << "failed to add subnet with id: "
- << (*subnet)->getID();
+ for (auto const& subnet : subnets) {
+ ASSERT_NO_THROW(cfg.add(subnet)) << "failed to add subnet with id: "
+ << subnet->getID();
}
// Iterate over all subnets and make sure they can be retrieved by
// subnet identifier.
- for (auto subnet = subnets.rbegin(); subnet != subnets.rend(); ++subnet) {
- ConstSubnet4Ptr subnet_returned = cfg.getBySubnetId((*subnet)->getID());
+ for (auto const& subnet : boost::adaptors::reverse(subnets)) {
+ ConstSubnet4Ptr subnet_returned = cfg.getBySubnetId(subnet->getID());
ASSERT_TRUE(subnet_returned) << "failed to return subnet with id: "
- << (*subnet)->getID();
- EXPECT_EQ((*subnet)->getID(), subnet_returned->getID());
- EXPECT_EQ((*subnet)->toText(), subnet_returned->toText());
+ << subnet->getID();
+ EXPECT_EQ(subnet->getID(), subnet_returned->getID());
+ EXPECT_EQ(subnet->toText(), subnet_returned->toText());
}
// Repeat the previous test, but this time retrieve subnets by their
// prefixes.
- for (auto subnet = subnets.rbegin(); subnet != subnets.rend(); ++subnet) {
- ConstSubnet4Ptr subnet_returned = cfg.getByPrefix((*subnet)->toText());
+ for (auto const& subnet : boost::adaptors::reverse(subnets)) {
+ ConstSubnet4Ptr subnet_returned = cfg.getByPrefix(subnet->toText());
ASSERT_TRUE(subnet_returned) << "failed to return subnet with id: "
- << (*subnet)->getID();
- EXPECT_EQ((*subnet)->getID(), subnet_returned->getID());
- EXPECT_EQ((*subnet)->toText(), subnet_returned->toText());
+ << subnet->getID();
+ EXPECT_EQ(subnet->getID(), subnet_returned->getID());
+ EXPECT_EQ(subnet->toText(), subnet_returned->toText());
}
// Make sure that null pointers are returned for non-existing subnets.
@@ -1368,14 +1369,14 @@ TEST(CfgSubnets4Test, teeTimePercentValidation) {
// Iterate over the test scenarios, verifying each prescribed
// outcome.
- for (auto test = tests.begin(); test != tests.end(); ++test) {
+ for (auto const& test : tests) {
{
- SCOPED_TRACE("test: " + (*test).label);
+ SCOPED_TRACE("test: " + test.label);
// Set this scenario's configuration parameters
- elems->set("calculate-tee-times", data::Element::create((*test).calculate_tee_times));
- elems->set("t1-percent", data::Element::create((*test).t1_percent));
- elems->set("t2-percent", data::Element::create((*test).t2_percent));
+ elems->set("calculate-tee-times", data::Element::create(test.calculate_tee_times));
+ elems->set("t1-percent", data::Element::create(test.t1_percent));
+ elems->set("t2-percent", data::Element::create(test.t2_percent));
Subnet4Ptr subnet;
try {
@@ -1383,9 +1384,9 @@ TEST(CfgSubnets4Test, teeTimePercentValidation) {
Subnet4ConfigParser parser;
subnet = parser.parse(elems);
} catch (const std::exception& ex) {
- if (!(*test).error_message.empty()) {
+ if (!test.error_message.empty()) {
// We expected a failure, did we fail the correct way?
- EXPECT_EQ((*test).error_message, ex.what());
+ EXPECT_EQ(test.error_message, ex.what());
} else {
// Should not have failed.
ADD_FAILURE() << "Scenario should not have failed: " << ex.what();
@@ -1396,9 +1397,9 @@ TEST(CfgSubnets4Test, teeTimePercentValidation) {
}
// We parsed correctly, make sure the values are right.
- EXPECT_EQ((*test).calculate_tee_times, subnet->getCalculateTeeTimes());
- EXPECT_TRUE(util::areDoublesEquivalent((*test).t1_percent, subnet->getT1Percent()));
- EXPECT_TRUE(util::areDoublesEquivalent((*test).t2_percent, subnet->getT2Percent()));
+ EXPECT_EQ(test.calculate_tee_times, subnet->getCalculateTeeTimes());
+ EXPECT_TRUE(util::areDoublesEquivalent(test.t1_percent, subnet->getT1Percent()));
+ EXPECT_TRUE(util::areDoublesEquivalent(test.t2_percent, subnet->getT2Percent()));
}
}
}
@@ -1779,12 +1780,12 @@ TEST(CfgSubnets4Test, cacheParamValidation) {
// Iterate over the test scenarios, verifying each prescribed
// outcome.
- for (auto test = tests.begin(); test != tests.end(); ++test) {
+ for (auto const& test : tests) {
{
- SCOPED_TRACE("test: " + (*test).label);
+ SCOPED_TRACE("test: " + test.label);
// Set this scenario's configuration parameters
- elems->set("cache-threshold", data::Element::create((*test).threshold));
+ elems->set("cache-threshold", data::Element::create(test.threshold));
Subnet4Ptr subnet;
try {
@@ -1792,9 +1793,9 @@ TEST(CfgSubnets4Test, cacheParamValidation) {
Subnet4ConfigParser parser;
subnet = parser.parse(elems);
} catch (const std::exception& ex) {
- if (!(*test).error_message.empty()) {
+ if (!test.error_message.empty()) {
// We expected a failure, did we fail the correct way?
- EXPECT_EQ((*test).error_message, ex.what());
+ EXPECT_EQ(test.error_message, ex.what());
} else {
// Should not have failed.
ADD_FAILURE() << "Scenario should not have failed: " << ex.what();
@@ -1805,7 +1806,7 @@ TEST(CfgSubnets4Test, cacheParamValidation) {
}
// We parsed correctly, make sure the values are right.
- EXPECT_TRUE(util::areDoublesEquivalent((*test).threshold, subnet->getCacheThreshold()));
+ EXPECT_TRUE(util::areDoublesEquivalent(test.threshold, subnet->getCacheThreshold()));
}
}
}
diff --git a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
index 20707fed8e..1959fb2cfa 100644
--- a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
+++ b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
@@ -28,6 +28,7 @@
#include <testutils/test_to_element.h>
#include <util/doubles.h>
+#include <boost/range/adaptor/reversed.hpp>
#include <gtest/gtest.h>
#include <string>
@@ -129,29 +130,29 @@ TEST(CfgSubnets6Test, getSpecificSubnet) {
subnets.push_back(subnet3);
// Add all subnets to the configuration.
- for (auto subnet = subnets.cbegin(); subnet != subnets.cend(); ++subnet) {
- ASSERT_NO_THROW(cfg.add(*subnet)) << "failed to add subnet with id: "
- << (*subnet)->getID();
+ for (auto const& subnet : subnets) {
+ ASSERT_NO_THROW(cfg.add(subnet)) << "failed to add subnet with id: "
+ << subnet->getID();
}
// Iterate over all subnets and make sure they can be retrieved by
// subnet identifier.
- for (auto subnet = subnets.rbegin(); subnet != subnets.rend(); ++subnet) {
- ConstSubnet6Ptr subnet_returned = cfg.getBySubnetId((*subnet)->getID());
+ for (auto const& subnet : boost::adaptors::reverse(subnets)) {
+ ConstSubnet6Ptr subnet_returned = cfg.getBySubnetId(subnet->getID());
ASSERT_TRUE(subnet_returned) << "failed to return subnet with id: "
- << (*subnet)->getID();
- EXPECT_EQ((*subnet)->getID(), subnet_returned->getID());
- EXPECT_EQ((*subnet)->toText(), subnet_returned->toText());
+ << subnet->getID();
+ EXPECT_EQ(subnet->getID(), subnet_returned->getID());
+ EXPECT_EQ(subnet->toText(), subnet_returned->toText());
}
// Repeat the previous test, but this time retrieve subnets by their
// prefixes.
- for (auto subnet = subnets.rbegin(); subnet != subnets.rend(); ++subnet) {
- ConstSubnet6Ptr subnet_returned = cfg.getByPrefix((*subnet)->toText());
+ for (auto const& subnet : boost::adaptors::reverse(subnets)) {
+ ConstSubnet6Ptr subnet_returned = cfg.getByPrefix(subnet->toText());
ASSERT_TRUE(subnet_returned) << "failed to return subnet with id: "
- << (*subnet)->getID();
- EXPECT_EQ((*subnet)->getID(), subnet_returned->getID());
- EXPECT_EQ((*subnet)->toText(), subnet_returned->toText());
+ << subnet->getID();
+ EXPECT_EQ(subnet->getID(), subnet_returned->getID());
+ EXPECT_EQ(subnet->toText(), subnet_returned->toText());
}
// Make sure that null pointers are returned for non-existing subnets.
@@ -1164,14 +1165,14 @@ TEST(CfgSubnets6Test, teeTimePercentValidation) {
// Iterate over the test scenarios, verifying each prescribed
// outcome.
- for (auto test = tests.begin(); test != tests.end(); ++test) {
+ for (auto const& test : tests) {
{
- SCOPED_TRACE("test: " + (*test).label);
+ SCOPED_TRACE("test: " + test.label);
// Set this scenario's configuration parameters
- elems->set("calculate-tee-times", data::Element::create((*test).calculate_tee_times));
- elems->set("t1-percent", data::Element::create((*test).t1_percent));
- elems->set("t2-percent", data::Element::create((*test).t2_percent));
+ elems->set("calculate-tee-times", data::Element::create(test.calculate_tee_times));
+ elems->set("t1-percent", data::Element::create(test.t1_percent));
+ elems->set("t2-percent", data::Element::create(test.t2_percent));
Subnet6Ptr subnet;
try {
@@ -1179,9 +1180,9 @@ TEST(CfgSubnets6Test, teeTimePercentValidation) {
Subnet6ConfigParser parser;
subnet = parser.parse(elems);
} catch (const std::exception& ex) {
- if (!(*test).error_message.empty()) {
+ if (!test.error_message.empty()) {
// We expected a failure, did we fail the correct way?
- EXPECT_EQ((*test).error_message, ex.what());
+ EXPECT_EQ(test.error_message, ex.what());
} else {
// Should not have failed.
ADD_FAILURE() << "Scenario should not have failed: " << ex.what();
@@ -1192,11 +1193,11 @@ TEST(CfgSubnets6Test, teeTimePercentValidation) {
}
// We parsed correctly, make sure the values are right.
- EXPECT_EQ((*test).calculate_tee_times, subnet->getCalculateTeeTimes());
- EXPECT_TRUE(util::areDoublesEquivalent((*test).t1_percent, subnet->getT1Percent()))
- << "expected:" << (*test).t1_percent << " actual: " << subnet->getT1Percent();
- EXPECT_TRUE(util::areDoublesEquivalent((*test).t2_percent, subnet->getT2Percent()))
- << "expected:" << (*test).t2_percent << " actual: " << subnet->getT2Percent();
+ EXPECT_EQ(test.calculate_tee_times, subnet->getCalculateTeeTimes());
+ EXPECT_TRUE(util::areDoublesEquivalent(test.t1_percent, subnet->getT1Percent()))
+ << "expected:" << test.t1_percent << " actual: " << subnet->getT1Percent();
+ EXPECT_TRUE(util::areDoublesEquivalent(test.t2_percent, subnet->getT2Percent()))
+ << "expected:" << test.t2_percent << " actual: " << subnet->getT2Percent();
}
}
}
@@ -1555,12 +1556,12 @@ TEST(CfgSubnets6Test, cacheParamValidation) {
// Iterate over the test scenarios, verifying each prescribed
// outcome.
- for (auto test = tests.begin(); test != tests.end(); ++test) {
+ for (auto const& test : tests) {
{
- SCOPED_TRACE("test: " + (*test).label);
+ SCOPED_TRACE("test: " + test.label);
// Set this scenario's configuration parameters
- elems->set("cache-threshold", data::Element::create((*test).threshold));
+ elems->set("cache-threshold", data::Element::create(test.threshold));
Subnet6Ptr subnet;
try {
@@ -1568,9 +1569,9 @@ TEST(CfgSubnets6Test, cacheParamValidation) {
Subnet6ConfigParser parser;
subnet = parser.parse(elems);
} catch (const std::exception& ex) {
- if (!(*test).error_message.empty()) {
+ if (!test.error_message.empty()) {
// We expected a failure, did we fail the correct way?
- EXPECT_EQ((*test).error_message, ex.what());
+ EXPECT_EQ(test.error_message, ex.what());
} else {
// Should not have failed.
ADD_FAILURE() << "Scenario should not have failed: " << ex.what();
@@ -1581,7 +1582,7 @@ TEST(CfgSubnets6Test, cacheParamValidation) {
}
// We parsed correctly, make sure the values are right.
- EXPECT_TRUE(util::areDoublesEquivalent((*test).threshold, subnet->getCacheThreshold()));
+ EXPECT_TRUE(util::areDoublesEquivalent(test.threshold, subnet->getCacheThreshold()));
}
}
}
diff --git a/src/lib/dhcpsrv/tests/client_class_def_unittest.cc b/src/lib/dhcpsrv/tests/client_class_def_unittest.cc
index bb7b2f67a9..1909c8dddf 100644
--- a/src/lib/dhcpsrv/tests/client_class_def_unittest.cc
+++ b/src/lib/dhcpsrv/tests/client_class_def_unittest.cc
@@ -602,7 +602,7 @@ TEST(ClientClassDictionary, initMatchExprError) {
ASSERT_THROW(dictionary->initMatchExpr(AF_INET), std::exception);
// Ensure that no classes have their match expressions modified.
- for (auto const& c : (*dictionary->getClasses())) {
+ for (auto const& c : *dictionary->getClasses()) {
EXPECT_FALSE(c->getMatchExpr());
}
}
@@ -1448,7 +1448,7 @@ TEST(ClientClassDictionary, templateInitMatchExprError) {
ASSERT_THROW(dictionary->initMatchExpr(AF_INET), std::exception);
// Ensure that no classes have their match expressions modified.
- for (auto const& c : (*dictionary->getClasses())) {
+ for (auto const& c : *dictionary->getClasses()) {
EXPECT_FALSE(c->getMatchExpr());
}
}
diff --git a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
index 84f429a6e1..ce98d2b0d0 100644
--- a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
+++ b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
@@ -36,7 +36,6 @@
#include <testutils/test_to_element.h>
#include <gtest/gtest.h>
-#include <boost/foreach.hpp>
#include <boost/pointer_cast.hpp>
#include <map>
@@ -197,12 +196,11 @@ public:
return (answer);
}
- ConfigPair config_pair;
try {
// Iterate over the config elements.
const std::map<std::string, ConstElementPtr>& values_map =
config_set->mapValue();
- BOOST_FOREACH(config_pair, values_map) {
+ for (auto const& config_pair : values_map) {
// These are the simple parsers. No need to go through
// the ParserPtr hooplas with them.
@@ -337,14 +335,14 @@ public:
// Now set option definition defaults for each specified option definition
ConstElementPtr option_defs = global->get("option-def");
if (option_defs) {
- BOOST_FOREACH(ElementPtr single_def, option_defs->listValue()) {
+ for (auto const& single_def : option_defs->listValue()) {
cnt += SimpleParser::setDefaults(single_def, option_def_defaults);
}
}
ConstElementPtr options = global->get("option-data");
if (options) {
- BOOST_FOREACH(ElementPtr single_option, options->listValue()) {
+ for (auto const& single_option : options->listValue()) {
cnt += SimpleParser::setDefaults(single_option, option_defaults);
}
}
diff --git a/src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc b/src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc
index fd2ed2e0b9..b8e81cef9e 100644
--- a/src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc
+++ b/src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc
@@ -20,8 +20,9 @@
#include <dhcpsrv/parsers/host_reservation_parser.h>
#include <dhcpsrv/testutils/config_result_check.h>
#include <testutils/test_to_element.h>
-#include <boost/pointer_cast.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/foreach.hpp>
+#include <boost/pointer_cast.hpp>
#include <gtest/gtest.h>
#include <iterator>
#include <sstream>
@@ -67,9 +68,8 @@ protected:
/// in which the reservation will be searched.
bool
reservationExists(const IPv6Resrv& resrv, const IPv6ResrvRange& range) {
- for (IPv6ResrvIterator it = range.first; it != range.second;
- ++it) {
- if (resrv == it->second) {
+ BOOST_FOREACH(auto const& it, range) {
+ if (resrv == it.second) {
return (true);
}
}
diff --git a/src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc b/src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc
index c10adde0bf..8468e4e634 100644
--- a/src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc
+++ b/src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc
@@ -173,8 +173,8 @@ TEST_F(HostReservationsListParserTest, ipv4Reservations) {
HostReservationsListParser<HostReservationParser4> parser;
ASSERT_NO_THROW(parser.parse(SubnetID(1), config_element, hosts));
- for (auto h = hosts.begin(); h != hosts.end(); ++h) {
- CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+ for (auto const& h : hosts) {
+ CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
}
CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
@@ -248,8 +248,8 @@ TEST_F(HostReservationsListParserTest, duplicatedIdentifierValue4) {
HostReservationsListParser<HostReservationParser4> parser;
EXPECT_THROW({
parser.parse(SubnetID(1), config_element, hosts);
- for (auto h = hosts.begin(); h != hosts.end(); ++h) {
- CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+ for (auto const& h : hosts) {
+ CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
}
}, DuplicateHost);
// The code threw exception, because the second insertion failed.
@@ -285,8 +285,8 @@ TEST_F(HostReservationsListParserTest, ipv6Reservations) {
HostReservationsListParser<HostReservationParser6> parser;
ASSERT_NO_THROW(parser.parse(SubnetID(2), config_element, hosts));
- for (auto h = hosts.begin(); h != hosts.end(); ++h) {
- CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+ for (auto const& h : hosts) {
+ CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
}
CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
@@ -378,8 +378,8 @@ TEST_F(HostReservationsListParserTest, duplicatedIdentifierValue6) {
HostReservationsListParser<HostReservationParser6> parser;
EXPECT_THROW({
parser.parse(SubnetID(1), config_element, hosts);
- for (auto h = hosts.begin(); h != hosts.end(); ++h) {
- CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+ for (auto const& h : hosts) {
+ CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
}
}, DuplicateHost);
}
diff --git a/src/lib/dhcpsrv/tests/host_unittest.cc b/src/lib/dhcpsrv/tests/host_unittest.cc
index be8c674448..2661e8e13b 100644
--- a/src/lib/dhcpsrv/tests/host_unittest.cc
+++ b/src/lib/dhcpsrv/tests/host_unittest.cc
@@ -11,6 +11,7 @@
#include <testutils/gtest_utils.h>
#include <util/encode/hex.h>
#include <util/range_utilities.h>
+#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
#include <cstdlib>
@@ -167,9 +168,8 @@ public:
/// @return true if reservation exists, false otherwise.
bool
reservationExists(const IPv6Resrv& resrv, const IPv6ResrvRange& range) {
- for (IPv6ResrvIterator it = range.first; it != range.second;
- ++it) {
- if (resrv == it->second) {
+ BOOST_FOREACH(auto const& it, range) {
+ if (resrv == it.second) {
return (true);
}
}
@@ -925,10 +925,9 @@ TEST_F(HostTest, addOptions4) {
// Validate codes of options added to dhcp4 option space.
uint16_t expected_code = 100;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -938,10 +937,9 @@ TEST_F(HostTest, addOptions4) {
// Validate codes of options added to isc option space.
expected_code = 105;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -1013,10 +1011,9 @@ TEST_F(HostTest, addOptions6) {
// Validate codes of options added to dhcp6 option space.
uint16_t expected_code = 100;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -1026,10 +1023,9 @@ TEST_F(HostTest, addOptions6) {
// Validate codes of options added to isc option space.
expected_code = 105;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
diff --git a/src/lib/dhcpsrv/tests/pool_unittest.cc b/src/lib/dhcpsrv/tests/pool_unittest.cc
index d40ee33a23..c1ba331528 100644
--- a/src/lib/dhcpsrv/tests/pool_unittest.cc
+++ b/src/lib/dhcpsrv/tests/pool_unittest.cc
@@ -156,10 +156,9 @@ TEST(Pool4Test, addOptions) {
// Validate codes of options added to dhcp4 option space.
uint16_t expected_code = 100;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -169,10 +168,9 @@ TEST(Pool4Test, addOptions) {
// Validate codes of options added to isc option space.
expected_code = 105;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -562,10 +560,9 @@ TEST(Pool6Test, addOptions) {
// Validate codes of options added to dhcp6 option space.
uint16_t expected_code = 100;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -575,10 +572,9 @@ TEST(Pool6Test, addOptions) {
// Validate codes of options added to isc option space.
expected_code = 105;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
diff --git a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc
index 3472e0f190..213d628dd0 100644
--- a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc
+++ b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc
@@ -92,10 +92,9 @@ public:
ASSERT_EQ(test.addresses_.size(), network.getRelayAddresses().size());
// Are the expected addresses in the list?
- for (auto exp_address = test.addresses_.begin(); exp_address != test.addresses_.end();
- ++exp_address) {
- EXPECT_TRUE(network.hasRelayAddress(*exp_address))
- << " expected address: " << (*exp_address).toText() << " not found" ;
+ for (auto const& exp_address : test.addresses_) {
+ EXPECT_TRUE(network.hasRelayAddress(exp_address))
+ << " expected address: " << exp_address.toText() << " not found" ;
}
}
@@ -451,11 +450,9 @@ TEST_F(SharedNetwork4ParserTest, relayInfoTests) {
// Iterate over the test scenarios, verifying each prescribed
// outcome.
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- relayTest(*test);
- }
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ relayTest(test);
}
}
@@ -1030,11 +1027,9 @@ TEST_F(SharedNetwork6ParserTest, relayInfoTests) {
// Iterate over the test scenarios, verifying each prescribed
// outcome.
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- relayTest(*test);
- }
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ relayTest(test);
}
}
diff --git a/src/lib/dhcpsrv/tests/srv_config_unittest.cc b/src/lib/dhcpsrv/tests/srv_config_unittest.cc
index 77673c4074..e9d3b4f8e3 100644
--- a/src/lib/dhcpsrv/tests/srv_config_unittest.cc
+++ b/src/lib/dhcpsrv/tests/srv_config_unittest.cc
@@ -551,21 +551,21 @@ TEST_F(SrvConfigTest, configuredGlobals) {
// Maps and lists should be excluded.
auto globals = srv_globals->valuesMap();
- for (auto global = globals.begin(); global != globals.end(); ++global) {
- if (global->first == "comment") {
- ASSERT_EQ(Element::string, global->second->getType());
- EXPECT_EQ("okay", global->second->stringValue());
- } else if (global->first == "valid-lifetime") {
- ASSERT_EQ(Element::integer, global->second->getType());
- EXPECT_EQ(444, global->second->intValue());
- } else if (global->first == "store-extended-info") {
- ASSERT_EQ(Element::boolean, global->second->getType());
- EXPECT_TRUE(global->second->boolValue());
- } else if (global->first == "t1-percent") {
- ASSERT_EQ(Element::real, global->second->getType());
- EXPECT_EQ(1.234, global->second->doubleValue());
+ for (auto const& global : globals) {
+ if (global.first == "comment") {
+ ASSERT_EQ(Element::string, global.second->getType());
+ EXPECT_EQ("okay", global.second->stringValue());
+ } else if (global.first == "valid-lifetime") {
+ ASSERT_EQ(Element::integer, global.second->getType());
+ EXPECT_EQ(444, global.second->intValue());
+ } else if (global.first == "store-extended-info") {
+ ASSERT_EQ(Element::boolean, global.second->getType());
+ EXPECT_TRUE(global.second->boolValue());
+ } else if (global.first == "t1-percent") {
+ ASSERT_EQ(Element::real, global.second->getType());
+ EXPECT_EQ(1.234, global.second->doubleValue());
} else {
- ADD_FAILURE() << "unexpected element found:" << global->first;
+ ADD_FAILURE() << "unexpected element found:" << global.first;
}
}
diff --git a/src/lib/dhcpsrv/tests/subnet_unittest.cc b/src/lib/dhcpsrv/tests/subnet_unittest.cc
index 69f762cace..c13680438a 100644
--- a/src/lib/dhcpsrv/tests/subnet_unittest.cc
+++ b/src/lib/dhcpsrv/tests/subnet_unittest.cc
@@ -1380,10 +1380,9 @@ TEST(Subnet6Test, addOptions) {
// Validate codes of options added to dhcp6 option space.
uint16_t expected_code = 100;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -1393,10 +1392,9 @@ TEST(Subnet6Test, addOptions) {
// Validate codes of options added to isc option space.
expected_code = 105;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -1435,10 +1433,9 @@ TEST(Subnet6Test, addNonUniqueOptions) {
// have been returned for the particular code.
ASSERT_EQ(2, distance(range.first, range.second));
// Check that returned options actually have the expected option code.
- for (OptionContainerTypeIndex::const_iterator option_desc = range.first;
- option_desc != range.second; ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(code, option_desc->option_->getType());
+ BOOST_FOREACH(auto const& option_desc, range) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(code, option_desc.option_->getType());
}
}
@@ -1544,10 +1541,9 @@ TEST(Subnet6Test, addVendorOption) {
// Validate codes of options added to dhcp6 option space.
uint16_t expected_code = 100;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
@@ -1557,10 +1553,9 @@ TEST(Subnet6Test, addVendorOption) {
// Validate codes of options added to isc option space.
expected_code = 105;
- for (OptionContainer::const_iterator option_desc = options->begin();
- option_desc != options->end(); ++option_desc) {
- ASSERT_TRUE(option_desc->option_);
- EXPECT_EQ(expected_code, option_desc->option_->getType());
+ for (auto const& option_desc : *options) {
+ ASSERT_TRUE(option_desc.option_);
+ EXPECT_EQ(expected_code, option_desc.option_->getType());
++expected_code;
}
diff --git a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc
index d1eba33643..fbc3c75b46 100644
--- a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc
@@ -295,12 +295,12 @@ TimerMgrTest::testUnregisterTimers() {
doWait(500);
// Make sure that all timers have been executed at least once.
- for (CallsCount::iterator it = calls_count_.begin();
- it != calls_count_.end(); ++it) {
- unsigned int calls_count = it->second;
+ size_t count = 0;
+ for (auto const& it : calls_count_) {
+ unsigned int calls_count = it.second;
ASSERT_GT(calls_count, 0)
- << "expected calls counter for timer"
- << (std::distance(calls_count_.begin(), it) + 1)
+ << "expected calls counter for timer "
+ << ++count
<< " greater than 0";
}
diff --git a/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc b/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc
index 55540e0aae..462dbdfa09 100644
--- a/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc
+++ b/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc
@@ -13,6 +13,8 @@
#include <typeinfo>
#include <testutils/gtest_utils.h>
+#include <boost/range/adaptor/reversed.hpp>
+
using namespace isc::data;
using namespace isc::db;
@@ -168,11 +170,13 @@ GenericBackendTest::testNewAuditEntry(const std::string& exp_object_type,
// Iterate over specified number of entries starting from the most recent
// one and check they have correct values.
- for (auto audit_entry_it = mod_time_idx.rbegin();
- ((std::distance(mod_time_idx.rbegin(), audit_entry_it) < new_entries_num) &&
- (std::distance(mod_time_idx.rbegin(), audit_entry_it) < max_tested_entries));
- ++audit_entry_it) {
- auto audit_entry = *audit_entry_it;
+ size_t count = 0;
+ for (auto const& audit_entry_it : boost::adaptors::reverse(mod_time_idx)) {
+ if (count >= new_entries_num || count >= max_tested_entries) {
+ break;
+ }
+ count++;
+ auto audit_entry = audit_entry_it;
EXPECT_EQ(exp_object_type, audit_entry->getObjectType())
<< logExistingAuditEntries(tag);
EXPECT_EQ(exp_modification_type, audit_entry->getModificationType())
@@ -219,11 +223,13 @@ GenericBackendTest::testNewAuditEntry(const std::vector<ExpAuditEntry>& exp_entr
// Iterate over specified number of entries starting from the most recent
// one and check they have correct values.
auto exp_entry = exp_entries.rbegin();
- for (auto audit_entry_it = mod_time_idx.rbegin();
- ((std::distance(mod_time_idx.rbegin(), audit_entry_it) < new_entries_num));
- ++audit_entry_it) {
-
- auto audit_entry = *audit_entry_it;
+ size_t count = 0;
+ for (auto const& audit_entry_it : boost::adaptors::reverse(mod_time_idx)) {
+ if (count >= new_entries_num) {
+ break;
+ }
+ count++;
+ auto audit_entry = audit_entry_it;
EXPECT_EQ((*exp_entry).object_type, audit_entry->getObjectType())
<< logExistingAuditEntries(tag);
EXPECT_EQ((*exp_entry).modification_type, audit_entry->getModificationType())
@@ -260,10 +266,8 @@ GenericBackendTest::logExistingAuditEntries(const std::string& server_tag) {
auto& mod_time_idx = audit_entries_[server_tag].get<AuditEntryModificationTimeIdTag>();
- for (auto audit_entry_it = mod_time_idx.begin();
- audit_entry_it != mod_time_idx.end();
- ++audit_entry_it) {
- auto audit_entry = *audit_entry_it;
+ for (auto const& audit_entry_it : mod_time_idx) {
+ auto audit_entry = audit_entry_it;
s << audit_entry->getObjectType() << ", "
<< audit_entry->getObjectId() << ", "
<< static_cast<int>(audit_entry->getModificationType()) << ", "
diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc
index 4d71fce430..4abf305689 100644
--- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc
+++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc
@@ -776,9 +776,9 @@ GenericConfigBackendDHCPv4Test::globalParameters4WithServerTagsTest() {
// Capture the returned values into the map so as we can check the
// values against the servers.
std::map<std::string, std::string> values;
- for (auto g = returned_globals.begin(); g != returned_globals.end(); ++g) {
- ASSERT_EQ(1, (*g)->getServerTags().size());
- values[(*g)->getServerTags().begin()->get()] = ((*g)->getValue());
+ for (auto const& g : returned_globals) {
+ ASSERT_EQ(1, g->getServerTags().size());
+ values[g->getServerTags().begin()->get()] = g->getValue();
}
ASSERT_EQ(3, values.size());
@@ -895,10 +895,9 @@ GenericConfigBackendDHCPv4Test::getAllGlobalParameters4Test() {
EXPECT_TRUE((*parameters_index.find("name4"))->getBoolValue());
EXPECT_EQ(1.65, (*parameters_index.find("name5"))->getDoubleValue());
- for (auto param = parameters_index.begin(); param != parameters_index.end();
- ++param) {
- ASSERT_EQ(1, (*param)->getServerTags().size());
- EXPECT_EQ("all", (*param)->getServerTags().begin()->get());
+ for (auto const& param : parameters_index) {
+ ASSERT_EQ(1, param->getServerTags().size());
+ EXPECT_EQ("all", param->getServerTags().begin()->get());
}
// Should be able to fetch these parameters when explicitly providing
@@ -3101,17 +3100,17 @@ GenericConfigBackendDHCPv4Test::getAllOptionDefs4Test() {
ASSERT_EQ(test_option_defs_.size() - updates_num, option_defs.size());
// See if option definitions are returned ok.
- for (auto def = option_defs.begin(); def != option_defs.end(); ++def) {
- ASSERT_EQ(1, (*def)->getServerTags().size());
- EXPECT_EQ("all", (*def)->getServerTags().begin()->get());
+ for (auto const& def : option_defs) {
+ ASSERT_EQ(1, def->getServerTags().size());
+ EXPECT_EQ("all", def->getServerTags().begin()->get());
bool success = false;
for (auto i = 1; i < test_option_defs_.size(); ++i) {
- if ((*def)->equals(*test_option_defs_[i])) {
+ if (def->equals(*test_option_defs_[i])) {
success = true;
}
}
- ASSERT_TRUE(success) << "failed for option definition " << (*def)->getCode()
- << ", option space " << (*def)->getOptionSpaceName();
+ ASSERT_TRUE(success) << "failed for option definition " << def->getCode()
+ << ", option space " << def->getOptionSpaceName();
}
// Deleting non-existing option definition should return 0.
@@ -4610,12 +4609,13 @@ GenericConfigBackendDHCPv4Test::multipleAuditEntriesTest() {
// Check that partial retrieves return the right count.
auto& mod_time_idx = audit_entries.get<AuditEntryModificationTimeIdTag>();
- for (auto it = mod_time_idx.begin(); it != mod_time_idx.end(); ++it) {
+ size_t distance = mod_time_idx.size();
+ for (auto const& it : mod_time_idx) {
size_t partial_size =
cbptr_->getRecentAuditEntries(server_selector,
- (*it)->getModificationTime(),
- (*it)->getRevisionId()).size();
- EXPECT_EQ(partial_size + 1,
- std::distance(it, mod_time_idx.end()));
+ it->getModificationTime(),
+ it->getRevisionId()).size();
+ EXPECT_EQ(partial_size + 1, distance);
+ distance--;
}
}
diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
index 62985934c5..b9cf42b1eb 100644
--- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
+++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
@@ -808,9 +808,9 @@ GenericConfigBackendDHCPv6Test::globalParameters6WithServerTagsTest() {
// Capture the returned values into the map so as we can check the
// values against the servers.
std::map<std::string, std::string> values;
- for (auto g = returned_globals.begin(); g != returned_globals.end(); ++g) {
- ASSERT_EQ(1, (*g)->getServerTags().size());
- values[(*g)->getServerTags().begin()->get()] = ((*g)->getValue());
+ for (auto const& g : returned_globals) {
+ ASSERT_EQ(1, g->getServerTags().size());
+ values[g->getServerTags().begin()->get()] = g->getValue();
}
ASSERT_EQ(3, values.size());
@@ -927,10 +927,9 @@ GenericConfigBackendDHCPv6Test::getAllGlobalParameters6Test() {
EXPECT_TRUE((*parameters_index.find("name4"))->getBoolValue());
EXPECT_EQ(1.65, (*parameters_index.find("name5"))->getDoubleValue());
- for (auto param = parameters_index.begin(); param != parameters_index.end();
- ++param) {
- ASSERT_EQ(1, (*param)->getServerTags().size());
- EXPECT_EQ("all", (*param)->getServerTags().begin()->get());
+ for (auto const& param : parameters_index) {
+ ASSERT_EQ(1, param->getServerTags().size());
+ EXPECT_EQ("all", param->getServerTags().begin()->get());
}
// Should be able to fetch these parameters when explicitly providing
@@ -3127,17 +3126,17 @@ GenericConfigBackendDHCPv6Test::getAllOptionDefs6Test() {
ASSERT_EQ(test_option_defs_.size() - updates_num, option_defs.size());
// See if option definitions are returned ok.
- for (auto def = option_defs.begin(); def != option_defs.end(); ++def) {
- ASSERT_EQ(1, (*def)->getServerTags().size());
- EXPECT_EQ("all", (*def)->getServerTags().begin()->get());
+ for (auto const& def : option_defs) {
+ ASSERT_EQ(1, def->getServerTags().size());
+ EXPECT_EQ("all", def->getServerTags().begin()->get());
bool success = false;
for (auto i = 1; i < test_option_defs_.size(); ++i) {
- if ((*def)->equals(*test_option_defs_[i])) {
+ if (def->equals(*test_option_defs_[i])) {
success = true;
}
}
- ASSERT_TRUE(success) << "failed for option definition " << (*def)->getCode()
- << ", option space " << (*def)->getOptionSpaceName();
+ ASSERT_TRUE(success) << "failed for option definition " << def->getCode()
+ << ", option space " << def->getOptionSpaceName();
}
// Deleting non-existing option definition should return 0.
@@ -4761,12 +4760,13 @@ GenericConfigBackendDHCPv6Test::multipleAuditEntriesTest() {
// Check that partial retrieves return the right count.
auto& mod_time_idx = audit_entries.get<AuditEntryModificationTimeIdTag>();
- for (auto it = mod_time_idx.begin(); it != mod_time_idx.end(); ++it) {
+ size_t distance = mod_time_idx.size();
+ for (auto const& it : mod_time_idx) {
size_t partial_size =
cbptr_->getRecentAuditEntries(server_selector,
- (*it)->getModificationTime(),
- (*it)->getRevisionId()).size();
- EXPECT_EQ(partial_size + 1,
- std::distance(it, mod_time_idx.end()));
+ it->getModificationTime(),
+ it->getRevisionId()).size();
+ EXPECT_EQ(partial_size + 1, distance);
+ distance--;
}
}
diff --git a/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc b/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc
index f3caa3f8c6..c14e398c67 100644
--- a/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc
+++ b/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc
@@ -1446,22 +1446,20 @@ GenericHostDataSourceTest::testHostname(std::string name, int num) {
}
// Now add them all to the host data source.
- for (vector<HostPtr>::const_iterator it = hosts.begin(); it != hosts.end();
- ++it) {
+ for (auto const& it : hosts) {
// Try to add both of the to the host data source.
- ASSERT_NO_THROW(hdsptr_->add(*it));
+ ASSERT_NO_THROW(hdsptr_->add(it));
}
// And finally retrieve them one by one and check
// if the hostname was preserved.
- for (vector<HostPtr>::const_iterator it = hosts.begin(); it != hosts.end();
- ++it) {
+ for (auto const& it : hosts) {
ConstHostPtr from_hds;
- ASSERT_NO_THROW(from_hds = hdsptr_->get4((*it)->getIPv4SubnetID(),
- (*it)->getIPv4Reservation()));
+ ASSERT_NO_THROW(from_hds = hdsptr_->get4(it->getIPv4SubnetID(),
+ it->getIPv4Reservation()));
ASSERT_TRUE(from_hds);
- EXPECT_EQ((*it)->getHostname(), from_hds->getHostname());
+ EXPECT_EQ(it->getHostname(), from_hds->getHostname());
}
}
@@ -1542,10 +1540,9 @@ GenericHostDataSourceTest::testMultipleSubnets(int subnets,
// Verify that the values returned are proper.
int i = 0;
- for (ConstHostCollection::const_iterator it = all_by_addr.begin();
- it != all_by_addr.end(); ++it) {
- EXPECT_EQ(IOAddress("192.0.2.1"), (*it)->getIPv4Reservation());
- EXPECT_EQ(1000 + i++, (*it)->getIPv4SubnetID());
+ for (auto const& it : all_by_addr) {
+ EXPECT_EQ(IOAddress("192.0.2.1"), it->getIPv4Reservation());
+ EXPECT_EQ(1000 + i++, it->getIPv4SubnetID());
}
// Finally, check that the hosts can be retrieved by HW address or DUID
@@ -1555,10 +1552,9 @@ GenericHostDataSourceTest::testMultipleSubnets(int subnets,
// Check that the returned values are as expected.
i = 0;
- for (ConstHostCollection::const_iterator it = all_by_id.begin();
- it != all_by_id.end(); ++it) {
- EXPECT_EQ(IOAddress("192.0.2.1"), (*it)->getIPv4Reservation());
- EXPECT_EQ(1000 + i++, (*it)->getIPv4SubnetID());
+ for (auto const& it : all_by_id) {
+ EXPECT_EQ(IOAddress("192.0.2.1"), it->getIPv4Reservation());
+ EXPECT_EQ(1000 + i++, it->getIPv4SubnetID());
}
}
@@ -1678,10 +1674,9 @@ GenericHostDataSourceTest::testSubnetId6(int subnets, Host::IdentifierType id) {
// Check that the returned values are as expected.
int i = 0;
- for (ConstHostCollection::const_iterator it = all_by_id.begin();
- it != all_by_id.end(); ++it) {
- EXPECT_EQ(IOAddress("0.0.0.0"), (*it)->getIPv4Reservation());
- EXPECT_EQ(1000 + i++, (*it)->getIPv6SubnetID());
+ for (auto const& it : all_by_id) {
+ EXPECT_EQ(IOAddress("0.0.0.0"), it->getIPv4Reservation());
+ EXPECT_EQ(1000 + i++, it->getIPv6SubnetID());
}
}
@@ -2354,9 +2349,8 @@ GenericHostDataSourceTest::stressTest(unsigned int nOfHosts /* = 0xfffdU */) {
start = (struct timespec){0, 0};
end = (struct timespec){0, 0};
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
- for (std::vector<HostPtr>::const_iterator it = hosts.begin();
- it != hosts.end(); it++) {
- ASSERT_NO_THROW(hdsptr_->add(*it));
+ for (auto const& it : hosts) {
+ ASSERT_NO_THROW(hdsptr_->add(it));
}
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
double s = static_cast<double>(end.tv_sec - start.tv_sec) +
@@ -2371,15 +2365,14 @@ GenericHostDataSourceTest::stressTest(unsigned int nOfHosts /* = 0xfffdU */) {
start = (struct timespec){0, 0};
end = (struct timespec){0, 0};
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
- for (std::vector<HostPtr>::const_iterator it = hosts.begin();
- it != hosts.end(); it++) {
- IPv6ResrvRange range = (*it)->getIPv6Reservations();
+ for (auto const& it : hosts) {
+ IPv6ResrvRange range = it->getIPv6Reservations();
// This get6() call is particularly useful to test because it involves a
// subquery for MySQL and PostgreSQL.
ConstHostPtr from_hds =
hdsptr_->get6(range.first->second.getPrefix(), 128);
ASSERT_TRUE(from_hds);
- HostDataSourceUtils::compareHosts(*it, from_hds);
+ HostDataSourceUtils::compareHosts(it, from_hds);
}
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
s = static_cast<double>(end.tv_sec - start.tv_sec) +
diff --git a/src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc b/src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc
index 9e1d87c9eb..e832efec09 100644
--- a/src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc
@@ -20,7 +20,7 @@
#include <testutils/gtest_utils.h>
#include <util/bigints.h>
-#include <boost/foreach.hpp>
+#include <boost/range/adaptor/reversed.hpp>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
@@ -575,20 +575,18 @@ GenericLeaseMgrTest::testGetLease4HWAddr2() {
// Check the lease[5] (and only this one) has an user context.
size_t contexts = 0;
- for (Lease4Collection::const_iterator i = returned.begin();
- i != returned.end(); ++i) {
- if ((*i)->getContext()) {
+ for (auto const& i : returned) {
+ if (i->getContext()) {
++contexts;
- EXPECT_EQ("{ \"foo\": true }", (*i)->getContext()->str());
+ EXPECT_EQ("{ \"foo\": true }", i->getContext()->str());
}
}
EXPECT_EQ(1, contexts);
// Easiest way to check is to look at the addresses.
vector<string> addresses;
- for (Lease4Collection::const_iterator i = returned.begin();
- i != returned.end(); ++i) {
- addresses.push_back((*i)->addr_.toText());
+ for (auto const& i : returned) {
+ addresses.push_back(i->addr_.toText());
}
sort(addresses.begin(), addresses.end());
EXPECT_EQ(straddress4_[1], addresses[0]);
@@ -1172,20 +1170,18 @@ GenericLeaseMgrTest::testGetLease4ClientId2() {
// Check the lease[5] (and only this one) has an user context.
size_t contexts = 0;
- for (Lease4Collection::const_iterator i = returned.begin();
- i != returned.end(); ++i) {
- if ((*i)->getContext()) {
+ for (auto const& i : returned) {
+ if (i->getContext()) {
++contexts;
- EXPECT_EQ("{ \"foo\": true }", (*i)->getContext()->str());
+ EXPECT_EQ("{ \"foo\": true }", i->getContext()->str());
}
}
EXPECT_EQ(1, contexts);
// Easiest way to check is to look at the addresses.
vector<string> addresses;
- for (Lease4Collection::const_iterator i = returned.begin();
- i != returned.end(); ++i) {
- addresses.push_back((*i)->addr_.toText());
+ for (auto const& i : returned) {
+ addresses.push_back(i->addr_.toText());
}
sort(addresses.begin(), addresses.end());
EXPECT_EQ(straddress4_[1], addresses[0]);
@@ -1335,7 +1331,7 @@ GenericLeaseMgrTest::testGetLeases4Paged() {
Lease4Collection page = lmptr_->getLeases4(last_address, LeasePageSize(3));
// Collect leases in a common structure. They may be out of order.
- for (const Lease4Ptr& lease : page) {
+ for (auto const& lease : page) {
all_leases.push_back(lease);
}
@@ -1356,9 +1352,9 @@ GenericLeaseMgrTest::testGetLeases4Paged() {
// Make sure that all leases that we stored in the lease database
// have been retrieved.
- for (const Lease4Ptr& lease : leases) {
+ for (auto const& lease : leases) {
bool found = false;
- for (const Lease4Ptr& returned_lease : all_leases) {
+ for (auto const& returned_lease : all_leases) {
if (lease->addr_ == returned_lease->addr_) {
found = true;
break;
@@ -1421,7 +1417,7 @@ GenericLeaseMgrTest::testGetLeases6SubnetIdPaged() {
LeasePageSize(3));
// Collect leases in a common structure.
- for (Lease6Ptr lease : page) {
+ for (auto const& lease : page) {
all_leases.push_back(lease);
}
@@ -1440,12 +1436,12 @@ GenericLeaseMgrTest::testGetLeases6SubnetIdPaged() {
// Make sure that all leases that we stored in the lease database
// have been retrieved at the exception of the third.
- for (Lease6Ptr lease : leases) {
+ for (auto const& lease : leases) {
if (lease == leases[3]) {
continue;
}
bool found = false;
- for (Lease6Ptr returned_lease : all_leases) {
+ for (auto const& returned_lease : all_leases) {
if (lease->addr_ == returned_lease->addr_) {
found = true;
break;
@@ -1517,7 +1513,7 @@ GenericLeaseMgrTest::testGetLeases6Paged() {
Lease6Collection page = lmptr_->getLeases6(last_address, LeasePageSize(3));
// Collect leases in a common structure. They may be out of order.
- for (const Lease6Ptr& lease : page) {
+ for (auto const& lease : page) {
all_leases.push_back(lease);
}
@@ -1538,9 +1534,9 @@ GenericLeaseMgrTest::testGetLeases6Paged() {
// Make sure that all leases that we stored in the lease database
// have been retrieved.
- for (const Lease6Ptr& lease : leases) {
+ for (auto const& lease : leases) {
bool found = false;
- for (const Lease6Ptr& returned_lease : all_leases) {
+ for (auto const& returned_lease : all_leases) {
if (lease->addr_ == returned_lease->addr_) {
found = true;
break;
@@ -1576,9 +1572,8 @@ GenericLeaseMgrTest::testGetLeases6DuidIaid() {
// Easiest way to check is to look at the addresses.
vector<string> addresses;
- for (Lease6Collection::const_iterator i = returned.begin();
- i != returned.end(); ++i) {
- addresses.push_back((*i)->addr_.toText());
+ for (auto const& i : returned) {
+ addresses.push_back(i->addr_.toText());
}
sort(addresses.begin(), addresses.end());
EXPECT_EQ(straddress6_[1], addresses[0]);
@@ -1694,9 +1689,8 @@ GenericLeaseMgrTest::testLease6LeaseTypeCheck() {
// Collection order returned is not guaranteed.
// Easiest way to check is to look at the addresses.
vector<string> addresses;
- for (Lease6Collection::const_iterator it = returned.begin();
- it != returned.end(); ++it) {
- addresses.push_back((*it)->addr_.toText());
+ for (auto const& it : returned) {
+ addresses.push_back(it->addr_.toText());
}
auto compare_addr = [](const string& left, const string& right) {
@@ -2205,13 +2199,13 @@ GenericLeaseMgrTest::testGetExpiredLeases4() {
// The expired leases should be returned from the most to least expired.
// This matches the reverse order to which they have been added.
- for (Lease4Collection::reverse_iterator lease = expired_leases.rbegin();
- lease != expired_leases.rend(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.rbegin(), lease));
+ size_t count = 0;
+ for (auto const& lease : boost::adaptors::reverse(expired_leases)) {
+ int index = count++;
// Multiple current index by two, because only leases with even indexes
// should have been returned.
ASSERT_LE(2 * index, leases.size());
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
}
// Update current time for the next test.
@@ -2239,11 +2233,11 @@ GenericLeaseMgrTest::testGetExpiredLeases4() {
ASSERT_EQ(static_cast<size_t>(leases.size() / 2), expired_leases.size());
// This time leases should be returned in the non-reverse order.
- for (Lease4Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
ASSERT_LE(2 * index, leases.size());
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
}
// Remember expired leases returned.
@@ -2259,11 +2253,11 @@ GenericLeaseMgrTest::testGetExpiredLeases4() {
ASSERT_EQ(2, expired_leases.size());
// Test that most expired leases have been returned.
- for (Lease4Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
ASSERT_LE(2 * index, leases.size());
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
}
// Mark every other expired lease as reclaimed.
@@ -2284,10 +2278,10 @@ GenericLeaseMgrTest::testGetExpiredLeases4() {
// Make sure that returned leases are those that are not reclaimed, i.e.
// those that have even index.
- for (Lease4Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
- EXPECT_EQ(saved_expired_leases[2 * index]->addr_, (*lease)->addr_);
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
+ EXPECT_EQ(saved_expired_leases[2 * index]->addr_, lease->addr_);
}
}
@@ -2327,12 +2321,12 @@ GenericLeaseMgrTest::testGetExpiredLeases6() {
// The expired leases should be returned from the most to least expired.
// This matches the reverse order to which they have been added.
- for (Lease6Collection::reverse_iterator lease = expired_leases.rbegin();
- lease != expired_leases.rend(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.rbegin(), lease));
+ size_t count = 0;
+ for (auto const& lease : boost::adaptors::reverse(expired_leases)) {
+ int index = count++;
// Multiple current index by two, because only leases with even indexes
// should have been returned.
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
}
// Update current time for the next test.
@@ -2361,10 +2355,10 @@ GenericLeaseMgrTest::testGetExpiredLeases6() {
ASSERT_EQ(static_cast<size_t>(leases.size() / 2), expired_leases.size());
// This time leases should be returned in the non-reverse order.
- for (Lease6Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
}
// Remember expired leases returned.
@@ -2380,10 +2374,10 @@ GenericLeaseMgrTest::testGetExpiredLeases6() {
ASSERT_EQ(2, expired_leases.size());
// Test that most expired leases have been returned.
- for (Lease6Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
}
// Mark every other expired lease as reclaimed.
@@ -2404,10 +2398,10 @@ GenericLeaseMgrTest::testGetExpiredLeases6() {
// Make sure that returned leases are those that are not reclaimed, i.e.
// those that have even index.
- for (Lease6Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
- EXPECT_EQ(saved_expired_leases[2 * index]->addr_, (*lease)->addr_);
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
+ EXPECT_EQ(saved_expired_leases[2 * index]->addr_, lease->addr_);
}
}
@@ -2708,17 +2702,17 @@ GenericLeaseMgrTest::testGetDeclinedLeases4() {
// The expired leases should be returned from the most to least expired.
// This matches the reverse order to which they have been added.
- for (Lease4Collection::reverse_iterator lease = expired_leases.rbegin();
- lease != expired_leases.rend(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.rbegin(), lease));
+ size_t count = 0;
+ for (auto const& lease : boost::adaptors::reverse(expired_leases)) {
+ int index = count++;
// Multiple current index by two, because only leases with even indexes
// should have been returned.
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
// Count leases in default and declined states
- if ((*lease)->state_ == Lease::STATE_DEFAULT) {
+ if (lease->state_ == Lease::STATE_DEFAULT) {
default_state++;
- } else if ((*lease)->state_ == Lease::STATE_DECLINED) {
+ } else if (lease->state_ == Lease::STATE_DECLINED) {
declined_state++;
}
}
@@ -2763,15 +2757,15 @@ GenericLeaseMgrTest::testGetDeclinedLeases4() {
// This time leases should be returned in the non-reverse order.
declined_state = 0;
default_state = 0;
- for (Lease4Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
// Count leases in default and declined states
- if ((*lease)->state_ == Lease::STATE_DEFAULT) {
+ if (lease->state_ == Lease::STATE_DEFAULT) {
default_state++;
- } else if ((*lease)->state_ == Lease::STATE_DECLINED) {
+ } else if (lease->state_ == Lease::STATE_DECLINED) {
declined_state++;
}
}
@@ -2790,10 +2784,10 @@ GenericLeaseMgrTest::testGetDeclinedLeases4() {
ASSERT_EQ(2, expired_leases.size());
// Test that most expired leases have been returned.
- for (Lease4Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
}
}
@@ -2858,17 +2852,17 @@ GenericLeaseMgrTest::testGetDeclinedLeases6() {
// The expired leases should be returned from the most to least expired.
// This matches the reverse order to which they have been added.
- for (Lease6Collection::reverse_iterator lease = expired_leases.rbegin();
- lease != expired_leases.rend(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.rbegin(), lease));
+ size_t count = 0;
+ for (auto const& lease : boost::adaptors::reverse(expired_leases)) {
+ int index = count++;
// Multiple current index by two, because only leases with even indexes
// should have been returned.
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
// Count leases in default and declined states
- if ((*lease)->state_ == Lease::STATE_DEFAULT) {
+ if (lease->state_ == Lease::STATE_DEFAULT) {
default_state++;
- } else if ((*lease)->state_ == Lease::STATE_DECLINED) {
+ } else if (lease->state_ == Lease::STATE_DECLINED) {
declined_state++;
}
}
@@ -2913,15 +2907,15 @@ GenericLeaseMgrTest::testGetDeclinedLeases6() {
// This time leases should be returned in the non-reverse order.
declined_state = 0;
default_state = 0;
- for (Lease6Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
// Count leases in default and declined states
- if ((*lease)->state_ == Lease::STATE_DEFAULT) {
+ if (lease->state_ == Lease::STATE_DEFAULT) {
default_state++;
- } else if ((*lease)->state_ == Lease::STATE_DECLINED) {
+ } else if (lease->state_ == Lease::STATE_DECLINED) {
declined_state++;
}
}
@@ -2940,10 +2934,10 @@ GenericLeaseMgrTest::testGetDeclinedLeases6() {
ASSERT_EQ(2, expired_leases.size());
// Test that most expired leases have been returned.
- for (Lease6Collection::iterator lease = expired_leases.begin();
- lease != expired_leases.end(); ++lease) {
- int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
- EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+ count = 0;
+ for (auto const& lease : expired_leases) {
+ int index = count++;
+ EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
}
}
@@ -2955,7 +2949,7 @@ GenericLeaseMgrTest::checkLeaseStats(const StatValMapList& expectedStats) {
// Iterate over all stats for each subnet
for (int subnet_idx = 0; subnet_idx < expectedStats.size(); ++subnet_idx) {
- BOOST_FOREACH(StatValPair expectedStat, expectedStats[subnet_idx]) {
+ for (auto const& expectedStat : expectedStats[subnet_idx]) {
// Verify the per subnet value.
checkStat(stats::StatsMgr::generateName("subnet", subnet_idx + 1,
expectedStat.first),
@@ -3886,9 +3880,9 @@ GenericLeaseMgrTest::checkLeaseRange(const Lease4Collection& returned,
const std::vector<std::string>& expected_addresses) {
ASSERT_EQ(expected_addresses.size(), returned.size());
- for (auto a = returned.cbegin(); a != returned.cend(); ++a) {
- EXPECT_EQ(expected_addresses[std::distance(returned.cbegin(), a)],
- (*a)->addr_.toText());
+ size_t count = 0;
+ for (auto const& a : returned) {
+ EXPECT_EQ(expected_addresses[count++], a->addr_.toText());
}
}
diff --git a/src/lib/dhcpsrv/testutils/host_data_source_utils.cc b/src/lib/dhcpsrv/testutils/host_data_source_utils.cc
index 8d378d0e31..5be6a2b72d 100644
--- a/src/lib/dhcpsrv/testutils/host_data_source_utils.cc
+++ b/src/lib/dhcpsrv/testutils/host_data_source_utils.cc
@@ -8,10 +8,11 @@
#include <dhcpsrv/testutils/host_data_source_utils.h>
#include <asiolink/io_address.h>
-#include <boost/foreach.hpp>
#include <cc/data.h>
#include <gtest/gtest.h>
+#include <boost/foreach.hpp>
+
using namespace std;
using namespace isc::data;
using namespace isc::asiolink;
@@ -128,8 +129,8 @@ HostDataSourceUtils::initializeHost6(std::string address,
bool
HostDataSourceUtils::reservationExists(const IPv6Resrv& resrv,
const IPv6ResrvRange& range) {
- for (IPv6ResrvIterator it = range.first; it != range.second; ++it) {
- if (resrv == it->second) {
+ BOOST_FOREACH(auto const& it, range) {
+ if (resrv == it.second) {
return true;
}
}
@@ -332,7 +333,7 @@ HostDataSourceUtils::compareOptions(const ConstCfgOptionPtr& cfg1,
EXPECT_EQ(vendor_spaces.size(), cfg1->getVendorIdsSpaceNames().size());
// Iterate over all option spaces existing in cfg2.
- BOOST_FOREACH (std::string space, option_spaces) {
+ for (auto const& space : option_spaces) {
// Retrieve options belonging to the current option space.
OptionContainerPtr options1 = cfg1->getAll(space);
OptionContainerPtr options2 = cfg2->getAll(space);
@@ -344,7 +345,7 @@ HostDataSourceUtils::compareOptions(const ConstCfgOptionPtr& cfg1,
<< "failed for option space " << space;
// Iterate over all options within this option space.
- BOOST_FOREACH (OptionDescriptor desc1, *options1) {
+ for (auto const& desc1 : *options1) {
OptionDescriptor desc2 = cfg2->get(space, desc1.option_->getType());
// Compare persistent flag.
EXPECT_EQ(desc1.persistent_, desc2.persistent_)
diff --git a/src/lib/dhcpsrv/testutils/memory_host_data_source.cc b/src/lib/dhcpsrv/testutils/memory_host_data_source.cc
index ef1b2bcd64..f570a4ac04 100644
--- a/src/lib/dhcpsrv/testutils/memory_host_data_source.cc
+++ b/src/lib/dhcpsrv/testutils/memory_host_data_source.cc
@@ -7,6 +7,7 @@
#include <config.h>
#include <dhcpsrv/testutils/memory_host_data_source.h>
+#include <boost/foreach.hpp>
using namespace isc::db;
using namespace std;
@@ -21,14 +22,14 @@ MemHostDataSource::getAll(const Host::IdentifierType& identifier_type,
const size_t identifier_len) const {
vector<uint8_t> ident(identifier_begin, identifier_begin + identifier_len);
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// If identifier type do not match, it's not for us
- if ((*h)->getIdentifierType() != identifier_type) {
+ if (h->getIdentifierType() != identifier_type) {
continue;
}
// If the identifier matches, we found one!
- if ((*h)->getIdentifier() == ident) {
- hosts.push_back(*h);
+ if (h->getIdentifier() == ident) {
+ hosts.push_back(h);
}
}
return (hosts);
@@ -37,10 +38,10 @@ MemHostDataSource::getAll(const Host::IdentifierType& identifier_type,
ConstHostCollection
MemHostDataSource::getAll4(const SubnetID& subnet_id) const {
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// Keep it when subnet_id matches.
- if ((*h)->getIPv4SubnetID() == subnet_id) {
- hosts.push_back(*h);
+ if (h->getIPv4SubnetID() == subnet_id) {
+ hosts.push_back(h);
}
}
return (hosts);
@@ -49,10 +50,10 @@ MemHostDataSource::getAll4(const SubnetID& subnet_id) const {
ConstHostCollection
MemHostDataSource::getAll6(const SubnetID& subnet_id) const {
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// Keep it when subnet_id matches.
- if ((*h)->getIPv6SubnetID() == subnet_id) {
- hosts.push_back(*h);
+ if (h->getIPv6SubnetID() == subnet_id) {
+ hosts.push_back(h);
}
}
return (hosts);
@@ -61,10 +62,10 @@ MemHostDataSource::getAll6(const SubnetID& subnet_id) const {
ConstHostCollection
MemHostDataSource::getAllbyHostname(const std::string& hostname) const {
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// Keep it when hostname matches.
- if ((*h)->getLowerHostname() == hostname) {
- hosts.push_back(*h);
+ if (h->getLowerHostname() == hostname) {
+ hosts.push_back(h);
}
}
return (hosts);
@@ -74,11 +75,11 @@ ConstHostCollection
MemHostDataSource::getAllbyHostname4(const std::string& hostname,
const SubnetID& subnet_id) const {
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// Keep it when hostname and subnet_id match.
- if (((*h)->getLowerHostname() == hostname) &&
- ((*h)->getIPv4SubnetID() == subnet_id)) {
- hosts.push_back(*h);
+ if ((h->getLowerHostname() == hostname) &&
+ (h->getIPv4SubnetID() == subnet_id)) {
+ hosts.push_back(h);
}
}
return (hosts);
@@ -88,11 +89,11 @@ ConstHostCollection
MemHostDataSource::getAllbyHostname6(const std::string& hostname,
const SubnetID& subnet_id) const {
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// Keep it when hostname and subnet_id match.
- if (((*h)->getLowerHostname() == hostname) &&
- ((*h)->getIPv6SubnetID() == subnet_id)) {
- hosts.push_back(*h);
+ if ((h->getLowerHostname() == hostname) &&
+ (h->getIPv6SubnetID() == subnet_id)) {
+ hosts.push_back(h);
}
}
return (hosts);
@@ -104,15 +105,15 @@ MemHostDataSource::getPage4(const SubnetID& subnet_id,
uint64_t lower_host_id,
const HostPageSize& page_size) const {
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// Skip it when subnet_id does not match.
- if ((*h)->getIPv4SubnetID() != subnet_id) {
+ if (h->getIPv4SubnetID() != subnet_id) {
continue;
}
- if (lower_host_id && ((*h)->getHostId() <= lower_host_id)) {
+ if (lower_host_id && (h->getHostId() <= lower_host_id)) {
continue;
}
- hosts.push_back(*h);
+ hosts.push_back(h);
if (hosts.size() == page_size.page_size_) {
break;
}
@@ -126,15 +127,15 @@ MemHostDataSource::getPage6(const SubnetID& subnet_id,
uint64_t lower_host_id,
const HostPageSize& page_size) const {
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// Skip it when subnet_id does not match.
- if ((*h)->getIPv6SubnetID() != subnet_id) {
+ if (h->getIPv6SubnetID() != subnet_id) {
continue;
}
- if (lower_host_id && ((*h)->getHostId() <= lower_host_id)) {
+ if (lower_host_id && (h->getHostId() <= lower_host_id)) {
continue;
}
- hosts.push_back(*h);
+ hosts.push_back(h);
if (hosts.size() == page_size.page_size_) {
break;
}
@@ -147,11 +148,11 @@ MemHostDataSource::getPage4(size_t& /*source_index*/,
uint64_t lower_host_id,
const HostPageSize& page_size) const {
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
- if (lower_host_id && ((*h)->getHostId() <= lower_host_id)) {
+ for (auto const& h : store_) {
+ if (lower_host_id && (h->getHostId() <= lower_host_id)) {
continue;
}
- hosts.push_back(*h);
+ hosts.push_back(h);
if (hosts.size() == page_size.page_size_) {
break;
}
@@ -164,11 +165,11 @@ MemHostDataSource::getPage6(size_t& /*source_index*/,
uint64_t lower_host_id,
const HostPageSize& page_size) const {
ConstHostCollection hosts;
- for (auto h = store_.begin(); h != store_.end(); ++h) {
- if (lower_host_id && ((*h)->getHostId() <= lower_host_id)) {
+ for (auto const& h : store_) {
+ if (lower_host_id && (h->getHostId() <= lower_host_id)) {
continue;
}
- hosts.push_back(*h);
+ hosts.push_back(h);
if (hosts.size() == page_size.page_size_) {
break;
}
@@ -179,7 +180,7 @@ MemHostDataSource::getPage6(size_t& /*source_index*/,
ConstHostCollection
MemHostDataSource::getAll4(const asiolink::IOAddress& address) const {
ConstHostCollection hosts;
- for (auto const & h : store_) {
+ for (auto const& h : store_) {
if (h->getIPv4Reservation() == address) {
hosts.push_back(h);
}
@@ -194,16 +195,16 @@ MemHostDataSource::get4(const SubnetID& subnet_id,
const uint8_t* identifier_begin,
const size_t identifier_len) const {
vector<uint8_t> ident(identifier_begin, identifier_begin + identifier_len);
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// If either subnet-id or identifier type do not match,
// it's not our host
- if (((*h)->getIPv4SubnetID() != subnet_id) ||
- ((*h)->getIdentifierType() != identifier_type)) {
+ if ((h->getIPv4SubnetID() != subnet_id) ||
+ (h->getIdentifierType() != identifier_type)) {
continue;
}
// If the identifier matches, we found it!
- if ((*h)->getIdentifier() == ident) {
- return (*h);
+ if (h->getIdentifier() == ident) {
+ return (h);
}
}
@@ -217,16 +218,16 @@ MemHostDataSource::get6(const SubnetID& subnet_id,
const uint8_t* identifier_begin,
const size_t identifier_len) const {
vector<uint8_t> ident(identifier_begin, identifier_begin + identifier_len);
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// If either subnet-id or identifier type do not match,
// it's not our host
- if (((*h)->getIPv6SubnetID() != subnet_id) ||
- ((*h)->getIdentifierType() != identifier_type)) {
+ if ((h->getIPv6SubnetID() != subnet_id) ||
+ (h->getIdentifierType() != identifier_type)) {
continue;
}
// If the identifier matches, we found it!
- if ((*h)->getIdentifier() == ident) {
- return (*h);
+ if (h->getIdentifier() == ident) {
+ return (h);
}
}
@@ -236,10 +237,10 @@ MemHostDataSource::get6(const SubnetID& subnet_id,
ConstHostPtr
MemHostDataSource::get4(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const {
- for (auto h = store_.begin(); h != store_.end(); ++h) {
- if ((*h)->getIPv4SubnetID() == subnet_id &&
- (*h)->getIPv4Reservation() == address) {
- return (*h);
+ for (auto const& h : store_) {
+ if (h->getIPv4SubnetID() == subnet_id &&
+ h->getIPv4Reservation() == address) {
+ return (h);
}
}
@@ -250,7 +251,7 @@ ConstHostCollection
MemHostDataSource::getAll4(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const {
ConstHostCollection hosts;
- for (auto const & h : store_) {
+ for (auto const& h : store_) {
if (h->getIPv4SubnetID() == subnet_id &&
h->getIPv4Reservation() == address) {
hosts.push_back(h);
@@ -269,22 +270,22 @@ MemHostDataSource::get6(const asiolink::IOAddress& /*prefix*/,
ConstHostPtr
MemHostDataSource::get6(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const {
- for (auto h = store_.begin(); h != store_.end(); ++h) {
+ for (auto const& h : store_) {
// Naive approach: check hosts one by one
// First check: subnet-id must match.
- if ((*h)->getIPv6SubnetID() != subnet_id) {
+ if (h->getIPv6SubnetID() != subnet_id) {
// wrong subnet-id? ok, skip this one
continue;
}
// Second check: the v6 reservation must much. This is very simple
// as we ignore the reservation type.
- auto resrvs = (*h)->getIPv6Reservations();
- for (auto r = resrvs.first; r != resrvs.second; ++r) {
- if ((*r).second.getPrefix() == address) {
- return (*h);
+ auto const& resrvs = h->getIPv6Reservations();
+ BOOST_FOREACH(auto const& r, resrvs) {
+ if (r.second.getPrefix() == address) {
+ return (h);
}
}
}
@@ -296,14 +297,14 @@ ConstHostCollection
MemHostDataSource::getAll6(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const {
ConstHostCollection hosts;
- for (auto const & h : store_) {
+ for (auto const& h : store_) {
if (h->getIPv6SubnetID() != subnet_id) {
continue;
}
- auto resrvs = h->getIPv6Reservations();
- for (auto r = resrvs.first; r != resrvs.second; ++r) {
- if ((*r).second.getPrefix() == address) {
+ auto const& resrvs = h->getIPv6Reservations();
+ BOOST_FOREACH(auto const& r, resrvs) {
+ if (r.second.getPrefix() == address) {
hosts.push_back(h);
}
}
@@ -315,10 +316,10 @@ MemHostDataSource::getAll6(const SubnetID& subnet_id,
ConstHostCollection
MemHostDataSource::getAll6(const asiolink::IOAddress& address) const {
ConstHostCollection hosts;
- for (auto const & h : store_) {
- auto resrvs = h->getIPv6Reservations();
- for (auto r = resrvs.first; r != resrvs.second; ++r) {
- if ((*r).second.getPrefix() == address) {
+ for (auto const& h : store_) {
+ auto const& resrvs = h->getIPv6Reservations();
+ BOOST_FOREACH(auto const& r, resrvs) {
+ if (r.second.getPrefix() == address) {
hosts.push_back(h);
}
}
@@ -351,9 +352,9 @@ MemHostDataSource::del(const SubnetID& subnet_id,
// Second check: the v6 reservation must much. This is very simple
// as we ignore the reservation type.
- auto resrvs = (*h)->getIPv6Reservations();
- for (auto r = resrvs.first; r != resrvs.second; ++r) {
- if ((*r).second.getPrefix() == addr) {
+ auto const& resrvs = (*h)->getIPv6Reservations();
+ BOOST_FOREACH(auto const& r, resrvs) {
+ if (r.second.getPrefix() == addr) {
store_.erase(h);
return (true);
}
diff --git a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc
index 98be2a1337..51adf520fe 100644
--- a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc
+++ b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc
@@ -8,6 +8,7 @@
#include <database/database_connection.h>
#include <test_config_backend_dhcp4.h>
+#include <boost/foreach.hpp>
#include <list>
using namespace isc::data;
@@ -296,17 +297,15 @@ TestConfigBackendDHCPv4::getOptionDef4(const db::ServerSelector& server_selector
auto const& index = option_defs_.get<1>();
auto option_def_it_pair = index.equal_range(code);
- for (auto option_def_it = option_def_it_pair.first;
- option_def_it != option_def_it_pair.second;
- ++option_def_it) {
- if ((*option_def_it)->getOptionSpaceName() == space) {
+ BOOST_FOREACH(auto const& option_def_it, option_def_it_pair) {
+ if (option_def_it->getOptionSpaceName() == space) {
for (auto const& tag : tags) {
- if ((*option_def_it)->hasServerTag(ServerTag(tag))) {
- return (*option_def_it);
+ if (option_def_it->hasServerTag(ServerTag(tag))) {
+ return (option_def_it);
}
}
- if ((*option_def_it)->hasAllServerTag()) {
- candidate = *option_def_it;
+ if (option_def_it->hasAllServerTag()) {
+ candidate = option_def_it;
}
}
}
@@ -378,16 +377,15 @@ TestConfigBackendDHCPv4::getOption4(const db::ServerSelector& server_selector,
auto const& index = options_.get<1>();
auto option_it_pair = index.equal_range(code);
- for (auto option_it = option_it_pair.first; option_it != option_it_pair.second;
- ++option_it) {
- if (option_it->space_name_ == space) {
+ BOOST_FOREACH(auto const& option_it, option_it_pair) {
+ if (option_it.space_name_ == space) {
for (auto const& tag : tags) {
- if (option_it->hasServerTag(ServerTag(tag))) {
- return (OptionDescriptorPtr(new OptionDescriptor(*option_it)));
+ if (option_it.hasServerTag(ServerTag(tag))) {
+ return (OptionDescriptorPtr(new OptionDescriptor(option_it)));
}
}
- if (option_it->hasAllServerTag()) {
- candidate = OptionDescriptorPtr(new OptionDescriptor(*option_it));
+ if (option_it.hasAllServerTag()) {
+ candidate = OptionDescriptorPtr(new OptionDescriptor(option_it));
}
}
}
@@ -451,15 +449,14 @@ TestConfigBackendDHCPv4::getGlobalParameter4(const db::ServerSelector& server_se
auto candidate = StampedValuePtr();
auto const& index = globals_.get<StampedValueNameIndexTag>();
auto global_range = index.equal_range(name);
- for (auto global_it = global_range.first; global_it != global_range.second;
- ++global_it) {
+ BOOST_FOREACH(auto const& global_it, global_range) {
for (auto const& tag : tags) {
- if ((*global_it)->hasServerTag(ServerTag(tag))) {
- return (*global_it);
+ if (global_it->hasServerTag(ServerTag(tag))) {
+ return (global_it);
}
}
- if ((*global_it)->hasAllServerTag()) {
- candidate = *global_it;
+ if (global_it->hasAllServerTag()) {
+ candidate = global_it;
}
}
@@ -1091,9 +1088,9 @@ TestConfigBackendDHCPv4::deleteSharedNetwork4(const db::ServerSelector& server_s
}
// Remove this shared network.
- for (auto subnet = subnets_.begin(); subnet != subnets_.end(); ++subnet) {
- if ((*subnet)->getSharedNetworkName() == name) {
- (*subnet)->setSharedNetworkName("");
+ for (auto const& subnet : subnets_) {
+ if (subnet->getSharedNetworkName() == name) {
+ subnet->setSharedNetworkName("");
}
}
(*network_it)->delAll();
diff --git a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc
index 9a3fe1d6d7..c31b14745b 100644
--- a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc
+++ b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc
@@ -8,6 +8,7 @@
#include <database/database_connection.h>
#include <test_config_backend_dhcp6.h>
+#include <boost/foreach.hpp>
using namespace isc::data;
using namespace isc::db;
@@ -48,7 +49,7 @@ TestConfigBackendDHCPv6::getSubnet6(const db::ServerSelector& server_selector,
if (server_selector.amUnassigned()) {
return (subnet->getServerTags().empty() ? subnet : Subnet6Ptr());
}
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
return (subnet);
@@ -72,7 +73,7 @@ TestConfigBackendDHCPv6::getSubnet6(const db::ServerSelector& server_selector,
if (server_selector.amUnassigned()) {
return (subnet->getServerTags().empty() ? subnet : Subnet6Ptr());
}
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
return (subnet);
@@ -96,7 +97,7 @@ TestConfigBackendDHCPv6::getAllSubnets6(const db::ServerSelector& server_selecto
continue;
}
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
subnets.insert(subnet);
@@ -132,7 +133,7 @@ TestConfigBackendDHCPv6::getModifiedSubnets6(const db::ServerSelector& server_se
continue;
}
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if ((*subnet)->hasServerTag(ServerTag(tag))) {
subnets.insert(*subnet);
@@ -166,7 +167,7 @@ TestConfigBackendDHCPv6::getSharedNetworkSubnets6(const db::ServerSelector& serv
}
if (!server_selector.amAny()) {
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
got = true;
@@ -208,7 +209,7 @@ TestConfigBackendDHCPv6::getSharedNetwork6(const db::ServerSelector& server_sele
if (server_selector.amUnassigned()) {
return (network->getServerTags().empty() ? network : SharedNetwork6Ptr());
}
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (network->hasServerTag(ServerTag(tag))) {
return (network);
@@ -232,7 +233,7 @@ TestConfigBackendDHCPv6::getAllSharedNetworks6(const db::ServerSelector& server_
continue;
}
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
shared_networks.push_back(shared_network);
@@ -268,7 +269,7 @@ TestConfigBackendDHCPv6::getModifiedSharedNetworks6(const db::ServerSelector& se
continue;
}
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if ((*shared_network)->hasServerTag(ServerTag(tag))) {
shared_networks.push_back(*shared_network);
@@ -290,22 +291,20 @@ OptionDefinitionPtr
TestConfigBackendDHCPv6::getOptionDef6(const db::ServerSelector& server_selector,
const uint16_t code,
const std::string& space) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
auto candidate = OptionDefinitionPtr();
auto const& index = option_defs_.get<1>();
auto option_def_it_pair = index.equal_range(code);
- for (auto option_def_it = option_def_it_pair.first;
- option_def_it != option_def_it_pair.second;
- ++option_def_it) {
- if ((*option_def_it)->getOptionSpaceName() == space) {
+ BOOST_FOREACH(auto const& option_def_it, option_def_it_pair) {
+ if (option_def_it->getOptionSpaceName() == space) {
for (auto const& tag : tags) {
- if ((*option_def_it)->hasServerTag(ServerTag(tag))) {
- return (*option_def_it);
+ if (option_def_it->hasServerTag(ServerTag(tag))) {
+ return (option_def_it);
}
}
- if ((*option_def_it)->hasAllServerTag()) {
- candidate = *option_def_it;
+ if (option_def_it->hasAllServerTag()) {
+ candidate = option_def_it;
}
}
}
@@ -314,7 +313,7 @@ TestConfigBackendDHCPv6::getOptionDef6(const db::ServerSelector& server_selector
OptionDefContainer
TestConfigBackendDHCPv6::getAllOptionDefs6(const db::ServerSelector& server_selector) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
OptionDefContainer option_defs;
for (auto const& option_def : option_defs_) {
bool got = false;
@@ -345,7 +344,7 @@ TestConfigBackendDHCPv6::getAllOptionDefs6(const db::ServerSelector& server_sele
OptionDefContainer
TestConfigBackendDHCPv6::getModifiedOptionDefs6(const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
OptionDefContainer option_defs;
auto const& index = option_defs_.get<3>();
auto lb = index.lower_bound(modification_time);
@@ -372,21 +371,20 @@ OptionDescriptorPtr
TestConfigBackendDHCPv6::getOption6(const db::ServerSelector& server_selector,
const uint16_t code,
const std::string& space) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
auto candidate = OptionDescriptorPtr();
auto const& index = options_.get<1>();
auto option_it_pair = index.equal_range(code);
- for (auto option_it = option_it_pair.first; option_it != option_it_pair.second;
- ++option_it) {
- if (option_it->space_name_ == space) {
+ BOOST_FOREACH(auto const& option_it, option_it_pair) {
+ if (option_it.space_name_ == space) {
for (auto const& tag : tags) {
- if (option_it->hasServerTag(ServerTag(tag))) {
- return (OptionDescriptorPtr(new OptionDescriptor(*option_it)));
+ if (option_it.hasServerTag(ServerTag(tag))) {
+ return (OptionDescriptorPtr(new OptionDescriptor(option_it)));
}
}
- if (option_it->hasAllServerTag()) {
- candidate = OptionDescriptorPtr(new OptionDescriptor(*option_it));
+ if (option_it.hasAllServerTag()) {
+ candidate = OptionDescriptorPtr(new OptionDescriptor(option_it));
}
}
}
@@ -396,7 +394,7 @@ TestConfigBackendDHCPv6::getOption6(const db::ServerSelector& server_selector,
OptionContainer
TestConfigBackendDHCPv6::getAllOptions6(const db::ServerSelector& server_selector) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
OptionContainer options;
for (auto const& option : options_) {
bool got = false;
@@ -420,7 +418,7 @@ TestConfigBackendDHCPv6::getAllOptions6(const db::ServerSelector& server_selecto
OptionContainer
TestConfigBackendDHCPv6::getModifiedOptions6(const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
OptionContainer options;
auto const& index = options_.get<3>();
auto lb = index.lower_bound(modification_time);
@@ -446,19 +444,18 @@ TestConfigBackendDHCPv6::getModifiedOptions6(const db::ServerSelector& server_se
StampedValuePtr
TestConfigBackendDHCPv6::getGlobalParameter6(const db::ServerSelector& server_selector,
const std::string& name) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
auto candidate = StampedValuePtr();
auto const& index = globals_.get<StampedValueNameIndexTag>();
auto global_range = index.equal_range(name);
- for (auto global_it = global_range.first; global_it != global_range.second;
- ++global_it) {
+ BOOST_FOREACH(auto const& global_it, global_range) {
for (auto const& tag : tags) {
- if ((*global_it)->hasServerTag(ServerTag(tag))) {
- return (*global_it);
+ if (global_it->hasServerTag(ServerTag(tag))) {
+ return (global_it);
}
}
- if ((*global_it)->hasAllServerTag()) {
- candidate = *global_it;
+ if (global_it->hasAllServerTag()) {
+ candidate = global_it;
}
}
@@ -468,7 +465,7 @@ TestConfigBackendDHCPv6::getGlobalParameter6(const db::ServerSelector& server_se
StampedValueCollection
TestConfigBackendDHCPv6::getAllGlobalParameters6(const db::ServerSelector& server_selector) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
StampedValueCollection globals;
for (auto const& global : globals_) {
bool got = false;
@@ -492,7 +489,7 @@ TestConfigBackendDHCPv6::getAllGlobalParameters6(const db::ServerSelector& serve
StampedValueCollection
TestConfigBackendDHCPv6::getModifiedGlobalParameters6(const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
StampedValueCollection globals;
auto const& index = globals_.get<StampedValueModificationTimeIndexTag>();
auto lb = index.lower_bound(modification_time);
@@ -531,7 +528,7 @@ TestConfigBackendDHCPv6::getClientClass6(const db::ServerSelector& server_select
if (server_selector.amUnassigned()) {
return (client_class->getServerTags().empty() ? client_class : ClientClassDefPtr());
}
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
return (client_class);
@@ -542,7 +539,7 @@ TestConfigBackendDHCPv6::getClientClass6(const db::ServerSelector& server_select
ClientClassDictionary
TestConfigBackendDHCPv6::getAllClientClasses6(const db::ServerSelector& server_selector) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
ClientClassDictionary all_classes;
for (auto const& client_class : classes_) {
if (server_selector.amAny()) {
@@ -576,7 +573,7 @@ TestConfigBackendDHCPv6::getAllClientClasses6(const db::ServerSelector& server_s
ClientClassDictionary
TestConfigBackendDHCPv6::getModifiedClientClasses6(const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
ClientClassDictionary modified_classes;
for (auto const& client_class : classes_) {
if (client_class->getModificationTime() >= modification_time) {
@@ -695,7 +692,7 @@ TestConfigBackendDHCPv6::createUpdateSharedNetwork6(const db::ServerSelector& se
void
TestConfigBackendDHCPv6::createUpdateOptionDef6(const db::ServerSelector& server_selector,
const OptionDefinitionPtr& option_def) {
- auto tag = getServerTag(server_selector);
+ auto const& tag = getServerTag(server_selector);
option_def->setServerTag(tag);
// Index #1 is by option code.
@@ -734,7 +731,7 @@ TestConfigBackendDHCPv6::createUpdateOptionDef6(const db::ServerSelector& server
void
TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_selector,
const OptionDescriptorPtr& option) {
- auto tag = getServerTag(server_selector);
+ auto const& tag = getServerTag(server_selector);
option->setServerTag(tag);
auto& index = options_.get<1>();
@@ -776,7 +773,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
} else if (shared_network->hasAllServerTag()) {
found = true;
} else {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
found = true;
@@ -817,7 +814,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
} else if (subnet->hasAllServerTag()) {
found = true;
} else {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
found = true;
@@ -856,7 +853,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
}
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
@@ -910,7 +907,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
}
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
@@ -946,7 +943,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
void
TestConfigBackendDHCPv6::createUpdateGlobalParameter6(const db::ServerSelector& server_selector,
const data::StampedValuePtr& value) {
- auto tag = getServerTag(server_selector);
+ auto const& tag = getServerTag(server_selector);
value->setServerTag(tag);
auto& index = globals_.get<StampedValueNameIndexTag>();
@@ -991,7 +988,7 @@ TestConfigBackendDHCPv6::deleteSubnet6(const db::ServerSelector& server_selector
}
if (!server_selector.amAny()) {
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if ((*subnet_it)->hasServerTag(ServerTag(tag))) {
got = true;
@@ -1019,7 +1016,7 @@ TestConfigBackendDHCPv6::deleteSubnet6(const db::ServerSelector& server_selector
}
if (!server_selector.amAny()) {
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if ((*subnet_it)->hasServerTag(ServerTag(tag))) {
got = true;
@@ -1049,7 +1046,7 @@ TestConfigBackendDHCPv6::deleteAllSubnets6(const db::ServerSelector& server_sele
continue;
}
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
ids.push_back(subnet->getID());
@@ -1087,7 +1084,7 @@ TestConfigBackendDHCPv6::deleteSharedNetworkSubnets6(const db::ServerSelector& s
}
if (!server_selector.amAny()) {
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if ((*subnet)->hasServerTag(ServerTag(tag))) {
got = true;
@@ -1131,7 +1128,7 @@ TestConfigBackendDHCPv6::deleteSharedNetwork6(const db::ServerSelector& server_s
}
if (!server_selector.amAny()) {
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if ((*network_it)->hasServerTag(ServerTag(tag))) {
got = true;
@@ -1144,9 +1141,9 @@ TestConfigBackendDHCPv6::deleteSharedNetwork6(const db::ServerSelector& server_s
}
// Remove this shared network.
- for (auto subnet = subnets_.begin(); subnet != subnets_.end(); ++subnet) {
- if ((*subnet)->getSharedNetworkName() == name) {
- (*subnet)->setSharedNetworkName("");
+ for (auto const& subnet : subnets_) {
+ if (subnet->getSharedNetworkName() == name) {
+ subnet->setSharedNetworkName("");
}
}
(*network_it)->delAll();
@@ -1169,7 +1166,7 @@ TestConfigBackendDHCPv6::deleteAllSharedNetworks6(const db::ServerSelector& serv
continue;
}
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
names.push_back(shared_network->getName());
@@ -1198,7 +1195,7 @@ uint64_t
TestConfigBackendDHCPv6::deleteOptionDef6(const db::ServerSelector& server_selector,
const uint16_t code,
const std::string& space) {
- auto tag = getServerTag(server_selector);
+ auto const& tag = getServerTag(server_selector);
uint64_t erased = 0;
for (auto option_def_it = option_defs_.begin(); option_def_it != option_defs_.end(); ) {
if (((*option_def_it)->getCode() == code) &&
@@ -1215,7 +1212,7 @@ TestConfigBackendDHCPv6::deleteOptionDef6(const db::ServerSelector& server_selec
uint64_t
TestConfigBackendDHCPv6::deleteAllOptionDefs6(const db::ServerSelector& server_selector) {
- auto tag = getServerTag(server_selector);
+ auto const& tag = getServerTag(server_selector);
uint64_t erased = 0;
for (auto option_def_it = option_defs_.begin(); option_def_it != option_defs_.end(); ) {
if ((*option_def_it)->hasServerTag(ServerTag(tag))) {
@@ -1232,7 +1229,7 @@ uint64_t
TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector,
const uint16_t code,
const std::string& space) {
- auto tag = getServerTag(server_selector);
+ auto const& tag = getServerTag(server_selector);
uint64_t erased = 0;
for (auto option_it = options_.begin(); option_it != options_.end(); ) {
if ((option_it->option_->getType() == code) &&
@@ -1271,7 +1268,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
} else if (shared_network->hasAllServerTag()) {
found = true;
} else {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (shared_network->hasServerTag(ServerTag(tag))) {
found = true;
@@ -1312,7 +1309,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
} else if (subnet->hasAllServerTag()) {
found = true;
} else {
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
found = true;
@@ -1352,7 +1349,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
}
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
@@ -1401,7 +1398,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
}
} else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
auto in_tags = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (subnet->hasServerTag(ServerTag(tag))) {
in_tags = true;
@@ -1433,7 +1430,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
uint64_t
TestConfigBackendDHCPv6::deleteGlobalParameter6(const db::ServerSelector& server_selector,
const std::string& name) {
- auto tag = getServerTag(server_selector);
+ auto const& tag = getServerTag(server_selector);
auto& index = globals_.get<StampedValueNameIndexTag>();
auto global_it_pair = index.equal_range(name);
@@ -1450,7 +1447,7 @@ TestConfigBackendDHCPv6::deleteGlobalParameter6(const db::ServerSelector& server
uint64_t
TestConfigBackendDHCPv6::deleteAllGlobalParameters6(const db::ServerSelector& server_selector) {
- auto tag = getServerTag(server_selector);
+ auto const& tag = getServerTag(server_selector);
uint64_t cnt = 0;
for (auto global_it = globals_.begin(); global_it != globals_.end(); ) {
auto value = *global_it;
@@ -1484,7 +1481,7 @@ TestConfigBackendDHCPv6::deleteClientClass6(const db::ServerSelector& server_sel
}
if (!server_selector.amAny()) {
bool got = false;
- auto tags = server_selector.getTags();
+ auto const& tags = server_selector.getTags();
for (auto const& tag : tags) {
if (existing_class->hasServerTag(ServerTag(tag))) {
got = true;
@@ -1517,8 +1514,8 @@ TestConfigBackendDHCPv6::deleteAllClientClasses6(const db::ServerSelector& serve
continue;
}
bool got = false;
- auto tags = server_selector.getTags();
- for (auto tag : tags) {
+ auto const& tags = server_selector.getTags();
+ for (auto const& tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
c = classes_.erase(c);
++count;
diff --git a/src/lib/dhcpsrv/timer_mgr.cc b/src/lib/dhcpsrv/timer_mgr.cc
index cc4005b177..e5adce66ef 100644
--- a/src/lib/dhcpsrv/timer_mgr.cc
+++ b/src/lib/dhcpsrv/timer_mgr.cc
@@ -334,9 +334,8 @@ TimerMgrImpl::unregisterTimersInternal() {
TimerInfoMap registered_timers_copy(registered_timers_);
// Iterate over the existing timers and unregister them.
- for (TimerInfoMap::iterator timer_info_it = registered_timers_copy.begin();
- timer_info_it != registered_timers_copy.end(); ++timer_info_it) {
- unregisterTimerInternal(timer_info_it->first);
+ for (auto const& timer_info_it : registered_timers_copy) {
+ unregisterTimerInternal(timer_info_it.first);
}
}
diff --git a/src/lib/dhcpsrv/tracking_lease_mgr.cc b/src/lib/dhcpsrv/tracking_lease_mgr.cc
index 35c8192b47..2424e2642a 100644
--- a/src/lib/dhcpsrv/tracking_lease_mgr.cc
+++ b/src/lib/dhcpsrv/tracking_lease_mgr.cc
@@ -10,6 +10,7 @@
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/tracking_lease_mgr.h>
#include <util/multi_threading_mgr.h>
+#include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp>
using namespace isc::asiolink;
@@ -139,8 +140,7 @@ TrackingLeaseMgr::runCallbacksForSubnetID(CallbackType type, SubnetID subnet_id,
if (cbs.first == cbs.second) {
return;
}
- for (auto it = cbs.first; it != cbs.second; ++it) {
- auto cb = *it;
+ BOOST_FOREACH(auto const& cb, cbs) {
try {
cb.fn(lease);
} catch (const std::exception& ex) {