home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2003-09-16 | 33.7 KB | 1,147 lines
//********************************************************************************** //** //** File Name: sdcnetcheck.js //** //** Summary: SupportSoft Network Utility JavaScript File //** //** Description: This file contains global functions and structures used by //** several pages to check and modify network settings such as //** DHCP, adapters, and IP addresses. //** //** Copyright SupportSoft Inc. 2003, All rights reserved. //** //********************************************************************************** // sdcnetcheck object document.write('<object classid="CLSID:01118400-3e00-11d2-8470-0060089874ed" height="0" width="0" id="netobj"></object>'); //********************************************************************************** // Constants //********************************************************************************** // Pages to go to if a check fails var HREF_FAIL_OS = "fail_os.htm"; var HREF_FAIL_MEMORY = "fail_mem_orig.htm"; var HREF_FAIL_CPU = "fail_cpu.htm"; var HREF_FAIL_DISK_SPACE = "fail_disk.htm"; var HREF_FAIL_NIC = "viewer_nic.htm"; var HREF_FAIL_TCPIP = "viewer_tcpip.htm"; var HREF_FAIL_BRIDGE = "viewer_bridge.htm"; var HREF_FAIL_DISABLED = "viewer_enable.htm"; var HREF_FAIL_IE = "swload.htm"; var HREF_FAIL_OE = "swload.htm"; var HREF_FAIL_CONNECTION = "install.htm"; // Values for network adapter testing. Solution links, status. var gAdapterStatus = ""; var gFix = ""; var FIX_DISABLED = "<a href='" + HREF_FAIL_DISABLED + "'>Solution</a>"; var FIX_DISCONNECTED = "<a href='" + HREF_FAIL_CONNECTION + "'>Solution</a>"; var FIX_DHCP = "<a href='" + HREF_FAIL_NIC + "'>Solution</a>"; var FIX_TCPIP = "<a href='" + HREF_FAIL_TCPIP + "'>Solution</a>"; var FIX_BRIDGED = "<a href='" + HREF_FAIL_BRIDGE + "'>Solution</a>"; var FIX_NIC = "<a href='" + HREF_FAIL_NIC + "'>Solution</a>" var STATUS_NIC_FAILED = "No Network Adapter Found"; var STATUS_DISABLED = "Adapter Disabled"; var STATUS_DHCP_FAILED = "DHCP Disabled"; var STATUS_TCPIP_FAILED = "TCP/IP Not Installed"; var STATUS_BRIDGED = "Adapter Bridged"; // Minimum requirements var MIN_MEMORY = 32; var MIN_CPU = 133; var MIN_DISK_SPACE = 150; var MIN_IE_VERSION = 5.0; var MIN_EMAIL_CLIENT = "Outlook Express"; var MIN_BROWSER_TYPE = "Internet Explorer"; var MIN_PROCESSOR_TYPE = "Pentium"; // Recommended requirements var REC_MEMORY = 64; var REC_CPU = 166; var REC_DISK_SPACE = 150; // Values for testing Internet connections. Used with function ssTestConnect() var TEST_CONNECT_INT_ADD = "supportsoft.adelphia.net"; var TEST_CONNECT_NET = "65.83.242.107"; var TEST_CONNECT_INT_PORT = 80; // Values for POP server testing var TEST_POP_ADD = window.external.GetIniValue("", "SETUP", "pop"); var TEST_POP_PORT = window.external.GetIniValue("", "SETUP", "popport"); // Values for SMTP server testing var TEST_SMTP_DOMAIN = window.external.GetIniValue("", "SETUP", "maildomain"); var TEST_SMTP_ADD = window.external.GetIniValue("", "SETUP", "smtp"); var TEST_SMTP_PORT = window.external.GetIniValue("", "SETUP", "smtpport"); // From value for the test email sent by ssOnCheckSMTP var TEST_SMTP_FROM = ""; // Subject value for the test email sent by ssOnCheckSMTP var TEST_SMTP_SUBJECT = ""; // Body of the test email sent by ssOnCheckSMTP var TEST_SMTP_BODY = ""; // Message for disconnected cable/ethernet card var MSG_DISCONNECTED = "(Network Card Disconnected)"; // Message for disabled cable/ethernet card var MSG_DISABLED = "<b>Warning</b><br>We found your Network Interface Card, but it appears to be disabled. Please go to the Device Manager and enable the adapter under Network Adapters."; // Limit display name of adapter to 40 characters for UI purposes var INT_ADAPTER_NAME_LENGTH = 40; //********************************************************************************** // Arrays //********************************************************************************** // Values will be stored in these arrays for multi-adapter/nic scenarios var arrayDesc = new Array(); var arrayNicSer = new Array(); var arrayDhcp = new Array(); var arrayNicIP = new Array(); var arrayNicStatus = new Array(); var arrayNic98me = new Array(); var arrayNicFix = new Array(); var arrayTcpip = new Array(); // These values are used to filter out virtual adapters on NT only var arrayAdapterFilter = new Array(); arrayAdapterFilter[0] = "bay networks extranet access client adapter"; arrayAdapterFilter[1] = "ppp pptp"; arrayAdapterFilter[2] = "virtual"; arrayAdapterFilter[3] = "dial"; arrayAdapterFilter[4] = "remote access"; arrayAdapterFilter[5] = "ivasion"; arrayAdapterFilter[6] = "winpoet"; arrayAdapterFilter[7] = "vpn"; arrayAdapterFilter[8] = "eacfilt miniport"; arrayAdapterFilter[9] = "nts enternet p.p.p.o.e"; arrayAdapterFilter[10] = "vmware"; arrayAdapterFilter[11] = "wan miniport"; arrayAdapterFilter[12] = "deterministic network enhancer miniport"; arrayAdapterFilter[13] = "internet connection sharing"; arrayAdapterFilter[14] = "ti adsl"; arrayAdapterFilter[15] = "ras async adapter"; arrayAdapterFilter[16] = "direct parallel"; //********************************************************************************** // Global variables //********************************************************************************** var gFreeSpace, gMemory, gCpuCheck, gTcpipImage, gNicImage, gTotalRam, gCPU, gStrNic, gProcessor; var gOpSystem, gFreeSpaceMB, gOSImage, gIEVersion, gIEImage, gOEInstalled, gMinIEInstalled; var gNicIP, gOSGroup; var gDHCP = ""; var gNicFix = ""; var gTcpipFix = ""; var gOsFix = ""; var gIeFix = ""; var gOeFix = ""; var gDiskFix = ""; var gRamFix = ""; var cpuFix = ""; var gProcessorTypeFix = ""; var gProcessorType = ""; var gQueryString = ""; var gDisconnect = ""; var gNicDisabled = false; var gEthernet = ""; var gPresentethernetcards = ""; var gAdaptTypeCount; //********************************************************************************** // Functions //********************************************************************************** //******************************* // Name: ssGetEthernetCards // Purpose: Retrieve the adapters that have been installed // Return: Array //******************************* function ssGetEthernetCards() { try { var mynetcheck = new ActiveXObject("SdcUser.SdcNetCheck.1") //use a clean one each time. var ncards = mynetcheck.GetEthernetCards().split(";"); var ncardz; var ncard; ncardz=[]; for (n in ncards) { ncard = ncards[n].split("="); if (ncard[1]) { ncardz[ncard[0]]=ncard[1]; } } } catch (gec_err) { } return ncardz; } //******************************* // Name: ssGetPresentAdapters // Purpose: Retrieve an array of present ethernet adapters on system // Parameter: Array of all ethernet adapters that have been installed, using ssGetEthernetCards() // Return: Array //******************************* function ssGetPresentAdapters(comparearray) { try { var counter; var mynetcheck = new ActiveXObject("SdcUser.SdcNetCheck.1") //use a clean one each time. present = mynetcheck.GetNetClassDevices().toString().split(";"); rr=""; ispresent=[]; for (r in present) { presentsplit = present[r].split("="); if (presentsplit[0]) { if (comparearray[presentsplit[0]]) { // Check against filter list for virtual adapters on NT only if (ssGetOS() == "nt") { counter = 0; for (i=0; i <= arrayAdapterFilter.length-1; i++) { if (comparearray[presentsplit[0]].toLowerCase().indexOf(arrayAdapterFilter[i].toLowerCase()) != -1) { counter++; } } // Add the adapter to our list if it passes the keyword filtering if (counter == 0) { ispresent[presentsplit[0]]=comparearray[presentsplit[0]]; } } else { ispresent[presentsplit[0]]=comparearray[presentsplit[0]]; } } } } } catch (gpa_err) { } return ispresent; //an array by service name of adapters that are present on the machine. } //******************************* // Name: ssGetPresentAdaptersCount // Purpose: Retrieve the number of present ethernet adapters on system // Parameter: Array of all present ethernet adapters, using ssGetPresentAdapters() // Return: Integer //******************************* function ssGetPresentAdaptersCount(comparearray) { try { var mynetcheck = new ActiveXObject("SdcUser.SdcNetCheck.1") //use a clean one each time. present = mynetcheck.GetNetClassDevices().toString().split(";"); rr=""; ispresent=[]; for (r in present) { presentsplit = present[r].split("="); if (presentsplit[0]) { if (comparearray[presentsplit[0]]) { ispresent[presentsplit[0]]=comparearray[presentsplit[0]]; } } } } catch (gpa_err) { } return presentsplit.length; //an intenger representing the number of adapters that are present on the machine. } //******************************* // Name: ssGetAdapterFromQuery // Purpose: Retrieve adapter index as passed in querystring // Return: Integer //******************************* function ssGetAdapterFromQuery() { var strPage = window.location.href; var arraySplit = strPage.split("="); var adapterValue = arraySplit[1]; return adapterValue; } //******************************* // Name: ssTestConnection // Purpose: Test a network or Internet connection // Parameter: address -- IP Address or name address (like www.yahoo.com) to be tested // port -- integer value of port to be tested // Return: boolean //******************************* function ssTestConnection(address,port) { var netTest = document.netobj.TestConnect(address,port,30000); return netTest; } //******************************* // Name: ssCheckPop // Purpose: Test connection to POP server // Parameter: pop -- address of POP server to test // port -- integer value of port to be tested (like 110) // username -- string // password -- string // Return: boolean //******************************* function ssCheckPop(pop,port,username,password) { var retval = document.netobj.CheckPop(pop,port,username,password); return retval; } //******************************* // Name: ssOnCheckSMTP // Purpose: Test connection to POP server // Parameter: pop -- address of POP server to test // port -- integer value of port to be tested (like 110) // username -- string // password -- string // Return: boolean //******************************* function ssOnCheckSMTP(smtp,port,from,to,subject,body) { var retval = document.netobj.CheckSmtp(smtp,port,from,to,subject,body); return retval; } //******************************* // Name: ssRetestNetwork // Purpose: Resend the page and test with adapter selected in droplist // Parameter: adapter -- Integer index of adapter to be tested //******************************* function ssRetestNetwork(tintAdapter) { window.location.href = ssGetCurrentPage() + "?adapter=" + tintAdapter; } //******************************* // Name: ssSaveAdapterList // Purpose: Loop through each adapter and make a list of adapter names to add to registry for SI use //******************************* function ssSaveAdapterList() { ssGetAllAdapters(); var strAdapterList = ""; for (i=0; i < arrayDesc.length; i++) { strAdapterList += arrayDesc[i]; if (i < arrayDesc.length-1) { strAdapterList += "<br>"; } } ssSetReg("adapters",strAdapterList); return strAdapterList; } //******************************* // Name: ssGetAllAdapters // Purpose: Loop through each adapter and add its attributes to global arrays. // Parameter: name -- Name of the registry value to retrieve // Return: String //******************************* function ssGetAllAdapters() { switch (ssGetOS()) { // Windows 2k, NT and XP // Loop through adapters and make sure all are DHCP enabled case "2000": case "xp": case "nt": var cnt = 0; var count = 0; for (i in gPresentethernetcards) { // Now shake out DHCP, IP and connection status document.netobj.GetAdaptersInfo(""); var count = document.netobj.GetCount(); var j; document.netobj.MoveFirst(); // Set the servicename and description arrayNicSer[cnt] = i; arrayDesc[cnt] = gPresentethernetcards[i]; if (i != "" && document.netobj.GetAdapterStatus(i) == "") { arrayNicStatus[cnt] = document.netobj.GetAdapterStatus(i); arrayDhcp[cnt] = ""; arrayNicIP[cnt] = ""; arrayNicFix[cnt] = "Adapter Disabled"; // Is TCP/IP installed? if (netobj.IsTCPIPBoundToAdapter(arrayNicSer[cnt])) { arrayTcpip[cnt] = true; } else { arrayTcpip[cnt] = false; } } else { // Loop through GetAdapter list (from ipconfig) to find a match for(j = 0; j < count ; j++) { if(document.netobj.GetAttribute("AdapterInfo", "ServiceName") == i) { // Get the values out of the adapter arrayDhcp[cnt] = document.netobj.GetAttribute("AdapterInfo", "DHCPEnabled"); arrayNicStatus[cnt] = document.netobj.GetAdapterStatus(arrayNicSer[cnt]); arrayNicIP[cnt] = document.netobj.GetAttribute("AdapterInfo", "IPAddress"); if (arrayNicStatus[cnt].toLowerCase().indexOf("disconnected") != -1) { arrayNicFix[cnt] = MSG_DISCONNECTED; } else { arrayNicFix[cnt] = ""; } // Is TCP/IP installed? arrayTcpip[cnt] = netobj.IsTCPIPBoundToAdapter(arrayNicSer[cnt]); break; } else { // Check for Network Bridge (XP only) var bridgeValue = window.external.QueryRegValue("HKLM", "System\\CurrentControlSet\\services\\bridge\\linkage", "bind"); if (bridgeValue.indexOf(i) != -1) { arrayDhcp[cnt] = ""; arrayNicStatus[cnt] = "Bridged"; arrayNicIP[cnt] = ""; arrayNicFix[cnt] = "Connection Bridged! <a href='" + HREF_FAIL_BRIDGE + "?adapter=" + cnt + "'>Solution!</a>"; arrayTcpip[cnt] = "Bridged"; } else // not bridged mode, so check whether TCPIP is bound to this adapter { if (netobj.IsTCPIPBoundToAdapter(i)) { // should never get here arrayDhcp[cnt] = ""; arrayNicStatus[cnt] = ""; arrayNicIP[cnt] = ""; arrayNicFix[cnt] = "Unknown Problem"; arrayTcpip[cnt] = "Unknown Problem"; } // TCP/IP is not bound else { arrayDhcp[cnt] = ""; arrayNicStatus[cnt] = ""; arrayNicIP[cnt] = ""; arrayNicFix[cnt] = "<a href='" + HREF_FAIL_TCPIP + "?adapter=" + cnt + "'>Solution!</a>"; arrayTcpip[cnt] = false; } } } document.netobj.MoveNext(); } // end for loop // We have an adapter, but we can't get a count to loop through if (count == 0) { arrayDhcp[cnt] = ""; arrayNicStatus[cnt] = document.netobj.GetAdapterStatus(arrayNicSer[cnt]); arrayNicIP[cnt] = document.netobj.GetAttribute("AdapterInfo", "IPAddress"); // Is TCP/IP installed? if (netobj.IsTCPIPBoundToAdapter(arrayNicSer[cnt])) { arrayTcpip[cnt] = true; } else { arrayTcpip[cnt] = false; } } } cnt = cnt + 1; } break; default : // Windows 95, 98, ME var cnt = 0; // If valid ethernet adapters are found for (i in gPresentethernetcards) { // All we can get for 95, 98, ME is servicename and description. arrayNicSer[cnt] = i; arrayDesc[cnt] = gPresentethernetcards[i]; arrayDhcp[cnt] = ""; arrayNicStatus[cnt] = ""; arrayNicIP[cnt] = ""; arrayNicFix[cnt] = ""; // Is TCP/IP installed? if (netobj.IsTCPIPBoundToAdapter(arrayNicSer[cnt])) { arrayTcpip[cnt] = true; } else { arrayTcpip[cnt] = false; } cnt ++; } } } //******************************* // Name: ssGeneralInfo // Purpose: Gather Network Info and iterate through series of pass/fail tests // Parameter: adapter -- Integer index of adapter to be tested //******************************* function ssGeneralInfo(tintAdapter) { var issueFn = document.si.GetIssueFile(ssGetIssueID()); MemThreshold = MIN_MEMORY; CPUThreshold = MIN_CPU; document.si.StartXMLIO(issueFn); var SystemID = document.si.GetXMLValue('SDC_Connectivity', 'ConnectionData', 'MacID'); gTotalRam = document.si.GetXMLValue("PCH_Sysinfo",SystemID, "RAM"); gCPU = document.si.GetXMLValue("PCH_Sysinfo",SystemID, "ClockSpeed"); gOpSystem = document.si.GetXMLValue("PCH_Sysinfo",SystemID, "OSName"); var processorType = document.si.GetXMLValue("SDC_AdditionalSysInfo", "SDC_AdditionalSysInfo", "ProcessorType"); processorType = processorType.toLowerCase(); gProcessor = processorType; var regex = /_/g; gProcessor = gProcessor.replace(regex," "); if (processorType.indexOf(MIN_PROCESSOR_TYPE.toLowerCase()) != -1) { gProcessorType = gStatusLightGreen; } else { gProcessorType = gStatusLightRed; flagPass = false; gProcessorTypeFix = "<a href='" + HREF_FAIL_CPU + "?adapter=" + tintAdapter + "'>More Info</a>"; } // Write the operating system to the registry ssSetReg("OS",gOpSystem.toLowerCase()); // browser info var defaultbrowser = document.si.GetXMLValue("BrowserInfo","BrowserInfo", "DefaultBrowser"); gIEVersion = document.si.GetXMLValue("BrowserInfo","BrowserInfo", "IEVersion"); gIEVersion = gIEVersion.toLowerCase().substr(0,3); // check all mail clients var mailclients = document.si.GetXMLSections("Mail_Categories"); // var tcpip = nicCount; var disksRaw = new String(document.si.GetXMLSections('Win32_LogicalDisk')); var disks = disksRaw.split(','); // Debug mode if (gdebugOS != "") { gOpSystem = gdebugOS; } // Loop through supported operating systems to see if there is a match if (gOpSystem.toLowerCase().indexOf("windows") != -1 ) { for (i=0; i <= arraySupportedOS.length-1; i++) { var boolOS; if (gOpSystem.toLowerCase().indexOf(arraySupportedOS[i].abName) != -1) { boolOS = true; } } if (boolOS) { gOSImage = gStatusLightGreen; } else { flagPass = false; gOSImage = gStatusLightRed; gOsFix = "<a href='" + HREF_FAIL_OS + "?adapter=" + tintAdapter + "'>More Info</a>"; } } else { flagPass = false; gOsFix = "<a href='" + HREF_FAIL_OS + "?adapter=" + tintAdapter + "'>More Info</a>"; } // Get free disk space for first drive (usually C:) for (i=0; i<1; i++) { var freeSpace = document.si.GetXMLValue('Win32_LogicalDisk', disks[i], 'TotalFreeSpace'); var totalSpace = document.si.GetXMLValue('Win32_LogicalDisk', disks[i], 'TotalCapacity'); var percent = freeSpace*100/totalSpace; var freeSpaceMBtemp = freeSpace/1024; gFreeSpaceMB = Math.round(freeSpaceMBtemp); // Debug mode if (gdebugFreeSpace != "") { gFreeSpaceMB = gdebugFreeSpace; } if (gFreeSpaceMB > MIN_DISK_SPACE) { gFreeSpace = gStatusLightGreen; } else { gFreeSpace = gStatusLightRed; flagPass = false; gDiskFix = "<a href='" + HREF_FAIL_DISK_SPACE + "?adapter=" + tintAdapter + "'>Solution!</a>"; } } // Debug mode if (gdebugRAM != "") { gTotalRam = gdebugRAM; } if (gTotalRam > MemThreshold) { gMemory = gStatusLightGreen; } else { gMemory = gStatusLightRed; flagPass = false; gRamFix = "<a href='" + HREF_FAIL_MEMORY + "?adapter=" + tintAdapter + "'>More Info</a>"; } // Debug mode if (gdebugCPU != "") { gCPU = gdebugCPU; } if (gCPU > CPUThreshold) { gCpuCheck = gStatusLightGreen; } else { gCpuCheck = gStatusLightRed; flagPass = false; cpuFix = "<a href='" + HREF_FAIL_CPU + "?adapter=" + tintAdapter + "'>More Info</a>"; } // Debug mode if (gdebugEmail != "") { mailclients = gdebugEmail; } if (mailclients.toLowerCase().indexOf(MIN_EMAIL_CLIENT.toLowerCase()) != -1 ) { oeimg = gStatusLightGreen; gOEInstalled = "Yes"; } else { oeimg = gStatusLightRed; gOEInstalled = "No"; } // Debug mode if (gdebugIE != "") { gIEVersion = gdebugIE; } if (gIEVersion >= MIN_IE_VERSION ) { gIEImage = gStatusLightGreen; gMinIEInstalled = "Yes"; } else { gIEImage = gStatusLightRed; gMinIEInstalled = "No"; } document.si.EndXMLIO(); } //******************************* // Name: ssEnableDHCP // Purpose: Enable DHCP on a given adapter // Parameter: adapter -- Service Name of adapter to be enabled. Windows 95/98/ME // can pass an empty string since all adapters will be enabled // reboot -- Boolean. True will reboot system after enabling DHCP on 95/98/ME/NT // reload -- Boolean. True will reload the current page after enabling on 2k and XP //******************************* function ssEnableDHCP(adapter,reboot,reload) { document.netobj.EnableDHCP(adapter); // Set the Current User/runonce key to launch SmartAccess on reboot ssSetInstallRestart(); if (ssGetReg("OS").indexOf("2000") != -1 || ssGetReg("OS").indexOf("xp") != -1) { var stopDHCP = window.external.StartDhcp(false); var startDHCP = window.external.StartDhcp(true); var renewIP = window.external.IpConfig(1); if (reload == true) { window.location.reload(); } } else { if (reboot == true) { alert(ALERT_REBOOT); window.external.Reboot(); } } } //******************************* // Name: ssDetectUSB // Purpose: Detect whether there is a USB port available on the computer // Return: String. Yes, No or Unknown //******************************* function ssDetectUSB() { if (ssGetOS() == "98" || ssGetOS() == "me") { var UsbCount = new String(window.external.QueryRegValue("HKLM", "SYSTEM\\CurrentControlSet\\Services\\Class\\USB\\0000", "NTMPDriver")); } else { var UsbCount = new String(window.external.QueryRegValue("HKLM", "SYSTEM\\CurrentControlSet\\Services\\usbhub\\Enum", "Count")); } if (UsbCount == '') { usb = 'Unknown'; } else if (UsbCount == '0') { usb = 'No'; } else { usb = 'Yes'; } return usb; } //******************************* // Name: ssFinalAdapterList // Purpose: List all viable network adapters // Parameter: adapter -- Integer index of adapter to be tested //******************************* function ssFinalAdapterList(tintAdapter) { // Set up parameters for adapter arrays gEthernet = ssGetEthernetCards(); gPresentethernetcards = ssGetPresentAdapters(gEthernet); // Set adapter arrays ssGetAllAdapters(); // Debug mode -- Are there any ethernet cards? var nicCount = arrayDesc.length; if (gdebugNIC != "") { nicCount = gdebugNIC; } // Ethernet Cards if (nicCount > 0) { var counter = 0; // Assign values from arrays nicDesc = arrayDesc[tintAdapter]; nicServiceName = arrayNicSer[tintAdapter]; var selected = ""; var strSize = arrayDesc.length + 1; // build list box of adapters strNic = "<select ID='aSelect' onChange='ssRetestNetwork(this.selectedIndex);' size=" + strSize + " style='width:350px;'>"; for (i=0; i<=arrayDesc.length-1; i++) { if (i == tintAdapter) { selected = "SELECTED"; } // Only show adapter if it matches modem type in registry if (ssAdapterType(arrayDesc[i]) == ssGetReg("ModemType")) { // Limit display name of adapter to 40 characters for UI purposes var displayName = arrayDesc[i]; if (displayName.length > INT_ADAPTER_NAME_LENGTH) { displayName = displayName.slice(0,INT_ADAPTER_NAME_LENGTH) + "..."; } strNic += "<option value='"+arrayNicSer[i]+"' " + selected + ">" + displayName +"</option>"; selected = ""; var indexTcpip = i; gNicImage = gStatusLightGreen; } else { gNicImage = gStatusLightRed; } } strNic += "</select>"; gNicFix = arrayNicFix[tintAdapter]; } else { strNic = "Ethernet Card Not found"; gNicIP = "Not found"; gNicImage = gStatusLightRed; flagPass = false; gNicFix = "<a href='" + HREF_FAIL_NIC + "?adapter=" + tintAdapter + "'>Solution!</a>"; } gDHCP = arrayDhcp[tintAdapter]; // There is an ethernet card, but it might be unplugged if (nicCount > 0) { if (nicCount <= document.netobj.GetCount()) { gNicImage = gStatusLightGreen; } // There is an ethernet card, but it might be disabled else if (!gIsBridged) { // Is TCP/IP installed? If so, we are probably disabled. if (arrayTcpip[tintAdapter] == "Installed" && arrayNicStatus[tintAdapter] != "Connected" && arrayNicStatus[tintAdapter] != "DisConnected" && gOSGroup == "2k") { gNicImage = gStatusLightRed; gNicFix = 'Adapter Disabled! <a href="' + HREF_FAIL_DISABLED + '">Solution!</a>'; gNicDisabled = true; flagPass = false; } else if (arrayNicStatus[tintAdapter] == "DisConnected") { gNicImage = gStatusLightGreen; gNicFix = MSG_DISCONNECTED; gNicDisabled = false; } else { gNicImage = gStatusLightGreen; gNicFix = ''; gNicDisabled = false; } } if (arrayNicStatus[tintAdapter] == "Bridged") { gNicImage = gStatusLightRed; } } else { gNicImage = gStatusLightRed; flagPass = false; if (arrayTcpip[tintAdapter] == "Not Installed") { gNicFix = "<a href='" + HREF_FAIL_TCPIP + "?adapter=" + tintAdapter + "'>Solution!</a>"; } else { gNicFix = "<a href='" + HREF_FAIL_NIC + "?adapter=" + tintAdapter + "'>Solution!</a>"; } } } //******************************* // Name: ssAdapterType // Purpose: Determine whether user has chosen to install on USB or ethernet adapter // Return: usb -- User has chosen USB adapter // ethernet -- User has chosen ethernet adapter //******************************* function ssAdapterType(desc) { var selectedAdapterType; var description = desc.toLowerCase(); var currentUSBAdapters = window.external.GetUsbDeviceList(true); if (description.indexOf("usb") != -1 || currentUSBAdapters.toLowerCase().indexOf(description) != -1) { selectedAdapterType = "usb"; } else { selectedAdapterType = "ethernet"; } return selectedAdapterType; } //******************************* // Name: ssInstalledUSB // Purpose: Determine whether user has any USB adapters installed // Return: boolean //******************************* function ssInstalledUSB() { // Set up parameters for adapter arrays document.netobj.GetAdaptersInfo(""); var count = document.netobj.GetCount(); gEthernet = ssGetEthernetCards(); gPresentethernetcards = ssGetPresentAdapters(gEthernet); // Set adapter arrays ssGetAllAdapters(); gAdaptTypeCount = 0; for (i=0; i < arrayDesc.length; i++) { var adapterDesc = arrayDesc[i]; var adapterType = ssAdapterType(adapterDesc); if (adapterType == "usb") { return true; } } return false; } //******************************* // Name: ssNicTest // Purpose: Check for ethernet adapters // Return: boolean //******************************* function ssNicTest() { var nicCount = arrayDesc.length; if (gdebugNIC != "") { nicCount = gdebugNIC; } if (nicCount < 1) { gAdapterStatus = STATUS_NIC_FAILED; gFix = FIX_NIC; return false; } return true; } //******************************* // Name: ssDhcpTest // Purpose: Check adapter for DHCP // Parameter: adapter -- Integer index of adapter to be tested // Return: boolean //******************************* function ssDhcpTest(tintAdapter) { var status = arrayDhcp[tintAdapter]; if (status.toLowerCase() == "yes") { return true; } else { gAdapterStatus = STATUS_DHCP_FAILED; gFix = FIX_DHCP; return false; } } //******************************* // Name: ssStatusTest // Purpose: Check adapter status - connected, disconnected, etc. If not 2K or XP, we return true // Parameter: adapter -- Integer index of adapter to be tested // Return: boolean //******************************* function ssStatusTest(tintAdapter) { var status = arrayNicStatus[tintAdapter]; if (status.toLowerCase() != "connected" && ssOSGroup() == "2k") { return false; } else { return true; } } //******************************* // Name: ssTcpipTest // Purpose: Check for TCP/IP on specified adapter // Parameter: adapter -- Integer index of adapter to be tested // Return: TCP/IP status //******************************* function ssTcpipTest(tintAdapter) { var status = arrayTcpip[tintAdapter]; if (gdebugTcpip != "") { status = gdebugTcpip; } if (status != true) { gAdapterStatus = STATUS_TCPIP_FAILED; gFix = FIX_TCPIP; return false; } return status; } //******************************* // Name: ssAdapterEnabled // Purpose: Is adapter enabled? 2k, XP, NT model // Parameter: adapter -- Integer index of adapter to be tested // Return: boolean //******************************* function ssAdapterEnabled(tintAdapter) { var status = arrayNicStatus[tintAdapter]; status = status.toLowerCase(); // We have no status, but we do have TCP/IP, so we are probably disabled if (status == "" && ssTcpipTest(tintAdapter) && ssOSGroup() == "2k") { gAdapterStatus = STATUS_DISABLED; gFix = FIX_DISABLED; return false; } if (status == "disconnected") { gAdapterStatus = status; gFix = FIX_DISCONNECTED; return false; } if (status == "bridged") { gAdapterStatus = status; gFix = FIX_BRIDGED; return false; } return true; } //******************************* // Name: ssBridgeTest // Purpose: Check if adapter is bridged. XP only // Parameter: adapter -- Integer index of adapter to be tested // Return: boolean //******************************* function ssBridgeTest(tintAdapter) { // Only check adapter if it matches modem type in registry var adapterDesc = arrayDesc[tintAdapter]; var adapterType = ssAdapterType(adapterDesc); if (adapterType == ssGetReg("ModemType")) { status = arrayNicStatus[tintAdapter]; status = status.toLowerCase(); if (status == "bridged") { gAdapterStatus = STATUS_BRIDGED; gFix = FIX_BRIDGED; return false; } } return true; } //******************************* // Name: ssTestAdapter // Purpose: Run a series of tests on adapter // Parameter: adapter -- Integer index of adapter to be tested // Return: boolean. Returns true if all tests pass //******************************* function ssTestAdapter(tintAdapter) { // Reset adapter status and solution text/link for each adapter // Assume connected until tests prove otherwise gAdapterStatus = "Connected"; gFix = ""; var status = true; if (!ssNicTest()) { return false; } // Check adapter status if (ssOSGroup() == "2k") { if (!ssStatusTest(tintAdapter)) { if (!ssAdapterEnabled(tintAdapter)) { status = false; } } } // Check for a bridge on XP only if (ssGetOS() == "xp") { if (!ssBridgeTest(tintAdapter)) { status = false; } } // Check TCP/IP if (status && !ssTcpipTest(tintAdapter)) { status = false; } return status; }