2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-06 00:45:23 +00:00

[5009] Implemented get6(subnet_id, address) function for SQL backends.

Also removed uint32_t cast operator from IOAddress to remove
ambiguity when calling this new function.
This commit is contained in:
Marcin Siodelski
2016-09-20 09:29:06 +02:00
parent bb34f5f3fe
commit 8cce1aa713
29 changed files with 261 additions and 48 deletions

View File

@@ -1148,6 +1148,7 @@ public:
GET_HOST_SUBID6_DHCPID, // Gets host by IPv6 SubnetID, HW address/DUID
GET_HOST_SUBID_ADDR, // Gets host by IPv4 SubnetID and IPv4 address
GET_HOST_PREFIX, // Gets host by IPv6 prefix
GET_HOST_SUBID6_ADDR, // Gets host by IPv6 SubnetID and IPv6 prefix
GET_VERSION, // Obtain version number
INSERT_HOST, // Insert new host to collection
INSERT_V6_RESRV, // Insert v6 reservation
@@ -1454,6 +1455,32 @@ TaggedStatementArray tagged_statements = { {
"ORDER BY h.host_id, o.option_id, r.reservation_id"
},
// PgSqlHostDataSourceImpl::GET_HOST_SUBID6_ADDR
// Retrieves host information, IPv6 reservations and DHCPv6 options
// associated with a host using IPv6 subnet id and prefix. This query
// returns host information for a single host. However, multiple rows
// are returned due to left joining IPv6 reservations and DHCPv6 options.
// The number of rows returned is multiplication of number of existing
// IPv6 reservations and DHCPv6 options.
{2,
{ OID_INT4, OID_VARCHAR },
"get_host_subid6_addr",
"SELECT h.host_id, h.dhcp_identifier, "
" h.dhcp_identifier_type, h.dhcp4_subnet_id, "
" h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
" h.dhcp4_client_classes, h.dhcp6_client_classes, "
" h.dhcp4_next_server, h.dhcp4_server_hostname, h.dhcp4_boot_file_name, "
" o.option_id, o.code, o.value, o.formatted_value, o.space, "
" o.persistent, "
" r.reservation_id, r.address, r.prefix_len, r.type, "
" r.dhcp6_iaid "
"FROM hosts AS h "
"LEFT JOIN dhcp6_options AS o ON h.host_id = o.host_id "
"LEFT JOIN ipv6_reservations AS r ON h.host_id = r.host_id "
"WHERE h.dhcp6_subnet_id = $1 AND r.address = $2 "
"ORDER BY h.host_id, o.option_id, r.reservation_id"
},
// PgSqlHostDataSourceImpl::GET_VERSION
// Retrieves MySQL schema version.
{0,
@@ -1955,6 +1982,34 @@ PgSqlHostDataSource::get6(const asiolink::IOAddress& prefix,
return (result);
}
ConstHostPtr
PgSqlHostDataSource::get6(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const {
/// @todo: Check that prefix is v6 address, not v4.
// Set up the WHERE clause value
PsqlBindArrayPtr bind_array(new PsqlBindArray());
// Add the subnet id
bind_array->add(subnet_id);
// Add the prefix
bind_array->add(address);
ConstHostCollection collection;
impl_->getHostCollection(PgSqlHostDataSourceImpl::GET_HOST_SUBID6_ADDR,
bind_array, impl_->host_ipv6_exchange_,
collection, true);
// Return single record if present, else clear the host.
ConstHostPtr result;
if (!collection.empty()) {
result = *collection.begin();
}
return (result);
}
// Miscellaneous database methods.
std::string PgSqlHostDataSource::getName() const {