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

toInetAddress() question #15

Closed
tapir opened this issue Jan 8, 2019 · 2 comments
Closed

toInetAddress() question #15

tapir opened this issue Jan 8, 2019 · 2 comments

Comments

@tapir
Copy link

tapir commented Jan 8, 2019

I'm trying this

import inet.ipaddr.*;

public class MyClass {
    public static void main(String args[]) {
        try {
            IPAddress addr = new IPAddressString("::/0").toAddress();
            System.out.println(addr.getNetworkPrefixLength());
            System.out.println(addr.toInetAddress().getHostAddress());
        } catch(Exception e) {
            System.out.println(e);
        }
    }
}

which gives

0
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

But according to documentation toInetAddress() should give the lowest of the range which I suppose should be 0:0:0:0:0:0:0:0 no?

I have no idea about CIDR and IP in general so If I'm mistaken apologies in advance.

@seancfoley
Copy link
Owner

seancfoley commented Jan 8, 2019

You're right, that's a bug with toInetAddress(). Will fix very shortly. As a workaround, you can do:

addr.getLower().toInetAddress().getHostAddress()

@seancfoley
Copy link
Owner

This is fixed in release 5.0.2, which is in maven central repo

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