Source code of Windows XP (NT5)
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.

1254 lines
37 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // loadnet.c
  8. //
  9. // Description:
  10. // Reads in the settings for the Clients, Services and Protocols.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "pch.h"
  14. //
  15. // String constants
  16. //
  17. static const LPTSTR StrConstYes = _T("Yes");
  18. static const LPTSTR StrConstNo = _T("No");
  19. //
  20. // Local prototypes
  21. //
  22. static VOID SetFlagToInstalled( INT iStringResourceId, HWND hwnd );
  23. static int GetNetworkAdapterCount( IN TCHAR szBuffer[] );
  24. static VOID GetNextAdapterSection( IN OUT TCHAR **pAdapterSections,
  25. OUT TCHAR szNetworkBuffer[] );
  26. static VOID ReadPlugAndPlayIds( IN HWND hwnd );
  27. static VOID ReadClientForMsNetworks( IN HWND hwnd );
  28. static VOID ReadClientServiceForNetware( IN HWND hwnd );
  29. static VOID ReadFileAndPrintSharing( IN HWND hwnd );
  30. static VOID ReadPacketSchedulingDriver( IN HWND hwnd );
  31. static VOID ReadSapAgentSettings( IN HWND hwnd );
  32. static VOID ReadAppleTalkSettings( IN HWND hwnd );
  33. static VOID ReadDlcSettings( IN HWND hwnd );
  34. static VOID ReadTcpipSettings( IN HWND hwnd );
  35. static VOID ReadNetBeuiSettings( IN HWND hwnd );
  36. static VOID ReadNetworkMonitorSettings( IN HWND hwnd );
  37. static VOID ReadIpxSettings( IN HWND hwnd );
  38. //----------------------------------------------------------------------------
  39. //
  40. // Function: ReadNetworkSettings
  41. //
  42. // Purpose: Reads in what network settings are set to be installed and reads
  43. // there settings.
  44. //
  45. // Arguments: IN HWND hwnd - handle to the dialog
  46. //
  47. // Returns: VOID
  48. //
  49. //----------------------------------------------------------------------------
  50. extern VOID
  51. ReadNetworkSettings( IN HWND hwnd )
  52. {
  53. TCHAR Buffer[MAX_INILINE_LEN];
  54. GetPrivateProfileString( _T("Networking"),
  55. _T("InstallDefaultComponents"),
  56. StrConstYes,
  57. Buffer,
  58. StrBuffSize(Buffer),
  59. FixedGlobals.ScriptName );
  60. if( lstrcmpi( Buffer, StrConstYes ) == 0 )
  61. {
  62. NetSettings.iNetworkingMethod = TYPICAL_NETWORKING;
  63. }
  64. else
  65. {
  66. NETWORK_COMPONENT *pNetComponent;
  67. NetSettings.iNetworkingMethod = CUSTOM_NETWORKING;
  68. //
  69. // Uninstall all Client, Service and Protocols before reading
  70. // which ones are to be installed
  71. //
  72. for( pNetComponent = NetSettings.NetComponentsList;
  73. pNetComponent;
  74. pNetComponent = pNetComponent->next )
  75. {
  76. pNetComponent->bInstalled = FALSE;
  77. }
  78. }
  79. ReadPlugAndPlayIds( hwnd );
  80. //
  81. // Read the Client settings
  82. //
  83. SettingQueue_MarkVolatile( _T("NetClients"),
  84. SETTING_QUEUE_ORIG_ANSWERS );
  85. ReadClientForMsNetworks( hwnd );
  86. ReadClientServiceForNetware( hwnd );
  87. //
  88. // Read the Service settings
  89. //
  90. SettingQueue_MarkVolatile( _T("NetServices"),
  91. SETTING_QUEUE_ORIG_ANSWERS );
  92. ReadFileAndPrintSharing( hwnd );
  93. ReadPacketSchedulingDriver( hwnd );
  94. ReadSapAgentSettings( hwnd );
  95. //
  96. // Read the Protocol settings
  97. //
  98. SettingQueue_MarkVolatile( _T("NetProtocols"),
  99. SETTING_QUEUE_ORIG_ANSWERS );
  100. ReadAppleTalkSettings( hwnd );
  101. ReadDlcSettings( hwnd );
  102. ReadTcpipSettings( hwnd );
  103. ReadNetBeuiSettings( hwnd );
  104. ReadNetworkMonitorSettings( hwnd );
  105. ReadIpxSettings( hwnd );
  106. }
  107. //----------------------------------------------------------------------------
  108. //
  109. // Function: ReadPlugAndPlayIds
  110. //
  111. // Purpose: read input file and fill global structs with the Plug and Play Ids
  112. //
  113. // Arguments: VOID
  114. //
  115. // Returns: VOID
  116. //
  117. //----------------------------------------------------------------------------
  118. VOID
  119. ReadPlugAndPlayIds( IN HWND hwnd )
  120. {
  121. INT iCount;
  122. INT NewNumberOfNetworkCards;
  123. TCHAR Buffer[MAX_INILINE_LEN] = _T("");
  124. TCHAR szAdapterSections[MAX_INILINE_LEN] = _T("");
  125. NETWORK_ADAPTER_NODE *pAdapter = NetSettings.NetworkAdapterHead;
  126. HRESULT hrPrintf;
  127. //
  128. // Count how many network cards there are
  129. //
  130. for( iCount = 1;
  131. ;
  132. iCount++ )
  133. {
  134. hrPrintf=StringCchPrintf( szAdapterSections,AS(szAdapterSections), _T("Adapter%d"), iCount );
  135. if( GetPrivateProfileString(_T("NetAdapters"),
  136. szAdapterSections,
  137. _T(""),
  138. Buffer,
  139. StrBuffSize(Buffer),
  140. FixedGlobals.ScriptName) <= 0 )
  141. {
  142. break; // no more adapters
  143. }
  144. }
  145. SettingQueue_MarkVolatile( _T("NetAdapters"),
  146. SETTING_QUEUE_ORIG_ANSWERS );
  147. NewNumberOfNetworkCards = iCount - 1;
  148. AdjustNetworkCardMemory( NewNumberOfNetworkCards,
  149. NetSettings.iNumberOfNetworkCards );
  150. NetSettings.iNumberOfNetworkCards = NewNumberOfNetworkCards;
  151. for( iCount = 1;
  152. iCount <= NewNumberOfNetworkCards;
  153. iCount++, pAdapter = pAdapter->next )
  154. {
  155. hrPrintf=StringCchPrintf( szAdapterSections,AS(szAdapterSections), _T("Adapter%d"), iCount );
  156. GetPrivateProfileString( _T("NetAdapters"),
  157. szAdapterSections,
  158. _T(""),
  159. Buffer,
  160. StrBuffSize(Buffer),
  161. FixedGlobals.ScriptName );
  162. SettingQueue_MarkVolatile( Buffer,
  163. SETTING_QUEUE_ORIG_ANSWERS );
  164. //
  165. // Read in the Plug and Play IDs
  166. //
  167. GetPrivateProfileString( Buffer,
  168. _T("INFID"),
  169. _T(""),
  170. pAdapter->szPlugAndPlayID,
  171. StrBuffSize( pAdapter->szPlugAndPlayID ),
  172. FixedGlobals.ScriptName );
  173. }
  174. }
  175. //----------------------------------------------------------------------------
  176. //
  177. // Function: ReadClientForMsNetworks
  178. //
  179. // Purpose: read input file and determine if the Client for Microsoft
  180. // Networks is to be installed and if so, read in its settings
  181. // and populate global structs
  182. //
  183. // Arguments: VOID
  184. //
  185. // Returns: VOID
  186. //
  187. //----------------------------------------------------------------------------
  188. VOID
  189. ReadClientForMsNetworks( IN HWND hwnd )
  190. {
  191. TCHAR Buffer[MAX_INILINE_LEN];
  192. TCHAR szNameServiceProvider[MAX_INILINE_LEN];
  193. TCHAR szNetworkBuffer[MAX_INILINE_LEN];
  194. //
  195. // See if MS Client is installed
  196. //
  197. if( GetPrivateProfileString(_T("NetClients"),
  198. _T("MS_MSClient"),
  199. _T(""),
  200. Buffer,
  201. StrBuffSize(Buffer),
  202. FixedGlobals.ScriptName) > 0)
  203. {
  204. //
  205. // MS Client is installed so set its installed flag to true
  206. //
  207. SetFlagToInstalled( IDS_CLIENT_FOR_MS_NETWORKS, hwnd );
  208. SettingQueue_MarkVolatile( Buffer,
  209. SETTING_QUEUE_ORIG_ANSWERS );
  210. //
  211. // and grab all of its settings from the
  212. // answer file
  213. //
  214. GetPrivateProfileString( Buffer,
  215. _T("NameServiceProtocol"),
  216. _T(""),
  217. szNameServiceProvider,
  218. StrBuffSize( szNameServiceProvider ),
  219. FixedGlobals.ScriptName );
  220. if ( LSTRCMPI(szNameServiceProvider, _T("ncacn_ip_tcp")) == 0 )
  221. {
  222. NetSettings.NameServiceProvider = MS_CLIENT_DCE_CELL_DIR_SERVICE;
  223. }
  224. else
  225. {
  226. NetSettings.NameServiceProvider = MS_CLIENT_WINDOWS_LOCATOR;
  227. }
  228. GetPrivateProfileString( Buffer,
  229. _T("NameServiceNetworkAddress"),
  230. NetSettings.szNetworkAddress,
  231. NetSettings.szNetworkAddress,
  232. StrBuffSize( NetSettings.szNetworkAddress ),
  233. FixedGlobals.ScriptName );
  234. }
  235. }
  236. //----------------------------------------------------------------------------
  237. //
  238. // Function: ReadClientServiceForNetware
  239. //
  240. // Purpose: read input file and determine if the Client Service for Netware
  241. // is to be installed
  242. //
  243. // Arguments: VOID
  244. //
  245. // Returns: VOID
  246. //
  247. //----------------------------------------------------------------------------
  248. VOID
  249. ReadClientServiceForNetware( IN HWND hwnd )
  250. {
  251. TCHAR Buffer[MAX_INILINE_LEN];
  252. TCHAR YesNoBuffer[MAX_INILINE_LEN];
  253. //
  254. // See if the NetWare Client is installed
  255. //
  256. if( GetPrivateProfileString(_T("NetClients"),
  257. _T("MS_NWClient"),
  258. _T(""),
  259. Buffer,
  260. StrBuffSize(Buffer),
  261. FixedGlobals.ScriptName) > 0)
  262. {
  263. //
  264. // Netware Client is installed so set its installed flag to true
  265. //
  266. // ISSUE-2002/02/28-stelo - verify this works since Netware client has two
  267. // different names, 1 for client, 1 for server
  268. SetFlagToInstalled( IDS_CLIENT_FOR_NETWARE, hwnd );
  269. SettingQueue_MarkVolatile( Buffer,
  270. SETTING_QUEUE_ORIG_ANSWERS );
  271. //
  272. // and grab all of its settings from the
  273. // answer file
  274. //
  275. GetPrivateProfileString( Buffer,
  276. _T("PreferredServer"),
  277. NetSettings.szPreferredServer,
  278. NetSettings.szPreferredServer,
  279. StrBuffSize(NetSettings.szPreferredServer),
  280. FixedGlobals.ScriptName );
  281. if( NetSettings.szPreferredServer[0] != _T('\0') )
  282. {
  283. NetSettings.bDefaultTreeContext = FALSE;
  284. }
  285. else
  286. {
  287. NetSettings.bDefaultTreeContext = TRUE;
  288. }
  289. GetPrivateProfileString(Buffer,
  290. _T("DefaultTree"),
  291. NetSettings.szDefaultTree,
  292. NetSettings.szDefaultTree,
  293. StrBuffSize(NetSettings.szDefaultTree),
  294. FixedGlobals.ScriptName);
  295. GetPrivateProfileString(Buffer,
  296. _T("DefaultContext"),
  297. NetSettings.szDefaultContext,
  298. NetSettings.szDefaultContext,
  299. StrBuffSize(NetSettings.szDefaultContext),
  300. FixedGlobals.ScriptName);
  301. GetPrivateProfileString(Buffer,
  302. _T("LogonScript"),
  303. NetSettings.szDefaultContext,
  304. YesNoBuffer,
  305. StrBuffSize(YesNoBuffer),
  306. FixedGlobals.ScriptName);
  307. if ( lstrcmpi(YesNoBuffer, StrConstYes) == 0 )
  308. NetSettings.bNetwareLogonScript = TRUE;
  309. else
  310. NetSettings.bNetwareLogonScript = FALSE;
  311. }
  312. }
  313. //----------------------------------------------------------------------------
  314. //
  315. // Function: ReadFileAndPrintSharing
  316. //
  317. // Purpose: read input file and determine if the File and Print Sharing
  318. // is to be installed
  319. //
  320. // Arguments: VOID
  321. //
  322. // Returns: VOID
  323. //
  324. //----------------------------------------------------------------------------
  325. VOID
  326. ReadFileAndPrintSharing( IN HWND hwnd )
  327. {
  328. TCHAR Buffer[MAX_INILINE_LEN];
  329. //
  330. // See if MS Server (File and Print Sharing) is installed
  331. //
  332. if( GetPrivateProfileString(_T("NetServices"),
  333. _T("MS_SERVER"),
  334. _T(""),
  335. Buffer,
  336. StrBuffSize(Buffer),
  337. FixedGlobals.ScriptName) > 0)
  338. {
  339. //
  340. // MS Server (File and Print Sharing) is installed so set its
  341. // installed flag to true
  342. //
  343. SetFlagToInstalled( IDS_FILE_AND_PRINT_SHARING, hwnd );
  344. SettingQueue_MarkVolatile( Buffer,
  345. SETTING_QUEUE_ORIG_ANSWERS );
  346. }
  347. }
  348. //----------------------------------------------------------------------------
  349. //
  350. // Function: ReadPacketSchedulingDriver
  351. //
  352. // Purpose: read input file and determine if the Packet Scheduling Driver
  353. // is to be installed
  354. //
  355. // Arguments: VOID
  356. //
  357. // Returns: VOID
  358. //
  359. //----------------------------------------------------------------------------
  360. VOID
  361. ReadPacketSchedulingDriver( IN HWND hwnd )
  362. {
  363. TCHAR Buffer[MAX_INILINE_LEN];
  364. //
  365. // See if Packet Scheduling Driver is installed
  366. //
  367. if( GetPrivateProfileString(_T("NetServices"),
  368. _T("MS_PSched"),
  369. _T(""),
  370. Buffer,
  371. StrBuffSize(Buffer),
  372. FixedGlobals.ScriptName) > 0)
  373. {
  374. //
  375. // Packet Scheduling Driver is installed so set its installed flag
  376. // to true
  377. //
  378. SetFlagToInstalled( IDS_PACKET_SCHEDULING_DRIVER, hwnd );
  379. SettingQueue_MarkVolatile( Buffer,
  380. SETTING_QUEUE_ORIG_ANSWERS );
  381. }
  382. }
  383. //----------------------------------------------------------------------------
  384. //
  385. // Function: ReadSapAgentSettings
  386. //
  387. // Purpose: read input file and determine if the SAP Agent is to be installed
  388. //
  389. // Arguments: VOID
  390. //
  391. // Returns: VOID
  392. //
  393. //----------------------------------------------------------------------------
  394. VOID
  395. ReadSapAgentSettings( IN HWND hwnd )
  396. {
  397. TCHAR Buffer[MAX_INILINE_LEN];
  398. //
  399. // See if SAP Agent is installed
  400. //
  401. if( GetPrivateProfileString(_T("NetServices"),
  402. _T("MS_NwSapAgent"),
  403. _T(""),
  404. Buffer,
  405. StrBuffSize(Buffer),
  406. FixedGlobals.ScriptName) > 0)
  407. {
  408. //
  409. // SAP Agent is installed so set its installed flag to true
  410. //
  411. SetFlagToInstalled( IDS_SAP_AGENT, hwnd );
  412. SettingQueue_MarkVolatile( Buffer,
  413. SETTING_QUEUE_ORIG_ANSWERS );
  414. }
  415. }
  416. //----------------------------------------------------------------------------
  417. //
  418. // Function: ReadAppleTalkSettings
  419. //
  420. // Purpose: read input file and determine if the AppleTalk protocol is to be
  421. // installed and if so, read in its settings
  422. //
  423. // Arguments: VOID
  424. //
  425. // Returns: VOID
  426. //
  427. //----------------------------------------------------------------------------
  428. VOID
  429. ReadAppleTalkSettings( IN HWND hwnd )
  430. {
  431. TCHAR Buffer[MAX_INILINE_LEN];
  432. //
  433. // See if AppleTalk is installed
  434. //
  435. if( GetPrivateProfileString(_T("NetProtocols"),
  436. _T("MS_AppleTalk"),
  437. _T(""),
  438. Buffer,
  439. StrBuffSize(Buffer),
  440. FixedGlobals.ScriptName) > 0)
  441. {
  442. //
  443. // AppleTalk is installed so set its installed flag to true
  444. //
  445. SetFlagToInstalled( IDS_APPLETALK_PROTOCOL, hwnd );
  446. //
  447. // and grab all of its settings from the
  448. // answer file
  449. //
  450. // ISSUE-2002/02/28-stelo- fill this in, once we know the
  451. // parameters to read in
  452. }
  453. }
  454. //----------------------------------------------------------------------------
  455. //
  456. // Function: ReadDlcSettings
  457. //
  458. // Purpose: read input file and determine if the DLC protocol is to be
  459. // installed
  460. //
  461. // Arguments: VOID
  462. //
  463. // Returns: VOID
  464. //
  465. //----------------------------------------------------------------------------
  466. VOID
  467. ReadDlcSettings( IN HWND hwnd )
  468. {
  469. TCHAR Buffer[MAX_INILINE_LEN];
  470. //
  471. // See if DLC is installed
  472. //
  473. if( GetPrivateProfileString(_T("NetProtocols"),
  474. _T("MS_DLC"),
  475. _T(""),
  476. Buffer,
  477. StrBuffSize(Buffer),
  478. FixedGlobals.ScriptName) > 0)
  479. {
  480. //
  481. // DLC is installed so set its installed flag to true
  482. //
  483. SetFlagToInstalled( IDS_DLC_PROTOCOL, hwnd );
  484. SettingQueue_MarkVolatile( Buffer,
  485. SETTING_QUEUE_ORIG_ANSWERS );
  486. }
  487. }
  488. //----------------------------------------------------------------------------
  489. //
  490. // Function: ReadTcpipSettings
  491. //
  492. // Purpose: read input file and determine if the TCP/IP protocol is to be
  493. // installed and if so, read in its settings
  494. //
  495. // Arguments: VOID
  496. //
  497. // Returns: VOID
  498. //
  499. //----------------------------------------------------------------------------
  500. VOID
  501. ReadTcpipSettings( IN HWND hwnd )
  502. {
  503. INT NewNumberOfNetworkCards;
  504. NETWORK_ADAPTER_NODE *pAdapter;
  505. TCHAR *pAdapterSections;
  506. TCHAR *pBuffer;
  507. TCHAR *pSubnetBuffer;
  508. TCHAR Buffer[MAX_INILINE_LEN];
  509. TCHAR szNetworkBuffer[MAX_INILINE_LEN] = _T("");
  510. TCHAR szSubnetBuffer[MAX_INILINE_LEN] = _T("");
  511. TCHAR szAdapterSections[MAX_INILINE_LEN] = _T("");
  512. TCHAR szIPString[IPSTRINGLENGTH] = _T("");
  513. TCHAR szSubnetString[IPSTRINGLENGTH] = _T("");
  514. //
  515. // See if TCP/IP is installed
  516. //
  517. if( GetPrivateProfileString(_T("NetProtocols"),
  518. _T("MS_TCPIP"),
  519. _T(""),
  520. Buffer,
  521. StrBuffSize(Buffer),
  522. FixedGlobals.ScriptName) > 0)
  523. {
  524. SettingQueue_MarkVolatile( Buffer,
  525. SETTING_QUEUE_ORIG_ANSWERS );
  526. //
  527. // TCP/IP is installed so set its installed flag to true
  528. //
  529. SetFlagToInstalled( IDS_TCPIP, hwnd );
  530. //
  531. // and grab all of its settings from the
  532. // answer file
  533. //
  534. GetPrivateProfileString( Buffer,
  535. _T("EnableLMHosts"),
  536. StrConstNo,
  537. szNetworkBuffer,
  538. StrBuffSize( szNetworkBuffer ),
  539. FixedGlobals.ScriptName );
  540. if( lstrcmpi( szNetworkBuffer, StrConstYes ) == 0 )
  541. NetSettings.bEnableLMHosts = TRUE;
  542. else
  543. NetSettings.bEnableLMHosts = FALSE;
  544. GetPrivateProfileString( Buffer,
  545. _T("UseDomainNameDevolution"),
  546. StrConstNo,
  547. szNetworkBuffer,
  548. StrBuffSize( szNetworkBuffer ),
  549. FixedGlobals.ScriptName );
  550. if( lstrcmpi( szNetworkBuffer, StrConstYes ) == 0 )
  551. NetSettings.bIncludeParentDomains = TRUE;
  552. else
  553. NetSettings.bIncludeParentDomains = FALSE;
  554. GetPrivateProfileString( Buffer,
  555. _T("DNS"),
  556. StrConstNo,
  557. szNetworkBuffer,
  558. StrBuffSize( szNetworkBuffer ),
  559. FixedGlobals.ScriptName );
  560. if( lstrcmpi( szNetworkBuffer, StrConstYes ) == 0 )
  561. NetSettings.bObtainDNSServerAutomatically = TRUE;
  562. else
  563. NetSettings.bObtainDNSServerAutomatically = FALSE;
  564. GetPrivateProfileString( Buffer,
  565. _T("AdapterSections"),
  566. _T(""),
  567. szAdapterSections,
  568. StrBuffSize( szAdapterSections ),
  569. FixedGlobals.ScriptName );
  570. NewNumberOfNetworkCards = GetNetworkAdapterCount( szAdapterSections );
  571. // allocate the right amount of space for the netword cards
  572. // that will be read in
  573. AdjustNetworkCardMemory( NewNumberOfNetworkCards,
  574. NetSettings.iNumberOfNetworkCards );
  575. NetSettings.iNumberOfNetworkCards = NewNumberOfNetworkCards;
  576. //
  577. // Load network adapter specific TCP/IP settings
  578. //
  579. pAdapterSections = szAdapterSections;
  580. for( pAdapter = NetSettings.NetworkAdapterHead;
  581. pAdapter;
  582. pAdapter = pAdapter->next )
  583. {
  584. GetNextAdapterSection( &pAdapterSections, szNetworkBuffer );
  585. SettingQueue_MarkVolatile( szNetworkBuffer,
  586. SETTING_QUEUE_ORIG_ANSWERS );
  587. //
  588. // Read in the DNS Domain Name
  589. //
  590. GetPrivateProfileString( szNetworkBuffer,
  591. _T("DNSDomain"),
  592. pAdapter->szDNSDomainName,
  593. pAdapter->szDNSDomainName,
  594. StrBuffSize( pAdapter->szDNSDomainName ),
  595. FixedGlobals.ScriptName );
  596. pAdapter->iNetBiosOption = GetPrivateProfileInt( szNetworkBuffer,
  597. _T("NetBIOSOptions"),
  598. pAdapter->iNetBiosOption,
  599. FixedGlobals.ScriptName );
  600. //
  601. // if it is not using server assigned DNS, then read in the
  602. // DNS IPs
  603. //
  604. if( !NetSettings.bObtainDNSServerAutomatically )
  605. {
  606. GetPrivateProfileString( szNetworkBuffer,
  607. _T("DNSServerSearchOrder"),
  608. _T(""),
  609. Buffer,
  610. StrBuffSize(Buffer),
  611. FixedGlobals.ScriptName );
  612. pBuffer = Buffer;
  613. //
  614. // Loop grabbing the DNS addresses and inserting them into
  615. // its namelist
  616. //
  617. while( GetCommaDelimitedEntry( szIPString, &pBuffer ) )
  618. {
  619. TcpipAddNameToNameList( &pAdapter->Tcpip_DnsAddresses,
  620. szIPString );
  621. }
  622. }
  623. //
  624. // Read from the file if it is using DHCP or not
  625. //
  626. GetPrivateProfileString( szNetworkBuffer,
  627. _T("DHCP"),
  628. StrConstYes,
  629. Buffer,
  630. StrBuffSize(Buffer),
  631. FixedGlobals.ScriptName );
  632. if ( lstrcmpi( Buffer, StrConstYes ) == 0 )
  633. pAdapter->bObtainIPAddressAutomatically = TRUE;
  634. else
  635. pAdapter->bObtainIPAddressAutomatically = FALSE;
  636. if( !pAdapter->bObtainIPAddressAutomatically )
  637. {
  638. //
  639. // DHCP is set to "No" so:
  640. // Read the IP and Subnet addresses from the file and
  641. // insert them into the proper variables
  642. //
  643. GetPrivateProfileString( szNetworkBuffer,
  644. _T("IPAddress"),
  645. _T(""),
  646. Buffer,
  647. StrBuffSize(Buffer),
  648. FixedGlobals.ScriptName );
  649. GetPrivateProfileString( szNetworkBuffer,
  650. _T("SubnetMask"),
  651. _T(""),
  652. szSubnetBuffer,
  653. StrBuffSize(szSubnetBuffer),
  654. FixedGlobals.ScriptName );
  655. pBuffer = Buffer;
  656. pSubnetBuffer = szSubnetBuffer;
  657. //
  658. // Loop grabbing the IP address and Subnet masks and
  659. // inserting them into their respective namelists
  660. //
  661. while( GetCommaDelimitedEntry( szIPString, &pBuffer ) &&
  662. GetCommaDelimitedEntry( szSubnetString, &pSubnetBuffer ) )
  663. {
  664. TcpipAddNameToNameList( &pAdapter->Tcpip_IpAddresses,
  665. szIPString );
  666. TcpipAddNameToNameList( &pAdapter->Tcpip_SubnetMaskAddresses,
  667. szSubnetString );
  668. }
  669. //
  670. // Read the Gateway addresses from the file and insert them
  671. // into the proper variables
  672. //
  673. GetPrivateProfileString( szNetworkBuffer,
  674. _T("DefaultGateway"),
  675. _T(""),
  676. Buffer,
  677. StrBuffSize(Buffer),
  678. FixedGlobals.ScriptName );
  679. pBuffer = Buffer;
  680. //
  681. // Loop grabbing the Gateway IPs and inserting them into
  682. // its namelist
  683. //
  684. while( GetCommaDelimitedEntry( szIPString, &pBuffer ) )
  685. {
  686. TcpipAddNameToNameList( &pAdapter->
  687. Tcpip_GatewayAddresses,
  688. szIPString );
  689. }
  690. }
  691. //
  692. // if WINS is set to "Yes", then read in the WINS addresses
  693. //
  694. GetPrivateProfileString( szNetworkBuffer,
  695. _T("WINS"),
  696. StrConstYes,
  697. Buffer,
  698. StrBuffSize(Buffer),
  699. FixedGlobals.ScriptName );
  700. if( lstrcmpi( Buffer, StrConstYes ) == 0 )
  701. {
  702. //
  703. // Read the WINS addresses from the file and insert them
  704. // into the proper variables
  705. //
  706. GetPrivateProfileString( szNetworkBuffer,
  707. _T("WinsServerList"),
  708. _T(""),
  709. Buffer,
  710. StrBuffSize(Buffer),
  711. FixedGlobals.ScriptName );
  712. pBuffer = Buffer;
  713. //
  714. // Loop grabbing the IPs and inserting them into
  715. // the NameList
  716. //
  717. while( GetCommaDelimitedEntry( szIPString, &pBuffer ) )
  718. {
  719. AddNameToNameList( &pAdapter->Tcpip_WinsAddresses,
  720. szIPString );
  721. }
  722. }
  723. //
  724. // Read in the DNS suffixes, if there are any
  725. //
  726. GetPrivateProfileString( szNetworkBuffer,
  727. _T("WinsServerList"),
  728. _T(""),
  729. Buffer,
  730. StrBuffSize(Buffer),
  731. FixedGlobals.ScriptName );
  732. pBuffer = Buffer;
  733. //
  734. // Loop grabbing the IPs and inserting them into the NameList
  735. //
  736. while( GetCommaDelimitedEntry( szIPString, &pBuffer ) )
  737. {
  738. AddNameToNameList( &NetSettings.TCPIP_DNS_Domains,
  739. szIPString );
  740. }
  741. }
  742. }
  743. }
  744. //----------------------------------------------------------------------------
  745. //
  746. // Function: ReadNetBeuiSettings
  747. //
  748. // Purpose: read input file and determine if the Net BEUI protocol is to be
  749. // installed
  750. //
  751. // Arguments: VOID
  752. //
  753. // Returns: VOID
  754. //
  755. //----------------------------------------------------------------------------
  756. VOID
  757. ReadNetBeuiSettings( IN HWND hwnd ) {
  758. TCHAR Buffer[MAX_INILINE_LEN];
  759. //
  760. // See if NetBEUI is installed
  761. //
  762. if( GetPrivateProfileString(_T("NetProtocols"),
  763. _T("MS_NetBEUI"),
  764. _T(""),
  765. Buffer,
  766. StrBuffSize(Buffer),
  767. FixedGlobals.ScriptName) > 0)
  768. {
  769. //
  770. // NetBEUI is installed so set its installed flag to true
  771. //
  772. SetFlagToInstalled( IDS_NETBEUI_PROTOCOL, hwnd );
  773. SettingQueue_MarkVolatile( Buffer,
  774. SETTING_QUEUE_ORIG_ANSWERS );
  775. }
  776. }
  777. //----------------------------------------------------------------------------
  778. //
  779. // Function: ReadNetworkMonitorSettings
  780. //
  781. // Purpose: read input file and determine if the Network Monitor is to be
  782. // installed
  783. //
  784. // Arguments: VOID
  785. //
  786. // Returns: VOID
  787. //
  788. //----------------------------------------------------------------------------
  789. VOID
  790. ReadNetworkMonitorSettings( IN HWND hwnd ) {
  791. TCHAR Buffer[MAX_INILINE_LEN];
  792. //
  793. // See if Network Monitor Agent is installed
  794. //
  795. if( GetPrivateProfileString(_T("NetProtocols"),
  796. _T("MS_NetMon"),
  797. _T(""),
  798. Buffer,
  799. StrBuffSize(Buffer),
  800. FixedGlobals.ScriptName) > 0)
  801. {
  802. //
  803. // Network Monitor Agent is installed so set its installed flag
  804. // to true
  805. //
  806. SetFlagToInstalled( IDS_NETWORK_MONITOR_AGENT, hwnd );
  807. SettingQueue_MarkVolatile( Buffer,
  808. SETTING_QUEUE_ORIG_ANSWERS );
  809. }
  810. }
  811. //----------------------------------------------------------------------------
  812. //
  813. // Function: ReadIpxSettings
  814. //
  815. // Purpose: read input file and determine if the IPX protocol is to be
  816. // installed and if so, read in its settings
  817. //
  818. // Arguments: VOID
  819. //
  820. // Returns: VOID
  821. //
  822. //----------------------------------------------------------------------------
  823. VOID
  824. ReadIpxSettings( IN HWND hwnd ) {
  825. INT NewNumberOfNetworkCards;
  826. NETWORK_ADAPTER_NODE *pAdapter;
  827. TCHAR *pAdapterSections;
  828. TCHAR Buffer[MAX_INILINE_LEN];
  829. TCHAR szAdapterSections[MAX_INILINE_LEN];
  830. TCHAR szNetworkBuffer[MAX_INILINE_LEN];
  831. //
  832. // See if IPX is installed
  833. //
  834. if( GetPrivateProfileString(_T("NetProtocols"),
  835. _T("MS_NWIPX"),
  836. _T(""),
  837. Buffer,
  838. StrBuffSize(Buffer),
  839. FixedGlobals.ScriptName) > 0)
  840. {
  841. SettingQueue_MarkVolatile( Buffer,
  842. SETTING_QUEUE_ORIG_ANSWERS );
  843. //
  844. // IPX is installed so set its installed flag to true
  845. //
  846. SetFlagToInstalled( IDS_IPX_PROTOCOL, hwnd );
  847. //
  848. // and grab all of its settings from the
  849. // answer file
  850. //
  851. GetPrivateProfileString(
  852. Buffer,
  853. _T("VirtualNetworkNumber"),
  854. NetSettings.szInternalNetworkNumber,
  855. NetSettings.szInternalNetworkNumber,
  856. StrBuffSize( NetSettings.szInternalNetworkNumber ),
  857. FixedGlobals.ScriptName );
  858. GetPrivateProfileString( Buffer,
  859. _T("AdapterSections"),
  860. _T(""),
  861. szAdapterSections,
  862. StrBuffSize( szAdapterSections ),
  863. FixedGlobals.ScriptName );
  864. NewNumberOfNetworkCards = GetNetworkAdapterCount( szAdapterSections );
  865. //
  866. // allocate the right amount of space for the netword cards that will
  867. // be read in
  868. //
  869. AdjustNetworkCardMemory( NewNumberOfNetworkCards,
  870. NetSettings.iNumberOfNetworkCards );
  871. NetSettings.iNumberOfNetworkCards = NewNumberOfNetworkCards;
  872. //
  873. // Load network adapter specific IPX settings
  874. //
  875. pAdapterSections = szAdapterSections;
  876. for( pAdapter = NetSettings.NetworkAdapterHead;
  877. pAdapter;
  878. pAdapter = pAdapter->next )
  879. {
  880. GetNextAdapterSection( &pAdapterSections, szNetworkBuffer );
  881. SettingQueue_MarkVolatile( szNetworkBuffer,
  882. SETTING_QUEUE_ORIG_ANSWERS );
  883. GetPrivateProfileString( szNetworkBuffer,
  884. _T("PktType"),
  885. pAdapter->szFrameType,
  886. pAdapter->szFrameType,
  887. StrBuffSize( pAdapter->szFrameType ),
  888. FixedGlobals.ScriptName );
  889. GetPrivateProfileString( szNetworkBuffer,
  890. _T("NetworkNumber"),
  891. pAdapter->szNetworkNumber,
  892. pAdapter->szNetworkNumber,
  893. StrBuffSize( pAdapter->szNetworkNumber ),
  894. FixedGlobals.ScriptName );
  895. }
  896. }
  897. }
  898. //----------------------------------------------------------------------------
  899. //
  900. // Function: SetFlagToInstalled
  901. //
  902. // Purpose: iterate through the Network list until the item whose name matches
  903. // the input parameter is found. Set its flag to installed.
  904. //
  905. // Arguments: IN INT iStringResourceId - the string resource ID
  906. // IN HWND hwnd - handle to the dialog window
  907. //
  908. // Returns: VOID
  909. //
  910. //----------------------------------------------------------------------------
  911. static VOID
  912. SetFlagToInstalled( IN INT iStringResourceId, IN HWND hwnd )
  913. {
  914. INT i;
  915. TCHAR *szComponentName;
  916. NETWORK_COMPONENT *pNetComponent;
  917. szComponentName = MyLoadString( iStringResourceId );
  918. for( pNetComponent = NetSettings.NetComponentsList;
  919. pNetComponent;
  920. pNetComponent = pNetComponent->next )
  921. {
  922. if( lstrcmpi( pNetComponent->StrComponentName,
  923. szComponentName ) == 0 )
  924. {
  925. pNetComponent->bInstalled = TRUE;
  926. free( szComponentName );
  927. return;
  928. }
  929. }
  930. free( szComponentName );
  931. // if the function reaches this point then the string ID passed as input
  932. // did not match any string in NetComponentsList
  933. AssertMsg(FALSE, "String ID not found.");
  934. }
  935. //----------------------------------------------------------------------------
  936. //
  937. // Function: GetNextAdapterSection
  938. //
  939. // Purpose: copies the next section from pAdapterSections into szNetworkBuffer
  940. // each section is separated by commas so that's what it looks for
  941. //
  942. // Arguments: IN OUT TCHAR *pAdapterSections - pointer to the current position
  943. // in the AdapterSections string
  944. // OUT TCHAR szNetworkBuffer[] - the parsed section from the
  945. // AdapterSections string
  946. //
  947. // Returns: VOID
  948. //
  949. //----------------------------------------------------------------------------
  950. static VOID
  951. GetNextAdapterSection( IN OUT TCHAR **pAdapterSections, OUT TCHAR szNetworkBuffer[] )
  952. {
  953. INT i;
  954. //
  955. // Copy over the string char by char
  956. //
  957. i = 0;
  958. while( **pAdapterSections != _T(',') && **pAdapterSections != _T('\0') )
  959. {
  960. szNetworkBuffer[i] = **pAdapterSections;
  961. (*pAdapterSections)++;
  962. i++;
  963. }
  964. szNetworkBuffer[i] = _T('\0');
  965. //
  966. // Prepare pAdapterSections for the next call to this functions
  967. //
  968. if( **pAdapterSections == _T(',') )
  969. {
  970. (*pAdapterSections)++;
  971. }
  972. }
  973. //----------------------------------------------------------------------------
  974. //
  975. // Function: GetNetworkAdapterCount
  976. //
  977. // Purpose: Counts the number of network cards by counting the number of
  978. // commas in the adapter sections buffer
  979. //
  980. // Arguments: IN TCHAR szBuffer[] - string that lists the sections for each
  981. // network card
  982. //
  983. // Returns: int - number of network adapters there are
  984. //
  985. //----------------------------------------------------------------------------
  986. static int
  987. GetNetworkAdapterCount( IN TCHAR szBuffer[] )
  988. {
  989. INT i;
  990. INT NetworkCardCount = 1;
  991. for( i = 0; szBuffer[i] != _T('\0'); i++ )
  992. {
  993. if( szBuffer[i] == _T(',') )
  994. {
  995. NetworkCardCount++;
  996. }
  997. }
  998. return( NetworkCardCount );
  999. }