return (IOAddress::fromBytes(addr.getFamily(), &packed[0]));
}
-std::size_t
+size_t
hash_value(const IOAddress& address) {
- boost::hash<std::vector<uint8_t> > hasher;
- return (hasher(address.toBytes()));
+ 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
/// \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.
-std::size_t hash_value(const IOAddress& address);
+size_t hash_value(const IOAddress& address);
} // namespace asiolink
} // namespace isc