]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5563] Changes done and compile
authorFrancis Dupont <fdupont@isc.org>
Thu, 24 May 2018 14:51:07 +0000 (16:51 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 24 May 2018 14:51:07 +0000 (16:51 +0200)
23 files changed:
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp6/tests/config_parser_unittest.cc
src/lib/dhcpsrv/base_host_data_source.h
src/lib/dhcpsrv/cfg_hosts.cc
src/lib/dhcpsrv/cfg_hosts.h
src/lib/dhcpsrv/cql_host_data_source.cc
src/lib/dhcpsrv/cql_host_data_source.h
src/lib/dhcpsrv/host_mgr.cc
src/lib/dhcpsrv/host_mgr.h
src/lib/dhcpsrv/hosts_messages.mes
src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/dhcpsrv/mysql_host_data_source.h
src/lib/dhcpsrv/pgsql_host_data_source.cc
src/lib/dhcpsrv/pgsql_host_data_source.h
src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
src/lib/dhcpsrv/tests/host_cache_unittest.cc
src/lib/dhcpsrv/tests/host_mgr_unittest.cc
src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc
src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc
src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc
src/lib/dhcpsrv/testutils/memory_host_data_source.cc
src/lib/dhcpsrv/testutils/memory_host_data_source.h
src/lib/dhcpsrv/writable_host_data_source.h

index e1e291e815b440d54394863adb9026b0b0ecc878..e1ff5f64762507b2da0c6e223f47b7ec2cc4d4d2 100644 (file)
@@ -4421,19 +4421,21 @@ TEST_F(Dhcp4ParserTest, reservations) {
     // Let's create an object holding hardware address of the host having
     // a reservation in the subnet having id of 234. For simplicity the
     // address is a collection of numbers from 1 to 6.
-    std::vector<uint8_t> hwaddr_vec;
+    std::vector<uint8_t> hwaddr;
     for (unsigned int i = 1; i < 7; ++i) {
-        hwaddr_vec.push_back(static_cast<uint8_t>(i));
+        hwaddr.push_back(static_cast<uint8_t>(i));
     }
-    HWAddrPtr hwaddr(new HWAddr(hwaddr_vec, HTYPE_ETHER));
     // Retrieve the reservation and sanity check the address reserved.
-    ConstHostPtr host = hosts_cfg->get4(234, hwaddr);
+    ConstHostPtr host = hosts_cfg->get4(234, Host::IDENT_HWADDR,
+                                        &hwaddr[0], hwaddr.size());
     ASSERT_TRUE(host);
     EXPECT_EQ("192.0.3.120", host->getIPv4Reservation().toText());
     // This reservation should be solely assigned to the subnet 234,
     // and not to other two.
-    EXPECT_FALSE(hosts_cfg->get4(123, hwaddr));
-    EXPECT_FALSE(hosts_cfg->get4(542, hwaddr));
+    EXPECT_FALSE(hosts_cfg->get4(123, Host::IDENT_HWADDR,
+                                 &hwaddr[0], hwaddr.size()));
+    EXPECT_FALSE(hosts_cfg->get4(542, Host::IDENT_HWADDR,
+                                 &hwaddr[0], hwaddr.size()));
     // Check that options are assigned correctly.
     Option4AddrLstPtr opt_dns =
         retrieveOption<Option4AddrLstPtr>(*host, DHO_NAME_SERVERS);
@@ -4447,16 +4449,15 @@ TEST_F(Dhcp4ParserTest, reservations) {
     EXPECT_EQ(11, static_cast<int>(opt_ttl->getValue()));
 
     // Do the same test for the DUID based reservation.
-    std::vector<uint8_t> duid_vec;
+    std::vector<uint8_t> duid;
     for (unsigned int i = 1; i < 0xb; ++i) {
-        duid_vec.push_back(static_cast<uint8_t>(i));
+        duid.push_back(static_cast<uint8_t>(i));
     }
-    DuidPtr duid(new DUID(duid_vec));
-    host = hosts_cfg->get4(234, HWAddrPtr(), duid);
+    host = hosts_cfg->get4(234, Host::IDENT_DUID, &duid[0], duid.size());
     ASSERT_TRUE(host);
     EXPECT_EQ("192.0.3.112", host->getIPv4Reservation().toText());
-    EXPECT_FALSE(hosts_cfg->get4(123, HWAddrPtr(), duid));
-    EXPECT_FALSE(hosts_cfg->get4(542, HWAddrPtr(), duid));
+    EXPECT_FALSE(hosts_cfg->get4(123, Host::IDENT_DUID, &duid[0], duid.size()));
+    EXPECT_FALSE(hosts_cfg->get4(542, Host::IDENT_DUID, &duid[0], duid.size()));
     // Check that options are assigned correctly.
     opt_dns = retrieveOption<Option4AddrLstPtr>(*host, DHO_NAME_SERVERS);
     ASSERT_TRUE(opt_dns);
@@ -4470,7 +4471,7 @@ TEST_F(Dhcp4ParserTest, reservations) {
     // The circuit-id used for one of the reservations in the subnet 542
     // consists of numbers from 6 to 1. So, let's just reverse the order
     // of the address from the previous test.
-    std::vector<uint8_t> circuit_id(hwaddr_vec.rbegin(), hwaddr_vec.rend());
+    std::vector<uint8_t> circuit_id(hwaddr.rbegin(), hwaddr.rend());
     host = hosts_cfg->get4(542, Host::IDENT_CIRCUIT_ID, &circuit_id[0],
                            circuit_id.size());
     EXPECT_TRUE(host);
@@ -4483,13 +4484,14 @@ TEST_F(Dhcp4ParserTest, reservations) {
 
 
     // Repeat the test for the DUID based reservation in this subnet.
-    duid.reset(new DUID(std::vector<uint8_t>(duid_vec.rbegin(),
-                                             duid_vec.rend())));
-    host = hosts_cfg->get4(542, HWAddrPtr(), duid);
+    std::vector<uint8_t> duid_r(duid.rbegin(), duid.rend());
+    host = hosts_cfg->get4(542, Host::IDENT_DUID, &duid_r[0], duid_r.size());
     ASSERT_TRUE(host);
     EXPECT_EQ("192.0.4.101", host->getIPv4Reservation().toText());
-    EXPECT_FALSE(hosts_cfg->get4(123, HWAddrPtr(), duid));
-    EXPECT_FALSE(hosts_cfg->get4(234, HWAddrPtr(), duid));
+    EXPECT_FALSE(hosts_cfg->get4(123, Host::IDENT_DUID,
+                                 &duid_r[0], duid_r.size()));
+    EXPECT_FALSE(hosts_cfg->get4(234, Host::IDENT_DUID,
+                                 &duid_r[0], duid_r.size()));
     // Check that options are assigned correctly.
     opt_dns = retrieveOption<Option4AddrLstPtr>(*host, DHO_NAME_SERVERS);
     ASSERT_TRUE(opt_dns);
@@ -4564,13 +4566,13 @@ TEST_F(Dhcp4ParserTest, reservationWithOptionDefinition) {
 
     // Let's create an object holding DUID of the host. For simplicity the
     // address is a collection of numbers from 1 to A.
-    std::vector<uint8_t> duid_vec;
+    std::vector<uint8_t> duid;
     for (unsigned int i = 1; i < 0xB; ++i) {
-        duid_vec.push_back(static_cast<uint8_t>(i));
+        duid.push_back(static_cast<uint8_t>(i));
     }
-    DuidPtr duid(new DUID(duid_vec));
     // Retrieve the reservation and sanity check the address reserved.
-    ConstHostPtr host = hosts_cfg->get4(234, HWAddrPtr(), duid);
+    ConstHostPtr host =
+        hosts_cfg->get4(234, Host::IDENT_DUID, &duid[0], duid.size());
     ASSERT_TRUE(host);
     EXPECT_EQ("192.0.3.112", host->getIPv4Reservation().toText());
 
@@ -5992,9 +5994,9 @@ TEST_F(Dhcp4ParserTest, comments) {
 
     // The subnet has a host reservation.
     uint8_t hw[] = { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
-    HWAddrPtr hwaddr(new HWAddr(hw, sizeof(hw), HTYPE_ETHER));
     ConstHostPtr host =
-        CfgMgr::instance().getStagingCfg()->getCfgHosts()->get4(100, hwaddr);
+        CfgMgr::instance().getStagingCfg()->getCfgHosts()->
+        get4(100, Host::IDENT_HWADDR, &hw[0], sizeof(hw));
     ASSERT_TRUE(host);
     EXPECT_EQ(Host::IDENT_HWADDR, host->getIdentifierType());
     EXPECT_EQ("aa:bb:cc:dd:ee:ff", host->getHWAddress()->toText(false));
index a954d6adcb12259456033733455eaf9cbcacc05f..d8b33dfa14769922868c64973f0d23ca83428a1c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2018 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
@@ -4694,13 +4694,13 @@ TEST_F(Dhcp6ParserTest, reservations) {
     // Let's create an object holding hardware address of the host having
     // a reservation in the subnet having id of 234. For simplicity the
     // address is a collection of numbers from 1 to 6.
-    std::vector<uint8_t> hwaddr_vec;
+    std::vector<uint8_t> hwaddr;
     for (unsigned int i = 1; i < 7; ++i) {
-        hwaddr_vec.push_back(static_cast<uint8_t>(i));
+        hwaddr.push_back(static_cast<uint8_t>(i));
     }
-    HWAddrPtr hwaddr(new HWAddr(hwaddr_vec, HTYPE_ETHER));
     // Retrieve the reservation and sanity check the address reserved.
-    ConstHostPtr host = hosts_cfg->get6(234, DuidPtr(), hwaddr);
+    ConstHostPtr host = hosts_cfg->get6(234, Host::IDENT_HWADDR,
+                                        &hwaddr[0], hwaddr.size());
     ASSERT_TRUE(host);
     IPv6ResrvRange resrv = host->getIPv6Reservations(IPv6Resrv::TYPE_NA);
     ASSERT_EQ(1, std::distance(resrv.first, resrv.second));
@@ -4709,8 +4709,10 @@ TEST_F(Dhcp6ParserTest, reservations) {
                                   resrv));
     // This reservation should be solely assigned to the subnet 234,
     // and not to other two.
-    EXPECT_FALSE(hosts_cfg->get6(123, DuidPtr(), hwaddr));
-    EXPECT_FALSE(hosts_cfg->get6(542, DuidPtr(), hwaddr));
+    EXPECT_FALSE(hosts_cfg->get6(123, Host::IDENT_HWADDR,
+                                 &hwaddr[0], hwaddr.size()));
+    EXPECT_FALSE(hosts_cfg->get6(542, Host::IDENT_HWADDR,
+                                 &hwaddr[0], hwaddr.size()));
     // Check that options are assigned correctly.
     Option6AddrLstPtr opt_dns =
         retrieveOption<Option6AddrLstPtr>(*host, D6O_NAME_SERVERS);
@@ -4724,20 +4726,19 @@ TEST_F(Dhcp6ParserTest, reservations) {
     EXPECT_EQ(25, static_cast<int>(opt_prf->getValue()));
 
     // Do the same test for the DUID based reservation.
-    std::vector<uint8_t> duid_vec;
+    std::vector<uint8_t> duid;
     for (unsigned int i = 1; i < 0xb; ++i) {
-        duid_vec.push_back(static_cast<uint8_t>(i));
+        duid.push_back(static_cast<uint8_t>(i));
     }
-    DuidPtr duid(new DUID(duid_vec));
-    host = hosts_cfg->get6(234, duid);
+    host = hosts_cfg->get6(234, Host::IDENT_DUID, &duid[0], duid.size());
     ASSERT_TRUE(host);
     resrv = host->getIPv6Reservations(IPv6Resrv::TYPE_NA);
     ASSERT_EQ(1, std::distance(resrv.first, resrv.second));
     EXPECT_TRUE(reservationExists(IPv6Resrv(IPv6Resrv::TYPE_NA,
                                             IOAddress("2001:db8:2::1234")),
                                   resrv));
-    EXPECT_FALSE(hosts_cfg->get6(123, duid));
-    EXPECT_FALSE(hosts_cfg->get6(542, duid));
+    EXPECT_FALSE(hosts_cfg->get6(123, Host::IDENT_DUID, &duid[0], duid.size()));
+    EXPECT_FALSE(hosts_cfg->get6(542, Host::IDENT_DUID, &duid[0], duid.size()));
     // Check that options are assigned correctly.
     opt_dns = retrieveOption<Option6AddrLstPtr>(*host, D6O_NAME_SERVERS);
     ASSERT_TRUE(opt_dns);
@@ -4752,9 +4753,10 @@ TEST_F(Dhcp6ParserTest, reservations) {
     // The HW address used for one of the reservations in the subnet 542
     // consists of numbers from 6 to 1. So, let's just reverse the order
     // of the address from the previous test.
-    hwaddr->hwaddr_.assign(hwaddr_vec.rbegin(), hwaddr_vec.rend());
-    host = hosts_cfg->get6(542, DuidPtr(), hwaddr);
-    EXPECT_TRUE(host);
+    std::vector<uint8_t> hwaddr_r(hwaddr.rbegin(), hwaddr.rend());
+    host = hosts_cfg->get6(542, Host::IDENT_HWADDR,
+                           &hwaddr_r[0], hwaddr_r.size());
+    ASSERT_TRUE(host);
     resrv = host->getIPv6Reservations(IPv6Resrv::TYPE_PD);
     ASSERT_EQ(1, std::distance(resrv.first, resrv.second));
     EXPECT_TRUE(reservationExists(IPv6Resrv(IPv6Resrv::TYPE_PD,
@@ -4762,13 +4764,14 @@ TEST_F(Dhcp6ParserTest, reservations) {
                                             96), resrv));
 
     // This reservation must not belong to other subnets.
-    EXPECT_FALSE(hosts_cfg->get6(123, DuidPtr(), hwaddr));
-    EXPECT_FALSE(hosts_cfg->get6(234, DuidPtr(), hwaddr));
+    EXPECT_FALSE(hosts_cfg->get6(123, Host::IDENT_HWADDR,
+                                 &hwaddr_r[0], hwaddr_r.size()));
+    EXPECT_FALSE(hosts_cfg->get6(234, Host::IDENT_HWADDR,
+                                 &hwaddr_r[0], hwaddr_r.size()));
 
     // Repeat the test for the DUID based reservation in this subnet.
-    duid.reset(new DUID(std::vector<uint8_t>(duid_vec.rbegin(),
-                                             duid_vec.rend())));
-    host = hosts_cfg->get6(542, duid);
+    std::vector<uint8_t> duid_r(duid.rbegin(), duid.rend());
+    host = hosts_cfg->get6(542, Host::IDENT_DUID, &duid_r[0], duid_r.size());
     ASSERT_TRUE(host);
     resrv = host->getIPv6Reservations(IPv6Resrv::TYPE_PD);
     ASSERT_EQ(1, std::distance(resrv.first, resrv.second));
@@ -4776,8 +4779,10 @@ TEST_F(Dhcp6ParserTest, reservations) {
                                             IOAddress("2001:db8:3:2::"),
                                             96), resrv));
 
-    EXPECT_FALSE(hosts_cfg->get6(123, duid));
-    EXPECT_FALSE(hosts_cfg->get6(234, duid));
+    EXPECT_FALSE(hosts_cfg->get6(123, Host::IDENT_DUID,
+                                 &duid_r[0], duid_r.size()));
+    EXPECT_FALSE(hosts_cfg->get6(234, Host::IDENT_DUID,
+                                 &duid_r[0], duid_r.size()));
     // Check that options are assigned correctly.
     opt_dns = retrieveOption<Option6AddrLstPtr>(*host, D6O_NAME_SERVERS);
     ASSERT_TRUE(opt_dns);
@@ -4842,13 +4847,13 @@ TEST_F(Dhcp6ParserTest, reservationWithOptionDefinition) {
 
     // Let's create an object holding DUID of the host. For simplicity the
     // address is a collection of numbers from 1 to A.
-    std::vector<uint8_t> duid_vec;
+    std::vector<uint8_t> duid;
     for (unsigned int i = 1; i < 0xB; ++i) {
-        duid_vec.push_back(static_cast<uint8_t>(i));
+        duid.push_back(static_cast<uint8_t>(i));
     }
-    DuidPtr duid(new DUID(duid_vec));
     // Retrieve the reservation and sanity check the address reserved.
-    ConstHostPtr host = hosts_cfg->get6(234, duid);
+    ConstHostPtr host = hosts_cfg->get6(234, Host::IDENT_DUID,
+                                        &duid[0], duid.size());
     ASSERT_TRUE(host);
 
     // Check if the option has been parsed.
@@ -6566,9 +6571,9 @@ TEST_F(Dhcp6ParserTest, comments) {
 
     // The subnet has a host reservation.
     uint8_t hw[] = { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
-    HWAddrPtr hwaddr(new HWAddr(hw, sizeof(hw), HTYPE_ETHER));
     ConstHostPtr host =
-        CfgMgr::instance().getStagingCfg()->getCfgHosts()->get6(100, DuidPtr(), hwaddr);
+        CfgMgr::instance().getStagingCfg()->getCfgHosts()->
+        get6(100, Host::IDENT_HWADDR, &hw[0], sizeof(hw));
     ASSERT_TRUE(host);
     EXPECT_EQ(Host::IDENT_HWADDR, host->getIdentifierType());
     EXPECT_EQ("aa:bb:cc:dd:ee:ff", host->getHWAddress()->toText(false));
index 640715ca31107183bdc4682ee3f4c889250feb7b..115c82ed57fbc702b7a1b4ae39c6a3c82c59006b 100644 (file)
@@ -8,8 +8,6 @@
 #define BASE_HOST_DATA_SOURCE_H
 
 #include <asiolink/io_address.h>
-#include <dhcp/duid.h>
-#include <dhcp/hwaddr.h>
 #include <dhcpsrv/host.h>
 #include <exceptions/exceptions.h>
 #include <boost/shared_ptr.hpp>
@@ -76,30 +74,6 @@ public:
     /// @brief Default destructor implementation.
     virtual ~BaseHostDataSource() { }
 
-    /// @brief Return all hosts for the specified HW address or DUID.
-    ///
-    /// This method returns all @c Host objects which represent reservations
-    /// for the specified HW address or DUID. Note, that this method may
-    /// return multiple reservations because a particular client may have
-    /// reservations in multiple subnets and the same client may be identified
-    /// by HW address or DUID. The server is unable to verify that the specific
-    /// DUID and HW address belong to the same client, until the client sends
-    /// a DHCP message.
-    ///
-    /// Specifying both hardware address and DUID is allowed for this method
-    /// and results in returning all objects that are associated with hardware
-    /// address OR duid. For example: if one host is associated with the
-    /// specified hardware address and another host is associated with the
-    /// specified DUID, two hosts will be returned.
-    ///
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
-    ///
-    /// @return Collection of const @c Host objects.
-    virtual ConstHostCollection
-    getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const = 0;
-
     /// @brief Return all hosts connected to any subnet for which reservations
     /// have been made using a specified identifier.
     ///
@@ -129,25 +103,6 @@ public:
     virtual ConstHostCollection
     getAll4(const asiolink::IOAddress& address) const = 0;
 
-    /// @brief Returns a host connected to the IPv4 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @c Host are present, e.g. when two
-    /// @c Host objects are found, one for the DUID, another one for the
-    /// HW address. In such case, an implementation of this method
-    /// should throw an exception.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-         const DuidPtr& duid = DuidPtr()) const = 0;
-
-
     /// @brief Returns a host connected to the IPv4 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -184,24 +139,6 @@ public:
     get4(const SubnetID& subnet_id,
          const asiolink::IOAddress& address) const = 0;
 
-    /// @brief Returns a host connected to the IPv6 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @c Host are present, e.g. when two
-    /// @c Host objects are found, one for the DUID, another one for the
-    /// HW address. In such case, an implementation of this method
-    /// should throw an exception.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid DUID or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get6(const SubnetID& subnet_id, const DuidPtr& duid,
-         const HWAddrPtr& hwaddr = HWAddrPtr()) const = 0;
-
     /// @brief Returns a host connected to the IPv6 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -223,7 +160,7 @@ public:
     /// @param prefix IPv6 prefix for which the @c Host object is searched.
     /// @param prefix_len IPv6 prefix length.
     ///
-    /// @return Const @c Host object using a specified HW address or DUID.
+    /// @return Const @c Host object using a specified IPv6 prefix.
     virtual ConstHostPtr
     get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const = 0;
 
index b7f52d405e4a7f3d3b9546a2dca83c050ca46d2f..d673cdc3b1f24f9197a890a8b62f637d654602b9 100644 (file)
@@ -1,10 +1,12 @@
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 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
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 #include <config.h>
+#include <dhcp/duid.h>
+#include <dhcp/hwaddr.h>
 #include <dhcpsrv/cfg_hosts.h>
 #include <dhcpsrv/cfg_hosts_util.h>
 #include <dhcpsrv/hosts_log.h>
@@ -21,24 +23,6 @@ using namespace isc::data;
 namespace isc {
 namespace dhcp {
 
-ConstHostCollection
-CfgHosts::getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid) const {
-    // Do not issue logging message here because it will be logged by
-    // the getAllInternal method.
-    ConstHostCollection collection;
-    getAllInternal<ConstHostCollection>(hwaddr, duid, collection);
-    return (collection);
-}
-
-HostCollection
-CfgHosts::getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid) {
-    // Do not issue logging message here because it will be logged by
-    // the getAllInternal method.
-    HostCollection collection;
-    getAllInternal<HostCollection>(hwaddr, duid, collection);
-    return (collection);
-}
-
 ConstHostCollection
 CfgHosts::getAll(const Host::IdentifierType& identifier_type,
                  const uint8_t* identifier_begin,
@@ -137,26 +121,6 @@ CfgHosts::getAllInternal(const Host::IdentifierType& identifier_type,
         .arg(storage.size());
 }
 
-template<typename Storage>
-void
-CfgHosts::getAllInternal(const HWAddrPtr& hwaddr, const DuidPtr& duid,
-                         Storage& storage) const {
-    LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_CFG_GET_ALL_HWADDR_DUID)
-        .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)")
-        .arg(duid ? duid->toText() : "(no-duid)");
-
-    // Get hosts using HW address.
-    if (hwaddr && !hwaddr->hwaddr_.empty()) {
-        getAllInternal<Storage>(Host::IDENT_HWADDR, &hwaddr->hwaddr_[0],
-                                hwaddr->hwaddr_.size(), storage);
-    }
-    // Get hosts using DUID.
-    if (duid && !duid->getDuid().empty()) {
-        getAllInternal<Storage>(Host::IDENT_DUID, &duid->getDuid()[0],
-                                duid->getDuid().size(), storage);
-    }
-}
-
 template<typename Storage>
 void
 CfgHosts::getAllInternal4(const IOAddress& address, Storage& storage) const {
@@ -215,44 +179,6 @@ CfgHosts::getAllInternal6(const IOAddress& address, Storage& storage) const {
         .arg(storage.size());
 }
 
-ConstHostPtr
-CfgHosts::get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-               const DuidPtr& duid) const {
-    // Do not log here because getHostInternal logs.
-    // The false value indicates that it is an IPv4 subnet.
-    HostPtr host;
-    if (hwaddr && !hwaddr->hwaddr_.empty()) {
-        host = getHostInternal(subnet_id, false, Host::IDENT_HWADDR,
-                               &hwaddr->hwaddr_[0],
-                               hwaddr->hwaddr_.size());
-    }
-    if (!host && duid && !duid->getDuid().empty()) {
-        host = getHostInternal(subnet_id, false, Host::IDENT_DUID,
-                               &duid->getDuid()[0],
-                               duid->getDuid().size());
-    }
-    return (host);
-}
-
-HostPtr
-CfgHosts::get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-               const DuidPtr& duid) {
-    // Do not log here because getHostInternal logs.
-    // The false value indicates that it is an IPv4 subnet.
-    HostPtr host;
-    if (hwaddr && !hwaddr->hwaddr_.empty()) {
-        host = getHostInternal(subnet_id, false, Host::IDENT_HWADDR,
-                               &hwaddr->hwaddr_[0],
-                               hwaddr->hwaddr_.size());
-    }
-    if (!host && duid && !duid->getDuid().empty()) {
-        host = getHostInternal(subnet_id, false, Host::IDENT_DUID,
-                               &duid->getDuid()[0],
-                               duid->getDuid().size());
-    }
-    return (host);
-}
-
 ConstHostPtr
 CfgHosts::get4(const SubnetID& subnet_id,
                const Host::IdentifierType& identifier_type,
@@ -295,46 +221,6 @@ CfgHosts::get4(const SubnetID& subnet_id, const IOAddress& address) const {
 }
 
 
-ConstHostPtr
-CfgHosts::get6(const SubnetID& subnet_id, const DuidPtr& duid,
-               const HWAddrPtr& hwaddr) const {
-    // Do not log here because getHostInternal logs.
-    // The true value indicates that it is an IPv6 subnet.
-    HostPtr host;
-    if (duid && !duid->getDuid().empty()) {
-        host = getHostInternal(subnet_id, true, Host::IDENT_DUID,
-                               &duid->getDuid()[0],
-                               duid->getDuid().size());
-    }
-    if (!host && hwaddr && !hwaddr->hwaddr_.empty()) {
-        host = getHostInternal(subnet_id, true, Host::IDENT_HWADDR,
-                               &hwaddr->hwaddr_[0],
-                               hwaddr->hwaddr_.size());
-    }
-
-    return (host);
-}
-
-HostPtr
-CfgHosts::get6(const SubnetID& subnet_id, const DuidPtr& duid,
-               const HWAddrPtr& hwaddr) {
-    // Do not log here because getHostInternal logs.
-    // The true value indicates that it is an IPv6 subnet.
-    HostPtr host;
-    if (duid && !duid->getDuid().empty()) {
-        host = getHostInternal(subnet_id, true, Host::IDENT_DUID,
-                               &duid->getDuid()[0],
-                               duid->getDuid().size());
-    }
-    if (!host && hwaddr && !hwaddr->hwaddr_.empty()) {
-        host = getHostInternal(subnet_id, true, Host::IDENT_HWADDR,
-                               &hwaddr->hwaddr_[0],
-                               hwaddr->hwaddr_.size());
-    }
-
-    return (host);
-}
-
 ConstHostPtr
 CfgHosts::get6(const SubnetID& subnet_id,
                const Host::IdentifierType& identifier_type,
@@ -603,23 +489,41 @@ CfgHosts::add4(const HostPtr& host) {
     }
 
     // Check for duplicates for the specified IPv4 subnet.
-    if ((host->getIPv4SubnetID() > 0) &&
-        get4(host->getIPv4SubnetID(), hwaddr, duid)) {
-        isc_throw(DuplicateHost, "failed to add new host using the HW"
-                  " address '" << (hwaddr ? hwaddr->toText(false) : "(null)")
-                  << " and DUID '" << (duid ? duid->toText() : "(null)")
-                  << "' to the IPv4 subnet id '" << host->getIPv4SubnetID()
-                  << "' as this host has already been added");
-
-
+    if (host->getIPv4SubnetID() > 0) {
+        if (hwaddr && !hwaddr->hwaddr_.empty() &&
+            get4(host->getIPv4SubnetID(), Host::IDENT_HWADDR,
+                 &hwaddr->hwaddr_[0], hwaddr->hwaddr_.size())) {
+            isc_throw(DuplicateHost, "failed to add new host using the HW"
+                      << " address '" << hwaddr->toText(false)
+                      << "' to the IPv4 subnet id '" << host->getIPv4SubnetID()
+                      << "' as this host has already been added");
+        }
+        if (duid && !duid->getDuid().empty() &&
+            get4(host->getIPv4SubnetID(), Host::IDENT_DUID,
+                 &duid->getDuid()[0], duid->getDuid().size())) {
+            isc_throw(DuplicateHost, "failed to add new host using the "
+                      << "DUID '" << duid->toText()
+                      << "' to the IPv4 subnet id '" << host->getIPv4SubnetID()
+                      << "' as this host has already been added");
+        }
     // Check for duplicates for the specified IPv6 subnet.
-    } else if (host->getIPv6SubnetID() &&
-               get6(host->getIPv6SubnetID(), duid, hwaddr)) {
-        isc_throw(DuplicateHost, "failed to add new host using the HW"
-                  " address '" << (hwaddr ? hwaddr->toText(false) : "(null)")
-                  << " and DUID '" << (duid ? duid->toText() : "(null)")
-                  << "' to the IPv6 subnet id '" << host->getIPv6SubnetID()
-                  << "' as this host has already been added");
+    } else if (host->getIPv6SubnetID()) {
+        if (duid && !duid->getDuid().empty() &&
+            get6(host->getIPv6SubnetID(), Host::IDENT_DUID,
+                 &duid->getDuid()[0], duid->getDuid().size())) {
+            isc_throw(DuplicateHost, "failed to add new host using the "
+                      << "DUID '" << duid->toText()
+                      << "' to the IPv6 subnet id '" << host->getIPv6SubnetID()
+                      << "' as this host has already been added");
+        }
+        if (hwaddr && !hwaddr->hwaddr_.empty() &&
+            get6(host->getIPv6SubnetID(), Host::IDENT_HWADDR,
+                 &hwaddr->hwaddr_[0], hwaddr->hwaddr_.size())) {
+            isc_throw(DuplicateHost, "failed to add new host using the HW"
+                      << " address '" << hwaddr->toText(false)
+                      << "' to the IPv6 subnet id '" << host->getIPv6SubnetID()
+                      << "' as this host has already been added");
+        }
     }
 
     // Check if the address is already reserved for the specified IPv4 subnet.
index 0717e9a17407eb825b16660b59913b84df340696..e41ba6a2503161cb93c2d4c1713ed4248c69961a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 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
@@ -9,8 +9,6 @@
 
 #include <asiolink/io_address.h>
 #include <cc/cfg_to_element.h>
-#include <dhcp/duid.h>
-#include <dhcp/hwaddr.h>
 #include <dhcpsrv/base_host_data_source.h>
 #include <dhcpsrv/host.h>
 #include <dhcpsrv/host_container.h>
@@ -43,34 +41,6 @@ public:
     /// @brief Destructor.
     virtual ~CfgHosts() { }
 
-    /// @brief Return all hosts for the specified HW address or DUID.
-    ///
-    /// This method returns all @c Host objects which represent reservations
-    /// for the specified HW address or DUID. Note, that this method may
-    /// return multiple reservations because a particular client may have
-    /// reservations in multiple subnets and the same client may be identified
-    /// by HW address or DUID. The server is unable to verify that the specific
-    /// DUID and HW address belong to the same client, until the client sends
-    /// a DHCP message.
-    ///
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
-    ///
-    /// @return Collection of const @c Host objects.
-    virtual ConstHostCollection
-    getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
-
-    /// @brief Non-const version of the @c getAll const method.
-    ///
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
-    ///
-    /// @return Collection of non-const @c Host objects.
-    virtual HostCollection
-    getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr());
-
     /// @brief Return all hosts connected to any subnet for which reservations
     /// have been made using a specified identifier.
     ///
@@ -149,36 +119,6 @@ public:
     virtual HostCollection
     getAll6(const asiolink::IOAddress& address);
 
-    /// @brief Returns a host connected to the IPv4 subnet and matching
-    /// specified identifiers.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    /// @throw isc::dhcp::DuplicateHost if more than one candidate host has
-    /// been found.
-    virtual ConstHostPtr
-    get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-         const DuidPtr& duid = DuidPtr()) const;
-
-    /// @brief Returns a host connected to the IPv4 subnet and matching
-    /// specified identifiers.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available.
-    ///
-    /// @return Non-const @c Host object using a specified HW address or DUID.
-    /// @throw isc::dhcp::DuplicateHost if more than one candidate host has
-    /// been found.
-    virtual HostPtr
-    get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-         const DuidPtr& duid = DuidPtr());
-
     /// @brief Returns a host connected to the IPv4 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -217,36 +157,6 @@ public:
     virtual ConstHostPtr
     get4(const SubnetID& subnet_id, const asiolink::IOAddress& address) const;
 
-    /// @brief Returns a host connected to the IPv6 subnet and matching
-    /// the specified identifiers.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid DUID or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    /// @throw isc::dhcp::DuplicateHost if more than one candidate host has
-    /// been found.
-    virtual ConstHostPtr
-    get6(const SubnetID& subnet_id, const DuidPtr& duid,
-         const HWAddrPtr& hwaddr = HWAddrPtr()) const;
-
-    /// @brief Returns a host connected to the IPv6 subnet and matching the
-    /// specified identifiers.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid DUID or NULL if not available.
-    ///
-    /// @return Non-const @c Host object using a specified HW address or DUID.
-    /// @throw isc::dhcp::DuplicateHost if more than one candidate host has
-    /// been found.
-    virtual HostPtr
-    get6(const SubnetID& subnet_id, const DuidPtr& duid,
-         const HWAddrPtr& hwaddr = HWAddrPtr());
-
     /// @brief Returns a host connected to the IPv6 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -408,21 +318,6 @@ private:
                         const size_t identifier_len,
                         Storage& storage) const;
 
-    /// @brief Returns @c Host objects for the specified HW address or DUID.
-    ///
-    /// This private method is called by the @c CfgHosts::getAll methods to
-    /// retrieve the @c Host objects using HW address or DUID. The retrieved
-    /// objects are appended to the @c storage container.
-    ///
-    /// @param hwaddr HW address identifying a host.
-    /// @param duid DUID identifying a host.
-    /// @param [out] storage Container to which the retrieved objects are
-    /// appended.
-    /// @tparam One of the @c ConstHostCollection or @c HostCollection.
-    template<typename Storage>
-    void getAllInternal(const HWAddrPtr& hwaddr, const DuidPtr& duid,
-                        Storage& storage) const;
-
     /// @brief Returns @c Host objects for the specified IPv4 address.
     ///
     /// This private method is called by the @c CfgHosts::getAll4 methods
index 549984802454e06e3276de38eea14d6bdf7f03e8..9e2b95fb7a4ac9c746411e40f7ddc4ca464a9db7 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <dhcpsrv/cql_host_data_source.h>
 
+#include <dhcp/duid.h>
 #include <dhcp/libdhcp++.h>
 #include <dhcp/option.h>
 #include <dhcp/option_definition.h>
@@ -1351,18 +1352,6 @@ public:
     virtual ConstHostPtr get4(const SubnetID& subnet_id,
                               const asiolink::IOAddress& address) const;
 
-    /// @brief Implementation of @ref CqlHostDataSource::get4()
-    ///
-    /// See @ref CqlHostDataSource::get4() for parameter details.
-    /// Either hwaddr or DUID must be specified, not both.
-    ///
-    /// @param subnet_id Id of the subnet to look into
-    /// @param hwaddr hardware address
-    /// @param duid DUID of the client
-    virtual ConstHostPtr get4(const SubnetID& subnet_id,
-                              const HWAddrPtr& hwaddr,
-                              const DuidPtr& duid = DuidPtr()) const;
-
     /// @brief Implementation of @ref CqlHostDataSource::get4()
     ///
     /// See @ref CqlHostDataSource::get4() for parameter details.
@@ -1385,18 +1374,6 @@ public:
     virtual ConstHostPtr get6(const asiolink::IOAddress& prefix,
                               const uint8_t prefix_len) const;
 
-    /// @brief Retrieves a host by DUID or hardware address.
-    ///
-    /// Only one of DUID or hwaddr must be specified, not both.
-    /// See @ref CqlHostDataSource::get6() for parameter details.
-    ///
-    /// @param subnet_id Id of the subnet to look into
-    /// @param duid Searched DUID
-    /// @param hwaddr Searched hwaddr
-    virtual ConstHostPtr get6(const SubnetID& subnet_id,
-                              const DuidPtr& duid,
-                              const HWAddrPtr& hwaddr = HWAddrPtr()) const;
-
     /// @brief Implementation of @ref CqlHostDataSource::get6()
     ///
     /// See @ref CqlHostDataSource::get6() for parameter details.
@@ -1419,19 +1396,6 @@ public:
     virtual ConstHostPtr get6(const SubnetID& subnet_id,
                               const asiolink::IOAddress& address) const;
 
-    /// @brief Implementation of @ref CqlHostDataSource::getAll()
-    ///
-    /// Returns reservations in all subnets for a given host.
-    /// See @ref CqlHostDataSource::getAll() for parameter details.
-    ///
-    /// Only one of DUID or hwaddr must be specified, not both.
-    /// See @ref CqlHostDataSource::get6() for parameter details.
-    ///
-    /// @param hwaddr
-    /// @param duid
-    virtual ConstHostCollection getAll(const HWAddrPtr& hwaddr,
-                                       const DuidPtr& duid = DuidPtr()) const;
-
     /// @brief Implementation of @ref CqlHostDataSource::getAll()
     ///
     /// See @ref CqlHostDataSource::getAll() for parameter details.
@@ -1684,38 +1648,6 @@ CqlHostDataSourceImpl::get4(const SubnetID& subnet_id, const asiolink::IOAddress
     return (result);
 }
 
-ConstHostPtr
-CqlHostDataSourceImpl::get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-                            const DuidPtr& duid) const {
-    /// @todo: Rethink the logic in BaseHostDataSource::get4(subnet, hwaddr, duid)
-    if (hwaddr && duid) {
-        isc_throw(BadValue, "CqlHostDataSource::get4(3) called with both "
-                            "hwaddr and duid, only one of them is allowed");
-    } else if (!hwaddr && !duid) {
-        isc_throw(BadValue, "CqlHostDataSource::get4(3) called with neither "
-                            "hwaddr or duid specified, one of them is "
-                            "required");
-    }
-
-    const HostIdentifier* host_identifier;
-    Host::IdentifierType host_identifier_type;
-    if (duid) {
-        host_identifier = &duid->getDuid();
-        host_identifier_type = Host::IDENT_DUID;
-    } else if (hwaddr) {
-        host_identifier = &hwaddr->hwaddr_;
-        host_identifier_type = Host::IDENT_HWADDR;
-    } else {
-        return (ConstHostPtr());
-    }
-
-    // Delegate to get4(4).
-    ConstHostPtr result = get4(subnet_id, host_identifier_type, host_identifier->data(),
-                               host_identifier->size());
-
-    return (result);
-}
-
 ConstHostPtr
 CqlHostDataSourceImpl::get4(const SubnetID& subnet_id,
                             const Host::IdentifierType& identifier_type,
@@ -1782,39 +1714,6 @@ CqlHostDataSourceImpl::get6(const asiolink::IOAddress& prefix,
     return (result);
 }
 
-ConstHostPtr
-CqlHostDataSourceImpl::get6(const SubnetID& subnet_id,
-                            const DuidPtr& duid,
-                            const HWAddrPtr& hwaddr) const {
-    /// @todo: Rethink the logic in BaseHostDataSource::get6(subnet, hwaddr, duid)
-    if (hwaddr && duid) {
-        isc_throw(BadValue, "CqlHostDataSource::get6(3): both hardware address "
-                            "and DUID are specified, only one of them is "
-                            "allowed");
-    } else if (!hwaddr && !duid) {
-        isc_throw(BadValue, "CqlHostDataSource::get6(3): both hardware address "
-                            "and DUID are specified, one of them is required");
-    }
-
-    const HostIdentifier* host_identifier;
-    Host::IdentifierType host_identifier_type;
-    if (duid) {
-        host_identifier = &duid->getDuid();
-        host_identifier_type = Host::IDENT_DUID;
-    } else if (hwaddr) {
-        host_identifier = &hwaddr->hwaddr_;
-        host_identifier_type = Host::IDENT_HWADDR;
-    } else {
-        return (ConstHostPtr());
-    }
-
-    // Delegate to get6(4).
-    ConstHostPtr result = get6(subnet_id, host_identifier_type, host_identifier->data(),
-                               host_identifier->size());
-
-    return (result);
-}
-
 ConstHostPtr
 CqlHostDataSourceImpl::get6(const SubnetID& subnet_id,
                             const Host::IdentifierType& identifier_type,
@@ -1856,36 +1755,6 @@ CqlHostDataSourceImpl::get6(const SubnetID& subnet_id, const IOAddress& address)
     return (result);
 }
 
-ConstHostCollection
-CqlHostDataSourceImpl::getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid) const {
-    if (!duid && !hwaddr) {
-        return (ConstHostCollection());
-    }
-
-    // Convert to CQL data types.
-    cass_int32_t host_identifier_type;
-    CassBlob host_identifier;
-    if (duid) {
-        HostIdentifier duid_vector = duid->getDuid();
-        host_identifier = CassBlob(duid_vector.begin(), duid_vector.end());
-        host_identifier_type = static_cast<cass_int32_t>(Host::IDENT_DUID);
-    } else if (hwaddr) {
-        host_identifier = CassBlob(hwaddr->hwaddr_.begin(), hwaddr->hwaddr_.end());
-        host_identifier_type = static_cast<cass_int32_t>(Host::IDENT_HWADDR);
-    }
-
-    // Bind to array.
-    AnyArray where_values;
-    where_values.add(&host_identifier);
-    where_values.add(&host_identifier_type);
-
-    // Run statement.
-    ConstHostCollection result = getHostCollection(CqlHostExchange::GET_HOST_BY_HOST_ID,
-                                                   where_values);
-
-    return (result);
-}
-
 ConstHostCollection
 CqlHostDataSourceImpl::getAll(const Host::IdentifierType& identifier_type,
                               const uint8_t* identifier_begin,
@@ -2168,13 +2037,6 @@ CqlHostDataSource::del6(const SubnetID& subnet_id, const Host::IdentifierType& i
     return (impl_->insertOrDelete(host, false));
 }
 
-ConstHostCollection
-CqlHostDataSource::getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid) const {
-    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_HOST_GET_ALL);
-
-    return (impl_->getAll(hwaddr, duid));
-}
-
 ConstHostCollection
 CqlHostDataSource::getAll(const Host::IdentifierType& identifier_type,
                           const uint8_t* identifier_begin,
@@ -2191,15 +2053,6 @@ CqlHostDataSource::getAll4(const asiolink::IOAddress& address) const {
     return (impl_->getAll4(address));
 }
 
-ConstHostPtr
-CqlHostDataSource::get4(const SubnetID& subnet_id,
-                        const HWAddrPtr& hwaddr,
-                        const DuidPtr& duid) const {
-    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_HOST_GET4);
-
-    return (impl_->get4(subnet_id, hwaddr, duid));
-}
-
 ConstHostPtr
 CqlHostDataSource::get4(const SubnetID& subnet_id,
                         const Host::IdentifierType& identifier_type,
@@ -2219,15 +2072,6 @@ CqlHostDataSource::get4(const SubnetID& subnet_id,
     return (impl_->get4(subnet_id, address));
 }
 
-ConstHostPtr
-CqlHostDataSource::get6(const SubnetID& subnet_id,
-                        const DuidPtr& duid,
-                        const HWAddrPtr& hwaddr) const {
-    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_HOST_GET6);
-
-    return (impl_->get6(subnet_id, duid, hwaddr));
-}
-
 ConstHostPtr
 CqlHostDataSource::get6(const SubnetID& subnet_id,
                         const Host::IdentifierType& identifier_type,
index 75d4d45a1d60fad1fbac00b18a9a9cb8698f699b..a03b3336ae82a97df7a9605904e0766908c4302e 100644 (file)
@@ -148,32 +148,6 @@ public:
                       const uint8_t* identifier_begin,
                       const size_t identifier_len) override;
 
-    /// @brief Return all @ref Host objects for the specified @ref HWAddr or
-    /// @ref DUID.
-    ///
-    /// Returns all @ref Host objects which represent reservations
-    /// for the specified HW address or DUID. Note, that this method may
-    /// return multiple reservations because a particular client may have
-    /// reservations in multiple subnets and the same client may be identified
-    /// by HW address or DUID. The server is unable to verify that the specific
-    /// DUID and HW address belong to the same client, until the client sends
-    /// a DHCP message.
-    ///
-    /// Specifying both @ref HWAddr and @ref DUID is allowed for this method
-    /// and results in returning all objects that are associated with hardware
-    /// address OR duid. For example: if one @ref Host is associated with the
-    /// specified @ref HWAddr and another @ref Host is associated with the
-    /// specified @ref DUID, two hosts will be returned.
-    ///
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
-    ///
-    /// @return collection of const @ref Host objects.
-    virtual ConstHostCollection
-    getAll(const HWAddrPtr& hwaddr,
-           const DuidPtr& duid = DuidPtr()) const override;
-
     /// @brief Return all hosts connected to any subnet for which reservations
     /// have been made using a specified identifier.
     ///
@@ -203,26 +177,6 @@ public:
     virtual ConstHostCollection
     getAll4(const asiolink::IOAddress& address) const override;
 
-    /// @brief Retrieves a single @ref Host connected to an IPv4 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @ref Host are present, e.g. when two @ref
-    /// Host objects are found, one for the @ref DUID, another one for the @ref
-    /// HWAddr. In such case, throw a @ref MultipleRecords exception.
-    ///
-    /// @param subnet_id subnet identifier to filter by
-    /// @param hwaddr hardware address of the client to filter by or NULL if not
-    ///     available
-    /// @param duid client identifier to filter by or NULL if not available
-    ///
-    /// @return @ref ConstHostPtr to a @ref Host object using a specified @ref
-    ///     HWAddr or @ref DUID
-    ///
-    /// @throw BadValue if both or neither of subnet_id and duid are specified
-    virtual ConstHostPtr get4(const SubnetID& subnet_id,
-                              const HWAddrPtr& hwaddr,
-                              const DuidPtr& duid = DuidPtr()) const override;
-
     /// @brief Retrieves a @ref Host connected to an IPv4 subnet.
     ///
     /// The host is identified by specific identifier.
@@ -254,26 +208,6 @@ public:
     get4(const SubnetID& subnet_id,
          const asiolink::IOAddress& address) const override;
 
-    /// @brief Retrieves a @ref Host connected to an IPv6 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @ref Host are present, e.g. when two
-    /// @ref Host objects are found, one for the @ref DUID, another one for the
-    /// @ref HWAddr. In such case, throw a @ref MultipleRecords exception.
-    ///
-    /// @param subnet_id subnet identifier to filter by
-    /// @param hwaddr hardware address of the client to filter by or NULL if not
-    ///     available
-    /// @param duid client identifier to filter by or NULL if not available
-    ///
-    /// @return @ref Host object using a specified @ref HWAddr or @ref DUID
-    ///
-    /// @throw BadValue if both or neither of subnet_id and duid are specified
-    virtual ConstHostPtr
-    get6(const SubnetID& subnet_id,
-         const DuidPtr& duid,
-         const HWAddrPtr& hwaddr = HWAddrPtr()) const override;
-
     /// @brief Returns a @ref Host connected to an IPv6 subnet.
     ///
     /// @param subnet_id subnet identifier to filter by
@@ -294,7 +228,7 @@ public:
     /// @param prefix IPv6 prefix for which the @ref Host object is searched.
     /// @param prefix_len IPv6 prefix length.
     ///
-    /// @return Const @ref Host object using a specified HW address or DUID.
+    /// @return Const @ref Host object using a specified IPv6 prefix.
     ///
     /// @throw MultipleRecords if two or more rows are returned from the
     ///     Cassandra database
index 3b8d3ab658a8755d934439c8fd41f65bb2745878..6792a73f8ec825e7de954d1db92e1cc491370041 100644 (file)
@@ -95,16 +95,6 @@ HostMgr::instance() {
     return (*host_mgr_ptr);
 }
 
-ConstHostCollection
-HostMgr::getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid) const {
-    ConstHostCollection hosts = getCfgHosts()->getAll(hwaddr, duid);
-    for (auto source : alternate_sources_) {
-        ConstHostCollection hosts_plus = source->getAll(hwaddr, duid);
-        hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
-    }
-    return (hosts);
-}
-
 ConstHostCollection
 HostMgr::getAll(const Host::IdentifierType& identifier_type,
                 const uint8_t* identifier_begin,
@@ -131,38 +121,6 @@ HostMgr::getAll4(const IOAddress& address) const {
     return (hosts);
 }
 
-ConstHostPtr
-HostMgr::get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-              const DuidPtr& duid) const {
-    ConstHostPtr host = getCfgHosts()->get4(subnet_id, hwaddr, duid);
-    if (host || alternate_sources_.empty()) {
-        return (host);
-    }
-    LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
-              HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_HWADDR_DUID)
-        .arg(subnet_id)
-        .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)")
-        .arg(duid ? duid->toText() : "(duid)");
-    for (auto source : alternate_sources_) {
-        if (hwaddr) {
-            host = source->get4(subnet_id, hwaddr, DuidPtr());
-        }
-        if (!host && duid) {
-            host = source->get4(subnet_id, HWAddrPtr(), duid);
-        }
-        if (host && host->getNegative()) {
-            return (ConstHostPtr());
-        }
-        if (host && (source != cache_ptr_)) {
-            cache(host);
-        }
-        if (host) {
-            return (host);
-        }
-    }
-    return (ConstHostPtr());
-}
-
 ConstHostPtr
 HostMgr::get4Any(const SubnetID& subnet_id,
                  const Host::IdentifierType& identifier_type,
@@ -256,39 +214,6 @@ HostMgr::get4(const SubnetID& subnet_id,
 }
 
 
-ConstHostPtr
-HostMgr::get6(const SubnetID& subnet_id, const DuidPtr& duid,
-               const HWAddrPtr& hwaddr) const {
-    ConstHostPtr host = getCfgHosts()->get6(subnet_id, duid, hwaddr);
-    if (host || alternate_sources_.empty()) {
-        return (host);
-    }
-    LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE,
-              HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_DUID_HWADDR)
-        .arg(subnet_id)
-        .arg(duid ? duid->toText() : "(duid)")
-        .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)");
-
-    for (auto source : alternate_sources_) {
-        if (duid) {
-            host = source->get6(subnet_id, duid, HWAddrPtr());
-        }
-        if (!host && hwaddr) {
-            host = source->get6(subnet_id, DuidPtr(), hwaddr);
-        }
-        if (host && host->getNegative()) {
-            return (ConstHostPtr());
-        }
-        if (host && source != cache_ptr_) {
-            cache(host);
-        }
-        if (host) {
-            return (host);
-        }
-    }
-    return (ConstHostPtr());
-}
-
 ConstHostPtr
 HostMgr::get6(const IOAddress& prefix, const uint8_t prefix_len) const {
     ConstHostPtr host = getCfgHosts()->get6(prefix, prefix_len);
index 28d0f22daf1877a49710cb6c43e7386f0177ab92..bc7b6c211c439710e7b0d46b7fb4ee66abc0757b 100644 (file)
@@ -7,8 +7,6 @@
 #ifndef HOST_MGR_H
 #define HOST_MGR_H
 
-#include <dhcp/duid.h>
-#include <dhcp/hwaddr.h>
 #include <dhcpsrv/base_host_data_source.h>
 #include <dhcpsrv/cache_host_data_source.h>
 #include <dhcpsrv/database_connection.h>
@@ -102,29 +100,6 @@ public:
     /// manager to not use the alternate host data source.
     static HostMgr& instance();
 
-    /// @brief Returns all hosts for the specified HW address or DUID.
-    ///
-    /// This method returns all @c Host objects representing reservations for
-    /// the specified HW address or/and DUID as documented in the
-    /// @c BaseHostDataSource::getAll.
-    ///
-    /// 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.
-    ///
-    /// Note that returned collection may contain duplicates. It is the
-    /// caller's responsibility to check for duplicates.
-    ///
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL of not available.
-    ///
-    /// @return Collection of const @c Host objects.
-    virtual ConstHostCollection
-    getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
-
     /// @brief Return all hosts connected to any subnet for which reservations
     /// have been made using a specified identifier.
     ///
@@ -165,22 +140,6 @@ public:
     virtual ConstHostCollection
     getAll4(const asiolink::IOAddress& address) const;
 
-    /// @brief Returns a host connected to the IPv4 subnet.
-    ///
-    /// This method returns a single reservation for the particular host
-    /// (identified by the HW address or DUID) as documented in the
-    /// @c BaseHostDataSource::get4.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-         const DuidPtr& duid = DuidPtr()) const;
-
     /// @brief Returns any host connected to the IPv4 subnet.
     ///
     /// This method returns a single reservation for a particular host as
@@ -233,22 +192,6 @@ public:
     virtual ConstHostPtr
     get4(const SubnetID& subnet_id, const asiolink::IOAddress& address) const;
 
-    /// @brief Returns a host connected to the IPv6 subnet.
-    ///
-    /// This method returns a host connected to the IPv6 subnet and identified
-    /// by the HW address or DUID, as described in the
-    /// @c BaseHostDataSource::get6.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid DUID or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get6(const SubnetID& subnet_id, const DuidPtr& duid,
-         const HWAddrPtr& hwaddr = HWAddrPtr()) const;
-
     /// @brief Returns any host connected to the IPv6 subnet.
     ///
     /// This method returns a host connected to the IPv6 subnet as described
@@ -295,7 +238,7 @@ public:
     /// @param prefix IPv6 prefix for which the @c Host object is searched.
     /// @param prefix_len IPv6 prefix length.
     ///
-    /// @return Const @c Host object using a specified HW address or DUID.
+    /// @return Const @c Host object using a specified IPv6 prefix.
     virtual ConstHostPtr
     get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const;
 
index 5d06fc486ac20c7c94c41267d8102820cac4919a..f3ccfde0babde635c001e4581e557f39eeba4780 100644 (file)
@@ -61,11 +61,6 @@ This debug message is issued when found host with the reservation
 for the specified IPv6 address. The arguments specify the IPv6 address
 and the detailed description of the host found.
 
-% HOSTS_CFG_GET_ALL_HWADDR_DUID get all hosts with reservations for HWADDR %1 and DUID %2
-This debug message is issued when starting to retrieve reservations for all hosts
-using specific HW address or DUID. The arguments specify the HW address and
-DUID respectively. The argument specify the HW address and DUID respectively.
-
 % HOSTS_CFG_GET_ALL_IDENTIFIER get all hosts with reservations using identifier: %1
 This debug message is issued when starting to retrieve reservations for all hosts
 identified by HW address or DUID. The argument holds both the identifier
@@ -156,12 +151,6 @@ host connected to the specific subnet and having the reservation for
 the specific IPv4 address, and it is starting to search for this host
 in alternate host data sources.
 
-% HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_HWADDR_DUID trying alternate sources for host using subnet id %1, HWADDR %2, DUID%3
-This debug message is issued when the Host Manager doesn't find the
-host connected to the specific subnet and identified by the HW address
-or DUID, and it is starting to search for this host in alternate
-host data sources.
-
 % HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER get one host with IPv4 reservation for subnet id %1, identified by %2
 This debug message is issued when starting to retrieve a host holding
 IPv4 reservation, which is connected to a specific subnet and
@@ -188,12 +177,6 @@ host connected to the specific subnet and having the reservation for
 the specified IPv6 address, and it is starting to search for this
 host in alternate host data sources.
 
-% HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_DUID_HWADDR trying alternate sources for host using subnet id %1, DUID %2, HWADDR %3
-This debug message is issued when the Host Manager doesn't find the
-host connected to the specific subnet and identified by the specified
-DUID or HW Address, and it is starting to search for this host in
-alternate host data sources.
-
 % HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER get one host with IPv6 reservation for subnet id %1, identified by %2
 This debug message is issued when starting to retrieve a host holding
 IPv4 reservation, which is connected to a specific subnet and
index 1c72afd741b634212297ebef5a2802714bdbce75..50d13f5dad42df8cd6f9c68c5e6306df083123e3 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2018 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
@@ -2712,23 +2712,6 @@ MySqlHostDataSource::del6(const SubnetID& subnet_id,
     return (impl_->delStatement(MySqlHostDataSourceImpl::DEL_HOST_SUBID6_ID, inbind));
 }
 
-ConstHostCollection
-MySqlHostDataSource::getAll(const HWAddrPtr& hwaddr,
-                            const DuidPtr& duid) const {
-
-    if (duid) {
-        return (getAll(Host::IDENT_DUID, &duid->getDuid()[0],
-                       duid->getDuid().size()));
-
-    } else if (hwaddr) {
-        return (getAll(Host::IDENT_HWADDR,
-                       &hwaddr->hwaddr_[0],
-                       hwaddr->hwaddr_.size()));
-    }
-
-    return (ConstHostCollection());
-}
-
 ConstHostCollection
 MySqlHostDataSource::getAll(const Host::IdentifierType& identifier_type,
                             const uint8_t* identifier_begin,
@@ -2778,33 +2761,6 @@ MySqlHostDataSource::getAll4(const asiolink::IOAddress& address) const {
     return (result);
 }
 
-ConstHostPtr
-MySqlHostDataSource::get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-                          const DuidPtr& duid) const {
-
-    /// @todo: Rethink the logic in BaseHostDataSource::get4(subnet, hwaddr, duid)
-    if (hwaddr && duid) {
-        isc_throw(BadValue, "MySQL host data source get4() called with both"
-                  " hwaddr and duid, only one of them is allowed");
-    }
-    if (!hwaddr && !duid) {
-        isc_throw(BadValue, "MySQL host data source get4() called with "
-                  "neither hwaddr or duid specified, one of them is required");
-    }
-
-    // Choosing one of the identifiers
-    if (hwaddr) {
-        return (get4(subnet_id, Host::IDENT_HWADDR, &hwaddr->hwaddr_[0],
-                     hwaddr->hwaddr_.size()));
-
-    } else if (duid) {
-        return (get4(subnet_id, Host::IDENT_DUID, &duid->getDuid()[0],
-                     duid->getDuid().size()));
-    }
-
-    return (ConstHostPtr());
-}
-
 ConstHostPtr
 MySqlHostDataSource::get4(const SubnetID& subnet_id,
                           const Host::IdentifierType& identifier_type,
@@ -2850,32 +2806,6 @@ MySqlHostDataSource::get4(const SubnetID& subnet_id,
     return (result);
 }
 
-ConstHostPtr
-MySqlHostDataSource::get6(const SubnetID& subnet_id, const DuidPtr& duid,
-                          const HWAddrPtr& hwaddr) const {
-
-    /// @todo: Rethink the logic in BaseHostDataSource::get6(subnet, hwaddr, duid)
-    if (hwaddr && duid) {
-        isc_throw(BadValue, "MySQL host data source get6() called with both"
-                  " hwaddr and duid, only one of them is allowed");
-    }
-    if (!hwaddr && !duid) {
-        isc_throw(BadValue, "MySQL host data source get6() called with "
-                  "neither hwaddr or duid specified, one of them is required");
-    }
-
-    // Choosing one of the identifiers
-    if (hwaddr) {
-        return (get6(subnet_id, Host::IDENT_HWADDR, &hwaddr->hwaddr_[0],
-                     hwaddr->hwaddr_.size()));
-    } else if (duid) {
-        return (get6(subnet_id, Host::IDENT_DUID, &duid->getDuid()[0],
-                     duid->getDuid().size()));
-    }
-
-    return (ConstHostPtr());
-}
-
 ConstHostPtr
 MySqlHostDataSource::get6(const SubnetID& subnet_id,
                           const Host::IdentifierType& identifier_type,
index d64d3c8d61786879c6c0fcabc82c11843203a4ed..62483dd690f871be90cc446143e2538d216339c7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2018 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
@@ -113,30 +113,6 @@ public:
                       const Host::IdentifierType& identifier_type,
                       const uint8_t* identifier_begin, const size_t identifier_len);
 
-    /// @brief Return all hosts for the specified HW address or DUID.
-    ///
-    /// This method returns all @c Host objects which represent reservations
-    /// for the specified HW address or DUID. Note, that this method may
-    /// return multiple reservations because a particular client may have
-    /// reservations in multiple subnets and the same client may be identified
-    /// by HW address or DUID. The server is unable to verify that the specific
-    /// DUID and HW address belong to the same client, until the client sends
-    /// a DHCP message.
-    ///
-    /// Specifying both hardware address and DUID is allowed for this method
-    /// and results in returning all objects that are associated with hardware
-    /// address OR duid. For example: if one host is associated with the
-    /// specified hardware address and another host is associated with the
-    /// specified DUID, two hosts will be returned.
-    ///
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
-    ///
-    /// @return Collection of const @c Host objects.
-    virtual ConstHostCollection
-    getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
-
     /// @brief Return all hosts connected to any subnet for which reservations
     /// have been made using a specified identifier.
     ///
@@ -165,24 +141,6 @@ public:
     virtual ConstHostCollection
     getAll4(const asiolink::IOAddress& address) const;
 
-    /// @brief Returns a host connected to the IPv4 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @c Host are present, e.g. when two
-    /// @c Host objects are found, one for the DUID, another one for the
-    /// HW address. In such case, an implementation of this method
-    /// should throw an MultipleRecords exception.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-         const DuidPtr& duid = DuidPtr()) const;
-
     /// @brief Returns a host connected to the IPv4 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -216,24 +174,6 @@ public:
     virtual ConstHostPtr
     get4(const SubnetID& subnet_id, const asiolink::IOAddress& address) const;
 
-    /// @brief Returns a host connected to the IPv6 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @c Host are present, e.g. when two
-    /// @c Host objects are found, one for the DUID, another one for the
-    /// HW address. In such case, an implementation of this method
-    /// should throw an MultipleRecords exception.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid DUID or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get6(const SubnetID& subnet_id, const DuidPtr& duid,
-            const HWAddrPtr& hwaddr = HWAddrPtr()) const;
-
     /// @brief Returns a host connected to the IPv6 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -253,7 +193,7 @@ public:
     /// @param prefix IPv6 prefix for which the @c Host object is searched.
     /// @param prefix_len IPv6 prefix length.
     ///
-    /// @return Const @c Host object using a specified HW address or DUID.
+    /// @return Const @c Host object using a specified IPv6 prefix.
     virtual ConstHostPtr
     get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const;
 
index ae632ef22bb57c52a85f74c3308b77d2e790f3ed..243c759d04060f2eade1375d4b44421d43168bc7 100644 (file)
@@ -2036,23 +2036,6 @@ PgSqlHostDataSource::del6(const SubnetID& subnet_id,
                                 bind_array));
 }
 
-ConstHostCollection
-PgSqlHostDataSource::getAll(const HWAddrPtr& hwaddr,
-                            const DuidPtr& duid) const {
-
-    if (duid){
-        return (getAll(Host::IDENT_DUID, &duid->getDuid()[0],
-                       duid->getDuid().size()));
-
-    } else if (hwaddr) {
-        return (getAll(Host::IDENT_HWADDR,
-                       &hwaddr->hwaddr_[0],
-                       hwaddr->hwaddr_.size()));
-    }
-
-    return (ConstHostCollection());
-}
-
 ConstHostCollection
 PgSqlHostDataSource::getAll(const Host::IdentifierType& identifier_type,
                             const uint8_t* identifier_begin,
@@ -2089,33 +2072,6 @@ PgSqlHostDataSource::getAll4(const asiolink::IOAddress& address) const {
     return (result);
 }
 
-ConstHostPtr
-PgSqlHostDataSource::get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-                          const DuidPtr& duid) const {
-
-    /// @todo: Rethink the logic in BaseHostDataSource::get4(subnet, hwaddr, duid)
-    if (hwaddr && duid) {
-        isc_throw(BadValue, "PgSQL host data source get4() called with both"
-                  " hwaddr and duid, only one of them is allowed");
-    }
-    if (!hwaddr && !duid) {
-        isc_throw(BadValue, "PgSQL host data source get4() called with "
-                  "neither hwaddr or duid specified, one of them is required");
-    }
-
-    // Choosing one of the identifiers
-    if (hwaddr) {
-        return (get4(subnet_id, Host::IDENT_HWADDR, &hwaddr->hwaddr_[0],
-                     hwaddr->hwaddr_.size()));
-
-    } else if (duid) {
-        return (get4(subnet_id, Host::IDENT_DUID, &duid->getDuid()[0],
-                     duid->getDuid().size()));
-    }
-
-    return (ConstHostPtr());
-}
-
 ConstHostPtr
 PgSqlHostDataSource::get4(const SubnetID& subnet_id,
                           const Host::IdentifierType& identifier_type,
@@ -2158,32 +2114,6 @@ PgSqlHostDataSource::get4(const SubnetID& subnet_id,
     return (result);
 }
 
-ConstHostPtr
-PgSqlHostDataSource::get6(const SubnetID& subnet_id, const DuidPtr& duid,
-                          const HWAddrPtr& hwaddr) const {
-
-    /// @todo: Rethink the logic in BaseHostDataSource::get6(subnet, hwaddr, duid)
-    if (hwaddr && duid) {
-        isc_throw(BadValue, "PgSQL host data source get6() called with both"
-                  " hwaddr and duid, only one of them is allowed");
-    }
-    if (!hwaddr && !duid) {
-        isc_throw(BadValue, "PgSQL host data source get6() called with "
-                  "neither hwaddr or duid specified, one of them is required");
-    }
-
-    // Choosing one of the identifiers
-    if (hwaddr) {
-        return (get6(subnet_id, Host::IDENT_HWADDR, &hwaddr->hwaddr_[0],
-                     hwaddr->hwaddr_.size()));
-    } else if (duid) {
-        return (get6(subnet_id, Host::IDENT_DUID, &duid->getDuid()[0],
-                     duid->getDuid().size()));
-    }
-
-    return (ConstHostPtr());
-}
-
 ConstHostPtr
 PgSqlHostDataSource::get6(const SubnetID& subnet_id,
                           const Host::IdentifierType& identifier_type,
index 5a270b449cadd75d66540d42bf1153bbb721ed31..93f1be4a8a38553cc533bc330e95676d158cca72 100644 (file)
@@ -141,30 +141,6 @@ public:
                       const Host::IdentifierType& identifier_type,
                       const uint8_t* identifier_begin, const size_t identifier_len);
 
-    /// @brief Return all hosts for the specified HW address or DUID.
-    ///
-    /// This method returns all @c Host objects which represent reservations
-    /// for the specified HW address or DUID. Note, that this method may
-    /// return multiple reservations because a particular client may have
-    /// reservations in multiple subnets and the same client may be identified
-    /// by HW address or DUID. The server is unable to verify that the specific
-    /// DUID and HW address belong to the same client, until the client sends
-    /// a DHCP message.
-    ///
-    /// Specifying both hardware address and DUID is allowed for this method
-    /// and results in returning all objects that are associated with hardware
-    /// address OR duid. For example: if one host is associated with the
-    /// specified hardware address and another host is associated with the
-    /// specified DUID, two hosts will be returned.
-    ///
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
-    ///
-    /// @return Collection of const @c Host objects.
-    virtual ConstHostCollection
-    getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
-
     /// @brief Return all hosts connected to any subnet for which reservations
     /// have been made using a specified identifier.
     ///
@@ -193,24 +169,6 @@ public:
     virtual ConstHostCollection
     getAll4(const asiolink::IOAddress& address) const;
 
-    /// @brief Returns a host connected to the IPv4 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @c Host are present, e.g. when two
-    /// @c Host objects are found, one for the DUID, another one for the
-    /// HW address. In such case, an implementation of this method
-    /// should throw an MultipleRecords exception.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-         const DuidPtr& duid = DuidPtr()) const;
-
     /// @brief Returns a host connected to the IPv4 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -242,24 +200,6 @@ public:
     virtual ConstHostPtr
     get4(const SubnetID& subnet_id, const asiolink::IOAddress& address) const;
 
-    /// @brief Returns a host connected to the IPv6 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @c Host are present, e.g. when two
-    /// @c Host objects are found, one for the DUID, another one for the
-    /// HW address. In such case, an implementation of this method
-    /// should throw an MultipleRecords exception.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid DUID or NULL if not available.
-    ///
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get6(const SubnetID& subnet_id, const DuidPtr& duid,
-            const HWAddrPtr& hwaddr = HWAddrPtr()) const;
-
     /// @brief Returns a host connected to the IPv6 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -279,7 +219,7 @@ public:
     /// @param prefix IPv6 prefix for which the @c Host object is searched.
     /// @param prefix_len IPv6 prefix length.
     ///
-    /// @return Const @c Host object using a specified HW address or DUID.
+    /// @return Const @c Host object using a specified IPv6 prefix.
     virtual ConstHostPtr
     get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const;
 
index 73dc6a4e53f5f85f0b42c2f5b05500bc3f10c2ca..2496048e9ce6bae69be20e4b85809d935fed06f6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 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
@@ -175,30 +175,34 @@ TEST_F(CfgHostsTest, getAllRepeatingHosts) {
 
     // Verify that hosts can be retrieved.
     for (unsigned i = 0; i < 25; ++i) {
-        // Get host by HW address. The DUID is non-null but the reservation
-        // should be returned for the HW address because there are no
-        // reservations for the DUIDs from the range of 25 to 49.
-        HostCollection hosts = cfg.getAll(hwaddrs_[i], duids_[i + 25]);
+        // Get host by HW address.
+        HostCollection hosts = cfg.getAll(Host::IDENT_HWADDR,
+                                          &hwaddrs_[i]->hwaddr_[0],
+                                          hwaddrs_[i]->hwaddr_.size());
         ASSERT_EQ(2, hosts.size());
         EXPECT_EQ(1, hosts[0]->getIPv4SubnetID());
         EXPECT_EQ(addressesa_[i], hosts[0]->getIPv4Reservation().toText());
         EXPECT_EQ(2, hosts[1]->getIPv4SubnetID());
         EXPECT_EQ(addressesb_[i], hosts[1]->getIPv4Reservation().toText());
 
-        // Get host by DUID. The HW address is non-null but the reservation
-        // should be returned for the DUID because there are no
-        // reservations for the HW addresses from the range of 25 to 49.
-        hosts = cfg.getAll(hwaddrs_[i + 25], duids_[i]);
-        ASSERT_EQ(2, hosts.size());
-        EXPECT_EQ(1, hosts[0]->getIPv4SubnetID());
-        EXPECT_EQ(2, hosts[1]->getIPv4SubnetID());
-    }
+        // The HW address is non-null but there are no reservations
+        // for the HW addresses from the range of 25 to 49.
+        hosts = cfg.getAll(Host::IDENT_HWADDR,
+                           &hwaddrs_[i + 25]->hwaddr_[0],
+                           hwaddrs_[i + 25]->hwaddr_.size());
+        EXPECT_TRUE(hosts.empty());
+
+        // Get host by DUID.
+        hosts = cfg.getAll(Host::IDENT_DUID,
+                           &duids_[i]->getDuid()[0],
+                           duids_[i]->getDuid().size());
 
-    // The getAll function should return empty containers for the HW addresses
-    //  and DUIDs for which the reservations haven't been added.
-    for (int i = 25; i < 50; ++i) {
-        EXPECT_TRUE(cfg.getAll(hwaddrs_[i]).empty());
-        EXPECT_TRUE(cfg.getAll(HWAddrPtr(), duids_[i]).empty());
+        // The DUID is non-null but there are no reservations
+        // for the DUIDs from the range of 25 to 49.
+        hosts = cfg.getAll(Host::IDENT_DUID,
+                           &duids_[i + 25]->getDuid()[0],
+                           duids_[i + 25]->getDuid().size());
+        EXPECT_TRUE(hosts.empty());
     }
 }
 
index c93b2baa5404e9c4dcf7ec94086f8789eed49528..0f589f0db1ed143f01e76b1b4fdf06a67bbc20d4 100644 (file)
@@ -597,10 +597,6 @@ public:
     /// Destructor
     virtual ~TestOneBackend() { }
 
-    ConstHostCollection getAll(const HWAddrPtr&, const DuidPtr&) const {
-        return (getCollection());
-    }
-
     ConstHostCollection getAll(const Host::IdentifierType&, const uint8_t*, 
                                const size_t) const {
         return (getCollection());
@@ -610,11 +606,6 @@ public:
         return (getCollection());
     }
 
-    ConstHostPtr get4(const SubnetID&, const HWAddrPtr&,
-                      const DuidPtr&) const {
-        return (getOne());
-    }
-
     ConstHostPtr get4(const SubnetID&, const Host::IdentifierType&,
                       const uint8_t*, const size_t) const {
         return (getOne());
@@ -624,11 +615,6 @@ public:
         return (getOne());
     }
 
-    ConstHostPtr get6(const SubnetID&, const DuidPtr&,
-                      const HWAddrPtr&) const {
-        return (getOne());
-    }
-
     ConstHostPtr get6(const SubnetID&, const Host::IdentifierType&,
                       const uint8_t*, const size_t) const {
         return (getOne());
@@ -812,11 +798,6 @@ void NegativeCacheTest::testGetAll() {
 
     // Verifies getAll* return a collection with it.
     ConstHostCollection hosts;
-    ASSERT_NO_THROW(hosts =
-        HostMgr::instance().getAll(host->getHWAddress(), DuidPtr()));
-    ASSERT_EQ(1, hosts.size());
-    EXPECT_EQ(host, hosts[0]);
-
     ASSERT_NO_THROW(hosts =
         HostMgr::instance().getAll(host->getIdentifierType(),
                                    &host->getIdentifier()[0],
@@ -848,11 +829,6 @@ void NegativeCacheTest::testGet4() {
 
     // Verifies get4 overloads return a null pointer.
     ConstHostPtr got;
-    ASSERT_NO_THROW(got =
-        HostMgr::instance().get4(host->getIPv4SubnetID(),
-                                 host->getHWAddress(), DuidPtr()));
-    EXPECT_FALSE(got);
-
     ASSERT_NO_THROW(got =
         HostMgr::instance().get4(host->getIPv4SubnetID(),
                                  host->getIdentifierType(),
@@ -899,12 +875,6 @@ void NegativeCacheTest::testGet6() {
 
     // Verifies get6 overloads return a null pointer.
     ConstHostPtr got;
-    ASSERT_NO_THROW(got =
-                    HostMgr::instance().get6(host->getIPv6SubnetID(),
-                                             host->getDuid(),
-                                             HWAddrPtr()));
-    EXPECT_FALSE(got);
-
     ASSERT_NO_THROW(got =
                     HostMgr::instance().get6(host->getIPv6SubnetID(),
                                              host->getIdentifierType(),
index fccec646517abfecdc6af7fa3ae8f36fd8a9cfd5..21ecfceb30f1cafb64a7ba3ca5f7c06ef65ac695 100644 (file)
@@ -210,7 +210,10 @@ void
 HostMgrTest::testGetAll(BaseHostDataSource& data_source1,
                         BaseHostDataSource& data_source2) {
     // Initially, no reservations should be present.
-    ConstHostCollection hosts = HostMgr::instance().getAll(hwaddrs_[0]);
+    ConstHostCollection hosts = 
+        HostMgr::instance().getAll(Host::IDENT_HWADDR,
+                                   &hwaddrs_[1]->hwaddr_[0],
+                                   hwaddrs_[1]->hwaddr_.size());
     ASSERT_TRUE(hosts.empty());
 
     // Add two reservations for the same HW address. They differ by the IP
@@ -293,7 +296,10 @@ HostMgrTest::testGetAll4(BaseHostDataSource& data_source1,
 void
 HostMgrTest::testGet4(BaseHostDataSource& data_source) {
     // Initially, no host should be present.
-    ConstHostPtr host = HostMgr::instance().get4(SubnetID(1), hwaddrs_[0]);
+    ConstHostPtr host =
+        HostMgr::instance().get4(SubnetID(1), Host::IDENT_HWADDR,
+                                 &hwaddrs_[0]->hwaddr_[0],
+                                 hwaddrs_[0]->hwaddr_.size());
     ASSERT_FALSE(host);
 
     // Add new host to the database.
@@ -367,7 +373,10 @@ HostMgrTest::testGet4Any() {
 void
 HostMgrTest::testGet6(BaseHostDataSource& data_source) {
     // Initially, no host should be present.
-    ConstHostPtr host = HostMgr::instance().get6(SubnetID(2), duids_[0]);
+    ConstHostPtr host =
+        HostMgr::instance().get6(SubnetID(2), Host::IDENT_DUID,
+                                 &duids_[0]->getDuid()[0],
+                                 duids_[0]->getDuid().size());
     ASSERT_FALSE(host);
 
     // Add new host to the database.
index 7f8681b23d358fea3d51750f30c85024938b2588..4712450137e02309bcd9b1c8a5d0b0476bd62a22 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 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
@@ -364,8 +364,9 @@ TEST_F(HostReservationParserTest, dhcp4NoHostname) {
     ASSERT_NO_THROW(cfg_hosts->add(host));
 
     HostCollection hosts;
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(HWAddrPtr(), duid_));
-
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_DUID,
+                                              &duid_->getDuid()[0],
+                                              duid_->getDuid().size()));
     ASSERT_EQ(1, hosts.size());
 
     EXPECT_EQ(10, hosts[0]->getIPv4SubnetID());
@@ -404,8 +405,9 @@ TEST_F(HostReservationParserTest, dhcp4ClientClasses) {
     ASSERT_NO_THROW(cfg_hosts->add(host));
 
     HostCollection hosts;
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(hwaddr_));
-
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_HWADDR,
+                                              &hwaddr_->hwaddr_[0],
+                                              hwaddr_->hwaddr_.size()));
     ASSERT_EQ(1, hosts.size());
 
     const ClientClasses& classes = hosts[0]->getClientClasses4();
@@ -555,8 +557,9 @@ TEST_F(HostReservationParserTest, noIPAddress) {
     ASSERT_NO_THROW(cfg_hosts->add(host));
 
     HostCollection hosts;
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(HWAddrPtr(), duid_));
-
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_DUID,
+                                              &duid_->getDuid()[0],
+                                              duid_->getDuid().size()));
     ASSERT_EQ(1, hosts.size());
 
     EXPECT_EQ(10, hosts[0]->getIPv4SubnetID());
@@ -668,8 +671,9 @@ TEST_F(HostReservationParserTest, dhcp6HWaddr) {
     ASSERT_NO_THROW(cfg_hosts->add(host));
 
     HostCollection hosts;
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(hwaddr_, DuidPtr()));
-
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_HWADDR,
+                                              &hwaddr_->hwaddr_[0],
+                                              hwaddr_->hwaddr_.size()));
     ASSERT_EQ(1, hosts.size());
 
     EXPECT_EQ(0, hosts[0]->getIPv4SubnetID());
@@ -737,8 +741,9 @@ TEST_F(HostReservationParserTest, dhcp6DUID) {
     ASSERT_NO_THROW(cfg_hosts->add(host));
 
     HostCollection hosts;
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(HWAddrPtr(), duid_));
-
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_DUID,
+                                              &duid_->getDuid()[0],
+                                              duid_->getDuid().size()));
     ASSERT_EQ(1, hosts.size());
 
     EXPECT_EQ(0, hosts[0]->getIPv4SubnetID());
@@ -817,8 +822,9 @@ TEST_F(HostReservationParserTest, dhcp6NoHostname) {
     ASSERT_NO_THROW(cfg_hosts->add(host));
 
     HostCollection hosts;
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(HWAddrPtr(), duid_));
-
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_DUID,
+                                              &duid_->getDuid()[0],
+                                              duid_->getDuid().size()));
     ASSERT_EQ(1, hosts.size());
 
     EXPECT_EQ(0, hosts[0]->getIPv4SubnetID());
@@ -1028,7 +1034,9 @@ TEST_F(HostReservationParserTest, options4) {
     ASSERT_NO_THROW(cfg_hosts->add(host));
 
     HostCollection hosts;
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(hwaddr_));
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_HWADDR,
+                                              &hwaddr_->hwaddr_[0],
+                                              hwaddr_->hwaddr_.size()));
     ASSERT_EQ(1, hosts.size());
 
     // Retrieve and sanity check name servers.
@@ -1119,7 +1127,9 @@ TEST_F(HostReservationParserTest, options6) {
     ASSERT_NO_THROW(cfg_hosts->add(host));
 
     HostCollection hosts;
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(HWAddrPtr(), duid_));
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_DUID,
+                                              &duid_->getDuid()[0],
+                                              duid_->getDuid().size()));
     ASSERT_EQ(1, hosts.size());
 
     // Retrieve and sanity check DNS servers option.
index 9d9ea64c2b7b645de597a0f340fe893230a478d6..80583aa6e0781b975bcf6b08f7c2c65a670b6d77 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 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
@@ -174,7 +174,9 @@ TEST_F(HostReservationsListParserTest, ipv4Reservations) {
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
 
     // Get the first reservation for the host identified by the HW address.
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(hwaddr_));
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_HWADDR,
+                                              &hwaddr_->hwaddr_[0],
+                                              hwaddr_->hwaddr_.size()));
     ASSERT_EQ(1, hosts.size());
 
     EXPECT_EQ(1, hosts[0]->getIPv4SubnetID());
@@ -183,7 +185,9 @@ TEST_F(HostReservationsListParserTest, ipv4Reservations) {
     EXPECT_EQ("foo.example.com", hosts[0]->getHostname());
 
     // Get the second reservation for the host identified by the DUID.
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(HWAddrPtr(), duid_));
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_DUID,
+                                              &duid_->getDuid()[0],
+                                              duid_->getDuid().size()));
     ASSERT_EQ(1, hosts.size());
 
     EXPECT_EQ(1, hosts[0]->getIPv4SubnetID());
@@ -282,7 +286,9 @@ TEST_F(HostReservationsListParserTest, ipv6Reservations) {
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
 
     // Get the reservation for the host identified by the HW address.
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(hwaddr_));
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_HWADDR,
+                                              &hwaddr_->hwaddr_[0],
+                                              hwaddr_->hwaddr_.size()));
     ASSERT_EQ(1, hosts.size());
 
     // Make sure it belongs to a valid subnet.
@@ -300,7 +306,9 @@ TEST_F(HostReservationsListParserTest, ipv6Reservations) {
     EXPECT_EQ(128, prefixes.first->second.getPrefixLen());
 
     // Validate the second reservation.
-    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(HWAddrPtr(), duid_));
+    ASSERT_NO_THROW(hosts = cfg_hosts->getAll(Host::IDENT_DUID,
+                                              &duid_->getDuid()[0],
+                                              duid_->getDuid().size()));
     ASSERT_EQ(1, hosts.size());
 
     EXPECT_EQ(0, hosts[0]->getIPv4SubnetID());
index 9a58475edf82e1fd78b955e4449bc2cc716c4bfa..2e7ef08ad8f353c48f7c28c8bda332835e4bb6d5 100644 (file)
@@ -1057,16 +1057,10 @@ GenericHostDataSourceTest::testMultipleClientClasses4() {
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv4SubnetID();
 
-    // Fetch the host via:
-    // getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
-    ConstHostCollection hosts_by_id = hdsptr_->getAll(host->getHWAddress());
-    ASSERT_EQ(1, hosts_by_id.size());
-    ASSERT_NO_FATAL_FAILURE(HostDataSourceUtils::compareHosts(host, *hosts_by_id.begin()));
-
     // Fetch the host via:
     // getAll(const Host::IdentifierType, const uint8_t* identifier_begin,
     //       const size_t identifier_len) const;
-    hosts_by_id =
+    ConstHostCollection hosts_by_id =
         hdsptr_->getAll(host->getIdentifierType(), &host->getIdentifier()[0],
                         host->getIdentifier().size());
     ASSERT_EQ(1, hosts_by_id.size());
@@ -1078,18 +1072,11 @@ GenericHostDataSourceTest::testMultipleClientClasses4() {
     ASSERT_EQ(1, hosts_by_id.size());
     ASSERT_NO_FATAL_FAILURE(HostDataSourceUtils::compareHosts(host, *hosts_by_id.begin()));
 
-    // Fetch the host via
-    // get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-    //     const DuidPtr& duid = DuidPtr()) const;
-    ConstHostPtr from_hds = hdsptr_->get4(subnet_id, host->getHWAddress());
-    ASSERT_TRUE(from_hds);
-    ASSERT_NO_FATAL_FAILURE(HostDataSourceUtils::compareHosts(host, from_hds));
-
     // Fetch the host via
     // get4(const SubnetID& subnet_id, const Host::IdentifierType&
     // identifier_type,
     //     const uint8_t* identifier_begin, const size_t identifier_len) const;
-    from_hds =
+    ConstHostPtr from_hds =
         hdsptr_->get4(subnet_id, host->getIdentifierType(),
                       &host->getIdentifier()[0], host->getIdentifier().size());
     ASSERT_TRUE(from_hds);
@@ -1122,33 +1109,20 @@ GenericHostDataSourceTest::testMultipleClientClasses6() {
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv6SubnetID();
 
-    // Fetch the host via:
-    // getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
-    ConstHostCollection hosts_by_id = hdsptr_->getAll(host->getHWAddress());
-    ASSERT_EQ(1, hosts_by_id.size());
-    ASSERT_NO_FATAL_FAILURE(HostDataSourceUtils::compareHosts(host, *hosts_by_id.begin()));
-
     // getAll(const Host::IdentifierType& identifier_type,
     //        const uint8_t* identifier_begin,
     //        const size_t identifier_len) const;
-    hosts_by_id =
+    ConstHostCollection hosts_by_id =
         hdsptr_->getAll(host->getIdentifierType(), &host->getIdentifier()[0],
                         host->getIdentifier().size());
     ASSERT_EQ(1, hosts_by_id.size());
     ASSERT_NO_FATAL_FAILURE(HostDataSourceUtils::compareHosts(host, *hosts_by_id.begin()));
 
-    // get6(const SubnetID& subnet_id, const DuidPtr& duid,
-    //      const HWAddrPtr& hwaddr = HWAddrPtr()) const;
-    ConstHostPtr from_hds =
-        hdsptr_->get6(subnet_id, DuidPtr(), host->getHWAddress());
-    ASSERT_TRUE(from_hds);
-    ASSERT_NO_FATAL_FAILURE(HostDataSourceUtils::compareHosts(host, from_hds));
-
     // Fetch the host via:
     // get6(const SubnetID& subnet_id, const Host::IdentifierType&
     // identifier_type,
     //     const uint8_t* identifier_begin, const size_t identifier_len) const;
-    from_hds =
+    ConstHostPtr from_hds =
         hdsptr_->get6(subnet_id, Host::IDENT_HWADDR, &host->getIdentifier()[0],
                       host->getIdentifier().size());
     ASSERT_TRUE(from_hds);
@@ -1220,16 +1194,10 @@ GenericHostDataSourceTest::testMessageFields4() {
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv4SubnetID();
 
-    // Fetch the host via:
-    // getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
-    ConstHostCollection hosts_by_id = hdsptr_->getAll(host->getHWAddress());
-    ASSERT_EQ(1, hosts_by_id.size());
-    ASSERT_NO_FATAL_FAILURE(HostDataSourceUtils::compareHosts(host, *hosts_by_id.begin()));
-
     // Fetch the host via:
     // getAll(const Host::IdentifierType, const uint8_t* identifier_begin,
     //       const size_t identifier_len) const;
-    hosts_by_id =
+    ConstHostCollection hosts_by_id =
         hdsptr_->getAll(host->getIdentifierType(), &host->getIdentifier()[0],
                         host->getIdentifier().size());
     ASSERT_EQ(1, hosts_by_id.size());
@@ -1241,18 +1209,11 @@ GenericHostDataSourceTest::testMessageFields4() {
     ASSERT_EQ(1, hosts_by_id.size());
     ASSERT_NO_FATAL_FAILURE(HostDataSourceUtils::compareHosts(host, *hosts_by_id.begin()));
 
-    // Fetch the host via
-    // get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-    //     const DuidPtr& duid = DuidPtr()) const;
-    ConstHostPtr from_hds = hdsptr_->get4(subnet_id, host->getHWAddress());
-    ASSERT_TRUE(from_hds);
-    ASSERT_NO_FATAL_FAILURE(HostDataSourceUtils::compareHosts(host, from_hds));
-
     // Fetch the host via
     // get4(const SubnetID& subnet_id, const Host::IdentifierType&
     // identifier_type,
     //     const uint8_t* identifier_begin, const size_t identifier_len) const;
-    from_hds =
+    ConstHostPtr from_hds =
         hdsptr_->get4(subnet_id, host->getIdentifierType(),
                       &host->getIdentifier()[0], host->getIdentifier().size());
     ASSERT_TRUE(from_hds);
index c83f82839ad3282acc2e3f637fcfcdb44206d17a..9ce958b1697ccffa5033b46c6b66739ed0538559 100644 (file)
@@ -14,12 +14,6 @@ namespace isc {
 namespace dhcp {
 namespace test {
 
-ConstHostCollection
-MemHostDataSource::getAll(const HWAddrPtr& /*hwaddr*/,
-                          const DuidPtr& /*duid*/) const {
-    return (ConstHostCollection());
-}
-
 ConstHostCollection
 MemHostDataSource::getAll(const Host::IdentifierType& /*identifier_type*/,
                           const uint8_t* /*identifier_begin*/,
@@ -32,13 +26,6 @@ MemHostDataSource::getAll4(const asiolink::IOAddress& /*address*/) const {
     return (ConstHostCollection());
 }
 
-ConstHostPtr
-MemHostDataSource::get4(const SubnetID& /*subnet_id*/,
-                        const HWAddrPtr& /*hwaddr*/,
-                        const DuidPtr& /*duid*/) const {
-    return (ConstHostPtr());
-}
-
 ConstHostPtr
 MemHostDataSource::get4(const SubnetID& subnet_id,
                         const Host::IdentifierType& identifier_type,
@@ -97,13 +84,6 @@ MemHostDataSource::get4(const SubnetID& subnet_id,
     return (ConstHostPtr());
 }
 
-ConstHostPtr
-MemHostDataSource::get6(const SubnetID& /*subnet_id*/,
-                        const DuidPtr& /*duid*/,
-                        const HWAddrPtr& /*hwaddr*/) const {
-    return (ConstHostPtr());
-}
-
 ConstHostPtr
 MemHostDataSource::get6(const asiolink::IOAddress& /*prefix*/,
                         const uint8_t /*prefix_len*/) const {
index 906a3630b25ef0cba05cfacbb778a0388a5822a5..d95ba9a28276ea3db77a999cd46f6bcb1e7a6d3f 100644 (file)
@@ -29,19 +29,6 @@ public:
 
     /// BaseHostDataSource methods.
 
-    /// @brief Return all hosts for the specified HW address or DUID.
-    ///
-    /// This may return hosts from multiple subnets.
-    ///
-    /// Currently not implemented.
-    ///
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
-    /// @return Empty collection of const @c Host objects.
-    virtual ConstHostCollection
-    getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
-
     /// @brief Return all hosts connected to any subnet for which reservations
     /// have been made using a specified identifier.
     ///
@@ -68,19 +55,6 @@ public:
     virtual ConstHostCollection
     getAll4(const asiolink::IOAddress& address) const;
 
-    /// @brief Returns a host connected to the IPv4 subnet.
-    ///
-    /// Currently not implemented.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available.
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-         const DuidPtr& duid = DuidPtr()) const;
-
 
     /// @brief Returns a host connected to the IPv4 subnet.
     ///
@@ -107,19 +81,6 @@ public:
     get4(const SubnetID& subnet_id,
          const asiolink::IOAddress& address) const;
 
-    /// @brief Returns a host connected to the IPv6 subnet.
-    ///
-    /// Currently not implemented.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid DUID or NULL if not available.
-    /// @return Const @c Host object using a specified HW address or DUID.
-    virtual ConstHostPtr
-    get6(const SubnetID& subnet_id, const DuidPtr& duid,
-         const HWAddrPtr& hwaddr = HWAddrPtr()) const;
-
     /// @brief Returns a host connected to the IPv6 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -141,7 +102,7 @@ public:
     ///
     /// @param prefix IPv6 prefix for which the @c Host object is searched.
     /// @param prefix_len IPv6 prefix length.
-    /// @return Const @c Host object using a specified HW address or DUID.
+    /// @return Const @c Host object using a specified IPv6 prefix.
     virtual ConstHostPtr
     get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const;
 
index fcdef0791064595e4ad7e84af8fcafdcf04e3a1d..931ed129957e093c06374f18589e85ce78b9bbd4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 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
@@ -24,22 +24,6 @@ public:
     /// @brief Default destructor implementation.
     virtual ~WritableHostDataSource() { }
 
-    /// @brief Non-const version of the @c getAll const method.
-    ///
-    /// Specifying both hardware address and DUID is allowed for this method
-    /// and results in returning all objects that are associated with hardware
-    /// address OR duid. For example: if one host is associated with the
-    /// specified hardware address and another host is associated with the
-    /// specified DUID, two hosts will be returned.
-    ///
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
-    ///
-    /// @return Collection of non-const @c Host objects.
-    virtual HostCollection
-    getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) = 0;
-
     /// @brief Non-const version of the @c getAll const method.
     ///
     /// This method returns all @c Host objects which represent reservations
@@ -68,24 +52,6 @@ public:
     virtual HostCollection
     getAll4(const asiolink::IOAddress& address) = 0;
 
-    /// @brief Returns a host connected to the IPv4 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @c Host are present, e.g. when two
-    /// @c Host objects are found, one for the DUID, another one for the
-    /// HW address. In such case, an implementation of this method
-    /// should throw an exception.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid client id or NULL if not available.
-    ///
-    /// @return Non-const @c Host object using a specified HW address or DUID.
-    virtual HostPtr
-    get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
-         const DuidPtr& duid = DuidPtr()) = 0;
-
     /// @brief Returns a host connected to the IPv4 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -100,24 +66,6 @@ public:
     get4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
          const uint8_t* identifier_begin, const size_t identifier_len) = 0;
 
-    /// @brief Returns a host connected to the IPv6 subnet.
-    ///
-    /// Implementations of this method should guard against the case when
-    /// multiple instances of the @c Host are present, e.g. when two
-    /// @c Host objects are found, one for the DUID, another one for the
-    /// HW address. In such case, an implementation of this method
-    /// should throw an exception.
-    ///
-    /// @param subnet_id Subnet identifier.
-    /// @param hwaddr HW address of the client or NULL if no HW address
-    /// available.
-    /// @param duid DUID or NULL if not available.
-    ///
-    /// @return Non-const @c Host object using a specified HW address or DUID.
-    virtual HostPtr
-    get6(const SubnetID& subnet_id, const DuidPtr& duid,
-         const HWAddrPtr& hwaddr = HWAddrPtr()) = 0;
-
     /// @brief Returns a host connected to the IPv6 subnet.
     ///
     /// @param subnet_id Subnet identifier.
@@ -137,7 +85,7 @@ public:
     /// @param prefix IPv6 prefix for which the @c Host object is searched.
     /// @param prefix_len IPv6 prefix length.
     ///
-    /// @return Non-const @c Host object using a specified HW address or DUID.
+    /// @return Non-const @c Host object using a specified IPv6 prefix.
     virtual HostPtr
     get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) = 0;