Commit b572b4aa authored by Michal Nowikowski's avatar Michal Nowikowski

Revert [#1283]

This reverts commit d30af02c
and 392d1e59.
parent e8779187
// Copyright (C) 2010-2020 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2010-2016 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
......@@ -11,7 +11,6 @@
#include <exceptions/exceptions.h>
#include <boost/static_assert.hpp>
#include <boost/container_hash/hash.hpp>
#include <unistd.h> // for some IPC/network system calls
#include <stdint.h>
......@@ -173,16 +172,6 @@ IOAddress::increase(const IOAddress& addr) {
return (IOAddress::fromBytes(addr.getFamily(), &packed[0]));
}
size_t
hash_value(const IOAddress& address) {
if (address.isV4()) {
boost::hash<uint32_t> hasher;
return (hasher(address.toUint32()));
} else {
boost::hash<std::vector<uint8_t> > hasher;
return (hasher(address.toBytes()));
}
}
} // namespace asiolink
} // namespace isc
......@@ -302,17 +302,6 @@ private:
std::ostream&
operator<<(std::ostream& os, const IOAddress& address);
/// \brief Hash the IOAddress.
///
/// This method allows boost multi-index hashed indexes on IOAddresses.
/// It follows the requirement with equality: if two addresses are equal
/// their hashes are equal, if two addresses are not equal their hashes
/// are almost surely not equal.
///
/// \param address A \c IOAddress to hash.
/// \return The hash of the IOAddress.
size_t hash_value(const IOAddress& address);
} // namespace asiolink
} // namespace isc
#endif // IO_ADDRESS_H
// Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......@@ -339,14 +339,3 @@ TEST(IOAddressTest, increaseAddr) {
EXPECT_EQ(IOAddress("::1"), IOAddress::increase(any6));
EXPECT_EQ(IOAddress("::"), IOAddress::increase(the_last_one));
}
// Test verifies the hash function is sane.
TEST(IOAddressTest, hash) {
size_t hash1 = hash_value(IOAddress("192.0.2.1"));
size_t hash2 = hash_value(IOAddress("192.0.2.2"));
EXPECT_NE(hash1, hash2);
hash1 = hash_value(IOAddress("2001:db8::12"));
hash2 = hash_value(IOAddress("2001:db8::1234"));
EXPECT_NE(hash1, hash2);
}
......@@ -243,7 +243,7 @@ typedef boost::multi_index_container<
>,
// Fourth index allows for access by server identifier specified for the
// network.
boost::multi_index::hashed_non_unique<
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<SharedNetworkServerIdIndexTag>,
boost::multi_index::const_mem_fun<Network4, asiolink::IOAddress,
&Network4::getServerId>
......
......@@ -16,9 +16,8 @@
#include <dhcpsrv/pool.h>
#include <dhcpsrv/subnet_id.h>
#include <dhcpsrv/triplet.h>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/indexed_by.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/indexed_by.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/random_access_index.hpp>
#include <boost/multi_index_container.hpp>
......@@ -862,7 +861,7 @@ typedef boost::multi_index_container<
>,
// Fourth index allows for searching using an output from getServerId.
boost::multi_index::hashed_non_unique<
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<SubnetServerIdIndexTag>,
boost::multi_index::const_mem_fun<Network4, asiolink::IOAddress,
&Network4::getServerId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment