mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[#2931] Fixed getting host by IPv6 address
Modified the query fetching host by IPv6 address to include all addresses and options associated with the host.
This commit is contained in:
parent
9e51cc140a
commit
704655fa8e
@ -2477,7 +2477,9 @@ TaggedStatementArray tagged_statements = { {
|
||||
"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 = ? AND r.address = ? "
|
||||
"WHERE h.dhcp6_subnet_id = ? AND h.host_id = "
|
||||
"( SELECT host_id FROM ipv6_reservations "
|
||||
"WHERE address = ? ) "
|
||||
"ORDER BY h.host_id, o.option_id, r.reservation_id"},
|
||||
|
||||
// Retrieves host information along with the DHCPv4 options associated with
|
||||
|
@ -1807,7 +1807,9 @@ TaggedStatementArray tagged_statements = { {
|
||||
"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 "
|
||||
"WHERE h.dhcp6_subnet_id = $1 AND h.host_id = "
|
||||
" (SELECT host_id FROM ipv6_reservations "
|
||||
" WHERE address = $2) "
|
||||
"ORDER BY h.host_id, o.option_id, r.reservation_id"
|
||||
},
|
||||
|
||||
|
@ -183,6 +183,11 @@ GenericHostDataSourceTest::addTestOptions(const HostPtr& host,
|
||||
LibDHCP::setRuntimeOptionDefs(defs);
|
||||
}
|
||||
|
||||
void
|
||||
GenericHostDataSourceTest::addIPv6Address(const HostPtr& host, const std::string& address) const {
|
||||
host->addReservation(IPv6Resrv(IPv6Resrv::TYPE_NA, IOAddress(address)));
|
||||
}
|
||||
|
||||
void
|
||||
GenericHostDataSourceTest::testReadOnlyDatabase(const char* valid_db_type) {
|
||||
ASSERT_TRUE(hdsptr_);
|
||||
@ -1721,9 +1726,13 @@ GenericHostDataSourceTest::testGetBySubnetIPv6() {
|
||||
|
||||
// Let's create a couple of hosts...
|
||||
HostPtr host1 = HostDataSourceUtils::initializeHost6("2001:db8:1::", Host::IDENT_DUID, true);
|
||||
addIPv6Address(host1, "2001:db8:1::10");
|
||||
HostPtr host2 = HostDataSourceUtils::initializeHost6("2001:db8:2::", Host::IDENT_DUID, true);
|
||||
addIPv6Address(host2, "2001:db8:1::20");
|
||||
HostPtr host3 = HostDataSourceUtils::initializeHost6("2001:db8:3::", Host::IDENT_DUID, true);
|
||||
addIPv6Address(host3, "2001:db8:1::30");
|
||||
HostPtr host4 = HostDataSourceUtils::initializeHost6("2001:db8:4::", Host::IDENT_DUID, true);
|
||||
addIPv6Address(host4, "2001:db8:1::40");
|
||||
|
||||
// ... and add them to the data source.
|
||||
ASSERT_NO_THROW(hdsptr_->add(host1));
|
||||
|
@ -142,6 +142,12 @@ public:
|
||||
isc::data::ConstElementPtr user_context =
|
||||
isc::data::ConstElementPtr()) const;
|
||||
|
||||
/// @brief Adds an IPv6 address to the host.
|
||||
///
|
||||
/// @param host pointer to the host instance.
|
||||
/// @param address an IPv6 address to be added as a string.
|
||||
void addIPv6Address(const HostPtr& host, const std::string& address) const;
|
||||
|
||||
/// @brief Pointer to the host data source
|
||||
HostDataSourcePtr hdsptr_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user