Beispiel #1
0
        /*
         * Returns the number of default gateways
         * in the routing table. Default gateways
         * have destination IPs of 0.0.0.0.
         */
        public static int DiagnoseMultipleDefaultGateways(IPForwardTable routingTable)
        {
            int defaultGateways = 0;

            foreach (IPFORWARDROW forwardRow in routingTable.Table)
            {
                if (forwardRow.dwForwardDest == 0)
                {
                    ++defaultGateways;
                }
            }

            return(defaultGateways);
        }
Beispiel #2
0
        private bool RunAutomaticDiagnoses()
        {
            bool issuesDetected = false;

            NetworkInterface wifiAdapter  = Diagnosis.GetAdapter("Wi-Fi");
            IPForwardTable   routingTable = Diagnosis.GetIPForwardTable();
            IPAddress        localIP      = Diagnosis.GetLocalIP();

            if (wifiAdapter == null)
            {
                string message =
                    "Detected: Failed to get the wi-fi adapter.\n\n" +
                    "The interface may be offline or nonexistant.\n\n" +
                    "In the main dialog, choose \"Manage Network Adapters\"" +
                    "and ensure the adapter named \"Wi-Fi\" exists, and is enabled.\n\n" +
                    "If the problem persists, create a report to send\n" +
                    "to your support staff by choosing \"Generate Text Report.\"";

                MessageBox.Show(message, "HD Diagnostic Utility");

                //if we can't get the interface, there's not
                //much other diagnosis we can do
                return(true);
            }

            if (Diagnosis.DiagnoseDHCPDisabled(wifiAdapter))
            {
                string message =
                    "Detected: DHCP is disabled.\n\n" +
                    "In the main dialog, choose \"Enable DHCP\" under\n" +
                    "\"Troubleshooting Options.\"\n" +
                    "If the problem persists, try choosing Automatic Diagnosis\n" +
                    "again.\n\n" +
                    "If the problem still persists, create a report to send\n" +
                    "to your support staff by choosing \"Generate Text Report.\"";

                MessageBox.Show(message, "HD Diagnostic Utility");

                //DHCP should be enabled
                //before we attempt to solve other problems
                return(true);
            }

            if (Diagnosis.DiagnoseIllegalDNSServers(wifiAdapter))
            {
                string message =
                    "Detected: DNS servers are not set to be automatically acquired.\n\n" +
                    "In the main dialog, choose \"Reset DNS Servers\" under\n" +
                    "\"Troubleshooting Options.\"";

                MessageBox.Show(message, "HD Diagnostic Utility");

                issuesDetected = true;
            }

            int defaultGateways = Diagnosis.DiagnoseMultipleDefaultGateways(routingTable);

            if (defaultGateways == 0)
            {
                string message =
                    "Detected: There is no default gateway in the IP routing table.\n\n" +
                    "Create a report to send to your support staff\n" +
                    "by choosing \"Generate Text Report.\" in the main dialog.";

                MessageBox.Show(message, "HD Diagnostic Utility");

                issuesDetected = true;
            }
            else if (defaultGateways > 1)
            {
                string message =
                    "Detected: There are multiple default gateways in the IP routing table.\n\n" +
                    "There may be more than one active network interface.\n" +
                    "When more than one network interface is active, Windows\n" +
                    "can become confused and route network traffic incorrectly.\n\n" +
                    "In the main dialog, choose \"Manage Network Adapters\"\n" +
                    "and ensure the only enabled adapter is the \"Wi-Fi\" adapter.\n\n" +
                    "If the problem persists, choose \"Disable Tunnelling\" in\n" +
                    "the main dialog.\n\n" +
                    "If the problem still persists, create a report to send\n" +
                    "to your support staff by choosing \"Generate Text Report.\"";

                MessageBox.Show(message, "HD Diagnostic Utility");

                issuesDetected = true;
            }

            if (localIP == null)
            {
                string message =
                    "Detected: Failed to determine the local IP.\n\n" +
                    "There is no local IP available.\n\n" +
                    "Create a report to send to your support staff\n" +
                    "by choosing \"Generate Text Report.\" in the main dialog.";

                MessageBox.Show(message, "HD Diagnostic Utility");

                issuesDetected = true;
            }
            else if (Diagnosis.DiagnoseLocalIpUnrecognizedRange(localIP))
            {
                string message =
                    "Detected: Local IP is not in a known RPI network range.\n\n" +
                    "Create a report to send to your support staff\n" +
                    "by choosing \"Generate Text Report.\" in the main dialog.";

                MessageBox.Show(message, "HD Diagnostic Utility");

                issuesDetected = true;
            }

            if (Diagnosis.DiagnoseNetBIOSOverTcpip(wifiAdapter))
            {
                string message =
                    "Detected: NetBIOS over TCP/IP is enabled.\n\n" +
                    "In the main dialog, choose \"Disable NetBIOS over TCP/IP.\"\n\n" +
                    "If the problem persists, create a report to send\n" +
                    "to your support staff by choosing \"Generate Text Report.\"";

                MessageBox.Show(message, "HD Diagnostic Utility");

                issuesDetected = true;
            }

            return(issuesDetected);
        }