-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected result with IPv4Address.toSequentialRange method #39
Comments
Hello, To get the subnet is not difficult, just call toPrefixBlock on your address object. val ip = 2130706590
val mask = 24
val ipAdd = new IPv4Address(ip, mask).toPrefixBlock
val ipAdd2 = new IPv4Address(Array(127, 0, 0, 158).map(_.toByte), mask).toPrefixBlock
val ipAdd3 = new IPv4Address(Array(127, 0, 0, 0).map(_.toByte), mask)
println(ipAdd)
println(ipAdd2)
println(ipAdd3)
println(ipAdd.getCount) // subnet size
println(ipAdd2.getCount)
println(ipAdd3.getCount)
val ipRange = ipAdd.toSequentialRange
val ipRange2 = ipAdd.toZeroHost.toSequentialRange(ipAdd.toMaxHost)
if (ipRange != ipRange2) {
println(s"$ipRange not the same as $ipRange2")
} else {
println(s"$ipRange is the same as $ipRange2")
} More details here: https://github.com/seancfoley/IPAddress/wiki/Code-Examples#parse-prefixed-as-subnet-or-ip-address |
That makes sense. Thank you for your explanation. I was confused about it, because the |
The following ip: 127.0.0.158 (2130706590 in Integer form), with a subnet mask of 24.
When i create a range of ips with
toSequentialRange()
i don't get a complete range of ips. I get aIPv4AddressSeqRange
with 1 IP inside it. (127.0.0.158 -> 127.0.0.158), when i expect it to be (127.0.0.0 -> 127.0.0.250), calculated with: http://jodies.de/ipcalc?host=130.225.157.76&mask1=24&mask2=When i create the ip-range with
toZeroHost
andtoMaxHost
the range comes out as expected.Using scala, jdk11, and v5.1.0 or 5.0.2 of this lib.
Code to reproduce:
same thing happens with 194.105.145.69/31 where the range is still just 1 IP, but i expect it to be 194.105.145.68 -> 194.105.145.69. (Again, using
toZeroHost
andtoMaxHost
works)Is this a bug, or is my expectation of
toSequentialRange
wrong?The text was updated successfully, but these errors were encountered: