summaryrefslogtreecommitdiffstats
path: root/src/lib/asiolink/addr_utilities.h
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2023-04-26 14:45:29 +0200
committerAndrei Pavel <andrei@isc.org>2023-05-17 18:09:38 +0200
commit4a06d2baf0dff1d21948bd9a39f100c94a159fe0 (patch)
tree83c4bce0b946e63e204521806ad0341f747e5f46 /src/lib/asiolink/addr_utilities.h
parent[#2658] add BigIntElement (diff)
downloadkea-4a06d2baf0dff1d21948bd9a39f100c94a159fe0.tar.xz
kea-4a06d2baf0dff1d21948bd9a39f100c94a159fe0.zip
[#2658] add big integer support to statistics
Pool capacities have been promoted in code from uint64_t to uint128_t. Bigint is modelled as an int128_t in statistics, following the precedent of signed integer of int64_t from statistics. - "total-nas" is extended to 128 bits as requested in the issue. - "total-pds" has the same risk of overflowing so it has been extended as well. - "total-addresses" always fits in 64 bits, but certain code forces a 128 bit value on it. See Pool::getCapacity(), Subnet::getPoolCapacity(), Subnet::sumPoolCapacity(). It could have been truncated to a 64 bit value, but that seems like an unnecessary complication. Because of the disparity in signedness there is some truncation that can happen when pool capacity values are passed on to statistics. That only happens for the last half of the value range, so for prefix ranges larger than /1.
Diffstat (limited to 'src/lib/asiolink/addr_utilities.h')
-rw-r--r--src/lib/asiolink/addr_utilities.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/asiolink/addr_utilities.h b/src/lib/asiolink/addr_utilities.h
index bd78deec4c..9aa9af2d10 100644
--- a/src/lib/asiolink/addr_utilities.h
+++ b/src/lib/asiolink/addr_utilities.h
@@ -8,6 +8,7 @@
#define ADDR_UTILITIES_H
#include <asiolink/io_address.h>
+#include <util/bigints.h>
namespace isc {
namespace asiolink {
@@ -54,7 +55,7 @@ IOAddress getNetmask4(uint8_t len);
/// @param min the first address in range
/// @param max the last address in range
/// @return number of addresses in range
-uint64_t addrsInRange(const IOAddress& min, const IOAddress& max);
+isc::util::uint128_t addrsInRange(const IOAddress& min, const IOAddress& max);
/// @brief Returns prefix length from the specified range (min - max).
///
@@ -78,7 +79,7 @@ int prefixLengthFromRange(const IOAddress& min, const IOAddress& max);
/// @param pool_len length of the pool in bits
/// @param delegated_len length of the prefixes to be delegated from the pool
/// @return number of prefixes in range
-uint64_t prefixesInRange(const uint8_t pool_len, const uint8_t delegated_len);
+isc::util::uint128_t prefixesInRange(const uint8_t pool_len, const uint8_t delegated_len);
/// @brief Finds the address increased by offset.
///
@@ -92,7 +93,7 @@ uint64_t prefixesInRange(const uint8_t pool_len, const uint8_t delegated_len);
/// @return address being offset greater than the input address
IOAddress offsetAddress(const IOAddress& addr, uint64_t offset);
-};
-};
+} // namespace asiolink
+} // namespace isc
#endif // ADDR_UTILITIES_H