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.

899 lines
22 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // IPSubnetPage.cpp
  7. //
  8. // Maintained By:
  9. // David Potter (DavidP) 14-JUN-2001
  10. // Geoffrey Pease (GPease) 12-MAY-2000
  11. //
  12. //////////////////////////////////////////////////////////////////////////////
  13. #include "Pch.h"
  14. #include "IPSubnetPage.h"
  15. DEFINE_THISCLASS("CIPSubnetPage");
  16. #define CONVERT_ADDRESS( _addrOut, _addrIn ) \
  17. _addrOut = ( FIRST_IPADDRESS( _addrIn ) ) | ( SECOND_IPADDRESS( _addrIn ) << 8 ) | ( THIRD_IPADDRESS( _addrIn ) << 16 ) | ( FOURTH_IPADDRESS( _addrIn ) << 24 )
  18. //////////////////////////////////////////////////////////////////////////////
  19. //++
  20. //
  21. // CIPSubnetPage::CIPSubnetPage(
  22. // IServiceProvider * pspIn,
  23. // ECreateAddMode ecamCreateAddModeIn
  24. // LONG * pulIPSubnetInout,
  25. // BSTR * pbstrNetworkNameInout,
  26. // ULONG * pulIPAddressIn,
  27. // BSTR * pbstrClusterNameIn
  28. // )
  29. //
  30. //--
  31. //////////////////////////////////////////////////////////////////////////////
  32. CIPSubnetPage::CIPSubnetPage(
  33. IServiceProvider * pspIn,
  34. ECreateAddMode ecamCreateAddModeIn,
  35. ULONG * pulIPSubnetInout,
  36. BSTR * pbstrNetworkNameInout,
  37. ULONG * pulIPAddressIn,
  38. BSTR * pbstrClusterNameIn
  39. )
  40. {
  41. TraceFunc( "" );
  42. Assert( pspIn != NULL );
  43. Assert( pulIPSubnetInout != NULL );
  44. Assert( pbstrNetworkNameInout != NULL );
  45. Assert( pulIPAddressIn != NULL );
  46. Assert( pbstrClusterNameIn != NULL );
  47. // m_hwnd = NULL;
  48. THR( pspIn->TypeSafeQI( IServiceProvider, &m_psp ) );
  49. m_pulIPSubnet = pulIPSubnetInout;
  50. m_pbstrNetworkName = pbstrNetworkNameInout;
  51. m_pulIPAddress = pulIPAddressIn;
  52. m_pbstrClusterName = pbstrClusterNameIn;
  53. TraceFuncExit();
  54. } //*** CIPSubnetPage::CIPSubnetPage
  55. //////////////////////////////////////////////////////////////////////////////
  56. //++
  57. //
  58. // CIPSubnetPage::~CIPSubnetPage( void )
  59. //
  60. //--
  61. //////////////////////////////////////////////////////////////////////////////
  62. CIPSubnetPage::~CIPSubnetPage( void )
  63. {
  64. TraceFunc( "" );
  65. if ( m_psp != NULL )
  66. {
  67. m_psp->Release();
  68. }
  69. TraceFuncExit();
  70. } //*** CIPSubnetPage::~CIPSubnetPage
  71. //////////////////////////////////////////////////////////////////////////////
  72. //++
  73. //
  74. // LRESULT
  75. // CIPSubnetPage::OnInitDialog( void )
  76. //
  77. //--
  78. //////////////////////////////////////////////////////////////////////////////
  79. LRESULT
  80. CIPSubnetPage::OnInitDialog( void )
  81. {
  82. TraceFunc( "" );
  83. BOOL bRet;
  84. LRESULT lr = FALSE; // Didn't set focus
  85. if ( *m_pulIPSubnet != 0 )
  86. {
  87. ULONG ulIPSubnet;
  88. CONVERT_ADDRESS( ulIPSubnet, *m_pulIPSubnet );
  89. SendDlgItemMessage( m_hwnd, IDC_IP_SUBNETMASK, IPM_SETADDRESS, 0, ulIPSubnet );
  90. }
  91. RETURN( lr );
  92. } //*** CIPSubnetPage::OnInitDialog
  93. //////////////////////////////////////////////////////////////////////////////
  94. //++
  95. //
  96. // LRESULT
  97. // CIPSubnetPage::OnCommand(
  98. // UINT idNotificationIn,
  99. // UINT idControlIn,
  100. // HWND hwndSenderIn
  101. // )
  102. //
  103. //--
  104. //////////////////////////////////////////////////////////////////////////////
  105. LRESULT
  106. CIPSubnetPage::OnCommand(
  107. UINT idNotificationIn,
  108. UINT idControlIn,
  109. HWND hwndSenderIn
  110. )
  111. {
  112. TraceFunc( "" );
  113. LRESULT lr = FALSE;
  114. switch ( idControlIn )
  115. {
  116. case IDC_IP_SUBNETMASK:
  117. if ( idNotificationIn == IPN_FIELDCHANGED
  118. || idNotificationIn == EN_CHANGE
  119. )
  120. {
  121. THR( HrUpdateWizardButtons() );
  122. lr = TRUE;
  123. }
  124. break;
  125. case IDC_CB_NETWORKS:
  126. if ( idNotificationIn == CBN_SELCHANGE )
  127. {
  128. THR( HrUpdateWizardButtons() );
  129. lr = TRUE;
  130. }
  131. break;
  132. }
  133. RETURN( lr );
  134. } //*** CIPSubnetPage::OnCommand
  135. //////////////////////////////////////////////////////////////////////////////
  136. //++
  137. //
  138. // HRESULT
  139. // CIPSubnetPage::HrUpdateWizardButtons( void )
  140. //
  141. //--
  142. //////////////////////////////////////////////////////////////////////////////
  143. HRESULT
  144. CIPSubnetPage::HrUpdateWizardButtons( void )
  145. {
  146. TraceFunc( "" );
  147. LRESULT lr;
  148. ULONG ulIPSubnet;
  149. HRESULT hr = S_OK;
  150. DWORD dwFlags = PSWIZB_BACK | PSWIZB_NEXT;
  151. lr = SendDlgItemMessage( m_hwnd, IDC_IP_SUBNETMASK, IPM_ISBLANK, 0, 0 );
  152. if ( lr != 0 )
  153. {
  154. dwFlags &= ~PSWIZB_NEXT;
  155. }
  156. lr = ComboBox_GetCurSel( GetDlgItem( m_hwnd, IDC_CB_NETWORKS ) );
  157. if ( lr == CB_ERR )
  158. {
  159. dwFlags &= ~PSWIZB_NEXT;
  160. }
  161. PropSheet_SetWizButtons( GetParent( m_hwnd ), dwFlags );
  162. HRETURN( hr );
  163. } //*** CIPSubnetPage::HrUpdateWizardButtons
  164. //////////////////////////////////////////////////////////////////////////////
  165. //++
  166. //
  167. // LRESULT
  168. // CIPSubnetPage::OnNotify(
  169. // WPARAM idCtrlIn,
  170. // LPNMHDR pnmhdrIn
  171. // )
  172. //
  173. //--
  174. //////////////////////////////////////////////////////////////////////////////
  175. LRESULT
  176. CIPSubnetPage::OnNotify(
  177. WPARAM idCtrlIn,
  178. LPNMHDR pnmhdrIn
  179. )
  180. {
  181. TraceFunc( "" );
  182. LRESULT lr = TRUE;
  183. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, 0 );
  184. switch( pnmhdrIn->code )
  185. {
  186. case PSN_SETACTIVE:
  187. lr = OnNotifySetActive();
  188. break;
  189. case PSN_KILLACTIVE:
  190. lr = OnNotifyKillActive();
  191. break;
  192. case PSN_WIZNEXT:
  193. lr = OnNotifyWizNext();
  194. break;
  195. case PSN_QUERYCANCEL:
  196. lr = OnNotifyQueryCancel();
  197. break;
  198. }
  199. RETURN( lr );
  200. } //*** CIPSubnetPage::OnNotify
  201. //////////////////////////////////////////////////////////////////////////////
  202. //++
  203. //
  204. // LRESULT
  205. // CIPSubnetPage::OnNotifyQueryCancel( void )
  206. //
  207. //--
  208. //////////////////////////////////////////////////////////////////////////////
  209. LRESULT
  210. CIPSubnetPage::OnNotifyQueryCancel( void )
  211. {
  212. TraceFunc( "" );
  213. LRESULT lr = TRUE;
  214. int iRet;
  215. iRet = MessageBoxFromStrings( m_hwnd,
  216. IDS_QUERY_CANCEL_TITLE,
  217. IDS_QUERY_CANCEL_TEXT,
  218. MB_YESNO
  219. );
  220. if ( iRet == IDNO )
  221. {
  222. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, -1 );
  223. } // if:
  224. else
  225. {
  226. THR( HrLaunchCleanupTask( m_pccw ) );
  227. } // else:
  228. RETURN( lr );
  229. } //*** CIPSubnetPage::OnNotifyQueryCancel
  230. //////////////////////////////////////////////////////////////////////////////
  231. //++
  232. //
  233. // LRESULT
  234. // CIPSubnetPage::OnNotifySetActive( void )
  235. //
  236. //--
  237. //////////////////////////////////////////////////////////////////////////////
  238. LRESULT
  239. CIPSubnetPage::OnNotifySetActive( void )
  240. {
  241. TraceFunc( "" );
  242. LRESULT lr = TRUE;
  243. HWND hwndIP = GetDlgItem( m_hwnd, IDC_IP_SUBNETMASK );
  244. HWND hwndCB = GetDlgItem( m_hwnd, IDC_CB_NETWORKS );
  245. WCHAR szIPAddress[ ARRAYSIZE( "255 . 255 . 255 . 255" ) ];
  246. LRESULT lrCB;
  247. HRESULT hr;
  248. THR( HrUpdateWizardButtons() );
  249. //
  250. // Set the IP address string.
  251. //
  252. THR( StringCchPrintfW( szIPAddress,
  253. ARRAYSIZE( szIPAddress ),
  254. L"%u . %u . %u . %u",
  255. FOURTH_IPADDRESS( *m_pulIPAddress ),
  256. THIRD_IPADDRESS( *m_pulIPAddress ),
  257. SECOND_IPADDRESS( *m_pulIPAddress ),
  258. FIRST_IPADDRESS( *m_pulIPAddress )
  259. ) );
  260. SetDlgItemText( m_hwnd, IDC_E_IPADDRESS, szIPAddress );
  261. //
  262. // Add networks to the combobox.
  263. //
  264. hr = STHR( HrAddNetworksToComboBox( hwndCB ) );
  265. //
  266. // Set the subnet mask based on what was found from
  267. // the networks added to the combobox.
  268. //
  269. if ( *m_pulIPSubnet != 0 )
  270. {
  271. ULONG ulIPSubnet;
  272. CONVERT_ADDRESS( ulIPSubnet, *m_pulIPSubnet );
  273. SendMessage( hwndIP, IPM_SETADDRESS, 0, ulIPSubnet );
  274. }
  275. //
  276. // If there isn't a selected network, select the first one.
  277. //
  278. lrCB = ComboBox_GetCurSel( hwndCB );
  279. if ( lrCB == CB_ERR )
  280. {
  281. ComboBox_SetCurSel( hwndCB, 0 );
  282. }
  283. //
  284. // Determine if we need to show this page.
  285. //
  286. if ( hr == S_OK )
  287. {
  288. OnNotifyWizNext();
  289. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, -1 );
  290. }
  291. RETURN( lr );
  292. } //*** CIPSubnetPage::OnNotifySetActive
  293. //////////////////////////////////////////////////////////////////////////////
  294. //++
  295. //
  296. // LRESULT
  297. // CIPSubnetPage::OnNotifyKillActive( void )
  298. //
  299. //--
  300. //////////////////////////////////////////////////////////////////////////////
  301. LRESULT
  302. CIPSubnetPage::OnNotifyKillActive( void )
  303. {
  304. TraceFunc( "" );
  305. LRESULT lr = TRUE;
  306. HWND hwndCB = GetDlgItem( m_hwnd, IDC_CB_NETWORKS );
  307. LRESULT citems;
  308. //
  309. // Release all the network info interfaces stored in the combobox.
  310. //
  311. citems = ComboBox_GetCount( hwndCB );
  312. Assert( citems != CB_ERR );
  313. if ( ( citems != CB_ERR )
  314. && ( citems > 0 ) )
  315. {
  316. LRESULT idx;
  317. LRESULT lrItemData;
  318. IClusCfgNetworkInfo * pccni;
  319. for ( idx = 0 ; idx < citems ; idx++ )
  320. {
  321. lrItemData = ComboBox_GetItemData( hwndCB, idx );
  322. Assert( lrItemData != CB_ERR );
  323. pccni = reinterpret_cast< IClusCfgNetworkInfo * >( lrItemData );
  324. pccni->Release();
  325. } // for: each item in the combobox
  326. } // if: retrieved combobox count and combobox not empty
  327. ComboBox_ResetContent( hwndCB );
  328. RETURN( lr );
  329. } //*** CIPSubnetPage::OnNotifyKillActive
  330. //////////////////////////////////////////////////////////////////////////////
  331. //++
  332. //
  333. // LRESULT
  334. // CIPSubnetPage::OnNotifyWizNext( void )
  335. //
  336. //--
  337. //////////////////////////////////////////////////////////////////////////////
  338. LRESULT
  339. CIPSubnetPage::OnNotifyWizNext( void )
  340. {
  341. TraceFunc( "" );
  342. OBJECTCOOKIE cookieDummy;
  343. LRESULT lr = TRUE;
  344. LRESULT lrCB;
  345. HRESULT hr;
  346. ULONG ulIPSubnet;
  347. HWND hwndCB = GetDlgItem( m_hwnd, IDC_CB_NETWORKS );
  348. IUnknown * punk = NULL;
  349. IObjectManager * pom = NULL;
  350. IClusCfgClusterInfo * pccci = NULL;
  351. IClusCfgNetworkInfo * pccni = NULL;
  352. SendDlgItemMessage( m_hwnd, IDC_IP_SUBNETMASK, IPM_GETADDRESS, 0, (LPARAM) &ulIPSubnet );
  353. CONVERT_ADDRESS( *m_pulIPSubnet, ulIPSubnet );
  354. //
  355. // Grab the object manager.
  356. //
  357. hr = THR( m_psp->TypeSafeQS( CLSID_ObjectManager,
  358. IObjectManager,
  359. &pom
  360. ) );
  361. if ( FAILED( hr ) )
  362. goto Error;
  363. //
  364. // Get the cluster configuration info.
  365. //
  366. hr = THR( pom->FindObject( CLSID_ClusterConfigurationType,
  367. NULL,
  368. *m_pbstrClusterName,
  369. DFGUID_ClusterConfigurationInfo,
  370. &cookieDummy,
  371. &punk
  372. ) );
  373. if ( FAILED( hr ) )
  374. goto Error;
  375. hr = THR( punk->TypeSafeQI( IClusCfgClusterInfo, &pccci ) );
  376. if ( FAILED( hr ) )
  377. goto Cleanup;
  378. //
  379. // Set the IP subnet mask.
  380. //
  381. hr = THR( pccci->SetSubnetMask( *m_pulIPSubnet ) );
  382. if ( FAILED( hr ) )
  383. goto Error;
  384. //
  385. // Get the selected network.
  386. //
  387. //
  388. // Set the network.
  389. //
  390. lrCB = ComboBox_GetCurSel( hwndCB );
  391. Assert( lrCB != CB_ERR );
  392. lrCB = ComboBox_GetItemData( hwndCB, lrCB );
  393. Assert( lrCB != CB_ERR );
  394. pccni = reinterpret_cast< IClusCfgNetworkInfo * >( lrCB );
  395. hr = THR( pccci->SetNetworkInfo( pccni ) );
  396. if ( FAILED( hr ) )
  397. goto Error;
  398. Cleanup:
  399. if ( punk != NULL )
  400. {
  401. punk->Release();
  402. }
  403. if ( pccci != NULL )
  404. {
  405. pccci->Release();
  406. }
  407. if ( pom != NULL )
  408. {
  409. pom->Release();
  410. }
  411. RETURN( lr );
  412. Error:
  413. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, -1 );
  414. goto Cleanup;
  415. } //*** CIPSubnetPage::OnNotifyWizNext
  416. //////////////////////////////////////////////////////////////////////////////
  417. //++
  418. //
  419. // HRESULT
  420. // CIPSubnetPage::HrAddNetworksToComboBox( void )
  421. //
  422. //--
  423. //////////////////////////////////////////////////////////////////////////////
  424. HRESULT
  425. CIPSubnetPage::HrAddNetworksToComboBox(
  426. HWND hwndCBIn
  427. )
  428. {
  429. TraceFunc( "" );
  430. HRESULT hr = S_OK;
  431. IUnknown * punk = NULL;
  432. IObjectManager * pom = NULL;
  433. IEnumCookies * pec = NULL;
  434. IEnumClusCfgNetworks * peccn = NULL;
  435. IClusCfgNetworkInfo * pccni = NULL;
  436. BSTR bstrNetName = NULL;
  437. OBJECTCOOKIE cookieCluster;
  438. OBJECTCOOKIE cookieNode;
  439. OBJECTCOOKIE cookieDummy;
  440. ULONG celtDummy;
  441. bool fFoundNetwork = false;
  442. LRESULT lr;
  443. LRESULT lrIndex;
  444. Assert( hwndCBIn != NULL );
  445. ComboBox_ResetContent( hwndCBIn );
  446. //
  447. // Grab the object manager.
  448. //
  449. hr = THR( m_psp->TypeSafeQS(
  450. CLSID_ObjectManager,
  451. IObjectManager,
  452. &pom
  453. ) );
  454. if ( FAILED( hr ) )
  455. goto Cleanup;
  456. //
  457. // Get the cluster configuration info cookie.
  458. //
  459. hr = THR( pom->FindObject(
  460. CLSID_ClusterConfigurationType,
  461. NULL,
  462. *m_pbstrClusterName,
  463. IID_NULL,
  464. &cookieCluster,
  465. &punk
  466. ) );
  467. Assert( punk == NULL );
  468. if ( FAILED( hr ) )
  469. goto Cleanup;
  470. //
  471. // Get the enumeration of nodes whose parent is this cluster.
  472. // We want the enumeration of cookies (indicated by using
  473. // DFGUID_EnumCookies) because we want to use the cookie of the
  474. // node to search for all networks on that node.
  475. //
  476. hr = THR( pom->FindObject(
  477. CLSID_NodeType,
  478. cookieCluster,
  479. NULL,
  480. DFGUID_EnumCookies,
  481. &cookieDummy,
  482. &punk
  483. ) );
  484. if ( FAILED( hr ) )
  485. goto Cleanup;
  486. hr = THR( punk->TypeSafeQI( IEnumCookies, &pec ) );
  487. if ( FAILED( hr ) )
  488. goto Cleanup;
  489. pec = TraceInterface( L"CIPSubnetPage!IEnumCookies", IEnumCookies, pec, 1 );
  490. punk->Release();
  491. punk = NULL;
  492. //
  493. // Get the cookie for the first node in the node enumeration.
  494. //
  495. hr = THR( pec->Next( 1, &cookieNode, &celtDummy ) );
  496. if ( FAILED( hr ) )
  497. goto Cleanup;
  498. //
  499. // Get the network enumerator.
  500. //
  501. hr = THR( pom->FindObject(
  502. CLSID_NetworkType,
  503. cookieNode,
  504. NULL,
  505. DFGUID_EnumManageableNetworks,
  506. &cookieDummy,
  507. &punk
  508. ) );
  509. if ( FAILED( hr ) )
  510. goto Cleanup;
  511. hr = THR( punk->TypeSafeQI( IEnumClusCfgNetworks, &peccn ) );
  512. if ( FAILED( hr ) )
  513. goto Cleanup;
  514. punk->Release();
  515. punk = NULL;
  516. //
  517. // Add each network to the combobox.
  518. //
  519. for ( ;; )
  520. {
  521. // Get the next network.
  522. hr = STHR( peccn->Next( 1, &pccni, &celtDummy ) );
  523. if ( hr == S_FALSE )
  524. break;
  525. if ( FAILED( hr ) )
  526. goto Cleanup;
  527. // Skip this network if it isn't public.
  528. hr = STHR( pccni->IsPublic() );
  529. if ( hr == S_OK )
  530. {
  531. // Get the name of the network.
  532. hr = THR( pccni->GetName( &bstrNetName ) );
  533. if ( SUCCEEDED( hr ) )
  534. {
  535. TraceMemoryAddBSTR( bstrNetName );
  536. // Add the network to the combobox.
  537. lrIndex = ComboBox_AddString( hwndCBIn, bstrNetName );
  538. Assert( ( lrIndex != CB_ERR )
  539. && ( lrIndex != CB_ERRSPACE )
  540. );
  541. // Add the netinfo interface to the combobox as well.
  542. if ( ( lrIndex != CB_ERR )
  543. && ( lrIndex != CB_ERRSPACE ) )
  544. {
  545. pccni->AddRef();
  546. lr = ComboBox_SetItemData( hwndCBIn, lrIndex, pccni );
  547. Assert( lr != CB_ERR );
  548. }
  549. // Determine if this network matches the user's IP address.
  550. // If it is, select it in the combobox.
  551. if ( ! fFoundNetwork )
  552. {
  553. hr = STHR( HrMatchNetwork( pccni, bstrNetName ) );
  554. if ( hr == S_OK )
  555. {
  556. fFoundNetwork = true;
  557. lr = ComboBox_SetCurSel( hwndCBIn, lrIndex );
  558. Assert( lr != CB_ERR );
  559. }
  560. }
  561. // Cleanup.
  562. TraceSysFreeString( bstrNetName );
  563. bstrNetName = NULL;
  564. } // if: name retrieved successfully
  565. } // if: network is public
  566. pccni->Release();
  567. pccni = NULL;
  568. } // forever
  569. if ( fFoundNetwork )
  570. {
  571. hr = S_OK;
  572. }
  573. else
  574. {
  575. hr = S_FALSE;
  576. }
  577. Cleanup:
  578. if ( punk != NULL )
  579. {
  580. punk->Release();
  581. }
  582. TraceSysFreeString( bstrNetName );
  583. if ( pccni != NULL )
  584. {
  585. pccni->Release();
  586. }
  587. if ( peccn != NULL )
  588. {
  589. peccn->Release();
  590. }
  591. if ( pec != NULL )
  592. {
  593. pec->Release();
  594. }
  595. if ( pom != NULL )
  596. {
  597. pom->Release();
  598. }
  599. HRETURN( hr );
  600. } //*** CIPSubnetPage::HrAddNetworksToComboBox
  601. //////////////////////////////////////////////////////////////////////////////
  602. //++
  603. //
  604. // HRESULT
  605. // CIPSubnetPage::HrMatchNetwork(
  606. // IClusCfgNetworkInfo * pccniIn,
  607. // BSTR bstrNetworkNameIn
  608. // )
  609. //
  610. //--
  611. //////////////////////////////////////////////////////////////////////////////
  612. HRESULT
  613. CIPSubnetPage::HrMatchNetwork(
  614. IClusCfgNetworkInfo * pccniIn,
  615. BSTR bstrNetworkNameIn
  616. )
  617. {
  618. TraceFunc( "" );
  619. HRESULT hr = S_OK;
  620. IClusCfgIPAddressInfo * pccipai = NULL;
  621. ULONG ulIPAddress;
  622. ULONG ulIPSubnet;
  623. Assert( pccniIn != NULL );
  624. Assert( bstrNetworkNameIn != NULL );
  625. //
  626. // Get the IP Address Info for the network.
  627. //
  628. hr = THR( pccniIn->GetPrimaryNetworkAddress( &pccipai ) );
  629. if ( FAILED( hr ) )
  630. {
  631. goto Cleanup;
  632. }
  633. //
  634. // Get the address and subnet of the network.
  635. //
  636. hr = THR( pccipai->GetIPAddress( &ulIPAddress ) );
  637. if ( FAILED( hr ) )
  638. {
  639. goto Cleanup;
  640. }
  641. hr = THR( pccipai->GetSubnetMask( &ulIPSubnet ) );
  642. if ( FAILED( hr ) )
  643. {
  644. goto Cleanup;
  645. }
  646. //
  647. // Determine if these match.
  648. //
  649. if ( ClRtlAreTcpipAddressesOnSameSubnet( *m_pulIPAddress, ulIPAddress, ulIPSubnet) )
  650. {
  651. // Save the subnet mask.
  652. *m_pulIPSubnet = ulIPSubnet;
  653. // Save the name of the network.
  654. if ( *m_pbstrNetworkName == NULL )
  655. {
  656. *m_pbstrNetworkName = TraceSysAllocString( bstrNetworkNameIn );
  657. if ( *m_pbstrNetworkName == NULL )
  658. {
  659. hr = THR( E_OUTOFMEMORY );
  660. goto Cleanup;
  661. }
  662. }
  663. else
  664. {
  665. INT iRet = TraceSysReAllocString( m_pbstrNetworkName, bstrNetworkNameIn );
  666. if ( ! iRet )
  667. {
  668. hr = THR( E_OUTOFMEMORY );
  669. goto Cleanup;
  670. }
  671. }
  672. } // if: match found
  673. else
  674. {
  675. hr = S_FALSE;
  676. }
  677. Cleanup:
  678. if ( pccipai != NULL )
  679. {
  680. pccipai->Release();
  681. }
  682. HRETURN( hr );
  683. } //*** CIPSubnetPage::HrMatchNetwork
  684. //////////////////////////////////////////////////////////////////////////////
  685. //++
  686. //
  687. // [static]
  688. // INT_PTR
  689. // CALLBACK
  690. // CIPSubnetPage::S_DlgProc(
  691. // HWND hDlgIn,
  692. // UINT MsgIn,
  693. // WPARAM wParam,
  694. // LPARAM lParam
  695. // )
  696. //
  697. //--
  698. //////////////////////////////////////////////////////////////////////////////
  699. INT_PTR
  700. CALLBACK
  701. CIPSubnetPage::S_DlgProc(
  702. HWND hDlgIn,
  703. UINT MsgIn,
  704. WPARAM wParam,
  705. LPARAM lParam
  706. )
  707. {
  708. // Don't do TraceFunc because every mouse movement
  709. // will cause this function to be called.
  710. WndMsg( hDlgIn, MsgIn, wParam, lParam );
  711. LRESULT lr = FALSE;
  712. CIPSubnetPage * pPage = reinterpret_cast< CIPSubnetPage *> ( GetWindowLongPtr( hDlgIn, GWLP_USERDATA ) );
  713. if ( MsgIn == WM_INITDIALOG )
  714. {
  715. PROPSHEETPAGE * ppage = reinterpret_cast< PROPSHEETPAGE * >( lParam );
  716. SetWindowLongPtr( hDlgIn, GWLP_USERDATA, (LPARAM) ppage->lParam );
  717. pPage = reinterpret_cast< CIPSubnetPage * >( ppage->lParam );
  718. pPage->m_hwnd = hDlgIn;
  719. }
  720. if ( pPage != NULL )
  721. {
  722. Assert( hDlgIn == pPage->m_hwnd );
  723. switch( MsgIn )
  724. {
  725. case WM_INITDIALOG:
  726. lr = pPage->OnInitDialog();
  727. break;
  728. case WM_NOTIFY:
  729. lr = pPage->OnNotify( wParam, reinterpret_cast< LPNMHDR >( lParam ) );
  730. break;
  731. case WM_COMMAND:
  732. lr= pPage->OnCommand( HIWORD( wParam ), LOWORD( wParam ), (HWND) lParam );
  733. break;
  734. // no default clause needed
  735. }
  736. }
  737. return lr;
  738. } //*** CIPSubnetPage::S_DlgProc