Esempio n. 1
0
        public void scan(string subnet)
        {
            Ping        ping;
            PingReply   reply;
            IPAddress   address;
            IPHostEntry host;

            for (int i = 1; i < 255; i++)
            {
                string subnetn = "." + i.ToString();
                ping  = new Ping();
                reply = ping.Send(subnet + subnetn);

                if (reply.Status == IPStatus.Success)
                {
                    try
                    {
                        address = IPAddress.Parse(subnet + subnetn);
                        host    = Dns.GetHostEntry(address);

                        IPBox.AppendText(subnet + "\t" + subnetn + "\t" + host.HostName.ToString() + "\t" + "UP\n");
                    }
                    catch
                    {
                    }
                }
            }
        }
Esempio n. 2
0
        public void scan(string subnet)
        {
            Ping        ping;
            PingReply   reply;
            IPAddress   address;
            IPHostEntry host;

            for (int i = 250; i < 255; i++)
            {
                try
                {
                    string subnetn = "." + i.ToString();
                    ping  = new Ping();
                    reply = ping.Send(subnet + subnetn);

                    if (reply.Status == IPStatus.Success)
                    {
                        try
                        {
                            address = IPAddress.Parse(subnet + subnetn);
                            host    = Dns.GetHostEntry(address);

                            IPBox.AppendText(subnet + "\t" + subnetn + "\t" + host.HostName.ToString() + "\t" + "UP\n");
                        }
                        catch
                        {
                        }
                    }
                    if (i < 254)
                    {
                        label1.Text = "Checking " + SubnetBox.Text + "." + i;
                    }
                    else
                    {
                        StopButton.Enabled  = true;
                        StartButton.Enabled = false;
                        SubnetBox.Enabled   = false;
                        SubnetBox.Text      = "";
                        label1.Text         = "Finished";
                    }
                }
                catch
                {
                }
            }
        }
Esempio n. 3
0
        public void scan(string subnet)
        {
            SolidBrush  greenBrush = new SolidBrush(Color.Green);
            Pen         blackPen   = new Pen(Color.Black);
            Font        myFont     = new Font("Arial", 10);
            Ping        ping;
            PingReply   reply;
            IPAddress   address;
            IPHostEntry host;

            nodes[] myNode = new nodes[254];
            MapBox.Visible = false;
            MapBox.Visible = true;
            int coor       = 0;
            int j          = 0;
            int totalNodes = 0;

            for (int i = 1; i <= 255; i++)
            {
                if (i <= 255)
                {
                    label1.Text = "Checking " + SubnetBox.Text + "." + i;
                }
                else
                {
                    StopButton.Enabled  = true;
                    StartButton.Enabled = false;
                    SubnetBox.Enabled   = false;
                    SubnetBox.Text      = "";
                    label1.Text         = "Finished";
                }
                string subnetn = "." + i.ToString();
                ping  = new Ping();
                reply = ping.Send(subnet + subnetn, 10);
                if (i == 1)
                {
                    drawArea.FillEllipse(greenBrush, 150, 85, 25, 25);
                    drawArea.DrawString(subnet + "." + i.ToString(), myFont, Brushes.Black, new Point(125, 90));
                }
                else
                {
                    if (reply.Status == IPStatus.Success)
                    {
                        try
                        {
                            j      += 1;
                            address = IPAddress.Parse(subnet + subnetn);
                            host    = Dns.GetHostEntry(address);
                            IPBox.AppendText(subnet + "\t" + subnetn + "\t" + host.HostName.ToString() + "\n");
                            Form1 form1 = new Form1();
                            myNode[j].ipAddress = subnet + subnetn;
                            myNode[j].hostNamse = host.HostName.ToLower();
                            myNode[j].status    = "UP";
                            drawArea.DrawLine(blackPen, 160, 95, 30 + coor, 60 + coor);
                            drawArea.FillEllipse(greenBrush, 150, 85, 25, 25);
                            drawArea.DrawString("192.168.1.1", myFont, Brushes.Black, new Point(125, 90));
                            drawArea.FillEllipse(greenBrush, 20 + coor, 50 + coor, 25, 25);
                            drawArea.DrawString(subnet + "." + i.ToString(), myFont, Brushes.Black, new Point(20 + coor, 50 + coor));
                            coor += 30;
                        }
                        catch
                        {
                        }
                    }
                }
            }
            StartButton.Enabled = true;
            StopButton.Enabled  = false;
            SubnetBox.Enabled   = true;
            AboutApps.Enabled   = true;
            SubnetBox.Text      = "";
            label1.Text         = "Finished";
            myThread.Abort();
        }