26 SrvConfig::SrvConfig()
27 : sequence_(0), cfg_iface_(new
CfgIface()),
38 decline_timer_(0), echo_v4_client_id_(true), dhcp4o6_port_(0),
40 configured_globals_(
Element::createMap()),
46 : sequence_(sequence), cfg_iface_(new
CfgIface()),
57 decline_timer_(0), echo_v4_client_id_(true), dhcp4o6_port_(0),
59 configured_globals_(
Element::createMap()),
70 if (subnets_num > 0) {
71 s <<
"added IPv4 subnets: " << subnets_num;
73 s <<
"no IPv4 subnets!";
80 if (subnets_num > 0) {
81 s <<
"added IPv6 subnets: " << subnets_num;
83 s <<
"no IPv6 subnets!";
90 s <<
"DDNS: " << (ddns_enabled ?
"enabled" :
"disabled") <<
"; ";
93 if (s.tellp() ==
static_cast<std::streampos
>(0)) {
94 s <<
"no config details available";
97 std::string summary = s.str();
98 size_t last_separator_pos = summary.find_last_of(
";");
99 if (last_separator_pos == summary.length() - 2) {
100 summary.erase(last_separator_pos);
115 new_config.cfg_iface_.reset(
new CfgIface(*cfg_iface_));
117 cfg_option_def_->copyTo(*new_config.cfg_option_def_);
118 cfg_option_->copyTo(*new_config.cfg_option_);
124 new_config.hooks_config_.
clear();
126 for (HookLibsCollection::const_iterator it =
127 hooks_config_.get().begin();
128 it != hooks_config_.get().end(); ++it) {
129 new_config.hooks_config_.
add(it->first, it->second);
137 if (!ConfigBase::equals(other)) {
142 if ((*cfg_iface_ != *other.cfg_iface_) ||
143 (*cfg_option_def_ != *other.cfg_option_def_) ||
144 (*cfg_option_ != *other.cfg_option_) ||
145 (*class_dictionary_ != *other.class_dictionary_) ||
146 (*d2_client_config_ != *other.d2_client_config_)) {
152 if (hooks_config_.
get().size() != other.hooks_config_.
get().size()) {
156 return (hooks_config_.
equal(other.hooks_config_));
185 if (config->getType() != Element::map) {
189 const std::map<std::string, ConstElementPtr>& values = config->mapValue();
190 for (
auto value = values.begin(); value != values.end(); ++value) {
191 if (value->second->getType() != Element::list &&
192 value->second->getType() != Element::map) {
209 dhcp->setValue(configured_globals_->mapValue());
215 dhcp->set(
"decline-probation-period",
216 Element::create(
static_cast<long long>(decline_timer_)));
218 if (family == AF_INET) {
219 dhcp->set(
"echo-client-id", Element::create(echo_v4_client_id_));
222 dhcp->set(
"dhcp4o6-port",
223 Element::create(
static_cast<int>(dhcp4o6_port_)));
226 dhcp->set(
"dhcp-ddns", d2_client_config_->toElement());
228 dhcp->set(
"interfaces-config", cfg_iface_->toElement());
230 dhcp->set(
"option-def", cfg_option_def_->toElement());
232 dhcp->set(
"option-data", cfg_option_->toElement());
245 std::vector<ElementPtr> sn_list;
247 if (family == AF_INET) {
249 ElementPtr plain_subnets = Element::createList();
251 for (Subnet4Collection::const_iterator subnet = subnets->cbegin();
252 subnet != subnets->cend(); ++subnet) {
255 (*subnet)->getSharedNetwork(network);
259 ElementPtr subnet_cfg = (*subnet)->toElement();
260 sn_list.push_back(subnet_cfg);
261 plain_subnets->add(subnet_cfg);
263 dhcp->set(
"subnet4", plain_subnets);
266 ElementPtr shared_networks = cfg_shared_networks4_->toElement();
267 dhcp->set(
"shared-networks", shared_networks);
270 const std::vector<ElementPtr> networks = shared_networks->listValue();
271 for (
auto network = networks.cbegin();
272 network != networks.cend(); ++network) {
273 const std::vector<ElementPtr> sh_list =
274 (*network)->get(
"subnet4")->listValue();
275 for (
auto subnet = sh_list.cbegin();
276 subnet != sh_list.cend(); ++subnet) {
277 sn_list.push_back(*subnet);
283 ElementPtr plain_subnets = Element::createList();
285 for (Subnet6Collection::const_iterator subnet = subnets->cbegin();
286 subnet != subnets->cend(); ++subnet) {
289 (*subnet)->getSharedNetwork(network);
293 ElementPtr subnet_cfg = (*subnet)->toElement();
294 sn_list.push_back(subnet_cfg);
295 plain_subnets->add(subnet_cfg);
297 dhcp->set(
"subnet6", plain_subnets);
300 ElementPtr shared_networks = cfg_shared_networks6_->toElement();
301 dhcp->set(
"shared-networks", shared_networks);
304 const std::vector<ElementPtr> networks = shared_networks->listValue();
305 for (
auto network = networks.cbegin();
306 network != networks.cend(); ++network) {
307 const std::vector<ElementPtr> sh_list =
308 (*network)->get(
"subnet6")->listValue();
309 for (
auto subnet = sh_list.cbegin();
310 subnet != sh_list.cend(); ++subnet) {
311 sn_list.push_back(*subnet);
322 if (global_resvs->size() > 0) {
323 dhcp->set(
"reservations", global_resvs);
327 for (std::vector<ElementPtr>::const_iterator subnet = sn_list.cbegin();
328 subnet != sn_list.cend(); ++subnet) {
333 SubnetID subnet_id =
id->intValue();
335 (*subnet)->set(
"reservations", resvs);
340 dhcp->set(
"expired-leases-processing", expired);
341 if (family == AF_INET6) {
343 dhcp->set(
"server-id", cfg_duid_->toElement());
346 dhcp->set(
"relay-supplied-options", cfg_rsoo_->toElement());
350 dhcp->set(
"lease-database", lease_db.
toElement());
354 if (hosts_databases->size() > 0) {
355 dhcp->set(
"hosts-databases", hosts_databases);
359 if (family == AF_INET) {
360 host_ids = cfg_host_operations4_->toElement();
362 host_ids = cfg_host_operations6_->toElement();
364 dhcp->set(
"host-reservation-identifiers", host_ids);
366 if (family == AF_INET6) {
367 dhcp->set(
"mac-sources", cfg_mac_source_.
toElement());
370 if (!
isNull(control_socket_)) {
371 dhcp->set(
"control-socket", UserContext::toElement(control_socket_));
376 if (!client_classes->empty()) {
377 dhcp->set(
"client-classes", client_classes);
381 dhcp->set(
"hooks-libraries", hooks_libs);
383 result->set(family == AF_INET ?
"Dhcp4" :
"Dhcp6", dhcp);
386 dhcp->set(
"sanity-checks", cfg_consist);
392 dhcp->set(
"config-control", info_elem);
397 if (dhcp_queue_control) {
398 dhcp->set(
"dhcp-queue-control", dhcp_queue_control);