summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dhcpsrv/cfg_hosts.cc12
-rw-r--r--src/lib/dhcpsrv/host_container.h17
-rw-r--r--src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc2
3 files changed, 24 insertions, 7 deletions
diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc
index 2ea5ad0fd7..c21905bf7e 100644
--- a/src/lib/dhcpsrv/cfg_hosts.cc
+++ b/src/lib/dhcpsrv/cfg_hosts.cc
@@ -644,16 +644,16 @@ CfgHosts::getAllInternal6(const IOAddress& address, Storage& storage) const {
" for a host, specified address was " << address);
}
// Search for the Host using the reserved IPv6 address as a key.
- const HostContainerIndex1& idx = hosts_.get<1>();
- HostContainerIndex1Range r = idx.equal_range(address);
+ const HostContainer6Index4& idx = hosts6_.get<4>();
+ HostContainer6Index4Range r = idx.equal_range(address);
// Append each Host object to the storage.
- for (HostContainerIndex1::iterator host = r.first; host != r.second;
- ++host) {
+ for (HostContainer6Index4::iterator reservation = r.first; reservation != r.second;
+ ++reservation) {
LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
HOSTS_CFG_GET_ALL_ADDRESS6_HOST)
.arg(address.toText())
- .arg((*host)->toText());
- storage.push_back(*host);
+ .arg(reservation->host_->toText());
+ storage.push_back(reservation->host_);
}
LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_ADDRESS6_COUNT)
diff --git a/src/lib/dhcpsrv/host_container.h b/src/lib/dhcpsrv/host_container.h
index cb106adc24..fd830760dd 100644
--- a/src/lib/dhcpsrv/host_container.h
+++ b/src/lib/dhcpsrv/host_container.h
@@ -249,6 +249,14 @@ typedef boost::multi_index_container<
// Index using values returned by the @c Host::getHostId
boost::multi_index::const_mem_fun<HostResrv6Tuple, uint64_t,
&HostResrv6Tuple::getHostId>
+ >,
+
+ // Fifth index is used to search by the reserved address.
+ boost::multi_index::ordered_non_unique<
+ boost::multi_index::const_mem_fun<
+ HostResrv6Tuple, const asiolink::IOAddress&,
+ &HostResrv6Tuple::getPrefix
+ >
>
>
> HostContainer6;
@@ -292,6 +300,15 @@ typedef HostContainer6::nth_index<3>::type HostContainer6Index3;
typedef std::pair<HostContainer6Index3::iterator,
HostContainer6Index3::iterator> HostContainer6Index3Range;
+/// @brief Fifth index type in the @c HostContainer6.
+///
+/// This index allows for searching for @c Host objects using an IP address.
+typedef HostContainer6::nth_index<4>::type HostContainer6Index4;
+
+/// @brief Results range returned using the @c HostContainer6Index4.
+typedef std::pair<HostContainer6Index4::iterator,
+ HostContainer6Index4::iterator> HostContainer6Index4Range;
+
}; // end of isc::dhcp namespace
}; // end of isc namespace
diff --git a/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc b/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
index 0abd18d200..de45d7965b 100644
--- a/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
+++ b/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
@@ -284,7 +284,7 @@ TEST_F(CfgHostsTest, getAll6ByAddress) {
// Add 25 hosts identified by DUID in the same subnet.
for (unsigned i = 0; i < 25; ++i) {
HostPtr host = HostPtr(new Host(duids_[i]->toText(), "duid",
- SUBNET_ID_UNUSED, SubnetID(1),
+ SUBNET_ID_UNUSED, SubnetID(i+1),
IOAddress("0.0.0.0")));
host->addReservation(IPv6Resrv(IPv6Resrv::TYPE_NA,
increase(IOAddress("2001:db8:1::1"),