Ejemplo n.º 1
0
        protected void fillIPCalc()
        {
            if (ip == null || ip.getIp() == null)
            {
                return;
            }
            this.fill = true;

            this.fillComboBox_Prefix();
            this.fillComboBox_NetworkMask();

            // Prefix
            int prefix = ip.getNetworkPrefix();

            if (prefix >= 8 && prefix <= 30)
            {
                if (prefix != ip.getNetworkClassPrefix() && !ip.isFirstSubNetBit())
                {
                    prefix--;
                }
                prefix = prefix - ip.getNetworkClassPrefix();
            }
            else
            {
                prefix = -1;
            }
            prefixComboBox.SelectedIndex = prefix;
            // NetMask
            netMaskComboBox.SelectedIndex = prefix;

            // folgendes nur wenn Netzwerkmaske vorhanden
            // nicht der Fall bei Class-D oder E
            if (prefix != -1)
            {
                // max Net Hosts
                maxCountHosts.Text = ip.getMaxNetworkHosts() + "";
                // Net Class
                calcNetwork.Text = ip.getNetworkClassName();
                // Broadcast
                calcBroadcast.Text = ip.getBroadCast();
                //	Network
                calcNetwork.Text = ip.getNetwork();
                //	Net-Class
                netClassComboBox.SelectedIndex = ip.getNetworkClass();
                // IP-Range
                string [] ipRange = ip.getNetworkIPRange();
                calcIPRange.Text = ipRange[0] + " - " + ipRange[1];
                // max Sub-Nets
                clacMaxNetCount.Text = ip.getMaxSubNets() + "";
            }
            else             // Anzeige löschen
            {
                // max Net Hosts
                maxCountHosts.Text = "";
                // Net Class
                calcNetwork.Text = "";
                // Broadcast
                calcBroadcast.Text = "";
                //	Network
                calcNetwork.Text = "";
                // IP-Range
                calcIPRange.Text = "";
                // max Sub-Nets
                clacMaxNetCount.Text = "";
            }
            // Description
            string desc = "";

            if (ip.get1Byte() >= (byte)64 && ip.getNetworkClass() == (byte)0)                   // 64.
            {
                desc = "reserved for future use";
            }
            if (ip.get1Byte() == (byte)127)             // localhost
            {
                desc = "localhost and loopback-Device - your one computer";
            }
            if (ip.get1Byte() == (byte)10)              // private 10.0.0.0
            {
                desc = "private net - for internal use only, would not be routed in internet";
            }
            if (ip.get1Byte() == (byte)192 && ip.get2Byte() == (byte)168)              // private 192. - 168.
            {
                desc = "private net - for internal use only, would not be routed in internet";
            }
            if (ip.get1Byte() == (byte)172 && (ip.get2Byte() >= (byte)16 && ip.get2Byte() <= (byte)31))                         //private 172.16 - 172.31
            {
                desc = "private net - for internal use only, would not be routed in internet";
            }
            if ((ip.get1Byte() == (byte)169) && (ip.get2Byte() == (byte)254))                           // 169.254.
            {
                desc = "APIPA Automatic Private IP Addressing";
            }
            if (ip.get1Byte() == (byte)0)               // 0.
            {
                desc = "0.0.0.0 = default route";
            }
            if (ip.getNetworkClass() == (byte)4)             // Class-E
            {
                desc = "reserved for future use";
            }
            if (ip.getNetworkClass() == (byte)3)             // Class-D
            {
                desc = "used for multicast";
            }

            noticeLabel.Text = "Info stuff: " + desc;
            this.fill        = false;
        }