Commit d55f941e authored by Francis Dupont's avatar Francis Dupont

[#1283] Restored and fixed

parent 8c02c0e5
// 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
......@@ -174,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
......@@ -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
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