-/* Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
}
}
+\"hosts-databases\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::Parser4Context::DHCP4:
+ return isc::dhcp::Dhcp4Parser::make_HOSTS_DATABASES(driver.loc_);
+ default:
+ return isc::dhcp::Dhcp4Parser::make_STRING("hosts-databases", driver.loc_);
+ }
+}
+
\"readonly\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::HOSTS_DATABASE:
-/* Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
LEASE_DATABASE "lease-database"
HOSTS_DATABASE "hosts-database"
+ HOSTS_DATABASES "hosts-databases"
TYPE "type"
MEMFILE "memfile"
MYSQL "mysql"
| interfaces_config
| lease_database
| hosts_database
+ | hosts_databases
| host_reservation_identifiers
| client_classes
| option_def_list
ctx.leave();
};
+hosts_databases: HOSTS_DATABASES {
+ ElementPtr l(new ListElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->set("hosts-databases", l);
+ ctx.stack_.push_back(l);
+ ctx.enter(ctx.HOSTS_DATABASE);
+} COLON LSQUARE_BRACKET database_list RSQUARE_BRACKET {
+ ctx.stack_.pop_back();
+ ctx.leave();
+};
+
+database_list: %empty
+ | not_empty_database_list
+ ;
+
+not_empty_database_list: database
+ | not_empty_database_list COMMA database
+ ;
+
+database: LCURLY_BRACKET {
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->add(m);
+ ctx.stack_.push_back(m);
+} database_map_params RCURLY_BRACKET {
+ // The type parameter is required
+ ctx.require("type", ctx.loc2pos(@1), ctx.loc2pos(@4));
+ ctx.stack_.pop_back();
+};
+
database_map_params: database_map_param
| database_map_params COMMA database_map_param
;
-// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
continue;
}
+ // For now only support empty or singleton, ignoring extra entries.
+ if (config_pair.first == "hosts-databases") {
+ if (config_pair.second->size() == 0) {
+ continue;
+ }
+ DbAccessParser parser(DbAccessParser::HOSTS_DB);
+ CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
+ parser.parse(cfg_db_access, config_pair.second->get(0));
+ continue;
+ }
+
if (config_pair.first == "subnet4") {
SrvConfigPtr srv_cfg = CfgMgr::instance().getStagingCfg();
Subnets4ListConfigParser subnets_parser;
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
/// Used while parsing Dhcp4/lease-database structures.
LEASE_DATABASE,
- /// Used while parsing Dhcp4/hosts-database structures.
+ /// Used while parsing Dhcp4/hosts-database[s] structures.
HOSTS_DATABASE,
/// Used while parsing Dhcp4/*-database/type.
-/* Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
}
}
+\"hosts-databases\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::Parser6Context::DHCP6:
+ return isc::dhcp::Dhcp6Parser::make_HOSTS_DATABASES(driver.loc_);
+ default:
+ return isc::dhcp::Dhcp6Parser::make_STRING("hosts-databases", driver.loc_);
+ }
+}
+
\"readonly\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::HOSTS_DATABASE:
-/* Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
LEASE_DATABASE "lease-database"
HOSTS_DATABASE "hosts-database"
+ HOSTS_DATABASES "hosts-databases"
TYPE "type"
MEMFILE "memfile"
MYSQL "mysql"
| interfaces_config
| lease_database
| hosts_database
+ | hosts_databases
| mac_sources
| relay_supplied_options
| host_reservation_identifiers
ctx.leave();
};
+hosts_databases: HOSTS_DATABASES {
+ ElementPtr l(new ListElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->set("hosts-databases", l);
+ ctx.stack_.push_back(l);
+ ctx.enter(ctx.HOSTS_DATABASE);
+} COLON LSQUARE_BRACKET database_list RSQUARE_BRACKET {
+ ctx.stack_.pop_back();
+ ctx.leave();
+};
+
+database_list: %empty
+ | not_empty_database_list
+ ;
+
+not_empty_database_list: database
+ | not_empty_database_list COMMA database
+ ;
+
+database: LCURLY_BRACKET {
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->add(m);
+ ctx.stack_.push_back(m);
+} database_map_params RCURLY_BRACKET {
+ // The type parameter is required
+ ctx.require("type", ctx.loc2pos(@1), ctx.loc2pos(@4));
+ ctx.stack_.pop_back();
+};
+
database_map_params: database_map_param
| database_map_params COMMA database_map_param
;
-// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
continue;
}
+ // For now only support empty or singleton, ignoring extra entries.
+ if (config_pair.first == "hosts-databases") {
+ if (config_pair.second->size() == 0) {
+ continue;
+ }
+ DbAccessParser parser(DbAccessParser::HOSTS_DB);
+ CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
+ parser.parse(cfg_db_access, config_pair.second->get(0));
+ continue;
+ }
+
if (config_pair.first == "subnet6") {
Subnets6ListConfigParser subnets_parser;
// parse() returns number of subnets parsed. We may log it one day.
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
/// Used while parsing Dhcp6/lease-database structures.
LEASE_DATABASE,
- /// Used while parsing Dhcp6/hosts-database structures.
+ /// Used while parsing Dhcp6/hosts-database[s] structures.
HOSTS_DATABASE,
/// Used while parsing Dhcp6/*-database/type.
HostMgr::get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
const DuidPtr& duid) const {
ConstHostPtr host = getCfgHosts()->get4(subnet_id, hwaddr, duid);
+ if (host || alternate_sources_.empty()) {
+ return (host);
+ }
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
+ HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_HWADDR_DUID)
+ .arg(subnet_id)
+ .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)")
+ .arg(duid ? duid->toText() : "(duid)");
for (auto it = alternate_sources_.begin();
- it != alternate_sources_.end(); ++it) {
- if (host) {
- break;
- }
- LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
- HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_HWADDR_DUID)
- .arg(subnet_id)
- .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)")
- .arg(duid ? duid->toText() : "(duid)");
+ !host && it != alternate_sources_.end(); ++it) {
if (duid) {
host = (*it)->get4(subnet_id, HWAddrPtr(), duid);
}
const size_t identifier_len) const {
ConstHostPtr host = getCfgHosts()->get4(subnet_id, identifier_type,
identifier_begin, identifier_len);
+ if (host || alternate_sources_.empty()) {
+ return (host);
+ }
+
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
+ HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER)
+ .arg(subnet_id)
+ .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
+ identifier_len));
+
for (auto it = alternate_sources_.begin();
it != alternate_sources_.end(); ++it) {
- if (host) {
- break;
- }
- LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
- HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER)
- .arg(subnet_id)
- .arg(Host::getIdentifierAsText(identifier_type,
- identifier_begin,
- identifier_len));
-
host = (*it)->get4(subnet_id, identifier_type,
identifier_begin, identifier_len);
.arg(Host::getIdentifierAsText(identifier_type,
identifier_begin,
identifier_len))
+ .arg((*it)->getType())
.arg(host->toText());
- break;
+
+ return (host);
}
- LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS,
- HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER_NULL)
- .arg(subnet_id)
- .arg(Host::getIdentifierAsText(identifier_type,
- identifier_begin,
- identifier_len));
}
-
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS,
+ HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER_NULL)
+ .arg(subnet_id)
+ .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
+ identifier_len));
return (host);
}
HostMgr::get4(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const {
ConstHostPtr host = getCfgHosts()->get4(subnet_id, address);
+ if (host || alternate_sources_.empty()) {
+ return (host);
+ }
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
+ HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4)
+ .arg(subnet_id)
+ .arg(address.toText());
for (auto it = alternate_sources_.begin();
- it != alternate_sources_.end(); ++it) {
- if (host) {
- break;
- }
- LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
- HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4)
- .arg(subnet_id)
- .arg(address.toText());
+ !host && it != alternate_sources_.end(); ++it) {
host = (*it)->get4(subnet_id, address);
}
return (host);
HostMgr::get6(const SubnetID& subnet_id, const DuidPtr& duid,
const HWAddrPtr& hwaddr) const {
ConstHostPtr host = getCfgHosts()->get6(subnet_id, duid, hwaddr);
+ if (host || alternate_sources_.empty()) {
+ return (host);
+ }
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
+ HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_DUID_HWADDR)
+ .arg(subnet_id)
+ .arg(duid ? duid->toText() : "(duid)")
+ .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)");
+
for (auto it = alternate_sources_.begin();
- it != alternate_sources_.end(); ++it) {
- if (host) {
- break;
- }
- LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
- HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_DUID_HWADDR)
- .arg(subnet_id)
- .arg(duid ? duid->toText() : "(duid)")
- .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)");
+ !host && it != alternate_sources_.end(); ++it) {
if (duid) {
host = (*it)->get6(subnet_id, duid, HWAddrPtr());
}
ConstHostPtr
HostMgr::get6(const IOAddress& prefix, const uint8_t prefix_len) const {
ConstHostPtr host = getCfgHosts()->get6(prefix, prefix_len);
+ if (host || alternate_sources_.empty()) {
+ return (host);
+ }
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
+ HOSTS_MGR_ALTERNATE_GET6_PREFIX)
+ .arg(prefix.toText())
+ .arg(static_cast<int>(prefix_len));
for (auto it = alternate_sources_.begin();
- it != alternate_sources_.end(); ++it) {
- if (host) {
- break;
- }
- LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
- HOSTS_MGR_ALTERNATE_GET6_PREFIX)
- .arg(prefix.toText())
- .arg(static_cast<int>(prefix_len));
+ !host && it != alternate_sources_.end(); ++it) {
host = (*it)->get6(prefix, prefix_len);
}
return (host);
const size_t identifier_len) const {
ConstHostPtr host = getCfgHosts()->get6(subnet_id, identifier_type,
identifier_begin, identifier_len);
+ if (host || alternate_sources_.empty()) {
+ return (host);
+ }
+
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
+ HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER)
+ .arg(subnet_id)
+ .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
+ identifier_len));
+
for (auto it = alternate_sources_.begin();
it != alternate_sources_.end(); ++it) {
- if (host) {
- break;
- }
- LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
- HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER)
- .arg(subnet_id)
- .arg(Host::getIdentifierAsText(identifier_type,
- identifier_begin,
- identifier_len));
host = (*it)->get6(subnet_id, identifier_type,
identifier_begin, identifier_len);
.arg(Host::getIdentifierAsText(identifier_type,
identifier_begin,
identifier_len))
+ .arg((*it)->getType())
.arg(host->toText());
- break;
+ return (host);
}
- LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS,
- HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER_NULL)
- .arg(subnet_id)
- .arg(Host::getIdentifierAsText(identifier_type,
- identifier_begin,
- identifier_len));
}
+
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS,
+ HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER_NULL)
+ .arg(subnet_id)
+ .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
+ identifier_len));
+
return (host);
}
HostMgr::get6(const SubnetID& subnet_id,
const asiolink::IOAddress& addr) const {
ConstHostPtr host = getCfgHosts()->get6(subnet_id, addr);
+ if (host || alternate_sources_.empty()) {
+ return (host);
+ }
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
+ HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_ADDRESS6)
+ .arg(subnet_id)
+ .arg(addr.toText());
for (auto it = alternate_sources_.begin();
- it != alternate_sources_.end(); ++it) {
- if (host) {
- break;
- }
- LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
- HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_ADDRESS6)
- .arg(subnet_id)
- .arg(addr.toText());
+ !host && it != alternate_sources_.end(); ++it) {
host = (*it)->get6(subnet_id, addr);
}
return (host);
-# Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
This debug message is issued when no host was found using the specified
subnet id and host identifier.
-% HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4 trying alternate source for host using subnet id %1 and address %2
+% HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4 trying alternate sources for host using subnet id %1 and address %2
This debug message is issued when the Host Manager doesn't find the
host connected to the specific subnet and having the reservation for
the specific IPv4 address, and it is starting to search for this host
-in the alternate host data source.
+in alternate host data sources.
-% HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_HWADDR_DUID trying alternate source for host using subnet id %1, HWADDR %2, DUID%3
+% HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_HWADDR_DUID trying alternate sources for host using subnet id %1, HWADDR %2, DUID%3
This debug message is issued when the Host Manager doesn't find the
host connected to the specific subnet and identified by the HW address
-or DUID, and it is starting to search for this host in the alternate
-host data source.
+or DUID, and it is starting to search for this host in alternate
+host data sources.
% HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER get one host with IPv4 reservation for subnet id %1, identified by %2
This debug message is issued when starting to retrieve a host holding
IPv4 reservation, which is connected to a specific subnet and
is identified by a specific unique identifier.
-% HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER_HOST using subnet id %1 and identifier %2, found host: %3
+% HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER_HOST using subnet id %1 and identifier %2, found in %3 host: %4
This debug message includes the details of a host returned by an
alternate hosts data source using a subnet id and specific host
identifier.
This debug message is issued when no host was found using the specified
subnet id and host identifier.
-% HOSTS_MGR_ALTERNATE_GET6_PREFIX trying alternate source for host using prefix %1/%2
+% HOSTS_MGR_ALTERNATE_GET6_PREFIX trying alternate sources for host using prefix %1/%2
This debug message is issued when the Host Manager doesn't find the
host connected to the specific subnet and having the reservation for
the specified prefix, and it is starting to search for this host in
-the alternate host data source.
+alternate host data sources.
-% HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_ADDRESS6 trying alternate source for host using subnet id %1 and IPv6 address %2
+% HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_ADDRESS6 trying alternate sources for host using subnet id %1 and IPv6 address %2
This debug message is issued when the Host Manager doesn't find the
host connected to the specific subnet and having the reservation for
the specified IPv6 address, and it is starting to search for this
-host in the alternate host data source.
+host in alternate host data sources.
-% HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_DUID_HWADDR trying alternate source for host using subnet id %1, DUID %2, HWADDR %3
+% HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_DUID_HWADDR trying alternate sources for host using subnet id %1, DUID %2, HWADDR %3
This debug message is issued when the Host Manager doesn't find the
host connected to the specific subnet and identified by the specified
-DUID or HW Address, and it is starting to search for this host in the
-alternate host data source.
+DUID or HW Address, and it is starting to search for this host in
+alternate host data sources.
% HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER get one host with IPv6 reservation for subnet id %1, identified by %2
This debug message is issued when starting to retrieve a host holding
IPv4 reservation, which is connected to a specific subnet and
is identified by a specific unique identifier.
-% HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER_HOST using subnet id %1 and identifier %2, found host: %3
+% HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER_HOST using subnet id %1 and identifier %2, found in %3 host: %4
This debug message includes the details of a host returned by an
-alternate hosts data source using a subnet id and specific host
+alternate host data source using a subnet id and specific host
identifier.
% HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER_NULL host not found using subnet id %1 and identifier %2