#include <database/dbaccess_parser.h>
#include <database/backend_selector.h>
#include <database/server_selector.h>
-#include <dhcp/libdhcp++.h>
-#include <dhcp/option_definition.h>
#include <dhcp4/dhcp4_log.h>
#include <dhcp4/dhcp4_srv.h>
#include <dhcp4/json_config_parser.h>
+#include <dhcp/libdhcp++.h>
+#include <dhcp/option_definition.h>
#include <dhcpsrv/cb_ctl_dhcp4.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/config_backend_dhcp4_mgr.h>
#include <dhcpsrv/db_type.h>
-#include <dhcpsrv/host_data_source_factory.h>
#include <dhcpsrv/parsers/client_class_def_parser.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <dhcpsrv/parsers/expiration_config_parser.h>
#include <dhcpsrv/parsers/simple_parser4.h>
#include <dhcpsrv/parsers/shared_networks_list_parser.h>
#include <dhcpsrv/parsers/sanity_checks_parser.h>
+#include <dhcpsrv/host_data_source_factory.h>
#include <dhcpsrv/timer_mgr.h>
#include <process/config_ctl_parser.h>
#include <hooks/hooks_parser.h>
#include <util/encode/hex.h>
#include <util/strutil.h>
-#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string.hpp>
-#include <iostream>
#include <limits>
-#include <map>
+#include <iostream>
+#include <iomanip>
#include <netinet/in.h>
#include <vector>
+#include <map>
using namespace std;
using namespace isc;
-using namespace isc::data;
using namespace isc::dhcp;
+using namespace isc::data;
using namespace isc::asiolink;
using namespace isc::hooks;
using namespace isc::process;
// have to be restored to global storages.
bool rollback = false;
// config_pair holds the details of the current parser when iterating over
- // the parsers. It is declared outside the loop so in case of error, the
- // name of the failing parser can be retrieved within the "catch" clause.
+ // the parsers. It is declared outside the loops so in case of an error,
+ // the name of the failing parser can be retrieved in the "catch" clause.
ConfigPair config_pair;
ElementPtr mutable_cfg;
SrvConfigPtr srv_cfg;
try {
- // Get the staging configuration.
+ // Get the staging configuration
srv_cfg = CfgMgr::instance().getStagingCfg();
// This is a way to convert ConstElementPtr to ElementPtr.
catch (const isc::Exception& ex) {
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what());
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
- // An error occurred, so make sure to restore the original data.
rollback = true;
} catch (...) {
// For things like bad_cast in boost::lexical_cast
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_EXCEPTION);
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, "undefined configuration"
" parsing error");
- // An error occurred, so make sure to restore the original data.
rollback = true;
}
}
err << "during update from config backend database: " << ex.what();
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(err.str());
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str());
- // An error occurred, so make sure to restore the original data.
rollback = true;
} catch (...) {
// For things like bad_cast in boost::lexical_cast
<< "undefined configuration parsing error";
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(err.str());
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str());
- // An error occurred, so make sure to restore the original data.
rollback = true;
}
}
#include <config.h>
-#include <cc/data.h>
#include <dhcpsrv/parsers/simple_parser4.h>
-
+#include <cc/data.h>
#include <boost/foreach.hpp>
+#include <iostream>
using namespace isc::data;
/// @brief This table defines default values for each IPv4 subnet that is
/// part of a shared network
///
-/// This is mostly the same as @ref SUBNET4_DEFAULTS, except the parameters
+/// This is mostly the same as @ref SUBNET4_DEFAULTS, except two parameters
/// that can be derived from shared-network, but cannot from global scope.
/// Those are: interface and reservation-mode.
const SimpleDefaults SimpleParser4::SHARED_SUBNET4_DEFAULTS = {
{ "4o6-subnet", Element::string, "" },
};
-/// @brief List of parameters that can be inherited from the global to subnet4 scope.
+/// @brief List of parameters that can be inherited to subnet4 scope.
///
/// Some parameters may be defined on both global (directly in Dhcp4) and
/// subnet (Dhcp4/subnet4/...) scope. If not defined in the subnet scope,
// Set global defaults first.
cnt = setDefaults(global, GLOBAL4_DEFAULTS);
- // Now set the defaults for each specified option definition
+ // Now set option definition defaults for each specified option definition
ConstElementPtr option_defs = global->get("option-def");
if (option_defs) {
- cnt += setListDefaults(option_defs, OPTION4_DEF_DEFAULTS);
+ BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) {
+ cnt += SimpleParser::setDefaults(option_def, OPTION4_DEF_DEFAULTS);
+ }
}
// Set the defaults for option data
}
}
- // Set the defaults for dhcp-queue-control. If the element isn't there
- // we'll add it.
+ // Set the defaults for dhcp-queue-control. If the element isn't
+ // there we'll add it.
ConstElementPtr queue_control = global->get("dhcp-queue-control");
ElementPtr mutable_cfg;
if (queue_control) {
// Now set the defaults for each specified option definition
ConstElementPtr option_defs = global->get("option-def");
if (option_defs) {
- cnt += setListDefaults(option_defs, OPTION6_DEF_DEFAULTS);
+ BOOST_FOREACH(ElementPtr 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) {
- cnt += setListDefaults(options, OPTION6_DEFAULTS);
+ BOOST_FOREACH(ElementPtr single_option, options->listValue()) {
+ cnt += SimpleParser::setDefaults(single_option, OPTION6_DEFAULTS);
+ }
}
// Now set the defaults for defined subnets