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

IP network mask #27

Closed
mkpaz opened this issue Oct 17, 2019 · 2 comments
Closed

IP network mask #27

mkpaz opened this issue Oct 17, 2019 · 2 comments

Comments

@mkpaz
Copy link

mkpaz commented Oct 17, 2019

Suppose, we have an adress string and ones need to get IPv4 netmask address in octet format.

IPAddress ipv4Address = new IPAddressString("1.2.3.4/24").toAddress();
System.out.println(ipv4Address.getNetwork().getNetworkMask(ipv4Address.getNetworkPrefixLength()));

This code does its work, but it literally requires to specify the network prefix twice. First in the address string and then as arg in getNetworkMask(). Would it be possible to add getNetworkMask() method to IPAddress or inherit prefix length from IPAddress in getNetwork() ?

@seancfoley
Copy link
Owner

Yes, that seems reasonable.

@seancfoley
Copy link
Owner

This has been added to versions 4.3.1 and 5.1.0, getNetworkMask and getHostMask. Also added toZeroNetwork as mentioned in issue #28.

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