You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2013/12/06 20:53:37 UTC

[jira] [Resolved] (NET-513) [patch attached]SubnetUtils.SubnetInfo.getAllAddresses() Doesn't return all addresses

     [ https://issues.apache.org/jira/browse/NET-513?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved NET-513.
----------------------

    Resolution: Invalid

Note that the addresses returned by SubnetInfo depend on the setting of isInclusiveHostCount.

If this is false, then the network and broadcast addresses are not returned.
This is by design.

> [patch attached]SubnetUtils.SubnetInfo.getAllAddresses() Doesn't return all addresses
> -------------------------------------------------------------------------------------
>
>                 Key: NET-513
>                 URL: https://issues.apache.org/jira/browse/NET-513
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 3.3
>            Reporter: akash kushwaha
>              Labels: easyfix, patch
>
> SubnetInfo.getAllAddresses() Doesn't return all addresses, but return all but 2 addresses.
> Fixing code at following lines worked for me.
> 	        private int low()           { return network() ; }
> 	        private int high()          { return broadcast() ; }
> public int getAddressCount()                { return (broadcast() - low() + 1); }
> 	            //j < addresses.length added as for loop will run infinitely when high is Integer.MAX_VALUE test case: 127.0.0.0/8
> 	            for (int add = low(), j=0; add <= high() && j < addresses.length; ++add, ++j) {



--
This message was sent by Atlassian JIRA
(v6.1#6144)