Skip to content

Incorrect output for /32 #2

@freb

Description

@freb

/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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions