コード例 #1
0
        public static string CheckSpecDiaps(string IP)
        {
            int uip = IPConverter.IPToInt32(IP);

            for (int i = 0; i < SpecList.GetLength(0); i++)
            {
                int    start = IPConverter.IPToInt32(SpecList[i, 0]);
                int    end   = IPConverter.IPToInt32(SpecList[i, 1]);
                string desr  = SpecList[i, 2];

                if (uip >= start && uip <= end)
                {
                    return(desr);
                }
            }

            return(string.Empty);
        }
コード例 #2
0
        private void btnCheck_Click(object sender, EventArgs e)
        {
            string IP   = txtIP.Text.Trim();
            string Info = string.Empty;
            string NF   = string.Empty;

            if (!IPConverter.IsIP(IP))
            {
                MessageBox.Show(IP + " not IP address", "Information",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            NF = IPConverter.ToStandForm(IP);
            if (IP != NF)
            {
                Info = Info + "IP address: " + NF + "\n";
                Info = Info + "Input: " + IP + "\n";
            }
            else
            {
                Info = Info + "IP address: " + IP + "\n";
            }

            string Result = DiapasonsChecker.CheckSpecDiaps(IP);

            if (Result == string.Empty)
            {
                Info = Info + "Not in reserved diapason.";
            }
            else
            {
                Info = Info + Result;
            }

            MessageBox.Show(Info, "Information",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }