Don't skip blocks if suffix size fits

This commit is contained in:
Zoran Rilak
2024-05-29 21:53:36 +02:00
committed by GitHub
parent e3c50e23bd
commit 3177256e4d
@@ -162,9 +162,12 @@ function CalculateNextAddressPrefix {
$startIPAddress = $endIPAddress
}
}
# round up to the next possible start for the given suffix size
$suffixLength = 32 - $prefixLength
$startIPAddress = (($startIPAddress -shr $suffixLength) + 1) -shl $suffixLength
$startIPAddress += 1
# if crossing a block boundary, round to the next possible start for the given suffix size
if (($startIPAddress -shr $prefixLength) -ne 0) {
$suffixLength = 32 - $prefixLength
$startIPAddress = (($startIPAddress -shr $suffixLength) + 1) -shl $suffixLength
}
# convert and return
$addressPrefixResult = (ConvertUInt32ToIPAddress $startIPAddress) + "/" + $prefixLength
Write-Host "Using address prefix $addressPrefixResult." -ForegroundColor Green