Skip to content
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

Incorrect output for /32 #2

Open
freb opened this issue May 31, 2018 · 1 comment
Open

Incorrect output for /32 #2

freb opened this issue May 31, 2018 · 1 comment

Comments

@freb
Copy link

freb commented May 31, 2018

/32 networks (single host) get weird output from some of the calls. Admittedly some of the function calls don't necessarily make sense for /32, but the output doesn't seem to be what one would expect:

sub := ipsubnet.SubnetCalculator("8.8.8.8", "32")
sub.GetNumberIPAddresses() // 0
sub.GetNumberAddressableHosts() // 1
sub.GetIPAddressRange()[0] // 8.8.8.8
sub.GetIPAddressRange()[1] // 263.263.263.263
sub.GetBroadcastAddress() // 263.263.263.263
  • GetNumberIPAddresses: I would think this would return 1 since /32 generally means just a single IP address, though I can see how 0 might result from masking operations.
  • GetNumberAddressableHosts: I'm not sure if this should return 1 or 0, but 1 is probably preferred and is what is currently returned
  • GetIPAddressRange()[1]: This should just return the single IP address. The return value isn't valid
  • GetBroadcastAddress(): I would think this would just return the single IP address as well. The return value isn't valid.
@the-hotmann
Copy link

the-hotmann commented Oct 24, 2022

Noticed the same.
For GetIPAddressRange() I think it should return two values like [8.8.8.8, 8.8.8.8] because otherwise prope ask for second entry and get an error.

But for GetBroadcastAddress() I noticed some weird behaviour:

sub := ipsubnet.SubnetCalculator("192.168.132.197", "32")
sub.GetBroadcastAddress() // 447.423.387.452      THIS IS NOT A VALID IP!

A fix would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants