示例#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);
        }
示例#2
0
        private void prefixComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (ip == null || ip.getIp() == null || fill)
            {
                return;
            }
            if (ip.getNetworkClassPrefix() == -1)
            {
                return;
            }

            int prefix = Int32.Parse((string)prefixComboBox.SelectedItem);

            ip.setNetworkPrefix(prefix);

            fillIPCalc();
        }