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.

1054 lines
31 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // savenet.c
  8. //
  9. // Description:
  10. // Adds the appropriate settings to the output queue for each of the
  11. // Clients, Services and Protocols installed.
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "pch.h"
  15. #include "allres.h"
  16. //
  17. // String constants
  18. //
  19. static const LPTSTR StrConstYes = _T("Yes");
  20. static const LPTSTR StrConstNo = _T("No");
  21. static const LPTSTR StrConstStar = _T("*");
  22. static const LPTSTR StrComma = _T(",");
  23. //
  24. // local prototypes
  25. //
  26. static VOID WriteOutCustomNetSettings( HWND );
  27. static VOID WriteOutAppleTalkSettings( VOID );
  28. static VOID WriteOutDlcProtocolSettings( VOID );
  29. static VOID WriteOutFileAndPrintSharingSettings( VOID );
  30. static VOID WriteOutIpxSettings( VOID );
  31. static VOID WriteOutMSClientSettings( VOID );
  32. static VOID WriteOutNetBeuiSettings( VOID );
  33. static VOID WriteOutNetWareSettings( VOID );
  34. static VOID WriteOutNetworkMonitorSettings( VOID );
  35. static VOID WriteOutPacketSchedulingDriverSettings( VOID );
  36. static VOID WriteOutSapAgentSettings( VOID );
  37. static VOID WriteOutTcpipSettings( IN HWND hwnd );
  38. static VOID WriteOutAdapterSpecificTcpipSettings( IN HWND hwnd,
  39. IN TCHAR *szSectionName,
  40. IN NETWORK_ADAPTER_NODE *pAdapter );
  41. extern VOID NamelistToCommaString( IN NAMELIST* pNamelist, OUT TCHAR *szBuffer, IN DWORD cbSize);
  42. //----------------------------------------------------------------------------
  43. //
  44. // Function: WriteOutNetSettings
  45. //
  46. // Purpose: Writes out network settings
  47. //
  48. // Arguments: IN HWND hwnd - handle to the dialog
  49. //
  50. // Returns: VOID
  51. //
  52. //----------------------------------------------------------------------------
  53. extern VOID
  54. WriteOutNetSettings( IN HWND hwnd ) {
  55. if( NetSettings.iNetworkingMethod == CUSTOM_NETWORKING ) {
  56. SettingQueue_AddSetting(_T("Networking"),
  57. _T("InstallDefaultComponents"),
  58. StrConstNo,
  59. SETTING_QUEUE_ANSWERS);
  60. WriteOutCustomNetSettings( hwnd );
  61. }
  62. else {
  63. SettingQueue_AddSetting(_T("Networking"),
  64. _T("InstallDefaultComponents"),
  65. StrConstYes,
  66. SETTING_QUEUE_ANSWERS);
  67. }
  68. }
  69. //----------------------------------------------------------------------------
  70. //
  71. // Function: WriteOutCustomNetSettings
  72. //
  73. // Purpose: Add to the output queue the settings for each of the Clients,
  74. // Services and Protocols installed.
  75. //
  76. // Arguments: IN HWND hwnd - handle to the dialog
  77. //
  78. // Returns: VOID
  79. //
  80. //----------------------------------------------------------------------------
  81. static VOID
  82. WriteOutCustomNetSettings( IN HWND hwnd ) {
  83. INT iCount;
  84. NETWORK_ADAPTER_NODE *pAdapter;
  85. NETWORK_COMPONENT *pNetComponent;
  86. TCHAR szAdapter[MAX_STRING_LEN] = _T("");
  87. TCHAR szParams[MAX_STRING_LEN] = _T("");
  88. HRESULT hrPrintf;
  89. //
  90. // Don't write out [NetAdapters] or params section on a sysprep because
  91. // they aren't supported.
  92. //
  93. if( WizGlobals.iProductInstall != PRODUCT_SYSPREP )
  94. {
  95. for( pAdapter = NetSettings.NetworkAdapterHead, iCount = 1;
  96. pAdapter;
  97. pAdapter = pAdapter->next, iCount++ ) {
  98. hrPrintf=StringCchPrintf( szAdapter, AS(szAdapter), _T("Adapter%d"), iCount );
  99. hrPrintf=StringCchPrintf( szParams, AS(szParams), _T("params.%s"), szAdapter );
  100. SettingQueue_AddSetting( _T("NetAdapters"),
  101. szAdapter,
  102. szParams,
  103. SETTING_QUEUE_ANSWERS );
  104. //
  105. // If more than 1 network adapter will be installed then we have
  106. // to specify the Plug and Play IDs
  107. //
  108. if( NetSettings.iNumberOfNetworkCards > 1) {
  109. SettingQueue_AddSetting( szParams,
  110. _T("INFID"),
  111. pAdapter->szPlugAndPlayID,
  112. SETTING_QUEUE_ANSWERS );
  113. }
  114. szAdapter[0] = _T('\0');
  115. szParams[0] = _T('\0');
  116. }
  117. if( NetSettings.iNumberOfNetworkCards == 1 ) {
  118. SettingQueue_AddSetting( _T("params.Adapter1"),
  119. _T("INFID"),
  120. StrConstStar,
  121. SETTING_QUEUE_ANSWERS );
  122. }
  123. }
  124. //
  125. // Iterate over the Net list writing out settings for the
  126. // installed components
  127. //
  128. for( pNetComponent = NetSettings.NetComponentsList;
  129. pNetComponent;
  130. pNetComponent = pNetComponent->next )
  131. {
  132. if( pNetComponent->bInstalled ) {
  133. //
  134. // find the appropriate function to call to write its settings
  135. //
  136. switch( pNetComponent->iPosition ) {
  137. case MS_CLIENT_POSITION:
  138. WriteOutMSClientSettings();
  139. break;
  140. case NETWARE_CLIENT_POSITION:
  141. if( WizGlobals.iPlatform == PLATFORM_WORKSTATION || WizGlobals.iPlatform == PLATFORM_PERSONAL )
  142. {
  143. WriteOutNetWareSettings();
  144. }
  145. break;
  146. case GATEWAY_FOR_NETWARE_POSITION:
  147. if( WizGlobals.iPlatform == PLATFORM_SERVER || WizGlobals.iPlatform == PLATFORM_ENTERPRISE || WizGlobals.iPlatform == PLATFORM_WEBBLADE)
  148. {
  149. WriteOutNetWareSettings();
  150. }
  151. break;
  152. case FILE_AND_PRINT_SHARING_POSITION:
  153. WriteOutFileAndPrintSharingSettings();
  154. break;
  155. case PACKET_SCHEDULING_POSITION:
  156. WriteOutPacketSchedulingDriverSettings();
  157. break;
  158. case SAP_AGENT_POSITION:
  159. WriteOutSapAgentSettings();
  160. break;
  161. case APPLETALK_POSITION:
  162. WriteOutAppleTalkSettings();
  163. break;
  164. case DLC_POSITION:
  165. WriteOutDlcProtocolSettings();
  166. break;
  167. case TCPIP_POSITION:
  168. WriteOutTcpipSettings( hwnd );
  169. break;
  170. case NETBEUI_POSITION:
  171. WriteOutNetBeuiSettings();
  172. break;
  173. case NETWORK_MONITOR_AGENT_POSITION:
  174. WriteOutNetworkMonitorSettings();
  175. break;
  176. case IPX_POSITION:
  177. WriteOutIpxSettings();
  178. break;
  179. default:
  180. AssertMsg( FALSE,
  181. "Bad case in Net Save switch block." );
  182. }
  183. }
  184. }
  185. }
  186. //----------------------------------------------------------------------------
  187. //
  188. // Function: WriteOutMSClientSettings
  189. //
  190. // Purpose: Adds the settings for the Client for MS Networks to the
  191. // output queue.
  192. //
  193. // Arguments: VOID
  194. //
  195. // Returns: VOID
  196. //
  197. //----------------------------------------------------------------------------
  198. static VOID
  199. WriteOutMSClientSettings( VOID ) {
  200. LPTSTR lpNameServiceProvider = _T("");
  201. LPTSTR lpNameServiceNetworkAddress = _T("");
  202. SettingQueue_AddSetting( _T("NetClients"),
  203. _T("MS_MSClient"),
  204. _T("params.MS_MSClient"),
  205. SETTING_QUEUE_ANSWERS );
  206. if( NetSettings.NameServiceProvider == MS_CLIENT_WINDOWS_LOCATOR )
  207. {
  208. lpNameServiceProvider = _T("");
  209. }
  210. else if( NetSettings.NameServiceProvider == MS_CLIENT_DCE_CELL_DIR_SERVICE )
  211. {
  212. lpNameServiceProvider = _T("ncacn_ip_tcp");
  213. lpNameServiceNetworkAddress = NetSettings.szNetworkAddress;
  214. }
  215. else
  216. {
  217. AssertMsg( FALSE,
  218. "Invalid case for NameServiceProvider" );
  219. }
  220. SettingQueue_AddSetting( _T("params.MS_MSClient"),
  221. _T("NameServiceProtocol"),
  222. lpNameServiceProvider,
  223. SETTING_QUEUE_ANSWERS );
  224. SettingQueue_AddSetting( _T("params.MS_MSClient"),
  225. _T("NameServiceNetworkAddress"),
  226. lpNameServiceNetworkAddress,
  227. SETTING_QUEUE_ANSWERS );
  228. }
  229. //----------------------------------------------------------------------------
  230. //
  231. // Function: WriteOutNetWareSettings
  232. //
  233. // Purpose: Adds the settings for Netware to the output queue.
  234. //
  235. // Arguments: VOID
  236. //
  237. // Returns: VOID
  238. //
  239. //----------------------------------------------------------------------------
  240. static VOID
  241. WriteOutNetWareSettings( VOID ) {
  242. LPTSTR lpPreferredServer = _T("");
  243. LPTSTR lpDefaultTree = _T("");
  244. LPTSTR lpDefaultContext = _T("");
  245. LPTSTR lpLogonScript = _T("");
  246. SettingQueue_AddSetting( _T("NetClients"),
  247. _T("MS_NWClient"),
  248. _T("params.MS_NWClient"),
  249. SETTING_QUEUE_ANSWERS );
  250. if( NetSettings.bDefaultTreeContext ) {
  251. lpDefaultTree = NetSettings.szDefaultTree;
  252. lpDefaultContext = NetSettings.szDefaultContext;
  253. }
  254. else {
  255. lpPreferredServer = NetSettings.szPreferredServer;
  256. }
  257. if( NetSettings.bNetwareLogonScript ) {
  258. lpLogonScript = StrConstYes;
  259. }
  260. else {
  261. lpLogonScript = StrConstNo;
  262. }
  263. SettingQueue_AddSetting( _T("params.MS_NWClient"),
  264. _T("PreferredServer"),
  265. lpPreferredServer,
  266. SETTING_QUEUE_ANSWERS );
  267. SettingQueue_AddSetting( _T("params.MS_NWClient"),
  268. _T("DefaultTree"),
  269. lpDefaultTree,
  270. SETTING_QUEUE_ANSWERS );
  271. SettingQueue_AddSetting( _T("params.MS_NWClient"),
  272. _T("DefaultContext"),
  273. lpDefaultContext,
  274. SETTING_QUEUE_ANSWERS );
  275. SettingQueue_AddSetting( _T("params.MS_NWClient"),
  276. _T("LogonScript"),
  277. lpLogonScript,
  278. SETTING_QUEUE_ANSWERS );
  279. }
  280. //----------------------------------------------------------------------------
  281. //
  282. // Function: WriteOutFileAndPrintSharingSettings
  283. //
  284. // Purpose: Adds the settings for File and Print Sharing to the output queue.
  285. //
  286. // Arguments: VOID
  287. //
  288. // Returns: VOID
  289. //
  290. //----------------------------------------------------------------------------
  291. static VOID
  292. WriteOutFileAndPrintSharingSettings( VOID ) {
  293. SettingQueue_AddSetting( _T("NetServices"),
  294. _T("MS_SERVER"),
  295. _T("params.MS_SERVER"),
  296. SETTING_QUEUE_ANSWERS );
  297. SettingQueue_AddSetting( _T("params.MS_SERVER"),
  298. _T(""),
  299. _T(""),
  300. SETTING_QUEUE_ANSWERS );
  301. }
  302. //----------------------------------------------------------------------------
  303. //
  304. // Function: WriteOutPacketSchedulingDriverSettings
  305. //
  306. // Purpose: Adds the settings for the QoS Packet Scheduler to the
  307. // output queue.
  308. //
  309. // Arguments: VOID
  310. //
  311. // Returns: VOID
  312. //
  313. //----------------------------------------------------------------------------
  314. static VOID
  315. WriteOutPacketSchedulingDriverSettings( VOID ) {
  316. SettingQueue_AddSetting( _T("NetServices"),
  317. _T("MS_PSched"),
  318. _T("params.MS_PSched"),
  319. SETTING_QUEUE_ANSWERS );
  320. SettingQueue_AddSetting( _T("params.MS_PSched"),
  321. _T(""),
  322. _T(""),
  323. SETTING_QUEUE_ANSWERS );
  324. }
  325. //----------------------------------------------------------------------------
  326. //
  327. // Function: WriteOutSapAgentSettings
  328. //
  329. // Purpose: Adds the settings for the SAP Agent to the output queue.
  330. //
  331. // Arguments: VOID
  332. //
  333. // Returns: VOID
  334. //
  335. //----------------------------------------------------------------------------
  336. static VOID
  337. WriteOutSapAgentSettings( VOID ) {
  338. SettingQueue_AddSetting( _T("NetServices"),
  339. _T("MS_NwSapAgent"),
  340. _T("params.MS_NwSapAgent"),
  341. SETTING_QUEUE_ANSWERS );
  342. SettingQueue_AddSetting( _T("params.MS_NwSapAgent"),
  343. _T(""),
  344. _T(""),
  345. SETTING_QUEUE_ANSWERS );
  346. }
  347. //----------------------------------------------------------------------------
  348. //
  349. // Function: WriteOutAppleTalkSettings
  350. //
  351. // Purpose: Adds the settings for AppleTalk to the output queue.
  352. //
  353. // Arguments: VOID
  354. //
  355. // Returns: VOID
  356. //
  357. //----------------------------------------------------------------------------
  358. static VOID
  359. WriteOutAppleTalkSettings( VOID ) {
  360. // ISSUE-2002/02/28-stelo- fill in the parameters, once I know what ones to use
  361. SettingQueue_AddSetting( _T("NetProtocols"),
  362. _T("MS_AppleTalk"),
  363. _T("params.MS_AppleTalk"),
  364. SETTING_QUEUE_ANSWERS );
  365. /*
  366. SettingQueue_AddSetting( _T("params.MS_AppleTalk"),
  367. _T("DefaultZone"),
  368. NetSettings.szDefaultZone,
  369. SETTING_QUEUE_ANSWERS );
  370. */
  371. }
  372. //----------------------------------------------------------------------------
  373. //
  374. // Function: WriteOutDlcProtocolSettings
  375. //
  376. // Purpose: Adds the settings for the DLC protocol to the output queue.
  377. //
  378. // Arguments: VOID
  379. //
  380. // Returns: VOID
  381. //
  382. //----------------------------------------------------------------------------
  383. static VOID
  384. WriteOutDlcProtocolSettings( VOID ) {
  385. SettingQueue_AddSetting( _T("NetProtocols"),
  386. _T("MS_DLC"),
  387. _T("params.MS_DLC"),
  388. SETTING_QUEUE_ANSWERS );
  389. SettingQueue_AddSetting( _T("params.MS_DLC"),
  390. _T(""),
  391. _T(""),
  392. SETTING_QUEUE_ANSWERS );
  393. }
  394. //----------------------------------------------------------------------------
  395. //
  396. // Function: WriteOutNetBeuiSettings
  397. //
  398. // Purpose: Adds the settings for Net BEUI to the output queue.
  399. //
  400. // Arguments: VOID
  401. //
  402. // Returns: VOID
  403. //
  404. //----------------------------------------------------------------------------
  405. static VOID
  406. WriteOutNetBeuiSettings( VOID ) {
  407. SettingQueue_AddSetting( _T("NetProtocols"),
  408. _T("MS_NetBEUI"),
  409. _T("params.MS_NetBEUI"),
  410. SETTING_QUEUE_ANSWERS );
  411. SettingQueue_AddSetting( _T("params.MS_NetBEUI"),
  412. _T(""),
  413. _T(""),
  414. SETTING_QUEUE_ANSWERS );
  415. }
  416. //----------------------------------------------------------------------------
  417. //
  418. // Function: WriteOutNetworkMonitorSettings
  419. //
  420. // Purpose: Adds the settings for the Network Monitor to the output queue.
  421. //
  422. // Arguments: VOID
  423. //
  424. // Returns: VOID
  425. //
  426. //----------------------------------------------------------------------------
  427. static VOID
  428. WriteOutNetworkMonitorSettings( VOID ) {
  429. SettingQueue_AddSetting( _T("NetProtocols"),
  430. _T("MS_NetMon"),
  431. _T("params.MS_NetMon"),
  432. SETTING_QUEUE_ANSWERS );
  433. SettingQueue_AddSetting( _T("params.MS_NetMon"),
  434. _T(""),
  435. _T(""),
  436. SETTING_QUEUE_ANSWERS );
  437. }
  438. //----------------------------------------------------------------------------
  439. //
  440. // Function: WriteOutIpxSettings
  441. //
  442. // Purpose: Adds the settings for the IPX protocol to the output queue.
  443. //
  444. // Arguments: VOID
  445. //
  446. // Returns: VOID
  447. //
  448. //----------------------------------------------------------------------------
  449. static VOID
  450. WriteOutIpxSettings( VOID ) {
  451. INT iCount = 0;
  452. INT iCharCount = 0;
  453. TCHAR szAdapterSectionsBuffer[MAX_INILINE_LEN] = _T("");
  454. TCHAR szAdapter[MAX_INILINE_LEN] = _T("");
  455. TCHAR szParams[MAX_INILINE_LEN] = _T("");
  456. NETWORK_ADAPTER_NODE *pAdapter;
  457. HRESULT hrCat;
  458. HRESULT hrPrintf;
  459. SettingQueue_AddSetting( _T("NetProtocols"),
  460. _T("MS_NWIPX"),
  461. _T("params.MS_NWIPX"),
  462. SETTING_QUEUE_ANSWERS );
  463. SettingQueue_AddSetting( _T("params.MS_NWIPX"),
  464. _T("VirtualNetworkNumber"),
  465. NetSettings.szInternalNetworkNumber,
  466. SETTING_QUEUE_ANSWERS );
  467. //
  468. // Build up the AdapterSections string by iterating over the list and
  469. // appending a string for each entry and then write out the IPX settings
  470. // specific for that adapter
  471. //
  472. for( pAdapter = NetSettings.NetworkAdapterHead, iCount = 1;
  473. pAdapter;
  474. pAdapter = pAdapter->next, iCount++ ) {
  475. hrPrintf=StringCchPrintf( szParams, AS(szParams), _T("params.MS_NWIPX.Adapter%d"), iCount );
  476. iCharCount= lstrlen(szParams);
  477. //
  478. // Break out of the for loop if there is no more room in the buffer
  479. // - the +1 is to take into account the space the comma takes up
  480. //
  481. if( ( lstrlen( szAdapterSectionsBuffer ) + iCharCount + 1 ) >= MAX_INILINE_LEN ) {
  482. break;
  483. }
  484. //
  485. // Don't add the comma before the first item in the list
  486. //
  487. if( iCount != 1 ) {
  488. hrCat=StringCchCat( szAdapterSectionsBuffer, AS(szAdapterSectionsBuffer), StrComma );
  489. }
  490. hrCat=StringCchCat( szAdapterSectionsBuffer, AS(szAdapterSectionsBuffer), szParams );
  491. hrPrintf=StringCchPrintf( szAdapter, AS(szAdapter), _T("Adapter%d"), iCount );
  492. SettingQueue_AddSetting( szParams,
  493. _T("SpecificTo"),
  494. szAdapter,
  495. SETTING_QUEUE_ANSWERS );
  496. SettingQueue_AddSetting( szParams,
  497. _T("PktType"),
  498. pAdapter->szFrameType,
  499. SETTING_QUEUE_ANSWERS );
  500. SettingQueue_AddSetting( szParams,
  501. _T("NetworkNumber"),
  502. pAdapter->szNetworkNumber,
  503. SETTING_QUEUE_ANSWERS );
  504. }
  505. SettingQueue_AddSetting( _T("params.MS_NWIPX"),
  506. _T("AdapterSections"),
  507. szAdapterSectionsBuffer,
  508. SETTING_QUEUE_ANSWERS );
  509. }
  510. //----------------------------------------------------------------------------
  511. //
  512. // Function: WriteOutTcpipSettings
  513. //
  514. // Purpose: Adds the settings for TCPIP to the output queue.
  515. //
  516. // Arguments: IN HWND hwnd - handle to the dialog
  517. //
  518. // Returns: VOID
  519. //
  520. //----------------------------------------------------------------------------
  521. static VOID
  522. WriteOutTcpipSettings( IN HWND hwnd ) {
  523. LPTSTR lpDns;
  524. LPTSTR lpDomainNameDevolution;
  525. LPTSTR lpLmHosts;
  526. INT iCount;
  527. INT iCharCount;
  528. NETWORK_ADAPTER_NODE *pAdapter;
  529. TCHAR szBuffer[MAX_INILINE_LEN];
  530. TCHAR szAdapterSectionsBuffer[MAX_INILINE_LEN] = _T("");
  531. TCHAR szAdapter[MAX_INILINE_LEN] = _T("");
  532. TCHAR szParams[MAX_INILINE_LEN] = _T("");
  533. HRESULT hrCat;
  534. HRESULT hrPrintf;
  535. SettingQueue_AddSetting( _T("NetProtocols"),
  536. _T("MS_TCPIP"),
  537. _T("params.MS_TCPIP"),
  538. SETTING_QUEUE_ANSWERS );
  539. //
  540. // Write out if DNS is going to be configured automatically or if not,
  541. // the actual IP addresses
  542. //
  543. if( NetSettings.bObtainDNSServerAutomatically ) {
  544. lpDns = StrConstYes;
  545. }
  546. else {
  547. lpDns = StrConstNo;
  548. }
  549. SettingQueue_AddSetting( _T("params.MS_TCPIP"),
  550. _T("DNS"),
  551. lpDns,
  552. SETTING_QUEUE_ANSWERS );
  553. //
  554. // Write out the DNS suffix names
  555. //
  556. NamelistToCommaString( &NetSettings.TCPIP_DNS_Domains, szBuffer, AS(szBuffer) );
  557. SettingQueue_AddSetting( _T("params.MS_TCPIP"),
  558. _T("DNSSuffixSearchOrder"),
  559. szBuffer,
  560. SETTING_QUEUE_ANSWERS );
  561. //
  562. // Write out if we are using Domain Name Devolution or not
  563. // (another name for "Include parent Domains"
  564. //
  565. if( NetSettings.bIncludeParentDomains ) {
  566. lpDomainNameDevolution = StrConstYes;
  567. }
  568. else {
  569. lpDomainNameDevolution = StrConstNo;
  570. }
  571. SettingQueue_AddSetting( _T("params.MS_TCPIP"),
  572. _T("UseDomainNameDevolution"),
  573. lpDomainNameDevolution,
  574. SETTING_QUEUE_ANSWERS );
  575. //
  576. // Write out if LM Hosts is enabled or not
  577. //
  578. if( NetSettings.bEnableLMHosts ) {
  579. lpLmHosts = StrConstYes;
  580. }
  581. else {
  582. lpLmHosts = StrConstNo;
  583. }
  584. SettingQueue_AddSetting( _T("params.MS_TCPIP"),
  585. _T("EnableLMHosts"),
  586. lpLmHosts,
  587. SETTING_QUEUE_ANSWERS );
  588. //
  589. // Setup for and write out the Adapter Specific TCP/IP Settings
  590. //
  591. for( pAdapter = NetSettings.NetworkAdapterHead, iCount = 1;
  592. pAdapter;
  593. pAdapter = pAdapter->next, iCount++ ) {
  594. hrPrintf=StringCchPrintf( szParams, AS(szParams), _T("params.MS_TCPIP.Adapter%d"), iCount );
  595. iCharCount= lstrlen(szParams);
  596. //
  597. // Break out of the for loop if there is no more room in the buffer
  598. // - the +1 is to take into account the space the comma takes up
  599. //
  600. if( ( lstrlen( szAdapterSectionsBuffer ) + iCharCount + 1 ) >= MAX_INILINE_LEN ) {
  601. break;
  602. }
  603. //
  604. // Don't add the comma before the first item in the list
  605. //
  606. if( iCount != 1) {
  607. hrCat=StringCchCat( szAdapterSectionsBuffer, AS(szAdapterSectionsBuffer), StrComma );
  608. }
  609. hrCat=StringCchCat( szAdapterSectionsBuffer, AS(szAdapterSectionsBuffer), szParams );
  610. hrPrintf=StringCchPrintf( szAdapter, AS(szAdapter), _T("Adapter%d"), iCount );
  611. SettingQueue_AddSetting( szParams,
  612. _T("SpecificTo"),
  613. szAdapter,
  614. SETTING_QUEUE_ANSWERS );
  615. WriteOutAdapterSpecificTcpipSettings( hwnd, szParams, pAdapter );
  616. }
  617. SettingQueue_AddSetting( _T("params.MS_TCPIP"),
  618. _T("AdapterSections"),
  619. szAdapterSectionsBuffer,
  620. SETTING_QUEUE_ANSWERS );
  621. }
  622. //----------------------------------------------------------------------------
  623. //
  624. // Function: WriteOutAdapterSpecificTcpipSettings
  625. //
  626. // Purpose: Writes out settings to the output queue that are specific to a
  627. // particular network adapter.
  628. //
  629. // Arguments: IN HWND hwnd - handle to the dialog window
  630. // IN TCHAR *szSectionName - section name to write in settings under
  631. // IN NETWORK_ADAPTER_NODE *pAdapter - the network adapter that has
  632. // the settings to write out
  633. //
  634. // Returns: VOID
  635. //
  636. //----------------------------------------------------------------------------
  637. static VOID
  638. WriteOutAdapterSpecificTcpipSettings( IN HWND hwnd,
  639. IN TCHAR *szSectionName,
  640. IN NETWORK_ADAPTER_NODE *pAdapter ) {
  641. INT nEntries;
  642. LPTSTR lpNetBios = NULL;
  643. TCHAR szIpAddresses[MAX_INILINE_LEN];
  644. TCHAR szSubnetMaskAddresses[MAX_INILINE_LEN];
  645. TCHAR szGatewayAddresses[MAX_INILINE_LEN];
  646. TCHAR szDnsAddresses[MAX_INILINE_LEN];
  647. TCHAR szWinsServerAddresses[MAX_INILINE_LEN];
  648. //
  649. // Write out if we are using DHCP or not
  650. // If we are not then write the IP, Subnet masks and Gateway
  651. // IP addresses
  652. //
  653. if( pAdapter->bObtainIPAddressAutomatically ) {
  654. SettingQueue_AddSetting( szSectionName,
  655. _T("DHCP"),
  656. _T("Yes"),
  657. SETTING_QUEUE_ANSWERS );
  658. }
  659. else {
  660. SettingQueue_AddSetting( szSectionName,
  661. _T("DHCP"),
  662. _T("No"),
  663. SETTING_QUEUE_ANSWERS );
  664. //
  665. // Write out the IP addresses
  666. //
  667. NamelistToCommaString( &pAdapter->Tcpip_IpAddresses,
  668. szIpAddresses,
  669. AS(szIpAddresses));
  670. SettingQueue_AddSetting( szSectionName,
  671. _T("IPAddress"),
  672. szIpAddresses,
  673. SETTING_QUEUE_ANSWERS );
  674. //
  675. // Write out the Subnet Masks
  676. //
  677. NamelistToCommaString( &pAdapter->Tcpip_SubnetMaskAddresses,
  678. szSubnetMaskAddresses,
  679. AS(szSubnetMaskAddresses));
  680. SettingQueue_AddSetting( szSectionName,
  681. _T("SubnetMask"),
  682. szSubnetMaskAddresses,
  683. SETTING_QUEUE_ANSWERS );
  684. //
  685. // Write out the gateways
  686. //
  687. NamelistToCommaString( &pAdapter->Tcpip_GatewayAddresses,
  688. szGatewayAddresses,
  689. AS(szGatewayAddresses));
  690. SettingQueue_AddSetting( szSectionName,
  691. _T("DefaultGateway"),
  692. szGatewayAddresses,
  693. SETTING_QUEUE_ANSWERS );
  694. }
  695. //
  696. // Write out the DNS Server addresses
  697. //
  698. if( ! NetSettings.bObtainDNSServerAutomatically ) {
  699. NamelistToCommaString( &pAdapter->Tcpip_DnsAddresses,
  700. szDnsAddresses,
  701. AS(szGatewayAddresses));
  702. SettingQueue_AddSetting( szSectionName,
  703. _T("DNSServerSearchOrder"),
  704. szDnsAddresses,
  705. SETTING_QUEUE_ANSWERS );
  706. }
  707. //
  708. // Write out if we are using WINS or not
  709. //
  710. nEntries = GetNameListSize( &pAdapter->Tcpip_WinsAddresses );
  711. // ISSUE-2002/02/28-stelo- is this the correct way of detecting if we are using WINS
  712. // or not, just checking to see if they added anything in the
  713. // list box?
  714. if( nEntries == 0 ) {
  715. SettingQueue_AddSetting( szSectionName,
  716. _T("WINS"),
  717. _T("No"),
  718. SETTING_QUEUE_ANSWERS );
  719. }
  720. else {
  721. SettingQueue_AddSetting( szSectionName,
  722. _T("WINS"),
  723. _T("Yes"),
  724. SETTING_QUEUE_ANSWERS );
  725. NamelistToCommaString( &pAdapter->Tcpip_WinsAddresses,
  726. szWinsServerAddresses,
  727. AS(szWinsServerAddresses));
  728. SettingQueue_AddSetting( szSectionName,
  729. _T("WinsServerList"),
  730. szWinsServerAddresses,
  731. SETTING_QUEUE_ANSWERS );
  732. }
  733. //
  734. // Write out the NetBIOS option
  735. //
  736. switch( pAdapter->iNetBiosOption ) {
  737. case 0: lpNetBios = _T("0"); break; // Use value generated by DHCP
  738. case 1: lpNetBios = _T("1"); break; // Enable NetBIOS over TCP/IP
  739. case 2: lpNetBios = _T("2"); break; // Disable NetBIOS over TCP/IP
  740. default: AssertMsg( FALSE,
  741. "Bad case in Net BIOS switch" );
  742. }
  743. if ( lpNetBios )
  744. {
  745. SettingQueue_AddSetting( szSectionName,
  746. _T("NetBIOSOptions"),
  747. lpNetBios,
  748. SETTING_QUEUE_ANSWERS );
  749. }
  750. //
  751. // Write out the DNS Domain name
  752. //
  753. SettingQueue_AddSetting( szSectionName,
  754. _T("DNSDomain"),
  755. pAdapter->szDNSDomainName,
  756. SETTING_QUEUE_ANSWERS );
  757. }
  758. //----------------------------------------------------------------------------
  759. //
  760. // Function: NamelistToCommaString
  761. //
  762. // Purpose: takes the elements of a Namelist and concatenates them together
  763. // into a string with each element separated by a comma
  764. //
  765. // For instance, the namelist 1->2->3->4 becomes the string 1,2,3,4
  766. //
  767. // it does NOT preserve the string inside of szBuffer
  768. //
  769. // assumes szBuffer is of size MAX_INILINE_LEN
  770. //
  771. // Arguments:
  772. //
  773. // Returns: VOID
  774. //
  775. //----------------------------------------------------------------------------
  776. VOID
  777. NamelistToCommaString( IN NAMELIST* pNamelist, OUT TCHAR *szBuffer, IN DWORD cbSize ) {
  778. INT i;
  779. INT nEntries;
  780. TCHAR *pString;
  781. HRESULT hrCat;
  782. szBuffer[0] = _T('\0');
  783. nEntries = GetNameListSize( pNamelist );
  784. for( i = 0; i < nEntries; i++ ) {
  785. //
  786. // Separate entries by a comma (but leave it off the first one)
  787. //
  788. if( i != 0 ) {
  789. hrCat=StringCchCat( szBuffer, cbSize, StrComma );
  790. }
  791. //
  792. // Get the new string
  793. //
  794. pString = GetNameListName( pNamelist, i );
  795. //
  796. // Append the IP string to the buffer
  797. //
  798. hrCat=StringCchCat( szBuffer, cbSize, pString );
  799. }
  800. }