-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2019 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
const uint8_t* identifier_begin,
const size_t identifier_len) const = 0;
+ /// @brief Return all hosts in a DHCPv4 subnet.
+ ///
+ /// This method returns all @c Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of const @c Host objects.
+ virtual ConstHostCollection
+ getAll4(const SubnetID& subnet_id) const = 0;
+
+ /// @brief Return all hosts in a DHCPv6 subnet.
+ ///
+ /// This method returns all @c Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of const @c Host objects.
+ virtual ConstHostCollection
+ getAll6(const SubnetID& subnet_id) const = 0;
+
/// @brief Returns a collection of hosts using the specified IPv4 address.
///
/// This method may return multiple @c Host objects if they are connected
-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2019 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
return (collection);
}
+ConstHostCollection
+CfgHosts::getAll4(const SubnetID& subnet_id) const {
+ // Do not issue logging message here because it will be logged by
+ // the getAllInternal method.
+ ConstHostCollection collection;
+ getAllInternal4<ConstHostCollection>(subnet_id, collection);
+ return (collection);
+}
+
+HostCollection
+CfgHosts::getAll4(const SubnetID& subnet_id) {
+ // Do not issue logging message here because it will be logged by
+ // the getAllInternal method.
+ HostCollection collection;
+ getAllInternal4<HostCollection>(subnet_id, collection);
+ return (collection);
+}
+
+ConstHostCollection
+CfgHosts::getAll6(const SubnetID& subnet_id) const {
+ // Do not issue logging message here because it will be logged by
+ // the getAllInternal method.
+ ConstHostCollection collection;
+ getAllInternal6<ConstHostCollection>(subnet_id, collection);
+ return (collection);
+}
+
+HostCollection
+CfgHosts::getAll6(const SubnetID& subnet_id) {
+ // Do not issue logging message here because it will be logged by
+ // the getAllInternal method.
+ HostCollection collection;
+ getAllInternal6<HostCollection>(subnet_id, collection);
+ return (collection);
+}
+
ConstHostCollection
CfgHosts::getAll4(const IOAddress& address) const {
// Do not issue logging message here because it will be logged by
.arg(storage.size());
}
+template<typename Storage>
+void
+CfgHosts::getAllInternal4(const SubnetID& subnet_id,
+ Storage& storage) const {
+
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_CFG_GET_ALL_SUBNET_ID4)
+ .arg(subnet_id);
+
+ // Use try DHCPv4 subnet id.
+ const HostContainerIndex2& idx = hosts_.get<2>();
+
+ // Append each Host object to the storage.
+ for (HostContainerIndex2::iterator host = idx.lower_bound(subnet_id);
+ host != idx.upper_bound(subnet_id);
+ ++host) {
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+ HOSTS_CFG_GET_ALL_SUBNET_ID4_HOST)
+ .arg(subnet_id)
+ .arg((*host)->toText());
+ storage.push_back(*host);
+ }
+
+ // Log how many hosts have been found.
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_SUBNET_ID4_COUNT)
+ .arg(subnet_id)
+ .arg(storage.size());
+}
+
+template<typename Storage>
+void
+CfgHosts::getAllInternal6(const SubnetID& subnet_id,
+ Storage& storage) const {
+
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_CFG_GET_ALL_SUBNET_ID6)
+ .arg(subnet_id);
+
+ // Use try DHCPv6 subnet id.
+ const HostContainerIndex3& idx = hosts_.get<3>();
+
+ // Append each Host object to the storage.
+ for (HostContainerIndex3::iterator host = idx.lower_bound(subnet_id);
+ host != idx.upper_bound(subnet_id);
+ ++host) {
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+ HOSTS_CFG_GET_ALL_SUBNET_ID6_HOST)
+ .arg(subnet_id)
+ .arg((*host)->toText());
+ storage.push_back(*host);
+ }
+
+ // Log how many hosts have been found.
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_SUBNET_ID6_COUNT)
+ .arg(subnet_id)
+ .arg(storage.size());
+}
+
+
template<typename Storage>
void
CfgHosts::getAllInternal4(const IOAddress& address, Storage& storage) const {
}
// At least one subnet ID must be used
- if (host->getIPv4SubnetID() == SUBNET_ID_UNUSED &&
+ if (host->getIPv4SubnetID() == SUBNET_ID_UNUSED &&
host->getIPv6SubnetID() == SUBNET_ID_UNUSED) {
isc_throw(BadValue, "must not use both IPv4 and IPv6 subnet ids of"
" 0 when adding new host reservation");
-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2019 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
const uint8_t* identifier_begin,
const size_t identifier_len);
+ /// @brief Return all hosts in a DHCPv4 subnet.
+ ///
+ /// This method returns all @c Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of const @c Host objects.
+ virtual ConstHostCollection
+ getAll4(const SubnetID& subnet_id) const;
+
+ /// @brief Return all hosts in a DHCPv4 subnet.
+ ///
+ /// This method returns all @c Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of non-const @c Host objects.
+ virtual HostCollection
+ getAll4(const SubnetID& subnet_id);
+
+ /// @brief Return all hosts in a DHCPv6 subnet.
+ ///
+ /// This method returns all @c Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of const @c Host objects.
+ virtual ConstHostCollection
+ getAll6(const SubnetID& subnet_id) const;
+
+ /// @brief Return all hosts in a DHCPv6 subnet.
+ ///
+ /// This method returns all @c Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of non-const @c Host objects.
+ virtual HostCollection
+ getAll6(const SubnetID& subnet_id);
+
/// @brief Returns a collection of hosts using the specified IPv4 address.
///
/// This method may return multiple @c Host objects if they are connected
const size_t identifier_len,
Storage& storage) const;
+ /// @brief Returns @c Host objects in a DHCPv4 subnet.
+ ///
+ /// This private method is called by the @c CfgHosts::getAllInternal
+ /// method which finds the @c Host objects in a specified subnet.
+ /// The retrieved objects are appended to the @c storage container.
+ ///
+ /// @param subnet_id Subnet identifier.
+ /// @param [out] storage Container to which the retrieved objects are
+ /// appended.
+ /// @tparam One of the @c ConstHostCollection of @c HostCollection.
+ template<typename Storage>
+ void getAllInternal4(const SubnetID& subnet_id,
+ Storage& storage) const;
+
+ /// @brief Returns @c Host objects in a DHCPv6 subnet.
+ ///
+ /// This private method is called by the @c CfgHosts::getAllInternal
+ /// method which finds the @c Host objects in a specified subnet.
+ /// The retrieved objects are appended to the @c storage container.
+ ///
+ /// @param subnet_id Subnet identifier.
+ /// @param [out] storage Container to which the retrieved objects are
+ /// appended.
+ /// @tparam One of the @c ConstHostCollection of @c HostCollection.
+ template<typename Storage>
+ void getAllInternal6(const SubnetID& subnet_id,
+ Storage& storage) const;
+
/// @brief Returns @c Host objects for the specified IPv4 address.
///
/// This private method is called by the @c CfgHosts::getAll4 methods
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2016-2018 Deutsche Telekom AG.
//
// Author: Andrei Pavel <andrei.pavel@qualitance.com>
const uint8_t* identifier_begin,
const size_t identifier_len) const override;
+ /// @brief Return all hosts in a DHCPv4 subnet.
+ ///
+ /// This method returns all @ref Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id subnet identifier to filter by
+ ///
+ /// @return Collection of const @ref Host objects.
+ virtual ConstHostCollection
+ getAll4(const SubnetID& subnet_id) const override;
+
+ /// @brief Return all hosts in a DHCPv6 subnet.
+ ///
+ /// This method returns all @ref Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id subnet identifier to filter by
+ ///
+ /// @return Collection of const @ref Host objects.
+ virtual ConstHostCollection
+ getAll6(const SubnetID& subnet_id) const override;
+
/// @brief Returns a collection of hosts using the specified IPv4 address.
///
/// This method may return multiple @ref Host objects if they are connected
-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2019 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
return (hosts);
}
+ConstHostCollection
+HostMgr::getAll4(const SubnetID& subnet_id) const {
+ ConstHostCollection hosts = getCfgHosts()->getAll4(subnet_id);
+ for (auto source : alternate_sources_) {
+ ConstHostCollection hosts_plus = source->getAll4(subnet_id);
+ hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
+ }
+ return (hosts);
+}
+
+
+ConstHostCollection
+HostMgr::getAll6(const SubnetID& subnet_id) const {
+ ConstHostCollection hosts = getCfgHosts()->getAll6(subnet_id);
+ for (auto source : alternate_sources_) {
+ ConstHostCollection hosts_plus = source->getAll6(subnet_id);
+ hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
+ }
+ return (hosts);
+}
+
ConstHostCollection
HostMgr::getAll4(const IOAddress& address) const {
}
return (host);
}
-
+
ConstHostPtr
HostMgr::get4(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const {
-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2019 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
const uint8_t* identifier_begin,
const size_t identifier_len) const;
+ /// @brief Return all hosts in a DHCPv4 subnet.
+ ///
+ /// This method returns all @c Host objects representing reservations
+ /// in a specified subnet as documented in the
+ /// @c BaseHostDataSource::getAll4
+ ///
+ /// It retrieves reservations from both primary and alternate host data
+ /// source as a single collection of @c Host objects, i.e. if matching
+ /// reservations are in both sources, all of them are returned. The
+ /// reservations from the primary data source are placed before the
+ /// reservations from the alternate source.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of const @c Host objects.
+ virtual ConstHostCollection
+ getAll4(const SubnetID& subnet_id) const;
+
+ /// @brief Return all hosts in a DHCPv6 subnet.
+ ///
+ /// This method returns all @c Host objects representing reservations
+ /// in a specified subnet as documented in the
+ /// @c BaseHostDataSource::getAll6
+ ///
+ /// It retrieves reservations from both primary and alternate host data
+ /// source as a single collection of @c Host objects, i.e. if matching
+ /// reservations are in both sources, all of them are returned. The
+ /// reservations from the primary data source are placed before the
+ /// reservations from the alternate source.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of const @c Host objects.
+ virtual ConstHostCollection
+ getAll6(const SubnetID& subnet_id) const;
+
/// @brief Returns a collection of hosts using the specified IPv4 address.
///
/// This method may return multiple @c Host objects if they are connected to
/// @brief Returns any host connected to the IPv6 subnet.
///
/// This method returns a host connected to the IPv6 subnet as described
- /// in the @c BaseHostDataSource::get6 even when the
+ /// in the @c BaseHostDataSource::get6 even when the
/// reservation is marked as from negative caching. This allows to
/// monitor negative caching.
///
-# Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2015-2019 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
identifier. The arguments specify the identifier and the detailed
description of the host found.
+% HOSTS_CFG_GET_ALL_SUBNET_ID4 get all hosts with reservations for subnet id4 %1
+This debug message is issued when starting to retrieve all hosts connected to
+the specific DHCPv4 subnet. The argument specifies subnet id.
+
+% HOSTS_CFG_GET_ALL_SUBNET_ID6 get all hosts with reservations for subnet id6 %1
+This debug message is issued when starting to retrieve all hosts connected to
+the specific DHCPv6 subnet. The argument specifies subnet id.
+
% HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6 get all hosts with reservations for subnet id %1 and IPv6 address %2
This debug message is issued when starting to retrieve all hosts connected to
the specific subnet and having the specific IPv6 address reserved.
% HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_COUNT using subnet id %1 and address %2, found %3 host(s)
This debug message include the details of the host found using the
subnet id and address. The arguments specify subnet id, address and
-found host details respectively.
+the number of hosts found respectively.
% HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_HOST using subnet id %1 and address %2, found host: %3
This debug message includes the details of the host found using the
subnet id and address. The arguments specify subnet id, address and
+the number of hosts found respectively.
found host details respectively.
+% HOSTS_CFG_GET_ALL_SUBNET_ID4_COUNT using subnet id4 %1, found %2 host(s)
+This debug message include the details of the host found using the DHCPv4
+subnet id. The arguments specify subnet id and the number of hosts found
+respectively.
+
+% HOSTS_CFG_GET_ALL_SUBNET_ID6_COUNT using subnet id6 %1, found %2 host(s)
+This debug message include the details of the host found using the DHCPv6
+subnet id. The arguments specify subnet id and the number of hosts found
+respectively.
+
+% HOSTS_CFG_GET_ALL_SUBNET_ID4_HOST using subnet id4 %1, found host: %2
+This debug message includes the details of the host found using the DHCPv4
+subnet id. The arguments specify subnet id and found host details respectively.
+
+% HOSTS_CFG_GET_ALL_SUBNET_ID6_HOST using subnet id6 %1, found host: %2
+This debug message includes the details of the host found using the DHCPv6
+subnet id. The arguments specify subnet id and found host details respectively.
+
% HOSTS_CFG_GET_ONE_PREFIX get one host with reservation for prefix %1/%2
This debug message is issued when starting to retrieve a host having a
reservation for a specified prefix. The arguments specify a prefix and
-// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2019 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
getAll(const Host::IdentifierType& identifier_type,
const uint8_t* identifier_begin, const size_t identifier_len) const;
+ /// @brief Return all hosts in a DHCPv4 subnet.
+ ///
+ /// This method returns all @ref Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id subnet identifier to filter by
+ ///
+ /// @return Collection of const @ref Host objects.
+ virtual ConstHostCollection
+ getAll4(const SubnetID& subnet_id) const override;
+
+ /// @brief Return all hosts in a DHCPv6 subnet.
+ ///
+ /// This method returns all @ref Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id subnet identifier to filter by
+ ///
+ /// @return Collection of const @ref Host objects.
+ virtual ConstHostCollection
+ getAll6(const SubnetID& subnet_id) const override;
+
/// @brief Returns a collection of hosts using the specified IPv4 address.
///
/// This method may return multiple @c Host objects if they are connected
-// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-2019 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
getAll(const Host::IdentifierType& identifier_type,
const uint8_t* identifier_begin, const size_t identifier_len) const;
+ /// @brief Return all hosts in a DHCPv4 subnet.
+ ///
+ /// This method returns all @ref Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id subnet identifier to filter by
+ ///
+ /// @return Collection of const @ref Host objects.
+ virtual ConstHostCollection
+ getAll4(const SubnetID& subnet_id) const override;
+
+ /// @brief Return all hosts in a DHCPv6 subnet.
+ ///
+ /// This method returns all @ref Host objects which represent reservations
+ /// in a specified subnet.
+ ///
+ /// @param subnet_id subnet identifier to filter by
+ ///
+ /// @return Collection of const @ref Host objects.
+ virtual ConstHostCollection
+ getAll6(const SubnetID& subnet_id) const override;
+
/// @brief Returns a collection of hosts using the specified IPv4 address.
///
/// This method may return multiple @c Host objects if they are connected
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 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
// Remove it from test host data source.
EXPECT_TRUE(memptr_->del(host->getIPv4SubnetID(), address));
-
+
// It is cached so we can still get it.
got = HostMgr::instance().get4(host->getIPv4SubnetID(),
host->getIdentifierType(),
host->getIdentifier().size());
ASSERT_TRUE(got);
HostDataSourceUtils::compareHosts(got, host);
-
+
// Even by address.
got = HostMgr::instance().get4(host->getIPv4SubnetID(), address);
ASSERT_TRUE(got);
Host::IDENT_DUID,
false);
ASSERT_TRUE(host); // Make sure the host is generated properly.
-
+
// Get the address.
IPv6ResrvRange resrvs = host->getIPv6Reservations();
ASSERT_EQ(1, std::distance(resrvs.first, resrvs.second));
// Remove it from test host data source.
EXPECT_TRUE(memptr_->del(host->getIPv6SubnetID(), address));
-
+
// It is cached so we can still get it.
got = HostMgr::instance().get6(host->getIPv6SubnetID(),
host->getIdentifierType(),
host->getIdentifier().size());
ASSERT_TRUE(got);
HostDataSourceUtils::compareHosts(got, host);
-
+
// Even by address.
got = HostMgr::instance().get6(host->getIPv6SubnetID(), address);
ASSERT_TRUE(got);
// Remove it from test host data source.
EXPECT_TRUE(memptr_->del(host->getIPv4SubnetID(), address));
-
+
// It is cached so we can still get it.
got = HostMgr::instance().get4(host->getIPv4SubnetID(), address);
ASSERT_TRUE(got);
HostDataSourceUtils::compareHosts(got, host);
-
+
// Even by identifier.
got = HostMgr::instance().get4(host->getIPv4SubnetID(),
host->getIdentifierType(),
Host::IDENT_DUID,
false);
ASSERT_TRUE(host); // Make sure the host is generated properly.
-
+
// Get the address.
IPv6ResrvRange resrvs = host->getIPv6Reservations();
ASSERT_EQ(1, std::distance(resrvs.first, resrvs.second));
// Remove it from test host data source.
EXPECT_TRUE(memptr_->del(host->getIPv6SubnetID(), address));
-
+
// It is cached so we can still get it.
got = HostMgr::instance().get6(host->getIPv6SubnetID(), address);
ASSERT_TRUE(got);
HostDataSourceUtils::compareHosts(got, host);
-
+
// Even by identifier.
got = HostMgr::instance().get6(host->getIPv6SubnetID(),
host->getIdentifierType(),
Host::IDENT_DUID,
false);
ASSERT_TRUE(host); // Make sure the host is generated properly.
-
+
// Get the address.
IPv6ResrvRange resrvs = host->getIPv6Reservations();
ASSERT_EQ(1, std::distance(resrvs.first, resrvs.second));
/// Destructor
virtual ~TestOneBackend() { }
- ConstHostCollection getAll(const Host::IdentifierType&, const uint8_t*,
+ ConstHostCollection getAll(const Host::IdentifierType&, const uint8_t*,
const size_t) const {
return (getCollection());
}
+ ConstHostCollection getAll4(const SubnetID&) const {
+ return (getCollection());
+ }
+
+ ConstHostCollection getAll6(const SubnetID&) const {
+ return (getCollection());
+ }
+
ConstHostCollection getAll4(const IOAddress&) const {
return (getCollection());
}
-// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2019 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
if ((added_options == DHCP4_ONLY) || (added_options == DHCP4_AND_DHCP6)) {
// Add DHCPv4 options.
CfgOptionPtr opts = host->getCfgOption4();
- OptionDescriptor desc =
+ OptionDescriptor desc =
createOption<OptionString>(Option::V4, DHO_BOOT_FILE_NAME,
true, formatted, "my-boot-file");
desc.setContext(user_context);
if ((added_options == DHCP6_ONLY) || (added_options == DHCP4_AND_DHCP6)) {
// Add DHCPv6 options.
CfgOptionPtr opts = host->getCfgOption6();
- OptionDescriptor desc =
+ OptionDescriptor desc =
createOption<OptionString>(Option::V6, D6O_BOOTFILE_URL,
true, formatted, "my-boot-file");
desc.setContext(user_context);
// Subnet id will be used in queries to the database.
SubnetID subnet_id = host->getIPv4SubnetID();
+ // getAll4(subnet_id)
+ ConstHostCollection hosts_by_subnet = hdsptr_->getAll4(subnet_id);
+ // Not yet implemented.
+ EXPECT_EQ(0, hosts_by_subnet.size());
+
// getAll4(address)
ConstHostCollection hosts_by_addr =
hdsptr_->getAll4(host->getIPv4Reservation());
ASSERT_NO_THROW(addTestOptions(host, formatted, DHCP4_AND_DHCP6));
// Insert host, options and IPv6 reservations into respective tables.
ASSERT_NO_THROW(hdsptr_->add(host));
+ // Subnet id will be used in queries to the database.
+ SubnetID subnet_id = host->getIPv6SubnetID();
+
+ // getAll6(subnet_id)
+ ConstHostCollection hosts_by_subnet = hdsptr_->getAll6(subnet_id);
+ // Not yet implemented.
+ EXPECT_EQ(0, hosts_by_subnet.size());
// getAll(identifier_type, identifier, identifier_size)
ConstHostCollection hosts_by_id =
const std::string prefix = std::string("2001:db8::") + n_host;
hosts.push_back(HostDataSourceUtils::initializeHost6(prefix,
Host::IDENT_HWADDR, false, "key##1"));
-
+
IPv6ResrvRange range = hosts.back()->getIPv6Reservations();
ASSERT_EQ(1, std::distance(range.first, range.second));
EXPECT_TRUE(HostDataSourceUtils::reservationExists
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 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
return (ConstHostCollection());
}
+ConstHostCollection
+MemHostDataSource::getAll4(const SubnetID& /*subnet_id*/) const {
+ return (ConstHostCollection());
+}
+
+ConstHostCollection
+MemHostDataSource::getAll6(const SubnetID& /*subnet_id*/) const {
+ return (ConstHostCollection());
+}
+
ConstHostCollection
MemHostDataSource::getAll4(const asiolink::IOAddress& /*address*/) const {
return (ConstHostCollection());
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 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
const uint8_t* identifier_begin,
const size_t identifier_len) const;
+ /// @brief Return all hosts in a DHCPv4 subnet.
+ ///
+ /// Currently not implemented.
+ ///
+ /// @param subnet_id Subnet identifier.
+ virtual ConstHostCollection
+ getAll4(const SubnetID& subnet_id) const;
+
+ /// @brief Return all hosts in a DHCPv6 subnet.
+ ///
+ /// Currently not implemented.
+ ///
+ /// @param subnet_id Subnet identifier.
+ virtual ConstHostCollection
+ getAll6(const SubnetID& subnet_id) const;
+
/// @brief Returns a collection of hosts using the specified IPv4 address.
///
/// Currently not implemented.
-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2019 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
const uint8_t* identifier_begin,
const size_t identifier_len) = 0;
+ /// @brief Returns a collection of hosts in the specified DHCPv4 subnet.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of non-const @c Host objects.
+ virtual HostCollection
+ getAll4(const SubnetID& subnet_id) = 0;
+
+ /// @brief Returns a collection of hosts in the specified DHCPv6 subnet.
+ ///
+ /// @param subnet_id Subnet identifier.
+ ///
+ /// @return Collection of non-const @c Host objects.
+ virtual HostCollection
+ getAll6(const SubnetID& subnet_id) = 0;
+
/// @brief Returns a collection of hosts using the specified IPv4 address.
///
/// This method may return multiple @c Host objects if they are connected