Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3160 lines
56 KiB

  1. <%@Language=VbScript%>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' nicip_prop.asp : Page gets/sets the IP adresses along with
  6. ' GateWay Addresses
  7. '
  8. ' Copyright (c) Microsoft Corporation. All rights reserved.
  9. '
  10. ' Date Description
  11. ' 06-Mar-2001 Created date
  12. ' 10-Mar-2001 Modified date
  13. '-------------------------------------------------------------------------
  14. %>
  15. <!-- #include virtual="/admin/inc_framework.asp"--->
  16. <!-- #include file="inc_network.asp" -->
  17. <!-- #include file="loc_nicspecific.asp" -->
  18. <%
  19. '-------------------------------------------------------
  20. ' Form Variables
  21. '-------------------------------------------------------
  22. Dim F_strIPAddress ' to hold IP address
  23. Dim F_strSubnetMask ' to hold subnet mask
  24. Dim F_nConnectionMetric ' to hold connection metric
  25. Dim F_strGatewayAddress ' to hold gateway address
  26. Dim F_strListIP ' to hold array of IP
  27. Dim F_strListGateway ' to hold array of Gateway
  28. Dim F_strRadIP ' to hold the radio button selected
  29. '-------------------------------------------------------
  30. ' Global Variables
  31. '-------------------------------------------------------
  32. Dim g_arrIPList ' List of IP Addresses
  33. Dim g_arrGATEWAYList ' List of Gateway Addresses
  34. Dim page ' to hold page object
  35. Dim blnDHCPEnabled ' to hold whether DHCP is enabled or not
  36. Dim g_strDeviceID ' to hold device ID
  37. Dim g_initialIPAddress
  38. Dim SOURCE_FILE
  39. SOURCE_FILE = SA_GetScriptFileName()
  40. Dim g_iTabGeneral ' to hold value of general page
  41. Dim g_iTabAdvanced ' to hold value of Advanced page
  42. Dim g_strTabValue ' to hold value of general tab
  43. Dim g_strAdvTabValue ' to hold value of Advanced tab
  44. Const G_CONST_REGISTRY_PATH ="SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
  45. '-------------------------------------------------------
  46. ' Entry point
  47. '-------------------------------------------------------
  48. ' Create a Property Page
  49. Call SA_CreatePage( L_TASKTITLE_TEXT, "", PT_TABBED, page )
  50. Call SA_AddTabPage(page, L_GENERAL_TEXT, g_iTabGeneral)
  51. Call SA_AddTabPage(page, L_ADVANCED_TEXT, g_iTabAdvanced)
  52. ' Serve the page
  53. Call SA_ShowPage( page )
  54. '-------------------------------------------------------
  55. ' Web Framework Event Handlers
  56. '-------------------------------------------------------
  57. '-------------------------------------------------------------------------
  58. 'Function: OnInitPage()
  59. 'Description: Called to signal first time processing for this page.
  60. ' Use this method to do first time initialization tasks.
  61. 'Input Variables: PageIn,EventArg
  62. 'Output Variables: PageIn,EventArg
  63. 'Returns: TRUE to indicate initialization was successful. FALSE to indicate
  64. ' errors. Returning FALSE will cause the page to be abandoned.
  65. 'Global Variables: None
  66. '-------------------------------------------------------------------------
  67. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  68. Dim itemCount 'holds item count
  69. Dim x 'holds increment count for the loop
  70. Dim itemKey 'holds the item selected from the OTS page
  71. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  72. itemCount = OTS_GetTableSelectionCount("")
  73. For x = 1 to itemCount
  74. If ( OTS_GetTableSelection("", x, itemKey) ) Then
  75. g_strDeviceID = itemKey ' to get the device ID
  76. Exit for
  77. End If
  78. Next
  79. OnInitPage = TRUE
  80. End Function
  81. '-------------------------------------------------------------------------
  82. 'Function: OnServeTabbedPropertyPage
  83. 'Description: Called when the page needs to be served.Use this
  84. ' method to serve content
  85. 'Input Variables: PageIn,EventArg, iTab,bIsVisible
  86. 'Output Variables: PageIn,EventArg
  87. 'Returns: TRUE to indicate not problems occured. FALSE to indicate errors.
  88. ' Returning FALSE will cause the page to be abandoned.
  89. 'Global Variables: SOURCE_FILE, g_*
  90. '-------------------------------------------------------------------------
  91. Public Function OnServeTabbedPropertyPage(ByRef PageIn, _
  92. ByVal iTab, _
  93. ByVal bIsVisible, ByRef EventArg)
  94. Call SA_TraceOut(SOURCE_FILE, "OnServeTabbedPropertyPage")
  95. Select Case iTab
  96. Case g_iTabGeneral
  97. Call ServeTabGeneral(PageIn, bIsVisible)
  98. Case g_iTabAdvanced
  99. Call ServeTabAdvanced(PageIn, bIsVisible)
  100. Case Else
  101. Call SA_TraceErrorOut(SOURCE_FILE, "OnServeTabbedPropertyPage unrecognized tab id: " + CStr(iTab))
  102. End Select
  103. OnServeTabbedPropertyPage = TRUE
  104. End Function
  105. '-------------------------------------------------------------------------
  106. 'Function: OnPostBackPage()
  107. 'Description: Called to signal a post-back. A post-back occurs as the user
  108. ' navigates through pages. This event should be used to save the
  109. ' state of the current page.
  110. 'Input Variables: PageIn,EventArg
  111. 'Output Variables: PageIn,EventArg
  112. 'Returns: True
  113. 'Global Variables: F_*,G_*,g_*
  114. '-------------------------------------------------------------------------
  115. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  116. Call SA_TraceOut(SOURCE_FILE, "OnPostBackPage")
  117. g_strTabValue = Request.Form("hdnGeneralTabValue")
  118. g_strAdvTabValue = Request.Form("hdnAdvancedTabValue")
  119. g_strDeviceID = Request.Form("hdnDeviceID")
  120. g_initialIPAddress = Request.Form("hdnInitialIPValue")
  121. F_strRadIP = Request.Form("hdnRadIP")
  122. F_strListIP = Request.Form("hdnlstIP")
  123. F_strListGateway = Request.Form("hdnlstGATEWAY")
  124. F_strIPAddress = Request.Form("txtIP")
  125. F_strSubnetMask = Request.Form("txtMask")
  126. F_strGatewayAddress = Request.Form("txtGateway")
  127. F_nConnectionMetric = Request.Form("txtConnectionMetric")
  128. OnPostBackPage = TRUE
  129. End Function
  130. '-------------------------------------------------------------------------
  131. 'Function: OnSubmitPage()
  132. 'Description: Called when the page has been submitted for processing.
  133. ' Use this method to process the submit request.
  134. 'Input Variables: PageIn,EventArg
  135. 'Output Variables: PageIn,EventArg
  136. 'Returns: TRUE if the submit was successful, FALSE to indicate error(s).
  137. ' Returning FALSE will cause the page to be served again using
  138. ' a call to OnServeTabbedPropertyPage.
  139. 'Global Variables: F_*, g_*, blnDHCPEnabled,
  140. '-------------------------------------------------------------------------
  141. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  142. Call SA_TraceOut(SOURCE_FILE, "OnSubmitPage")
  143. 'checking whether DHCP is enabled
  144. If Ucase(Request.Form("radIP"))="IPDEFAULT" Then
  145. blnDHCPEnabled = TRUE
  146. Else
  147. blnDHCPEnabled = FALSE
  148. End If
  149. 'Set Individual NIC properties
  150. OnSubmitPage = setNIC()
  151. End Function
  152. '-------------------------------------------------------------------------
  153. 'Function: OnClosePage()
  154. 'Description: Called when the page is about closed.Use this method
  155. ' to perform clean-up processing
  156. 'Input Variables: PageIn,EventArg
  157. 'Output Variables: PageIn,EventArg
  158. 'Returns: TRUE to allow close, FALSE to prevent close. Returning FALSE
  159. ' will result in a call to OnServeTabbedPropertyPage.
  160. 'Global Variables: None
  161. '-------------------------------------------------------------------------
  162. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  163. Call SA_TraceOut(SOURCE_FILE, "OnClosePage")
  164. OnClosePage = TRUE
  165. End Function
  166. '-------------------------------------------------------------------------
  167. 'Function: ServeTabGeneral
  168. 'Description: Called when the general page needs to be served.
  169. 'Input Variables: PageIn,EventArg
  170. 'Output Variables: PageIn,EventArg
  171. 'Returns: SA_NO_ERROR
  172. 'Global Variables: SOURCE_FILE, g_*,F_*
  173. '-------------------------------------------------------------------------
  174. Private Function ServeTabGeneral(ByRef PageIn, ByVal bIsVisible)
  175. Call SA_TraceOut(SOURCE_FILE, "ServeTabGeneral(PageIn, bIsVisible="+ CStr(bIsVisible) + ")")
  176. If ( bIsVisible ) Then
  177. 'call the java script function
  178. Call ServeCommonJavaScript()
  179. Call ServeGeneralTabJavaScript()
  180. 'Serves UI for General tab
  181. Call ServeGeneralUI()
  182. Else
  183. Response.Write("<input type=hidden name=hdnDeviceID value='"+g_strDeviceID +"' >")
  184. Response.Write("<input type=hidden name=hdnGeneralTabValue value='"+g_strTabValue +"' >")
  185. Response.Write("<input type=hidden name=txtIP value='"+F_strIPAddress +"' >")
  186. Response.Write("<input type=hidden name=txtGateway value='"+F_strGatewayAddress +"' >")
  187. Response.Write("<input type=hidden name=txtMask value='"+F_strSubnetMask +"' >")
  188. Response.Write("<input type=hidden name=hdnRadIP value='"+F_strRadIP +"' >")
  189. End If
  190. ServeTabGeneral = SA_NO_ERROR
  191. End Function
  192. '-------------------------------------------------------------------------
  193. 'Function: ServeTabAdvanced
  194. 'Description: Called when the Advanced page needs to be served.
  195. 'Input Variables: PageIn,EventArg
  196. 'Output Variables: PageIn,EventArg
  197. 'Returns: SA_NO_ERROR
  198. 'Global Variables: SOURCE_FILE, g_*,F_*
  199. '-------------------------------------------------------------------------
  200. Private Function ServeTabAdvanced(ByRef PageIn, ByVal bIsVisible)
  201. Call SA_TraceOut(SOURCE_FILE, "ServeTabAdvanced(PageIn, bIsVisible="+ CStr(bIsVisible) + ")")
  202. If ( bIsVisible ) Then
  203. 'Serve common javascript that is required for this page type.
  204. Call ServeCommonJavaScript()
  205. Call ServeAdvancedTabJavaScript()
  206. 'Serve UI for Advanced tab
  207. Call ServeAdvancedUI()
  208. Else
  209. Response.Write("<input type=hidden name=hdnDeviceID value='"+g_strDeviceID +"' >")
  210. Response.Write("<input type=hidden name=txtConnectionMetric value='"+F_nConnectionMetric +"' >")
  211. Response.Write("<input type=hidden name=hdnlstIP value='"+F_strListIP +"'>")
  212. Response.Write("<input type=hidden name=hdnlstGATEWAY value='"+F_strListGateway +"' >")
  213. Response.Write("<input type=hidden name=hdnAdvancedTabValue value='"+g_strAdvTabValue+"'>")
  214. End If
  215. ServeTabAdvanced = SA_NO_ERROR
  216. End Function
  217. '-------------------------------------------------------------------------
  218. 'Function: ServeGeneralTabJavaScript
  219. 'Description: Serve common javascript that is required for general tab
  220. 'Input Variables: None
  221. 'Output Variables: None
  222. 'Returns: None
  223. 'Global Variables: None
  224. '-------------------------------------------------------------------------
  225. Function ServeGeneralTabJavaScript()
  226. %>
  227. <SCRIPT LANGUAGE="JavaScript">
  228. //
  229. // Microsoft Server Appliance Web Framework Support Functions
  230. // Copyright (c) Microsoft Corporation. All rights reserved.
  231. //
  232. // Init Function
  233. // -----------
  234. // This function is called by the Web Framework to allow the page
  235. // to perform first time initialization.
  236. //
  237. // This function must be included or a javascript runtime error will occur.
  238. //
  239. function Init()
  240. {
  241. var OptionSel = "<%=F_strRadIP %>";
  242. if (OptionSel != "")
  243. {
  244. document.frmTask.radIP[OptionSel].checked = true;
  245. if (OptionSel == 0)
  246. {
  247. enableIPControls(true);
  248. }
  249. else if(OptionSel == 1)
  250. {
  251. enableIPControls(false);
  252. }
  253. }
  254. return true;
  255. }
  256. // ValidatePage Function
  257. // ------------------
  258. // This function is called by the Web Framework as part of the
  259. // submit processing. Used to validate user input. Returning
  260. // false will cause the submit to abort.
  261. // Returns: True if the page is OK, false if error(s) exist.
  262. function ValidatePage()
  263. {
  264. var retVal;
  265. if (document.frmTask.txtIP.disabled == false)
  266. {
  267. var IPVal = document.frmTask.txtIP;
  268. if( IPVal.value != "")
  269. {
  270. retVal = isValidIP(IPVal);
  271. if(retVal!=0)
  272. {
  273. //Calling to validate the IP and display the error message
  274. SA_DisplayErr('<%=SA_EscapeQuotes(L_IP_ERRORMESSAGE)%>');
  275. document.frmTask.onkeypress = ClearErr;
  276. return false;
  277. }
  278. }
  279. if (IPVal.value == "")
  280. {
  281. SA_DisplayErr('<%=SA_EscapeQuotes(L_IP_ERRORMESSAGE)%>');
  282. document.frmTask.onkeypress = ClearErr;
  283. return false;
  284. }
  285. }
  286. if (document.frmTask.txtMask.disabled == false)
  287. {
  288. var IPMask = document.frmTask.txtMask;
  289. var IPVal = document.frmTask.txtIP;
  290. if (IPMask.value == "" && IPVal.value != "")
  291. {
  292. SA_DisplayErr('<%=SA_EscapeQuotes(L_INVALIDSUBNETADDRESSES_ERRORMESSAGE)%>');
  293. return false;
  294. }
  295. if(IPMask.value != "")
  296. {
  297. retVal = isValidSubnetMask(IPMask)
  298. if(!retVal)
  299. {
  300. SA_DisplayErr('<%=SA_EscapeQuotes(L_INVALIDFORMATFORSUBNET_ERRORMESSAGE)%>');
  301. return false;
  302. }
  303. }
  304. retVal = isValidSubnetMask(IPMask)
  305. if(retVal == true && IPVal.value == "")
  306. {
  307. SA_DisplayErr('<%=SA_EscapeQuotes(L_IP_ERRORMESSAGE)%>');
  308. document.frmTask.onkeypress = ClearErr;
  309. return false;
  310. }
  311. }
  312. if (document.frmTask.txtGateway.disabled == false)
  313. {
  314. var IPVal = document.frmTask.txtGateway;
  315. if ( IPVal.value != "")
  316. {
  317. retVal = isValidIP(IPVal)
  318. if(retVal!=0)
  319. {
  320. //Calling to validate the IP and display the error message
  321. SA_DisplayErr('<%=SA_EscapeQuotes(L_IP_ERRORMESSAGE)%>');
  322. document.frmTask.onkeypress = ClearErr;
  323. return false;
  324. }
  325. }
  326. else // checking for the blank gateway case
  327. {
  328. SA_DisplayErr('<%=SA_EscapeQuotes(L_GATEWAY_ERRORMESSAGE)%>');
  329. document.frmTask.onkeypress = ClearErr;
  330. return false;
  331. }
  332. }
  333. document.frmTask.hdnGeneralTabValue.value = "true";
  334. if(document.frmTask.radIP[0].checked==true)
  335. {
  336. document.frmTask.hdnRadIP.value = 0;
  337. }
  338. else if(document.frmTask.radIP[1].checked)
  339. {
  340. document.frmTask.hdnRadIP.value = 1;
  341. }
  342. return true;
  343. }
  344. // SetData Function
  345. // --------------
  346. // This function is called by the Web Framework and is called
  347. // only if ValidatePage returned a success (true) code.
  348. function SetData()
  349. {
  350. return true;
  351. }
  352. </SCRIPT>
  353. <%
  354. End Function
  355. '-------------------------------------------------------------------------
  356. 'Function: ServeAdvancedTabJavaScript
  357. 'Description: Serve common javascript that is required for Advanced tab
  358. 'Input Variables: None
  359. 'Output Variables: None
  360. 'Returns: None
  361. 'Global Variables: None
  362. '-------------------------------------------------------------------------
  363. Function ServeAdvancedTabJavaScript()
  364. %>
  365. <SCRIPT LANGUAGE="JavaScript">
  366. //
  367. // Microsoft Server Appliance Web Framework Support Functions
  368. // Copyright (c) Microsoft Corporation. All rights reserved.
  369. //
  370. // Init Function
  371. // -----------
  372. // This function is called by the Web Framework to allow the page
  373. // to perform first time initialization.
  374. function Init()
  375. {
  376. var OptionSel = "<%=F_strRadIP %>";
  377. if (OptionSel == 0)
  378. {
  379. // disable IP controls
  380. document.frmTask.lstIP.disabled = true;
  381. document.frmTask.btnAddIP.disabled = true;
  382. document.frmTask.btnRemoveIP.disabled = true;
  383. document.frmTask.txtAdvIP.disabled = true;
  384. document.frmTask.txtAdvMask.disabled = true;
  385. // disable Gateway controls
  386. document.frmTask.lstGATEWAY.disabled = true;
  387. document.frmTask.txtAdvGATEWAY.disabled = true;
  388. document.frmTask.btnAddGATEWAY.disabled = true;
  389. document.frmTask.txtGATEWAYMetric.disabled = true;
  390. document.frmTask.btnRemoveGATEWAY.disabled = true;
  391. }
  392. else
  393. {
  394. LimitListLength(document.frmTask.lstIP,40,document.frmTask.txtAdvIP,document.frmTask.txtAdvMask,document.frmTask.btnAddIP);
  395. LimitListLength(document.frmTask.lstGATEWAY,20,document.frmTask.txtAdvGATEWAY,document.frmTask.txtGATEWAYMetric,document.frmTask.btnAddGATEWAY);
  396. // default value of Gateway metric
  397. if(document.frmTask.lstGATEWAY.length >=20)
  398. document.frmTask.txtGATEWAYMetric.value = "";
  399. else
  400. document.frmTask.txtGATEWAYMetric.value = 1;
  401. document.frmTask.btnAddIP.disabled = true;
  402. document.frmTask.btnAddGATEWAY.disabled = true;
  403. }
  404. if(document.frmTask.lstIP.length == 0)
  405. document.frmTask.btnRemoveIP.disabled = true;
  406. if(document.frmTask.lstGATEWAY.length == 0)
  407. document.frmTask.btnRemoveGATEWAY.disabled = true;
  408. return true;
  409. }
  410. // ValidatePage Function
  411. // ------------------
  412. // This function is called by the Web Framework as part of the
  413. // submit processing. Used to validate user input. Returning
  414. // false will cause the submit to abort.
  415. // Returns: True if the page is OK, false if error(s) exist.
  416. function ValidatePage()
  417. {
  418. var i=0;
  419. var arrIP = "";
  420. var arrGatewayIP = "";
  421. if(document.frmTask.hdnAdvancedTabValue.value != "")
  422. {
  423. for(i=0;i<document.frmTask.lstIP.length;i++)
  424. {
  425. arrIP = arrIP+ document.frmTask.lstIP.options[i].value + ";";
  426. }
  427. for(i=0;i<document.frmTask.lstGATEWAY.length;i++)
  428. {
  429. arrGatewayIP = arrGatewayIP + document.frmTask.lstGATEWAY.options[i].value + ";";
  430. }
  431. arrIP = arrIP.substring(0,arrIP.length-1);
  432. arrGatewayIP = arrGatewayIP.substring(0,arrGatewayIP.length-1);
  433. document.frmTask.hdnlstIP.value = arrIP;
  434. document.frmTask.hdnlstGATEWAY.value = arrGatewayIP;
  435. var OptionSel = "<%=F_strRadIP %>";
  436. if (OptionSel == 1)
  437. {
  438. var arrIPValue;
  439. var strIPValue;
  440. if ( document.frmTask.lstGATEWAY.length == 0) // checking for the blank gateway case
  441. {
  442. SA_DisplayErr('<%=SA_EscapeQuotes(L_GATEWAY_ERRORMESSAGE)%>');
  443. document.frmTask.onkeypress = ClearErr;
  444. return false;
  445. }
  446. if(document.frmTask.lstIP.length != 0)
  447. {
  448. strIPValue = document.frmTask.lstIP[0].value;
  449. arrIPValue = strIPValue.split(':');
  450. document.frmTask.txtIP.value = arrIPValue[0];
  451. document.frmTask.txtMask.value = arrIPValue[1];
  452. var arrGatewayValue;
  453. arrGatewayValue = arrGatewayIP.split(' <%=L_METRIC_TEXT%> ');
  454. document.frmTask.txtGateway.value = arrGatewayValue[0];
  455. }
  456. else if(document.frmTask.lstIP.length == 0)
  457. {
  458. document.frmTask.txtIP.value = "";
  459. document.frmTask.txtMask.value = "";
  460. }
  461. }
  462. }
  463. return true;
  464. }
  465. // SetData Function
  466. // --------------
  467. // This function is called by the Web Framework and is called
  468. // only if ValidatePage returned a success (true) code.
  469. function SetData()
  470. {
  471. return true;
  472. }
  473. </SCRIPT>
  474. <%
  475. End Function
  476. '-------------------------------------------------------------------------
  477. 'Function: ServeCommonJavaScript
  478. 'Description: Serve common javascript that is required for this page type.
  479. 'Input Variables: None
  480. 'Output Variables: None
  481. 'Returns: None
  482. 'Global Variables: None
  483. '-------------------------------------------------------------------------
  484. Function ServeCommonJavaScript()
  485. %>
  486. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  487. </script>
  488. <script language="JavaScript">
  489. //
  490. // Microsoft Server Appliance Web Framework Support Functions
  491. // Copyright (c) Microsoft Corporation. All rights reserved.
  492. //
  493. // Function to enable or disable controls of the General tab
  494. function enableIPControls(Flag)
  495. {
  496. // Disable text boxes
  497. document.frmTask.txtIP.disabled=Flag;
  498. document.frmTask.txtMask.disabled=Flag;
  499. document.frmTask.txtGateway.disabled=Flag;
  500. }
  501. //Function to validate the Subnet mask and return true or false.
  502. function isValidSubnetMask(objSubnetMask)
  503. {
  504. var strMasktext = objSubnetMask.value;
  505. if (strMasktext.length == 0)
  506. return false; // No subnet entered
  507. // counts no of dots by calling the function if it is less returns 0
  508. if ( countChars(strMasktext,".") != 3)
  509. {
  510. // Invalid format
  511. return false;
  512. }
  513. var arrMask = strMasktext.split(".");
  514. var i,j,blnValid ;
  515. for(i = 0; i < 4; i++)
  516. {
  517. if ( (arrMask[i].length < 1 ) || (arrMask[i].length > 3 ) )
  518. {
  519. // Invalid format
  520. return false;
  521. }
  522. if ( !isInteger(arrMask[i]))
  523. {
  524. // Invalid characters
  525. return false;
  526. }
  527. arrMask[i] = parseInt(arrMask[i],10);
  528. if (arrMask[i] > 255)
  529. {
  530. // Out of bounds
  531. return false;
  532. }
  533. } // end of for loop
  534. if ( arrMask[0] == 0 || arrMask[3] == 255)
  535. {
  536. // mask must not start with 0 or end with 255
  537. return false;
  538. }
  539. for(i=0;i<4;i++)
  540. {
  541. if(arrMask[i] != 255)
  542. {
  543. for(j=i+1 ; j<4; j++)
  544. {
  545. if (arrMask[j] != 0)
  546. { // mask not contiguous
  547. return false;
  548. }
  549. }// end of j for loop
  550. blnValid = false;
  551. for(j=1;j<9;j++)
  552. {
  553. if (arrMask[i] == (256-Math.pow(2, j)))
  554. blnValid = true;
  555. }
  556. if(!blnValid)
  557. {
  558. // mask not contiguous
  559. return false;
  560. }
  561. }// end of if(arrMask[i] != 255)
  562. }// end of for loop
  563. objSubnetMask.value = arrMask.join(".");
  564. return true;
  565. }
  566. //Disable the controls related to Gateway when no items in Gateway listbox
  567. function enableGatewayControls()
  568. {
  569. if(document.frmTask.lstGATEWAY.length==0)
  570. {
  571. document.frmTask.btnAddGATEWAY.disabled=true;
  572. }
  573. else
  574. {
  575. document.frmTask.txtAdvGATEWAY.disabled = false;
  576. document.frmTask.txtGATEWAYMetric.disabled = false;
  577. document.frmTask.txtGATEWAYMetric.value = 1;
  578. }
  579. }
  580. //Disable the controls related to IP when no items in IP listbox
  581. function enableAdvIPControls()
  582. {
  583. if(document.frmTask.lstIP.length==0)
  584. {
  585. document.frmTask.btnAddIP.disabled=true;
  586. }
  587. else
  588. {
  589. document.frmTask.txtAdvIP.disabled = false;
  590. document.frmTask.txtAdvMask.disabled = false;
  591. }
  592. }
  593. //Limits the length of listbox to a specified value and disables the appropriate textboxes
  594. function LimitListLength(Obj,Objlen,ObjFirst,ObjSecond,ObjButton)
  595. {
  596. var lstIPLength = Obj.length;
  597. if(lstIPLength >= Objlen)
  598. {
  599. ObjFirst.disabled = true;
  600. ObjSecond.disabled = true;
  601. ObjButton.disabled = true;
  602. }
  603. }
  604. // Function to add the IP& subnet to the selected list box
  605. function addIPtoListBox(objLst,objFirst,objSecond,objRemove)
  606. {
  607. var strIPANDSubnet=objFirst.value+":"+objSecond.value;
  608. //calling function to validate IP
  609. var intResult=isValidIP(objFirst);
  610. if(intResult!=0)
  611. {
  612. //Calling to validate the IP and display the error message
  613. SA_DisplayErr('<%=SA_EscapeQuotes(L_IP_ERRORMESSAGE)%>');
  614. document.frmTask.onkeypress = ClearErr;
  615. selectFocus(objFirst);
  616. return;
  617. }
  618. //Checking for the SubnetMask validation
  619. if (objSecond.value==""|| !isValidSubnetMask(objSecond))
  620. {
  621. SA_DisplayErr('<%=SA_EscapeQuotes(L_INVALIDSUBNETADDRESSES_ERRORMESSAGE)%>');
  622. document.frmTask.onkeypress = ClearErr;
  623. selectFocus(objSecond);
  624. return;
  625. }
  626. // checking for the duplicate values if not add to the list box
  627. if (!addToListBox(objLst,objRemove,strIPANDSubnet,strIPANDSubnet))
  628. {
  629. SA_DisplayErr('<%=SA_EscapeQuotes(L_DUPLICATEADDRESSES_ERRORMESSAGE)%>');
  630. document.frmTask.onkeypress = ClearErr;
  631. }
  632. else
  633. {
  634. objFirst.value="";
  635. objSecond.value="";
  636. objFirst.focus();
  637. // making the addIP button disable
  638. document.frmTask.btnAddIP.disabled=true;
  639. if(objLst.length >= 40)
  640. {
  641. objFirst.disabled = true;
  642. objSecond.disabled = true;
  643. }
  644. }
  645. }// end of function addIPtoListBox
  646. // to set the default subnetmask depending
  647. // on the Class of IP address
  648. function setDefaultSubnet(objIP,objSubnet)
  649. {
  650. // get the IP and subnet values
  651. var strIPtext = objIP.value;
  652. var strSubnet = objSubnet.value;
  653. // validate the IP address first
  654. var nRetval = isValidIP(objIP)
  655. if (nRetval!= 0)
  656. {
  657. return;
  658. }
  659. // return if the subnet already has some value
  660. if(!(Trim(strSubnet) == ""))
  661. {
  662. return;
  663. }
  664. // decide the class of IP to give the default Subnet
  665. var arrIP = strIPtext.split(".");
  666. var nClassId = parseInt(arrIP[0],10);
  667. // set the value of the subnet depending on the class
  668. if(nClassId <=126)
  669. objSubnet.value = "255.0.0.0"; // Class A
  670. else if(nClassId <=191)
  671. objSubnet.value = "255.255.0.0"; // Class B
  672. else if(nClassId < 255)
  673. objSubnet.value = "255.255.255.0"; // Class C
  674. // set the focus on the subnet
  675. selectFocus(objSubnet);
  676. }
  677. // Function to add the Gateway & Gatewaymetric to the selected list box
  678. function addGATEWAYtoListBox(objLst,objFirst,objSecond,objRemove)
  679. {
  680. var strGatewayANDMetric=objFirst.value + " <%=L_METRIC_TEXT%> " + objSecond.value;
  681. //calling function to validate GATEWAY
  682. var intResult=isValidIP(objFirst)
  683. if(intResult!=0)
  684. {
  685. //Calling to validate the GATEWAY and display the error message
  686. SA_DisplayErr('<%=SA_EscapeQuotes(L_IP_ERRORMESSAGE)%>');
  687. document.frmTask.onkeypress = ClearErr;
  688. selectFocus(objFirst);
  689. return;
  690. }
  691. //Checking for the SubnetMask validation
  692. if (objSecond.value=="" || !validateMetric(objSecond,
  693. '<%=SA_EscapeQuotes(L_INVALIDGATEWAYMETRIC_ERRORMESSAGE)%>'))
  694. {
  695. SA_DisplayErr('<%=SA_EscapeQuotes(L_INVALIDGATEWAYMETRIC_ERRORMESSAGE)%>');
  696. document.frmTask.onkeypress = ClearErr;
  697. selectFocus(objSecond);
  698. return;
  699. }
  700. // checking for the duplicate values if not add to the list box
  701. if (!addToListBox(objLst,objRemove,strGatewayANDMetric,strGatewayANDMetric))
  702. {
  703. SA_DisplayErr('<%=SA_EscapeQuotes(L_DUPLICATEADDRESSES_ERRORMESSAGE)%>');
  704. document.frmTask.onkeypress = ClearErr;
  705. }
  706. else
  707. {
  708. objFirst.value="";
  709. objSecond.value="";
  710. objFirst.focus();
  711. // making the addGATEWAY button disable
  712. document.frmTask.btnAddGATEWAY.disabled=true;
  713. objSecond.value=1;
  714. if(objLst.length >= 20)
  715. {
  716. objFirst.disabled = true;
  717. objSecond.disabled = true;
  718. objSecond.value = "";
  719. }
  720. }
  721. }// end of function addGATEWAYtoListBox
  722. function validateMetric(objTxt,strErrorMsg)
  723. {
  724. if (objTxt.value=="" || objTxt.value==0 ||objTxt.value > 9999 )
  725. {
  726. SA_DisplayErr(strErrorMsg);
  727. document.frmTask.onkeypress = ClearErr;
  728. // making the value null
  729. objTxt.value="";
  730. objTxt.focus();
  731. return false;
  732. }
  733. else
  734. return true;
  735. }
  736. </script>
  737. <%
  738. End Function
  739. '-------------------------------------------------------------------------
  740. 'Function: ServeGeneralUI
  741. 'Description: Serves the HTML content for General tab
  742. 'Input Variables: None
  743. 'Output Variables: None
  744. 'Returns: None
  745. 'Global Variables: g_*, F_*, blnDHCPEnabled, L_*
  746. '-------------------------------------------------------------------------
  747. Function ServeGeneralUI()
  748. Call SA_TraceOut(SOURCE_FILE, "ServeGeneralUI")
  749. 'check whether DHCP is enabled
  750. Dim objService ' WMI connection object
  751. Dim objInstance ' Adapter instance
  752. 'Trying to connect to the server
  753. Set objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  754. 'Getting the instance of the particulat NIC card object
  755. Set objInstance = getNetworkAdapterObject(objService,g_strDeviceID)
  756. ' Getting DHCP Enable/Disable and accordingly set radio values
  757. blnDHCPEnabled = isDHCPenabled(objInstance)
  758. 'Release the objects
  759. set objService = nothing
  760. set objInstance = nothing
  761. if trim(g_strTabValue) = "" or blnDHCPEnabled then
  762. Call getDefaultGeneralValues() 'Get the default values for General tab
  763. end if
  764. %>
  765. <TABLE ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2>
  766. <TR>
  767. <TD COLSPAN=2 nowrap class="TasksBody">
  768. <INPUT TYPE="RADIO" CLASS="FormRadioButton" NAME="radIP" VALUE="IPDEFAULT" TABINDEX=1 <%If (blnDHCPEnabled) Then Response.Write " CHECKED" End If%> onClick="enableIPControls(true)" >&nbsp;<%=L_OBTAINIPFROMDHCP_TEXT %>
  769. </TD>
  770. </TR>
  771. <TR>
  772. <TD COLSPAN=2 nowrap class="TasksBody">
  773. <INPUT TYPE="RADIO" CLASS="FormRadioButton" NAME="radIP" VALUE="IPMANUAL" TABINDEX=1 <%If (Not blnDHCPEnabled) Then Response.Write " CHECKED" End If %> onClick="enableIPControls(false)" >&nbsp;<%=L_CONFIGUREMANUALLY_TEXT%>
  774. </TD>
  775. </TR>
  776. <TR>
  777. <TD COLSPAN=2 class="TasksBody">
  778. <P>&nbsp;</P>
  779. </TD>
  780. </TR>
  781. <TR>
  782. <TD ALIGN=LEFT nowrap class="TasksBody">
  783. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=L_NIC_IP_IP%>
  784. </TD>
  785. <TD ALIGN=left class="TasksBody">
  786. <%
  787. select case blnDHCPEnabled
  788. case false
  789. %>
  790. <INPUT CLASS='FormField' TYPE="TEXT" NAME="txtIP" VALUE="<%=F_strIPAddress %>" TABINDEX=2 MAXLENGTH=15 OnKeyPress="if(window.event.keyCode == 13) return true ; checkKeyforIPAddress(this);">
  791. <%
  792. case true
  793. %>
  794. <INPUT CLASS='FormField' TYPE="TEXT" NAME="txtIP" VALUE="<%=F_strIPAddress %>" disabled TABINDEX=2 MAXLENGTH=15 OnKeyPress="if(window.event.keyCode == 13) return true ; checkKeyforIPAddress(this);">
  795. <%
  796. end select
  797. %>
  798. </TD>
  799. </TR>
  800. <TR>
  801. <TD ALIGN=LEFT nowrap class="TasksBody">
  802. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=L_SUBNETMASK_TEXT%>
  803. </TD>
  804. <TD ALIGN=left class="TasksBody">
  805. <%
  806. select case blnDHCPEnabled
  807. case false
  808. %>
  809. <INPUT CLASS='FormField' TYPE="TEXT" NAME="txtMask" VALUE="<%=F_strSubnetMask%>" TABINDEX=3 MAXLENGTH=15 OnKeyPress=" if(window.event.keyCode == 13) return true ; checkKeyforIPAddress(this);">
  810. <%
  811. case true
  812. %>
  813. <INPUT CLASS='FormField' TYPE="TEXT" NAME="txtMask" VALUE="<%=F_strSubnetMask%>" disabled TABINDEX=3 MAXLENGTH=15 OnKeyPress=" if(window.event.keyCode == 13) return true ; checkKeyforIPAddress(this);">
  814. <%
  815. end select
  816. %>
  817. </TD>
  818. </TR>
  819. <TR>
  820. <TD ALIGN=left nowrap class="TasksBody">
  821. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=L_DEFAULTGATEWAY_TEXT%>
  822. </TD>
  823. <TD ALIGN=left class="TasksBody">
  824. <%
  825. select case blnDHCPEnabled
  826. case false
  827. %>
  828. <INPUT CLASS='FormField' TYPE="TEXT" NAME="txtGateway" VALUE="<%=F_strGatewayAddress%>" TABINDEX=3 MAXLENGTH=15 OnKeyPress=" if(window.event.keyCode == 13) return true ; checkKeyforIPAddress(this);">
  829. <%
  830. case true
  831. %>
  832. <INPUT CLASS='FormField' TYPE="TEXT" DISABLED NAME="txtGateway" VALUE="<%=F_strGatewayAddress%>" TABINDEX=3 MAXLENGTH=15 OnKeyPress=" if(window.event.keyCode == 13) return true ; checkKeyforIPAddress(this);">
  833. <%
  834. end select
  835. %>
  836. </TD>
  837. </TR>
  838. </TABLE>
  839. <INPUT TYPE=hidden NAME=hdnGeneralTabValue VALUE="">
  840. <INPUT TYPE=hidden NAME=hdnInitialIPValue VALUE="<%= g_initialIPAddress %>">
  841. <INPUT TYPE=hidden NAME=hdnRadIP VALUE="">
  842. <%
  843. End Function
  844. '-------------------------------------------------------------------------
  845. 'Function: ServeAdvancedUI
  846. 'Description: Serves the HTML content for Advanced tab
  847. 'Input Variables: None
  848. 'Output Variables: None
  849. 'Returns: None
  850. 'Global Variables: g_*, F_*, L_*
  851. '-------------------------------------------------------------------------
  852. Function ServeAdvancedUI()
  853. Call SA_TraceOut(SOURCE_FILE, "ServeAdvancedUI")
  854. if trim(g_strAdvTabValue) = "" then
  855. getDefaultAdvancedvalues() 'Get the default values for Advanced tab
  856. else
  857. UpdateDefaultValues() 'Update the values when navigated between tabs
  858. end if
  859. %>
  860. <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  861. <TR>
  862. <TD NOWRAP class="TasksBody" >
  863. <P><%=L_NIC_IP_IP%></P>
  864. </TD>
  865. <TD class="TasksBody">
  866. </TD>
  867. <TD VALIGN=TOP nowrap rowspan=2 class="TasksBody" >
  868. <BR>
  869. <%=L_NIC_IP_IP%><BR>
  870. <INPUT CLASS='FormField' TYPE="TEXT" NAME="txtAdvIP" VALUE="" TABINDEX=3 SIZE=20 MAXLENGTH=15 OnKeyPress="checkKeyforIPAddress(this)" onKeyUP="disableAddButton(this,btnAddIP)">
  871. <BR>
  872. <%=L_ADVSUBNETMASK_TEXT%><BR>
  873. <INPUT CLASS='FormField' TYPE="TEXT" NAME="txtAdvMask" VALUE="" TABINDEX=5 SIZE=20 MAXLENGTH=15 OnKeyPress="checkKeyforIPAddress(this);" onfocus="setDefaultSubnet(txtAdvIP,this);">
  874. </TD>
  875. </TR>
  876. <TR>
  877. <TD class="TasksBody" width=23%>
  878. <SELECT NAME="lstIP" style="width=225px" class="FormField" TABINDEX=2 SIZE=7 >
  879. <%
  880. 'Function call to add the IP Addresses and Subnet masks to the List box and limit the size to 40
  881. ServeListValues g_arrIPList,L_SERVEVALUES_ERRORMESSAGE, 40
  882. %>
  883. </SELECT>
  884. </TD>
  885. <TD class="TasksBody" ALIGN=center width=23%>
  886. <% Call SA_ServeOnClickButtonEx(L_BUTTON_ADD_TEXT,"","addIPtoListBox(lstIP,txtAdvIP,txtAdvMask,btnRemoveIP)",90,0,"DISABLED","btnAddIP")%>
  887. <BR><BR><BR><BR>
  888. <% Call SA_ServeOnClickButtonEx(L_BUTTON_REMOVE_TEXT,"","removeListBoxItems(lstIP,btnRemoveIP);enableAdvIPControls()",90,0,"ENABLED","btnRemoveIP")%>
  889. </TD>
  890. </TR>
  891. <TR>
  892. <TD class="TasksBody" NOWRAP COLSPAN="3" ><BR><p><%=L_GATEWAYADDRESS_TEXT%></P></TD>
  893. </TR>
  894. <TR>
  895. <TD class="TasksBody">
  896. <SELECT NAME="lstGATEWAY" class="FormField" style="width=225px" TABINDEX=7 SIZE=6>
  897. <%
  898. 'Function call to add the Gateway Addresses and Metric to the List box and limit the size to 20
  899. ServeListValues g_arrGATEWAYList,L_SERVEVALUES_ERRORMESSAGE, 20
  900. %>
  901. </SELECT>
  902. </TD>
  903. <TD class="TasksBody" ALIGN=center >
  904. <% Call SA_ServeOnClickButtonEx(L_BUTTON_ADD_TEXT,"","addGATEWAYtoListBox(lstGATEWAY,txtAdvGATEWAY,txtGATEWAYMetric,btnRemoveGATEWAY)",90,0,"DISABLED","btnAddGATEWAY")%>
  905. <BR><BR><BR><BR>
  906. <% Call SA_ServeOnClickButtonEx(L_BUTTON_REMOVE_TEXT,"","removeListBoxItems(lstGATEWAY,btnRemoveGATEWAY); enableGatewayControls();",90,0,"ENABLED","btnRemoveGATEWAY")%>
  907. </TD>
  908. <TD nowrap class="TasksBody">
  909. <%=L_GATEWAY_TEXT %><BR>
  910. <INPUT CLASS='FormField' TYPE="TEXT" NAME="txtAdvGATEWAY" VALUE="" TABINDEX=8 SIZE=20 MAXLENGTH=15 OnKeyPress="checkKeyforIPAddress(this)" OnKeyUP="disableAddButton(this,btnAddGATEWAY)">
  911. <BR>
  912. <%=L_GATEWAYMETRIC_TEXT%><br>
  913. <INPUT CLASS='FormField' TYPE="TEXT" NAME="txtGATEWAYMetric" TABINDEX=9 VALUE="" SIZE=6 MAXLENGTH=4 OnKeyPress="checkKeyforNumbers(this)">
  914. </TD>
  915. </TR>
  916. <TR>
  917. <TD COLSPAN=3 class="TasksBody" nowrap TITLE="<%=L_METRICDESC_TEXT%>"><BR><%=L_IPCONNECTIONMETRIC_TEXT%>
  918. <INPUT TYPE="TEXT" NAME="txtConnectionMetric" TABINDEX=12 SIZE=15 MAXLENGTH=4 VALUE="<%=F_nConnectionMetric%>" OnKeyPress="checkKeyforNumbers(this)">
  919. </TD>
  920. </TR>
  921. <TR>
  922. <TD COLSPAN=3 class="TasksBody">
  923. <%= L_METRICDESC_TEXT %>
  924. </TD>
  925. </TR>
  926. </TABLE>
  927. <INPUT TYPE=hidden NAME=hdnlstIP VALUE="<%=F_strListIP%>">
  928. <INPUT TYPE=hidden NAME=hdnlstGATEWAY VALUE="<%=F_strListGateway%>">
  929. <INPUT TYPE=hidden NAME=hdnAdvancedTabValue VALUE="<%= g_strAdvTabValue %>">
  930. <INPUT TYPE=hidden NAME=hdnInitialIPValue VALUE="<%= g_initialIPAddress %>">
  931. <%
  932. End Function
  933. '-------------------------------------------------------------------------
  934. 'Sub routine name: ServeListValues
  935. 'Description: Serves in Loading the IP's/Gateways into the list box
  936. 'Input Variables: In - strList->list of the addresses with concatination
  937. ' character as ;
  938. ' In - ERRORMESSAGE->Error message for that particular call
  939. 'Output Variables: None
  940. 'Returns: None
  941. 'Global Variables: None
  942. '-------------------------------------------------------------------------
  943. Sub ServeListValues(strList,ERRORMESSAGE,nMaxcount)
  944. Err.Clear
  945. On Error Resume Next
  946. Dim arrTempList 'holds the array of items
  947. Dim i 'holds the increment count
  948. Dim nCountVal 'holds the count of items to limit the items in the listbox
  949. Call SA_TraceOut(SOURCE_FILE, "ServeListValues")
  950. ' splitting the string into array
  951. arrTempList=split(strList,";",-1,1)
  952. nCountVal =0
  953. 'Printing the array values into the listbox
  954. For i=Lbound(arrTempList) To Ubound(arrTempList)
  955. nCountVal = nCountVal + 1
  956. ' checking for empty and if the string is ":" dont display in the list box
  957. If arrTempList(i) <> "" AND arrTempList(i) <> ":" Then
  958. If i=Lbound(arrTempList) Then
  959. Response.Write "<OPTION VALUE=" & chr(34) & arrTempList(i)_
  960. & chr(34)& " SELECTED>" & arrTempList(i) & " </OPTION>"
  961. Else
  962. Response.Write "<OPTION VALUE=" & chr(34) & arrTempList(i)_
  963. & chr(34)& " >" & arrTempList(i) & " </OPTION>"
  964. End if
  965. End If
  966. if nCountVal = nMaxcount then exit for
  967. Next
  968. If Err.number <> 0 Then
  969. Call SA_TraceOut(SOURCE_FILE, "ServeListValues failed")
  970. SA_SetErrMsg ERRORMESSAGE & "(" & Hex(Err.Number) & ")"
  971. End If
  972. End Sub
  973. '-------------------------------------------------------------------------
  974. 'Function name: getDefaultGeneralValues
  975. 'Description: Serves in Getting the Default values from the System
  976. 'Input Variables: None
  977. 'Output Variables: None
  978. 'Returns: True/False
  979. 'Global Variables: In:G_CONST_REGISTRY_PATH-Reg path
  980. ' In:CONST_WMI_WIN32_NAMESPACE
  981. ' In:L_* -Localized strings
  982. ' Out:F_* - Form variables
  983. '
  984. 'Called several functions regConnection,
  985. 'getNetworkAdapterObject,isDHCPenabled,getRegkeyvalue
  986. 'which will be helpful in getting the NIC information
  987. '-------------------------------------------------------------------------
  988. Function getDefaultGeneralValues()
  989. Err.Clear
  990. On Error Resume Next
  991. Dim objService
  992. Dim objInstance
  993. Dim arrIPList 'hold array IP list
  994. Dim arrSubnetList 'hold array Subnet list
  995. Dim nCount
  996. Dim strSettingID 'hold setting id
  997. Dim arrGATEWAYList 'hold gateway array list
  998. Dim objRegistry
  999. Call SA_TraceOut(SOURCE_FILE, "getDefaultGeneralValues")
  1000. 'Trying to connect to the server
  1001. Set objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  1002. 'Connect to registry
  1003. Set objRegistry=regConnection()
  1004. 'Getting the instance of the particulat NIC card object
  1005. Set objInstance = getNetworkAdapterObject(objService,g_strDeviceID)
  1006. ' Getting DHCP Enable/Disable and accordingly set radio values
  1007. blnDHCPEnabled = isDHCPenabled(objInstance)
  1008. 'Getting the SettingID
  1009. strSettingID=objInstance.SettingID
  1010. 'Getting IP values from the registry by giving the complete path
  1011. arrIPList = objInstance.IPAddress
  1012. 'Getting subnet values from the registry by giving the complete path
  1013. arrSubnetList = objInstance.IPSubnet
  1014. 'Getting GATEWAY values from the registry by giving the complete path
  1015. arrGATEWAYList=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" _
  1016. & strSettingID,"DefaultGateway",CONST_MULTISTRING)
  1017. 'Forming the string of IP+ SubnetMask list
  1018. For nCount=LBound(arrIPList) To UBound(arrIPList)
  1019. F_strIPAddress = arrIPList(nCount)
  1020. g_initialIPAddress = arrIPList(nCount)
  1021. F_strSubnetMask = arrSubnetList(nCount)
  1022. F_strGatewayAddress = arrGATEWAYList(nCount)
  1023. Exit for
  1024. Next
  1025. getDefaultGeneralValues = true
  1026. 'release objects
  1027. Set objInstance = Nothing
  1028. Set objService = Nothing
  1029. Set objRegistry = Nothing
  1030. End Function
  1031. '-------------------------------------------------------------------------
  1032. 'Function name: getDefaultAdvancedvalues
  1033. 'Description: Serves in Getting the Default values from the System
  1034. 'Input Variables: None
  1035. 'Output Variables: None
  1036. 'Returns: True/False
  1037. 'Global Variables: In:G_CONST_REGISTRY_PATH-Reg path
  1038. ' Out:F_nConnectionMetric-IP connection
  1039. ' metric(from Registry)
  1040. ' Out:g_arrIPList-List of Ips& subnetmask
  1041. ' Out:G_arrGATEWAYList-List of Gateways& Metrics
  1042. ' In :L_* -Localized strings
  1043. '
  1044. 'Called several functions regConnection,
  1045. 'getNetworkAdapterObject,isDHCPenabled,getRegkeyvalue
  1046. 'which will be helpful in getting the NIC information
  1047. '-------------------------------------------------------------------------
  1048. Function getDefaultAdvancedvalues()
  1049. Err.Clear
  1050. On Error Resume Next
  1051. Dim objInstance
  1052. Dim objRegistry
  1053. Dim objService 'holds WMI Connection
  1054. Dim arrIPList 'holds IP array list
  1055. Dim arrSubnetList 'holds subnet array
  1056. Dim arrGATEWAYList 'holds gateway array
  1057. Dim arrGATEWAYMetricList 'holds gateway metric list
  1058. Dim strSettingID 'holds setting ID
  1059. Dim nCount
  1060. g_strAdvTabValue = "true"
  1061. Call SA_TraceOut(SOURCE_FILE, "getDefaultAdvancedvalues")
  1062. 'Trying to connect to the server
  1063. Set objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  1064. if Err.number <> 0 then
  1065. SA_ServeFailurePage L_WMI_CONNECTIONFAIL_ERRORMESSAGE
  1066. getDefaultAdvancedvalues = False
  1067. Exit Function
  1068. end if
  1069. 'Connecting to default namespace to carry registry operations
  1070. Set objRegistry=regConnection()
  1071. If (objRegistry is Nothing) Then
  1072. SA_ServeFailurePage L_SERVERCONNECTIONFAIL_ERRORMESSAGE
  1073. getDefaultAdvancedvalues = False
  1074. Exit Function
  1075. End If
  1076. 'Getting the instance of the particulat NIC card object
  1077. Set objInstance = getNetworkAdapterObject(objService,g_strDeviceID)
  1078. 'Getting the SettingID
  1079. strSettingID=objInstance.SettingID
  1080. 'Getting IP values from the registry by giving the complete path
  1081. 'arrIPList=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" _
  1082. '& strSettingID,"IPAddress",CONST_MULTISTRING)
  1083. arrIPList = objInstance.IPAddress
  1084. 'Getting subnet values from the registry by giving the complete path
  1085. 'arrSubnetList=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" _
  1086. '& strSettingID,"SubnetMask",CONST_MULTISTRING)
  1087. arrSubnetList = objInstance.IPSubnet
  1088. if trim(F_strIPAddress) <> "" then
  1089. g_arrIPList = F_strIPAddress & ":" & F_strSubnetMask & ";"
  1090. 'Forming the string of IP+ SubnetMask list
  1091. For nCount=LBound(arrIPList) + 1 To UBound(arrIPList)
  1092. g_arrIPList=g_arrIPList+arrIPList(nCount)+":"+arrSubnetList(nCount)+";"
  1093. Next
  1094. else
  1095. 'Forming the string of IP+ SubnetMask list
  1096. if F_strRadIP = 1 then
  1097. For nCount=LBound(arrIPList)+1 To UBound(arrIPList)
  1098. g_arrIPList=g_arrIPList+arrIPList(nCount)+":"+arrSubnetList(nCount)+";"
  1099. Next
  1100. end if
  1101. if F_strRadIP = 0 then
  1102. For nCount=LBound(arrIPList) To UBound(arrIPList)
  1103. g_arrIPList=g_arrIPList+arrIPList(nCount)+":"+arrSubnetList(nCount)+";"
  1104. Next
  1105. end if
  1106. end if
  1107. 'Getting GATEWAY values from the registry by giving the complete path
  1108. arrGATEWAYList=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" _
  1109. & strSettingID,"DefaultGateway",CONST_MULTISTRING)
  1110. 'Getting GateWayCostMetric from registry by giving the complete path
  1111. arrGATEWAYMetricList =getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH _
  1112. & "\" & strSettingID,"DefaultGatewayMetric",CONST_MULTISTRING)
  1113. if F_strRadIP <> 0 then
  1114. if F_strGatewayAddress <> "" then g_arrGATEWAYList = F_strGatewayAddress & " "+L_METRIC_TEXT+" 1;"
  1115. 'Forming the string of gateway+ metric list
  1116. For nCount=LBound(arrGATEWAYList) + 1 To UBound(arrGATEWAYList)
  1117. g_arrGATEWAYList = g_arrGATEWAYList+arrGATEWAYList(nCount)+ _
  1118. " "+L_METRIC_TEXT+" "+arrGATEWAYMetricList(nCount)+";"
  1119. Next
  1120. else
  1121. 'Forming the string of gateway+ metric list
  1122. For nCount=LBound(arrGATEWAYList) To UBound(arrGATEWAYList)
  1123. g_arrGATEWAYList = g_arrGATEWAYList+arrGATEWAYList(nCount)+ _
  1124. " "+L_METRIC_TEXT+" "+arrGATEWAYMetricList(nCount)+";"
  1125. Next
  1126. end if
  1127. 'Getting InterfaceMetric from the registry by giving the complete path
  1128. F_nConnectionMetric=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH _
  1129. & "\" & strSettingID ,"InterfaceMetric",CONST_DWORD)
  1130. 'Set to Nothing
  1131. Set objService=Nothing
  1132. Set objRegistry=Nothing
  1133. Set objInstance=Nothing
  1134. getDefaultAdvancedvalues = true
  1135. End Function
  1136. '-------------------------------------------------------------------------
  1137. 'Function: UpdateDefaultValues
  1138. 'Description: Updates the state of fields when navigated from one tab
  1139. ' to another
  1140. 'Input Variables: None
  1141. 'Output Variables: None
  1142. 'Returns: string
  1143. 'Global Variables: F_*,g_*
  1144. '-------------------------------------------------------------------------
  1145. Function UpdateDefaultValues()
  1146. Dim arrTempList 'holds temporary array
  1147. Dim i 'holds increment count
  1148. Call SA_TraceOut(SOURCE_FILE, "UpdateDefaultValues")
  1149. arrTempList=split(F_strListGateway,";",-1,1)
  1150. if F_strRadIP = 1 then
  1151. if F_strGatewayAddress <> "" then g_arrGATEWAYList = F_strGatewayAddress & " "+L_METRIC_TEXT+" 1;"
  1152. For i=Lbound(arrTempList)+ 1 To Ubound(arrTempList)
  1153. g_arrGATEWAYList = g_arrGATEWAYList & arrTempList(i) & ";"
  1154. next
  1155. end if
  1156. if F_strRadIP = 0 then
  1157. For i=Lbound(arrTempList) To Ubound(arrTempList)
  1158. g_arrGATEWAYList = g_arrGATEWAYList & arrTempList(i) & ";"
  1159. next
  1160. End if
  1161. arrTempList=split(F_strListIP,";",-1,1)
  1162. if F_strIPAddress <> "" then
  1163. g_arrIPList = F_strIPAddress & ":" & F_strSubnetMask & ";"
  1164. if F_strRadIP = 1 then
  1165. For i=Lbound(arrTempList)+ 1 To Ubound(arrTempList)
  1166. g_arrIPList = g_arrIPList & arrTempList(i) & ";"
  1167. next
  1168. end if
  1169. elseif F_strIPAddress = "" then
  1170. if F_strRadIP = 0 then
  1171. For i=Lbound(arrTempList) To Ubound(arrTempList)
  1172. g_arrIPList = g_arrIPList & arrTempList(i) & ";"
  1173. next
  1174. end if
  1175. end if
  1176. End Function
  1177. '-------------------------------------------------------------------------
  1178. 'Function name: setNIC
  1179. 'Description: serves in Setting new IP & gateway values
  1180. 'Input Variables: None
  1181. 'Output Variables:
  1182. 'Returns: Boolean - Returns ( True/Flase )
  1183. 'Global Variables: In - blnDHCPEnabled -Radio button value
  1184. ' In - G_CONST_REGISTRY_PATH -Reg path
  1185. ' In - L_* - Localized strings
  1186. 'Called registry related functions to update the values and displays the
  1187. 'corresponding error if any.
  1188. '-------------------------------------------------------------------------
  1189. Function setNIC()
  1190. Err.Clear
  1191. On Error resume next
  1192. Dim objInstance
  1193. Dim objService
  1194. Dim objRegistry 'holds registry connection object
  1195. Dim arrIPList
  1196. Dim arrSubnetList 'holds subnet array list
  1197. Dim arrGATEWAYList() 'holds gateway array list
  1198. Dim arrTemp
  1199. Dim arrMetricList
  1200. Dim strSettingID 'holds setting ID
  1201. Dim StrIP
  1202. Dim strSubnet
  1203. Dim strGATEWAY
  1204. Dim strMetric
  1205. Dim strTmpIP
  1206. Dim strTmpGATEWAY
  1207. Dim i
  1208. Dim intReturnValue
  1209. Dim arrGATEWAY
  1210. Dim strRetURL
  1211. Dim retVal
  1212. Redim arrIPList(0)
  1213. Redim arrGATEWAYList(0)
  1214. Redim arrSubnetList(0)
  1215. 'Initializing to FALSE
  1216. setNIC = FALSE
  1217. Call SA_TraceOut(SOURCE_FILE, "setNIC")
  1218. 'Connecting to the server
  1219. Set objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  1220. if Err.number <> 0 then
  1221. SA_ServeFailurePage L_WMI_CONNECTIONFAIL_ERRORMESSAGE
  1222. Exit Function
  1223. end if
  1224. 'Checks whether ServerAppliance IP Address is equal to IPAddress entered
  1225. 'Added check to only validate IP when we are specifying it (Static IP)
  1226. if (NOT(F_strRadIP = 0)) AND (trim(g_initialIPAddress) <> trim(F_strIPAddress)) then
  1227. '
  1228. ' Check to see if address is in-use
  1229. if ( TRUE = Ping(F_strIPAddress) ) then
  1230. call SA_SetActiveTabPage(page,g_iTabGeneral)
  1231. SA_SetErrMsg L_IP_INUSE_ERRORMESSAGE
  1232. exit function
  1233. end if
  1234. end if
  1235. 'Getting the instance of the particulat NIC card
  1236. Set objInstance = getNetworkAdapterObject(objService,g_strDeviceID)
  1237. If ( F_strRadIP = 0 ) Then
  1238. Call SA_TraceOut(SOURCE_FILE, "Enabled DHCP")
  1239. if ( Not objInstance.DHCPEnabled ) then
  1240. intReturnValue = enableDHCP(objInstance)
  1241. end if
  1242. 'Connecting to default namespace to carry registry operations
  1243. Set objRegistry=regConnection()
  1244. If (objRegistry is Nothing) Then
  1245. SA_ServeFailurePage L_SERVERCONNECTIONFAIL_ERRORMESSAGE
  1246. Exit Function
  1247. End If
  1248. 'Getting the SettingID
  1249. strSettingID=objInstance.SettingID
  1250. 'Set Interface metric
  1251. intReturnValue=updateRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" & strSettingID ,"InterfaceMetric",F_nConnectionMetric,CONST_DWORD)
  1252. If intReturnValue = FALSE Then
  1253. SA_SetErrMsg L_NIC_IP_ERR_COULDNOTSETIPCONNECTIONMETRIC & "(" & Hex(Err.Number) & ")"
  1254. Exit Function
  1255. End If
  1256. setNIC = TRUE
  1257. 'Release the objects
  1258. Set objInstance = Nothing
  1259. Set objRegistry=Nothing
  1260. Exit Function
  1261. End If
  1262. 'Connecting to default namespace to carry registry operations
  1263. Set objRegistry=regConnection()
  1264. if F_strListIP = "" then
  1265. F_strListIP = F_strIPAddress & ":" & F_strSubnetMask
  1266. end if
  1267. if F_strListGateway = "" then
  1268. F_strListGateway = F_strGatewayAddress & " "+L_METRIC_TEXT+" 1;"
  1269. end if
  1270. If (objRegistry is Nothing) Then
  1271. SA_ServeFailurePage L_SERVERCONNECTIONFAIL_ERRORMESSAGE
  1272. Exit Function
  1273. End If
  1274. 'Getting the SettingID
  1275. strSettingID=objInstance.SettingID
  1276. Dim arrNewIp
  1277. Dim arrNewSubnet
  1278. Dim nPos
  1279. 'Split Ip List into arrays of Ip and Subnet mask
  1280. nPos = InStr(F_strListIP, ";")
  1281. if( Cint(nPos) = 0 ) then
  1282. ReDim strTmpIP(0)
  1283. strTmpIP(0) = F_strListIP
  1284. else
  1285. strTmpIP = Split(F_strListIP, ";",-1,1)
  1286. end if
  1287. ReDim arrNewIp(UBound(strTmpIp))
  1288. ReDim arrNewSubnet(UBound(strTmpIp))
  1289. 'Loop to pack Ip's and subnetmasks in different variables
  1290. For i= 0 To UBound(strTmpIp)
  1291. arrTemp = Split(strTmpIP(i),":",-1,1)
  1292. arrNewIp(i) = arrTemp(0)
  1293. arrNewSubnet(i) = arrTemp(1)
  1294. Next
  1295. 'Split Gateway List into arrays of gateway and metric
  1296. strTmpGATEWAY = Split(F_strListGateway, ";", -1, 1)
  1297. redim arrGATEWAY(UBound(strTmpGATEWAY))
  1298. 'Loop to pack Gateways's and Metrics in different variables
  1299. For i= 0 to Ubound(strTmpGATEWAY)
  1300. if strTmpGATEWAY(i) = "" then
  1301. exit for
  1302. end if
  1303. arrTemp = Split(strTmpGATEWAY(i)," "+L_METRIC_TEXT+" ",-1,1)
  1304. If (isnull (strGATEWAY)) Then
  1305. strGATEWAY = arrTemp(0) & ";"
  1306. Else
  1307. strGATEWAY = strGATEWAY & arrTemp(0) & ";"
  1308. End If
  1309. If (isnull (strMetric)) Then
  1310. strMetric = arrTemp(1) & ";"
  1311. Else
  1312. strMetric = strMetric & arrTemp(1) & ";"
  1313. End If
  1314. Next
  1315. 'call wmi method EnableStatic in win32_networkadapterconfiguration to set the static ip
  1316. 'sets the ip and subnet
  1317. Call objInstance.EnableStatic(arrNewIp, arrNewSubnet)
  1318. If Err.Number <> 0 Then
  1319. SA_SetErrMsg L_NIC_IP_ERR_COULDNOTSETIP & objInstance.Description & "(" & Hex(Err.Number) & ")"
  1320. Exit Function
  1321. end if
  1322. if strGATEWAY <> "" then
  1323. strGATEWAY=Mid(strGATEWAY,1,(Len(strGATEWAY)-1))
  1324. end if
  1325. 'Splitting the string into array of GATEWAYS
  1326. redim arrGATEWAY(UBound(strTmpGATEWAY))
  1327. arrGATEWAY = split(strGATEWAY, ";", -1 ,1)
  1328. if strMetric <> "" then
  1329. strMetric=Mid(strMetric,1,(Len(strMetric)-1))
  1330. end if
  1331. 'Splitting the string into array of GATEWAYMetrics
  1332. arrMetricList= split(strMetric, ";", -1 ,1)
  1333. 'Sets gateway and connection metric
  1334. intReturnValue=objInstance.SetGateways(arrGATEWAY,arrMetricList)
  1335. If intReturnValue <> 0 Then
  1336. SA_SetErrMsg L_NIC_IP_ERR_COULDNOTSETGATEWAY & objInstance.Description & "(" & Hex(Err.Number) & ")"
  1337. Exit Function
  1338. end if
  1339. 'Sets Interface metric
  1340. intReturnValue=updateRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" & strSettingID ,"InterfaceMetric",F_nConnectionMetric,CONST_DWORD)
  1341. If intReturnValue = FALSE Then
  1342. SA_SetErrMsg L_NIC_IP_ERR_COULDNOTSETIPCONNECTIONMETRIC & "(" & Hex(Err.Number) & ")"
  1343. Exit Function
  1344. End If
  1345. 'Set to Nothing
  1346. Set objService=Nothing
  1347. Set objRegistry=Nothing
  1348. Set objInstance=Nothing
  1349. setNIC = TRUE
  1350. End Function
  1351. '-------------------------------------------------------------------------
  1352. 'Function: GetReturnURL
  1353. 'Description: Forms new URL for changed IP
  1354. 'Input Variables: strNewIP
  1355. 'Output Variables: strRetURL 'returns newly formed URL
  1356. 'Returns: string
  1357. 'Global Variables: None
  1358. '-------------------------------------------------------------------------
  1359. Function GetReturnURL(strNewIp)
  1360. Err.Clear
  1361. On Error Resume Next
  1362. GetReturnURL = ""
  1363. Dim strRetURL
  1364. Dim strBase
  1365. Dim strTab
  1366. strBase = SA_GetNewHostURLBase(strNewIp, SA_DEFAULT, FALSE, SA_DEFAULT)
  1367. strRetURL = strBase & "network/nicinterface_prop.asp"
  1368. strTab = GetTab1()
  1369. If ( Len(strTab) > 0 ) Then
  1370. Call SA_MungeURL(strRetURL, "Tab1", strTab)
  1371. End If
  1372. strTab = GetTab2()
  1373. If ( Len(strTab) > 0 ) Then
  1374. Call SA_MungeURL(strRetURL, "Tab2", strTab)
  1375. End If
  1376. Call SA_TraceOut(SOURCE_FILE, strRetURL)
  1377. GetReturnURL = strRetURL
  1378. End Function
  1379. Function Ping(ByVal sIP)
  1380. on error resume next
  1381. err.Clear()
  1382. Dim oHelper
  1383. Ping = FALSE
  1384. Set oHelper = CreateObject("ComHelper.NetworkTools")
  1385. if ( Err.Number <> 0 ) Then
  1386. Call SA_TraceOut("INC_GLOBAL", "Error creating ComHelper.NetworkTools object, error: " + CStr(Hex(Err.Number)))
  1387. Exit Function
  1388. End If
  1389. Ping = oHelper.Ping(sIP)
  1390. if ( Err.Number <> 0 ) Then
  1391. Ping = FALSE
  1392. Call SA_TraceOut("INC_GLOBAL", "oHelper.Ping(), error: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  1393. Exit Function
  1394. End If
  1395. if ( Ping > 0 ) Then
  1396. Ping = TRUE
  1397. End If
  1398. Set oHelper = Nothing
  1399. End Function
  1400. %>