// Finally, print the hook libraries names
const isc::hooks::HookLibsCollection libs = ctx->getHooksConfig().get();
s << ", " << libs.size() << " lib(s):";
- for (auto lib = libs.begin(); lib != libs.end(); ++lib) {
- s << lib->first << " ";
+ for (auto const& lib : libs) {
+ s << lib.first << " ";
}
return (s.str());
std::string
CtrlAgentCfgContext::getControlSocketInfoSummary() const {
std::ostringstream s;
- for (auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.end(); ++si) {
+ for (auto const& si : ctrl_sockets_) {
if (s.tellp() != 0) {
s << " ";
}
- s << si->first;
+ s << si.first;
}
if (s.tellp() == 0) {
ca->set("hooks-libraries", hooks_config_.toElement());
// Set control-sockets
ElementPtr control_sockets = Element::createMap();
- for (auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.cend(); ++si) {
- ConstElementPtr socket = UserContext::toElement(si->second);
- control_sockets->set(si->first, socket);
+ for (auto const& si : ctrl_sockets_) {
+ ConstElementPtr socket = UserContext::toElement(si.second);
+ control_sockets->set(si.first, socket);
}
ca->set("control-sockets", control_sockets);
// Set Control-agent
// listeners except the most recently added.
if (http_listeners_.size() > leaving) {
// Stop no longer used listeners.
- for (auto l = http_listeners_.begin();
- l != http_listeners_.end() - leaving;
- ++l) {
+ for (auto l = http_listeners_.begin(); l != http_listeners_.end() - leaving; ++l) {
(*l)->stop();
}
// We have stopped listeners but there may be some pending handlers
}
}
-
CtrlAgentCfgMgrPtr
CtrlAgentProcess::getCtrlAgentCfgMgr() {
return (boost::dynamic_pointer_cast<CtrlAgentCfgMgr>(getCfgMgr()));
#include <hooks/hooks_manager.h>
#include <hooks/hooks_parser.h>
#include <http/basic_auth_config.h>
-#include <boost/foreach.hpp>
using namespace isc::data;
ConstElementPtr ctrl_sockets = config->get("control-sockets");
if (ctrl_sockets) {
auto const& sockets_map = ctrl_sockets->mapValue();
- for (auto cs = sockets_map.cbegin(); cs != sockets_map.cend(); ++cs) {
- ctx->setControlSocketInfo(cs->second, cs->first);
+ for (auto const& cs : sockets_map) {
+ ctx->setControlSocketInfo(cs.second, cs.first);
}
}
std::vector<ElementPtr> answer_list = answer->listValue();
ASSERT_EQ(expected_codes.size(), answer_list.size());
+ size_t count = 0;
// Check all answers.
- for (auto ans = answer_list.cbegin(); ans != answer_list.cend();
- ++ans) {
+ for (auto const& ans : answer_list) {
ConstElementPtr text;
- ASSERT_NO_THROW(text = isc::config::parseAnswer(status_code, *ans));
- EXPECT_EQ(expected_codes[std::distance(answer_list.cbegin(), ans)],
- status_code)
+ ASSERT_NO_THROW(text = isc::config::parseAnswer(status_code, ans));
+ EXPECT_EQ(expected_codes[count], status_code)
<< "answer contains text: " << text->stringValue();
+ count++;
}
}
#include <test_data_files_config.h>
#include <util/encode/base64.h>
-#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
// NOTE that since prior tests have validated server parsing, we are are
// assuming that the servers did in fact parse correctly if the correct
// number of them are there.
- DdnsDomainMapPair domain_pair;
- BOOST_FOREACH(domain_pair, (*domains)) {
+ for (auto const& domain_pair : *domains) {
DdnsDomainPtr domain = domain_pair.second;
DnsServerInfoStoragePtr servers = domain->getServers();
count = servers->size();
// NOTE that since prior tests have validated server parsing, we are are
// assuming that the servers did in fact parse correctly if the correct
// number of them are there.
- BOOST_FOREACH(domain_pair, (*domains)) {
+ for (auto const& domain_pair : *domains) {
DdnsDomainPtr domain = domain_pair.second;
DnsServerInfoStoragePtr servers = domain->getServers();
count = servers->size();
// 5. submit JSON for parsing
isc::data::ConstElementPtr test;
ASSERT_TRUE(tests->get("test-list"));
- BOOST_FOREACH(test, tests->get("test-list")->listValue()) {
+ for (auto const& test : tests->get("test-list")->listValue()) {
// Grab the description.
std::string description = "<no desc>";
isc::data::ConstElementPtr elem = test->get("description");
EXPECT_EQ(num, 8);
// Let's go over all parameters we have defaults for.
- BOOST_FOREACH(SimpleDefault deflt, D2SimpleParser::D2_GLOBAL_DEFAULTS) {
+ for (auto const& deflt : D2SimpleParser::D2_GLOBAL_DEFAULTS) {
ConstElementPtr x;
ASSERT_NO_THROW(x = empty->get(deflt.name_));
size_t cnt = 0;
// We don't use SimpleParser::setListDefaults() as this does
// not handle sub-lists or sub-maps
- BOOST_FOREACH(ElementPtr domain, config->listValue()) {
+ for (auto const& domain : config->listValue()) {
cnt += D2SimpleParser::
setDdnsDomainDefaults(domain, D2SimpleParser::
DDNS_DOMAIN_DEFAULTS);
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
+#include <boost/range/adaptor/reversed.hpp>
#include <boost/pointer_cast.hpp>
#include <boost/shared_ptr.hpp>
// Collect host identifiers. The identifiers are stored in order of preference.
// The server will use them in that order to search for host reservations.
- BOOST_FOREACH(const Host::IdentifierType& id_type,
- cfg->getIdentifierTypes()) {
+ for (auto const& id_type : cfg->getIdentifierTypes()) {
switch (id_type) {
case Host::IDENT_HWADDR:
if (context->hwaddr_ && !context->hwaddr_->hwaddr_.empty()) {
Dhcpv4Exchange::setReservedClientClasses(AllocEngine::ClientContext4Ptr context) {
if (context->currentHost() && context->query_) {
const ClientClasses& classes = context->currentHost()->getClientClasses4();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- context->query_->addClass(*cclass);
+ for (auto const& cclass : classes) {
+ context->query_->addClass(cclass);
}
}
}
const ClientClassDictionaryPtr& dict =
CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
const ClientClassDefListPtr& defs_ptr = dict->getClasses();
- for (ClientClassDefList::const_iterator it = defs_ptr->cbegin();
- it != defs_ptr->cend(); ++it) {
+ for (auto const& it : *defs_ptr) {
// Note second cannot be null
- const ExpressionPtr& expr_ptr = (*it)->getMatchExpr();
+ const ExpressionPtr& expr_ptr = it->getMatchExpr();
// Nothing to do without an expression to evaluate
if (!expr_ptr) {
continue;
}
// Not the right time if only when required
- if ((*it)->getRequired()) {
+ if (it->getRequired()) {
continue;
}
// Not the right pass.
- if ((*it)->getDependOnKnown() != depend_on_known) {
+ if (it->getDependOnKnown() != depend_on_known) {
continue;
}
- (*it)->test(pkt, expr_ptr);
+ it->test(pkt, expr_ptr);
}
}
isc::stats::StatsMgr& stats_mgr = isc::stats::StatsMgr::instance();
// Iterate over set of observed statistics
- for (auto it = dhcp4_statistics.begin(); it != dhcp4_statistics.end(); ++it) {
+ for (auto const& it : dhcp4_statistics) {
// Initialize them with default value 0
- stats_mgr.setValue((*it), static_cast<int64_t>(0));
+ stats_mgr.setValue(it, static_cast<int64_t>(0));
}
}
// Initialize fields specific to relayed messages.
if (query6 && !query6->relay_info_.empty()) {
- BOOST_REVERSE_FOREACH(Pkt6::RelayInfo relay, query6->relay_info_) {
+ for (auto const& relay : boost::adaptors::reverse(query6->relay_info_)) {
if (!relay.linkaddr_.isV6Zero() &&
!relay.linkaddr_.isV6LinkLocal()) {
selector.first_relay_linkaddr_ = relay.linkaddr_;
// Add classes from the global reservations.
const ClientClasses& classes = global_host->getClientClasses4();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- query->addClass(*cclass);
+ for (auto const& cclass : classes) {
+ query->addClass(cclass);
}
// Evaluate classes before KNOWN.
// Each class in the incoming packet
const ClientClasses& classes = ex.getQuery()->getClasses();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
+ for (auto const& cclass : classes) {
// Find the client class definition for this class
const ClientClassDefPtr& ccdef = CfgMgr::instance().getCurrentCfg()->
- getClientClassDictionary()->findClass(*cclass);
+ getClientClassDictionary()->findClass(cclass);
if (!ccdef) {
// Not found: the class is built-in or not configured
- if (!isClientClassBuiltIn(*cclass)) {
+ if (!isClientClassBuiltIn(cclass)) {
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASS_UNCONFIGURED)
.arg(ex.getQuery()->getLabel())
- .arg(*cclass);
+ .arg(cclass);
}
// Skip it
continue;
// Get persistent options.
const OptionContainerPersistIndex& pidx = opts->get<2>();
const OptionContainerPersistRange& prange = pidx.equal_range(true);
- for (OptionContainerPersistIndex::const_iterator desc = prange.first;
- desc != prange.second; ++desc) {
+ BOOST_FOREACH(auto const& desc, prange) {
// Add the persistent option code to requested options.
- if (desc->option_) {
- uint8_t code = static_cast<uint8_t>(desc->option_->getType());
+ if (desc.option_) {
+ uint8_t code = static_cast<uint8_t>(desc.option_->getType());
static_cast<void>(requested_opts.insert(code));
}
}
// Get cancelled options.
const OptionContainerCancelIndex& cidx = opts->get<5>();
const OptionContainerCancelRange& crange = cidx.equal_range(true);
- for (OptionContainerCancelIndex::const_iterator desc = crange.first;
- desc != crange.second; ++desc) {
+ BOOST_FOREACH(auto const& desc, crange) {
// Add the cancelled option code to cancelled options.
- if (desc->option_) {
- uint8_t code = static_cast<uint8_t>(desc->option_->getType());
+ if (desc.option_) {
+ uint8_t code = static_cast<uint8_t>(desc.option_->getType());
static_cast<void>(cancelled_opts.insert(code));
}
}
// Iterate on the configured option list
for (auto const& copts : co_list) {
for (auto const& desc : copts->getList(DHCP4_OPTION_SPACE,
- DHO_VIVSO_SUBOPTIONS)) {
+ DHO_VIVSO_SUBOPTIONS)) {
if (!desc.option_) {
continue;
}
// Get persistent options.
const OptionContainerPersistIndex& pidx = opts->get<2>();
const OptionContainerPersistRange& prange = pidx.equal_range(true);
- for (OptionContainerPersistIndex::const_iterator desc = prange.first;
- desc != prange.second; ++desc) {
+ BOOST_FOREACH(auto const& desc, prange) {
// Add the persistent option code to requested options.
- if (desc->option_) {
- uint8_t code = static_cast<uint8_t>(desc->option_->getType());
+ if (desc.option_) {
+ uint8_t code = static_cast<uint8_t>(desc.option_->getType());
static_cast<void>(requested_opts[vendor_id].insert(code));
}
}
// Get cancelled options.
const OptionContainerCancelIndex& cidx = opts->get<5>();
const OptionContainerCancelRange& crange = cidx.equal_range(true);
- for (OptionContainerCancelIndex::const_iterator desc = crange.first;
- desc != crange.second; ++desc) {
+ BOOST_FOREACH(auto const& desc, crange) {
// Add the cancelled option code to cancelled options.
- if (desc->option_) {
- uint8_t code = static_cast<uint8_t>(desc->option_->getType());
+ if (desc.option_) {
+ uint8_t code = static_cast<uint8_t>(desc.option_->getType());
static_cast<void>(cancelled_opts.insert(code));
}
}
// Among those returned try to find a lease that belongs to
// current shared network.
while (s) {
- for (auto l = leases_client_id.begin(); l != leases_client_id.end(); ++l) {
- if ((*l)->subnet_id_ == s->getID()) {
- lease = *l;
+ for (auto const& l : leases_client_id) {
+ if (l->subnet_id_ == s->getID()) {
+ lease = l;
break;
}
}
// Pick one that belongs to a subnet in this shared network.
while (s) {
- for (auto l = leases_hwaddr.begin(); l != leases_hwaddr.end(); ++l) {
- if ((*l)->subnet_id_ == s->getID()) {
- lease = *l;
+ for (auto const& l : leases_hwaddr) {
+ if (l->subnet_id_ == s->getID()) {
+ lease = l;
break;
}
}
string sname;
string filename;
size_t found_cnt = 0; // How many fields we have found.
- for (ClientClasses::const_iterator name = classes.cbegin();
- name != classes.cend() && found_cnt < 3; ++name) {
+ for (auto const& name : classes) {
+
+ if (found_cnt >= 3) {
+ break;
+ }
- ClientClassDefPtr cl = dict->findClass(*name);
+ ClientClassDefPtr cl = dict->findClass(name);
if (!cl) {
// Let's skip classes that don't have definitions. Currently
// these are automatic classes VENDOR_CLASS_something, but there
// Check if the server identifier is configured at client class level.
const ClientClasses& classes = query->getClasses();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
+ for (auto const& cclass : classes) {
// Find the client class definition for this class
const ClientClassDefPtr& ccdef = CfgMgr::instance().getCurrentCfg()->
- getClientClassDictionary()->findClass(*cclass);
+ getClientClassDictionary()->findClass(cclass);
if (!ccdef) {
continue;
}
subnet->getSharedNetwork(network);
if (network) {
const ClientClasses& to_add = network->getRequiredClasses();
- for (ClientClasses::const_iterator cclass = to_add.cbegin();
- cclass != to_add.cend(); ++cclass) {
- classes.insert(*cclass);
+ for (auto const& cclass : to_add) {
+ classes.insert(cclass);
}
}
// Followed by the subnet
const ClientClasses& to_add = subnet->getRequiredClasses();
- for(ClientClasses::const_iterator cclass = to_add.cbegin();
- cclass != to_add.cend(); ++cclass) {
- classes.insert(*cclass);
+ for (auto const& cclass : to_add) {
+ classes.insert(cclass);
}
// And finish by the pool
PoolPtr pool = subnet->getPool(Lease::TYPE_V4, addr, false);
if (pool) {
const ClientClasses& to_add = pool->getRequiredClasses();
- for (ClientClasses::const_iterator cclass = to_add.cbegin();
- cclass != to_add.cend(); ++cclass) {
- classes.insert(*cclass);
+ for (auto const& cclass : to_add) {
+ classes.insert(cclass);
}
}
}
// Note getClientClassDictionary() cannot be null
const ClientClassDictionaryPtr& dict =
CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- const ClientClassDefPtr class_def = dict->findClass(*cclass);
+ for (auto const& cclass : classes) {
+ const ClientClassDefPtr class_def = dict->findClass(cclass);
if (!class_def) {
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASS_UNDEFINED)
- .arg(*cclass);
+ .arg(cclass);
continue;
}
const ExpressionPtr& expr_ptr = class_def->getMatchExpr();
// Nothing to do without an expression to evaluate
if (!expr_ptr) {
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASS_UNTESTABLE)
- .arg(*cclass);
+ .arg(cclass);
continue;
}
// Evaluate the expression which can return false (no match),
bool status = evaluateBool(*expr_ptr, *query);
if (status) {
LOG_INFO(dhcp4_logger, EVAL_RESULT)
- .arg(*cclass)
+ .arg(cclass)
.arg("true");
// Matching: add the class
- query->addClass(*cclass);
+ query->addClass(cclass);
} else {
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, EVAL_RESULT)
- .arg(*cclass)
+ .arg(cclass)
.arg("false");
}
} catch (const Exception& ex) {
LOG_ERROR(dhcp4_logger, EVAL_RESULT)
- .arg(*cclass)
+ .arg(cclass)
.arg(ex.what());
} catch (...) {
LOG_ERROR(dhcp4_logger, EVAL_RESULT)
- .arg(*cclass)
+ .arg(cclass)
.arg("get exception?");
}
}
void
Dhcpv4Srv::deferredUnpack(Pkt4Ptr& query) {
// Iterate on the list of deferred option codes
- BOOST_FOREACH(const uint16_t& code, query->getDeferredOptions()) {
+ for (auto const& code : query->getDeferredOptions()) {
OptionDefinitionPtr def;
// Iterate on client classes
const ClientClasses& classes = query->getClasses();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
+ for (auto const& cclass : classes) {
// Get the client class definition for this class
const ClientClassDefPtr& ccdef =
CfgMgr::instance().getCurrentCfg()->
- getClientClassDictionary()->findClass(*cclass);
+ getClientClassDictionary()->findClass(cclass);
// If not found skip it
if (!ccdef) {
continue;
#include <util/strutil.h>
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <iomanip>
}
// Let's go through all the networks one by one
- for (auto net = networks->begin(); net != networks->end(); ++net) {
+ for (auto const& net : *networks) {
// For each network go through all the subnets in it.
- const Subnet4SimpleCollection* subnets = (*net)->getAllSubnets();
+ const Subnet4SimpleCollection* subnets = net->getAllSubnets();
if (!subnets) {
// Shared network without subnets it weird, but we decided to
// accept such configurations.
}
// For each subnet, add it to a list of regular subnets.
- for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
- dest->add(*subnet);
+ for (auto const& subnet : *subnets) {
+ dest->add(subnet);
}
}
}
std::set<string> names;
// Let's go through all the networks one by one
- for (auto net = networks.begin(); net != networks.end(); ++net) {
+ for (auto const& net : networks) {
string txt;
// Let's check if all subnets have either the same interface
// or don't have the interface specified at all.
- bool authoritative = (*net)->getAuthoritative();
- string iface = (*net)->getIface();
+ bool authoritative = net->getAuthoritative();
+ string iface = net->getIface();
- const Subnet4SimpleCollection* subnets = (*net)->getAllSubnets();
+ const Subnet4SimpleCollection* subnets = net->getAllSubnets();
if (subnets) {
// For each subnet, add it to a list of regular subnets.
- for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
- if ((*subnet)->getAuthoritative() != authoritative) {
+ for (auto const& subnet : *subnets) {
+ if (subnet->getAuthoritative() != authoritative) {
isc_throw(DhcpConfigError, "Subnet " << boolalpha
- << (*subnet)->toText()
+ << subnet->toText()
<< " has different authoritative setting "
- << (*subnet)->getAuthoritative()
+ << subnet->getAuthoritative()
<< " than the shared-network itself: "
<< authoritative);
}
if (iface.empty()) {
- iface = (*subnet)->getIface();
+ iface = subnet->getIface();
continue;
}
- if ((*subnet)->getIface().empty()) {
+ if (subnet->getIface().empty()) {
continue;
}
- if ((*subnet)->getIface() != iface) {
- isc_throw(DhcpConfigError, "Subnet " << (*subnet)->toText()
- << " has specified interface " << (*subnet)->getIface()
+ if (subnet->getIface() != iface) {
+ isc_throw(DhcpConfigError, "Subnet " << subnet->toText()
+ << " has specified interface " << subnet->getIface()
<< ", but earlier subnet in the same shared-network"
<< " or the shared-network itself used " << iface);
}
// Let's collect the subnets in case we later find out the
// subnet doesn't have a mandatory name.
- txt += (*subnet)->toText() + " ";
+ txt += subnet->toText() + " ";
}
}
// Next, let's check name of the shared network.
- if ((*net)->getName().empty()) {
+ if (net->getName().empty()) {
isc_throw(DhcpConfigError, "Shared-network with subnets "
<< txt << " is missing mandatory 'name' parameter");
}
// Is it unique?
- if (names.find((*net)->getName()) != names.end()) {
+ if (names.find(net->getName()) != names.end()) {
isc_throw(DhcpConfigError, "A shared-network with "
- "name " << (*net)->getName() << " defined twice.");
+ "name " << net->getName() << " defined twice.");
}
- names.insert((*net)->getName());
+ names.insert(net->getName());
}
}
HostCollection hosts;
HostReservationsListParser<HostReservationParser4> parser;
parser.parse(SUBNET_ID_GLOBAL, reservations, hosts);
- for (auto h = hosts.begin(); h != hosts.end(); ++h) {
- srv_config->getCfgHosts()->add(*h);
+ for (auto const& h : hosts) {
+ srv_config->getCfgHosts()->add(h);
}
}
}
// Make parsers grouping.
- ConfigPair config_pair;
const std::map<std::string, ConstElementPtr>& values_map =
mutable_cfg->mapValue();
- BOOST_FOREACH(config_pair, values_map) {
-
+ for (auto const& config_pair : values_map) {
parameter_name = config_pair.first;
// These are converted to SimpleParser and are handled already above.
// Append argument names.
std::vector<std::string> args = handle.getArgumentNames();
- for (auto arg = args.begin(); arg != args.end(); ++arg) {
- if (appendArgument(SRV_CONFIG_MARKER_FILE, arg->c_str()) != 0) {
+ for (auto const& arg : args) {
+ if (appendArgument(SRV_CONFIG_MARKER_FILE, arg.c_str()) != 0) {
return (1);
}
}
#include <dhcp4/tests/dhcp4_test_utils.h>
#include <dhcp4/tests/get_config_unittest.h>
-#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <iostream>
#include "dhcp4_test_utils.h"
#include "get_config_unittest.h"
-#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <iostream>
" \"subnet\": \"192.0.2.0/24\", "
" \"option-data\": [ {";
bool first = true;
- typedef std::pair<std::string, std::string> ParamPair;
- BOOST_FOREACH(ParamPair param, params) {
+ for (auto const& param : params) {
if (!first) {
stream << ", ";
} else {
// Iterate over the list of scenarios. Each should fail to parse with
// a specific error message.
- for (auto scenario = scenarios.begin(); scenario != scenarios.end(); ++scenario) {
- {
- SCOPED_TRACE((*scenario).description_);
- ConstElementPtr config;
- ASSERT_NO_THROW(config = parseDHCP4((*scenario).config_json_))
- << "invalid json, broken test";
- ConstElementPtr status;
- EXPECT_NO_THROW(status = Dhcpv4SrvTest::configure(*srv_, config));
- checkResult(status, 1);
- ASSERT_TRUE(comment_);
- EXPECT_EQ(comment_->stringValue(), (*scenario).exp_error_msg_);
- }
+ for (auto const& scenario : scenarios) {
+ SCOPED_TRACE(scenario.description_);
+ ConstElementPtr config;
+ ASSERT_NO_THROW(config = parseDHCP4(scenario.config_json_))
+ << "invalid json, broken test";
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = Dhcpv4SrvTest::configure(*srv_, config));
+ checkResult(status, 1);
+ ASSERT_TRUE(comment_);
+ EXPECT_EQ(comment_->stringValue(), scenario.exp_error_msg_);
}
}
// preparing the schema which check if all statistics are set to zero
std::ostringstream s;
s << "{ \"arguments\": { ";
- for (auto st = initial_stats.begin(); st != initial_stats.end();) {
- s << "\"" << *st << "\": [ [ 0, \"";
- s << isc::util::clockToText(StatsMgr::instance().getObservation(*st)->getInteger().second);
- s << "\" ] ]";
- if (++st != initial_stats.end()) {
+ bool first = true;
+ for (auto const& st : initial_stats) {
+ if (!first) {
s << ", ";
+ } else {
+ first = false;
}
+ s << "\"" << st << "\": [ [ 0, \"";
+ s << isc::util::clockToText(StatsMgr::instance().getObservation(st)->getInteger().second);
+ s << "\" ] ]";
}
s << " }, \"result\": 0 }";
// has been specified to be requested.
OptionUint8ArrayPtr prl(new OptionUint8Array(Option::V4,
DHO_DHCP_PARAMETER_REQUEST_LIST));
- for (std::set<uint8_t>::const_iterator opt = requested_options_.begin();
- opt != requested_options_.end(); ++opt) {
- prl->addValue(*opt);
+ for (auto const& opt : requested_options_) {
+ prl->addValue(opt);
}
context_.query_->addOption(prl);
}
Dhcp4Client::appendExtraOptions() {
// If there are any custom options specified, add them all to the message.
if (!extra_options_.empty()) {
- for (OptionCollection::iterator opt = extra_options_.begin();
- opt != extra_options_.end(); ++opt) {
+ for (auto const& opt : extra_options_) {
// Call base class function so that unittests can add multiple
// options with the same code.
- context_.query_->Pkt::addOption(opt->second);
+ context_.query_->Pkt::addOption(opt.second);
}
}
}
void
Dhcp4Client::appendClasses() {
- for (ClientClasses::const_iterator cclass = classes_.cbegin();
- cclass != classes_.cend(); ++cclass) {
- context_.query_->addClass(*cclass);
+ for (auto const& cclass : classes_) {
+ context_.query_->addClass(cclass);
}
}
msg_copy->setIndex(iface_index_);
// Copy classes
const ClientClasses& classes = msg->getClasses();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- msg_copy->addClass(*cclass);
+ for (auto const& cclass : classes) {
+ msg_copy->addClass(cclass);
}
srv_->fakeReceive(msg_copy);
removeTlsParameters(hosts);
hosts = dhcp4->get("hosts-databases");
if (hosts) {
- for (auto& host : hosts->listValue()) {
+ for (auto const& host : hosts->listValue()) {
removeTlsParameters(host);
}
}
"with-ddns.json",
};
vector<string> files;
- for (const string& example : examples) {
+ for (auto const& example : examples) {
string file = path + "/" + example;
files.push_back(file);
}
// Checks if callouts installed on the dhcp4_srv_configured ared indeed called
// and all the necessary parameters are passed.
TEST_F(LoadUnloadDhcpv4SrvTest, Dhcpv4SrvConfigured) {
- for (const string& parameters : vector<string>{
+ for (auto const& parameters : vector<string>{
"",
R"(, "parameters": { "mode": "fail-without-error" } )",
R"(, "parameters": { "mode": "fail-with-error" } )"}) {
Subnet4Ptr getConfiguredSubnet(const IOAddress& address) {
CfgSubnets4Ptr cfg = CfgMgr::instance().getCurrentCfg()->getCfgSubnets4();
const Subnet4Collection* subnets = cfg->getAll();
- for (auto subnet_it = subnets->cbegin(); subnet_it != subnets->cend();
- ++subnet_it) {
- if ((*subnet_it)->inRange(address)) {
- return (*subnet_it);
+ for (auto const& subnet_it : *subnets) {
+ if (subnet_it->inRange(address)) {
+ return (subnet_it);
}
}
return (Subnet4Ptr());
#endif
#include <dhcpsrv/memfile_lease_mgr.h>
-#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
+#include <boost/foreach.hpp>
#include <boost/algorithm/string/erase.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/split.hpp>
isc::stats::StatsMgr& stats_mgr = isc::stats::StatsMgr::instance();
// Iterate over set of observed statistics
- for (auto it = dhcp6_statistics.begin(); it != dhcp6_statistics.end(); ++it) {
+ for (auto const& it : dhcp6_statistics) {
// Initialize them with default value 0
- stats_mgr.setValue((*it), static_cast<int64_t>(0));
+ stats_mgr.setValue(it, static_cast<int64_t>(0));
}
}
Dhcpv6Srv::setHostIdentifiers(AllocEngine::ClientContext6& ctx) {
const ConstCfgHostOperationsPtr cfg =
CfgMgr::instance().getCurrentCfg()->getCfgHostOperations6();
- BOOST_FOREACH(const Host::IdentifierType& id_type,
- cfg->getIdentifierTypes()) {
+ for (auto const& id_type : cfg->getIdentifierTypes()) {
switch (id_type) {
case Host::IDENT_DUID:
if (ctx.duid_) {
// Add classes from the global reservations.
const ClientClasses& classes = global_host->getClientClasses6();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- query->addClass(*cclass);
+ for (auto const& cclass : classes) {
+ query->addClass(cclass);
}
// Evaluate classes before KNOWN.
OptionBuffer data = opt->getData();
bool colon = false;
- for (OptionBufferConstIter it = data.begin(); it != data.end(); ++it) {
+ for (auto const& it : data) {
if (colon) {
tmp << ":";
}
- tmp << hex << setw(2) << setfill('0') << static_cast<uint16_t>(*it);
+ tmp << hex << setw(2) << setfill('0') << static_cast<uint16_t>(it);
if (!colon) {
colon = true;
}
// Each class in the incoming packet
const ClientClasses& classes = question->getClasses();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
+ for (auto const& cclass : classes) {
// Find the client class definition for this class
const ClientClassDefPtr& ccdef = CfgMgr::instance().getCurrentCfg()->
- getClientClassDictionary()->findClass(*cclass);
+ getClientClassDictionary()->findClass(cclass);
if (!ccdef) {
// Not found: the class is built-in or not configured
- if (!isClientClassBuiltIn(*cclass)) {
+ if (!isClientClassBuiltIn(cclass)) {
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASS_UNCONFIGURED)
.arg(question->getLabel())
- .arg(*cclass);
+ .arg(cclass);
}
// Skip it
continue;
// Get persistent options.
const OptionContainerPersistIndex& pidx = opts->get<2>();
const OptionContainerPersistRange& prange = pidx.equal_range(true);
- for (OptionContainerPersistIndex::const_iterator desc = prange.first;
- desc != prange.second; ++desc) {
+ BOOST_FOREACH(auto const& desc, prange) {
// Add the persistent option code to requested options.
- if (desc->option_) {
- uint16_t code = desc->option_->getType();
+ if (desc.option_) {
+ uint16_t code = desc.option_->getType();
static_cast<void>(requested_opts.insert(code));
}
}
// Get cancelled options.
const OptionContainerCancelIndex& cidx = opts->get<5>();
const OptionContainerCancelRange& crange = cidx.equal_range(true);
- for (OptionContainerCancelIndex::const_iterator desc = crange.first;
- desc != crange.second; ++desc) {
+ BOOST_FOREACH(auto const& desc, crange) {
// Add the cancelled option code to the cancelled options.
- if (desc->option_) {
- uint16_t code = desc->option_->getType();
+ if (desc.option_) {
+ uint16_t code = desc.option_->getType();
static_cast<void>(cancelled_opts.insert(code));
}
}
// Get persistent options.
const OptionContainerPersistIndex& pidx = opts->get<2>();
const OptionContainerPersistRange& prange = pidx.equal_range(true);
- for (OptionContainerPersistIndex::const_iterator desc = prange.first;
- desc != prange.second; ++desc) {
- if (!desc->option_) {
+ BOOST_FOREACH(auto const& desc, prange) {
+ if (!desc.option_) {
continue;
}
// Add the persistent option code to requested options
- uint16_t code = desc->option_->getType();
+ uint16_t code = desc.option_->getType();
static_cast<void>(requested_opts[vendor_id].insert(code));
}
// Get cancelled options.
const OptionContainerCancelIndex& cidx = opts->get<5>();
const OptionContainerCancelRange& crange = cidx.equal_range(true);
- for (OptionContainerCancelIndex::const_iterator desc = crange.first;
- desc != crange.second; ++desc) {
- if (!desc->option_) {
+ BOOST_FOREACH(auto const& desc, crange) {
+ if (!desc.option_) {
continue;
}
// Add the cancelled option code to cancelled options
- uint16_t code = desc->option_->getType();
+ uint16_t code = desc.option_->getType();
static_cast<void>(cancelled_opts[vendor_id].insert(code));
}
}
// to determine if the changes included changes to the FQDN. If so
// then we may need to do a CHG_REMOVE.
bool extended_only = false;
- for (Lease6Collection::const_iterator l = ctx.currentIA().changed_leases_.begin();
- l != ctx.currentIA().changed_leases_.end(); ++l) {
+ for (auto const& l : ctx.currentIA().changed_leases_) {
- if ((*l)->addr_ == iaaddr->getAddress()) {
+ if (l->addr_ == iaaddr->getAddress()) {
// The address is the same so this must be renewal. If we're not
// always updating on renew, then we only renew if DNS info has
// changed.
if (!ctx.getDdnsParams()->getUpdateOnRenew() &&
- ((*l)->hostname_ == opt_fqdn->getDomainName() &&
- (*l)->fqdn_fwd_ == do_fwd && (*l)->fqdn_rev_ == do_rev)) {
+ (l->hostname_ == opt_fqdn->getDomainName() &&
+ l->fqdn_fwd_ == do_fwd && l->fqdn_rev_ == do_rev)) {
extended_only = true;
} else {
// Queue a CHG_REMOVE of the old data.
// NCR will only be created if the lease hostname is not
// empty and at least one of the direction flags is true
- queueNCR(CHG_REMOVE, *l);
+ queueNCR(CHG_REMOVE, l);
}
break;
CfgMACSources mac_sources = CfgMgr::instance().getCurrentCfg()->
getMACSources().get();
HWAddrPtr hwaddr;
- for (CfgMACSources::const_iterator it = mac_sources.begin();
- it != mac_sources.end(); ++it) {
- hwaddr = pkt->getMAC(*it);
+ for (auto const& it : mac_sources) {
+ hwaddr = pkt->getMAC(it);
if (hwaddr) {
return (hwaddr);
}
uint32_t min_preferred_lft = (*leases.begin())->preferred_lft_;
const bool pd_exclude_requested = requestedInORO(query, D6O_PD_EXCLUDE);
- for (Lease6Collection::iterator l = leases.begin();
- l != leases.end(); ++l) {
+ for (auto const& l : leases) {
// We have a lease! Let's wrap its content into IA_PD option
// with IAADDR suboption.
if (ctx.fake_allocation_) {
LOG_INFO(lease6_logger, DHCP6_PD_LEASE_ADVERT)
.arg(query->getLabel())
- .arg((*l)->addr_.toText())
- .arg(static_cast<int>((*l)->prefixlen_))
+ .arg(l->addr_.toText())
+ .arg(static_cast<int>(l->prefixlen_))
.arg(ia->getIAID());
- } else if ((*l)->reuseable_valid_lft_ == 0) {
+ } else if (l->reuseable_valid_lft_ == 0) {
LOG_INFO(lease6_logger, DHCP6_PD_LEASE_ALLOC)
.arg(query->getLabel())
- .arg((*l)->addr_.toText())
- .arg(static_cast<int>((*l)->prefixlen_))
+ .arg(l->addr_.toText())
+ .arg(static_cast<int>(l->prefixlen_))
.arg(ia->getIAID())
- .arg(Lease::lifetimeToText((*l)->valid_lft_));
+ .arg(Lease::lifetimeToText(l->valid_lft_));
} else {
- (*l)->valid_lft_ = (*l)->reuseable_valid_lft_;
- (*l)->preferred_lft_ = (*l)->reuseable_preferred_lft_;
+ l->valid_lft_ = l->reuseable_valid_lft_;
+ l->preferred_lft_ = l->reuseable_preferred_lft_;
LOG_INFO(lease6_logger, DHCP6_PD_LEASE_REUSE)
.arg(query->getLabel())
- .arg((*l)->addr_.toText())
- .arg(static_cast<int>((*l)->prefixlen_))
+ .arg(l->addr_.toText())
+ .arg(static_cast<int>(l->prefixlen_))
.arg(ia->getIAID())
- .arg(Lease::lifetimeToText((*l)->valid_lft_));
+ .arg(Lease::lifetimeToText(l->valid_lft_));
// Increment the reuse statistics.
StatsMgr::instance().addValue("v6-ia-pd-lease-reuses", int64_t(1));
- StatsMgr::instance().addValue(StatsMgr::generateName("subnet", (*l)->subnet_id_,
+ StatsMgr::instance().addValue(StatsMgr::generateName("subnet", l->subnet_id_,
"v6-ia-pd-lease-reuses"),
int64_t(1));
}
// Check for new minimum lease time
- if (((*l)->preferred_lft_ > 0) && (min_preferred_lft > (*l)->preferred_lft_)) {
- min_preferred_lft = (*l)->preferred_lft_;
+ if ((l->preferred_lft_ > 0) && (min_preferred_lft > l->preferred_lft_)) {
+ min_preferred_lft = l->preferred_lft_;
}
boost::shared_ptr<Option6IAPrefix>
- addr(new Option6IAPrefix(D6O_IAPREFIX, (*l)->addr_,
- (*l)->prefixlen_, (*l)->preferred_lft_,
- (*l)->valid_lft_));
+ addr(new Option6IAPrefix(D6O_IAPREFIX, l->addr_,
+ l->prefixlen_, l->preferred_lft_,
+ l->valid_lft_));
ia_rsp->addOption(addr);
if (pd_exclude_requested) {
// PD exclude option has been requested via ORO, thus we need to
// include it if the pool configuration specifies this option.
Pool6Ptr pool = boost::dynamic_pointer_cast<
- Pool6>(subnet->getPool(Lease::TYPE_PD, (*l)->addr_));
+ Pool6>(subnet->getPool(Lease::TYPE_PD, l->addr_));
if (pool) {
Option6PDExcludePtr pd_exclude_option = pool->getPrefixExcludeOption();
if (pd_exclude_option) {
// Extract the addresses that the client is trying to obtain.
OptionCollection addrs = ia->getOptions();
- for (OptionCollection::const_iterator it = addrs.begin();
- it != addrs.end(); ++it) {
- if (it->second->getType() != D6O_IAADDR) {
+ for (auto const& it : addrs) {
+ if (it.second->getType() != D6O_IAADDR) {
continue;
}
- Option6IAAddrPtr iaaddr = boost::dynamic_pointer_cast<Option6IAAddr>(it->second);
+ Option6IAAddrPtr iaaddr = boost::dynamic_pointer_cast<Option6IAAddr>(it.second);
if (!iaaddr) {
// That's weird. Option code was ok, but the object type was not.
// This should never happen. The only case would be with badly
uint32_t min_preferred_lft = std::numeric_limits<uint32_t>::max();
// For all leases we have now, add the IAADDR with non-zero lifetimes.
- for (Lease6Collection::iterator l = leases.begin(); l != leases.end(); ++l) {
- if ((*l)->reuseable_valid_lft_ == 0) {
+ for (auto const& l : leases) {
+ if (l->reuseable_valid_lft_ == 0) {
LOG_INFO(lease6_logger, DHCP6_LEASE_RENEW)
.arg(query->getLabel())
- .arg((*l)->addr_.toText())
+ .arg(l->addr_.toText())
.arg(ia->getIAID());
} else {
- (*l)->valid_lft_ = (*l)->reuseable_valid_lft_;
- (*l)->preferred_lft_ = (*l)->reuseable_preferred_lft_;
+ l->valid_lft_ = l->reuseable_valid_lft_;
+ l->preferred_lft_ = l->reuseable_preferred_lft_;
LOG_INFO(lease6_logger, DHCP6_LEASE_REUSE)
.arg(query->getLabel())
- .arg((*l)->addr_.toText())
+ .arg(l->addr_.toText())
.arg(ia->getIAID())
- .arg(Lease::lifetimeToText((*l)->valid_lft_));
+ .arg(Lease::lifetimeToText(l->valid_lft_));
// Increment the reuse statistics.
StatsMgr::instance().addValue("v6-ia-na-lease-reuses", int64_t(1));
- StatsMgr::instance().addValue(StatsMgr::generateName("subnet", (*l)->subnet_id_,
+ StatsMgr::instance().addValue(StatsMgr::generateName("subnet", l->subnet_id_,
"v6-ia-na-lease-reuses"),
int64_t(1));
}
Option6IAAddrPtr iaaddr(new Option6IAAddr(D6O_IAADDR,
- (*l)->addr_, (*l)->preferred_lft_, (*l)->valid_lft_));
+ l->addr_, l->preferred_lft_, l->valid_lft_));
ia_rsp->addOption(iaaddr);
// Check for new minimum lease time
- if (((*l)->preferred_lft_ > 0) && (min_preferred_lft > (*l)->preferred_lft_)) {
- min_preferred_lft = (*l)->preferred_lft_;
+ if ((l->preferred_lft_ > 0) && (min_preferred_lft > l->preferred_lft_)) {
+ min_preferred_lft = l->preferred_lft_;
}
// Now remove this address from the hints list.
- AllocEngine::Resource hint_type((*l)->addr_);
+ AllocEngine::Resource hint_type(l->addr_);
hints.erase(std::remove(hints.begin(), hints.end(), hint_type),
hints.end());
}
// For the leases that we just retired, send the addresses with 0 lifetimes.
- for (Lease6Collection::iterator l = ctx.currentIA().old_leases_.begin();
- l != ctx.currentIA().old_leases_.end(); ++l) {
+ for (auto const& l : ctx.currentIA().old_leases_) {
// Send an address with zero lifetimes only when this lease belonged to
// this client. Do not send it when we're reusing an old lease that belonged
// to someone else.
- if (equalValues(query->getClientId(), (*l)->duid_)) {
+ if (equalValues(query->getClientId(), l->duid_)) {
Option6IAAddrPtr iaaddr(new Option6IAAddr(D6O_IAADDR,
- (*l)->addr_, 0, 0));
+ l->addr_, 0, 0));
ia_rsp->addOption(iaaddr);
}
// Now remove this address from the hints list.
- AllocEngine::Resource hint_type((*l)->addr_);
+ AllocEngine::Resource hint_type(l->addr_);
hints.erase(std::remove(hints.begin(), hints.end(), hint_type), hints.end());
// If the new FQDN settings have changed for the lease, we need to
// delete any existing FQDN records for this lease.
- if (((*l)->hostname_ != ctx.hostname_) || ((*l)->fqdn_fwd_ != ctx.fwd_dns_update_) ||
- ((*l)->fqdn_rev_ != ctx.rev_dns_update_)) {
+ if ((l->hostname_ != ctx.hostname_) || (l->fqdn_fwd_ != ctx.fwd_dns_update_) ||
+ (l->fqdn_rev_ != ctx.rev_dns_update_)) {
LOG_DEBUG(ddns6_logger, DBG_DHCP6_DETAIL,
DHCP6_DDNS_REMOVE_OLD_LEASE_FQDN)
.arg(query->getLabel())
- .arg((*l)->toText())
+ .arg(l->toText())
.arg(ctx.hostname_)
.arg(ctx.rev_dns_update_ ? "true" : "false")
.arg(ctx.fwd_dns_update_ ? "true" : "false");
- queueNCR(CHG_REMOVE, *l);
+ queueNCR(CHG_REMOVE, l);
}
}
// Finally, if there are any addresses requested that we haven't dealt with
// already, inform the client that he can't have them.
- for (AllocEngine::HintContainer::const_iterator hint = hints.begin();
- hint != hints.end(); ++hint) {
+ for (auto const& hint : hints) {
Option6IAAddrPtr iaaddr(new Option6IAAddr(D6O_IAADDR,
- hint->getAddress(), 0, 0));
+ hint.getAddress(), 0, 0));
ia_rsp->addOption(iaaddr);
}
// Extract prefixes that the client is trying to renew.
OptionCollection addrs = ia->getOptions();
- for (OptionCollection::const_iterator it = addrs.begin();
- it != addrs.end(); ++it) {
- if (it->second->getType() != D6O_IAPREFIX) {
+ for (auto const& it : addrs) {
+ if (it.second->getType() != D6O_IAPREFIX) {
continue;
}
- Option6IAPrefixPtr prf = boost::dynamic_pointer_cast<Option6IAPrefix>(it->second);
+ Option6IAPrefixPtr prf = boost::dynamic_pointer_cast<Option6IAPrefix>(it.second);
if (!prf) {
// That's weird. Option code was ok, but the object type was not.
// This should never happen. The only case would be with badly
// for calculating T1 and T2.
uint32_t min_preferred_lft = std::numeric_limits<uint32_t>::max();
- for (Lease6Collection::iterator l = leases.begin(); l != leases.end(); ++l) {
- if ((*l)->reuseable_valid_lft_ == 0) {
+ for (auto const& l : leases) {
+ if (l->reuseable_valid_lft_ == 0) {
LOG_INFO(lease6_logger, DHCP6_PD_LEASE_RENEW)
.arg(query->getLabel())
- .arg((*l)->addr_.toText())
- .arg(static_cast<int>((*l)->prefixlen_))
+ .arg(l->addr_.toText())
+ .arg(static_cast<int>(l->prefixlen_))
.arg(ia->getIAID());
} else {
- (*l)->valid_lft_ = (*l)->reuseable_valid_lft_;
- (*l)->preferred_lft_ = (*l)->reuseable_preferred_lft_;
+ l->valid_lft_ = l->reuseable_valid_lft_;
+ l->preferred_lft_ = l->reuseable_preferred_lft_;
LOG_INFO(lease6_logger, DHCP6_PD_LEASE_REUSE)
.arg(query->getLabel())
- .arg((*l)->addr_.toText())
- .arg(static_cast<int>((*l)->prefixlen_))
+ .arg(l->addr_.toText())
+ .arg(static_cast<int>(l->prefixlen_))
.arg(ia->getIAID())
- .arg(Lease::lifetimeToText((*l)->valid_lft_));
+ .arg(Lease::lifetimeToText(l->valid_lft_));
// Increment the reuse statistics.
StatsMgr::instance().addValue("v6-ia-pd-lease-reuses", int64_t(1));
- StatsMgr::instance().addValue(StatsMgr::generateName("subnet", (*l)->subnet_id_,
+ StatsMgr::instance().addValue(StatsMgr::generateName("subnet", l->subnet_id_,
"v6-ia-pd-lease-reuses"),
int64_t(1));
}
Option6IAPrefixPtr prf(new Option6IAPrefix(D6O_IAPREFIX,
- (*l)->addr_, (*l)->prefixlen_,
- (*l)->preferred_lft_, (*l)->valid_lft_));
+ l->addr_, l->prefixlen_,
+ l->preferred_lft_, l->valid_lft_));
ia_rsp->addOption(prf);
if (pd_exclude_requested) {
// PD exclude option has been requested via ORO, thus we need to
// include it if the pool configuration specifies this option.
Pool6Ptr pool = boost::dynamic_pointer_cast<
- Pool6>(subnet->getPool(Lease::TYPE_PD, (*l)->addr_));
+ Pool6>(subnet->getPool(Lease::TYPE_PD, l->addr_));
if (pool) {
Option6PDExcludePtr pd_exclude_option = pool->getPrefixExcludeOption();
}
// Check for new minimum lease time
- if (((*l)->preferred_lft_ > 0) && ((*l)->preferred_lft_ < min_preferred_lft)) {
- min_preferred_lft = (*l)->preferred_lft_;
+ if ((l->preferred_lft_ > 0) && (l->preferred_lft_ < min_preferred_lft)) {
+ min_preferred_lft = l->preferred_lft_;
}
// Now remove this prefix from the hints list.
- AllocEngine::Resource hint_type((*l)->addr_, (*l)->prefixlen_);
+ AllocEngine::Resource hint_type(l->addr_, l->prefixlen_);
hints.erase(std::remove(hints.begin(), hints.end(), hint_type),
hints.end());
}
/// For the leases that we just retired, send the prefixes with 0 lifetimes.
- for (Lease6Collection::iterator l = ctx.currentIA().old_leases_.begin();
- l != ctx.currentIA().old_leases_.end(); ++l) {
+ for (auto const& l : ctx.currentIA().old_leases_) {
// Send a prefix with zero lifetimes only when this lease belonged to
// this client. Do not send it when we're reusing an old lease that belonged
// to someone else.
- if (equalValues(query->getClientId(), (*l)->duid_)) {
- Option6IAPrefixPtr prefix(new Option6IAPrefix(D6O_IAPREFIX, (*l)->addr_,
- (*l)->prefixlen_, 0, 0));
+ if (equalValues(query->getClientId(), l->duid_)) {
+ Option6IAPrefixPtr prefix(new Option6IAPrefix(D6O_IAPREFIX, l->addr_,
+ l->prefixlen_, 0, 0));
ia_rsp->addOption(prefix);
}
// Now remove this prefix from the hints list.
- AllocEngine::Resource hint_type((*l)->addr_, (*l)->prefixlen_);
+ AllocEngine::Resource hint_type(l->addr_, l->prefixlen_);
hints.erase(std::remove(hints.begin(), hints.end(), hint_type), hints.end());
}
// Finally, if there are any prefixes requested that we haven't dealt with
// already, inform the client that he can't have them.
- for (AllocEngine::HintContainer::const_iterator prefix = hints.begin();
- prefix != hints.end(); ++prefix) {
+ for (auto const& prefix : hints) {
// Send the prefix with the zero lifetimes only if the prefix
// contains non-zero value. A zero value indicates that the hint was
// for the prefix length.
- if (!prefix->getAddress().isV6Zero()) {
+ if (!prefix.getAddress().isV6Zero()) {
OptionPtr prefix_opt(new Option6IAPrefix(D6O_IAPREFIX,
- prefix->getAddress(),
- prefix->getPrefixLength(),
+ prefix.getAddress(),
+ prefix.getPrefixLength(),
0, 0));
ia_rsp->addOption(prefix_opt);
}
// over the IA_NA options to check if they hold any addresses. If there
// are no, the Confirm is discarded.
// Check addresses in IA_NA options and make sure they are appropriate.
- for (OptionCollection::const_iterator ia = ias.begin();
- ia != ias.end(); ++ia) {
- const OptionCollection& opts = ia->second->getOptions();
- for (OptionCollection::const_iterator opt = opts.begin();
- opt != opts.end(); ++opt) {
+ for (auto const& ia : ias) {
+ const OptionCollection& opts = ia.second->getOptions();
+ for (auto const& opt : opts) {
// Ignore options other than IAAddr.
- if (opt->second->getType() == D6O_IAADDR) {
+ if (opt.second->getType() == D6O_IAADDR) {
// Check that the address is in range in the subnet selected.
Option6IAAddrPtr iaaddr = boost::dynamic_pointer_cast<
- Option6IAAddr>(opt->second);
+ Option6IAAddr>(opt.second);
// If there is subnet selected and the address has been included
// in IA_NA, mark it verified and verify that it belongs to the
// subnet.
const OptionCollection& opts = ia->getOptions();
int total_addrs = 0; // Let's count the total number of addresses.
- for (OptionCollection::const_iterator opt = opts.begin(); opt != opts.end();
- ++opt) {
+ for (auto const& opt : opts) {
// Let's ignore nested options other than IAADDR (there shouldn't be anything
// else in IA_NA in Decline message, but let's be on the safe side).
- if (opt->second->getType() != D6O_IAADDR) {
+ if (opt.second->getType() != D6O_IAADDR) {
continue;
}
Option6IAAddrPtr decline_addr = boost::dynamic_pointer_cast<Option6IAAddr>
- (opt->second);
+ (opt.second);
if (!decline_addr) {
continue;
}
const ClientClassDictionaryPtr& dict =
CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
const ClientClassDefListPtr& defs_ptr = dict->getClasses();
- for (ClientClassDefList::const_iterator it = defs_ptr->cbegin();
- it != defs_ptr->cend(); ++it) {
+ for (auto const& it : *defs_ptr) {
// Note second cannot be null
- const ExpressionPtr& expr_ptr = (*it)->getMatchExpr();
+ const ExpressionPtr& expr_ptr = it->getMatchExpr();
// Nothing to do without an expression to evaluate
if (!expr_ptr) {
continue;
}
// Not the right time if only when required
- if ((*it)->getRequired()) {
+ if (it->getRequired()) {
continue;
}
// Not the right pass.
- if ((*it)->getDependOnKnown() != depend_on_known) {
+ if (it->getDependOnKnown() != depend_on_known) {
continue;
}
- (*it)->test(pkt, expr_ptr);
+ it->test(pkt, expr_ptr);
}
}
const AllocEngine::ClientContext6& ctx) {
if (ctx.currentHost() && pkt) {
const ClientClasses& classes = ctx.currentHost()->getClientClasses6();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- pkt->addClass(*cclass);
+ for (auto const& cclass : classes) {
+ pkt->addClass(cclass);
}
}
}
subnet->getSharedNetwork(network);
if (network) {
const ClientClasses& to_add = network->getRequiredClasses();
- for (ClientClasses::const_iterator cclass = to_add.cbegin();
- cclass != to_add.cend(); ++cclass) {
- classes.insert(*cclass);
+ for (auto const& cclass : to_add) {
+ classes.insert(cclass);
}
}
// Followed by the subnet
const ClientClasses& to_add = subnet->getRequiredClasses();
- for (ClientClasses::const_iterator cclass = to_add.cbegin();
- cclass != to_add.cend(); ++cclass) {
- classes.insert(*cclass);
+ for (auto const& cclass : to_add) {
+ classes.insert(cclass);
}
// And finish by pools
false);
if (pool) {
const ClientClasses& to_add = pool->getRequiredClasses();
- for (ClientClasses::const_iterator cclass = to_add.cbegin();
- cclass != to_add.cend(); ++cclass) {
- classes.insert(*cclass);
+ for (auto const& cclass : to_add) {
+ classes.insert(cclass);
}
}
}
// Note getClientClassDictionary() cannot be null
const ClientClassDictionaryPtr& dict =
CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- const ClientClassDefPtr class_def = dict->findClass(*cclass);
+ for (auto const& cclass : classes) {
+ const ClientClassDefPtr class_def = dict->findClass(cclass);
if (!class_def) {
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASS_UNDEFINED)
- .arg(*cclass);
+ .arg(cclass);
continue;
}
const ExpressionPtr& expr_ptr = class_def->getMatchExpr();
// Nothing to do without an expression to evaluate
if (!expr_ptr) {
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASS_UNTESTABLE)
- .arg(*cclass);
+ .arg(cclass);
continue;
}
// Evaluate the expression which can return false (no match),
bool status = evaluateBool(*expr_ptr, *pkt);
if (status) {
LOG_INFO(dhcp6_logger, EVAL_RESULT)
- .arg(*cclass)
+ .arg(cclass)
.arg("true");
// Matching: add the class
- pkt->addClass(*cclass);
+ pkt->addClass(cclass);
} else {
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, EVAL_RESULT)
- .arg(*cclass)
+ .arg(cclass)
.arg("false");
}
} catch (const Exception& ex) {
LOG_ERROR(dhcp6_logger, EVAL_RESULT)
- .arg(*cclass)
+ .arg(cclass)
.arg(ex.what());
} catch (...) {
LOG_ERROR(dhcp6_logger, EVAL_RESULT)
- .arg(*cclass)
+ .arg(cclass)
.arg("get exception?");
}
}
// and if it's RSOO-enabled and there's no such option provided yet,
// copy it to the server's response
const OptionCollection& rsoo = rsoo_container->getOptions();
- for (OptionCollection::const_iterator opt = rsoo.begin();
- opt != rsoo.end(); ++opt) {
+ for (auto const& opt : rsoo) {
// Echo option if it is RSOO enabled option and there is no such
// option added yet.
- if (cfg_rsoo->enabled(opt->second->getType()) &&
- !rsp->getOption(opt->second->getType())) {
- rsp->addOption(opt->second);
+ if (cfg_rsoo->enabled(opt.second->getType()) &&
+ !rsp->getOption(opt.second->getType())) {
+ rsp->addOption(opt.second);
}
}
}
((prev_hostname != ctx.hostname_) ||
(prev_fwd_dns_update != ctx.fwd_dns_update_) ||
(prev_rev_dns_update != ctx.rev_dns_update_))) {
- for (Lease6Collection::const_iterator l = ctx.new_leases_.begin();
- l != ctx.new_leases_.end(); ++l) {
- (*l)->hostname_ = ctx.hostname_;
- (*l)->fqdn_fwd_ = ctx.fwd_dns_update_;
- (*l)->fqdn_rev_ = ctx.rev_dns_update_;
- (*l)->reuseable_valid_lft_ = 0;
- LeaseMgrFactory::instance().updateLease6(*l);
+ for (auto const& l : ctx.new_leases_) {
+ l->hostname_ = ctx.hostname_;
+ l->fqdn_fwd_ = ctx.fwd_dns_update_;
+ l->fqdn_rev_ = ctx.rev_dns_update_;
+ l->reuseable_valid_lft_ = 0;
+ LeaseMgrFactory::instance().updateLease6(l);
}
}
}
#include <util/triplet.h>
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
/// @param cfg server configuration (RSOO will be stored here)
void parse(const SrvConfigPtr& cfg, const isc::data::ConstElementPtr& value) {
try {
- BOOST_FOREACH(ConstElementPtr source_elem, value->listValue()) {
+ for (auto const& source_elem : value->listValue()) {
std::string option_str = source_elem->stringValue();
// This option can be either code (integer) or name. Let's try code first
int64_t code = 0;
}
// Let's go through all the networks one by one
- for (auto net = networks->begin(); net != networks->end(); ++net) {
+ for (auto const& net : *networks) {
// For each network go through all the subnets in it.
- const Subnet6SimpleCollection* subnets = (*net)->getAllSubnets();
+ const Subnet6SimpleCollection* subnets = net->getAllSubnets();
if (!subnets) {
// Shared network without subnets it weird, but we decided to
// accept such configurations.
}
// For each subnet, add it to a list of regular subnets.
- for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
- dest->add(*subnet);
+ for (auto const& subnet : *subnets) {
+ dest->add(subnet);
}
}
}
std::set<string> names;
// Let's go through all the networks one by one
- for (auto net = networks.begin(); net != networks.end(); ++net) {
+ for (auto const& net : networks) {
string txt;
// Let's check if all subnets have either the same interface
// or don't have the interface specified at all.
- string iface = (*net)->getIface();
+ string iface = net->getIface();
- const Subnet6SimpleCollection* subnets = (*net)->getAllSubnets();
+ const Subnet6SimpleCollection* subnets = net->getAllSubnets();
if (subnets) {
bool rapid_commit = false;
- // For each subnet, add it to a list of regular subnets.
- for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
+ // Rapid commit must either be enabled or disabled in all subnets
+ // in the shared network.
+ if (subnets->size()) {
+ // If this is the first subnet, remember the value.
+ rapid_commit = (*subnets->begin())->getRapidCommit();
+ }
- // Rapid commit must either be enabled or disabled in all subnets
- // in the shared network.
- if (subnet == subnets->begin()) {
- // If this is the first subnet, remember the value.
- rapid_commit = (*subnet)->getRapidCommit();
- } else {
- // Ok, this is the second or following subnets. The value
- // must match what was set in the first subnet.
- if (rapid_commit != (*subnet)->getRapidCommit()) {
- isc_throw(DhcpConfigError, "All subnets in a shared network "
- "must have the same rapid-commit value. Subnet "
- << (*subnet)->toText()
- << " has specified rapid-commit "
- << ( (*subnet)->getRapidCommit() ? "true" : "false")
- << ", but earlier subnet in the same shared-network"
- << " or the shared-network itself used rapid-commit "
- << (rapid_commit ? "true" : "false"));
- }
+ // For each subnet, add it to a list of regular subnets.
+ for (auto const& subnet : *subnets) {
+ // Ok, this is the second or following subnets. The value
+ // must match what was set in the first subnet.
+ if (rapid_commit != subnet->getRapidCommit()) {
+ isc_throw(DhcpConfigError, "All subnets in a shared network "
+ "must have the same rapid-commit value. Subnet "
+ << subnet->toText()
+ << " has specified rapid-commit "
+ << (subnet->getRapidCommit() ? "true" : "false")
+ << ", but earlier subnet in the same shared-network"
+ << " or the shared-network itself used rapid-commit "
+ << (rapid_commit ? "true" : "false"));
}
if (iface.empty()) {
- iface = (*subnet)->getIface();
+ iface = subnet->getIface();
continue;
}
- if ((*subnet)->getIface().empty()) {
+ if (subnet->getIface().empty()) {
continue;
}
- if ((*subnet)->getIface() != iface) {
- isc_throw(DhcpConfigError, "Subnet " << (*subnet)->toText()
- << " has specified interface " << (*subnet)->getIface()
+ if (subnet->getIface() != iface) {
+ isc_throw(DhcpConfigError, "Subnet " << subnet->toText()
+ << " has specified interface " << subnet->getIface()
<< ", but earlier subnet in the same shared-network"
<< " or the shared-network itself used " << iface);
}
// Let's collect the subnets in case we later find out the
// subnet doesn't have a mandatory name.
- txt += (*subnet)->toText() + " ";
+ txt += subnet->toText() + " ";
}
}
// Next, let's check name of the shared network.
- if ((*net)->getName().empty()) {
+ if (net->getName().empty()) {
isc_throw(DhcpConfigError, "Shared-network with subnets "
<< txt << " is missing mandatory 'name' parameter");
}
// Is it unique?
- if (names.find((*net)->getName()) != names.end()) {
+ if (names.find(net->getName()) != names.end()) {
isc_throw(DhcpConfigError, "A shared-network with "
- "name " << (*net)->getName() << " defined twice.");
+ "name " << net->getName() << " defined twice.");
}
- names.insert((*net)->getName());
+ names.insert(net->getName());
}
}
HostCollection hosts;
HostReservationsListParser<HostReservationParser6> parser;
parser.parse(SUBNET_ID_GLOBAL, reservations, hosts);
- for (auto h = hosts.begin(); h != hosts.end(); ++h) {
- srv_config->getCfgHosts()->add(*h);
+ for (auto const& h : hosts) {
+ srv_config->getCfgHosts()->add(h);
}
}
}
// Make parsers grouping.
- ConfigPair config_pair;
const std::map<std::string, ConstElementPtr>& values_map =
mutable_cfg->mapValue();
- BOOST_FOREACH(config_pair, values_map) {
-
+ for (auto const& config_pair : values_map) {
parameter_name = config_pair.first;
// These are converted to SimpleParser and are handled already above.
// Append argument names.
std::vector<std::string> args = handle.getArgumentNames();
- for (auto arg = args.begin(); arg != args.end(); ++arg) {
- if (appendArgument(SRV_CONFIG_MARKER_FILE, arg->c_str()) != 0) {
+ for (auto const& arg : args) {
+ if (appendArgument(SRV_CONFIG_MARKER_FILE, arg.c_str()) != 0) {
return (1);
}
}
#include <dhcp6/tests/dhcp6_test_utils.h>
#include <dhcp6/tests/get_config_unittest.h>
-#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <iostream>
#include "dhcp6_test_utils.h"
#include "get_config_unittest.h"
-#include <boost/foreach.hpp>
#include <gtest/gtest.h>
+#include <boost/foreach.hpp>
#include <fstream>
#include <iostream>
#include <sstream>
" \"subnet\": \"2001:db8:1::/64\", "
" \"option-data\": [ {";
bool first = true;
- typedef std::pair<std::string, std::string> ParamPair;
- BOOST_FOREACH(ParamPair param, params) {
+ for (auto const& param : params) {
if (!first) {
stream << ", ";
} else {
// Iterate over the list of scenarios. Each should fail to parse with
// a specific error message.
for (auto const& scenario : scenarios) {
- {
- SCOPED_TRACE(scenario.description_);
- ConstElementPtr config;
- ASSERT_NO_THROW(config = parseDHCP6(scenario.config_json_))
- << "invalid json, broken test";
- ConstElementPtr status;
- EXPECT_NO_THROW(status = Dhcpv6SrvTest::configure(srv_, config));
- checkResult(status, 1);
- EXPECT_EQ(comment_->stringValue(), scenario.exp_error_msg_);
- }
+ SCOPED_TRACE(scenario.description_);
+ ConstElementPtr config;
+ ASSERT_NO_THROW(config = parseDHCP6(scenario.config_json_))
+ << "invalid json, broken test";
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = Dhcpv6SrvTest::configure(srv_, config));
+ checkResult(status, 1);
+ EXPECT_EQ(comment_->stringValue(), scenario.exp_error_msg_);
}
}
/// @param range Range of reservations returned by the @c Host object
/// 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);
}
}
};
std::ostringstream s;
+ bool first = true;
s << "{ \"arguments\": { ";
- for (auto st = initial_stats.begin(); st != initial_stats.end();) {
- s << "\"" << *st << "\": [ [ 0, \"";
- s << isc::util::clockToText(StatsMgr::instance().getObservation(*st)->getInteger().second);
- s << "\" ] ]";
- if (++st != initial_stats.end()) {
+ for (auto const& st : initial_stats) {
+ if (!first) {
s << ", ";
+ } else {
+ first = false;
}
+ s << "\"" << st << "\": [ [ 0, \"";
+ s << isc::util::clockToText(StatsMgr::instance().getObservation(st)->getInteger().second);
+ s << "\" ] ]";
}
s << " }, \"result\": 0 }";
#include <dhcp6/tests/dhcp6_client.h>
#include <util/buffer.h>
#include <util/multi_threading_mgr.h>
-#include <boost/foreach.hpp>
#include <boost/pointer_cast.hpp>
#include <algorithm>
#include <cstdlib>
void
Dhcp6Client::appendRequestedIAs(const Pkt6Ptr& query) const {
- BOOST_FOREACH(const ClientIA& ia, client_ias_) {
+ for (auto const& ia : client_ias_) {
OptionCollection options =
query->getOptions(ia.type_ == Lease::TYPE_NA ?
D6O_IA_NA : D6O_IA_PD);
- std::pair<unsigned int, OptionPtr> option_pair;
Option6IAPtr existing_ia;
- BOOST_FOREACH(option_pair, options) {
+ for (auto const& option_pair : options) {
Option6IAPtr ia_opt =
boost::dynamic_pointer_cast<Option6IA>(option_pair.second);
// This shouldn't happen.
if ((ia.type_ == Lease::TYPE_NA) && !ia.prefix_.isV6Zero()) {
Option6IAAddrPtr ia_addr(new Option6IAAddr(D6O_IAADDR, ia.prefix_,
0, 0));
- BOOST_FOREACH(option_pair, existing_ia->getOptions()) {
+ for (auto const& option_pair : existing_ia->getOptions()) {
Option6IAAddrPtr existing_addr = boost::dynamic_pointer_cast<
Option6IAAddr>(option_pair.second);
if (existing_addr &&
ia.prefix_,
ia.prefix_len_,
0, 0));
- BOOST_FOREACH(option_pair, existing_ia->getOptions()) {
+ for (auto const& option_pair : existing_ia->getOptions()) {
Option6IAPrefixPtr existing_prefix =
boost::dynamic_pointer_cast<Option6IAPrefix>(option_pair.second);
if (existing_prefix &&
typedef OptionCollection Opts;
// Copy IA_NAs.
Opts opts = source->getOptions(D6O_IA_NA);
- for (Opts::const_iterator opt = opts.begin(); opt != opts.end(); ++opt) {
+ for (auto const& opt : opts) {
// Only copy the entire IA_NA if there is at lease one IA Address option.
- if (opt->second->getOption(D6O_IAADDR)) {
- dest->addOption(opt->second);
+ if (opt.second->getOption(D6O_IAADDR)) {
+ dest->addOption(opt.second);
}
}
// Copy IA_PDs.
opts = source->getOptions(D6O_IA_PD);
- for (Opts::const_iterator opt = opts.begin(); opt != opts.end(); ++opt) {
+ for (auto const& opt : opts) {
// Only copy the entire IA_PD if there is at least one IA Prefix option
// in it.
- if (opt->second->getOption(D6O_IAPREFIX)) {
- dest->addOption(opt->second);
+ if (opt.second->getOption(D6O_IAPREFIX)) {
+ dest->addOption(opt.second);
}
}
}
// Go over leases and create IA_NA and IA_PD options from them.
// Create one IA per lease.
std::set<uint32_t> iaids = getIAIDs();
- for (std::set<uint32_t>::const_iterator iaid = iaids.begin();
- iaid != iaids.end(); ++iaid) {
- std::vector<Lease6> leases = getLeasesByIAID(*iaid);
+ for (auto const& iaid : iaids) {
+ std::vector<Lease6> leases = getLeasesByIAID(iaid);
// Only a valid lease should be included. Do not copy a
// lease which have been marked by the server as invalid.
if (leases[0].valid_lft_ == 0) {
continue;
}
Option6IAPtr opt(new Option6IA(leases[0].type_ == Lease::TYPE_NA ?
- D6O_IA_NA : D6O_IA_PD, *iaid));
- for (std::vector<Lease6>::const_iterator lease = leases.begin();
- lease != leases.end(); ++lease) {
- if ((lease->preferred_lft_ != 0) && (lease->valid_lft_ != 0)) {
- if (lease->type_ == Lease::TYPE_NA) {
- opt->addOption(Option6IAAddrPtr(new Option6IAAddr(
- D6O_IAADDR,
- lease->addr_,
- lease->preferred_lft_,
- lease->valid_lft_)));
- } else if (lease->type_ == Lease::TYPE_PD) {
- opt->addOption(Option6IAAddrPtr(new Option6IAPrefix(
- D6O_IAPREFIX,
- lease->addr_,
- lease->prefixlen_,
- lease->preferred_lft_,
- lease->valid_lft_)));
+ D6O_IA_NA : D6O_IA_PD, iaid));
+ for (auto const& lease : leases) {
+ if ((lease.preferred_lft_ != 0) && (lease.valid_lft_ != 0)) {
+ if (lease.type_ == Lease::TYPE_NA) {
+ opt->addOption(Option6IAAddrPtr(new Option6IAAddr(D6O_IAADDR,
+ lease.addr_,
+ lease.preferred_lft_,
+ lease.valid_lft_)));
+ } else if (lease.type_ == Lease::TYPE_PD) {
+ opt->addOption(Option6IAAddrPtr(new Option6IAPrefix(D6O_IAPREFIX,
+ lease.addr_,
+ lease.prefixlen_,
+ lease.preferred_lft_,
+ lease.valid_lft_)));
}
}
}
// If there are any custom options specified, add them all to the message.
if (!extra_options_.empty()) {
- for (OptionCollection::iterator opt = extra_options_.begin();
- opt != extra_options_.end(); ++opt) {
- msg->addOption(opt->second);
+ for (auto const& opt : extra_options_) {
+ msg->addOption(opt.second);
}
}
// Add classes.
- for (ClientClasses::const_iterator cclass = classes_.cbegin();
- cclass != classes_.cend(); ++cclass) {
- msg->addClass(*cclass);
+ for (auto const& cclass : classes_) {
+ msg->addClass(cclass);
}
return (msg);
const bool include_address) {
/// @todo: add support for IAPREFIX here.
- for (std::vector<Lease6>::const_iterator lease = config_.leases_.begin();
- lease != config_.leases_.end(); ++lease) {
- if (lease->type_ != Lease::TYPE_NA) {
+ for (auto const& lease : config_.leases_) {
+ if (lease.type_ != Lease::TYPE_NA) {
continue;
}
- Option6IAPtr ia(new Option6IA(D6O_IA_NA, lease->iaid_));
+ Option6IAPtr ia(new Option6IA(D6O_IA_NA, lease.iaid_));
if (include_address) {
ia->addOption(OptionPtr(new Option6IAAddr(D6O_IAADDR,
- lease->addr_, lease->preferred_lft_, lease->valid_lft_)));
+ lease.addr_,
+ lease.preferred_lft_,
+ lease.valid_lft_)));
}
query->addOption(ia);
}
std::set<uint32_t>
Dhcp6Client::getIAIDs() const {
std::set<uint32_t> iaids;
- for (std::vector<Lease6>::const_iterator lease = config_.leases_.begin();
- lease != config_.leases_.end(); ++lease) {
- iaids.insert(lease->iaid_);
+ for (auto const& lease : config_.leases_) {
+ iaids.insert(lease.iaid_);
}
return (iaids);
}
Dhcp6Client::hasLeaseForAddress(const asiolink::IOAddress& address,
const IAID& iaid) const {
std::vector<Lease6> leases = getLeasesByAddress(address);
- BOOST_FOREACH(const Lease6& lease, leases) {
+ for (auto const& lease : leases) {
if (lease.iaid_ == iaid) {
return (true);
}
bool
Dhcp6Client::hasLeaseWithZeroLifetimeForAddress(const asiolink::IOAddress& address) const {
std::vector<Lease6> leases = getLeasesByAddress(address);
- BOOST_FOREACH(const Lease6& lease, leases) {
+ for (auto const& lease : leases) {
if ((lease.preferred_lft_ == 0) && (lease.valid_lft_ == 0)) {
return (true);
}
Dhcp6Client::hasLeaseForPrefix(const asiolink::IOAddress& prefix,
const uint8_t prefix_len) const {
std::vector<Lease6> leases = getLeasesByAddress(prefix);
- BOOST_FOREACH(const Lease6& lease, leases) {
+ for (auto const& lease : leases) {
if (lease.prefixlen_ == prefix_len) {
return (true);
}
const uint8_t prefix_len,
const IAID& iaid) const {
std::vector<Lease6> leases = getLeasesByAddress(prefix);
- BOOST_FOREACH(const Lease6& lease, leases) {
+ for (auto const& lease : leases) {
if ((lease.prefixlen_ == prefix_len) &&
(lease.iaid_ == iaid)) {
return (true);
Dhcp6Client::hasLeaseWithZeroLifetimeForPrefix(const asiolink::IOAddress& prefix,
const uint8_t prefix_len) const {
std::vector<Lease6> leases = getLeasesByAddress(prefix);
- BOOST_FOREACH(const Lease6& lease, leases) {
+ for (auto const& lease : leases) {
if ((lease.prefixlen_ == prefix_len) && (lease.preferred_lft_ == 0) &&
(lease.valid_lft_ == 0)) {
return (true);
// Copy classes
const ClientClasses& classes = msg->getClasses();
- for (ClientClasses::const_iterator cclass = classes.cbegin();
- cclass != classes.cend(); ++cclass) {
- msg_copy->addClass(*cclass);
+ for (auto const& cclass : classes) {
+ msg_copy->addClass(cclass);
}
srv_->fakeReceive(msg_copy);
removeTlsParameters(hosts);
hosts = dhcp6->get("hosts-databases");
if (hosts) {
- for (auto& host : hosts->listValue()) {
+ for (auto const& host : hosts->listValue()) {
removeTlsParameters(host);
}
}
"with-ddns.json",
};
vector<string> files;
- for (const string& example : examples) {
+ for (auto const& example : examples) {
string file = path + "/" + example;
files.push_back(file);
}
int count120 = 0; // Let's count how many times option 120 was echoed back
int count130 = 0; // Let's count how many times option 130 was echoed back
OptionPtr opt120;
- for (OptionCollection::const_iterator it = client.config_.options_.begin();
- it != client.config_.options_.end(); ++it) {
- switch (it->second->getType()) {
+ for (auto const& it : client.config_.options_) {
+ switch (it.second->getType()) {
case 110:
count110++;
break;
case 120:
count120++;
- opt120 = it->second;
+ opt120 = it.second;
break;
case 130:
count130++;
// it will return it with zeroed lifetimes.
if (check_addr) {
dhcp::OptionCollection options = ia->getOptions();
- for (isc::dhcp::OptionCollection::iterator opt = options.begin();
- opt != options.end(); ++opt) {
- if (opt->second->getType() != D6O_IAADDR) {
+ for (auto const& opt : options) {
+ if (opt.second->getType() != D6O_IAADDR) {
continue;
}
dhcp::Option6IAAddrPtr addr =
- boost::dynamic_pointer_cast<isc::dhcp::Option6IAAddr>(opt->second);
+ boost::dynamic_pointer_cast<isc::dhcp::Option6IAAddr>(opt.second);
ASSERT_TRUE(addr);
EXPECT_EQ(0, addr->getPreferred());
// Checks if callouts installed on the dhcp6_srv_configured ared indeed called
// and all the necessary parameters are passed.
TEST_F(LoadUnloadDhcpv6SrvTest, Dhcpv6SrvConfigured) {
- for (const string& parameters : vector<string>{
+ for (auto const& parameters : vector<string>{
"",
R"(, "parameters": { "mode": "fail-without-error" } )",
R"(, "parameters": { "mode": "fail-with-error" } )"}) {
Subnet6Ptr getConfiguredSubnet(const Lease::Type& type, const IOAddress& resource) const {
CfgSubnets6Ptr cfg = CfgMgr::instance().getCurrentCfg()->getCfgSubnets6();
const Subnet6Collection* subnets = cfg->getAll();
- for (auto subnet_it = subnets->cbegin(); subnet_it != subnets->cend(); ++subnet_it) {
- if ((*subnet_it)->inPool(type, resource)) {
- return (*subnet_it);
+ for (auto const& subnet_it : *subnets) {
+ if (subnet_it->inPool(type, resource)) {
+ return (subnet_it);
}
}
bool hasLeaseForAddressRange(Dhcp6Client& client, const IOAddress& first, const IOAddress& last,
const LeaseOnServer& lease_on_server = LeaseOnServer::MUST_EXIST) {
std::vector<Lease6> leases = client.getLeasesByAddressRange(first, last);
- for (auto lease_it = leases.cbegin(); lease_it != leases.cend(); ++lease_it) {
+ for (auto const& lease_it : leases) {
// Take into account only valid leases.
- if (lease_it->valid_lft_ == 0) {
+ if (lease_it.valid_lft_ == 0) {
continue;
}
- Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, lease_it->addr_);
+ Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, lease_it.addr_);
if ((lease && (lease_on_server == LeaseOnServer::MUST_NOT_EXIST)) ||
(!lease && (lease_on_server == LeaseOnServer::MUST_EXIST))) {
return (false);
const LeaseOnServer& lease_on_server = LeaseOnServer::MUST_EXIST) {
std::vector<Lease6> leases = client.getLeasesByPrefixPool(prefix, prefix_len, delegated_len);
- for (auto lease_it = leases.cbegin(); lease_it != leases.cend(); ++lease_it) {
+ for (auto const& lease_it : leases) {
// Take into account only valid leases.
- if (lease_it->valid_lft_ == 0) {
+ if (lease_it.valid_lft_ == 0) {
continue;
}
- Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_PD, lease_it->addr_);
+ Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_PD, lease_it.addr_);
if ((lease && (lease->prefixlen_ == lease->prefixlen_) &&
(lease_on_server == LeaseOnServer::MUST_NOT_EXIST)) ||
(!lease && (lease_on_server == LeaseOnServer::MUST_EXIST))) {
// If there are any options on the list, we will use provided
// options offsets to override them in the output buffer
// with new contents.
- for (OptionCollection::const_iterator it = options.begin();
- it != options.end(); ++it) {
+ for (auto const& it : options) {
// Get options with their position (offset).
boost::shared_ptr<LocalizedOption> option =
- boost::dynamic_pointer_cast<LocalizedOption>(it->second);
+ boost::dynamic_pointer_cast<LocalizedOption>(it.second);
if (option == NULL) {
isc_throw(isc::BadValue, "option is null");
}
out_buffer.writeUint8At(buf_data[i], offset + i);
}
}
- }
- catch (const Exception&) {
+ } catch (const Exception&) {
isc_throw(isc::BadValue, "failed to pack options into buffer.");
}
}
void
PktTransform::unpackOptions(const OptionBuffer& in_buffer,
const OptionCollection& options) {
- for (OptionCollection::const_iterator it = options.begin();
- it != options.end(); ++it) {
+ for (auto const& it : options) {
boost::shared_ptr<LocalizedOption> option =
- boost::dynamic_pointer_cast<LocalizedOption>(it->second);
+ boost::dynamic_pointer_cast<LocalizedOption>(it.second);
if (option == NULL) {
isc_throw(isc::BadValue, "option is null");
}
#include <dhcp/pkt4.h>
#include <perfdhcp/stats_mgr.h>
#include <perfdhcp/test_control.h>
+#include <boost/foreach.hpp>
using isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER;
using isc::dhcp::DUID;
using namespace boost::posix_time;
// Iterate through all received packets.
- for (PktListIterator it = rcvd_packets_.begin();
- it != rcvd_packets_.end();
- ++it) {
- PktPtr rcvd_packet = *it;
+ for (auto const& it : rcvd_packets_) {
+ PktPtr rcvd_packet = it;
PktListTransidHashIndex& idx =
archived_packets_.template get<1>();
std::pair<PktListTransidHashIterator,
PktListTransidHashIterator> p =
idx.equal_range(hashTransid(rcvd_packet));
- for (PktListTransidHashIterator it_archived = p.first;
- it_archived != p.second;
- ++it_archived) {
- if ((*it_archived)->getTransid() ==
- rcvd_packet->getTransid()) {
- PktPtr sent_packet = *it_archived;
+ BOOST_FOREACH(auto const& it_archived, p) {
+ if (it_archived->getTransid() == rcvd_packet->getTransid()) {
+ PktPtr sent_packet = it_archived;
// Get sent and received packet times.
ptime sent_time = sent_packet->getTimestamp();
ptime rcvd_time = rcvd_packet->getTimestamp();
/// \code
/// PktList packets_collection();
/// ... # Add elements to the container
- /// for (PktListIterator it = packets_collection.begin();
- /// it != packets_collection.end();
- /// ++it) {
- /// boost::shared_ptr<Pkt4> pkt = *it;
+ /// for (auto const& it : packets_collection) {
+ /// boost::shared_ptr<Pkt4> pkt = it;
/// # Do something with packet;
/// }
/// \endcode
///
// \return true, if packet drops occurred.
bool droppedPackets() const {
- for (ExchangesMapIterator it = exchanges_.begin();
- it != exchanges_.end();
- ++it) {
- if (it->second->getDroppedPacketsNum() > 0) {
+ for (auto const& it : exchanges_) {
+ if (it.second->getDroppedPacketsNum() > 0) {
return (true);
}
}
isc_throw(isc::InvalidOperation,
"no exchange type added for tracking");
}
- for (ExchangesMapIterator it = exchanges_.begin();
- it != exchanges_.end();
- ++it) {
- ExchangeStatsPtr xchg_stats = it->second;
- std::cout << "***Statistics for: " << it->first
+ for (auto const& it : exchanges_) {
+ ExchangeStatsPtr xchg_stats = it.second;
+ std::cout << "***Statistics for: " << it.first
<< "***" << std::endl;
xchg_stats->printMainStats();
std::cout << std::endl;
std::ostringstream stream_drops;
std::ostringstream stream_reject;
std::string sep("");
- for (ExchangesMapIterator it = exchanges_.begin();
- it != exchanges_.end(); ++it) {
-
- if (it != exchanges_.begin()) {
+ bool first = true;
+ for (auto const& it : exchanges_) {
+ if (!first) {
if (clean_report) {
sep = clean_sep;
} else {
sep = "/";
}
+ } else {
+ first = false;
}
- stream_sent << sep << it->second->getSentPacketsNum();
- stream_rcvd << sep << it->second->getRcvdPacketsNum();
- stream_drops << sep << it->second->getDroppedPacketsNum();
- stream_reject << sep << it->second->getRejLeasesNum();
+ stream_sent << sep << it.second->getSentPacketsNum();
+ stream_rcvd << sep << it.second->getRcvdPacketsNum();
+ stream_drops << sep << it.second->getDroppedPacketsNum();
+ stream_reject << sep << it.second->getRejLeasesNum();
}
if (clean_report) {
- std::cout << stream_sent.str()
- << clean_sep << stream_rcvd.str()
- << clean_sep << stream_drops.str()
- << clean_sep << stream_reject.str()
- << std::endl;
+ std::cout << stream_sent.str()
+ << clean_sep << stream_rcvd.str()
+ << clean_sep << stream_drops.str()
+ << clean_sep << stream_reject.str()
+ << std::endl;
} else {
- std::cout << "sent: " << stream_sent.str()
- << "; received: " << stream_rcvd.str()
- << "; drops: " << stream_drops.str()
- << "; rejected: " << stream_reject.str()
- << std::endl;
+ std::cout << "sent: " << stream_sent.str()
+ << "; received: " << stream_rcvd.str()
+ << "; drops: " << stream_drops.str()
+ << "; rejected: " << stream_reject.str()
+ << std::endl;
}
}
isc_throw(isc::InvalidOperation,
"no exchange type added for tracking");
}
- for (ExchangesMapIterator it = exchanges_.begin();
- it != exchanges_.end();
- ++it) {
- ExchangeStatsPtr xchg_stats = it->second;
+ for (auto const& it : exchanges_) {
+ ExchangeStatsPtr xchg_stats = it.second;
std::cout << "***Timestamps for packets: "
- << it->first
+ << it.first
<< "***" << std::endl;
xchg_stats->printTimestamps();
std::cout << std::endl;
if (custom_counters_.empty()) {
isc_throw(isc::InvalidOperation, "no custom counters specified");
}
- for (CustomCountersMapIterator it = custom_counters_.begin();
- it != custom_counters_.end();
- ++it) {
- CustomCounterPtr counter = it->second;
+ for (auto const& it : custom_counters_) {
+ CustomCounterPtr counter = it.second;
std::cout << counter->getName() << ": " << counter->getValue()
<< std::endl;
}
}
- std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> getSentPackets(const ExchangeType xchg_type) const {
+ std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator>
+ getSentPackets(const ExchangeType xchg_type) const {
ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
- std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> sent_packets_its = xchg_stats->getSentPackets();
- return(sent_packets_its);
+ std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> sent_packets_its =
+ xchg_stats->getSentPackets();
+ return (sent_packets_its);
}
private:
template_packets_v6_.clear();
template_buffers_.clear();
std::vector<std::string> template_files = options_.getTemplateFiles();
- for (std::vector<std::string>::const_iterator it = template_files.begin();
- it != template_files.end(); ++it) {
- readPacketTemplate(*it);
+ for (auto const& it : template_files) {
+ readPacketTemplate(it);
}
}
TestControl::vector2Hex(const std::vector<uint8_t>& vec,
const std::string& separator /* = "" */) {
std::ostringstream stream;
- for (std::vector<uint8_t>::const_iterator it = vec.begin();
- it != vec.end();
- ++it) {
- if (it == vec.begin()) {
- stream << byte2Hex(*it);
+ bool first = true;
+ for (auto const& it : vec) {
+ if (first) {
+ stream << byte2Hex(it);
+ first = false;
} else {
- stream << separator << byte2Hex(*it);
+ stream << separator << byte2Hex(it);
}
}
return (stream.str());
void addUniqeAddr(const std::set<std::string>& current, ExchangeType xchg_type) {
switch(xchg_type) {
case ExchangeType::SA: {
- for (auto current_it = current.begin();
- current_it != current.end(); ++current_it) {
+ for (auto const& current_it : current) {
// addresses should be unique cross packets
- auto ret = unique_address_.emplace(*current_it);
+ auto ret = unique_address_.emplace(current_it);
if (!ret.second) {
stats_mgr_.updateNonUniqueAddrNum(ExchangeType::SA);
}
break;
}
case ExchangeType::RR: {
- for (auto current_it = current.begin();
- current_it != current.end(); ++current_it) {
+ for (auto const& current_it : current) {
// addresses should be unique cross packets
- auto ret = unique_reply_address_.emplace(*current_it);
+ auto ret = unique_reply_address_.emplace(current_it);
if (!ret.second) {
stats_mgr_.updateNonUniqueAddrNum(ExchangeType::RR);
}
break;
}
case ExchangeType::DO: {
- for (auto current_it = current.begin();
- current_it != current.end(); ++current_it) {
+ for (auto const& current_it : current) {
// addresses should be unique cross packets
- auto ret = unique_address_.emplace(*current_it);
+ auto ret = unique_address_.emplace(current_it);
if (!ret.second) {
stats_mgr_.updateNonUniqueAddrNum(ExchangeType::DO);
}
break;
}
case ExchangeType::RA: {
- for (auto current_it = current.begin();
- current_it != current.end(); ++current_it) {
+ for (auto const& current_it : current) {
// addresses should be unique cross packets
- auto ret = unique_reply_address_.emplace(*current_it);
+ auto ret = unique_reply_address_.emplace(current_it);
if (!ret.second) {
stats_mgr_.updateNonUniqueAddrNum(ExchangeType::RA);
}
///
/// \param addr holding value of unique address.
void removeUniqueAddr(const std::set<std::string>& addr) {
- for (auto addr_it = addr.begin(); addr_it != addr.end(); ++addr_it) {
- auto it = unique_address_.find(*addr_it);
+ for (auto const& addr_it : addr) {
+ auto it = unique_address_.find(addr_it);
if (it != unique_address_.end()) {
unique_address_.erase(it);
}
- auto it2 = unique_reply_address_.find(*addr_it);
+ auto it2 = unique_reply_address_.find(addr_it);
if (it2 != unique_reply_address_.end()) {
unique_reply_address_.erase(it2);
}
#include <dhcp/option6_iaprefix.h>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
#include <algorithm>
#include <cstddef>
#include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_iaprefix.h>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
#include <algorithm>
#include <cstddef>
#include <config.h>
-#include "command_options_helper.h"
-#include "../perf_socket.h"
+#include <command_options_helper.h>
+#include <perf_socket.h>
#include <asiolink/io_address.h>
#include <exceptions/exceptions.h>
#include <dhcp/iface_mgr.h>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
#include <algorithm>
#include <cstddef>
#include <config.h>
-#include "command_options_helper.h"
-#include "../test_control.h"
+#include <command_options_helper.h>
+#include <test_control.h>
#include <asiolink/io_address.h>
#include <exceptions/exceptions.h>
#include <dhcp/option6_iaprefix.h>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <algorithm>
CommandCreator::createLease6BulkApply(const Lease6CollectionPtr& leases,
const Lease6CollectionPtr& deleted_leases) {
ElementPtr deleted_leases_list = Element::createList();
- for (auto lease = deleted_leases->begin(); lease != deleted_leases->end();
- ++lease) {
- ElementPtr lease_as_json = (*lease)->toElement();
+ for (auto const& lease : *deleted_leases) {
+ ElementPtr lease_as_json = lease->toElement();
insertLeaseExpireTime(lease_as_json);
deleted_leases_list->add(lease_as_json);
}
ElementPtr leases_list = Element::createList();
- for (auto lease = leases->begin(); lease != leases->end();
- ++lease) {
- ElementPtr lease_as_json = (*lease)->toElement();
+ for (auto const& lease : *leases) {
+ ElementPtr lease_as_json = lease->toElement();
insertLeaseExpireTime(lease_as_json);
leases_list->add(lease_as_json);
}
HAConfig::PeerConfigPtr
HAConfig::getFailoverPeerConfig() const {
PeerConfigMap servers = getOtherServersConfig();
- for (auto peer = servers.begin(); peer != servers.end(); ++peer) {
- if (peer->second->getRole() != HAConfig::PeerConfig::BACKUP) {
- return (peer->second);
+ for (auto const& peer : servers) {
+ if (peer.second->getRole() != HAConfig::PeerConfig::BACKUP) {
+ return (peer.second);
}
}
// Gather all the roles and see how many occurrences of each role we get.
std::map<PeerConfig::Role, unsigned> peers_cnt;
- for (auto p = peers_.begin(); p != peers_.end(); ++p) {
- if (!p->second->getUrl().isValid()) {
+ for (auto const& p : peers_) {
+ if (!p.second->getUrl().isValid()) {
isc_throw(HAConfigValidationError, "invalid URL: "
- << p->second->getUrl().getErrorMessage()
- << " for server " << p->second->getName());
+ << p.second->getUrl().getErrorMessage()
+ << " for server " << p.second->getName());
}
// The hostname must be an address, not a name.
IOAddress addr("::");
try {
- addr = IOAddress(p->second->getUrl().getStrippedHostname());
+ addr = IOAddress(p.second->getUrl().getStrippedHostname());
} catch (const IOError& ex) {
isc_throw(HAConfigValidationError, "bad url '"
- << p->second->getUrl().toText()
+ << p.second->getUrl().toText()
<< "': " << ex.what()
- << " for server " << p->second->getName());
+ << " for server " << p.second->getName());
}
// Check TLS setup.
- Optional<std::string> ca = p->second->getTrustAnchor();
- Optional<std::string> cert = p->second->getCertFile();
- Optional<std::string> key = p->second->getKeyFile();
+ Optional<std::string> ca = p.second->getTrustAnchor();
+ Optional<std::string> cert = p.second->getCertFile();
+ Optional<std::string> key = p.second->getKeyFile();
// When not configured get the value from the global level.
if (ca.unspecified()) {
ca = trust_anchor_;
TlsRole tls_role = TlsRole::CLIENT;
bool cert_required = true;
// The peer entry for myself will be used for the server side.
- if (p->second->getName() == getThisServerName()) {
+ if (p.second->getName() == getThisServerName()) {
tls_role = TlsRole::SERVER;
cert_required = getRequireClientCerts();
}
- TlsContext::configure(p->second->tls_context_,
+ TlsContext::configure(p.second->tls_context_,
tls_role,
ca.get(),
cert.get(),
cert_required);
} catch (const isc::Exception& ex) {
isc_throw(HAConfigValidationError, "bad TLS config for server "
- << p->second->getName() << ": " << ex.what());
+ << p.second->getName() << ": " << ex.what());
}
} else {
// Refuse HTTPS scheme when TLS is not enabled.
- if (p->second->getUrl().getScheme() == Url::HTTPS) {
+ if (p.second->getUrl().getScheme() == Url::HTTPS) {
isc_throw(HAConfigValidationError, "bad url '"
- << p->second->getUrl().toText()
+ << p.second->getUrl().toText()
<< "': https scheme is not supported"
- << " for server " << p->second->getName()
+ << " for server " << p.second->getName()
<< " where TLS is disabled");
}
}
- ++peers_cnt[p->second->getRole()];
+ ++peers_cnt[p.second->getRole()];
}
// Only one primary server allowed.
auto const& peers_vec = peers->listValue();
// Go over configuration of each peer.
- for (auto p = peers_vec.begin(); p != peers_vec.end(); ++p) {
+ for (auto const& p : peers_vec) {
// Peer configuration is held in a map.
- if ((*p)->getType() != Element::map) {
+ if (p->getType() != Element::map) {
isc_throw(ConfigError, "peer configuration must be a map");
}
- setDefaults(*p, HA_CONFIG_PEER_DEFAULTS);
+ setDefaults(p, HA_CONFIG_PEER_DEFAULTS);
// Server name.
- auto cfg = rel_config->selectNextPeerConfig(getString(*p, "name"));
+ auto cfg = rel_config->selectNextPeerConfig(getString(p, "name"));
// URL.
- cfg->setUrl(Url(getString((*p), "url")));
+ cfg->setUrl(Url(getString(p, "url")));
// Optional trust anchor.
- if ((*p)->contains("trust-anchor")) {
- cfg->setTrustAnchor(getString(*p, ("trust-anchor")));
+ if (p->contains("trust-anchor")) {
+ cfg->setTrustAnchor(getString(p, ("trust-anchor")));
}
// Optional certificate file.
- if ((*p)->contains("cert-file")) {
- cfg->setCertFile(getString(*p, ("cert-file")));
+ if (p->contains("cert-file")) {
+ cfg->setCertFile(getString(p, ("cert-file")));
}
// Optional private key file.
- if ((*p)->contains("key-file")) {
- cfg->setKeyFile(getString(*p, ("key-file")));
+ if (p->contains("key-file")) {
+ cfg->setKeyFile(getString(p, ("key-file")));
}
// Role.
- cfg->setRole(getString(*p, "role"));
+ cfg->setRole(getString(p, "role"));
// Auto failover configuration.
- cfg->setAutoFailover(getBoolean(*p, "auto-failover"));
+ cfg->setAutoFailover(getBoolean(p, "auto-failover"));
// Basic HTTP authentication password.
std::string password;
- if ((*p)->contains("basic-auth-password")) {
- if ((*p)->contains("basic-auth-password-file")) {
+ if (p->contains("basic-auth-password")) {
+ if (p->contains("basic-auth-password-file")) {
isc_throw(dhcp::DhcpConfigError, "only one of "
<< "basic-auth-password and "
<< "basic-auth-password-file parameter can be "
<< "configured in peer '"
<< cfg->getName() << "'");
}
- password = getString((*p), "basic-auth-password");
+ password = getString(p, "basic-auth-password");
}
- if ((*p)->contains("basic-auth-password-file")) {
+ if (p->contains("basic-auth-password-file")) {
std::string password_file =
- getString((*p), "basic-auth-password-file");
+ getString(p, "basic-auth-password-file");
try {
password = util::file::getContent(password_file);
} catch (const std::exception& ex) {
}
// Basic HTTP authentication user.
- if ((*p)->contains("basic-auth-user")) {
- std::string user = getString((*p), "basic-auth-user");
+ if (p->contains("basic-auth-user")) {
+ std::string user = getString(p, "basic-auth-user");
BasicHttpAuthPtr& auth = cfg->getBasicAuth();
try {
if (!user.empty()) {
std::set<int> configured_states;
// Go over per state configurations.
- for (auto s = states_vec.begin(); s != states_vec.end(); ++s) {
+ for (auto const& s : states_vec) {
// State configuration is held in map.
- if ((*s)->getType() != Element::map) {
+ if (s->getType() != Element::map) {
isc_throw(ConfigError, "state configuration must be a map");
}
- setDefaults(*s, HA_CONFIG_STATE_DEFAULTS);
+ setDefaults(s, HA_CONFIG_STATE_DEFAULTS);
// Get state name and set per state configuration.
- std::string state_name = getString(*s, "state");
+ std::string state_name = getString(s, "state");
int state = stringToState(state_name);
// Check that this configuration doesn't duplicate existing configuration.
configured_states.insert(state);
rel_config->getStateMachineConfig()->
- getStateConfig(state)->setPausing(getString(*s, "pause"));
+ getStateConfig(state)->setPausing(getString(s, "pause"));
}
}
size_t sent_num = 0;
// Schedule sending lease updates to each peer.
- for (auto p = peers_configs.begin(); p != peers_configs.end(); ++p) {
- HAConfig::PeerConfigPtr conf = p->second;
+ for (auto const& p : peers_configs) {
+ HAConfig::PeerConfigPtr conf = p.second;
// Check if the lease updates should be queued. This is the case when the
// server is in the communication-recovery state. Queued lease updates may
// be sent when the communication is re-established.
if (shouldQueueLeaseUpdates(conf)) {
// Lease updates for deleted leases.
- for (auto l = deleted_leases->begin(); l != deleted_leases->end(); ++l) {
- lease_update_backlog_.push(LeaseUpdateBacklog::DELETE, *l);
+ for (auto const& l : *deleted_leases) {
+ lease_update_backlog_.push(LeaseUpdateBacklog::DELETE, l);
}
// Lease updates for new allocations and updated leases.
- for (auto l = leases->begin(); l != leases->end(); ++l) {
- lease_update_backlog_.push(LeaseUpdateBacklog::ADD, *l);
+ for (auto const& l : *leases) {
+ lease_update_backlog_.push(LeaseUpdateBacklog::ADD, l);
}
continue;
}
// Lease updates for deleted leases.
- for (auto l = deleted_leases->begin(); l != deleted_leases->end(); ++l) {
- asyncSendLeaseUpdate(query, conf, CommandCreator::createLease4Delete(**l),
+ for (auto const& l : *deleted_leases) {
+ asyncSendLeaseUpdate(query, conf, CommandCreator::createLease4Delete(*l),
parking_lot);
}
// Lease updates for new allocations and updated leases.
- for (auto l = leases->begin(); l != leases->end(); ++l) {
- asyncSendLeaseUpdate(query, conf, CommandCreator::createLease4Update(**l),
+ for (auto const& l : *leases) {
+ asyncSendLeaseUpdate(query, conf, CommandCreator::createLease4Update(*l),
parking_lot);
}
size_t sent_num = 0;
// Schedule sending lease updates to each peer.
- for (auto p = peers_configs.begin(); p != peers_configs.end(); ++p) {
- HAConfig::PeerConfigPtr conf = p->second;
+ for (auto const& p : peers_configs) {
+ HAConfig::PeerConfigPtr conf = p.second;
// Check if the lease updates should be queued. This is the case when the
// server is in the communication-recovery state. Queued lease updates may
// be sent when the communication is re-established.
if (shouldQueueLeaseUpdates(conf)) {
- for (auto l = deleted_leases->begin(); l != deleted_leases->end(); ++l) {
- lease_update_backlog_.push(LeaseUpdateBacklog::DELETE, *l);
+ for (auto const& l : *deleted_leases) {
+ lease_update_backlog_.push(LeaseUpdateBacklog::DELETE, l);
}
// Lease updates for new allocations and updated leases.
- for (auto l = leases->begin(); l != leases->end(); ++l) {
- lease_update_backlog_.push(LeaseUpdateBacklog::ADD, *l);
+ for (auto const& l : *leases) {
+ lease_update_backlog_.push(LeaseUpdateBacklog::ADD, l);
}
continue;
}
std::set<std::string> scopes = query_filter_.getServedScopes();
ElementPtr list = Element::createList();
- for (const std::string& scope : scopes) {
+ for (auto const& scope : scopes) {
list->add(Element::create(scope));
}
local->set("scopes", list);
LeaseSyncFilter::apply() {
subnet_ids_.clear();
if (server_type_ == HAServerType::DHCPv4) {
- for (auto subnet : *CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll()) {
+ for (auto const& subnet : *CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll()) {
conditionallyApplySubnetFilter(subnet);
}
} else {
- for (auto subnet : *CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll()) {
+ for (auto const& subnet : *CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll()) {
conditionallyApplySubnetFilter(subnet);
}
}
try {
auto server_name = HAConfig::getSubnetServerName(subnet);
if (!server_name.empty()) {
- for (auto peer : config_->getAllServersConfig()) {
+ for (auto const& peer : config_->getAllServersConfig()) {
if (peer.first == server_name) {
subnet_ids_.insert(subnet->getID());
return;
// The returned configurations are not ordered. Let's iterate over them
// and put them in the desired order.
- for (auto peer_pair = peers_map.begin(); peer_pair != peers_map.end(); ++peer_pair) {
- auto peer = peer_pair->second;
+ for (auto const& peer_pair : peers_map) {
+ auto peer = peer_pair.second;
// The primary server is always first on the list.
if (peer->getRole() == HAConfig::PeerConfig::PRIMARY) {
peers_.insert(peers_.begin(), peer);
// Iterate over the roles of all servers to see which scope should
// be enabled.
- for (auto peer = peers_.begin(); peer != peers_.end(); ++peer) {
+ for (auto const& peer : peers_) {
// The scope of the primary server must always be served. If we're
// doing load balancing, the scope of the secondary server also
// has to be served. Regardless if I am primary or secondary,
// I will start serving queries from both scopes. If I am a
// standby server, I will start serving the scope of the primary
// server.
- if (((*peer)->getRole() == HAConfig::PeerConfig::PRIMARY) ||
- ((*peer)->getRole() == HAConfig::PeerConfig::SECONDARY)) {
- serveScopeInternal((*peer)->getName());
+ if ((peer->getRole() == HAConfig::PeerConfig::PRIMARY) ||
+ (peer->getRole() == HAConfig::PeerConfig::SECONDARY)) {
+ serveScopeInternal(peer->getName());
}
}
}
scopes_.clear();
// Disable scope for each peer in the configuration.
- for (auto peer = peers_.begin(); peer != peers_.end(); ++peer) {
- scopes_[(*peer)->getName()] = false;
+ for (auto const& peer : peers_) {
+ scopes_[peer->getName()] = false;
}
}
// expiring in the future. Even entries have lifetimes expiring in
// the past.
Entries entries;
- for (auto i = 0; i < 1000; i++) {
+ for (auto i = 0; i < 1000; ++i) {
entries.insert({i, time(NULL) + (i % 2 ? 100 + i : -1 - i)});
}
// Get the count of valid entries. It should remove the expiring
template<typename LeasesVec>
ConstElementPtr getLeasesAsJson(const LeasesVec& leases) {
ElementPtr leases_json = Element::createList();
- for (auto l = leases.begin(); l != leases.end(); ++l) {
- leases_json->add((*l)->toElement());
+ for (auto const& l : leases) {
+ leases_json->add(l->toElement());
}
return (leases_json);
}
findRequest(const std::string& str1, const std::string& str2,
const std::string& str3 = "") {
std::lock_guard<std::mutex> lk(mutex_);
- for (auto r = requests_.begin(); r < requests_.end(); ++r) {
- std::string request_as_string = (*r)->toString();
+ for (auto const& r : requests_) {
+ std::string request_as_string = r->toString();
if (request_as_string.find(str1) != std::string::npos) {
if (request_as_string.find(str2) != std::string::npos) {
if (str3.empty() ||
(request_as_string.find(str3) != std::string::npos))
- return (*r);
+ return (r);
}
}
}
}
const std::vector<ElementPtr>& subnet_ids = subnets->listValue();
- for (auto subnet_id = subnet_ids.begin();
- subnet_id != subnet_ids.end();
- ++subnet_id) {
- if ((*subnet_id)->getType() != Element::integer) {
+ for (auto const& subnet_id : subnet_ids) {
+ if (subnet_id->getType() != Element::integer) {
isc_throw(BadValue, "listed subnet identifiers must be numbers");
}
if (v4) {
Lease4Collection leases =
- LeaseMgrFactory::instance().getLeases4((*subnet_id)->intValue());
+ LeaseMgrFactory::instance().getLeases4(subnet_id->intValue());
for (auto const& lease : leases) {
ElementPtr lease_json = lease->toElement();
leases_json->add(lease_json);
}
} else {
Lease6Collection leases =
- LeaseMgrFactory::instance().getLeases6((*subnet_id)->intValue());
+ LeaseMgrFactory::instance().getLeases6(subnet_id->intValue());
for (auto const& lease : leases) {
ElementPtr lease_json = lease->toElement();
leases_json->add(lease_json);
// we're interested in.
if (l->getType() == isc::data::Element::list) {
std::vector<isc::data::ElementPtr> e = l->listValue();
- for (auto it = e.begin(); it != e.end(); ++it) {
- isc::data::ConstElementPtr ip_address = (*it)->get("ip-address");
+ for (auto const& it : e) {
+ isc::data::ConstElementPtr ip_address = it->get("ip-address");
if (ip_address && ip_address->stringValue() == ip) {
- l = (*it);
+ l = it;
break;
}
}
// we're interested in.
if (l->getType() == isc::data::Element::list) {
std::vector<isc::data::ElementPtr> e = l->listValue();
- for (auto it = e.begin(); it != e.end(); ++it) {
- isc::data::ConstElementPtr ip_address = (*it)->get("ip-address");
+ for (auto const& it : e) {
+ isc::data::ConstElementPtr ip_address = it->get("ip-address");
if (ip_address && ip_address->stringValue() == ip) {
- l = (*it);
+ l = it;
break;
}
}
/// @param cms a vector of string with command names
void testCommands(const std::vector<std::string> cmds) {
// The commands should not be registered yet.
- for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
- checkCommandRegistered(*cmd, false);
+ for (auto const& cmd : cmds) {
+ checkCommandRegistered(cmd, false);
}
loadLib();
// The commands should be available after library was loaded.
- for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
- checkCommandRegistered(*cmd, true);
+ for (auto const& cmd : cmds) {
+ checkCommandRegistered(cmd, true);
}
unloadLibs();
// and the commands should be gone now.
- for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
- checkCommandRegistered(*cmd, false);
+ for (auto const& cmd : cmds) {
+ checkCommandRegistered(cmd, false);
}
-
}
// Check that the library can be loaded and unloaded multiple times.
// Create JSON list of required classes.
ElementPtr required_classes_element = Element::createList();
auto const& required_classes = subnet->getRequiredClasses();
- for (auto required_class = required_classes.cbegin();
- required_class != required_classes.cend();
- ++required_class) {
- required_classes_element->add(Element::create(*required_class));
+ for (auto const& required_class : required_classes) {
+ required_classes_element->add(Element::create(required_class));
}
// Create binding for DDNS replace client name mode.
auto option_spaces = subnet->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = subnet->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption4(server_selector, subnet->getID(), desc_copy,
true);
auto option_spaces = pool->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = pool->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption4(server_selector, pool_id, desc_copy, true);
}
auto option_spaces = shared_network->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = shared_network->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption4(server_selector, shared_network->getName(),
desc_copy, true);
auto option_spaces = option_defs.getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionDefContainerPtr defs = option_defs.getItems(option_space);
- for (auto def = defs->begin(); def != defs->end(); ++def) {
- createUpdateOptionDef4(server_selector, *def, client_class->getName());
+ for (auto const& def : *defs) {
+ createUpdateOptionDef4(server_selector, def, client_class->getName());
}
}
}
auto option_spaces = client_class->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = client_class->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption4(server_selector, client_class, desc_copy);
}
// Create JSON list of required classes.
ElementPtr required_classes_element = Element::createList();
auto const& required_classes = subnet->getRequiredClasses();
- for (auto required_class = required_classes.cbegin();
- required_class != required_classes.cend();
- ++required_class) {
- required_classes_element->add(Element::create(*required_class));
+ for (auto const& required_class : required_classes) {
+ required_classes_element->add(Element::create(required_class));
}
// Create binding for DDNS replace client name mode.
auto option_spaces = subnet->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = subnet->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, subnet->getID(), desc_copy,
true);
auto option_spaces = pool->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = pool->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, Lease::TYPE_NA,
pool_id, desc_copy, true);
auto option_spaces = pd_pool->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = pd_pool->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, Lease::TYPE_PD,
pd_pool_id, desc_copy, true);
auto option_spaces = shared_network->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = shared_network->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, shared_network->getName(),
desc_copy, true);
auto option_spaces = option_defs.getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionDefContainerPtr defs = option_defs.getItems(option_space);
- for (auto def = defs->begin(); def != defs->end(); ++def) {
- createUpdateOptionDef6(server_selector, *def, client_class->getName());
+ for (auto const& def : *defs) {
+ createUpdateOptionDef6(server_selector, def, client_class->getName());
}
}
}
auto option_spaces = client_class->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = client_class->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, client_class, desc_copy);
}
// Create JSON list of required classes.
data::ElementPtr required_classes_element = data::Element::createList();
auto const& required_classes = object->getRequiredClasses();
- for (auto required_class = required_classes.cbegin();
- required_class != required_classes.cend();
- ++required_class) {
- required_classes_element->add(data::Element::create(*required_class));
+ for (auto const& required_class : required_classes) {
+ required_classes_element->add(data::Element::create(required_class));
}
return (required_classes_element ?
auto option_spaces = subnet->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = subnet->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption4(server_selector, subnet->getID(), desc_copy,
true);
auto option_spaces = pool->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = pool->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption4(server_selector, pool_id, desc_copy, true);
}
auto option_spaces = shared_network->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = shared_network->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption4(server_selector, shared_network->getName(),
desc_copy, true);
auto option_spaces = option_defs.getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionDefContainerPtr defs = option_defs.getItems(option_space);
- for (auto def = defs->begin(); def != defs->end(); ++def) {
- createUpdateOptionDef4(server_selector, *def, client_class->getName());
+ for (auto const& def : *defs) {
+ createUpdateOptionDef4(server_selector, def, client_class->getName());
}
}
}
auto option_spaces = client_class->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = client_class->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption4(server_selector, client_class, desc_copy);
}
auto option_spaces = subnet->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = subnet->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, subnet->getID(), desc_copy,
true);
auto option_spaces = pool->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = pool->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, Lease::TYPE_NA,
pool_id, desc_copy, true);
auto option_spaces = pd_pool->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = pd_pool->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, Lease::TYPE_PD,
pd_pool_id, desc_copy, true);
auto option_spaces = shared_network->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = shared_network->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, shared_network->getName(),
desc_copy, true);
auto option_spaces = option_defs.getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionDefContainerPtr defs = option_defs.getItems(option_space);
- for (auto def = defs->begin(); def != defs->end(); ++def) {
- createUpdateOptionDef6(server_selector, *def, client_class->getName());
+ for (auto const& def : *defs) {
+ createUpdateOptionDef6(server_selector, def, client_class->getName());
}
}
}
auto option_spaces = client_class->getCfgOption()->getOptionSpaceNames();
for (auto const& option_space : option_spaces) {
OptionContainerPtr options = client_class->getCfgOption()->getAll(option_space);
- for (auto desc = options->begin(); desc != options->end(); ++desc) {
- OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+ for (auto const& desc : *options) {
+ OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
desc_copy->space_name_ = option_space;
createUpdateOption6(server_selector, client_class, desc_copy);
}
// Create JSON list of required classes.
data::ElementPtr required_classes_element = data::Element::createList();
auto const& required_classes = object->getRequiredClasses();
- for (auto required_class = required_classes.cbegin();
- required_class != required_classes.cend();
- ++required_class) {
- required_classes_element->add(data::Element::create(*required_class));
+ for (auto const& required_class : required_classes) {
+ required_classes_element->add(data::Element::create(required_class));
}
bindings.add(required_classes_element);
// Create the list of column names and add it to the result set.
ElementPtr columns = Element::createList();
- for (auto label = column_labels.begin(); label != column_labels.end(); ++label) {
- columns->add(Element::create(*label));
+ for (auto const& label : column_labels) {
+ columns->add(Element::create(label));
}
result_set->set("columns", columns);
void testCommands(const std::vector<string> cmds) {
// The commands should not be registered yet.
- for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
- checkCommandRegistered(*cmd, false);
+ for (auto const& cmd : cmds) {
+ checkCommandRegistered(cmd, false);
}
loadLib();
// The commands should be available after library was loaded.
- for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
- checkCommandRegistered(*cmd, true);
+ for (auto const& cmd : cmds) {
+ checkCommandRegistered(cmd, true);
}
unloadLibs();
// and the commands should be gone now.
- for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
- checkCommandRegistered(*cmd, false);
+ for (auto const& cmd : cmds) {
+ checkCommandRegistered(cmd, false);
}
}
std::string description_;
std::string command_txt_;
std::string exp_response_;
- std::string exp_result_json;
+ std::string exp_result_json_;
};
// Verifies detection of invalid v4 input parameters.
}
};
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- testCommand((*test).command_txt_, CONTROL_RESULT_ERROR,(*test).exp_response_);
- }
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ testCommand(test.command_txt_, CONTROL_RESULT_ERROR, test.exp_response_);
}
}
}
};
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS,
- (*test).exp_response_, (*test).exp_result_json);
- }
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ testCommand(test.command_txt_, CONTROL_RESULT_SUCCESS,
+ test.exp_response_, test.exp_result_json_);
}
-
}
// Verifies result content for valid v4 statistic commands that
}
};
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- testCommand((*test).command_txt_, CONTROL_RESULT_EMPTY,
- (*test).exp_response_, (*test).exp_result_json);
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ testCommand(test.command_txt_, CONTROL_RESULT_EMPTY,
+ test.exp_response_, test.exp_result_json_);
}
- }
-
}
// Verifies detection of invalid v6 input parameters.
}
};
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- testCommand((*test).command_txt_, CONTROL_RESULT_ERROR,(*test).exp_response_);
- }
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ testCommand(test.command_txt_, CONTROL_RESULT_ERROR, test.exp_response_);
}
}
}
};
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS,
- (*test).exp_response_, (*test).exp_result_json);
- }
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ testCommand(test.command_txt_, CONTROL_RESULT_SUCCESS,
+ test.exp_response_, test.exp_result_json_);
}
}
}
};
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- testCommand((*test).command_txt_, CONTROL_RESULT_EMPTY,
- (*test).exp_response_, (*test).exp_result_json);
- }
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ testCommand(test.command_txt_, CONTROL_RESULT_EMPTY,
+ test.exp_response_, test.exp_result_json_);
}
}
}
};
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS,
- (*test).exp_response_, (*test).exp_result_json);
- }
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ testCommand(test.command_txt_, CONTROL_RESULT_SUCCESS,
+ test.exp_response_, test.exp_result_json_);
}
}
}
};
- for (auto test = tests.begin(); test != tests.end(); ++test) {
- {
- SCOPED_TRACE((*test).description_);
- testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS,
- (*test).exp_response_, (*test).exp_result_json);
- }
+ for (auto const& test : tests) {
+ SCOPED_TRACE(test.description_);
+ testCommand(test.command_txt_, CONTROL_RESULT_SUCCESS,
+ test.exp_response_, test.exp_result_json_);
}
}
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_char && delim) {
tmp << delim_char;
}
tmp << std::setw(2) << std::setfill('0')
- << static_cast<unsigned int>(*it);
+ << static_cast<unsigned int>(it);
delim = true;
}
#include <user.h>
#include <user_file.h>
-#include <boost/foreach.hpp>
#include <errno.h>
#include <iostream>
// respective locals. Anything else is assumed to be an option so
// add it to the local property map.
std::pair<std::string, isc::data::ConstElementPtr> element_pair;
- BOOST_FOREACH (element_pair, elements->mapValue()) {
+ for (auto const& element_pair : elements->mapValue()) {
// Get the element's label.
std::string label = element_pair.first;
TEST(IOAddressHashTest, hashIPv4) {
IOAddress::Hash hash;
std::unordered_set<size_t> results;
- for (uint32_t i = 0; i < 10; i++) {
+ for (uint32_t i = 0; i < 10; ++i) {
IOAddress address(i);
auto result = hash(address);
results.insert(result);
TEST(IOAddressHashTest, hashIPv6) {
IOAddress::Hash hash;
std::unordered_set<size_t> results;
- for (auto i = 0; i < 10; i++) {
+ for (auto i = 0; i < 10; ++i) {
std::ostringstream s;
s << "2001:db8:" << i << "::ffff";
IOAddress address(s.str());
/// @brief Stops all connections.
void stopAll() {
- for (auto conn = connections_.begin(); conn != connections_.end();
- ++conn) {
- (*conn)->stop();
+ for (auto const& conn : connections_) {
+ conn->stop();
}
connections_.clear();
}
// Storing command names in a set guarantees that the non-unique
// command names are aggregated.
std::set<std::string> combined_set;
- for (auto v = vec1.cbegin(); v != vec1.cend(); ++v) {
- combined_set.insert((*v)->stringValue());
+ for (auto const& v : vec1) {
+ combined_set.insert(v->stringValue());
}
- for (auto v = vec2.cbegin(); v != vec2.cend(); ++v) {
- combined_set.insert((*v)->stringValue());
+ for (auto const& v : vec2) {
+ combined_set.insert(v->stringValue());
}
// Create a combined list of commands.
ElementPtr combined_list = Element::createList();
- for (auto s = combined_set.cbegin(); s != combined_set.cend(); ++s) {
- combined_list->add(Element::create(*s));
+ for (auto const& s : combined_set) {
+ combined_list->add(Element::create(s));
}
return (createAnswer(CONTROL_RESULT_SUCCESS, combined_list));
}
ss << "[ ";
const std::vector<ElementPtr>& v = listValue();
- for (auto it = v.begin(); it != v.end(); ++it) {
- if (it != v.begin()) {
+ bool first = true;
+ for (auto const& it : v) {
+ if (!first) {
ss << ", ";
+ } else {
+ first = false;
}
- (*it)->toJSON(ss);
+ it->toJSON(ss);
}
ss << " ]";
}
MapElement::toJSON(std::ostream& ss) const {
ss << "{ ";
- for (auto it = m.begin(); it != m.end(); ++it) {
- if (it != m.begin()) {
+ bool first = true;
+ for (auto const& it : m) {
+ if (!first) {
ss << ", ";
+ } else {
+ first = false;
}
- ss << "\"" << (*it).first << "\": ";
- if ((*it).second) {
- (*it).second->toJSON(ss);
+ ss << "\"" << it.first << "\": ";
+ if (it.second) {
+ it.second->toJSON(ss);
} else {
ss << "None";
}
// Store new elements in a separate container so we don't overwrite
// options as we add them (if there are duplicates).
ElementPtr new_elements = Element::createList();
- for (auto& right : other->listValue()) {
+ for (auto const& right : other->listValue()) {
// Check if we have any description of the key in the configuration
// hierarchy.
auto f = hierarchy[idx].find(key);
if (f != hierarchy[idx].end()) {
bool found = false;
ElementPtr mutable_right = boost::const_pointer_cast<Element>(right);
- for (auto& left : element->listValue()) {
+ for (auto const& left : element->listValue()) {
ElementPtr mutable_left = boost::const_pointer_cast<Element>(left);
// Check if the elements refer to the same configuration
// entity.
}
}
// Finally add the new elements.
- for (auto& right : new_elements->listValue()) {
+ for (auto const& right : new_elements->listValue()) {
element->add(right);
}
return;
}
if (element->getType() == Element::list) {
- for (auto& right : other->listValue()) {
+ for (auto const& right : other->listValue()) {
// Check if we have any description of the key in the configuration
// hierarchy.
auto f = hierarchy[idx].find(key);
if (f != hierarchy[idx].end()) {
ElementPtr mutable_right = boost::const_pointer_cast<Element>(right);
- for (auto& left : element->listValue()) {
+ for (auto const& left : element->listValue()) {
ElementPtr mutable_left = boost::const_pointer_cast<Element>(left);
if (container == key) {
alter = true;
// iterate on items
auto const& l = element->listValue();
- for (auto it = l.begin(); it != l.end(); ++it) {
+ bool first = true;
+ for (auto const& it : l) {
// add the separator if not the first item
- if (it != l.begin()) {
+ if (!first) {
out << separator;
+ } else {
+ first = false;
}
// add indentation
if (complex) {
out << std::string(indent + step, ' ');
}
// recursive call
- prettyPrint(*it, out, indent + step, step);
+ prettyPrint(it, out, indent + step, step);
}
// close the list
// iterate on keyword: value
auto const& m = element->mapValue();
bool first = true;
- for (auto it = m.begin(); it != m.end(); ++it) {
+ for (auto const& it : m) {
// add the separator if not the first item
if (first) {
first = false;
// add indentation
out << std::string(indent + step, ' ');
// add keyword:
- out << "\"" << it->first << "\": ";
+ out << "\"" << it.first << "\": ";
// recursive call
- prettyPrint(it->second, out, indent + step, step);
+ prettyPrint(it.second, out, indent + step, step);
}
// close the map
#include <cc/simple_parser.h>
#include <asiolink/io_address.h>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <cc/data.h>
#include <string>
const Element::Position pos("<default-value>", 0, 0);
// Let's go over all parameters we have defaults for.
- BOOST_FOREACH(SimpleDefault def_value, default_values) {
+ for (auto const& def_value : default_values) {
// Try if such a parameter is there. If it is, let's
// skip it, because user knows best *cough*.
SimpleParser::setListDefaults(ConstElementPtr list,
const SimpleDefaults& default_values) {
size_t cnt = 0;
- BOOST_FOREACH(ElementPtr entry, list->listValue()) {
+ for (auto const& entry : list->listValue()) {
cnt += setDefaults(entry, default_values);
}
return (cnt);
}
size_t cnt = 0;
- BOOST_FOREACH(string param, params) {
+ for (auto const& param : params) {
ConstElementPtr x = parent->get(param);
if (!x) {
// Parent doesn't define this parameter, so there's
const isc::data::ConstElementPtr& ) {
using namespace isc::data;
ElementPtr commands = Element::createList();
- for (HandlerContainer::const_iterator it = handlers_.begin();
- it != handlers_.end(); ++it) {
- commands->add(Element::create(it->first));
+ for (auto const& it : handlers_) {
+ commands->add(Element::create(it.first));
}
return (createAnswer(CONTROL_RESULT_SUCCESS, commands));
}
/// @brief Stops all connections which are allowed to stop.
void stopAll() {
- for (auto conn = connections_.begin(); conn != connections_.end();
- ++conn) {
- (*conn)->stop();
+ for (auto const& conn : connections_) {
+ conn->stop();
}
connections_.clear();
}
// Only update the response if there are any hooks present.
if (!hooks.empty()) {
ElementPtr hooks_commands = Element::createList();
- for (auto h = hooks.cbegin(); h != hooks.end(); ++h) {
+ for (auto const& h : hooks) {
// Try to convert hook name to command name. If non-empty
// string is returned it means that the hook point may have
// command handlers associated with it. Otherwise, it means that
// existing hook points are not for command handlers but for
// regular callouts.
- std::string command_name = ServerHooks::hookToCommandName(*h);
+ std::string command_name = ServerHooks::hookToCommandName(h);
if (!command_name.empty()) {
// Final check: are command handlers registered for this
// hook point? If there are no command handlers associated,
// Iterate over existing hook points and for each of them remove
// callouts registered.
std::vector<std::string> hooks = ServerHooks::getServerHooksPtr()->getHookNames();
- for (auto h = hooks.cbegin(); h != hooks.cend(); ++h) {
- HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(*h);
+ for (auto const& h : hooks) {
+ HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(h);
}
}
const std::vector<ElementPtr>& commands_list = answer_arg->listValue();
ASSERT_EQ(3, commands_list.size());
std::vector<std::string> command_names_list;
- for (auto cmd = commands_list.cbegin(); cmd != commands_list.cend();
- ++cmd) {
- command_names_list.push_back((*cmd)->stringValue());
+ for (auto const& cmd : commands_list) {
+ command_names_list.push_back(cmd->stringValue());
}
std::sort(command_names_list.begin(), command_names_list.end());
EXPECT_EQ("list-commands", command_names_list[0]);
#include <cc/command_interpreter.h>
#include <config/base_command_mgr.h>
#include <util/encode/hex.h>
-
-#include <boost/foreach.hpp>
+#include <boost/range/adaptor/reversed.hpp>
using namespace isc::asiolink;
using namespace isc::config;
d2->set("reverse-ddns", reverse_ddns);
// Set tsig-keys
ElementPtr tsig_keys = Element::createList();
- for (TSIGKeyInfoMap::const_iterator key = keys_->begin();
- key != keys_->end(); ++key) {
- tsig_keys->add(key->second->toElement());
+ for (auto const& key : *keys_) {
+ tsig_keys->add(key.second->toElement());
}
d2->set("tsig-keys", tsig_keys);
// Set control-socket (skip if null as empty is not legal)
// Walk backwards through vector outputting each octet and a dot.
std::ostringstream stream;
- // We have to set the following variable to get
- // const_reverse_iterator type of rend(), otherwise Solaris GCC
- // complains on operator!= by trying to use the non-const variant.
- const ByteAddress::const_reverse_iterator end = bytes.rend();
-
- for (ByteAddress::const_reverse_iterator rit = bytes.rbegin();
- rit != end;
- ++rit)
- {
- stream << static_cast<unsigned int>(*rit) << ".";
+ for (auto const& rit : boost::adaptors::reverse(bytes)) {
+ stream << static_cast<unsigned int>(rit) << ".";
}
// Tack on the suffix and we're done.
// Walk backwards through string outputting each digits and a dot.
std::ostringstream stream;
- // We have to set the following variable to get
- // const_reverse_iterator type of rend(), otherwise Solaris GCC
- // complains on operator!= by trying to use the non-const variant.
- const std::string::const_reverse_iterator end = digits.rend();
-
- for (std::string::const_reverse_iterator rit = digits.rbegin();
- rit != end;
- ++rit)
- {
- stream << static_cast<char>(*rit) << ".";
+ for (auto const& rit : boost::adaptors::reverse(digits)) {
+ stream << static_cast<char>(rit) << ".";
}
// Tack on the suffix and we're done.
#include <exceptions/exceptions.h>
#include <asiolink/io_error.h>
-#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/algorithm/string/predicate.hpp>
result->set("name", Element::create(name_));
// Set servers
ElementPtr servers = Element::createList();
- for (DnsServerInfoStorage::const_iterator server = servers_->begin();
- server != servers_->end(); ++server) {
- ElementPtr dns_server = (*server)->toElement();
+ for (auto const& server : *servers_) {
+ ElementPtr dns_server = server->toElement();
servers->add(dns_server);
}
// the dns server list may not be empty
size_t req_len = fqdn.size();
size_t match_len = 0;
- DdnsDomainMapPair map_pair;
DdnsDomainPtr best_match;
- BOOST_FOREACH (map_pair, *domains_) {
+ for (auto const& map_pair : *domains_) {
std::string domain_name = map_pair.first;
size_t dom_len = domain_name.size();
DdnsDomainListMgr::toElement() const {
ElementPtr result = Element::createList();
// Iterate on ddns domains
- for (DdnsDomainMap::const_iterator domain = domains_->begin();
- domain != domains_->end(); ++domain) {
- ElementPtr ddns_domain = domain->second->toElement();
+ for (auto const& domain : *domains_) {
+ ElementPtr ddns_domain = domain.second->toElement();
result->add(ddns_domain);
}
TSIGKeyInfoMapPtr
TSIGKeyInfoListParser::parse(ConstElementPtr key_list) {
TSIGKeyInfoMapPtr keys(new TSIGKeyInfoMap());
- ConstElementPtr key_config;
TSIGKeyInfoParser key_parser;
- BOOST_FOREACH(key_config, key_list->listValue()) {
+ for (auto const& key_config : key_list->listValue()) {
TSIGKeyInfoPtr key = key_parser.parse(key_config);
// Duplicates are not allowed and should be flagged as an error.
ConstElementPtr domain_config,
const TSIGKeyInfoMapPtr keys) {
DnsServerInfoStoragePtr servers(new DnsServerInfoStorage());
- ConstElementPtr server_config;
DnsServerInfoParser parser;
- BOOST_FOREACH(server_config, server_list->listValue()) {
+ for (auto const& server_config : server_list->listValue()) {
DnsServerInfoPtr server =
parser.parse(server_config, domain_config, keys);
servers->push_back(server);
const TSIGKeyInfoMapPtr keys) {
DdnsDomainMapPtr domains(new DdnsDomainMap());
DdnsDomainParser parser;
- ConstElementPtr domain_config;
- BOOST_FOREACH(domain_config, domain_list->listValue()) {
+ for (auto const& domain_config : domain_list->listValue()) {
DdnsDomainPtr domain = parser.parse(domain_config, keys);
// Duplicates are not allowed
#include <exceptions/exceptions.h>
#include <process/d_cfg_mgr.h>
-#include <boost/foreach.hpp>
-
#include <stdint.h>
#include <string>
#include <cc/data.h>
#include <hooks/hooks_manager.h>
#include <hooks/hooks_parser.h>
-#include <boost/foreach.hpp>
using namespace isc::data;
using namespace isc::d2;
// manager is disabled.
if (mgr->find("ddns-domains")) {
ConstElementPtr domains = mgr->get("ddns-domains");
- BOOST_FOREACH(ElementPtr domain, domains->listValue()) {
+ for (auto const& domain : domains->listValue()) {
// Set the domain's defaults. We can't use setListDefaults()
// as this does not handle sub-lists or maps, like server list.
cnt += setDdnsDomainDefaults(domain, DDNS_DOMAIN_DEFAULTS);
#include <util/strutil.h>
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <vector>
using namespace isc::asiolink;
// /usr/include/c++/4.4/bits/stl_algo.h:2178 "array subscript is above
// array bounds"
boost::split(tokens, dba, boost::is_any_of(string("\t ")));
- BOOST_FOREACH(std::string token, tokens) {
+ for (auto const& token : tokens) {
size_t pos = token.find("=");
if (pos != string::npos) {
string name = token.substr(0, pos);
// Reconstruct the access string: start of with an empty string, then
// work through all the parameters in the original string and add them.
std::string access;
- for (DatabaseConnection::ParameterMap::const_iterator i = parameters.begin();
- i != parameters.end(); ++i) {
+ for (auto const& i : parameters) {
// Separate second and subsequent tokens are preceded by a space.
if (!access.empty()) {
}
// Append name of parameter...
- access += i->first;
+ access += i.first;
access += "=";
// ... and the value, except in the case of the password, where a
// redacted value is appended.
- if (i->first == std::string("password")) {
+ if (i.first == std::string("password")) {
access += "*****";
} else {
- access += i->second;
+ access += i.second;
}
}
// Check that the keywords and keyword values are the same: loop
// through the keywords in the database access string.
- for (DatabaseConnection::ParameterMap::const_iterator actual = parameters.begin();
- actual != parameters.end(); ++actual) {
+ for (auto const& actual : parameters) {
// Does the keyword exist in the set of expected keywords?
std::map<string, string>::iterator corresponding =
- expected.find(actual->first);
+ expected.find(actual.first);
ASSERT_TRUE(corresponding != expected.end());
// Keyword exists, is the value the same?
- EXPECT_EQ(corresponding->second, actual->second);
+ EXPECT_EQ(corresponding->second, actual.second);
}
}
std::string
ClientClasses::toText(const std::string& separator) const {
std::stringstream s;
- for (const_iterator class_it = cbegin(); class_it != cend(); ++class_it) {
- if (class_it != cbegin()) {
+ bool first = true;
+ for (auto const& class_it : *this) {
+ if (!first) {
s << separator;
+ } else {
+ first = false;
}
- s << *class_it;
+ s << class_it;
}
return (s.str());
}
ElementPtr
ClientClasses::toElement() const {
ElementPtr result(Element::createList());
- for (const ClientClass& c : container_) {
+ for (auto const& c : container_) {
result->add(Element::create(c));
}
return (result);
std::stringstream tmp;
tmp << std::hex;
bool delim = false;
- for (auto const data : data_) {
+ for (auto const& data : data_) {
if (delim) {
tmp << ":";
}
DUIDFactory::createLinkLayerId(std::vector<uint8_t>& identifier,
uint16_t& htype) const {
// Let's find suitable interface.
- for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
+ for (auto const& iface : IfaceMgr::instance().getIfaces()) {
// All the following checks could be merged into one multi-condition
// statement, but let's keep them separated as perhaps one day
// we will grow knobs to selectively turn them on or off. Also,
}
tmp << std::hex;
bool delim = false;
- for (std::vector<uint8_t>::const_iterator it = hwaddr_.begin();
- it != hwaddr_.end(); ++it) {
+ for (auto const& it : hwaddr_) {
if (delim) {
tmp << ":";
}
- tmp << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(*it);
+ tmp << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(it);
delim = true;
}
return (tmp.str());
freeifaddrs(iflist);
// Interfaces registering
- for (IfaceLst::const_iterator iface_iter = ifaces.begin();
- iface_iter != ifaces.end(); ++iface_iter) {
+ for (auto const& iface_iter : ifaces) {
IfacePtr iface;
if (update_only) {
- iface = getIface(iface_iter->first);
+ iface = getIface(iface_iter.first);
}
if (!iface) {
- addInterface(iface_iter->second);
+ addInterface(iface_iter.second);
}
}
}
uint8_t addr[V6ADDRESS_LEN];
RTattribPtrs rta_tb;
- for (NetlinkMessages::const_iterator msg = addr_info.begin();
- msg != addr_info.end(); ++msg) {
- ifaddrmsg* ifa = static_cast<ifaddrmsg*>(NLMSG_DATA(*msg));
+ for (auto const& msg : addr_info) {
+ ifaddrmsg* ifa = static_cast<ifaddrmsg*>(NLMSG_DATA(msg));
// These are not the addresses you are looking for
if (ifa->ifa_index != iface.getIndex()) {
if ((ifa->ifa_family == AF_INET6) || (ifa->ifa_family == AF_INET)) {
std::fill(rta_tb.begin(), rta_tb.end(), static_cast<rtattr*>(NULL));
- parse_rtattr(rta_tb, IFA_RTA(ifa), (*msg)->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa)));
+ parse_rtattr(rta_tb, IFA_RTA(ifa), msg->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa)));
if (!rta_tb[IFA_LOCAL]) {
rta_tb[IFA_LOCAL] = rta_tb[IFA_ADDRESS];
}
/// @param messages Set of messages to be freed.
void Netlink::release_list(NetlinkMessages& messages) {
// let's free local copies of stored messages
- for (NetlinkMessages::iterator msg = messages.begin(); msg != messages.end(); ++msg) {
- delete[] (*msg);
+ for (auto const& msg : messages) {
+ delete[] msg;
}
// and get rid of the message pointers as well
nl.rtnl_process_reply(addr_info);
// Now build list with interface names
- for (Netlink::NetlinkMessages::iterator msg = link_info.begin();
- msg != link_info.end(); ++msg) {
+ for (auto const& msg : link_info) {
// Required to display information about interface
- struct ifinfomsg* interface_info = static_cast<ifinfomsg*>(NLMSG_DATA(*msg));
- int len = (*msg)->nlmsg_len;
+ struct ifinfomsg* interface_info = static_cast<ifinfomsg*>(NLMSG_DATA(msg));
+ int len = msg->nlmsg_len;
len -= NLMSG_LENGTH(sizeof(*interface_info));
nl.parse_rtattr(attribs_table, IFLA_RTA(interface_info), len);
freeifaddrs(iflist);
// Interfaces registering
- for (IfaceLst::const_iterator iface_iter = ifaces.begin();
- iface_iter != ifaces.end(); ++iface_iter) {
+ for (auto const& iface_iter : ifaces) {
IfacePtr iface;
if (update_only) {
- iface = getIface(iface_iter->first);
+ iface = getIface(iface_iter.first);
}
if (!iface) {
- addInterface(iface_iter->second);
+ addInterface(iface_iter.second);
}
}
}
#include <exceptions/isc_assert.h>
#include <util/buffer.h>
+#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/shared_array.hpp>
#include <boost/shared_ptr.hpp>
typedef vector<OpaqueDataTuple> TuplesCollection;
map<uint32_t, TuplesCollection> vendors_tuples;
auto const& range = options.equal_range(DHO_VIVCO_SUBOPTIONS);
- for (auto it = range.first; it != range.second; ++it) {
+ BOOST_FOREACH(auto const& it, range) {
uint32_t offset = 0;
- auto const& data = it->second->getData();
+ auto const& data = it.second->getData();
size_t size;
while ((size = data.size() - offset) != 0) {
if (size < sizeof(uint32_t)) {
extendVivso(OptionCollection& options) {
map<uint32_t, OptionCollection> vendors_data;
auto const& range = options.equal_range(DHO_VIVSO_SUBOPTIONS);
- for (auto it = range.first; it != range.second; ++it) {
+ BOOST_FOREACH(auto const& it, range) {
uint32_t offset = 0;
- auto const& data = it->second->getData();
+ auto const& data = it.second->getData();
size_t size;
while ((size = data.size() - offset) != 0) {
if (size < sizeof(uint32_t)) {
// Do not copy it as a whole. addAddress() does sanity checks.
// i.e. throw if someone tries to set IPv6 address.
addrs_.clear();
- for (AddressContainer::const_iterator addr = addrs.begin();
- addr != addrs.end(); ++addr) {
- addAddress(*addr);
+ for (auto const& addr : addrs) {
+ addAddress(addr);
}
}
std::stringstream output;
output << headerToText(indent) << ":";
- for (AddressContainer::const_iterator addr = addrs_.begin();
- addr != addrs_.end(); ++addr) {
- output << " " << (*addr);
+ for (auto const& addr : addrs_) {
+ output << " " << addr;
}
return (output.str());
// len field contains length without 4-byte option header
buf.writeUint16(len() - getHeaderLen());
- for (AddressContainer::const_iterator addr=addrs_.begin();
- addr!=addrs_.end(); ++addr) {
- if (!addr->isV6()) {
- isc_throw(isc::BadValue, addr->toText()
+ for (auto const& addr : addrs_) {
+ if (!addr.isV6()) {
+ isc_throw(isc::BadValue, addr.toText()
<< " is not an IPv6 address");
}
// If an address is IPv6 address it should have assumed
// length of V6ADDRESS_LEN.
- buf.writeData(&addr->toBytes()[0], V6ADDRESS_LEN);
+ buf.writeData(&addr.toBytes()[0], V6ADDRESS_LEN);
}
}
stringstream output;
output << headerToText(indent) << ":";
- for (AddressContainer::const_iterator addr = addrs_.begin();
- addr != addrs_.end(); ++addr) {
- output << " " << *addr;
+ for (auto const& addr : addrs_) {
+ output << " " << addr;
}
return (output.str());
}
OPTION6_IA_LEN /* option content (12) */;
// length of all suboptions
- for (OptionCollection::const_iterator it = options_.begin();
- it != options_.end();
- ++it) {
- length += (*it).second->len();
+ for (auto const& it : options_) {
+ length += it.second->len();
}
return (length);
}
// length of all suboptions
// TODO implement:
// protected: unsigned short Option::lenHelper(int header_size);
- for (OptionCollection::const_iterator it = options_.begin();
- it != options_.end();
- ++it) {
- length += (*it).second->len();
+ for (auto const& it : options_) {
+ length += it.second->len();
}
return (length);
}
uint16_t length = OPTION6_HDR_LEN + OPTION6_IAPREFIX_LEN;
// length of all suboptions
- for (OptionCollection::const_iterator it = options_.begin();
- it != options_.end(); ++it) {
- length += (*it).second->len();
+ for (auto const& it : options_) {
+ length += it.second->len();
}
return (length);
}
OptionClasslessStaticRoute::pack(isc::util::OutputBuffer& buf, bool check) const {
// Header = option code and length.
packHeader(buf, check);
- for (const auto& route : static_routes_) {
+ for (auto const& route : static_routes_) {
// 1-5 octets of destination descriptor
auto dest = encodeDestinationDescriptor(route);
buf.writeData(&dest[0], dest.size());
stream << in << "type=" << type_ << "(CLASSLESS_STATIC_ROUTE), "
<< "len=" << (len() - getHeaderLen());
int i = 0;
- for (const auto& route : static_routes_) {
+ for (auto const& route : static_routes_) {
stream << ", Route " << ++i << " (subnet " << std::get<0>(route).toText() << "/"
<< static_cast<int>(std::get<1>(route)) << ", router IP "
<< std::get<2>(route).toText() << ")";
void
OptionClasslessStaticRoute::calcDataLen() {
uint16_t len = 0;
- for (const auto& route : static_routes_) {
+ for (auto const& route : static_routes_) {
// 1-5 octets of destination descriptor
len += calcSignificantOctets(std::get<1>(route)) + 1;
// IP address of the router
OptionClasslessStaticRoute::parseConfigData(const std::string& config_txt) {
// this option allows more than one static route, so let's separate them using comma
std::vector<std::string> tokens = str::tokens(config_txt, std::string(","));
- for (const auto& route_str : tokens) {
+ for (auto const& route_str : tokens) {
std::vector<std::string> parts = str::tokens(str::trim(route_str), std::string("-"));
if (parts.size() != 2) {
isc_throw(BadValue, "DHCPv4 OptionClasslessStaticRoute "
const OptionDefinition::RecordFieldsCollection fields =
definition_.getRecordFields();
- for (OptionDefinition::RecordFieldsConstIter field = fields.begin();
- field != fields.end(); ++field) {
+ for (auto const& field : fields) {
OptionBuffer buf;
- createBuffer(buf, *field);
+ createBuffer(buf, field);
// We have the buffer with default value prepared so we
// add it to the set of buffers.
buffers.push_back(buf);
definition_.getRecordFields();
// Go over all data fields within a record.
- for (OptionDefinition::RecordFieldsConstIter field = fields.begin();
- field != fields.end(); ++field) {
- size_t data_size = bufferLength(*field, false,
+ for (auto const& field : fields) {
+ size_t data_size = bufferLength(field, false,
data, data_buf.end());
// Our data field requires that there is a certain chunk of
packHeader(buf, check);
// Write data from buffers.
- for (std::vector<OptionBuffer>::const_iterator it = buffers_.begin();
- it != buffers_.end(); ++it) {
+ for (auto const& it : buffers_) {
// In theory the createBuffers function should have taken
// care that there are no empty buffers added to the
// collection but it is almost always good to make sure.
- if (!it->empty()) {
- buf.writeData(&(*it)[0], it->size());
+ if (!it.empty()) {
+ buf.writeData(&it[0], it.size());
}
}
size_t length = getHeaderLen();
// ... lengths of all buffers that hold option data ...
- for (std::vector<OptionBuffer>::const_iterator buf = buffers_.begin();
- buf != buffers_.end(); ++buf) {
- length += buf->size();
+ for (auto const& buf : buffers_) {
+ length += buf.size();
}
// ... and lengths of all suboptions
- for (OptionCollection::const_iterator it = options_.begin();
- it != options_.end();
- ++it) {
- length += (*it).second->len();
+ for (auto const& it : options_) {
+ length += it.second->len();
}
return (static_cast<uint16_t>(length));
// For record types we iterate over fields defined in
// option definition and match the appropriate buffer
// with them.
- for (OptionDefinition::RecordFieldsConstIter field = fields.begin();
- field != fields.end(); ++field) {
- output << " " << dataFieldToText(*field, std::distance(fields.begin(),
- field));
+ size_t j = 0;
+ for (auto const& field : fields) {
+ output << " " << dataFieldToText(field, j);
+ j++;
}
// If the last record field is an array iterate on extra buffers
// The data length is equal to size of T.
length += sizeof(T);;
// length of all suboptions
- for (OptionCollection::const_iterator it = options_.begin();
- it != options_.end();
- ++it) {
- length += (*it).second->len();
+ for (auto const& it : options_) {
+ length += it.second->len();
}
return (length);
}
uint16_t length = (getUniverse() == Option::V4) ? OPTION4_HDR_LEN : OPTION6_HDR_LEN;
length += values_.size() * sizeof(T);
// length of all suboptions
- for (OptionCollection::const_iterator it = options_.begin();
- it != options_.end();
- ++it) {
- length += (*it).second->len();
+ for (auto const& it : options_) {
+ length += it.second->len();
}
return (length);
}
output << headerToText(indent) << ":";
std::string data_type = OptionDataTypeUtil::getDataTypeName(OptionDataTypeTraits<T>::type);
- for (typename std::vector<T>::const_iterator value = values_.begin();
- value != values_.end(); ++value) {
+ for (auto const& value : values_) {
output << " ";
// For 1 byte long data types we need to cast to the integer
// because they are usually implemented as "char" types, in
// which case the character rather than number would be printed.
if (OptionDataTypeTraits<T>::len == 1) {
- output << static_cast<int>(*value);
+ output << static_cast<int>(value);
} else {
- output << *value;
+ output << value;
}
// Append data type.
OptionOpaqueDataTuples::pack(isc::util::OutputBuffer& buf, bool check) const {
packHeader(buf, check);
- for (TuplesCollection::const_iterator it = tuples_.begin();
- it != tuples_.end(); ++it) {
- it->pack(buf);
+ for (auto const& it : tuples_) {
+ it.pack(buf);
}
// That's it. We don't pack any sub-options here, because this option
// must not contain sub-options.
OptionOpaqueDataTuples::hasTuple(const std::string& tuple_str) const {
// Iterate over existing tuples (there shouldn't be many of them),
// and try to match the searched one.
- for (TuplesCollection::const_iterator it = tuples_.begin();
- it != tuples_.end(); ++it) {
- if (*it == tuple_str) {
+ for (auto const& it : tuples_) {
+ if (it == tuple_str) {
return (true);
}
}
// The option starts with the header.
uint16_t length = getHeaderLen();
// Now iterate over existing tuples and add their size.
- for (TuplesCollection::const_iterator it = tuples_.begin();
- it != tuples_.end(); ++it) {
- length += it->getTotalLength();
+ for (auto const& it : tuples_) {
+ length += it.getTotalLength();
}
return (length);
buf.writeUint32(getVendorId());
- for (TuplesCollection::const_iterator it = tuples_.begin();
- it != tuples_.end(); ++it) {
+ bool first = true;
+ for (auto const& it : tuples_) {
// For DHCPv4 V-I Vendor Class option, there is enterprise id before
// every tuple.
- if ((getUniverse() == V4) && (it != tuples_.begin())) {
+ if ((getUniverse() == V4) && (!first)) {
buf.writeUint32(getVendorId());
}
- it->pack(buf);
+ first = false;
+ it.pack(buf);
}
// That's it. We don't pack any sub-options here, because this option
OptionVendorClass::hasTuple(const std::string& tuple_str) const {
// Iterate over existing tuples (there shouldn't be many of them),
// and try to match the searched one.
- for (TuplesCollection::const_iterator it = tuples_.begin();
- it != tuples_.end(); ++it) {
- if (*it == tuple_str) {
+ for (auto const& it : tuples_) {
+ if (it == tuple_str) {
return (true);
}
}
// The option starts with the header and enterprise id.
uint16_t length = getHeaderLen() + sizeof(uint32_t);
// Now iterate over existing tuples and add their size.
- for (TuplesCollection::const_iterator it = tuples_.begin();
- it != tuples_.end(); ++it) {
+ bool first = true;
+ for (auto const& it : tuples_) {
// For DHCPv4 V-I Vendor Class option, there is enterprise id before
// every tuple.
- if ((getUniverse() == V4) && (it != tuples_.begin())) {
+ if ((getUniverse() == V4) && (!first)) {
length += sizeof(uint32_t);
}
- length += it->getTotalLength();
+ first = false;
+ length += it.getTotalLength();
}
#include <dhcp/pkt.h>
#include <dhcp/iface_mgr.h>
#include <dhcp/hwaddr.h>
+#include <boost/foreach.hpp>
#include <vector>
namespace isc {
// matching options, copy them and replace the original ones with new
// instances.
if (copy_retrieved_options_) {
- for (OptionCollection::iterator opt_it = range.first;
- opt_it != range.second; ++opt_it) {
- OptionPtr option_copy = opt_it->second->clone();
- opt_it->second = option_copy;
+ BOOST_FOREACH(auto& opt_it, range) {
+ OptionPtr option_copy = opt_it.second->clone();
+ opt_it.second = option_copy;
}
}
// Finally, return updated options. This can also be empty in some cases.
#include <exceptions/exceptions.h>
#include <dhcp/duid.h>
#include <dhcp/iface_mgr.h>
-
+#include <boost/foreach.hpp>
#include <iterator>
#include <iostream>
#include <sstream>
// matching options, copy them and replace the original ones with new
// instances.
if (copy_retrieved_options_) {
- for (OptionCollection::iterator opt_it = range.first;
- opt_it != range.second; ++opt_it) {
- OptionPtr option_copy = opt_it->second->clone();
- opt_it->second = option_copy;
+ BOOST_FOREACH(auto& opt_it, range) {
+ OptionPtr option_copy = opt_it.second->clone();
+ opt_it.second = option_copy;
}
}
opts.insert(range.first, range.second);
// matching options, copy them and replace the original ones with new
// instances.
if (copy_retrieved_options_) {
- for (OptionCollection::iterator opt_it = range.first;
- opt_it != range.second; ++opt_it) {
- OptionPtr option_copy = opt_it->second->clone();
- opt_it->second = option_copy;
+ BOOST_FOREACH(auto& opt_it, range) {
+ OptionPtr option_copy = opt_it.second->clone();
+ opt_it.second = option_copy;
}
}
// Finally, return updated options. This can also be empty in some cases.
calculateRelaySizes();
// Now for each relay, we need to...
- for (vector<RelayInfo>::iterator relay = relay_info_.begin();
- relay != relay_info_.end(); ++relay) {
+ for (auto const& relay : relay_info_) {
// build relay-forw/relay-repl header (see RFC 8415, section 9)
- buffer_out_.writeUint8(relay->msg_type_);
- buffer_out_.writeUint8(relay->hop_count_);
- buffer_out_.writeData(&(relay->linkaddr_.toBytes()[0]),
+ buffer_out_.writeUint8(relay.msg_type_);
+ buffer_out_.writeUint8(relay.hop_count_);
+ buffer_out_.writeData(&(relay.linkaddr_.toBytes()[0]),
isc::asiolink::V6ADDRESS_LEN);
- buffer_out_.writeData(&relay->peeraddr_.toBytes()[0],
+ buffer_out_.writeData(&relay.peeraddr_.toBytes()[0],
isc::asiolink::V6ADDRESS_LEN);
// store every option in this relay scope. Usually that will be
// present here as well (vendor-opts for Cable modems,
// subscriber-id, remote-id, options echoed back from Echo
// Request Option, etc.)
- for (auto const& opt : relay->options_) {
+ for (auto const& opt : relay.options_) {
(opt.second)->pack(buffer_out_);
}
// or outside the loop (if there are no more relays and the
// payload is a direct message)
buffer_out_.writeUint16(D6O_RELAY_MSG);
- buffer_out_.writeUint16(relay->relay_msg_len_);
+ buffer_out_.writeUint16(relay.relay_msg_len_);
}
}
bool seenbeta = false;
bool seengamma = false;
bool seendelta = false;
- for (ClientClasses::const_iterator it = classes.cbegin();
- it != classes.cend(); ++it) {
+ for (auto const& it : classes) {
++count;
- if (*it == "alpha") {
+ if (it == "alpha") {
seenalpha = true;
- } else if (*it == "beta") {
+ } else if (it == "beta") {
seenbeta = true;
- } else if (*it == "gamma") {
+ } else if (it == "gamma") {
seengamma = true;
- } else if (*it == "delta") {
+ } else if (it == "delta") {
seendelta = true;
} else {
- ADD_FAILURE() << "Got unexpected " << *it;
+ ADD_FAILURE() << "Got unexpected " << it;
}
}
EXPECT_EQ(count, classes.size());
#include <dhcp/tests/packet_queue_testutils.h>
#include <testutils/gtest_utils.h>
-#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
// Check if there is any other socket bound to the specified address
// and port on this interface.
const Iface::SocketCollection& sockets = iface.getSockets();
- for (Iface::SocketCollection::const_iterator socket = sockets.begin();
- socket != sockets.end(); ++socket) {
- if (((socket->addr_ == addr) ||
- ((socket->addr_ == IOAddress("::")) && join_multicast)) &&
- socket->port_ == port) {
+ for (auto const& socket : sockets) {
+ if (((socket.addr_ == addr) ||
+ ((socket.addr_ == IOAddress("::")) && join_multicast)) &&
+ socket.port_ == port) {
isc_throw(SocketConfigError, "test socket bind error");
}
}
return (false);
}
const Iface::SocketCollection& sockets = iface->getSockets();
- for (Iface::SocketCollection::const_iterator sock = sockets.begin();
- sock != sockets.end(); ++sock) {
- if (sock->addr_ == IOAddress(addr)) {
+ for (auto const& sock : sockets) {
+ if (sock.addr_ == IOAddress(addr)) {
return (true);
- } else if ((sock->addr_ == IOAddress("::")) &&
+ } else if ((sock.addr_ == IOAddress("::")) &&
(IOAddress(addr).isV6LinkLocal())) {
- BOOST_FOREACH(Iface::Address a, iface->getAddresses()) {
+ for (auto const& a : iface->getAddresses()) {
if (a.get() == IOAddress(addr)) {
return (true);
}
const bool up, const bool running,
const bool inactive4,
const bool inactive6) {
- for (const IfacePtr& iface : ifaces_) {
+ for (auto const& iface : ifaces_) {
if (iface->getName() == name) {
iface->flag_loopback_ = loopback;
iface->flag_up_ = up;
// Loop through sockets and try to find the ones which match the
// specified type.
int sockets_count = 0;
- for (Iface::SocketCollection::const_iterator sock = sockets.begin();
- sock != sockets.end(); ++sock) {
+ for (auto const& sock : sockets) {
// Match found, increase the counter.
- if (sock->family_ == family) {
+ if (sock.family_ == family) {
++sockets_count;
}
}
const isc::dhcp::SocketInfo*
getSocketByAddr(const isc::dhcp::Iface::SocketCollection& sockets,
const IOAddress& addr) {
- for (isc::dhcp::Iface::SocketCollection::const_iterator s =
- sockets.begin(); s != sockets.end(); ++s) {
- if (s->addr_ == addr) {
- return (&(*s));
+ for (auto const& s : sockets) {
+ if (s.addr_ == addr) {
+ return (&s);
}
}
return (NULL);
cout << "There are " << ifacemgr->getIfacesLst().size()
<< " interfaces." << endl;
- for (const IfacePtr& iface : ifacemgr->getIfacesLst()) {
+ for (auto const& iface : ifacemgr->getIfacesLst()) {
cout << " " << iface->getFullName() << endl;
}
IOAddress addrv4 = IOAddress::fromBytes(AF_INET, p);
- BOOST_FOREACH(Iface::Address a, iface.getAddresses()) {
+ for (auto const& a :iface.getAddresses()) {
if(a.get().isV4() && (a.get()) == addrv4) {
return (true);
}
IOAddress addrv6 = IOAddress::fromBytes(AF_INET6, p);
- BOOST_FOREACH(Iface::Address a, iface.getAddresses()) {
+ for (auto const& a : iface.getAddresses()) {
if (a.get().isV6() && (a.get() == addrv6)) {
return (true);
}
ASSERT_EQ(1, col.size());
ASSERT_EQ(1, col.begin()->second->getOptions().size());
uint8_t index = 0;
- for (auto const& option : col.begin()->second->getOptions()) {
+ auto const& options = col.begin()->second->getOptions();
+ for (auto const& option : options) {
for (auto const& value : option.second->getData()) {
ASSERT_EQ(index, value);
index++;
// Get all definitions.
const OptionDefContainerPtr defs = LibDHCP::getOptionDefs(DHCP6_OPTION_SPACE);
// For each definition try to find it using option name.
- for (OptionDefContainer::const_iterator def = defs->begin();
- def != defs->end(); ++def) {
+ for (auto const& def : *defs) {
OptionDefinitionPtr def_by_name =
- LibDHCP::getOptionDef(DHCP6_OPTION_SPACE, (*def)->getName());
+ LibDHCP::getOptionDef(DHCP6_OPTION_SPACE, def->getName());
ASSERT_TRUE(def_by_name);
- ASSERT_TRUE(**def == *def_by_name);
+ ASSERT_TRUE(*def == *def_by_name);
}
}
// Get all definitions.
const OptionDefContainerPtr defs = LibDHCP::getOptionDefs(DHCP4_OPTION_SPACE);
// For each definition try to find it using option name.
- for (OptionDefContainer::const_iterator def = defs->begin();
- def != defs->end(); ++def) {
+ for (auto const& def : *defs) {
OptionDefinitionPtr def_by_name =
- LibDHCP::getOptionDef(DHCP4_OPTION_SPACE, (*def)->getName());
+ LibDHCP::getOptionDef(DHCP4_OPTION_SPACE, def->getName());
ASSERT_TRUE(def_by_name);
- ASSERT_TRUE(**def == *def_by_name);
+ ASSERT_TRUE(*def == *def_by_name);
}
}
const OptionDefContainerPtr& defs =
LibDHCP::getVendorOptionDefs(Option::V6, VENDOR_ID_CABLE_LABS);
ASSERT_TRUE(defs);
- for (OptionDefContainer::const_iterator def = defs->begin();
- def != defs->end(); ++def) {
+ for (auto const& def : *defs) {
OptionDefinitionPtr def_by_name =
LibDHCP::getVendorOptionDef(Option::V6, VENDOR_ID_CABLE_LABS,
- (*def)->getName());
+ def->getName());
ASSERT_TRUE(def_by_name);
- ASSERT_TRUE(**def == *def_by_name);
+ ASSERT_TRUE(*def == *def_by_name);
}
}
const OptionDefContainerPtr& defs =
LibDHCP::getVendorOptionDefs(Option::V4, VENDOR_ID_CABLE_LABS);
ASSERT_TRUE(defs);
- for (OptionDefContainer::const_iterator def = defs->begin();
- def != defs->end(); ++def) {
+ for (auto const& def : *defs) {
OptionDefinitionPtr def_by_name =
LibDHCP::getVendorOptionDef(Option::V4, VENDOR_ID_CABLE_LABS,
- (*def)->getName());
+ def->getName());
ASSERT_TRUE(def_by_name);
- ASSERT_TRUE(**def == *def_by_name);
+ ASSERT_TRUE(*def == *def_by_name);
}
}
// Iterate over source options.
OptionCollection::const_iterator it_copy = option_copy_subs.begin();
- for (OptionCollection::const_iterator it = option_subs.begin();
- it != option_subs.end(); ++it, ++it_copy) {
+ for (auto const& it : option_subs) {
// The option codes should be equal in both containers.
- EXPECT_EQ(it->first, it_copy->first);
+ EXPECT_EQ(it.first, it_copy->first);
// Pointers must be unequal because the expectation is that options
// are copied, rather than pointers.
- EXPECT_NE(it->second, it_copy->second);
- Option* opt_ptr = it->second.get();
+ EXPECT_NE(it.second, it_copy->second);
+ Option* opt_ptr = it.second.get();
Option* opt_copy_ptr = it_copy->second.get();
// The C++ types must match.
EXPECT_TRUE(typeid(*opt_ptr) == typeid(*opt_copy_ptr));
+ ++it_copy;
}
// Final check is to compare their binary representations.
// Create a vector of strings representing addresses given above.
std::vector<std::string> addrs_str;
- for (std::vector<asiolink::IOAddress>::const_iterator it = addrs.begin();
- it != addrs.end(); ++it) {
- addrs_str.push_back(it->toText());
+ for (auto const& it : addrs) {
+ addrs_str.push_back(it.toText());
}
// Create DHCPv6 option using the list of IPv6 addresses given in the
// Create a vector of strings representing addresses given above.
std::vector<std::string> addrs_str;
- for (std::vector<asiolink::IOAddress>::const_iterator it = addrs.begin();
- it != addrs.end(); ++it) {
- addrs_str.push_back(it->toText());
+ for (auto const& it : addrs) {
+ addrs_str.push_back(it.toText());
}
// Create DHCPv4 option using the list of IPv4 addresses given in the
// in the packet.
pkt->setCopyRetrievedOptions(false);
OptionCollection options_modified = pkt->getOptions(1);
- for (OptionCollection::const_iterator opt_it_modified = options_modified.begin();
- opt_it_modified != options_modified.end(); ++opt_it_modified) {
- opt_it = std::find(options.begin(), options.end(), *opt_it_modified);
+ for (auto const& opt_it_modified : options_modified) {
+ opt_it = std::find(options.begin(), options.end(), opt_it_modified);
ASSERT_TRUE(opt_it != options.end());
}
#include <testutils/gtest_utils.h>
#include <util/range_utilities.h>
#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/range/adaptor/reversed.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/pointer_cast.hpp>
#include <util/encode/hex.h>
// Both options must be of type 2 and there must not be
// any other type returned
- for (OptionCollection::const_iterator x= options.begin();
- x != options.end(); ++x) {
- EXPECT_EQ(2, x->second->getType());
+ for (auto const& x : options) {
+ EXPECT_EQ(2, x.second->getType());
}
// Try to get a single option. Normally for singular options
// that copies of the options were used to replace original options
// in the packet.
OptionCollection options_modified = pkt.getNonCopiedOptions(1);
- for (OptionCollection::const_iterator opt_it_modified = options_modified.begin();
- opt_it_modified != options_modified.end(); ++opt_it_modified) {
- opt_it = std::find(options.begin(), options.end(), *opt_it_modified);
+ for (auto const& opt_it_modified : options_modified) {
+ opt_it = std::find(options.begin(), options.end(), opt_it_modified);
ASSERT_TRUE(opt_it != options.end());
}
// Check reverse order.
vector<OptionPtr> ropts;
- for (auto it = opts.rbegin(); it != opts.rend(); ++it) {
- ropts.push_back(it->second);
+ for (auto const& it : boost::adaptors::reverse(opts)) {
+ ropts.push_back(it.second);
}
+
EXPECT_TRUE(lopts0 == ropts);
// We just want option from the first relay (closest to the client)
#include <dhcp/pkt6.h>
#include <dhcp/tests/pkt_filter6_test_utils.h>
-#include <boost/foreach.hpp>
-
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
const uint16_t port, const bool) {
// Check if there is any other socket bound to the specified address
// and port on this interface.
- BOOST_FOREACH(SocketInfo socket, iface.getSockets()) {
+ for (auto const& socket : iface.getSockets()) {
if ((socket.addr_ == addr) && (socket.port_ == port)) {
isc_throw(SocketConfigError, "test socket bind error");
}
#include <dhcp/testutils/pkt_filter_test_stub.h>
#include <dhcp/testutils/pkt_filter6_test_stub.h>
-#include <boost/foreach.hpp>
-
using namespace isc::asiolink;
namespace isc {
isc_throw(Unexpected, "No such interface '" << iface_name << "'");
}
- BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
+ for (auto const& sock : iface->getSockets()) {
if (sock.family_ == family) {
return (true);
}
isc_throw(Unexpected, "No such interface '" << iface_name << "'");
}
- BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
+ for (auto const& sock : iface->getSockets()) {
if ((sock.family_ == AF_INET) &&
(sock.addr_ == IOAddress(address))) {
return (true);
isc_throw(Unexpected, "No such interface '" << iface_name << "'");
}
- BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
+ for (auto const& sock : iface->getSockets()) {
if ((!sock.addr_.isV6LinkLocal()) &&
(!sock.addr_.isV6Multicast())) {
return (true);
// 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;
}
}
}
// 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);
}
// 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))) {
// 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();
// 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.
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();
// 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);
// 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.
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)))) {
// 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();
candidate_valid = cl->getValid();
++have_both;
}
+ if (have_both == 2) {
+ break;
+ }
}
}
}
// 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);
}
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);
}
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);
}
}
size_t leases_processed = 0;
- BOOST_FOREACH(Lease6Ptr lease, leases) {
+ for (auto const& lease : leases) {
try {
// Reclaim the lease.
}
size_t leases_processed = 0;
- BOOST_FOREACH(Lease4Ptr lease, leases) {
+ for (auto const& lease : leases) {
try {
// Reclaim the 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;
}
// 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.
// 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;
}
}
}
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;
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;
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());
}
}
};
#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;
// 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;
network->del(subnet->getID());
}
// Actually delete the subnet from the configuration.
- current_cfg->getCfgSubnets4()->del((*entry)->getObjectId());
+ current_cfg->getCfgSubnets4()->del(entry->getObjectId());
}
}
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);
}
}
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_);
}
}
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.
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) {
#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;
// 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;
network->del(subnet->getID());
}
// Actually delete the subnet from the configuration.
- current_cfg->getCfgSubnets6()->del((*entry)->getObjectId());
+ current_cfg->getCfgSubnets6()->del(entry->getObjectId());
}
}
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);
}
}
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_);
}
}
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.
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) {
#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>
// 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.
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);
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);
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);
#include <dhcpsrv/cfgmgr.h>
#include <exceptions/exceptions.h>
#include <util/encode/hex.h>
+#include <boost/foreach.hpp>
#include <ostream>
#include <string>
#include <vector>
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)
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)
.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);
}
}
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_);
}
}
// 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,
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,
// 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"
}
// 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));
}
}
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);
}
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;) {
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());
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());
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);
bool
CfgIface::multipleAddressesPerInterfaceActive() {
- for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
+ for (auto const& iface : IfaceMgr::instance().getIfaces()) {
if (iface->countActive4() > 1) {
return (true);
}
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;
}
// 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
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) {
// 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;
}
}
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;
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);
}
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);
}
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.");
}
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));
}
return (result);
}
-};
-};
+}
+}
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);
}
}
}
// 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());
}
}
}
#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>
/// 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.
///
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);
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);
}
}
}
// 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);
}
}
// 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 {
// Include metadata if requested.
if (include_metadata) {
- map->set("metadata", (*def)->getMetadata());
+ map->set("metadata", def->getMetadata());
}
// Push on the list
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);
#include <cc/data.h>
#include <exceptions/exceptions.h>
#include <dhcpsrv/shared_network.h>
+#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
#include <string>
// 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.
// 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);
}
// 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;
}
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.
}
// 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));
}
}
#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>
// 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_;
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/parsers/client_class_def_parser.h>
-#include <boost/foreach.hpp>
#include <queue>
if (rhs.match_expr_) {
match_expr_.reset(new Expression());
- *match_expr_ = *(rhs.match_expr_);
+ *match_expr_ = *rhs.match_expr_;
}
if (rhs.cfg_option_def_) {
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_))) &&
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);
}
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;
}
}
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);
}
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);
}
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;
}
}
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();
// 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;
// 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;
#include <util/encode/hex.h>
#include <util/strutil.h>
+#include <boost/foreach.hpp>
#include <sstream>
using namespace isc::data;
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);
}
}
// 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
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
// 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);
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.
#endif
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <algorithm>
#include <iostream>
}
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());
}
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();
#include <stats/stats_mgr.h>
#include <util/encode/hex.h>
-#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
#include <algorithm>
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);
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")));
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);
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")));
}
}
- 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")));
#endif
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <algorithm>
#include <iostream>
#include <util/multi_threading_mgr.h>
#include <util/pid_file.h>
+#include <boost/foreach.hpp>
#include <cstdio>
#include <cstring>
#include <errno.h>
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)));
}
}
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)));
}
}
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)));
}
}
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)));
}
}
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)));
}
}
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)));
}
}
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)));
}
}
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)));
}
}
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)));
}
}
// 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);
// 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);
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);
}
}
}
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);
}
}
}
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());
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.
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;
}
#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>
// 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);
}
}
}
// 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);
}
}
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());
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);
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);
}
#include <asiolink/io_address.h>
#include <asiolink/io_error.h>
-#include <boost/foreach.hpp>
#include <algorithm>
#include <sstream>
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
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);
}
// 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);
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"
}
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);
"(" << 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);
}
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 *************************
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 *************************
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 *************************
/// Parse Pools first.
ConstElementPtr pools = subnet->get("pools");
if (pools) {
- auto parser = createPoolsListParser();
+ auto const& parser = createPoolsListParser();
parser->parse(pools_, pools, 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);
}
}
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());
}
}
boost::shared_ptr<PoolsListParser>
Subnet4ConfigParser::createPoolsListParser() const {
- auto parser = boost::make_shared<Pools4ListParser>();
- return (parser);
+ return (boost::make_shared<Pools4ListParser>());
}
//**************************** Subnets4ListConfigParser **********************
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) {
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 {
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 *********************************
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 ******************************
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>
PdPoolParser::createOptionDataListParser() const {
- auto parser = boost::make_shared<OptionDataListParser>(AF_INET6);
- return (parser);
+ return (boost::make_shared<OptionDataListParser>(AF_INET6));
}
//**************************** PdPoolsListParser ************************
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 ***********************
/// 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);
}
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);
}
}
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());
}
}
}
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 '"
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 ********************
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
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 {
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 **********************
#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>
#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>
#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;
#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>
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"
// 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 << ", ";
}
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.
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") {
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());
}
}
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
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.
} 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) {
// 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") {
#include <cc/simple_parser.h>
#include <dhcpsrv/host.h>
#include <dhcpsrv/subnet_id.h>
-#include <boost/foreach.hpp>
namespace isc {
namespace dhcp {
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));
}
#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>
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);
}
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;
#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>
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
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);
}
}
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());
}
}
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());
}
}
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);
}
}
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&) {
#include <dhcpsrv/parsers/simple_parser4.h>
#include <cc/data.h>
-#include <boost/foreach.hpp>
#include <iostream>
using namespace isc::data;
// 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);
}
}
// 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);
// 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);
}
// 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.
// 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);
}
#include <cc/data.h>
#include <dhcpsrv/parsers/simple_parser6.h>
-#include <boost/foreach.hpp>
-
using namespace isc::data;
namespace isc {
// 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);
}
}
// 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);
}
}
// 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);
// 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);
}
// 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.
// 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);
}
#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>
// 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);
}
}
}
// 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);
}
}
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());
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);
}
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;
}
// instance.
if (current_subnet_state->getLastAllocatedTime() >
preferred_subnet_state->getLastAllocatedTime()) {
- preferred_subnet = (*s);
+ preferred_subnet = s;
}
}
return (preferred_subnet);
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();
}
}
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);
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();
}
}
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);
// 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);
}
}
}
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);
}
}
}
// 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);
}
// 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);
}
}
// 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);
}
// 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);
}
}
}
}
// 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
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()
}
// 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()
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()
}
// Now check that the lease in LeaseMgr has the same parameters
- detailCompareLease(*it, from_mgr);
+ detailCompareLease(it, from_mgr);
}
return (leases);
#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>
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);
}
}
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);
}
}
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());
// 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());
// 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.
// 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.
// 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
#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>
// 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;
}
// 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;
}
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<
// 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);
// 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());
}
}
// 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;
}
// 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;
}
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++;
}
}
#include <testutils/test_to_element.h>
#include <util/doubles.h>
+#include <boost/range/adaptor/reversed.hpp>
#include <gtest/gtest.h>
#include <vector>
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.
// 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 {
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();
}
// 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()));
}
}
}
// 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 {
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();
}
// 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()));
}
}
}
#include <testutils/test_to_element.h>
#include <util/doubles.h>
+#include <boost/range/adaptor/reversed.hpp>
#include <gtest/gtest.h>
#include <string>
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.
// 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 {
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();
}
// 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();
}
}
}
// 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 {
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();
}
// 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()));
}
}
}
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());
}
}
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());
}
}
#include <testutils/test_to_element.h>
#include <gtest/gtest.h>
-#include <boost/foreach.hpp>
#include <boost/pointer_cast.hpp>
#include <map>
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.
// 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);
}
}
#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>
/// 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);
}
}
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();
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.
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();
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);
}
#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>
/// @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);
}
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
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" ;
}
}
// 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);
}
}
// 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);
}
}
// 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;
}
}
// 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;
}
// 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;
}
// 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());
}
}
// 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;
}
// 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;
}
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";
}
#include <typeinfo>
#include <testutils/gtest_utils.h>
+#include <boost/range/adaptor/reversed.hpp>
+
using namespace isc::data;
using namespace isc::db;
// 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())
// 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())
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()) << ", "
// 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());
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
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.
// 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--;
}
}
// 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());
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
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.
// 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--;
}
}
}
// 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());
}
}
// 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
// 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());
}
}
// 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());
}
}
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) +
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) +
#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>
// 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]);
// 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]);
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);
}
// 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;
LeasePageSize(3));
// Collect leases in a common structure.
- for (Lease6Ptr lease : page) {
+ for (auto const& lease : page) {
all_leases.push_back(lease);
}
// 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;
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);
}
// 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;
// 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]);
// 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) {
// 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.
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.
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.
// 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_);
}
}
// 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.
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.
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.
// 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_);
}
}
// 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++;
}
}
// 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++;
}
}
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_);
}
}
// 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++;
}
}
// 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++;
}
}
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_);
}
}
// 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),
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());
}
}
#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;
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;
}
}
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);
<< "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_)
#include <config.h>
#include <dhcpsrv/testutils/memory_host_data_source.h>
+#include <boost/foreach.hpp>
using namespace isc::db;
using namespace std;
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);
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);
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);
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);
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);
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);
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;
}
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;
}
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;
}
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;
}
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);
}
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);
}
}
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);
}
}
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);
}
}
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);
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);
}
}
}
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);
}
}
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);
}
}
// 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);
}
#include <database/database_connection.h>
#include <test_config_backend_dhcp4.h>
+#include <boost/foreach.hpp>
#include <list>
using namespace isc::data;
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;
}
}
}
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));
}
}
}
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;
}
}
}
// 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();
#include <database/database_connection.h>
#include <test_config_backend_dhcp6.h>
+#include <boost/foreach.hpp>
using namespace isc::data;
using namespace isc::db;
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);
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);
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);
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);
}
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;
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);
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);
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);
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;
}
}
}
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;
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);
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));
}
}
}
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;
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);
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;
}
}
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;
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);
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);
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()) {
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) {
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.
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>();
} 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;
} 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;
}
} 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;
}
} 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;
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>();
}
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;
}
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;
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());
}
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;
}
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;
}
// 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();
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());
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) &&
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))) {
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) &&
} 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;
} 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;
}
} 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;
}
} 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;
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);
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;
}
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;
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;
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);
}
}
#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;
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) {
#include <dns/master_lexer_inputsource.h>
#include <dns/master_lexer_state.h>
-#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/lexical_cast.hpp>
size_t
MasterLexer::getPosition() const {
size_t position = impl_->popped_size_;
- BOOST_FOREACH(InputSourcePtr& src, impl_->sources_) {
+ for (auto const& src : impl_->sources_) {
position += src->getPosition();
}
return (position);
{
std::string rstr;
- for (std::string::const_iterator it = str.begin(); it != str.end();) {
+ for (auto it = str.begin(); it != str.end();) {
switch (*it) {
case '$':
// This is the case when the '$' character is encountered in
#include <sstream>
#include <vector>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
}
- BOOST_FOREACH(ConstRRsetPtr r, impl_->rrsets_[section]) {
+ for (auto const& r : impl_->rrsets_[section]) {
if (r->getClass() == rrclass &&
r->getType() == rrtype &&
r->getName() == name) {
}
bool removed = false;
- for (vector<RRsetPtr>::iterator i = impl_->rrsets_[section].begin();
- i != impl_->rrsets_[section].end(); ++i) {
+ for (auto i = impl_->rrsets_[section].begin(); i != impl_->rrsets_[section].end(); ++i) {
if (((*i)->getName() == (*iterator)->getName()) &&
((*i)->getClass() == (*iterator)->getClass()) &&
((*i)->getType() == (*iterator)->getType())) {
}
if (section == SECTION_QUESTION) {
- for (QuestionIterator qi = source.beginQuestion();
- qi != source.endQuestion();
- ++qi) {
+ for (auto qi = source.beginQuestion(); qi != source.endQuestion(); ++qi) {
addQuestion(*qi);
}
} else {
- for (RRsetIterator rrsi = source.beginSection(section);
- rrsi != source.endSection(section);
- ++rrsi) {
+ for (auto rrsi = source.beginSection(section); rrsi != source.endSection(section); ++rrsi) {
addRRset(section, *rrsi);
}
}
size_t offset_count = offsets_.size();
offsets_.insert(offsets_.end(), origin->offsets_.begin(),
origin->offsets_.end());
- for (NameOffsets::iterator it(offsets_.begin() + offset_count);
- it != offsets_.end(); ++it) {
+ for (auto it(offsets_.begin() + offset_count); it != offsets_.end(); ++it) {
*it += offset;
}
std::string
charStringToString(const CharString& char_string) {
std::string s;
- for (CharString::const_iterator it = char_string.begin() + 1;
- it != char_string.end(); ++it) {
- const uint8_t ch = *it;
+ bool first = true;
+ for (auto const& it : char_string) {
+ if (first) {
+ first = false;
+ continue;
+ }
+ const uint8_t ch = it;
if ((ch < 0x20) || (ch >= 0x7f)) {
// convert to escaped \xxx (decimal) format
s.push_back('\\');
std::string
charStringDataToString(const CharStringData& char_string) {
std::string s;
- for (CharString::const_iterator it = char_string.begin();
- it != char_string.end(); ++it) {
- const uint8_t ch = *it;
+ for (auto const& it : char_string) {
+ const uint8_t ch = it;
if ((ch < 0x20) || (ch >= 0x7f)) {
// convert to escaped \xxx (decimal) format
s.push_back('\\');
#include <vector>
#include <boost/lexical_cast.hpp>
-#include <boost/foreach.hpp>
#include <util/encode/base64.h>
#include <util/buffer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
-#include <boost/foreach.hpp>
-
#include <string>
#include <string.h>
void
OPT::toWire(OutputBuffer& buffer) const {
- BOOST_FOREACH(const PseudoRR& pseudo_rr, impl_->pseudo_rrs_) {
+ for (auto const& pseudo_rr : impl_->pseudo_rrs_) {
buffer.writeUint16(pseudo_rr.getCode());
const uint16_t length = pseudo_rr.getLength();
buffer.writeUint16(length);
void
OPT::toWire(AbstractMessageRenderer& renderer) const {
- BOOST_FOREACH(const PseudoRR& pseudo_rr, impl_->pseudo_rrs_) {
+ for (auto const& pseudo_rr : impl_->pseudo_rrs_) {
renderer.writeUint16(pseudo_rr.getCode());
const uint16_t length = pseudo_rr.getLength();
renderer.writeUint16(length);
#include <vector>
#include <boost/lexical_cast.hpp>
-#include <boost/foreach.hpp>
#include <util/encode/base64.h>
#include <util/buffer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
-#include <boost/foreach.hpp>
-
#include <string>
#include <string.h>
void
OPT::toWire(OutputBuffer& buffer) const {
- BOOST_FOREACH(const PseudoRR& pseudo_rr, impl_->pseudo_rrs_) {
+ for (auto const& pseudo_rr : impl_->pseudo_rrs_) {
buffer.writeUint16(pseudo_rr.getCode());
const uint16_t length = pseudo_rr.getLength();
buffer.writeUint16(length);
void
OPT::toWire(AbstractMessageRenderer& renderer) const {
- BOOST_FOREACH(const PseudoRR& pseudo_rr, impl_->pseudo_rrs_) {
+ for (auto const& pseudo_rr : impl_->pseudo_rrs_) {
renderer.writeUint16(pseudo_rr.getCode());
const uint16_t length = pseudo_rr.getLength();
renderer.writeUint16(length);
#include <vector>
#include <boost/shared_ptr.hpp>
-#include <boost/foreach.hpp>
#include <util/buffer.h>
#include <dns/messagerenderer.h>
// sort the set of Rdata based on rrset-order and sortlist, and possible
// other options. Details to be considered.
- BOOST_FOREACH(const ConstRdataPtr& rdata, rdatalist_) {
+ for (auto const& rdata : rdatalist_) {
const size_t pos0 = renderer.getLength();
assert(pos0 < 65536);
if (answer_data != NULL) {
RRsetPtr ans_rrset(new RRset(Name("www.example.com"), RRClass::IN(),
qtype, RRTTL(86400)));
- for (vector<const char*>::const_iterator it = answer_data->begin();
- it != answer_data->end();
- ++it) {
- ans_rrset->addRdata(createRdata(qtype, RRClass::IN(), *it));
+ for (auto const& it : *answer_data) {
+ ans_rrset->addRdata(createRdata(qtype, RRClass::IN(), it));
}
message.addRRset(Message::SECTION_ANSWER, ans_rrset);
}
// decimal representation for "WWW"
strnames.push_back("\\087\\087\\087.example.com");
- vector<string>::const_iterator it;
- for (it = strnames.begin(); it != strnames.end(); ++it) {
- EXPECT_PRED_FORMAT2(UnitTestUtil::matchName, example_name, Name(*it));
+ for (auto const& it : strnames) {
+ EXPECT_PRED_FORMAT2(UnitTestUtil::matchName, example_name, Name(it));
}
// root names
NameComparisonResult::EQUAL,
0, 5));
- vector<CompareParameters>::const_iterator it;
- for (it = params.begin(); it != params.end(); ++it) {
- NameComparisonResult result = (*it).name1.compare((*it).name2);
- EXPECT_EQ((*it).reln, result.getRelation());
- EXPECT_EQ((*it).order,
- CompareParameters::normalizeOrder(result.getOrder()));
- EXPECT_EQ((*it).labels, result.getCommonLabels());
+ for (auto const& it : params) {
+ NameComparisonResult result = it.name1.compare(it.name2);
+ EXPECT_EQ(it.reln, result.getRelation());
+ EXPECT_EQ(it.order, CompareParameters::normalizeOrder(result.getOrder()));
+ EXPECT_EQ(it.labels, result.getCommonLabels());
}
}
vector<generic::NSEC> compare_set;
compare_set.push_back(generic::NSEC("a.example. A"));
compare_set.push_back(generic::NSEC("example. A"));
+
vector<generic::NSEC>::const_iterator it;
const vector<generic::NSEC>::const_iterator it_end = compare_set.end();
for (it = compare_set.begin(); it != it_end - 1; ++it) {
texts.push_back("Test-String\"Test-String\""); // and no space either
std::stringstream ss;
- for (std::vector<std::string >::const_iterator it = texts.begin();
- it != texts.end(); ++it) {
- ss << *it << "\n";
+ for (auto const& it : texts) {
+ ss << it << "\n";
}
this->lexer.pushSource(ss);
// Confirm we can construct the Rdata from the test text, both from
// std::string and with lexer, and that matches the from-wire data.
- for (std::vector<std::string >::const_iterator it = texts.begin();
- it != texts.end(); ++it) {
- SCOPED_TRACE(*it);
- EXPECT_EQ(0, TypeParam(*it).compare(*rdata));
+ for (auto const& it : texts) {
+ SCOPED_TRACE(it);
+ EXPECT_EQ(0, TypeParam(it).compare(*rdata));
EXPECT_EQ(0, TypeParam(this->lexer, NULL, MasterLoader::MANY_ERRORS,
this->loader_cb).compare(*rdata));
// Here, we just count the records and do some basic tests on them.
size_t count = 0;
- for (RRsetCollection::Iterator it = collection.begin();
- it != collection.end(); ++it) {
+ for (auto const& it : collection) {
++count;
- const AbstractRRset& rrset = *it;
+ const AbstractRRset& rrset = it;
EXPECT_EQ(rrclass, rrset.getClass());
EXPECT_EQ(RRTTL(3600), rrset.getTTL());
}
if (!expr) {
return (false);
}
- for (auto it = expr->cbegin(); it != expr->cend(); ++it) {
- if (dependOnClass(*it, name)) {
+ for (auto const& it : *expr) {
+ if (dependOnClass(it, name)) {
return (true);
}
}
return (false);
}
-}; // end of isc::dhcp namespace
-}; // end of isc namespace
+} // end of isc::dhcp namespace
+} // end of isc namespace
bool evaluateBool(const Expression& expr, Pkt& pkt) {
ValueStack values;
- for (Expression::const_iterator it = expr.begin();
- it != expr.end(); ++it) {
- (*it)->evaluate(pkt, values);
+ for (auto const& it : expr) {
+ it->evaluate(pkt, values);
}
if (values.size() != 1) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected exactly "
std::string
evaluateString(const Expression& expr, Pkt& pkt) {
ValueStack values;
- for (auto it = expr.begin(); it != expr.end(); ++it) {
- (*it)->evaluate(pkt, values);
+ for (auto const& it : expr) {
+ it->evaluate(pkt, values);
}
if (values.size() != 1) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected exactly "
return (values.top());
}
-
-}; // end of isc::dhcp namespace
-}; // end of isc namespace
+} // end of isc::dhcp namespace
+} // end of isc namespace
vector<string>
CalloutHandle::getArgumentNames() const {
vector<string> names;
- for (ElementCollection::const_iterator i = arguments_.begin();
- i != arguments_.end(); ++i) {
- names.push_back(i->first);
+ for (auto const& i : arguments_) {
+ names.push_back(i.first);
}
return (names);
CalloutHandle::getContextNames() const {
vector<string> names;
const ElementCollection& elements = getContextForLibrary();
- for (ElementCollection::const_iterator i = elements.begin();
- i != elements.end(); ++i) {
- names.push_back(i->first);
+ for (auto const& i : elements) {
+ names.push_back(i.first);
}
return (names);
.arg(server_hooks_.getName(callout_handle.getCurrentHook()));
// Call all the callouts.
- for (CalloutVector::const_iterator i = hook_vector_[hook_index].begin();
- i != hook_vector_[hook_index].end(); ++i) {
+ for (auto const& i : hook_vector_[hook_index]) {
// In case the callout requires access to the context associated
// with the library, set the current library index to the index
// associated with the library that registered the callout being
// called.
- callout_handle.setCurrentLibrary(i->first);
+ callout_handle.setCurrentLibrary(i.first);
// Call the callout
try {
stopwatch.start();
- int status = (*i->second)(callout_handle);
+ int status = (*i.second)(callout_handle);
stopwatch.stop();
if (status == 0) {
LOG_DEBUG(callouts_logger, HOOKS_DBG_EXTENDED_CALLS,
HOOKS_CALLOUT_CALLED)
.arg(callout_handle.getCurrentLibrary())
.arg(server_hooks_.getName(callout_handle.getCurrentHook()))
- .arg(PointerConverter(i->second).dlsymPtr())
+ .arg(PointerConverter(i.second).dlsymPtr())
.arg(stopwatch.logFormatLastDuration());
} else {
LOG_ERROR(callouts_logger, HOOKS_CALLOUT_ERROR)
.arg(server_hooks_.getName(callout_handle.getCurrentHook()))
.arg(callout_handle.getCurrentLibrary())
- .arg(PointerConverter(i->second).dlsymPtr())
+ .arg(PointerConverter(i.second).dlsymPtr())
.arg(stopwatch.logFormatLastDuration());
}
} catch (const std::exception& e) {
LOG_ERROR(callouts_logger, HOOKS_CALLOUT_EXCEPTION)
.arg(server_hooks_.getName(callout_handle.getCurrentHook()))
.arg(callout_handle.getCurrentLibrary())
- .arg(PointerConverter(i->second).dlsymPtr())
+ .arg(PointerConverter(i.second).dlsymPtr())
.arg(e.what())
.arg(stopwatch.logFormatLastDuration());
callout_handle.setStatus(CalloutHandle::NEXT_STEP_DROP);
LOG_ERROR(callouts_logger, HOOKS_CALLOUT_EXCEPTION)
.arg(server_hooks_.getName(callout_handle.getCurrentHook()))
.arg(callout_handle.getCurrentLibrary())
- .arg(PointerConverter(i->second).dlsymPtr())
+ .arg(PointerConverter(i.second).dlsymPtr())
.arg("Unspecified exception")
.arg(stopwatch.logFormatLastDuration());
callout_handle.setStatus(CalloutHandle::NEXT_STEP_DROP);
/// We don't have any libraries that are interacting (or would change their behavior
/// depending on the order in which their callouts are executed), so the code is
/// ok for now.
- for (isc::hooks::HookLibsCollection::const_iterator this_it = libraries_.begin();
- this_it != libraries_.end(); ++this_it) {
+ for (auto const& this_it : libraries_) {
bool match = false;
- for (isc::hooks::HookLibsCollection::const_iterator other_it =
- other.libraries_.begin(); other_it != other.libraries_.end(); ++other_it) {
- if (this_it->first != other_it->first) {
+ for (auto const& other_it : other.libraries_) {
+ if (this_it.first != other_it.first) {
continue;
}
- if (isNull(this_it->second) && isNull(other_it->second)) {
+ if (isNull(this_it.second) && isNull(other_it.second)) {
match = true;
break;
}
- if (isNull(this_it->second) || isNull(other_it->second)) {
+ if (isNull(this_it.second) || isNull(other_it.second)) {
continue;
}
- if (this_it->second->equals(*other_it->second)) {
+ if (this_it.second->equals(*other_it.second)) {
match = true;
break;
}
// hooks-libraries is a list of maps
ElementPtr result = Element::createList();
// Iterate through libraries
- for (HookLibsCollection::const_iterator hl = libraries_.begin();
- hl != libraries_.end(); ++hl) {
+ for (auto const& hl : libraries_) {
// Entries are maps
ElementPtr map = Element::createMap();
// Set the library name
- map->set("library", Element::create(hl->first));
+ map->set("library", Element::create(hl.first));
// Set parameters (not set vs set empty map)
- if (!isNull(hl->second)) {
- map->set("parameters", hl->second);
+ if (!isNull(hl.second)) {
+ map->set("parameters", hl.second);
}
// Push to the list
result->add(map);
return (result);
}
-};
-};
+}
+}
#include <cc/dhcp_config_error.h>
#include <hooks/hooks_parser.h>
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <util/strutil.h>
#include <vector>
}
// This is the new syntax. Iterate through it and get each map.
- BOOST_FOREACH(ConstElementPtr library_entry, value->listValue()) {
+ for (auto const& library_entry : value->listValue()) {
ConstElementPtr parameters;
// Is it a map?
// values from the previous loop round.
parameters.reset();
- BOOST_FOREACH(auto const& entry_item, library_entry->mapValue()) {
+ for (auto const& entry_item : library_entry->mapValue()) {
if (entry_item.first == "library") {
if (entry_item.second->getType() != Element::string) {
isc_throw(DhcpConfigError, "hooks library configuration"
extractNames(const isc::hooks::HookLibsCollection& libraries) {
std::vector<std::string> names;
- for (isc::hooks::HookLibsCollection::const_iterator it = libraries.begin();
- it != libraries.end(); ++it) {
- names.push_back(it->first);
+ for (auto const& it : libraries) {
+ names.push_back(it.first);
}
return (names);
}
-};
-};
+}
+}
return (names);
}
auto const& map = params->mapValue();
- for (auto elem = map.begin(); elem != map.end(); ++elem) {
- names.push_back(elem->first);
+ for (auto const& elem : map) {
+ names.push_back(elem.first);
}
return (names);
}
-
} // namespace util
} // namespace isc
#include <hooks/hooks_manager.h>
#include <hooks/library_manager.h>
#include <hooks/library_manager_collection.h>
+#include <boost/range/adaptor/reversed.hpp>
namespace isc {
namespace hooks {
: library_info_(libraries) {
// We need to split hook libs into library names and library parameters.
- for (HookLibsCollection::const_iterator it = libraries.begin();
- it != libraries.end(); ++it) {
- library_names_.push_back(it->first);
+ for (auto const& it : libraries) {
+ library_names_.push_back(it.first);
}
}
LibraryManagerCollection::prepareUnloadLibraries() {
bool result = true;
// Iterate on library managers in reverse order.
- for (auto lm = lib_managers_.rbegin(); lm != lib_managers_.rend(); ++lm) {
- result = (*lm)->prepareUnloadLibrary() && result;
+ for (auto const& lm : boost::adaptors::reverse(lib_managers_)) {
+ result = lm->prepareUnloadLibrary() && result;
}
return (result);
}
vector<string>
ServerHooks::getHookNames() const {
-
vector<string> names;
- HookCollection::const_iterator i;
- for (i = hooks_.begin(); i != hooks_.end(); ++i) {
- names.push_back(i->first);
+ for (auto const& i : hooks_) {
+ names.push_back(i.first);
}
return (names);
return ("");
}
-
-
} // namespace hooks
} // namespace isc
void
HttpConnectionPool::stopAllInternal() {
- for (auto connection = connections_.begin();
- connection != connections_.end();
- ++connection) {
- (*connection)->close();
+ for (auto const& connection : connections_) {
+ connection->close();
}
connections_.clear();
}
// Copy headers from the context.
- for (auto header = context_->headers_.begin();
- header != context_->headers_.end();
- ++header) {
- HttpHeaderPtr hdr(new HttpHeader(header->name_, header->value_));
+ for (auto const& header : context_->headers_) {
+ HttpHeaderPtr hdr(new HttpHeader(header.name_, header.value_));
headers_[hdr->getLowerCaseName()] = hdr;
}
// Iterate over required headers and check that they exist
// in the HTTP request.
- for (auto req_header = required_headers_.begin();
- req_header != required_headers_.end();
- ++req_header) {
- auto header = headers_.find(req_header->first);
+ for (auto const& req_header : required_headers_) {
+ auto header = headers_.find(req_header.first);
if (header == headers_.end()) {
- isc_throw(BadValue, "required header " << req_header->first
+ isc_throw(BadValue, "required header " << req_header.first
<< " not found in the HTTP request");
- } else if (!req_header->second->getValue().empty() &&
- !header->second->isValueEqual(req_header->second->getValue())) {
+ } else if (!req_header.second->getValue().empty() &&
+ !header->second->isValueEqual(req_header.second->getValue())) {
// If specific value is required for the header, check
// that the value in the HTTP request matches it.
isc_throw(BadValue, "required header's " << header->first
- << " value is " << req_header->second->getValue()
+ << " value is " << req_header.second->getValue()
<< ", but " << header->second->getValue() << " was found");
}
}
}
// Add all other headers.
- for (auto header_it = headers_.cbegin(); header_it != headers_.cend();
- ++header_it) {
- if (header_it->second->getName() != "Host") {
- s << header_it->second->getName() << ": " << header_it->second->getValue()
+ for (auto const& header_it : headers_) {
+ if (header_it.second->getName() != "Host") {
+ s << header_it.second->getName() << ": " << header_it.second->getValue()
<< crlf;
}
}
}
// Copy headers from the context.
- for (auto header = context_->headers_.begin();
- header != context_->headers_.end();
- ++header) {
- HttpHeaderPtr hdr(new HttpHeader(header->name_, header->value_));
+ for (auto const& header : context_->headers_) {
+ HttpHeaderPtr hdr(new HttpHeader(header.name_, header.value_));
headers_[hdr->getLowerCaseName()] = hdr;
}
// Iterate over required headers and check that they exist
// in the HTTP response.
- for (auto req_header = required_headers_.begin();
- req_header != required_headers_.end();
- ++req_header) {
- auto header = headers_.find(req_header->first);
+ for (auto const& req_header : required_headers_) {
+ auto header = headers_.find(req_header.first);
if (header == headers_.end()) {
- isc_throw(BadValue, "required header " << req_header->first
+ isc_throw(BadValue, "required header " << req_header.first
<< " not found in the HTTP response");
- } else if (!req_header->second->getValue().empty() &&
- !header->second->isValueEqual(req_header->second->getValue())) {
+ } else if (!req_header.second->getValue().empty() &&
+ !header->second->isValueEqual(req_header.second->getValue())) {
// If specific value is required for the header, check
// that the value in the HTTP response matches it.
isc_throw(BadValue, "required header's " << header->first
- << " value is " << req_header->second->getValue()
+ << " value is " << req_header.second->getValue()
<< ", but " << header->second->getValue() << " was found");
}
}
// HTTP version number and status code.
s << toBriefString() << crlf;
- for (auto header_it = headers_.cbegin(); header_it != headers_.cend();
- ++header_it) {
- s << header_it->second->getName() << ": " << header_it->second->getValue()
+ for (auto const& header_it : headers_) {
+ s << header_it.second->getName() << ": " << header_it.second->getValue()
<< crlf;
}
///
/// Removes active HTTP clients.
virtual ~HttpListenerTest() {
- for (auto client = clients_.begin(); client != clients_.end();
- ++client) {
- (*client)->close();
+ for (auto const& client : clients_) {
+ client->close();
}
}
///
/// Removes active HTTP clients.
virtual ~HttpsListenerTest() {
- for (auto client = clients_.begin(); client != clients_.end();
- ++client) {
- (*client)->close();
+ for (auto const& client : clients_) {
+ client->close();
}
}
// be a good idea; as we can't reliably know whether in what
// state the logger instance is now (or what the specific logger's
// settings were).
- LogEventList::const_iterator it;
- for (it = stored_.begin(); it != stored_.end(); ++it) {
- const std::string level(it->first);
- LogEventPtr event(it->second);
+ for (auto const& it : stored_) {
+ const std::string level(it.first);
+ LogEventPtr event(it.second);
std::printf("%s [%s]: %s\n", level.c_str(),
event->getLoggerName().c_str(),
event->getMessage().c_str());
LogEventList stored_copy;
stored_.swap(stored_copy);
- LogEventList::const_iterator it;
- for (it = stored_copy.begin(); it != stored_copy.end(); ++it) {
- LogEventPtr event(it->second);
+ for (auto const& it : stored_copy) {
+ LogEventPtr event(it.second);
log4cplus::Logger logger =
log4cplus::Logger::getInstance(event->getLoggerName());
#include <log/logger.h>
-#include <boost/foreach.hpp>
-
using namespace std;
using namespace isc::log;
using namespace isc::util;
sortedIdentifiers(MessageDictionary& dictionary) {
vector<string> ident;
- for (MessageDictionary::const_iterator i = dictionary.begin();
- i != dictionary.end(); ++i) {
- ident.push_back(i->first);
+ for (auto const& i : dictionary) {
+ ident.push_back(i.first);
}
sort(ident.begin(), ident.end());
writeOpeningNamespace(hfile, ns_components);
vector<string> idents = sortedIdentifiers(dictionary);
- for (vector<string>::const_iterator j = idents.begin();
- j != idents.end(); ++j) {
- hfile << "extern const isc::log::MessageID " << *j << ";\n";
+ for (auto const& j : idents) {
+ hfile << "extern const isc::log::MessageID " << j << ";\n";
}
hfile << "\n";
writeOpeningNamespace(ccfile, ns_components);
vector<string> idents = sortedIdentifiers(dictionary);
- for (vector<string>::const_iterator j = idents.begin();
- j != idents.end(); ++j) {
- ccfile << "extern const isc::log::MessageID " << *j <<
- " = \"" << *j << "\";\n";
+ for (auto const& j : idents) {
+ ccfile << "extern const isc::log::MessageID " << j <<
+ " = \"" << j << "\";\n";
}
ccfile << "\n";
// Output the identifiers and the associated text.
idents = sortedIdentifiers(dictionary);
- for (vector<string>::const_iterator i = idents.begin();
- i != idents.end(); ++i) {
- ccfile << " \"" << *i << "\", \"" <<
- quoteString(dictionary.getText(*i)) << "\",\n";
+ for (auto const& i : idents) {
+ ccfile << " \"" << i << "\", \"" << quoteString(dictionary.getText(i)) << "\",\n";
}
// ... and the postamble
sort(duplicates.begin(), duplicates.end());
MessageReader::MessageIDCollection::iterator new_end =
unique(duplicates.begin(), duplicates.end());
- for (MessageReader::MessageIDCollection::iterator i = duplicates.begin();
- i != new_end; ++i) {
- cout << " " << *i << "\n";
+ duplicates.erase(new_end, duplicates.end());
+ for (auto const& i : duplicates) {
+ cout << " " << i << "\n";
}
exit(1);
}
// There are duplicates present. This list itself may contain
// duplicates; if so, the message ID is listed as many times as
// there are duplicates.
- for (list<string>::const_iterator i = duplicates.begin();
- i != duplicates.end(); ++i) {
- LOG_WARN(logger, LOG_DUPLICATE_MESSAGE_ID).arg(*i);
+ for (auto const& i : duplicates) {
+ LOG_WARN(logger, LOG_DUPLICATE_MESSAGE_ID).arg(i);
}
MessageInitializer::clearDuplicates();
}
void LoggerManagerImpl::storeBufferAppenders() {
// Walk through all loggers, and find any buffer appenders there
log4cplus::LoggerList loggers = log4cplus::Logger::getCurrentLoggers();
- log4cplus::LoggerList::iterator it;
- for (it = loggers.begin(); it != loggers.end(); ++it) {
- log4cplus::SharedAppenderPtr buffer_appender =
- it->getAppender("buffer");
+ for (auto& it : loggers) {
+ log4cplus::SharedAppenderPtr buffer_appender = it.getAppender("buffer");
if (buffer_appender) {
buffer_appender_store_.push_back(buffer_appender);
}
std::vector<log4cplus::SharedAppenderPtr> copy;
buffer_appender_store_.swap(copy);
- std::vector<log4cplus::SharedAppenderPtr>::iterator it;
- for (it = copy.begin(); it != copy.end(); ++it) {
- internal::BufferAppender* app =
- dynamic_cast<internal::BufferAppender*>(it->get());
+ for (auto const& it : copy) {
+ internal::BufferAppender* app = dynamic_cast<internal::BufferAppender*>(it.get());
isc_throw_assert(app);
app->flush();
}
const MessageDictionaryPtr& global = MessageDictionary::globalDictionary();
const LoggerValuesListPtr& logger_values = getNonConstLoggerValues();
- for (LoggerValuesList::const_iterator values = logger_values->begin();
- values != logger_values->end(); ++values) {
- std::vector<std::string> repeats = global->load(*values);
+ for (auto const& values : *logger_values) {
+ std::vector<std::string> repeats = global->load(values);
// Append the IDs in the list just loaded (the "repeats") to the
// global list of duplicate IDs.
#include <database/server_selector.h>
#include <process/config_base.h>
#include <process/config_ctl_info.h>
+#include <boost/foreach.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <process/d_log.h>
db::AuditEntryCollection result;
auto const& index = audit_entries.get<db::AuditEntryObjectTypeTag>();
auto range = index.equal_range(object_type);
- for (auto it = range.first; it != range.second; ++it) {
- if ((*it)->getModificationType() != db::AuditEntry::ModificationType::DELETE) {
- result.insert(*it);
+ BOOST_FOREACH(auto const& it, range) {
+ if (it->getModificationType() != db::AuditEntry::ModificationType::DELETE) {
+ result.insert(it);
}
}
ConfigBase::copy(ConfigBase& other) const {
// We will entirely replace loggers in the new configuration.
other.logging_info_.clear();
- for (LoggingInfoStorage::const_iterator it = logging_info_.begin();
- it != logging_info_.end(); ++it) {
- other.addLoggingInfo(*it);
+ for (auto const& it : logging_info_) {
+ other.addLoggingInfo(it);
}
// Clone the config control info
const ConfigDbInfo&
ConfigControlInfo::findConfigDb(const std::string& param_name,
const std::string& param_value) {
- for (ConfigDbInfoList::iterator db = db_infos_.begin();
- db != db_infos_.end(); ++db) {
+ for (auto const& db : db_infos_) {
std::string db_value;
- if (db->getParameterValue(param_name, db_value) &&
- (param_value == db_value)) {
- return (*db);
- }
+ if (db.getParameterValue(param_name, db_value) && (param_value == db_value)) {
+ return (db);
+ }
}
return (EMPTY_DB());
}
const std::vector<data::ElementPtr>& db_list = elem->listValue();
- for (auto db = db_list.cbegin(); db != db_list.end(); ++db) {
+ for (auto const& db : db_list) {
db::DbAccessParser parser;
std::string access_string;
- parser.parse(access_string, *db);
+ parser.parse(access_string, db);
/// @todo do we still need access_string for this at all?
/// can't we just use params directly and get rid of the
/// string now that DatabaseConnection::toElement(map) exists?
#include <util/encode/hex.h>
#include <util/strutil.h>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <config.h>
#include <cc/data.h>
#include <process/log_parser.h>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <log/logger_specification.h>
#include <log/logger_support.h>
verbose_ = verbose;
// Iterate over all entries in "Server/loggers" list
- BOOST_FOREACH(ConstElementPtr logger, loggers->listValue()) {
+ for (auto const& logger : loggers->listValue()) {
parseConfigEntry(logger);
}
}
isc_throw(BadValue, "Missing 'output-options' structure in 'loggers'");
}
- BOOST_FOREACH(ConstElementPtr output_option, output_options->listValue()) {
+ for (auto const& output_option : output_options->listValue()) {
LoggingDestination dest;
// that they are at the same index of the vectors.
for (auto const& dest : destinations_) {
bool match = false;
- for (auto const &dest_other : other.destinations_) {
+ for (auto const& dest_other : other.destinations_) {
if (dest.equals(dest_other)) {
match = true;
break;
#include <process/d_cfg_mgr.h>
#include <process/redact_config.h>
-#include <boost/foreach.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <gtest/gtest.h>
// Iteration over all elements in the list
// and adding alternately value and timestamp to the entry
- for (std::list<IntegerSample>::iterator it = s.begin(); it != s.end(); ++it) {
+ for (auto const& it : s) {
entry = isc::data::Element::createList();
- value = isc::data::Element::create(static_cast<int64_t>((*it).first));
- timestamp = isc::data::Element::create(isc::util::clockToText((*it).second));
+ value = isc::data::Element::create(static_cast<int64_t>(it.first));
+ timestamp = isc::data::Element::create(isc::util::clockToText(it.second));
entry->add(value);
entry->add(timestamp);
// Iteration over all elements in the list
// and adding alternately value and timestamp to the entry
- for (std::list<FloatSample>::iterator it = s.begin(); it != s.end(); ++it) {
+ for (auto const& it : s) {
entry = isc::data::Element::createList();
- value = isc::data::Element::create((*it).first);
- timestamp = isc::data::Element::create(isc::util::clockToText((*it).second));
+ value = isc::data::Element::create(it.first);
+ timestamp = isc::data::Element::create(isc::util::clockToText(it.second));
entry->add(value);
entry->add(timestamp);
// Iteration over all elements in the list
// and adding alternately value and timestamp to the entry
- for (std::list<DurationSample>::iterator it = s.begin(); it != s.end(); ++it) {
+ for (auto const& it : s) {
entry = isc::data::Element::createList();
- value = isc::data::Element::create(isc::util::durationToText((*it).first));
- timestamp = isc::data::Element::create(isc::util::clockToText((*it).second));
+ value = isc::data::Element::create(isc::util::durationToText(it.first));
+ timestamp = isc::data::Element::create(isc::util::clockToText(it.second));
entry->add(value);
entry->add(timestamp);
// Iteration over all elements in the list
// and adding alternately value and timestamp to the entry
- for (std::list<StringSample>::iterator it = s.begin(); it != s.end(); ++it) {
+ for (auto const& it : s) {
entry = isc::data::Element::createList();
- value = isc::data::Element::create((*it).first);
- timestamp = isc::data::Element::create(isc::util::clockToText((*it).second));
+ value = isc::data::Element::create(it.first);
+ timestamp = isc::data::Element::create(isc::util::clockToText(it.second));
entry->add(value);
entry->add(timestamp);
std::list<BigIntegerSample> samples_bigint = e.getBigIntegers(); // List of all big integer samples
uint32_t i = 2; // Index pointed to the end of array of samples
- for (std::list<IntegerSample>::iterator it = samples_int.begin(); it != samples_int.end(); ++it) {
- EXPECT_EQ(int_samples[i], static_cast<int64_t>((*it).first));
+ for (auto const& it : samples_int) {
+ EXPECT_EQ(int_samples[i], static_cast<int64_t>(it.first));
--i;
}
i = 2;
- for (std::list<FloatSample>::iterator it = samples_float.begin(); it != samples_float.end(); ++it) {
- EXPECT_EQ(float_samples[i], (*it).first);
+ for (auto const& it : samples_float) {
+ EXPECT_EQ(float_samples[i], it.first);
--i;
}
i = 2;
- for (std::list<DurationSample>::iterator it = samples_dur.begin(); it != samples_dur.end(); ++it) {
- EXPECT_EQ(duration_samples[i], (*it).first);
+ for (auto const& it : samples_dur) {
+ EXPECT_EQ(duration_samples[i], it.first);
--i;
}
i = 2;
- for (std::list<StringSample>::iterator it = samples_str.begin(); it != samples_str.end(); ++it) {
- EXPECT_EQ(string_samples[i], (*it).first);
+ for (auto const& it : samples_str) {
+ EXPECT_EQ(string_samples[i], it.first);
--i;
}
i = 2;
- for (BigIntegerSample const& sample : samples_bigint) {
+ for (auto const& sample : samples_bigint) {
EXPECT_EQ(bigint_samples[i], sample.first);
--i;
}
// And whether stored values are correct
uint32_t i = 20; // index of the last element in array of test's samples
- for (std::list<IntegerSample>::iterator it = samples_int.begin(); it != samples_int.end(); ++it) {
- EXPECT_EQ((*it).first, int_samples[i]);
+ for (auto const& it : samples_int) {
+ EXPECT_EQ(it.first, int_samples[i]);
--i;
}
i = 20; // index of last element in array of test's samples
- for (std::list<FloatSample>::iterator it = samples_float.begin(); it != samples_float.end(); ++it) {
- EXPECT_EQ((*it).first, float_samples[i]);
+ for (auto const& it : samples_float) {
+ EXPECT_EQ(it.first, float_samples[i]);
--i;
}
i = 20; // index of last element in array of test's samples
- for (std::list<DurationSample>::iterator it = samples_duration.begin(); it != samples_duration.end(); ++it) {
- EXPECT_EQ((*it).first, duration_samples[i]);
+ for (auto const& it : samples_duration) {
+ EXPECT_EQ(it.first, duration_samples[i]);
--i;
}
i = 20; // index of last element in array of test's samples
- for (std::list<StringSample>::iterator it = samples_string.begin(); it != samples_string.end(); ++it) {
- EXPECT_EQ((*it).first, string_samples[i]);
+ for (auto const& it : samples_string) {
+ EXPECT_EQ(it.first, string_samples[i]);
--i;
}
i = 20; // index of last element in array of test's samples
- for (BigIntegerSample const& sample : samples_bigint) {
+ for (auto const& sample : samples_bigint) {
EXPECT_EQ(sample.first, int_samples[i]);
--i;
}
// And whether storages contain only the 10 newest values
i = 20; // index of last element in array of test's samples
- for (std::list<IntegerSample>::iterator it = samples_int.begin(); it != samples_int.end(); ++it) {
- EXPECT_EQ((*it).first, int_samples[i]);
+ for (auto const& it : samples_int) {
+ EXPECT_EQ(it.first, int_samples[i]);
--i;
}
i = 20; // index of last element in array of test's samples
- for (std::list<FloatSample>::iterator it = samples_float.begin(); it != samples_float.end(); ++it) {
- EXPECT_EQ((*it).first, float_samples[i]);
+ for (auto const& it : samples_float) {
+ EXPECT_EQ(it.first, float_samples[i]);
--i;
}
i = 20; // index of last element in array of test's samples
- for (std::list<DurationSample>::iterator it = samples_duration.begin(); it != samples_duration.end(); ++it) {
- EXPECT_EQ((*it).first, duration_samples[i]);
+ for (auto const& it : samples_duration) {
+ EXPECT_EQ(it.first, duration_samples[i]);
--i;
}
i = 20; // index of last element in array of test's samples
- for (std::list<StringSample>::iterator it = samples_string.begin(); it != samples_string.end(); ++it) {
- EXPECT_EQ((*it).first, string_samples[i]);
+ for (auto const& it : samples_string) {
+ EXPECT_EQ(it.first, string_samples[i]);
--i;
}
i = 20; // index of last element in array of test's samples
- for (BigIntegerSample const& sample : samples_bigint) {
+ for (auto const& sample : samples_bigint) {
EXPECT_EQ(sample.first, int_samples[i]);
--i;
}
ASSERT_EQ(e.getSize(), 11);
i = 21; // index of last element in array of test's samples
- for (std::list<IntegerSample>::iterator it = samples_int.begin(); it != samples_int.end(); ++it) {
- EXPECT_EQ((*it).first, int_samples[i]);
+ for (auto const& it : samples_int) {
+ EXPECT_EQ(it.first, int_samples[i]);
--i;
}
i = 21; // index of last element in array of test's samples
- for (std::list<FloatSample>::iterator it = samples_float.begin(); it != samples_float.end(); ++it) {
- EXPECT_EQ((*it).first, float_samples[i]);
+ for (auto const& it : samples_float) {
+ EXPECT_EQ(it.first, float_samples[i]);
--i;
}
i = 21; // index of last element in array of test's samples
- for (std::list<DurationSample>::iterator it = samples_duration.begin(); it != samples_duration.end(); ++it) {
- EXPECT_EQ((*it).first, duration_samples[i]);
+ for (auto const& it : samples_duration) {
+ EXPECT_EQ(it.first, duration_samples[i]);
--i;
}
i = 21; // index of last element in array of test's samples
- for (std::list<StringSample>::iterator it = samples_string.begin(); it != samples_string.end(); ++it) {
- EXPECT_EQ((*it).first, string_samples[i]);
+ for (auto const& it : samples_string) {
+ EXPECT_EQ(it.first, string_samples[i]);
--i;
}
i = 21; // index of last element in array of test's samples
- for (BigIntegerSample const& sample : samples_bigint) {
+ for (auto const& sample : samples_bigint) {
EXPECT_EQ(sample.first, int_samples[i]);
--i;
}
// and whether it contains expected values
uint32_t i = 9;
- for (std::list<DurationSample>::iterator it = samples_duration.begin(); it != samples_duration.end(); ++it) {
- EXPECT_EQ((*it).first, milliseconds(i));
+ for (auto const& it : samples_duration) {
+ EXPECT_EQ(it.first, milliseconds(i));
--i;
}
}
void
TcpConnectionPool::stopAllInternal() {
- for (auto connection = connections_.begin();
- connection != connections_.end();
- ++connection) {
- (*connection)->close();
+ for (auto const& connection : connections_) {
+ connection->close();
}
size_t cnt = connections_.size();
ElementPtr result = ElementPtr(new ListElement());
typedef std::vector<ElementPtr> ListType;
const ListType& list = element->listValue();
- for (ListType::const_iterator it = list.cbegin();
- it != list.cend(); ++it) {
- Value<ElementPtr> item = moveComments1(*it);
+ for (auto const& it : list) {
+ Value<ElementPtr> item = moveComments1(it);
result->add(item.get());
if (!item.isShared()) {
modified = true;
bool has_comment = false;
typedef std::map<std::string, ConstElementPtr> map_type;
const map_type& map = element->mapValue();
- for (map_type::const_iterator it = map.cbegin(); it != map.cend(); ++it) {
- if (it->first == "comment") {
+ for (auto const& it : map) {
+ if (it.first == "comment") {
// Note there is a comment entry to move
has_comment = true;
- } else if (it->first == "user-context") {
+ } else if (it.first == "user-context") {
// Do not traverse user-context entries
- result->set("user-context", it->second);
+ result->set("user-context", it.second);
} else {
// Not comment or user-context
- Value<ConstElementPtr> item = moveComments1(it->second);
- result->set(it->first, item.get());
+ Value<ConstElementPtr> item = moveComments1(it.second);
+ result->set(it.first, item.get());
if (!item.isShared()) {
modified = true;
}
#include <util/multi_threading_mgr.h>
+#include <boost/range/adaptor/reversed.hpp>
+
namespace isc {
namespace util {
MultiThreadingMgr::callEntryCallbacks() {
if (getMode()) {
auto const& callbacks = cs_callbacks_.getCallbackSets();
- for (auto cb_it = callbacks.begin(); cb_it != callbacks.end(); cb_it++) {
+ for (auto const& cb_it : callbacks) {
try {
- (cb_it->entry_cb_)();
+ (cb_it.entry_cb_)();
} catch (...) {
// We can't log it and throwing could be chaos.
// We'll swallow it and tell people their callbacks
MultiThreadingMgr::callExitCallbacks() {
if (getMode()) {
auto const& callbacks = cs_callbacks_.getCallbackSets();
- for (auto cb_it = callbacks.rbegin(); cb_it != callbacks.rend(); cb_it++) {
+ for (auto const& cb_it : boost::adaptors::reverse(callbacks)) {
try {
- (cb_it->exit_cb_)();
+ (cb_it.exit_cb_)();
} catch (...) {
// We can't log it and throwing could be chaos.
// We'll swallow it and tell people their callbacks
string token;
bool in_token = false;
bool escaped = false;
- for (auto c = text.cbegin(); c != text.cend(); ++c) {
- if (delim.find(*c) != string::npos) {
+ for (auto const& c : text) {
+ if (delim.find(c) != string::npos) {
// Current character is a delimiter
if (!in_token) {
// Two or more delimiters, eat them
} else if (escaped) {
// Escaped delimiter in a token: reset escaped and keep it
escaped = false;
- token.push_back(*c);
+ token.push_back(c);
} else {
// End of the current token: save it if not empty
if (!token.empty()) {
in_token = false;
token.clear();
}
- } else if (escape && (*c == '\\')) {
+ } else if (escape && (c == '\\')) {
// Current character is the escape character
if (!in_token) {
// The escape character is the first character of a new token
if (escaped) {
// Escaped escape: reset escaped and keep one character
escaped = false;
- token.push_back(*c);
+ token.push_back(c);
} else {
// Remember to keep the next character
escaped = true;
// Escaped common character: as escape was false
escaped = false;
token.push_back('\\');
- token.push_back(*c);
+ token.push_back(c);
} else {
// The common case: keep it
- token.push_back(*c);
+ token.push_back(c);
}
}
}
template<typename Iterator>
Iterator
seekTrimmed(Iterator begin, Iterator end, uint8_t trim_val) {
- for ( ; end != begin && *(end - 1) == trim_val; --end);
- return(end);
+ for (; end != begin && *(end - 1) == trim_val; --end);
+ return (end);
}
/// @brief Split String into Tokens
}
TEST_F(Base32HexTest, decode) {
- for (vector<StringPair>::const_iterator it = test_sequence.begin();
- it != test_sequence.end();
- ++it) {
- decodeCheck((*it).second, decoded_data, (*it).first);
+ for (auto const& it : test_sequence) {
+ decodeCheck(it.second, decoded_data, it.first);
}
// whitespace should be allowed
}
TEST_F(Base32HexTest, decodeLower) {
- for (vector<StringPair>::const_iterator it = test_sequence_lower.begin();
- it != test_sequence_lower.end();
- ++it) {
- decodeCheck((*it).second, decoded_data, (*it).first);
+ for (auto const& it : test_sequence_lower) {
+ decodeCheck(it.second, decoded_data, it.first);
}
}
TEST_F(Base32HexTest, encode) {
- for (vector<StringPair>::const_iterator it = test_sequence.begin();
- it != test_sequence.end();
- ++it) {
- decoded_data.assign((*it).first.begin(), (*it).first.end());
- EXPECT_EQ((*it).second, encodeBase32Hex(decoded_data));
+ for (auto const& it : test_sequence) {
+ decoded_data.assign(it.first.begin(), it.first.end());
+ EXPECT_EQ(it.second, encodeBase32Hex(decoded_data));
}
}
}
TEST_F(Base64Test, decode) {
- for (vector<StringPair>::const_iterator it = test_sequence.begin();
- it != test_sequence.end();
- ++it) {
- decodeCheck((*it).second, decoded_data, (*it).first);
+ for (auto const& it : test_sequence) {
+ decodeCheck(it.second, decoded_data, it.first);
}
// whitespace should be allowed
}
TEST_F(Base64Test, encode) {
- for (vector<StringPair>::const_iterator it = test_sequence.begin();
- it != test_sequence.end();
- ++it) {
- decoded_data.assign((*it).first.begin(), (*it).first.end());
- EXPECT_EQ((*it).second, encodeBase64(decoded_data));
+ for (auto const& it : test_sequence) {
+ decoded_data.assign(it.first.begin(), it.first.end());
+ EXPECT_EQ(it.second, encodeBase64(decoded_data));
}
}
}
void
openTestData(const char* const datafile, ifstream& ifs) {
- for (vector<string>::const_iterator it = getDataPaths().begin();
- it != getDataPaths().end(); ++it) {
- string data_path = *it;
+ for (auto const& it : getDataPaths()) {
+ string data_path = it;
if (data_path.empty() || *data_path.rbegin() != '/') {
data_path.push_back('/');
}
stringstream tmp;
tmp << hex;
bool delim = false;
- for (vector<uint8_t>::const_iterator it = binary.begin();
- it != binary.end(); ++it) {
+ for (auto const& it : binary) {
if (delim) {
tmp << ":";
}
- tmp << setw(2) << setfill('0') << static_cast<unsigned int>(*it);
+ tmp << setw(2) << setfill('0') << static_cast<unsigned int>(it);
delim = true;
}
host->set("flex-id", Element::create(tmp.str()));
"vivso.json",
//"with-ddns.json",
};
- for (const string& file : examples) {
+ for (auto const& file : examples) {
resetSession();
string path = string(CFG_EXAMPLES) + "/kea4/" + file;
SCOPED_TRACE("\n* Tested file: " + path);
"tee-times.json",
//"with-ddns.json",
};
- for (const string& file : examples) {
+ for (auto const& file : examples) {
resetSession();
string path = string(CFG_EXAMPLES) + "/kea6/" + file;
SCOPED_TRACE("\n* Tested file: " + path);