getAll6(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const = 0;
+ /// @brief Returns all hosts having a reservation for a specified
+ /// address or delegated prefix (lease) in all subnets.
+ ///
+ /// In most cases it is desired that there is at most one reservation
+ /// for a given IPv6 lease within a subnet. In a default configuration,
+ /// the backend does not allow for inserting more than one host with
+ /// the same IPv6 address or prefix.
+ ///
+ /// If the backend is configured to allow multiple hosts with reservations
+ /// for the same IPv6 lease in the given subnet, this method can return
+ /// more than one host per subnet.
+ ///
+ /// The typical use case when a single IPv6 lease is reserved for multiple
+ /// hosts is when these hosts represent different interfaces of the same
+ /// machine and each interface comes with a different MAC address. In that
+ /// case, the same IPv6 lease is assigned regardless of which interface is
+ /// used by the DHCP client to communicate with the server.
+ ///
+ /// @param address reserved IPv6 address/prefix.
+ ///
+ /// @return Collection of const @c Host objects.
+ virtual ConstHostCollection
+ getAll6(const asiolink::IOAddress& address) const = 0;
+
/// @brief Adds a new host to the collection.
///
/// The implementations of this method should guard against duplicate
return getAll6(subnet_id, address, HostMgrOperationTarget::ALL_SOURCES);
}
+ConstHostCollection
+HostMgr::getAll6(const IOAddress& address) const {
+ return (getAll6(address, HostMgrOperationTarget::ALL_SOURCES));
+}
+
ConstHostCollection
HostMgr::getAll6(const IOAddress& address, const HostMgrOperationTarget target) const {
ConstHostCollection hosts;
if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
for (auto source : alternate_sources_) {
- ConstHostCollection hosts_plus = source->getAll4(address);
+ ConstHostCollection hosts_plus = source->getAll6(address);
hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
}
getAll6(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const;
+ /// @brief The @c HostMgr::getAll6 compatible with @c BaseHostDataSource
+ /// interfaces. Operates on all host sources.
+ virtual ConstHostCollection
+ getAll6(const asiolink::IOAddress& address) const;
+
/// @brief Returns a collection of hosts using the specified IPv6 address.
///
/// This method may return multiple @c Host objects if they are connected to
return (getCollection());
}
+ ConstHostCollection getAll6(const IOAddress&) const {
+ return (getCollection());
+ }
+
ConstHostCollection getAllbyHostname(const std::string&) const {
return (getCollection());
}
MemHostDataSource::getAll6(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const {
ConstHostCollection hosts;
- auto host = get6(subnet_id, address);
- if (host) {
- hosts.push_back(host);
+ for (const auto & h : store_) {
+ if (h->getIPv6SubnetID() != subnet_id) {
+ continue;
+ }
+
+ auto resrvs = h->getIPv6Reservations();
+ for (auto r = resrvs.first; r != resrvs.second; ++r) {
+ if ((*r).second.getPrefix() == address) {
+ hosts.push_back(h);
+ }
+ }
}
+
+ return (hosts);
+}
+
+ConstHostCollection
+MemHostDataSource::getAll6(const asiolink::IOAddress& address) const {
+ ConstHostCollection hosts;
+ for (const auto & h : store_) {
+ auto resrvs = h->getIPv6Reservations();
+ for (auto r = resrvs.first; r != resrvs.second; ++r) {
+ if ((*r).second.getPrefix() == address) {
+ hosts.push_back(h);
+ }
+ }
+ }
+
return (hosts);
}
getAll6(const SubnetID& subnet_id,
const asiolink::IOAddress& address) const;
+ // @brief Returns all hosts having a reservation for a specified
+ // address or delegated prefix (lease).
+ ///
+ /// @param address reserved IPv6 address/prefix.
+ ///
+ /// @return Collection of const @c Host objects.
+ virtual ConstHostCollection
+ getAll6(const asiolink::IOAddress& address) const;
+
+
/// @brief Adds a new host to the collection.
///
/// @param host Pointer to the new @c Host object being added.