]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1283] Restored (fixed) patch
authorFrancis Dupont <fdupont@isc.org>
Fri, 24 Jul 2020 13:35:38 +0000 (15:35 +0200)
committerTomek Mrugalski <tomek@isc.org>
Mon, 27 Jul 2020 09:50:58 +0000 (09:50 +0000)
m4macros/ax_boost_for_kea.m4
src/lib/asiolink/io_address.cc
src/lib/asiolink/io_address.h

index 3b2ac8bd1d85e69bd83c8dd7d709d6b274f6b2a1..ebb6a61dbfa41ebbec027ee7b32dec37bc96b80e 100644 (file)
@@ -74,7 +74,7 @@ if test "${boost_include_path}" ; then
        BOOST_INCLUDES="-isystem ${boost_include_path}"
        CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES"
 fi
-AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/foreach.hpp boost/interprocess/sync/interprocess_upgradable_mutex.hpp boost/date_time/posix_time/posix_time_types.hpp boost/bind.hpp boost/function.hpp boost/asio.hpp boost/asio/ip/address.hpp boost/asio/signal_set.hpp boost/system/error_code.hpp boost/atomic.hpp boost/circular_buffer.hpp],,
+AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/foreach.hpp boost/interprocess/sync/interprocess_upgradable_mutex.hpp boost/date_time/posix_time/posix_time_types.hpp boost/bind.hpp boost/function.hpp boost/asio.hpp boost/asio/ip/address.hpp boost/asio/signal_set.hpp boost/system/error_code.hpp boost/atomic.hpp boost/circular_buffer.hpp boost/functional/hash.hpp],,
   AC_MSG_ERROR([Missing required header files.]))
 
 AC_CHECK_HEADERS(boost/asio/coroutine.hpp,,AC_MSG_RESULT(not found, using built-in header.))
index dae8074066655b75ed10e8016e75475e067c91d6..97a73fd2dd19c0a2e69f77b2b5b5e828b3530c63 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-2020 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,6 +11,8 @@
 #include <exceptions/exceptions.h>
 
 #include <boost/static_assert.hpp>
+// moved to container_hash on recent boost versions
+#include <boost/functional/hash.hpp>
 
 #include <unistd.h>             // for some IPC/network system calls
 #include <stdint.h>
@@ -172,6 +174,16 @@ 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
index bb2ce692d83c8118ab8a9bfb4fb06c787251c0fd..fb1d67b3ea4d462dcec472b3085f4cd16a56ee34 100644 (file)
@@ -302,6 +302,17 @@ 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