Ejemplo n.º 1
0
        public IPTool getNextSubNet(long numberOfHosts)
        {
            IPTool ip = IPTool.getNextIP(this.getBroadCast());

            ip.setIp(this.long2String(ip.ip2Long() + (long)1));
            ip.setFirstSubNetBit(this.isFirstSubNetBit());

            int lastPrefix = ip.getNetworkClassPrefix();

            int prefix = 30;

            do
            {
                if (prefix < ip.getNetworkClassPrefix())
                {
                    return(null);                    // no subnet found
                }
                ip.setNetworkPrefix(prefix);
                prefix--;
                // ignore subnetbit?
                if (!ip.isFirstSubNetBit() && prefix == lastPrefix + 1)
                {
                    prefix--;
                }
            }while (ip.getMaxNetworkHosts() < numberOfHosts);

            return(ip);
        }
Ejemplo n.º 2
0
        public static IPTool getNextIP(String ip)
        {
            IPTool nextIp = new IPTool(ip);

            nextIp.setIp(nextIp.long2String(nextIp.ip2Long() + (long)1));

            return(nextIp);
        }