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.

5647 lines
177 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. #include "stdafx.h"
  6. #include "root.h"
  7. #include "machine.h"
  8. #include "rtrutilp.h" // InitiateServerConnection
  9. #include "rtrcfg.h"
  10. #include "rraswiz.h"
  11. #include "rtrres.h"
  12. #include "rtrcomn.h"
  13. #include "addrpool.h"
  14. #include "rrasutil.h"
  15. #include "radbal.h" // RADIUSSERVER
  16. #include "radcfg.h" // SaveRadiusServers
  17. #include "lsa.h"
  18. #include "helper.h" // HrIsStandaloneServer
  19. #include "ifadmin.h" // GetPhoneBookPath
  20. #include "infoi.h" // InterfaceInfo::FindInterfaceTitle
  21. #include "rtrerr.h"
  22. #include "rtrui.h" // NatConflictExists
  23. #define _USTRINGP_NO_UNICODE_STRING
  24. #include "ustringp.h"
  25. #include <ntddip.h> // to resolve ipfltdrv dependancies
  26. #include "ipfltdrv.h" // for the filter stuff
  27. #include "raputil.h" // for UpdateDefaultPolicy
  28. extern "C" {
  29. #define _NOUIUTIL_H_
  30. #include "dtl.h"
  31. #include "pbuser.h"
  32. };
  33. WATERMARKINFO g_wmi = {0};
  34. #ifdef UNICODE
  35. #define SZROUTERENTRYDLG "RouterEntryDlgW"
  36. #else
  37. #define SZROUTERENTRYDLG "RouterEntryDlgA"
  38. #endif
  39. // Useful functions
  40. // defines for the flags parameter
  41. HRESULT CallRouterEntryDlg(HWND hWnd, NewRtrWizData *pWizData, LPARAM flags);
  42. HRESULT RouterEntryLoadInfoBase(LPCTSTR pszServerName,
  43. LPCTSTR pszIfName,
  44. DWORD dwTransportId,
  45. IInfoBase *pInfoBase);
  46. HRESULT RouterEntrySaveInfoBase(LPCTSTR pszServerName,
  47. LPCTSTR pszIfName,
  48. IInfoBase *pInfoBase,
  49. DWORD dwTransportId);
  50. void LaunchHelpTopic(LPCTSTR pszHelpString);
  51. HRESULT AddVPNFiltersToInterface(IRouterInfo *pRouter, LPCTSTR pszIfId, RtrWizInterface* pIf);
  52. HRESULT DisableDDNSandNetBtOnInterface ( IRouterInfo *pRouter, LPCTSTR pszIfName, RtrWizInterface* pIf);
  53. // This is the command line that I use to launch the Connections UI shell
  54. const TCHAR s_szConnectionUICommandLine[] =
  55. _T("\"%SystemRoot%\\explorer.exe\" ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007acc7-3202-11d1-aad2-00805fc1270e}");
  56. // Help strings
  57. const TCHAR s_szHowToAddICS[] =
  58. _T("%systemdir%\\help\\netcfg.chm::/howto_share_conn.htm");
  59. const TCHAR s_szHowToAddAProtocol[] =
  60. _T("%systemdir%\\help\\netcfg.chm::/HowTo_Add_Component.htm");
  61. const TCHAR s_szHowToAddInboundConnections[] =
  62. _T("%systemdir%\\help\\netcfg.chm::/howto_conn_incoming.htm");
  63. const TCHAR s_szGeneralNATHelp[] =
  64. _T("%systemdir%\\help\\RRASconcepts.chm::/sag_RRAS-Ch2_16.htm");
  65. const TCHAR s_szGeneralRASHelp[] =
  66. _T("%systemdir%\\help\\RRASconcepts.chm::/sag_RRAS-Ch1_1.htm");
  67. /*---------------------------------------------------------------------------
  68. This enum defines the columns for the Interface list controls.
  69. ---------------------------------------------------------------------------*/
  70. enum
  71. {
  72. IFLISTCOL_NAME = 0,
  73. IFLISTCOL_DESC,
  74. IFLISTCOL_IPADDRESS,
  75. IFLISTCOL_COUNT
  76. };
  77. // This array must match the column indices above
  78. INT s_rgIfListColumnHeaders[] =
  79. {
  80. IDS_IFLIST_COL_NAME,
  81. IDS_IFLIST_COL_DESC,
  82. IDS_IFLIST_COL_IPADDRESS,
  83. 0
  84. };
  85. /*!--------------------------------------------------------------------------
  86. MachineHandler::OnNewRtrRASConfigWiz
  87. -
  88. Author: KennT
  89. ---------------------------------------------------------------------------*/
  90. HRESULT MachineHandler::OnNewRtrRASConfigWiz(ITFSNode *pNode, BOOL fTest)
  91. {
  92. Assert(pNode);
  93. HRESULT hr = hrOK;
  94. CString strRtrWizTitle;
  95. SPIComponentData spComponentData;
  96. COSERVERINFO csi;
  97. COAUTHINFO cai;
  98. COAUTHIDENTITY caid;
  99. SPIRemoteNetworkConfig spNetwork;
  100. IUnknown * punk = NULL;
  101. CNewRtrWiz * pRtrWiz = NULL;
  102. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  103. // Windows NT Bug : 407878
  104. // We need to reset the registry information (to ensure
  105. // that it is reasonably accurate).
  106. // ----------------------------------------------------------------
  107. ZeroMemory(&csi, sizeof(csi));
  108. ZeroMemory(&cai, sizeof(cai));
  109. ZeroMemory(&caid, sizeof(caid));
  110. csi.pAuthInfo = &cai;
  111. cai.pAuthIdentityData = &caid;
  112. // Create the remote config object
  113. // ----------------------------------------------------------------
  114. hr = CoCreateRouterConfig(m_spRouterInfo->GetMachineName(),
  115. m_spRouterInfo,
  116. &csi,
  117. IID_IRemoteNetworkConfig,
  118. &punk);
  119. if (FHrOK(hr))
  120. {
  121. spNetwork = (IRemoteNetworkConfig *) punk;
  122. punk = NULL;
  123. // Upgrade the configuration (ensure that the registry keys
  124. // are populated correctly).
  125. // ------------------------------------------------------------
  126. spNetwork->UpgradeRouterConfig();
  127. }
  128. hr = SecureRouterInfo(pNode, TRUE /* fShowUI */);
  129. if(FAILED(hr)) return hr;
  130. m_spNodeMgr->GetComponentData(&spComponentData);
  131. strRtrWizTitle.LoadString(IDS_MENU_RTRWIZ);
  132. //Load the watermark and
  133. //set it in m_spTFSCompData
  134. InitWatermarkInfo(AfxGetInstanceHandle(),
  135. &g_wmi,
  136. IDB_WIZBANNER, // Header ID
  137. IDB_WIZWATERMARK, // Watermark ID
  138. NULL, // hPalette
  139. FALSE); // bStretch
  140. m_spTFSCompData->SetWatermarkInfo(&g_wmi);
  141. //
  142. //we dont have to free handles. MMC does it for us
  143. //
  144. pRtrWiz = new CNewRtrWiz(pNode,
  145. m_spRouterInfo,
  146. spComponentData,
  147. m_spTFSCompData,
  148. strRtrWizTitle);
  149. if (fTest)
  150. {
  151. // Pure TEST code
  152. if (!FHrOK(pRtrWiz->QueryForTestData()))
  153. {
  154. delete pRtrWiz;
  155. return S_FALSE;
  156. }
  157. }
  158. if ( FAILED(pRtrWiz->Init( m_spRouterInfo->GetMachineName())) )
  159. {
  160. delete pRtrWiz;
  161. return S_FALSE;
  162. }
  163. else
  164. {
  165. return pRtrWiz->DoModalWizard();
  166. }
  167. if (csi.pAuthInfo)
  168. delete csi.pAuthInfo->pAuthIdentityData->Password;
  169. return hr;
  170. }
  171. NewRtrWizData::~NewRtrWizData()
  172. {
  173. POSITION pos;
  174. CString st;
  175. RtrWizInterface * pRtrWizIf;
  176. pos = m_ifMap.GetStartPosition();
  177. while (pos)
  178. {
  179. m_ifMap.GetNextAssoc(pos, st, pRtrWizIf);
  180. delete pRtrWizIf;
  181. }
  182. m_ifMap.RemoveAll();
  183. // Clear out the RADIUS secret
  184. ZeroMemory(m_stRadiusSecret.GetBuffer(0),
  185. m_stRadiusSecret.GetLength() * sizeof(TCHAR));
  186. m_stRadiusSecret.ReleaseBuffer(-1);
  187. }
  188. /*!--------------------------------------------------------------------------
  189. NewRtrWizData::Init
  190. -
  191. Author: KennT
  192. ---------------------------------------------------------------------------*/
  193. HRESULT NewRtrWizData::Init(LPCTSTR pszServerName, IRouterInfo *pRouter)
  194. {
  195. DWORD dwServiceStatus = 0;
  196. DWORD dwErrorCode = 0;
  197. m_stServerName = pszServerName;
  198. // Initialize internal wizard data
  199. m_RtrConfigData.Init(pszServerName, pRouter);
  200. m_RtrConfigData.m_fIpSetup = TRUE;
  201. // Move some of the RtrConfigData info over
  202. m_fIpInstalled = m_RtrConfigData.m_fUseIp;
  203. m_fIpxInstalled = m_RtrConfigData.m_fUseIpx;
  204. m_fNbfInstalled = m_RtrConfigData.m_fUseNbf;
  205. m_fAppletalkInstalled = m_RtrConfigData.m_fUseArap;
  206. m_fIpInUse = m_fIpInstalled;
  207. m_fIpxInUse = m_fIpxInstalled;
  208. m_fAppletalkInUse = m_fAppletalkInstalled;
  209. m_fNbfInUse = m_fNbfInstalled;
  210. // Test the server to see if DNS/DHCP is installed
  211. m_fIsDNSRunningOnServer = FALSE;
  212. m_fIsDHCPRunningOnServer = FALSE;
  213. // Get the status of the DHCP service
  214. // ----------------------------------------------------------------
  215. if (FHrSucceeded(TFSGetServiceStatus(pszServerName,
  216. _T("DHCPServer"),
  217. &dwServiceStatus,
  218. &dwErrorCode)))
  219. {
  220. // Note, if the service is not running, we assume it will
  221. // stay off and not assume that it will be turned on.
  222. // ------------------------------------------------------------
  223. m_fIsDHCPRunningOnServer = (dwServiceStatus == SERVICE_RUNNING);
  224. }
  225. //$ TODO : is this the correct name for the DNS Server?
  226. // Get the status of the DNS service
  227. // ----------------------------------------------------------------
  228. if (FHrSucceeded(TFSGetServiceStatus(pszServerName,
  229. _T("DNSServer"),
  230. &dwServiceStatus,
  231. &dwErrorCode)))
  232. {
  233. // Note, if the service is not running, we assume it will
  234. // stay off and not assume that it will be turned on.
  235. // ------------------------------------------------------------
  236. m_fIsDNSRunningOnServer = (dwServiceStatus == SERVICE_RUNNING);
  237. }
  238. LoadInterfaceData(pRouter);
  239. return hrOK;
  240. }
  241. /*!--------------------------------------------------------------------------
  242. NewRtrWizData::QueryForTestData
  243. -
  244. Author: KennT
  245. ---------------------------------------------------------------------------*/
  246. BOOL NewRtrWizData::s_fIpInstalled = FALSE;
  247. BOOL NewRtrWizData::s_fIpxInstalled = FALSE;
  248. BOOL NewRtrWizData::s_fAppletalkInstalled = FALSE;
  249. BOOL NewRtrWizData::s_fNbfInstalled = FALSE;
  250. BOOL NewRtrWizData::s_fIsLocalMachine = FALSE;
  251. BOOL NewRtrWizData::s_fIsDNSRunningOnPrivateInterface = FALSE;
  252. BOOL NewRtrWizData::s_fIsDHCPRunningOnPrivateInterface = FALSE;
  253. BOOL NewRtrWizData::s_fIsSharedAccessRunningOnServer = FALSE;
  254. BOOL NewRtrWizData::s_fIsMemberOfDomain = FALSE;
  255. DWORD NewRtrWizData::s_dwNumberOfNICs = 0;
  256. /*!--------------------------------------------------------------------------
  257. NewRtrWizData::QueryForTestData
  258. -
  259. Author: KennT
  260. ---------------------------------------------------------------------------*/
  261. HRESULT NewRtrWizData::QueryForTestData()
  262. {
  263. HRESULT hr = hrOK;
  264. CNewWizTestParams dlgParams;
  265. m_fTest = TRUE;
  266. // Get the initial parameters
  267. // ----------------------------------------------------------------
  268. dlgParams.SetData(this);
  269. if (dlgParams.DoModal() == IDCANCEL)
  270. {
  271. return S_FALSE;
  272. }
  273. return hr;
  274. }
  275. /*!--------------------------------------------------------------------------
  276. NewRtrWizData::HrIsIPInstalled
  277. -
  278. Author: KennT
  279. ---------------------------------------------------------------------------*/
  280. HRESULT NewRtrWizData::HrIsIPInstalled()
  281. {
  282. if (m_fTest)
  283. return s_fIpInstalled ? S_OK : S_FALSE;
  284. else
  285. return m_fIpInstalled ? S_OK : S_FALSE;
  286. }
  287. /*!--------------------------------------------------------------------------
  288. NewRtrWizData::HrIsIPInUse
  289. -
  290. Author: KennT
  291. ---------------------------------------------------------------------------*/
  292. HRESULT NewRtrWizData::HrIsIPInUse()
  293. {
  294. HRESULT hr = hrOK;
  295. hr = HrIsIPInstalled();
  296. if (FHrOK(hr))
  297. return m_fIpInUse ? S_OK : S_FALSE;
  298. else
  299. return hr;
  300. }
  301. /*!--------------------------------------------------------------------------
  302. NewRtrWizData::HrIsIPXInstalled
  303. -
  304. Author: KennT
  305. ---------------------------------------------------------------------------*/
  306. HRESULT NewRtrWizData::HrIsIPXInstalled()
  307. {
  308. if (m_fTest)
  309. return s_fIpxInstalled ? S_OK : S_FALSE;
  310. else
  311. return m_fIpxInstalled ? S_OK : S_FALSE;
  312. }
  313. /*!--------------------------------------------------------------------------
  314. NewRtrWizData::HrIsIPXInUse
  315. -
  316. Author: KennT
  317. ---------------------------------------------------------------------------*/
  318. HRESULT NewRtrWizData::HrIsIPXInUse()
  319. {
  320. HRESULT hr = hrOK;
  321. hr = HrIsIPXInstalled();
  322. if (FHrOK(hr))
  323. return m_fIpxInUse ? S_OK : S_FALSE;
  324. else
  325. return hr;
  326. }
  327. /*!--------------------------------------------------------------------------
  328. NewRtrWizData::HrIsAppletalkInstalled
  329. -
  330. Author: KennT
  331. ---------------------------------------------------------------------------*/
  332. HRESULT NewRtrWizData::HrIsAppletalkInstalled()
  333. {
  334. if (m_fTest)
  335. return s_fAppletalkInstalled ? S_OK : S_FALSE;
  336. else
  337. return m_fAppletalkInstalled ? S_OK : S_FALSE;
  338. }
  339. /*!--------------------------------------------------------------------------
  340. NewRtrWizData::HrIsAppletalkInUse
  341. -
  342. Author: KennT
  343. ---------------------------------------------------------------------------*/
  344. HRESULT NewRtrWizData::HrIsAppletalkInUse()
  345. {
  346. HRESULT hr = hrOK;
  347. hr = HrIsAppletalkInstalled();
  348. if (FHrOK(hr))
  349. return m_fAppletalkInUse ? S_OK : S_FALSE;
  350. else
  351. return hr;
  352. }
  353. /*!--------------------------------------------------------------------------
  354. NewRtrWizData::HrIsNbfInstalled
  355. -
  356. Author: KennT
  357. ---------------------------------------------------------------------------*/
  358. HRESULT NewRtrWizData::HrIsNbfInstalled()
  359. {
  360. if (m_fTest)
  361. return s_fNbfInstalled ? S_OK : S_FALSE;
  362. else
  363. return m_fNbfInstalled ? S_OK : S_FALSE;
  364. }
  365. /*!--------------------------------------------------------------------------
  366. NewRtrWizData::HrIsNbfInUse
  367. -
  368. Author: KennT
  369. ---------------------------------------------------------------------------*/
  370. HRESULT NewRtrWizData::HrIsNbfInUse()
  371. {
  372. HRESULT hr = hrOK;
  373. hr = HrIsNbfInstalled();
  374. if (FHrOK(hr))
  375. return m_fNbfInUse ? S_OK : S_FALSE;
  376. else
  377. return hr;
  378. }
  379. /*!--------------------------------------------------------------------------
  380. NewRtrWizData::HrIsLocalMachine
  381. -
  382. Author: KennT
  383. ---------------------------------------------------------------------------*/
  384. HRESULT NewRtrWizData::HrIsLocalMachine()
  385. {
  386. if (m_fTest)
  387. return s_fIsLocalMachine ? S_OK : S_FALSE;
  388. else
  389. return IsLocalMachine(m_stServerName) ? S_OK : S_FALSE;
  390. }
  391. /*!--------------------------------------------------------------------------
  392. NewRtrWizData::HrIsDNSRunningOnInterface
  393. -
  394. Author: KennT
  395. ---------------------------------------------------------------------------*/
  396. HRESULT NewRtrWizData::HrIsDNSRunningOnInterface()
  397. {
  398. if (m_fTest)
  399. return s_fIsDNSRunningOnPrivateInterface ? S_OK : S_FALSE;
  400. else
  401. {
  402. // Search for the private interface in our list
  403. // ------------------------------------------------------------
  404. RtrWizInterface * pRtrWizIf = NULL;
  405. m_ifMap.Lookup(m_stPrivateInterfaceId, pRtrWizIf);
  406. if (pRtrWizIf)
  407. return pRtrWizIf->m_fIsDnsEnabled ? S_OK : S_FALSE;
  408. else
  409. return S_FALSE;
  410. }
  411. }
  412. /*!--------------------------------------------------------------------------
  413. NewRtrWizData::HrIsDHCPRunningOnInterface
  414. -
  415. Author: KennT
  416. ---------------------------------------------------------------------------*/
  417. HRESULT NewRtrWizData::HrIsDHCPRunningOnInterface()
  418. {
  419. if (m_fTest)
  420. return s_fIsDHCPRunningOnPrivateInterface ? S_OK : S_FALSE;
  421. else
  422. {
  423. // Search for the private interface in our list
  424. // ------------------------------------------------------------
  425. RtrWizInterface * pRtrWizIf = NULL;
  426. m_ifMap.Lookup(m_stPrivateInterfaceId, pRtrWizIf);
  427. if (pRtrWizIf)
  428. return pRtrWizIf->m_fIsDhcpEnabled ? S_OK : S_FALSE;
  429. else
  430. return S_FALSE;
  431. }
  432. }
  433. /*!--------------------------------------------------------------------------
  434. NewRtrWizData::HrIsDNSRunningOnServer
  435. -
  436. Author: KennT
  437. ---------------------------------------------------------------------------*/
  438. HRESULT NewRtrWizData::HrIsDNSRunningOnServer()
  439. {
  440. return m_fIsDNSRunningOnServer ? S_OK : S_FALSE;
  441. }
  442. /*!--------------------------------------------------------------------------
  443. NewRtrWizData::HrIsDHCPRunningOnServer
  444. -
  445. Author: KennT
  446. ---------------------------------------------------------------------------*/
  447. HRESULT NewRtrWizData::HrIsDHCPRunningOnServer()
  448. {
  449. return m_fIsDHCPRunningOnServer ? S_OK : S_FALSE;
  450. }
  451. /*!--------------------------------------------------------------------------
  452. NewRtrWizData::HrIsSharedAccessRunningOnServer
  453. -
  454. Author: KennT
  455. ---------------------------------------------------------------------------*/
  456. HRESULT NewRtrWizData::HrIsSharedAccessRunningOnServer()
  457. {
  458. if (m_fTest)
  459. return s_fIsSharedAccessRunningOnServer ? S_OK : S_FALSE;
  460. else
  461. return NatConflictExists(m_stServerName) ? S_OK : S_FALSE;
  462. }
  463. /*!--------------------------------------------------------------------------
  464. NewRtrWizData::HrIsMemberOfDomain
  465. -
  466. Author: KennT
  467. ---------------------------------------------------------------------------*/
  468. HRESULT NewRtrWizData::HrIsMemberOfDomain()
  469. {
  470. if (m_fTest)
  471. return s_fIsMemberOfDomain ? S_OK : S_FALSE;
  472. else
  473. {
  474. // flip the meaning
  475. HRESULT hr = HrIsStandaloneServer(m_stServerName);
  476. if (FHrSucceeded(hr))
  477. return FHrOK(hr) ? S_FALSE : S_OK;
  478. else
  479. return hr;
  480. }
  481. }
  482. /*!--------------------------------------------------------------------------
  483. NewRtrWizData::GetNextPage
  484. -
  485. Author: KennT
  486. ---------------------------------------------------------------------------*/
  487. LRESULT NewRtrWizData::GetNextPage(UINT uDialogId)
  488. {
  489. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  490. LRESULT lNextPage = 0;
  491. DWORD dwNICs;
  492. CString st;
  493. switch (uDialogId)
  494. {
  495. default:
  496. Panic0("We should not be here, this is a finish page!");
  497. break;
  498. case IDD_NEWRTRWIZ_WELCOME:
  499. lNextPage = IDD_NEWRTRWIZ_COMMONCONFIG;
  500. break;
  501. case IDD_NEWRTRWIZ_COMMONCONFIG:
  502. switch (m_wizType)
  503. {
  504. case WizardRouterType_NAT:
  505. if ( !FHrOK(HrIsIPInstalled()) )
  506. {
  507. if (FHrOK(HrIsLocalMachine()))
  508. lNextPage = IDD_NEWRTRWIZ_NAT_NOIP;
  509. else
  510. lNextPage = IDD_NEWRTRWIZ_NAT_NOIP_NONLOCAL;
  511. }
  512. else
  513. lNextPage = IDD_NEWRTRWIZ_NAT_CHOOSE;
  514. break;
  515. case WizardRouterType_RAS:
  516. {
  517. DWORD dwNICs = 0;
  518. GetNumberOfNICS_IPorIPX(&dwNICs);
  519. if ((dwNICs > 1) ||
  520. FHrOK(HrIsMemberOfDomain()))
  521. {
  522. m_fAdvanced = TRUE;
  523. lNextPage = IDD_NEWRTRWIZ_RAS_A_PROTOCOLS;
  524. }
  525. else
  526. lNextPage = IDD_NEWRTRWIZ_RAS_CHOOSE;
  527. }
  528. break;
  529. case WizardRouterType_VPN:
  530. if (FHrOK(HrIsIPInstalled()))
  531. {
  532. GetNumberOfNICS_IP(&dwNICs);
  533. if (dwNICs < 1)
  534. lNextPage = IDD_NEWRTRWIZ_VPN_A_FINISH_NONICS;
  535. else
  536. lNextPage = IDD_NEWRTRWIZ_VPN_A_PROTOCOLS;
  537. }
  538. else
  539. {
  540. if (FHrOK(HrIsLocalMachine()))
  541. lNextPage = IDD_NEWRTRWIZ_VPN_NOIP;
  542. else
  543. lNextPage = IDD_NEWRTRWIZ_VPN_NOIP_NONLOCAL;
  544. }
  545. // There is no simple path
  546. m_fAdvanced = TRUE;
  547. break;
  548. case WizardRouterType_Router:
  549. lNextPage = IDD_NEWRTRWIZ_ROUTER_PROTOCOLS;
  550. // There is no simple path
  551. m_fAdvanced = TRUE;
  552. break;
  553. case WizardRouterType_Manual:
  554. lNextPage = IDD_NEWRTRWIZ_MANUAL_FINISH;
  555. m_fAdvanced = TRUE;
  556. break;
  557. }
  558. break;
  559. case IDD_NEWRTRWIZ_NAT_CHOOSE:
  560. // Check to see if SharedAccess is running, if so we
  561. // have to abort the process here.
  562. if (FHrOK(HrIsSharedAccessRunningOnServer()))
  563. {
  564. if (m_fAdvanced)
  565. {
  566. if (FHrOK(HrIsLocalMachine()))
  567. lNextPage = IDD_NEWRTRWIZ_NAT_A_CONFLICT;
  568. else
  569. lNextPage = IDD_NEWRTRWIZ_NAT_A_CONFLICT_NONLOCAL;
  570. }
  571. else
  572. {
  573. if (FHrOK(HrIsLocalMachine()))
  574. lNextPage = IDD_NEWRTRWIZ_NAT_S_CONFLICT;
  575. else
  576. lNextPage = IDD_NEWRTRWIZ_NAT_S_CONFLICT_NONLOCAL;
  577. }
  578. }
  579. else if (m_fAdvanced)
  580. {
  581. lNextPage = IDD_NEWRTRWIZ_NAT_A_PUBLIC;
  582. }
  583. else
  584. {
  585. // Stay at the same page
  586. lNextPage = -1;
  587. if ( FHrOK( HrIsLocalMachine() ) )
  588. {
  589. if (AfxMessageBox(IDS_WRN_RTRWIZ_NAT_S_FINISH,
  590. MB_OKCANCEL | MB_ICONINFORMATION) == IDOK)
  591. {
  592. // Fix the save and help flags
  593. m_HelpFlag = HelpFlag_ICS;
  594. m_SaveFlag = SaveFlag_DoNothing;
  595. // Have it finish the wizard
  596. lNextPage = ERR_IDD_FINISH_WIZARD;
  597. }
  598. }
  599. else
  600. {
  601. st.Format(IDS_WRN_RTRWIZ_NAT_S_FINISH_NONLOCAL,
  602. (LPCTSTR) m_stServerName);
  603. if (AfxMessageBox(st,
  604. MB_OKCANCEL | MB_ICONINFORMATION) == IDOK)
  605. {
  606. // Fix the save and help flags
  607. m_HelpFlag = HelpFlag_Nothing;
  608. m_SaveFlag = SaveFlag_DoNothing;
  609. // Have it finish the wizard
  610. lNextPage = ERR_IDD_FINISH_WIZARD;
  611. }
  612. }
  613. }
  614. break;
  615. case IDD_NEWRTRWIZ_NAT_A_PUBLIC:
  616. {
  617. // Determine the number of NICs
  618. GetNumberOfNICS_IP(&dwNICs);
  619. // Adjust the number of NICs (depending on whether
  620. // we selected to create a DD or not).
  621. if (dwNICs)
  622. {
  623. if (!m_fCreateDD)
  624. dwNICs--;
  625. }
  626. // Now switch depending on the number of NICs
  627. if (dwNICs == 0)
  628. lNextPage = IDD_NEWRTRWIZ_NAT_A_NONICS_FINISH;
  629. else if (dwNICs > 1)
  630. lNextPage = IDD_NEWRTRWIZ_NAT_A_PRIVATE;
  631. if (lNextPage)
  632. break;
  633. }
  634. // Fall through to the next case
  635. // At this stage, we now have the case that the
  636. // remaining number of NICs == 1, and we need to
  637. // autoselect the NIC and go on to the next test.
  638. AutoSelectPrivateInterface();
  639. case IDD_NEWRTRWIZ_NAT_A_PRIVATE:
  640. if (FHrOK(HrIsDNSRunningOnInterface()) ||
  641. FHrOK(HrIsDHCPRunningOnInterface()) ||
  642. FHrOK(HrIsDNSRunningOnServer()) ||
  643. FHrOK(HrIsDHCPRunningOnServer()))
  644. {
  645. // Popup a warning box
  646. // AfxMessageBox(IDS_WRN_RTRWIZ_NAT_DHCPDNS_FOUND,
  647. // MB_ICONEXCLAMATION);
  648. m_fNatUseSimpleServers = FALSE;
  649. //continue on down, and fall through
  650. }
  651. else
  652. {
  653. lNextPage = IDD_NEWRTRWIZ_NAT_A_DHCPDNS;
  654. break;
  655. }
  656. case IDD_NEWRTRWIZ_NAT_A_DHCPDNS:
  657. if (m_fNatUseSimpleServers)
  658. lNextPage = IDD_NEWRTRWIZ_NAT_A_DHCP_WARNING;
  659. else
  660. {
  661. if (m_fCreateDD)
  662. lNextPage = IDD_NEWRTRWIZ_NAT_A_DD_WARNING;
  663. else
  664. lNextPage = IDD_NEWRTRWIZ_NAT_A_EXTERNAL_FINISH;
  665. }
  666. break;
  667. case IDD_NEWRTRWIZ_NAT_A_DHCP_WARNING:
  668. Assert(m_fNatUseSimpleServers);
  669. if (m_fCreateDD)
  670. lNextPage = IDD_NEWRTRWIZ_NAT_A_DD_WARNING;
  671. else
  672. lNextPage = IDD_NEWRTRWIZ_NAT_A_FINISH;
  673. break;
  674. case IDD_NEWRTRWIZ_NAT_A_DD_WARNING:
  675. if (!FHrSucceeded(m_hrDDError))
  676. lNextPage = IDD_NEWRTRWIZ_NAT_A_DD_ERROR;
  677. else
  678. {
  679. if (m_fNatUseSimpleServers)
  680. lNextPage = IDD_NEWRTRWIZ_NAT_A_FINISH;
  681. else
  682. lNextPage = IDD_NEWRTRWIZ_NAT_A_EXTERNAL_FINISH;
  683. }
  684. break;
  685. case IDD_NEWRTRWIZ_RAS_CHOOSE:
  686. if (m_fAdvanced)
  687. lNextPage = IDD_NEWRTRWIZ_RAS_A_PROTOCOLS;
  688. else
  689. {
  690. // Stay at the same page
  691. lNextPage = -1;
  692. if ( FHrOK( HrIsLocalMachine() ) )
  693. {
  694. // lNextPage = IDD_NEWRTRWIZ_RAS_S_FINISH;
  695. // Pop the current page so that we stay in sync
  696. if (AfxMessageBox(IDS_WRN_RTRWIZ_RAS_S_FINISH,
  697. MB_OKCANCEL | MB_ICONINFORMATION) == IDOK)
  698. {
  699. // Fix the save and help flags
  700. m_HelpFlag = HelpFlag_InboundConnections;
  701. m_SaveFlag = SaveFlag_DoNothing;
  702. // Have it finish the wizard
  703. lNextPage = ERR_IDD_FINISH_WIZARD;
  704. }
  705. }
  706. else
  707. {
  708. st.Format(IDS_WRN_RTRWIZ_RAS_S_FINISH_NONLOCAL,
  709. (LPCTSTR) m_stServerName);
  710. // lNextPage = IDD_NEWRTRWIZ_RAS_S_NONLOCAL;
  711. if (AfxMessageBox(st,
  712. MB_OKCANCEL | MB_ICONINFORMATION) == IDOK)
  713. {
  714. // Fix the save and help flags
  715. m_HelpFlag = HelpFlag_Nothing;
  716. m_SaveFlag = SaveFlag_DoNothing;
  717. // Have it finish the wizard
  718. lNextPage = ERR_IDD_FINISH_WIZARD;
  719. }
  720. }
  721. }
  722. break;
  723. case IDD_NEWRTRWIZ_RAS_A_PROTOCOLS:
  724. if (m_fNeedMoreProtocols)
  725. {
  726. if (FHrOK(HrIsLocalMachine()))
  727. lNextPage = IDD_NEWRTRWIZ_RAS_A_NEED_PROT;
  728. else
  729. lNextPage = IDD_NEWRTRWIZ_RAS_A_NEED_PROT_NONLOCAL;
  730. break;
  731. }
  732. /*
  733. if (FHrOK(HrIsAppletalkInUse()))
  734. {
  735. lNextPage = IDD_NEWRTRWIZ_RAS_A_ATALK;
  736. break;
  737. }
  738. */
  739. // fall through
  740. case IDD_NEWRTRWIZ_RAS_A_ATALK:
  741. if (FHrOK(HrIsIPInUse()))
  742. {
  743. GetNumberOfNICS_IP(&dwNICs);
  744. if (dwNICs > 1)
  745. lNextPage = IDD_NEWRTRWIZ_RAS_A_NETWORK;
  746. else if (dwNICs == 0)
  747. lNextPage = IDD_NEWRTRWIZ_RAS_A_NONICS;
  748. else
  749. {
  750. AutoSelectPrivateInterface();
  751. lNextPage = IDD_NEWRTRWIZ_RAS_A_ADDRESSING;
  752. }
  753. break;
  754. }
  755. // default catch
  756. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  757. break;
  758. case IDD_NEWRTRWIZ_RAS_A_NONICS:
  759. if (m_fNoNicsAreOk)
  760. lNextPage = IDD_NEWRTRWIZ_RAS_A_ADDRESSING_NONICS;
  761. else
  762. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH_NONICS;
  763. break;
  764. case IDD_NEWRTRWIZ_RAS_A_NETWORK:
  765. lNextPage = IDD_NEWRTRWIZ_RAS_A_ADDRESSING;
  766. break;
  767. case IDD_NEWRTRWIZ_RAS_A_ADDRESSING:
  768. if (m_fUseDHCP)
  769. {
  770. GetNumberOfNICS_IP(&dwNICs);
  771. if (dwNICs &&
  772. !FHrOK(HrIsDHCPRunningOnInterface()) &&
  773. !FHrOK(HrIsDHCPRunningOnServer()))
  774. AfxMessageBox(IDS_WRN_RTRWIZ_RAS_NODHCP,
  775. MB_ICONEXCLAMATION);
  776. lNextPage = IDD_NEWRTRWIZ_RAS_A_USERADIUS;
  777. }
  778. else
  779. lNextPage = IDD_NEWRTRWIZ_RAS_A_ADDRESSPOOL;
  780. break;
  781. case IDD_NEWRTRWIZ_RAS_A_ADDRESSING_NONICS:
  782. if (m_fUseDHCP)
  783. {
  784. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  785. }
  786. else
  787. lNextPage = IDD_NEWRTRWIZ_RAS_A_ADDRESSPOOL;
  788. break;
  789. case IDD_NEWRTRWIZ_RAS_A_ADDRESSPOOL:
  790. GetNumberOfNICS_IP(&dwNICs);
  791. if (dwNICs == 0)
  792. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  793. else
  794. lNextPage = IDD_NEWRTRWIZ_RAS_A_USERADIUS;
  795. break;
  796. case IDD_NEWRTRWIZ_RAS_A_USERADIUS:
  797. if (m_fUseRadius)
  798. lNextPage = IDD_NEWRTRWIZ_RAS_A_RADIUS_CONFIG;
  799. else
  800. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  801. break;
  802. case IDD_NEWRTRWIZ_RAS_A_RADIUS_CONFIG:
  803. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  804. break;
  805. case IDD_NEWRTRWIZ_VPN_A_PROTOCOLS:
  806. if (m_fNeedMoreProtocols)
  807. {
  808. if (FHrOK(HrIsLocalMachine()))
  809. lNextPage = IDD_NEWRTRWIZ_RAS_A_NEED_PROT;
  810. else
  811. lNextPage = IDD_NEWRTRWIZ_RAS_A_NEED_PROT_NONLOCAL;
  812. break;
  813. }
  814. /*
  815. if (FHrOK(HrIsAppletalkInUse()))
  816. {
  817. lNextPage = IDD_NEWRTRWIZ_VPN_A_ATALK;
  818. break;
  819. }
  820. */
  821. // fall through
  822. case IDD_NEWRTRWIZ_VPN_A_ATALK:
  823. GetNumberOfNICS_IP(&dwNICs);
  824. Assert(dwNICs >= 1);
  825. lNextPage = IDD_NEWRTRWIZ_VPN_A_PUBLIC;
  826. break;
  827. case IDD_NEWRTRWIZ_VPN_A_PUBLIC:
  828. GetNumberOfNICS_IP(&dwNICs);
  829. // Are there any NICs left?
  830. if (((dwNICs == 1) && m_stPublicInterfaceId.IsEmpty()) ||
  831. ((dwNICs == 2) && !m_stPublicInterfaceId.IsEmpty()))
  832. {
  833. AutoSelectPrivateInterface();
  834. lNextPage = IDD_NEWRTRWIZ_VPN_A_ADDRESSING;
  835. }
  836. else
  837. lNextPage = IDD_NEWRTRWIZ_VPN_A_PRIVATE;
  838. break;
  839. case IDD_NEWRTRWIZ_VPN_A_PRIVATE:
  840. Assert(!m_stPrivateInterfaceId.IsEmpty());
  841. lNextPage = IDD_NEWRTRWIZ_VPN_A_ADDRESSING;
  842. break;
  843. case IDD_NEWRTRWIZ_VPN_A_ADDRESSING:
  844. if (m_fUseDHCP)
  845. {
  846. GetNumberOfNICS_IP(&dwNICs);
  847. if (dwNICs &&
  848. !FHrOK(HrIsDHCPRunningOnInterface()) &&
  849. !FHrOK(HrIsDHCPRunningOnServer()))
  850. AfxMessageBox(IDS_WRN_RTRWIZ_VPN_NODHCP,
  851. MB_ICONEXCLAMATION);
  852. lNextPage = IDD_NEWRTRWIZ_VPN_A_USERADIUS;
  853. }
  854. else
  855. lNextPage = IDD_NEWRTRWIZ_VPN_A_ADDRESSPOOL;
  856. break;
  857. case IDD_NEWRTRWIZ_VPN_A_ADDRESSPOOL:
  858. lNextPage = IDD_NEWRTRWIZ_VPN_A_USERADIUS;
  859. break;
  860. case IDD_NEWRTRWIZ_VPN_A_USERADIUS:
  861. if (m_fUseRadius)
  862. lNextPage = IDD_NEWRTRWIZ_VPN_A_RADIUS_CONFIG;
  863. else
  864. lNextPage = IDD_NEWRTRWIZ_VPN_A_FINISH;
  865. break;
  866. case IDD_NEWRTRWIZ_VPN_A_RADIUS_CONFIG:
  867. lNextPage = IDD_NEWRTRWIZ_VPN_A_FINISH;
  868. break;
  869. case IDD_NEWRTRWIZ_ROUTER_PROTOCOLS:
  870. if (m_fNeedMoreProtocols)
  871. {
  872. if (FHrOK(HrIsLocalMachine()))
  873. lNextPage = IDD_NEWRTRWIZ_ROUTER_NEED_PROT;
  874. else
  875. lNextPage = IDD_NEWRTRWIZ_ROUTER_NEED_PROT_NONLOCAL;
  876. break;
  877. }
  878. lNextPage = IDD_NEWRTRWIZ_ROUTER_USEDD;
  879. break;
  880. case IDD_NEWRTRWIZ_ROUTER_USEDD:
  881. if (m_fUseDD)
  882. lNextPage = IDD_NEWRTRWIZ_ROUTER_ADDRESSING;
  883. else
  884. lNextPage = IDD_NEWRTRWIZ_ROUTER_FINISH;
  885. break;
  886. case IDD_NEWRTRWIZ_ROUTER_ADDRESSING:
  887. if (m_fUseDHCP)
  888. lNextPage = IDD_NEWRTRWIZ_ROUTER_FINISH_DD;
  889. else
  890. lNextPage = IDD_NEWRTRWIZ_ROUTER_ADDRESSPOOL;
  891. break;
  892. case IDD_NEWRTRWIZ_ROUTER_ADDRESSPOOL:
  893. lNextPage = IDD_NEWRTRWIZ_ROUTER_FINISH_DD;
  894. break;
  895. }
  896. return lNextPage;
  897. }
  898. /*!--------------------------------------------------------------------------
  899. NewRtrWizData::GetNumberOfNICS
  900. -
  901. Author: KennT
  902. ---------------------------------------------------------------------------*/
  903. HRESULT NewRtrWizData::GetNumberOfNICS_IP(DWORD *pdwNumber)
  904. {
  905. if (m_fTest)
  906. {
  907. Assert(s_dwNumberOfNICs == m_ifMap.GetCount());
  908. }
  909. *pdwNumber = m_ifMap.GetCount();
  910. return hrOK;
  911. }
  912. /*!--------------------------------------------------------------------------
  913. NewRtrWizData::GetNumberOfNICS_IPorIPX
  914. -
  915. Author: KennT
  916. ---------------------------------------------------------------------------*/
  917. HRESULT NewRtrWizData::GetNumberOfNICS_IPorIPX(DWORD *pdwNumber)
  918. {
  919. *pdwNumber = m_dwNumberOfNICs_IPorIPX;
  920. return hrOK;
  921. }
  922. /*!--------------------------------------------------------------------------
  923. NewRtrWizData::AutoSelectPrivateInterface
  924. -
  925. Author: KennT
  926. ---------------------------------------------------------------------------*/
  927. void NewRtrWizData::AutoSelectPrivateInterface()
  928. {
  929. POSITION pos;
  930. RtrWizInterface * pRtrWizIf = NULL;
  931. CString st;
  932. m_stPrivateInterfaceId.Empty();
  933. pos = m_ifMap.GetStartPosition();
  934. while (pos)
  935. {
  936. m_ifMap.GetNextAssoc(pos, st, pRtrWizIf);
  937. if (m_stPublicInterfaceId != st)
  938. {
  939. m_stPrivateInterfaceId = st;
  940. break;
  941. }
  942. }
  943. Assert(!m_stPrivateInterfaceId.IsEmpty());
  944. return;
  945. }
  946. /*!--------------------------------------------------------------------------
  947. NewRtrWizData::LoadInterfaceData
  948. -
  949. Author: KennT
  950. ---------------------------------------------------------------------------*/
  951. void NewRtrWizData::LoadInterfaceData(IRouterInfo *pRouter)
  952. {
  953. HRESULT hr = hrOK;
  954. HKEY hkeyMachine = NULL;
  955. if (!m_fTest)
  956. {
  957. // Try to get the real information
  958. SPIEnumInterfaceInfo spEnumIf;
  959. SPIInterfaceInfo spIf;
  960. RtrWizInterface * pRtrWizIf = NULL;
  961. CStringList listAddress;
  962. CStringList listMask;
  963. BOOL fDhcp;
  964. BOOL fDns;
  965. pRouter->EnumInterface(&spEnumIf);
  966. CWRg( ConnectRegistry(pRouter->GetMachineName(), &hkeyMachine) );
  967. for (; hrOK == spEnumIf->Next(1, &spIf, NULL); spIf.Release())
  968. {
  969. // Only look at NICs
  970. if (spIf->GetInterfaceType() != ROUTER_IF_TYPE_DEDICATED)
  971. continue;
  972. // count the interface bound to IP or IPX
  973. if (FHrOK(spIf->FindRtrMgrInterface(PID_IP, NULL)) || FHrOK(spIf->FindRtrMgrInterface(PID_IPX, NULL)))
  974. {
  975. m_dwNumberOfNICs_IPorIPX++;
  976. }
  977. // Only allow those interfaces bound to IP to show up
  978. if (!FHrOK(spIf->FindRtrMgrInterface(PID_IP, NULL)))
  979. {
  980. continue;
  981. }
  982. pRtrWizIf = new RtrWizInterface;
  983. pRtrWizIf->m_stName = spIf->GetTitle();
  984. pRtrWizIf->m_stId = spIf->GetId();
  985. pRtrWizIf->m_stDesc = spIf->GetDeviceName();
  986. if (FHrOK(HrIsIPInstalled()))
  987. {
  988. POSITION pos;
  989. DWORD netAddress, dwAddress;
  990. CString stAddress, stDhcpServer;
  991. // Clear the lists before getting them again.
  992. // ----------------------------------------------------
  993. listAddress.RemoveAll();
  994. listMask.RemoveAll();
  995. fDhcp = fDns = FALSE;
  996. QueryIpAddressList(pRouter->GetMachineName(),
  997. hkeyMachine,
  998. spIf->GetId(),
  999. &listAddress,
  1000. &listMask,
  1001. &fDhcp,
  1002. &fDns,
  1003. &stDhcpServer);
  1004. // Iterate through the list of strings looking
  1005. // for an autonet address
  1006. // ----------------------------------------------------
  1007. pos = listAddress.GetHeadPosition();
  1008. while (pos)
  1009. {
  1010. stAddress = listAddress.GetNext(pos);
  1011. netAddress = INET_ADDR((LPCTSTR) stAddress);
  1012. dwAddress = ntohl(netAddress);
  1013. // Check for reserved address ranges, this indicates
  1014. // an autonet address
  1015. // ------------------------------------------------
  1016. if ((dwAddress & 0xFFFF0000) == MAKEIPADDRESS(169,254,0,0))
  1017. {
  1018. // This is not a DHCP address, it is an
  1019. // autonet address.
  1020. // --------------------------------------------
  1021. fDhcp = FALSE;
  1022. break;
  1023. }
  1024. }
  1025. FormatListString(listAddress, pRtrWizIf->m_stIpAddress,
  1026. _T(","));
  1027. FormatListString(listMask, pRtrWizIf->m_stMask,
  1028. _T(","));
  1029. stDhcpServer.TrimLeft();
  1030. stDhcpServer.TrimRight();
  1031. pRtrWizIf->m_stDhcpServer = stDhcpServer;
  1032. pRtrWizIf->m_fDhcpObtained = fDhcp;
  1033. pRtrWizIf->m_fIsDhcpEnabled = fDhcp;
  1034. pRtrWizIf->m_fIsDnsEnabled = fDns;
  1035. }
  1036. m_ifMap.SetAt(pRtrWizIf->m_stId, pRtrWizIf);
  1037. pRtrWizIf = NULL;
  1038. }
  1039. delete pRtrWizIf;
  1040. }
  1041. else
  1042. {
  1043. CString st;
  1044. RtrWizInterface * pRtrWizIf;
  1045. // For now just the debug data
  1046. for (DWORD i=0; i<s_dwNumberOfNICs; i++)
  1047. {
  1048. pRtrWizIf = new RtrWizInterface;
  1049. pRtrWizIf->m_stName.Format(_T("Local Area Connection #%d"), i);
  1050. pRtrWizIf->m_stId.Format(_T("{%d-GUID...}"), i);
  1051. pRtrWizIf->m_stDesc = _T("Generic Intel hardware");
  1052. if (FHrOK(HrIsIPInstalled()))
  1053. {
  1054. pRtrWizIf->m_stIpAddress = _T("11.22.33.44");
  1055. pRtrWizIf->m_stMask = _T("255.255.0.0");
  1056. // These parameters are dependent on other things
  1057. pRtrWizIf->m_fDhcpObtained = FALSE;
  1058. pRtrWizIf->m_fIsDhcpEnabled = FALSE;
  1059. pRtrWizIf->m_fIsDnsEnabled = FALSE;
  1060. }
  1061. m_ifMap.SetAt(pRtrWizIf->m_stId, pRtrWizIf);
  1062. pRtrWizIf = NULL;
  1063. }
  1064. }
  1065. Error:
  1066. if (hkeyMachine)
  1067. DisconnectRegistry(hkeyMachine);
  1068. }
  1069. /*!--------------------------------------------------------------------------
  1070. NewRtrWizData::SaveToRtrConfigData
  1071. -
  1072. Author: KennT
  1073. ---------------------------------------------------------------------------*/
  1074. HRESULT NewRtrWizData::SaveToRtrConfigData()
  1075. {
  1076. HRESULT hr = hrOK;
  1077. POSITION pos;
  1078. AddressPoolInfo poolInfo;
  1079. // Sync up with the general structure
  1080. // ----------------------------------------------------------------
  1081. switch (m_wizType)
  1082. {
  1083. case WizardRouterType_NAT:
  1084. m_dwRouterType = ROUTER_TYPE_LAN;
  1085. // If we have been told to create a DD interface
  1086. // then we must have a WAN router.
  1087. if (m_fCreateDD)
  1088. m_dwRouterType |= ROUTER_TYPE_WAN;
  1089. break;
  1090. case WizardRouterType_RAS:
  1091. m_dwRouterType = ROUTER_TYPE_RAS;
  1092. break;
  1093. case WizardRouterType_VPN:
  1094. m_dwRouterType = ROUTER_TYPE_LAN | ROUTER_TYPE_WAN | ROUTER_TYPE_RAS;
  1095. break;
  1096. case WizardRouterType_Manual:
  1097. m_dwRouterType = ROUTER_TYPE_LAN | ROUTER_TYPE_WAN | ROUTER_TYPE_RAS;
  1098. break;
  1099. default:
  1100. case WizardRouterType_Router:
  1101. Assert(m_wizType == WizardRouterType_Router);
  1102. m_dwRouterType = ROUTER_TYPE_LAN;
  1103. // If we have chosen to use a DD interface, then we do
  1104. // WAN routing.
  1105. if (m_fUseDD)
  1106. m_dwRouterType |= ROUTER_TYPE_WAN;
  1107. break;
  1108. }
  1109. m_RtrConfigData.m_dwRouterType = m_dwRouterType;
  1110. // Setup the NAT-specific information
  1111. // ----------------------------------------------------------------
  1112. if (m_wizType == WizardRouterType_NAT)
  1113. {
  1114. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_NAT;
  1115. if (m_fNatUseSimpleServers)
  1116. {
  1117. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_DNS_PROXY;
  1118. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_DHCP_ALLOCATOR;
  1119. }
  1120. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_H323; // deonb added
  1121. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_FTP;
  1122. }
  1123. // Sync up with the IP structure
  1124. // ----------------------------------------------------------------
  1125. if (m_fIpInstalled)
  1126. {
  1127. DWORD dwNICs;
  1128. // Set the private interface id into the IP structure
  1129. Assert(!m_stPrivateInterfaceId.IsEmpty());
  1130. m_RtrConfigData.m_ipData.m_dwAllowNetworkAccess = TRUE;
  1131. m_RtrConfigData.m_ipData.m_dwUseDhcp = m_fUseDHCP;
  1132. // If there is only one NIC, leave this the way it is (RAS
  1133. // to select the adapter). Otherwise, people can get stuck.
  1134. // Install 1, remove it and install a new one.
  1135. //
  1136. // ------------------------------------------------------------
  1137. GetNumberOfNICS_IP(&dwNICs);
  1138. if (dwNICs > 1)
  1139. m_RtrConfigData.m_ipData.m_stNetworkAdapterGUID = m_stPrivateInterfaceId;
  1140. m_RtrConfigData.m_ipData.m_stPrivateAdapterGUID = m_stPrivateInterfaceId;
  1141. m_RtrConfigData.m_ipData.m_stPublicAdapterGUID = m_stPublicInterfaceId;
  1142. m_RtrConfigData.m_ipData.m_dwEnableIn = TRUE;
  1143. // copy over the address pool list
  1144. m_RtrConfigData.m_ipData.m_addressPoolList.RemoveAll();
  1145. if (m_addressPoolList.GetCount())
  1146. {
  1147. pos = m_addressPoolList.GetHeadPosition();
  1148. while (pos)
  1149. {
  1150. poolInfo = m_addressPoolList.GetNext(pos);
  1151. m_RtrConfigData.m_ipData.m_addressPoolList.AddTail(poolInfo);
  1152. }
  1153. }
  1154. }
  1155. // Sync up with the IPX structure
  1156. // ----------------------------------------------------------------
  1157. if (m_fIpxInstalled)
  1158. {
  1159. m_RtrConfigData.m_ipxData.m_dwAllowNetworkAccess = TRUE;
  1160. m_RtrConfigData.m_ipxData.m_dwEnableIn = TRUE;
  1161. m_RtrConfigData.m_ipxData.m_fEnableType20Broadcasts = m_fUseIpxType20Broadcasts;
  1162. // The other parameters will be left at their defaults
  1163. }
  1164. // Sync up with the Appletalk structure
  1165. // ----------------------------------------------------------------
  1166. if (m_fAppletalkInstalled)
  1167. {
  1168. m_RtrConfigData.m_arapData.m_dwEnableIn = TRUE;
  1169. }
  1170. // Sync up with the NBF structure
  1171. // ----------------------------------------------------------------
  1172. if (m_fNbfInstalled)
  1173. {
  1174. m_RtrConfigData.m_nbfData.m_dwAllowNetworkAccess = TRUE;
  1175. m_RtrConfigData.m_nbfData.m_dwEnableIn = TRUE;
  1176. }
  1177. // Sync up with the PPP structure
  1178. // ----------------------------------------------------------------
  1179. // Use the defaults
  1180. // Sync up with the Error log structure
  1181. // ----------------------------------------------------------------
  1182. // Use the defaults
  1183. // Sync up with the Auth structure
  1184. // ----------------------------------------------------------------
  1185. m_RtrConfigData.m_authData.m_dwFlags =
  1186. PPPCFG_NegotiateMSCHAP |
  1187. PPPCFG_NegotiateStrongMSCHAP;
  1188. if (m_fAppletalkUseNoAuth)
  1189. m_RtrConfigData.m_authData.m_dwFlags |=
  1190. PPPCFG_AllowNoAuthentication;
  1191. if (m_fUseRadius)
  1192. {
  1193. TCHAR szGuid[128];
  1194. // Setup the active auth/acct providers to be RADIUS
  1195. StringFromGUID2(CLSID_RouterAuthRADIUS, szGuid, DimensionOf(szGuid));
  1196. m_RtrConfigData.m_authData.m_stGuidActiveAuthProv = szGuid;
  1197. StringFromGUID2(CLSID_RouterAcctRADIUS, szGuid, DimensionOf(szGuid));
  1198. m_RtrConfigData.m_authData.m_stGuidActiveAcctProv = szGuid;
  1199. }
  1200. // Other parameters left at their defaults
  1201. return hr;
  1202. }
  1203. // --------------------------------------------------------------------
  1204. // Windows NT Bug : 408722
  1205. // Use this code to grab the WM_HELP message from the property sheet.
  1206. // --------------------------------------------------------------------
  1207. static WNDPROC s_lpfnOldWindowProc = NULL;
  1208. LONG FAR PASCAL HelpSubClassWndFunc(HWND hWnd,
  1209. UINT uMsg,
  1210. WPARAM wParam,
  1211. LPARAM lParam)
  1212. {
  1213. if (uMsg == WM_HELP)
  1214. {
  1215. HWND hWndOwner = PropSheet_GetCurrentPageHwnd(hWnd);
  1216. HELPINFO * pHelpInfo = (HELPINFO *) lParam;
  1217. // Reset the context ID, since we know exactly what we're
  1218. // sending (ahem, unless someone reuses this).
  1219. // ------------------------------------------------------------
  1220. pHelpInfo->dwContextId = 0xdeadbeef;
  1221. // Send the WM_HELP message to the prop page
  1222. // ------------------------------------------------------------
  1223. ::SendMessage(hWndOwner, uMsg, wParam, lParam);
  1224. return TRUE;
  1225. }
  1226. return CallWindowProc(s_lpfnOldWindowProc, hWnd, uMsg, wParam, lParam);
  1227. }
  1228. /*!--------------------------------------------------------------------------
  1229. NewRtrWizData::FinishTheDamnWizard
  1230. This is the code that actually does the work of saving the
  1231. data and doing all the operations.
  1232. Author: KennT
  1233. ---------------------------------------------------------------------------*/
  1234. HRESULT NewRtrWizData::FinishTheDamnWizard(HWND hwndOwner,
  1235. IRouterInfo *pRouter)
  1236. {
  1237. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  1238. DWORD dwError = ERROR_SUCCESS;
  1239. SPIRemoteNetworkConfig spNetwork;
  1240. IUnknown * punk = NULL;
  1241. CWaitCursor wait;
  1242. COSERVERINFO csi;
  1243. COAUTHINFO cai;
  1244. COAUTHIDENTITY caid;
  1245. HRESULT hr = hrOK;
  1246. if (m_fSaved)
  1247. return hr;
  1248. // Synchronize the RtrConfigData with this structure
  1249. // ----------------------------------------------------------------
  1250. CORg( SaveToRtrConfigData() );
  1251. // Ok, we now have the synchronized RtrConfigData.
  1252. // We can do everything else that we did before to save the
  1253. // information.
  1254. ZeroMemory(&csi, sizeof(csi));
  1255. ZeroMemory(&cai, sizeof(cai));
  1256. ZeroMemory(&caid, sizeof(caid));
  1257. csi.pAuthInfo = &cai;
  1258. cai.pAuthIdentityData = &caid;
  1259. // Create the remote config object
  1260. // ----------------------------------------------------------------
  1261. CORg( CoCreateRouterConfig(m_RtrConfigData.m_stServerName,
  1262. pRouter,
  1263. &csi,
  1264. IID_IRemoteNetworkConfig,
  1265. &punk) );
  1266. spNetwork = (IRemoteNetworkConfig *) punk;
  1267. punk = NULL;
  1268. // Upgrade the configuration (ensure that the registry keys
  1269. // are populated correctly).
  1270. // ------------------------------------------------------------
  1271. CORg( spNetwork->UpgradeRouterConfig() );
  1272. // Remove the IP-in-IP tunnel names (since the registry has
  1273. // been cleared).
  1274. // ------------------------------------------------------------
  1275. CleanupTunnelFriendlyNames(pRouter);
  1276. // At this point, the current IRouterInfo pointer is invalid.
  1277. // We will need to release the pointer and reload the info.
  1278. // ------------------------------------------------------------
  1279. if (pRouter)
  1280. {
  1281. pRouter->DoDisconnect();
  1282. pRouter->Unload();
  1283. pRouter->Load(m_stServerName, NULL);
  1284. }
  1285. dwError = RtrWizFinish( &m_RtrConfigData, pRouter );
  1286. hr = HResultFromWin32(dwError);
  1287. // Windows NT Bug : 173564
  1288. // Depending on the router type, we will go through and enable the
  1289. // devices.
  1290. // If routing only is enabled : set devices to ROUTING
  1291. // If ras-only : set devices to RAS
  1292. // If ras/routing : set devices to RAS/ROUTING
  1293. // 5/19/98 - need some resolution from DavidEi on what to do here.
  1294. // ------------------------------------------------------------
  1295. // Setup the entries in the list
  1296. // ------------------------------------------------------------
  1297. if (m_wizType == WizardRouterType_VPN)
  1298. SetDeviceType(m_stServerName, m_dwRouterType, 256);
  1299. else
  1300. SetDeviceType(m_stServerName, m_dwRouterType, 10);
  1301. // Update the RADIUS config
  1302. // ----------------------------------------------------------------
  1303. SaveRadiusConfig();
  1304. //
  1305. //Add the NAT protocol if tcpip routing is selected
  1306. //
  1307. if ( m_RtrConfigData.m_ipData.m_dwAllowNetworkAccess )
  1308. AddNATToServer(this, &m_RtrConfigData, pRouter, m_fCreateDD, TRUE);
  1309. // Ok at this point we try to establish the server in the domain
  1310. // If this fails, we ignore the error and popup a warning message.
  1311. //
  1312. // Windows NT Bug : 202776
  1313. // Do not register the router if we are a LAN-only router.
  1314. // ----------------------------------------------------------------
  1315. if ( FHrSucceeded(hr) &&
  1316. (m_dwRouterType != ROUTER_TYPE_LAN) &&
  1317. (!m_fUseRadius))
  1318. {
  1319. HRESULT hrT = hrOK;
  1320. hrT = ::RegisterRouterInDomain(m_stServerName, TRUE);
  1321. if (hrT != ERROR_NO_SUCH_DOMAIN)
  1322. {
  1323. if (!FHrSucceeded(hrT))
  1324. {
  1325. CString st;
  1326. CString stTitle;
  1327. st.Format(IDS_ERR_CANNOT_REGISTER_IN_DS,
  1328. m_stServerName);
  1329. stTitle.LoadString(AFX_IDS_APP_TITLE);
  1330. // Windows NT Bug : 408722
  1331. //
  1332. // NOTE: This code only works as long as this wizard
  1333. // blocks the main thread!
  1334. //
  1335. // We want the help message to be sent to the
  1336. // correct place (the property page)
  1337. // So let us subclass the sheet window (temporarily)
  1338. // ----------------------------------------------------
  1339. HWND hwndSheet = ::GetParent(hwndOwner);
  1340. if (hwndSheet)
  1341. {
  1342. s_lpfnOldWindowProc = (WNDPROC) SetWindowLongPtr(hwndSheet,
  1343. GWLP_WNDPROC, (LPARAM) HelpSubClassWndFunc);
  1344. if (s_lpfnOldWindowProc)
  1345. {
  1346. MessageBox(hwndOwner,
  1347. (LPCTSTR) st,
  1348. (LPCTSTR) stTitle,
  1349. MB_ICONWARNING | MB_OK | MB_HELP);
  1350. SetWindowLongPtr(hwndSheet, GWLP_WNDPROC,
  1351. (LPARAM) s_lpfnOldWindowProc);
  1352. s_lpfnOldWindowProc = NULL;
  1353. }
  1354. }
  1355. }
  1356. }
  1357. }
  1358. // NT Bug : 239384
  1359. // Install IGMP on the router by default (for RAS server only)
  1360. // Boing!, Change to whenever RAS is installed.
  1361. // ----------------------------------------------------------------
  1362. // We do NOT do this if we are using NAT. The reason is that
  1363. // NAT may want to be added to a demand dial interface.
  1364. // ----------------------------------------------------------------
  1365. if ((m_wizType != WizardRouterType_NAT) ||
  1366. ((m_wizType == WizardRouterType_NAT) && !m_fCreateDD))
  1367. {
  1368. // The path that NAT takes when creating the DD interface
  1369. // is somewhere else.
  1370. // ------------------------------------------------------------
  1371. Assert(m_fCreateDD == FALSE);
  1372. if (pRouter)
  1373. {
  1374. if (m_wizType == WizardRouterType_NAT)
  1375. {
  1376. AddIGMPToNATServer(&m_RtrConfigData, pRouter);
  1377. }
  1378. else if (m_RtrConfigData.m_dwRouterType & ROUTER_TYPE_RAS)
  1379. {
  1380. AddIGMPToRasServer(&m_RtrConfigData, pRouter);
  1381. }
  1382. }
  1383. if (m_RtrConfigData.m_dwConfigFlags & RTRCONFIG_SETUP_NAT)
  1384. {
  1385. AddNATToServer(this, &m_RtrConfigData, pRouter, m_fCreateDD, FALSE);
  1386. }
  1387. // Windows NT Bug : 371493
  1388. // Add the DHCP relay agent protocol
  1389. if (m_RtrConfigData.m_dwRouterType & ROUTER_TYPE_RAS)
  1390. {
  1391. DWORD dwDhcpServer = 0;
  1392. if (!m_stPrivateInterfaceId.IsEmpty())
  1393. {
  1394. RtrWizInterface * pRtrWizIf = NULL;
  1395. m_ifMap.Lookup(m_stPrivateInterfaceId, pRtrWizIf);
  1396. if (pRtrWizIf)
  1397. {
  1398. if (!pRtrWizIf->m_stDhcpServer.IsEmpty())
  1399. dwDhcpServer = INET_ADDR((LPCTSTR) pRtrWizIf->m_stDhcpServer);
  1400. // If we have a value of 0, or if the address
  1401. // is all 1's then we have a bogus address.
  1402. if ((dwDhcpServer == 0) ||
  1403. (dwDhcpServer == MAKEIPADDRESS(255,255,255,255)))
  1404. AfxMessageBox(IDS_WRN_RTRWIZ_NO_DHCP_SERVER);
  1405. }
  1406. }
  1407. AddIPBOOTPToServer(&m_RtrConfigData, pRouter, dwDhcpServer);
  1408. }
  1409. }
  1410. // If this is a VPN, add the filters to the public interface
  1411. // ----------------------------------------------------------------
  1412. if (m_wizType == WizardRouterType_VPN)
  1413. {
  1414. if (!m_stPublicInterfaceId.IsEmpty())
  1415. {
  1416. #if __USE_ICF__
  1417. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_NAT;
  1418. AddNATToServer(this, &m_RtrConfigData, pRouter, m_fCreateDD, FALSE);
  1419. #else
  1420. RtrWizInterface* pIf = NULL;
  1421. m_ifMap.Lookup(m_stPublicInterfaceId, pIf);
  1422. AddVPNFiltersToInterface(pRouter, m_stPublicInterfaceId, pIf);
  1423. DisableDDNSandNetBtOnInterface ( pRouter, m_stPublicInterfaceId, pIf);
  1424. #endif
  1425. }
  1426. }
  1427. // Try to update the policy.
  1428. // ----------------------------------------------------------------
  1429. // This should check the auth flags and the value of the flags
  1430. // should follow that.
  1431. // ----------------------------------------------------------------
  1432. if ((m_RtrConfigData.m_dwRouterType & ROUTER_TYPE_RAS) && !m_fUseRadius)
  1433. {
  1434. LPWSTR pswzServerName = NULL;
  1435. DWORD dwFlags;
  1436. BOOL fRequireEncryption;
  1437. if (!IsLocalMachine(m_stServerName))
  1438. pswzServerName = (LPTSTR)(LPCTSTR) m_stServerName;
  1439. dwFlags = m_RtrConfigData.m_authData.m_dwFlags;
  1440. // Only require encryption if this is a VPN server
  1441. // do not set the PPPCFG_RequireEncryption flag
  1442. // ------------------------------------------------------------
  1443. fRequireEncryption = (m_wizType == WizardRouterType_VPN);
  1444. hr = UpdateDefaultPolicy(pswzServerName,
  1445. !!(dwFlags & PPPCFG_NegotiateMSCHAP),
  1446. !!(dwFlags & PPPCFG_NegotiateStrongMSCHAP),
  1447. fRequireEncryption);
  1448. if (!FHrSucceeded(hr))
  1449. {
  1450. if (hr == ERROR_NO_DEFAULT_PROFILE)
  1451. {
  1452. // Do one thing
  1453. AfxMessageBox(IDS_ERR_CANNOT_FIND_DEFAULT_RAP, MB_OK | MB_ICONEXCLAMATION);
  1454. // since we already displayed the warning
  1455. hr = S_OK;
  1456. }
  1457. else
  1458. {
  1459. // Format the message
  1460. AddSystemErrorMessage(hr);
  1461. // popup a warning dialog
  1462. AddHighLevelErrorStringId(IDS_ERR_CANNOT_SYNC_WITH_RAP);
  1463. DisplayTFSErrorMessage(NULL);
  1464. }
  1465. }
  1466. }
  1467. // Always start the router.
  1468. // ----------------------------------------------------------------
  1469. SetRouterServiceStartType(m_stServerName,
  1470. SERVICE_AUTO_START);
  1471. {
  1472. // If this is manual start, we need to prompt them
  1473. // ------------------------------------------------------------
  1474. if ((m_wizType != WizardRouterType_Manual) ||
  1475. (AfxMessageBox(IDS_PROMPT_START_ROUTER_AFTER_INSTALL,
  1476. MB_YESNO | MB_TASKMODAL | MB_SETFOREGROUND) == IDYES))
  1477. {
  1478. CWaitCursor wait;
  1479. StartRouterService(m_RtrConfigData.m_stServerName);
  1480. }
  1481. }
  1482. // Mark this data structure as been saved. This way, when we
  1483. // reennter this function it doesn't get run again.
  1484. // ----------------------------------------------------------------
  1485. m_fSaved = TRUE;
  1486. Error:
  1487. // Force a router reconfiguration
  1488. // ----------------------------------------------------------------
  1489. // Force a full disconnect
  1490. // This will force the handles to be released
  1491. // ----------------------------------------------------------------
  1492. pRouter->DoDisconnect();
  1493. // ForceGlobalRefresh(m_spRouter);
  1494. // Get the error back
  1495. // ----------------------------------------------------------------
  1496. if (!FHrSucceeded(hr))
  1497. {
  1498. AddSystemErrorMessage(hr);
  1499. AddHighLevelErrorStringId(IDS_ERR_CANNOT_INSTALL_ROUTER);
  1500. DisplayTFSErrorMessage(NULL);
  1501. }
  1502. if (csi.pAuthInfo)
  1503. delete csi.pAuthInfo->pAuthIdentityData->Password;
  1504. return hr;
  1505. }
  1506. /*!--------------------------------------------------------------------------
  1507. NewRtrWizData::SaveRadiusConfig
  1508. -
  1509. Author: KennT
  1510. ---------------------------------------------------------------------------*/
  1511. HRESULT NewRtrWizData::SaveRadiusConfig()
  1512. {
  1513. HRESULT hr = hrOK;
  1514. HKEY hkeyMachine = NULL;
  1515. RADIUSSERVER rgServers[2];
  1516. RADIUSSERVER * pServers = NULL;
  1517. CRadiusServers oldServers;
  1518. BOOL fServerAdded = FALSE;
  1519. CWRg( ConnectRegistry((LPTSTR) (LPCTSTR) m_stServerName, &hkeyMachine) );
  1520. if (m_fUseRadius)
  1521. {
  1522. pServers = rgServers;
  1523. Assert(!m_stRadius1.IsEmpty() || !m_stRadius2.IsEmpty());
  1524. // Setup the pServers
  1525. if (!m_stRadius1.IsEmpty() && m_stRadius1.GetLength())
  1526. {
  1527. pServers->UseDefaults();
  1528. pServers->cScore = MAXSCORE;
  1529. // For compatibility with other RADIUS servers, we
  1530. // default this to OFF.
  1531. pServers->fUseDigitalSignatures = FALSE;
  1532. StrnCpy(pServers->szName, (LPCTSTR) m_stRadius1, MAX_PATH);
  1533. StrnCpy(pServers->wszSecret, (LPCTSTR) m_stRadiusSecret, MAX_PATH);
  1534. pServers->cchSecret = m_stRadiusSecret.GetLength();
  1535. pServers->IPAddress.sin_addr.s_addr = m_netRadius1IpAddress;
  1536. pServers->ucSeed = m_uSeed;
  1537. pServers->pNext = NULL;
  1538. fServerAdded = TRUE;
  1539. }
  1540. if (!m_stRadius2.IsEmpty() && m_stRadius2.GetLength())
  1541. {
  1542. // Have the previous one point here
  1543. if (fServerAdded)
  1544. {
  1545. pServers->pNext = pServers+1;
  1546. pServers++;
  1547. }
  1548. pServers->UseDefaults();
  1549. pServers->cScore = MAXSCORE - 1;
  1550. // For compatibility with other RADIUS servers, we
  1551. // default this to OFF.
  1552. pServers->fUseDigitalSignatures = FALSE;
  1553. StrnCpy(pServers->szName, (LPCTSTR) m_stRadius2, MAX_PATH);
  1554. StrnCpy(pServers->wszSecret, (LPCTSTR) m_stRadiusSecret, MAX_PATH);
  1555. pServers->cchSecret = m_stRadiusSecret.GetLength();
  1556. pServers->IPAddress.sin_addr.s_addr = m_netRadius2IpAddress;
  1557. pServers->ucSeed = m_uSeed;
  1558. pServers->pNext = NULL;
  1559. fServerAdded = TRUE;
  1560. }
  1561. // Ok, reset pServers
  1562. if (fServerAdded)
  1563. pServers = rgServers;
  1564. }
  1565. // Load the original server list and remove it from the
  1566. // LSA database.
  1567. LoadRadiusServers(m_stServerName,
  1568. hkeyMachine,
  1569. TRUE,
  1570. &oldServers,
  1571. RADIUS_FLAG_NOUI | RADIUS_FLAG_NOIP);
  1572. DeleteRadiusServers(m_stServerName,
  1573. oldServers.GetNextServer(TRUE));
  1574. oldServers.FreeAllServers();
  1575. LoadRadiusServers(m_stServerName,
  1576. hkeyMachine,
  1577. FALSE,
  1578. &oldServers,
  1579. RADIUS_FLAG_NOUI | RADIUS_FLAG_NOIP);
  1580. DeleteRadiusServers(m_stServerName,
  1581. oldServers.GetNextServer(TRUE));
  1582. // Save the authentication servers
  1583. CORg( SaveRadiusServers(m_stServerName,
  1584. hkeyMachine,
  1585. TRUE,
  1586. pServers) );
  1587. // Save the accounting servers
  1588. CORg( SaveRadiusServers(m_stServerName,
  1589. hkeyMachine,
  1590. FALSE,
  1591. pServers) );
  1592. Error:
  1593. if (hkeyMachine)
  1594. DisconnectRegistry(hkeyMachine);
  1595. return hr;
  1596. }
  1597. /*---------------------------------------------------------------------------
  1598. CNewRtrWizPageBase Implementation
  1599. ---------------------------------------------------------------------------*/
  1600. PageStack CNewRtrWizPageBase::m_pagestack;
  1601. CNewRtrWizPageBase::CNewRtrWizPageBase(UINT idd, PageType pt)
  1602. : CPropertyPageBase(idd),
  1603. m_pagetype(pt),
  1604. m_pRtrWizData(NULL),
  1605. m_uDialogId(idd)
  1606. {
  1607. }
  1608. BEGIN_MESSAGE_MAP(CNewRtrWizPageBase, CPropertyPageBase)
  1609. //{{AFX_MSG_MAP(CNewWizTestParams)
  1610. ON_MESSAGE(WM_HELP, OnHelp)
  1611. //}}AFX_MSG_MAP
  1612. END_MESSAGE_MAP()
  1613. static DWORD s_rgBulletId[] =
  1614. {
  1615. IDC_NEWWIZ_BULLET_1,
  1616. IDC_NEWWIZ_BULLET_2,
  1617. IDC_NEWWIZ_BULLET_3,
  1618. IDC_NEWWIZ_BULLET_4,
  1619. 0
  1620. };
  1621. BOOL CNewRtrWizPageBase::OnInitDialog()
  1622. {
  1623. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  1624. CWnd * pWnd = GetDlgItem(IDC_NEWWIZ_BIGTEXT);
  1625. HICON hIcon;
  1626. CWnd * pBulletWnd;
  1627. CString strFontName;
  1628. CString strFontSize;
  1629. BOOL fCreateFont = FALSE;
  1630. CPropertyPageBase::OnInitDialog();
  1631. if (pWnd)
  1632. {
  1633. // Ok we have to create the font
  1634. strFontName.LoadString(IDS_LARGEFONTNAME);
  1635. strFontSize.LoadString(IDS_LARGEFONTSIZE);
  1636. if (m_fontBig.CreatePointFont(10*_ttoi(strFontSize), strFontName))
  1637. {
  1638. pWnd->SetFont(&m_fontBig);
  1639. }
  1640. }
  1641. // Set the fonts to show up as bullets
  1642. for (int i=0; s_rgBulletId[i] != 0; i++)
  1643. {
  1644. pBulletWnd = GetDlgItem(s_rgBulletId[i]);
  1645. if (pBulletWnd)
  1646. {
  1647. // Only create the font if needed
  1648. if (!fCreateFont)
  1649. {
  1650. strFontName.LoadString(IDS_BULLETFONTNAME);
  1651. strFontSize.LoadString(IDS_BULLETFONTSIZE);
  1652. m_fontBullet.CreatePointFont(10*_ttoi(strFontSize), strFontName);
  1653. fCreateFont = TRUE;
  1654. }
  1655. pBulletWnd->SetFont(&m_fontBullet);
  1656. }
  1657. }
  1658. pWnd = GetDlgItem(IDC_NEWWIZ_ICON_WARNING);
  1659. if (pWnd)
  1660. {
  1661. hIcon = AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION);
  1662. ((CStatic *) pWnd)->SetIcon(hIcon);
  1663. }
  1664. pWnd = GetDlgItem(IDC_NEWWIZ_ICON_INFORMATION);
  1665. if (pWnd)
  1666. {
  1667. hIcon = AfxGetApp()->LoadStandardIcon(IDI_INFORMATION);
  1668. ((CStatic *) pWnd)->SetIcon(hIcon);
  1669. }
  1670. return TRUE;
  1671. }
  1672. /*!--------------------------------------------------------------------------
  1673. CNewRtrWizPageBase::PushPage
  1674. -
  1675. Author: KennT
  1676. ---------------------------------------------------------------------------*/
  1677. void CNewRtrWizPageBase::PushPage(UINT idd)
  1678. {
  1679. m_pagestack.AddHead(idd);
  1680. }
  1681. /*!--------------------------------------------------------------------------
  1682. CNewRtrWizPageBase::PopPage
  1683. -
  1684. Author: KennT
  1685. ---------------------------------------------------------------------------*/
  1686. UINT CNewRtrWizPageBase::PopPage()
  1687. {
  1688. if (m_pagestack.IsEmpty())
  1689. return 0;
  1690. return m_pagestack.RemoveHead();
  1691. }
  1692. /*!--------------------------------------------------------------------------
  1693. CNewRtrWizPageBase::OnSetActive
  1694. -
  1695. Author: KennT
  1696. ---------------------------------------------------------------------------*/
  1697. BOOL CNewRtrWizPageBase::OnSetActive()
  1698. {
  1699. switch (m_pagetype)
  1700. {
  1701. case Start:
  1702. GetHolder()->SetWizardButtonsFirst(TRUE);
  1703. break;
  1704. case Middle:
  1705. GetHolder()->SetWizardButtonsMiddle(TRUE);
  1706. break;
  1707. default:
  1708. case Finish:
  1709. GetHolder()->SetWizardButtonsLast(TRUE);
  1710. break;
  1711. }
  1712. return CPropertyPageBase::OnSetActive();
  1713. }
  1714. /*!--------------------------------------------------------------------------
  1715. CNewRtrWizPageBase::OnWizardNext
  1716. -
  1717. Author: KennT
  1718. ---------------------------------------------------------------------------*/
  1719. LRESULT CNewRtrWizPageBase::OnWizardNext()
  1720. {
  1721. HRESULT hr = hrOK;
  1722. LRESULT lResult;
  1723. // Tell the page to save it's state
  1724. hr = OnSavePage();
  1725. if (FHrSucceeded(hr))
  1726. {
  1727. // Now figure out where to go next
  1728. Assert(m_pRtrWizData);
  1729. lResult = m_pRtrWizData->GetNextPage(m_uDialogId);
  1730. switch (lResult)
  1731. {
  1732. case ERR_IDD_FINISH_WIZARD:
  1733. OnWizardFinish();
  1734. // fall through to the cancel case
  1735. case ERR_IDD_CANCEL_WIZARD:
  1736. GetHolder()->PressButton(PSBTN_CANCEL);
  1737. lResult = -1;
  1738. break;
  1739. default:
  1740. // Push the page only if we are going to another page
  1741. // The other cases will cause the wizard to exit, and
  1742. // we don't need the page stack.
  1743. // ----------------------------------------------------
  1744. if (lResult != -1)
  1745. PushPage(m_uDialogId);
  1746. break;
  1747. }
  1748. return lResult;
  1749. }
  1750. else
  1751. return (LRESULT) -1; // error! do not change the page
  1752. }
  1753. /*!--------------------------------------------------------------------------
  1754. CNewRtrWizPageBase::OnWizardBack
  1755. -
  1756. Author: KennT
  1757. ---------------------------------------------------------------------------*/
  1758. LRESULT CNewRtrWizPageBase::OnWizardBack()
  1759. {
  1760. Assert(!m_pagestack.IsEmpty());
  1761. return PopPage();
  1762. }
  1763. /*!--------------------------------------------------------------------------
  1764. CNewRtrWizPageBase::OnWizardFinish
  1765. -
  1766. Author: KennT
  1767. ---------------------------------------------------------------------------*/
  1768. BOOL CNewRtrWizPageBase::OnWizardFinish()
  1769. {
  1770. GetHolder()->OnFinish();
  1771. return TRUE;
  1772. }
  1773. HRESULT CNewRtrWizPageBase::OnSavePage()
  1774. {
  1775. return hrOK;
  1776. }
  1777. LRESULT CNewRtrWizPageBase::OnHelp(WPARAM, LPARAM lParam)
  1778. {
  1779. HELPINFO * pHelpInfo = (HELPINFO *) lParam;
  1780. // Windows NT Bug : 408722
  1781. // Put the help call here, this should only come in from
  1782. // the call from the dialog.
  1783. if (pHelpInfo->dwContextId == 0xdeadbeef)
  1784. {
  1785. HtmlHelpA(NULL, c_sazRRASDomainHelpTopic, HH_DISPLAY_TOPIC, 0);
  1786. return TRUE;
  1787. }
  1788. return FALSE;
  1789. }
  1790. /*---------------------------------------------------------------------------
  1791. CNewRtrWizFinishPageBase Implementation
  1792. ---------------------------------------------------------------------------*/
  1793. CNewRtrWizFinishPageBase::CNewRtrWizFinishPageBase(UINT idd,
  1794. RtrWizFinishSaveFlag SaveFlag,
  1795. RtrWizFinishHelpFlag HelpFlag)
  1796. : CNewRtrWizPageBase(idd, CNewRtrWizPageBase::Finish),
  1797. m_SaveFlag(SaveFlag),
  1798. m_HelpFlag(HelpFlag)
  1799. {
  1800. }
  1801. BEGIN_MESSAGE_MAP(CNewRtrWizFinishPageBase, CNewRtrWizPageBase)
  1802. //{{AFX_MSG_MAP(CNewWizTestParams)
  1803. //}}AFX_MSG_MAP
  1804. END_MESSAGE_MAP()
  1805. /*!--------------------------------------------------------------------------
  1806. CNewRtrWizFinishPageBase::OnSetActive
  1807. -
  1808. Author: KennT
  1809. ---------------------------------------------------------------------------*/
  1810. static DWORD s_rgServerNameId[] =
  1811. {
  1812. IDC_NEWWIZ_TEXT_SERVER_NAME,
  1813. IDC_NEWWIZ_TEXT_SERVER_NAME_2,
  1814. 0
  1815. };
  1816. static DWORD s_rgInterfaceId[] =
  1817. {
  1818. IDC_NEWWIZ_TEXT_INTERFACE_1, IDS_RTRWIZ_INTERFACE_NAME_1,
  1819. IDC_NEWWIZ_TEXT_INTERFACE_2, IDS_RTRWIZ_INTERFACE_2,
  1820. 0,0
  1821. };
  1822. /*!--------------------------------------------------------------------------
  1823. CNewRtrWizFinishPageBase::OnInitDialog
  1824. -
  1825. Author: KennT
  1826. ---------------------------------------------------------------------------*/
  1827. BOOL CNewRtrWizFinishPageBase::OnInitDialog()
  1828. {
  1829. CString st, stBase;
  1830. CNewRtrWizPageBase::OnInitDialog();
  1831. // If there is a control that wants a server name, replace it
  1832. for (int i=0; s_rgServerNameId[i]; i++)
  1833. {
  1834. if (GetDlgItem(s_rgServerNameId[i]))
  1835. {
  1836. GetDlgItemText(s_rgServerNameId[i], stBase);
  1837. st.Format((LPCTSTR) stBase,
  1838. (LPCTSTR) m_pRtrWizData->m_stServerName);
  1839. SetDlgItemText(s_rgServerNameId[i], st);
  1840. }
  1841. }
  1842. if (GetDlgItem(IDC_NEWWIZ_TEXT_ERROR))
  1843. {
  1844. TCHAR szErr[2048];
  1845. Assert(!FHrOK(m_pRtrWizData->m_hrDDError));
  1846. FormatRasError(m_pRtrWizData->m_hrDDError, szErr, DimensionOf(szErr));
  1847. GetDlgItemText(IDC_NEWWIZ_TEXT_ERROR, stBase);
  1848. st.Format((LPCTSTR) stBase,
  1849. szErr);
  1850. SetDlgItemText(IDC_NEWWIZ_TEXT_ERROR, (LPCTSTR) st);
  1851. }
  1852. return TRUE;
  1853. }
  1854. /*!--------------------------------------------------------------------------
  1855. CNewRtrWizFinishPageBase::OnSetActive
  1856. -
  1857. Author: KennT
  1858. ---------------------------------------------------------------------------*/
  1859. BOOL CNewRtrWizFinishPageBase::OnSetActive()
  1860. {
  1861. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  1862. DWORD i;
  1863. CString st;
  1864. CString stIfName;
  1865. RtrWizInterface * pRtrWizIf = NULL;
  1866. // Handle support for displaying the interface name on the
  1867. // finish page. We need to do it in the OnSetActive() rather
  1868. // than the OnInitDialog() since the interface chosen can change.
  1869. // Try to find the inteface name
  1870. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPublicInterfaceId,
  1871. pRtrWizIf);
  1872. if (pRtrWizIf)
  1873. stIfName = pRtrWizIf->m_stName;
  1874. else
  1875. {
  1876. // This may be the dd interface case. If we are creating
  1877. // a DD interface the name will never have been added to the
  1878. // interface map.
  1879. stIfName = m_pRtrWizData->m_stPublicInterfaceId;
  1880. }
  1881. for (i=0; s_rgInterfaceId[i] != 0; i+=2)
  1882. {
  1883. if (GetDlgItem(s_rgInterfaceId[i]))
  1884. {
  1885. st.Format(s_rgInterfaceId[i+1], (LPCTSTR) stIfName);
  1886. SetDlgItemText(s_rgInterfaceId[i], st);
  1887. }
  1888. }
  1889. return CNewRtrWizPageBase::OnSetActive();
  1890. }
  1891. /*!--------------------------------------------------------------------------
  1892. CNewRtrWizFinishPageBase::OnWizardFinish
  1893. -
  1894. Author: KennT
  1895. ---------------------------------------------------------------------------*/
  1896. BOOL CNewRtrWizFinishPageBase::OnWizardFinish()
  1897. {
  1898. m_pRtrWizData->m_SaveFlag = m_SaveFlag;
  1899. // If there is a help button and it is not checked,
  1900. // then do not bring up the help.
  1901. if (GetDlgItem(IDC_NEWWIZ_CHK_HELP) &&
  1902. !IsDlgButtonChecked(IDC_NEWWIZ_CHK_HELP))
  1903. m_pRtrWizData->m_HelpFlag = HelpFlag_Nothing;
  1904. else
  1905. m_pRtrWizData->m_HelpFlag = m_HelpFlag;
  1906. return CNewRtrWizPageBase::OnWizardFinish();
  1907. }
  1908. /////////////////////////////////////////////////////////////////////////////
  1909. //
  1910. // CNewRtrWiz holder
  1911. //
  1912. /////////////////////////////////////////////////////////////////////////////
  1913. CNewRtrWiz::CNewRtrWiz(
  1914. ITFSNode * pNode,
  1915. IRouterInfo * pRouter,
  1916. IComponentData * pComponentData,
  1917. ITFSComponentData * pTFSCompData,
  1918. LPCTSTR pszSheetName
  1919. ) :
  1920. CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  1921. {
  1922. //ASSERT(pFolderNode == GetContainerNode());
  1923. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  1924. Assert(pTFSCompData != NULL);
  1925. m_spTFSCompData.Set(pTFSCompData);
  1926. m_bWiz97 = TRUE;
  1927. m_spRouter.Set(pRouter);
  1928. }
  1929. CNewRtrWiz::~CNewRtrWiz()
  1930. {
  1931. POSITION pos;
  1932. CNewRtrWizPageBase *pPageBase;
  1933. pos = m_pagelist.GetHeadPosition();
  1934. while (pos)
  1935. {
  1936. pPageBase = m_pagelist.GetNext(pos);
  1937. RemovePageFromList(static_cast<CPropertyPageBase *>(pPageBase), FALSE);
  1938. }
  1939. m_pagelist.RemoveAll();
  1940. }
  1941. /*!--------------------------------------------------------------------------
  1942. CNewRtrWiz::Init
  1943. -
  1944. Author: KennT
  1945. ---------------------------------------------------------------------------*/
  1946. HRESULT CNewRtrWiz::Init(LPCTSTR pServerName)
  1947. {
  1948. HRESULT hr = hrOK;
  1949. POSITION pos;
  1950. CNewRtrWizPageBase *pPageBase;
  1951. // Setup the list of pages
  1952. m_pagelist.AddTail(&m_pageWelcome);
  1953. m_pagelist.AddTail(&m_pageCommonConfig);
  1954. m_pagelist.AddTail(&m_pageNatFinishSConflict);
  1955. m_pagelist.AddTail(&m_pageNatFinishSConflictNonLocal);
  1956. m_pagelist.AddTail(&m_pageNatFinishAConflict);
  1957. m_pagelist.AddTail(&m_pageNatFinishAConflictNonLocal);
  1958. m_pagelist.AddTail(&m_pageNatFinishNoIP);
  1959. m_pagelist.AddTail(&m_pageNatFinishNoIPNonLocal);
  1960. m_pagelist.AddTail(&m_pageNatChoice);
  1961. m_pagelist.AddTail(&m_pageNatSelectPublic);
  1962. m_pagelist.AddTail(&m_pageNatSelectPrivate);
  1963. m_pagelist.AddTail(&m_pageNatFinishAdvancedNoNICs);
  1964. m_pagelist.AddTail(&m_pageNatDHCPDNS);
  1965. m_pagelist.AddTail(&m_pageNatDHCPWarning);
  1966. m_pagelist.AddTail(&m_pageNatDDWarning);
  1967. m_pagelist.AddTail(&m_pageNatFinish);
  1968. m_pagelist.AddTail(&m_pageNatFinishExternal);
  1969. m_pagelist.AddTail(&m_pageNatFinishDDError);
  1970. m_pagelist.AddTail(&m_pageRasChoice);
  1971. m_pagelist.AddTail(&m_pageRasFinishNeedProtocols);
  1972. m_pagelist.AddTail(&m_pageRasFinishNeedProtocolsNonLocal);
  1973. m_pagelist.AddTail(&m_pageRasProtocols);
  1974. //m_pagelist.AddTail(&m_pageRasAppletalk);
  1975. m_pagelist.AddTail(&m_pageRasNoNICs);
  1976. m_pagelist.AddTail(&m_pageRasFinishNoNICs);
  1977. m_pagelist.AddTail(&m_pageRasNetwork);
  1978. m_pagelist.AddTail(&m_pageRasAddressing);
  1979. m_pagelist.AddTail(&m_pageRasAddressingNoNICs);
  1980. m_pagelist.AddTail(&m_pageRasAddressPool);
  1981. m_pagelist.AddTail(&m_pageRasRadius);
  1982. m_pagelist.AddTail(&m_pageRasRadiusConfig);
  1983. m_pagelist.AddTail(&m_pageRasFinishAdvanced);
  1984. m_pagelist.AddTail(&m_pageVpnFinishNoNICs);
  1985. m_pagelist.AddTail(&m_pageVpnFinishNoIP);
  1986. m_pagelist.AddTail(&m_pageVpnFinishNoIPNonLocal);
  1987. m_pagelist.AddTail(&m_pageVpnProtocols);
  1988. m_pagelist.AddTail(&m_pageVpnFinishNeedProtocols);
  1989. m_pagelist.AddTail(&m_pageVpnFinishNeedProtocolsNonLocal);
  1990. //m_pagelist.AddTail(&m_pageVpnAppletalk);
  1991. m_pagelist.AddTail(&m_pageVpnSelectPublic);
  1992. m_pagelist.AddTail(&m_pageVpnSelectPrivate);
  1993. m_pagelist.AddTail(&m_pageVpnAddressing);
  1994. m_pagelist.AddTail(&m_pageVpnAddressPool);
  1995. m_pagelist.AddTail(&m_pageVpnRadius);
  1996. m_pagelist.AddTail(&m_pageVpnRadiusConfig);
  1997. m_pagelist.AddTail(&m_pageVpnFinishAdvanced);
  1998. m_pagelist.AddTail(&m_pageRouterProtocols);
  1999. m_pagelist.AddTail(&m_pageRouterFinishNeedProtocols);
  2000. m_pagelist.AddTail(&m_pageRouterFinishNeedProtocolsNonLocal);
  2001. m_pagelist.AddTail(&m_pageRouterUseDD);
  2002. m_pagelist.AddTail(&m_pageRouterAddressing);
  2003. m_pagelist.AddTail(&m_pageRouterAddressPool);
  2004. m_pagelist.AddTail(&m_pageRouterFinish);
  2005. m_pagelist.AddTail(&m_pageRouterFinishDD);
  2006. m_pagelist.AddTail(&m_pageManualFinish);
  2007. m_RtrWizData.Init(pServerName, m_spRouter);
  2008. m_RtrWizData.m_stServerName = pServerName;
  2009. // Initialize all of the pages
  2010. pos = m_pagelist.GetHeadPosition();
  2011. while (pos)
  2012. {
  2013. pPageBase = m_pagelist.GetNext(pos);
  2014. pPageBase->Init(&m_RtrWizData, this);
  2015. }
  2016. // Add all of the pages to the property sheet
  2017. pos = m_pagelist.GetHeadPosition();
  2018. while (pos)
  2019. {
  2020. pPageBase = m_pagelist.GetNext(pos);
  2021. AddPageToList(static_cast<CPropertyPageBase *>(pPageBase));
  2022. }
  2023. return hr;
  2024. }
  2025. /*!--------------------------------------------------------------------------
  2026. CNewRtrWiz::OnFinish
  2027. Called from the OnWizardFinish
  2028. Author: KennT
  2029. ---------------------------------------------------------------------------*/
  2030. DWORD CNewRtrWiz::OnFinish()
  2031. {
  2032. DWORD dwError = ERROR_SUCCESS;
  2033. RtrWizInterface * pRtrWizIf = NULL;
  2034. TCHAR szBuffer[1024];
  2035. CString st;
  2036. LPCTSTR pszHelpString = NULL;
  2037. STARTUPINFO si;
  2038. PROCESS_INFORMATION pi;
  2039. #if defined(DEBUG) && defined(kennt)
  2040. if (m_RtrWizData.m_SaveFlag != SaveFlag_Advanced)
  2041. st += _T("NO configuration change required\n\n");
  2042. // For now, just display the test parameter output
  2043. switch (m_RtrWizData.m_wizType)
  2044. {
  2045. case NewRtrWizData::WizardRouterType_NAT:
  2046. st += _T("NAT\n");
  2047. break;
  2048. case NewRtrWizData::WizardRouterType_RAS:
  2049. st += _T("RAS\n");
  2050. break;
  2051. case NewRtrWizData::WizardRouterType_VPN:
  2052. st += _T("VPN\n");
  2053. break;
  2054. case NewRtrWizData::WizardRouterType_Router:
  2055. st += _T("Router\n");
  2056. break;
  2057. case NewRtrWizData::WizardRouterType_Manual:
  2058. st += _T("Manual\n");
  2059. break;
  2060. }
  2061. if (m_RtrWizData.m_fAdvanced)
  2062. st += _T("Advanced path\n");
  2063. else
  2064. st += _T("Simple path\n");
  2065. if (m_RtrWizData.m_fNeedMoreProtocols)
  2066. st += _T("Need to install more protocols\n");
  2067. if (m_RtrWizData.m_fCreateDD)
  2068. st += _T("Need to create a DD interface\n");
  2069. st += _T("Public interface : ");
  2070. m_RtrWizData.m_ifMap.Lookup(m_RtrWizData.m_stPublicInterfaceId, pRtrWizIf);
  2071. if (pRtrWizIf)
  2072. st += pRtrWizIf->m_stName;
  2073. st += _T("\n");
  2074. st += _T("Private interface : ");
  2075. m_RtrWizData.m_ifMap.Lookup(m_RtrWizData.m_stPrivateInterfaceId, pRtrWizIf);
  2076. if (pRtrWizIf)
  2077. st += pRtrWizIf->m_stName;
  2078. st += _T("\n");
  2079. if (m_RtrWizData.m_wizType == NewRtrWizData::WizardRouterType_NAT)
  2080. {
  2081. if (m_RtrWizData.m_fNatUseSimpleServers)
  2082. st += _T("NAT - use simple DHCP and DNS\n");
  2083. else
  2084. st += _T("NAT - use external DHCP and DNS\n");
  2085. }
  2086. if (m_RtrWizData.m_fWillBeInDomain)
  2087. st += _T("Will be in a domain\n");
  2088. if (m_RtrWizData.m_fNoNicsAreOk)
  2089. st += _T("No NICs is ok\n");
  2090. if (m_RtrWizData.m_fUseIpxType20Broadcasts)
  2091. st += _T("IPX should deliver Type20 broadcasts\n");
  2092. if (m_RtrWizData.m_fAppletalkUseNoAuth)
  2093. st += _T("Use unauthenticated access\n");
  2094. if (m_RtrWizData.m_fUseDHCP)
  2095. st += _T("Use DHCP for addressing\n");
  2096. else
  2097. st += _T("Use Static pools for addressing\n");
  2098. if (m_RtrWizData.m_fUseRadius)
  2099. {
  2100. st += _T("Use RADIUS\n");
  2101. st += _T("Server 1 : ");
  2102. st += m_RtrWizData.m_stRadius1;
  2103. st += _T("\n");
  2104. st += _T("Server 2 : ");
  2105. st += m_RtrWizData.m_stRadius2;
  2106. st += _T("\n");
  2107. }
  2108. if (m_RtrWizData.m_fTest)
  2109. {
  2110. if (AfxMessageBox(st, MB_OKCANCEL) == IDCANCEL)
  2111. return 0;
  2112. }
  2113. #endif
  2114. // else continue on, saving the real data
  2115. if (m_RtrWizData.m_SaveFlag == SaveFlag_Simple)
  2116. {
  2117. ::ZeroMemory(&si, sizeof(STARTUPINFO));
  2118. si.cb = sizeof(STARTUPINFO);
  2119. si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
  2120. si.wShowWindow = SW_SHOW;
  2121. ::ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
  2122. ExpandEnvironmentStrings(s_szConnectionUICommandLine,
  2123. szBuffer,
  2124. DimensionOf(szBuffer));
  2125. ::CreateProcess(NULL, // ptr to name of executable
  2126. szBuffer, // pointer to command line string
  2127. NULL, // process security attributes
  2128. NULL, // thread security attributes
  2129. FALSE, // handle inheritance flag
  2130. CREATE_NEW_CONSOLE,// creation flags
  2131. NULL, // ptr to new environment block
  2132. NULL, // ptr to current directory name
  2133. &si,
  2134. &pi);
  2135. ::CloseHandle(pi.hProcess);
  2136. ::CloseHandle(pi.hThread);
  2137. }
  2138. else if (m_RtrWizData.m_SaveFlag == SaveFlag_Advanced)
  2139. {
  2140. // Ok, we're done!
  2141. if (!m_RtrWizData.m_fTest)
  2142. {
  2143. // Get the owner window (i.e. the page)
  2144. // --------------------------------------------------------
  2145. HWND hWndOwner = PropSheet_GetCurrentPageHwnd(m_hSheetWindow);
  2146. m_RtrWizData.FinishTheDamnWizard(hWndOwner, m_spRouter);
  2147. }
  2148. }
  2149. if (m_RtrWizData.m_HelpFlag != HelpFlag_Nothing)
  2150. {
  2151. switch (m_RtrWizData.m_HelpFlag)
  2152. {
  2153. case HelpFlag_Nothing:
  2154. break;
  2155. case HelpFlag_ICS:
  2156. pszHelpString = s_szHowToAddICS;
  2157. break;
  2158. case HelpFlag_AddIp:
  2159. case HelpFlag_AddProtocol:
  2160. pszHelpString = s_szHowToAddAProtocol;
  2161. break;
  2162. case HelpFlag_InboundConnections:
  2163. pszHelpString = s_szHowToAddInboundConnections;
  2164. break;
  2165. case HelpFlag_GeneralNAT:
  2166. pszHelpString = s_szGeneralNATHelp;
  2167. break;
  2168. case HelpFlag_GeneralRAS:
  2169. pszHelpString = s_szGeneralRASHelp;
  2170. break;
  2171. default:
  2172. Panic0("Unknown help flag specified!");
  2173. break;
  2174. }
  2175. LaunchHelpTopic(pszHelpString);
  2176. }
  2177. return dwError;
  2178. }
  2179. /*---------------------------------------------------------------------------
  2180. CNewWizTestParams Implementation
  2181. ---------------------------------------------------------------------------*/
  2182. BEGIN_MESSAGE_MAP(CNewWizTestParams, CBaseDialog)
  2183. //{{AFX_MSG_MAP(CNewWizTestParams)
  2184. //}}AFX_MSG_MAP
  2185. END_MESSAGE_MAP()
  2186. BOOL CNewWizTestParams::OnInitDialog()
  2187. {
  2188. CBaseDialog::OnInitDialog();
  2189. CheckDlgButton(IDC_NEWWIZ_TEST_LOCAL, m_pWizData->s_fIsLocalMachine);
  2190. CheckDlgButton(IDC_NEWWIZ_TEST_USE_IP, m_pWizData->s_fIpInstalled);
  2191. CheckDlgButton(IDC_NEWWIZ_TEST_USE_IPX, m_pWizData->s_fIpxInstalled);
  2192. CheckDlgButton(IDC_NEWWIZ_TEST_USE_ATLK, m_pWizData->s_fAppletalkInstalled);
  2193. CheckDlgButton(IDC_NEWWIZ_TEST_DNS, m_pWizData->s_fIsDNSRunningOnPrivateInterface);
  2194. CheckDlgButton(IDC_NEWWIZ_TEST_DHCP, m_pWizData->s_fIsDHCPRunningOnPrivateInterface);
  2195. CheckDlgButton(IDC_NEWWIZ_TEST_DOMAIN, m_pWizData->s_fIsMemberOfDomain);
  2196. CheckDlgButton(IDC_NEWWIZ_TEST_SHAREDACCESS, m_pWizData->s_fIsSharedAccessRunningOnServer);
  2197. SetDlgItemInt(IDC_NEWWIZ_TEST_EDIT_NUMNICS, m_pWizData->s_dwNumberOfNICs);
  2198. return TRUE;
  2199. }
  2200. void CNewWizTestParams::OnOK()
  2201. {
  2202. m_pWizData->s_fIsLocalMachine = IsDlgButtonChecked(IDC_NEWWIZ_TEST_LOCAL);
  2203. m_pWizData->s_fIpInstalled = IsDlgButtonChecked(IDC_NEWWIZ_TEST_USE_IP);
  2204. m_pWizData->s_fIpxInstalled = IsDlgButtonChecked(IDC_NEWWIZ_TEST_USE_IPX);
  2205. m_pWizData->s_fAppletalkInstalled = IsDlgButtonChecked(IDC_NEWWIZ_TEST_USE_ATLK);
  2206. m_pWizData->s_fIsDNSRunningOnPrivateInterface = IsDlgButtonChecked(IDC_NEWWIZ_TEST_DNS);
  2207. m_pWizData->s_fIsDHCPRunningOnPrivateInterface = IsDlgButtonChecked(IDC_NEWWIZ_TEST_DHCP);
  2208. m_pWizData->s_fIsMemberOfDomain = IsDlgButtonChecked(IDC_NEWWIZ_TEST_DOMAIN);
  2209. m_pWizData->s_dwNumberOfNICs = GetDlgItemInt(IDC_NEWWIZ_TEST_EDIT_NUMNICS);
  2210. m_pWizData->s_fIsSharedAccessRunningOnServer = IsDlgButtonChecked(IDC_NEWWIZ_TEST_SHAREDACCESS);
  2211. CBaseDialog::OnOK();
  2212. }
  2213. /*---------------------------------------------------------------------------
  2214. CNewRtrWizWelcome Implementation
  2215. ---------------------------------------------------------------------------*/
  2216. CNewRtrWizWelcome::CNewRtrWizWelcome() :
  2217. CNewRtrWizPageBase(CNewRtrWizWelcome::IDD, CNewRtrWizPageBase::Start)
  2218. {
  2219. InitWiz97(TRUE, 0, 0);
  2220. }
  2221. BEGIN_MESSAGE_MAP(CNewRtrWizWelcome, CNewRtrWizPageBase)
  2222. END_MESSAGE_MAP()
  2223. /*---------------------------------------------------------------------------
  2224. CNewRtrWizCommonConfig Implementation
  2225. ---------------------------------------------------------------------------*/
  2226. CNewRtrWizCommonConfig::CNewRtrWizCommonConfig() :
  2227. CNewRtrWizPageBase(CNewRtrWizCommonConfig::IDD, CNewRtrWizPageBase::Middle)
  2228. {
  2229. InitWiz97(FALSE,
  2230. IDS_NEWWIZ_COMMONCONFIG_TITLE,
  2231. IDS_NEWWIZ_COMMONCONFIG_SUBTITLE);
  2232. }
  2233. BEGIN_MESSAGE_MAP(CNewRtrWizCommonConfig, CNewRtrWizPageBase)
  2234. END_MESSAGE_MAP()
  2235. // This list of IDs will have their controls made bold.
  2236. const DWORD s_rgCommonConfigOptionIds[] =
  2237. {
  2238. IDC_NEWWIZ_CONFIG_BTN_NAT,
  2239. IDC_NEWWIZ_CONFIG_BTN_RAS,
  2240. IDC_NEWWIZ_CONFIG_BTN_VPN,
  2241. IDC_NEWWIZ_CONFIG_BTN_ROUTER,
  2242. IDC_NEWWIZ_CONFIG_BTN_MANUAL,
  2243. 0
  2244. };
  2245. BOOL CNewRtrWizCommonConfig::OnInitDialog()
  2246. {
  2247. Assert(m_pRtrWizData);
  2248. UINT idSelection;
  2249. LOGFONT LogFont;
  2250. CFont * pOldFont;
  2251. CNewRtrWizPageBase::OnInitDialog();
  2252. // Create a bold text font for the options
  2253. pOldFont = GetDlgItem(s_rgCommonConfigOptionIds[0])->GetFont();
  2254. pOldFont->GetLogFont(&LogFont);
  2255. LogFont.lfWeight = 700; // make this a bold font
  2256. m_boldFont.CreateFontIndirect(&LogFont);
  2257. // Set all of the options to use the bold font
  2258. for (int i=0; s_rgCommonConfigOptionIds[i]; i++)
  2259. {
  2260. GetDlgItem(s_rgCommonConfigOptionIds[i])->SetFont(&m_boldFont);
  2261. }
  2262. // Need to set the proper value
  2263. switch (m_pRtrWizData->m_wizType)
  2264. {
  2265. case NewRtrWizData::WizardRouterType_NAT:
  2266. idSelection = IDC_NEWWIZ_CONFIG_BTN_NAT;
  2267. break;
  2268. case NewRtrWizData::WizardRouterType_RAS:
  2269. idSelection = IDC_NEWWIZ_CONFIG_BTN_RAS;
  2270. break;
  2271. case NewRtrWizData::WizardRouterType_VPN:
  2272. idSelection = IDC_NEWWIZ_CONFIG_BTN_VPN;
  2273. break;
  2274. case NewRtrWizData::WizardRouterType_Router:
  2275. idSelection = IDC_NEWWIZ_CONFIG_BTN_ROUTER;
  2276. break;
  2277. case NewRtrWizData::WizardRouterType_Manual:
  2278. idSelection = IDC_NEWWIZ_CONFIG_BTN_MANUAL;
  2279. break;
  2280. default:
  2281. Panic1("Unknown Wizard Router Type : %d",
  2282. m_pRtrWizData->m_wizType);
  2283. idSelection = IDC_NEWWIZ_CONFIG_BTN_NAT;
  2284. break;
  2285. }
  2286. CheckRadioButton(IDC_NEWWIZ_CONFIG_BTN_NAT,
  2287. IDC_NEWWIZ_CONFIG_BTN_ROUTER,
  2288. idSelection);
  2289. return TRUE; // return TRUE unless you set the focus to a control
  2290. // EXCEPTION: OCX Property Pages should return FALSE
  2291. }
  2292. HRESULT CNewRtrWizCommonConfig::OnSavePage()
  2293. {
  2294. // Record the change
  2295. if (IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_NAT))
  2296. {
  2297. m_pRtrWizData->m_wizType = NewRtrWizData::WizardRouterType_NAT;
  2298. }
  2299. else if (IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_RAS))
  2300. m_pRtrWizData->m_wizType = NewRtrWizData::WizardRouterType_RAS;
  2301. else if (IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_VPN))
  2302. m_pRtrWizData->m_wizType = NewRtrWizData::WizardRouterType_VPN;
  2303. else if (IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_MANUAL))
  2304. m_pRtrWizData->m_wizType = NewRtrWizData::WizardRouterType_Manual;
  2305. else
  2306. {
  2307. Assert(IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_ROUTER));
  2308. m_pRtrWizData->m_wizType = NewRtrWizData::WizardRouterType_Router;
  2309. }
  2310. return hrOK;
  2311. }
  2312. /*---------------------------------------------------------------------------
  2313. CNewRtrWizNatFinishSConflict Implementation
  2314. ---------------------------------------------------------------------------*/
  2315. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishSConflict,
  2316. SaveFlag_DoNothing,
  2317. HelpFlag_Nothing);
  2318. /*---------------------------------------------------------------------------
  2319. CNewRtrWizNatFinishSConflictNonLocal Implementation
  2320. ---------------------------------------------------------------------------*/
  2321. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishSConflictNonLocal,
  2322. SaveFlag_DoNothing,
  2323. HelpFlag_Nothing);
  2324. /*---------------------------------------------------------------------------
  2325. CNewRtrWizNatFinishAConflict Implementation
  2326. ---------------------------------------------------------------------------*/
  2327. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishAConflict,
  2328. SaveFlag_DoNothing,
  2329. HelpFlag_Nothing);
  2330. /*---------------------------------------------------------------------------
  2331. CNewRtrWizNatFinishAConflictNonLocal Implementation
  2332. ---------------------------------------------------------------------------*/
  2333. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishAConflictNonLocal,
  2334. SaveFlag_DoNothing,
  2335. HelpFlag_Nothing);
  2336. /*---------------------------------------------------------------------------
  2337. CNewRtrWizNatFinishNoIP Implementation
  2338. ---------------------------------------------------------------------------*/
  2339. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishNoIP,
  2340. SaveFlag_DoNothing,
  2341. HelpFlag_AddIp);
  2342. /*---------------------------------------------------------------------------
  2343. CNewRtrWizNatFinishNoIPNonLocal Implementation
  2344. ---------------------------------------------------------------------------*/
  2345. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishNoIPNonLocal,
  2346. SaveFlag_DoNothing,
  2347. HelpFlag_Nothing);
  2348. /*---------------------------------------------------------------------------
  2349. CNewRtrWizNatChoice Implementation
  2350. ---------------------------------------------------------------------------*/
  2351. CNewRtrWizNatChoice::CNewRtrWizNatChoice() :
  2352. CNewRtrWizPageBase(CNewRtrWizNatChoice::IDD, CNewRtrWizPageBase::Middle)
  2353. {
  2354. InitWiz97(FALSE,
  2355. IDS_NEWWIZ_NAT_CHOICE_TITLE,
  2356. IDS_NEWWIZ_NAT_CHOICE_SUBTITLE);
  2357. }
  2358. BEGIN_MESSAGE_MAP(CNewRtrWizNatChoice, CNewRtrWizPageBase)
  2359. END_MESSAGE_MAP()
  2360. /*!--------------------------------------------------------------------------
  2361. CNewRtrWizNatChoice::OnInitDialog
  2362. -
  2363. Author: KennT
  2364. ---------------------------------------------------------------------------*/
  2365. BOOL CNewRtrWizNatChoice::OnInitDialog()
  2366. {
  2367. DWORD dwNICs;
  2368. UINT uSelection;
  2369. OSVERSIONINFOEX osInfo;
  2370. CNewRtrWizPageBase::OnInitDialog();
  2371. osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  2372. ::GetVersionEx((POSVERSIONINFO) &osInfo);
  2373. if ((osInfo.wProductType == VER_NT_SERVER) &&
  2374. (osInfo.wSuiteMask &
  2375. (VER_SUITE_ENTERPRISE | VER_SUITE_DATACENTER)))
  2376. {
  2377. GetDlgItem(IDC_NEWWIZ_BTN_SIMPLE)->EnableWindow(FALSE);
  2378. GetDlgItem(IDC_ICS_TEXT)->EnableWindow(FALSE);
  2379. GetDlgItem(IDC_NEWWIZ_NO_ICS)->ShowWindow(SW_SHOW);
  2380. uSelection = IDC_NEWWIZ_BTN_ADVANCED;
  2381. }
  2382. else
  2383. {
  2384. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  2385. if (dwNICs == 1)
  2386. uSelection = IDC_NEWWIZ_BTN_SIMPLE;
  2387. else
  2388. uSelection = IDC_NEWWIZ_BTN_ADVANCED;
  2389. }
  2390. CheckRadioButton(IDC_NEWWIZ_BTN_SIMPLE,
  2391. IDC_NEWWIZ_BTN_ADVANCED,
  2392. uSelection);
  2393. return TRUE;
  2394. }
  2395. HRESULT CNewRtrWizNatChoice::OnSavePage()
  2396. {
  2397. // Record the data change
  2398. if (IsDlgButtonChecked(IDC_NEWWIZ_BTN_SIMPLE))
  2399. m_pRtrWizData->m_fAdvanced = FALSE;
  2400. else
  2401. {
  2402. Assert(IsDlgButtonChecked(IDC_NEWWIZ_BTN_ADVANCED));
  2403. m_pRtrWizData->m_fAdvanced = TRUE;
  2404. }
  2405. return hrOK;
  2406. }
  2407. /*---------------------------------------------------------------------------
  2408. CNewRtrWizNatSelectPublic implementation
  2409. ---------------------------------------------------------------------------*/
  2410. CNewRtrWizNatSelectPublic::CNewRtrWizNatSelectPublic() :
  2411. CNewRtrWizPageBase(CNewRtrWizNatSelectPublic::IDD, CNewRtrWizPageBase::Middle)
  2412. {
  2413. InitWiz97(FALSE,
  2414. IDS_NEWWIZ_NAT_A_PUBLIC_TITLE,
  2415. IDS_NEWWIZ_NAT_A_PUBLIC_SUBTITLE);
  2416. }
  2417. void CNewRtrWizNatSelectPublic::DoDataExchange(CDataExchange *pDX)
  2418. {
  2419. CNewRtrWizPageBase::DoDataExchange(pDX);
  2420. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  2421. }
  2422. BEGIN_MESSAGE_MAP(CNewRtrWizNatSelectPublic, CNewRtrWizPageBase)
  2423. ON_BN_CLICKED(IDC_NEWWIZ_BTN_NEW, OnBtnClicked)
  2424. ON_BN_CLICKED(IDC_NEWWIZ_BTN_EXISTING, OnBtnClicked)
  2425. END_MESSAGE_MAP()
  2426. /*!--------------------------------------------------------------------------
  2427. CNewRtrWizNatSelectPublic::OnInitDialog
  2428. -
  2429. Author: KennT
  2430. ---------------------------------------------------------------------------*/
  2431. BOOL CNewRtrWizNatSelectPublic::OnInitDialog()
  2432. {
  2433. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  2434. DWORD dwNICs;
  2435. UINT uSelection;
  2436. CNewRtrWizPageBase::OnInitDialog();
  2437. // Setup the dialog and add the NICs
  2438. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  2439. if (dwNICs == 0)
  2440. {
  2441. // Have to use new, there is no other choice.
  2442. CheckRadioButton(IDC_NEWWIZ_BTN_NEW, IDC_NEWWIZ_BTN_EXISTING,
  2443. IDC_NEWWIZ_BTN_NEW);
  2444. // There are no NICs, so just disable the entire listbox
  2445. MultiEnableWindow(GetSafeHwnd(),
  2446. FALSE,
  2447. IDC_NEWWIZ_LIST,
  2448. IDC_NEWWIZ_BTN_EXISTING,
  2449. 0);
  2450. }
  2451. else
  2452. {
  2453. // The default is to use an existing connection.
  2454. CheckRadioButton(IDC_NEWWIZ_BTN_NEW, IDC_NEWWIZ_BTN_EXISTING,
  2455. IDC_NEWWIZ_BTN_EXISTING);
  2456. InitializeInterfaceListControl(NULL,
  2457. &m_listCtrl,
  2458. NULL,
  2459. 0,
  2460. m_pRtrWizData);
  2461. RefreshInterfaceListControl(NULL,
  2462. &m_listCtrl,
  2463. NULL,
  2464. 0,
  2465. m_pRtrWizData);
  2466. OnBtnClicked();
  2467. }
  2468. return TRUE;
  2469. }
  2470. HRESULT CNewRtrWizNatSelectPublic::OnSavePage()
  2471. {
  2472. if (IsDlgButtonChecked(IDC_NEWWIZ_BTN_NEW))
  2473. {
  2474. m_pRtrWizData->m_fCreateDD = TRUE;
  2475. m_pRtrWizData->m_stPublicInterfaceId.Empty();
  2476. }
  2477. else
  2478. {
  2479. INT iSel;
  2480. // Check to see that we actually selected an item
  2481. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  2482. if (iSel == -1)
  2483. {
  2484. // We did not select an item
  2485. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  2486. return E_FAIL;
  2487. }
  2488. m_pRtrWizData->m_fCreateDD = FALSE;
  2489. m_pRtrWizData->m_stPublicInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  2490. }
  2491. return hrOK;
  2492. }
  2493. void CNewRtrWizNatSelectPublic::OnBtnClicked()
  2494. {
  2495. MultiEnableWindow(GetSafeHwnd(),
  2496. IsDlgButtonChecked(IDC_NEWWIZ_BTN_EXISTING),
  2497. IDC_NEWWIZ_LIST,
  2498. 0);
  2499. // If the use an existing button is checked,
  2500. // auto-select the first item.
  2501. if (IsDlgButtonChecked(IDC_NEWWIZ_BTN_EXISTING))
  2502. m_listCtrl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED );
  2503. }
  2504. /*---------------------------------------------------------------------------
  2505. CNewRtrWizNatFinishAdvancedNoNICs
  2506. ---------------------------------------------------------------------------*/
  2507. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishAdvancedNoNICs,
  2508. SaveFlag_DoNothing,
  2509. HelpFlag_Nothing);
  2510. /*---------------------------------------------------------------------------
  2511. CNewRtrWizNatSelectPrivate
  2512. ---------------------------------------------------------------------------*/
  2513. CNewRtrWizNatSelectPrivate::CNewRtrWizNatSelectPrivate() :
  2514. CNewRtrWizPageBase(CNewRtrWizNatSelectPrivate::IDD, CNewRtrWizPageBase::Middle)
  2515. {
  2516. InitWiz97(FALSE,
  2517. IDS_NEWWIZ_NAT_A_PRIVATE_TITLE,
  2518. IDS_NEWWIZ_NAT_A_PRIVATE_SUBTITLE);
  2519. }
  2520. void CNewRtrWizNatSelectPrivate::DoDataExchange(CDataExchange *pDX)
  2521. {
  2522. CNewRtrWizPageBase::DoDataExchange(pDX);
  2523. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  2524. }
  2525. BEGIN_MESSAGE_MAP(CNewRtrWizNatSelectPrivate, CNewRtrWizPageBase)
  2526. END_MESSAGE_MAP()
  2527. /*!--------------------------------------------------------------------------
  2528. CNewRtrWizNatSelectPrivate::OnInitDialog
  2529. -
  2530. Author: KennT
  2531. ---------------------------------------------------------------------------*/
  2532. BOOL CNewRtrWizNatSelectPrivate::OnInitDialog()
  2533. {
  2534. DWORD dwNICs;
  2535. CNewRtrWizPageBase::OnInitDialog();
  2536. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  2537. InitializeInterfaceListControl(NULL,
  2538. &m_listCtrl,
  2539. NULL,
  2540. 0,
  2541. m_pRtrWizData);
  2542. return TRUE;
  2543. }
  2544. BOOL CNewRtrWizNatSelectPrivate::OnSetActive()
  2545. {
  2546. DWORD dwNICs;
  2547. int iSel = 0;
  2548. CNewRtrWizPageBase::OnSetActive();
  2549. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  2550. RefreshInterfaceListControl(NULL,
  2551. &m_listCtrl,
  2552. (LPCTSTR) m_pRtrWizData->m_stPublicInterfaceId,
  2553. 0,
  2554. m_pRtrWizData);
  2555. if (!m_pRtrWizData->m_stPrivateInterfaceId.IsEmpty())
  2556. {
  2557. // Try to reselect the previously selected NIC
  2558. LV_FINDINFO lvfi;
  2559. lvfi.flags = LVFI_PARTIAL | LVFI_STRING;
  2560. lvfi.psz = (LPCTSTR) m_pRtrWizData->m_stPrivateInterfaceId;
  2561. iSel = m_listCtrl.FindItem(&lvfi, -1);
  2562. if (iSel == -1)
  2563. iSel = 0;
  2564. }
  2565. m_listCtrl.SetItemState(iSel, LVIS_SELECTED, LVIS_SELECTED );
  2566. return TRUE;
  2567. }
  2568. HRESULT CNewRtrWizNatSelectPrivate::OnSavePage()
  2569. {
  2570. INT iSel;
  2571. // Check to see that we actually selected an item
  2572. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  2573. if (iSel == -1)
  2574. {
  2575. // We did not select an item
  2576. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  2577. return E_FAIL;
  2578. }
  2579. m_pRtrWizData->m_stPrivateInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  2580. return hrOK;
  2581. }
  2582. /*---------------------------------------------------------------------------
  2583. CNewRtrWizNatDHCPDNS
  2584. ---------------------------------------------------------------------------*/
  2585. CNewRtrWizNatDHCPDNS::CNewRtrWizNatDHCPDNS() :
  2586. CNewRtrWizPageBase(CNewRtrWizNatDHCPDNS::IDD, CNewRtrWizPageBase::Middle)
  2587. {
  2588. InitWiz97(FALSE,
  2589. IDS_NEWWIZ_NAT_A_DHCPDNS_TITLE,
  2590. IDS_NEWWIZ_NAT_A_DHCPDNS_SUBTITLE);
  2591. }
  2592. BEGIN_MESSAGE_MAP(CNewRtrWizNatDHCPDNS, CNewRtrWizPageBase)
  2593. END_MESSAGE_MAP()
  2594. BOOL CNewRtrWizNatDHCPDNS::OnInitDialog()
  2595. {
  2596. CheckRadioButton(IDC_NEWWIZ_NAT_USE_SIMPLE,
  2597. IDC_NEWWIZ_NAT_USE_EXTERNAL,
  2598. m_pRtrWizData->m_fNatUseSimpleServers ? IDC_NEWWIZ_NAT_USE_SIMPLE : IDC_NEWWIZ_NAT_USE_EXTERNAL);
  2599. return TRUE;
  2600. }
  2601. HRESULT CNewRtrWizNatDHCPDNS::OnSavePage()
  2602. {
  2603. m_pRtrWizData->m_fNatUseSimpleServers = IsDlgButtonChecked(IDC_NEWWIZ_NAT_USE_SIMPLE);
  2604. return hrOK;
  2605. }
  2606. /*---------------------------------------------------------------------------
  2607. CNewRtrWizNatDHCPWarning
  2608. ---------------------------------------------------------------------------*/
  2609. CNewRtrWizNatDHCPWarning::CNewRtrWizNatDHCPWarning() :
  2610. CNewRtrWizPageBase(CNewRtrWizNatDHCPWarning::IDD, CNewRtrWizPageBase::Middle)
  2611. {
  2612. InitWiz97(FALSE,
  2613. IDS_NEWWIZ_NAT_A_DHCP_WARNING_TITLE,
  2614. IDS_NEWWIZ_NAT_A_DHCP_WARNING_SUBTITLE);
  2615. }
  2616. BEGIN_MESSAGE_MAP(CNewRtrWizNatDHCPWarning, CNewRtrWizPageBase)
  2617. END_MESSAGE_MAP()
  2618. BOOL CNewRtrWizNatDHCPWarning::OnSetActive()
  2619. {
  2620. CNewRtrWizPageBase::OnSetActive();
  2621. RtrWizInterface * pRtrWizIf = NULL;
  2622. // Get the information for the private interface
  2623. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPrivateInterfaceId,
  2624. pRtrWizIf);
  2625. if (pRtrWizIf)
  2626. {
  2627. DWORD netAddress, netMask;
  2628. CString st;
  2629. // We have to calculate the beginning of the subnet
  2630. netAddress = INET_ADDR(pRtrWizIf->m_stIpAddress);
  2631. netMask = INET_ADDR(pRtrWizIf->m_stMask);
  2632. netAddress = netAddress & netMask;
  2633. st = INET_NTOA(netAddress);
  2634. // Now write out the subnet information for the page
  2635. SetDlgItemText(IDC_NEWWIZ_TEXT_SUBNET, st);
  2636. SetDlgItemText(IDC_NEWWIZ_TEXT_MASK, pRtrWizIf->m_stMask);
  2637. }
  2638. else
  2639. {
  2640. // An error! we do not have a private interface
  2641. // Just leave things blank
  2642. SetDlgItemText(IDC_NEWWIZ_TEXT_SUBNET, _T(""));
  2643. SetDlgItemText(IDC_NEWWIZ_TEXT_MASK, _T(""));
  2644. }
  2645. return TRUE;
  2646. }
  2647. /*---------------------------------------------------------------------------
  2648. CNewRtrWizNatDDWarning
  2649. ---------------------------------------------------------------------------*/
  2650. CNewRtrWizNatDDWarning::CNewRtrWizNatDDWarning() :
  2651. CNewRtrWizPageBase(CNewRtrWizNatDDWarning::IDD, CNewRtrWizPageBase::Middle)
  2652. {
  2653. InitWiz97(FALSE,
  2654. IDS_NEWWIZ_NAT_A_DD_WARNING_TITLE,
  2655. IDS_NEWWIZ_NAT_A_DD_WARNING_SUBTITLE);
  2656. }
  2657. BEGIN_MESSAGE_MAP(CNewRtrWizNatDDWarning, CNewRtrWizPageBase)
  2658. END_MESSAGE_MAP()
  2659. BOOL CNewRtrWizNatDDWarning::OnSetActive()
  2660. {
  2661. CNewRtrWizPageBase::OnSetActive();
  2662. // If we came back here from the DD error page, then
  2663. // we don't allow them to go anywhere else.
  2664. if (!FHrOK(m_pRtrWizData->m_hrDDError))
  2665. {
  2666. CancelToClose();
  2667. GetHolder()->SetWizardButtons(PSWIZB_NEXT);
  2668. }
  2669. return TRUE;
  2670. }
  2671. HRESULT CNewRtrWizNatDDWarning::OnSavePage()
  2672. {
  2673. HRESULT hr = hrOK;
  2674. CWaitCursor wait;
  2675. if (m_pRtrWizData->m_fTest)
  2676. return hr;
  2677. // Save the wizard data, the service will be started
  2678. OnWizardFinish();
  2679. // Ok, at this point, all of the changes have been committed
  2680. // so we can't go away or go back
  2681. CancelToClose();
  2682. GetHolder()->SetWizardButtons(PSWIZB_NEXT);
  2683. // Start the DD wizard
  2684. Assert(m_pRtrWizData->m_fCreateDD);
  2685. hr = CallRouterEntryDlg(GetSafeHwnd(),
  2686. m_pRtrWizData,
  2687. 0);
  2688. // We need to force the RouterInfo to reload it's information
  2689. // ----------------------------------------------------------------
  2690. if (m_pRtrWiz && m_pRtrWiz->m_spRouter)
  2691. {
  2692. m_pRtrWiz->m_spRouter->DoDisconnect();
  2693. m_pRtrWiz->m_spRouter->Unload();
  2694. m_pRtrWiz->m_spRouter->Load(m_pRtrWiz->m_spRouter->GetMachineName(), NULL);
  2695. }
  2696. if (FHrSucceeded(hr))
  2697. {
  2698. // If we're setting up NAT, we can now add IGMP/NAT because
  2699. // the dd interface will have been created.
  2700. // ----------------------------------------------------------------
  2701. if (m_pRtrWizData->m_wizType == NewRtrWizData::WizardRouterType_NAT)
  2702. {
  2703. // Setup the data structure for the next couple of functions
  2704. m_pRtrWizData->m_RtrConfigData.m_ipData.m_stPrivateAdapterGUID = m_pRtrWizData->m_stPrivateInterfaceId;
  2705. m_pRtrWizData->m_RtrConfigData.m_ipData.m_stPublicAdapterGUID = m_pRtrWizData->m_stPublicInterfaceId;
  2706. AddIGMPToNATServer(&m_pRtrWizData->m_RtrConfigData, m_pRtrWiz->m_spRouter);
  2707. AddNATToServer(m_pRtrWizData, &m_pRtrWizData->m_RtrConfigData, m_pRtrWiz->m_spRouter, m_pRtrWizData->m_fCreateDD, FALSE);
  2708. }
  2709. }
  2710. m_pRtrWizData->m_hrDDError = hr;
  2711. // Ignore the error, always go on to the next page
  2712. return hrOK;
  2713. }
  2714. /*---------------------------------------------------------------------------
  2715. CNewRtrWizNatFinish
  2716. ---------------------------------------------------------------------------*/
  2717. CNewRtrWizNatFinish::CNewRtrWizNatFinish() :
  2718. CNewRtrWizFinishPageBase(CNewRtrWizNatFinish::IDD, SaveFlag_Advanced, HelpFlag_Nothing)
  2719. {
  2720. InitWiz97(TRUE, 0, 0);
  2721. }
  2722. BEGIN_MESSAGE_MAP(CNewRtrWizNatFinish, CNewRtrWizFinishPageBase)
  2723. END_MESSAGE_MAP()
  2724. BOOL CNewRtrWizNatFinish::OnSetActive()
  2725. {
  2726. CNewRtrWizFinishPageBase::OnSetActive();
  2727. // If we just got here because we created a DD interface
  2728. // we can't go back.
  2729. if (m_pRtrWizData->m_fCreateDD)
  2730. {
  2731. CancelToClose();
  2732. GetHolder()->SetWizardButtons(PSWIZB_FINISH);
  2733. }
  2734. return TRUE;
  2735. }
  2736. /*---------------------------------------------------------------------------
  2737. CNewRtrWizNatFinishExternal
  2738. ---------------------------------------------------------------------------*/
  2739. CNewRtrWizNatFinishExternal::CNewRtrWizNatFinishExternal() :
  2740. CNewRtrWizFinishPageBase(CNewRtrWizNatFinishExternal::IDD, SaveFlag_Advanced, HelpFlag_GeneralNAT)
  2741. {
  2742. InitWiz97(TRUE, 0, 0);
  2743. }
  2744. BEGIN_MESSAGE_MAP(CNewRtrWizNatFinishExternal, CNewRtrWizFinishPageBase)
  2745. END_MESSAGE_MAP()
  2746. BOOL CNewRtrWizNatFinishExternal::OnSetActive()
  2747. {
  2748. CNewRtrWizFinishPageBase::OnSetActive();
  2749. // If we just got here because we created a DD interface
  2750. // we can't go back.
  2751. if (m_pRtrWizData->m_fCreateDD)
  2752. {
  2753. CancelToClose();
  2754. GetHolder()->SetWizardButtons(PSWIZB_FINISH);
  2755. }
  2756. return TRUE;
  2757. }
  2758. /*---------------------------------------------------------------------------
  2759. CNewRtrWizNatDDError
  2760. ---------------------------------------------------------------------------*/
  2761. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishDDError,
  2762. SaveFlag_DoNothing,
  2763. HelpFlag_Nothing);
  2764. /*---------------------------------------------------------------------------
  2765. CNewRtrWizRasChoice Implementation
  2766. ---------------------------------------------------------------------------*/
  2767. CNewRtrWizRasChoice::CNewRtrWizRasChoice() :
  2768. CNewRtrWizPageBase(CNewRtrWizRasChoice::IDD, CNewRtrWizPageBase::Middle)
  2769. {
  2770. InitWiz97(FALSE,
  2771. IDS_NEWWIZ_RAS_CHOICE_TITLE,
  2772. IDS_NEWWIZ_RAS_CHOICE_SUBTITLE);
  2773. }
  2774. BEGIN_MESSAGE_MAP(CNewRtrWizRasChoice, CNewRtrWizPageBase)
  2775. END_MESSAGE_MAP()
  2776. /*!--------------------------------------------------------------------------
  2777. CNewRtrWizRasChoice::OnInitDialog
  2778. -
  2779. Author: KennT
  2780. ---------------------------------------------------------------------------*/
  2781. BOOL CNewRtrWizRasChoice::OnInitDialog()
  2782. {
  2783. DWORD dwNICs;
  2784. UINT uSelection;
  2785. CNewRtrWizPageBase::OnInitDialog();
  2786. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  2787. if (dwNICs == 1)
  2788. uSelection = IDC_NEWWIZ_BTN_SIMPLE;
  2789. else
  2790. uSelection = IDC_NEWWIZ_BTN_ADVANCED;
  2791. CheckRadioButton(IDC_NEWWIZ_BTN_SIMPLE,
  2792. IDC_NEWWIZ_BTN_ADVANCED,
  2793. uSelection);
  2794. return TRUE;
  2795. }
  2796. HRESULT CNewRtrWizRasChoice::OnSavePage()
  2797. {
  2798. // Record the data change
  2799. if (IsDlgButtonChecked(IDC_NEWWIZ_BTN_SIMPLE))
  2800. m_pRtrWizData->m_fAdvanced = FALSE;
  2801. else
  2802. {
  2803. Assert(IsDlgButtonChecked(IDC_NEWWIZ_BTN_ADVANCED));
  2804. m_pRtrWizData->m_fAdvanced = TRUE;
  2805. }
  2806. return hrOK;
  2807. }
  2808. /*---------------------------------------------------------------------------
  2809. CNewRtrWizProtocols implementation
  2810. ---------------------------------------------------------------------------*/
  2811. CNewRtrWizProtocols::CNewRtrWizProtocols(UINT uDialogId) :
  2812. CNewRtrWizPageBase(uDialogId, CNewRtrWizPageBase::Middle),
  2813. m_fUseChecks(TRUE)
  2814. {
  2815. // Turn off use of the checkboxes for everyone.
  2816. m_fUseChecks = FALSE;
  2817. }
  2818. void CNewRtrWizProtocols::DoDataExchange(CDataExchange *pDX)
  2819. {
  2820. CNewRtrWizPageBase::DoDataExchange(pDX);
  2821. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  2822. }
  2823. BEGIN_MESSAGE_MAP(CNewRtrWizProtocols, CNewRtrWizPageBase)
  2824. END_MESSAGE_MAP()
  2825. void CNewRtrWizProtocols::AddProtocolItem(UINT idsProto,
  2826. RtrWizProtocolId pid,
  2827. INT nCount)
  2828. {
  2829. CString st;
  2830. INT iPos;
  2831. LV_ITEM lvItem;
  2832. st.LoadString(idsProto);
  2833. lvItem.mask = LVIF_TEXT | LVIF_PARAM;
  2834. lvItem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
  2835. lvItem.state = 0;
  2836. lvItem.iSubItem = 0;
  2837. lvItem.iItem = nCount;
  2838. lvItem.pszText = (LPTSTR)(LPCTSTR) st;
  2839. lvItem.lParam = pid; //same functionality as SetItemData()
  2840. iPos = m_listCtrl.InsertItem(&lvItem);
  2841. m_listCtrl.SetItemText(iPos, 0, st);
  2842. if (m_fUseChecks)
  2843. m_listCtrl.SetCheck(iPos, TRUE);
  2844. }
  2845. /*!--------------------------------------------------------------------------
  2846. CNewRtrWizProtocols::OnInitDialog
  2847. -
  2848. Author: KennT
  2849. ---------------------------------------------------------------------------*/
  2850. BOOL CNewRtrWizProtocols::OnInitDialog()
  2851. {
  2852. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  2853. DWORD dwNICs;
  2854. UINT uSelection;
  2855. INT nCount = 0;
  2856. LV_COLUMN lvCol;
  2857. RECT rect;
  2858. CNewRtrWizPageBase::OnInitDialog();
  2859. // add our single column, there is no header
  2860. m_listCtrl.GetClientRect(&rect);
  2861. lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
  2862. lvCol.fmt = LVCFMT_LEFT;
  2863. lvCol.cx = rect.right;
  2864. m_listCtrl.InsertColumn(0, &lvCol);
  2865. if (m_fUseChecks)
  2866. m_listCtrl.InstallChecks();
  2867. // Setup the dialog by adding all of the protocols
  2868. if ( FHrOK(m_pRtrWizData->HrIsIPInstalled()) )
  2869. AddProtocolItem(IDS_RTRWIZ_PROTO_IP, RtrWizProtocol_Ip, nCount++);
  2870. if ( FHrOK(m_pRtrWizData->HrIsIPXInstalled()) )
  2871. AddProtocolItem(IDS_RTRWIZ_PROTO_IPX, RtrWizProtocol_Ipx, nCount++);
  2872. if ( FHrOK(m_pRtrWizData->HrIsAppletalkInstalled()) )
  2873. AddProtocolItem(IDS_RTRWIZ_PROTO_APPLETALK, RtrWizProtocol_Appletalk, nCount++);
  2874. //no more netbuei for us in the product: bugid:153752
  2875. #if 0
  2876. if ( FHrOK(m_pRtrWizData->HrIsNbfInstalled()) )
  2877. AddProtocolItem(IDS_RTRWIZ_PROTO_NETBEUI, RtrWizProtocol_Nbf, nCount++);
  2878. #endif
  2879. // Note the reversed order. The question is, do
  2880. // you have all the protocols?
  2881. CheckRadioButton(IDC_NEWWIZ_BTN_YES, IDC_NEWWIZ_BTN_NO,
  2882. m_pRtrWizData->m_fNeedMoreProtocols ? IDC_NEWWIZ_BTN_NO : IDC_NEWWIZ_BTN_YES);
  2883. return TRUE;
  2884. }
  2885. /*!--------------------------------------------------------------------------
  2886. CNewRtrWizProtocols::OnSavePage
  2887. -
  2888. Author: KennT
  2889. ---------------------------------------------------------------------------*/
  2890. HRESULT CNewRtrWizProtocols::OnSavePage()
  2891. {
  2892. m_pRtrWizData->m_fNeedMoreProtocols = IsDlgButtonChecked(IDC_NEWWIZ_BTN_NO);
  2893. if (m_fUseChecks)
  2894. {
  2895. LV_FINDINFO lvFind;
  2896. INT iPos;
  2897. lvFind.flags = LVFI_PARAM;
  2898. lvFind.psz = NULL;
  2899. // Is IP in use?
  2900. lvFind.lParam = RtrWizProtocol_Ip;
  2901. iPos = m_listCtrl.FindItem(&lvFind, -1);
  2902. if (iPos != -1)
  2903. m_pRtrWizData->m_fIpInUse = m_listCtrl.GetCheck(iPos);
  2904. // Is IPX in use?
  2905. lvFind.lParam = RtrWizProtocol_Ipx;
  2906. iPos = m_listCtrl.FindItem(&lvFind, -1);
  2907. if (iPos != -1)
  2908. m_pRtrWizData->m_fIpxInUse = m_listCtrl.GetCheck(iPos);
  2909. // Is Appletalk in use?
  2910. lvFind.lParam = RtrWizProtocol_Appletalk;
  2911. iPos = m_listCtrl.FindItem(&lvFind, -1);
  2912. if (iPos != -1)
  2913. m_pRtrWizData->m_fAppletalkInUse = m_listCtrl.GetCheck(iPos);
  2914. // Is Nbf in use?
  2915. lvFind.lParam = RtrWizProtocol_Nbf;
  2916. iPos = m_listCtrl.FindItem(&lvFind, -1);
  2917. if (iPos != -1)
  2918. m_pRtrWizData->m_fNbfInUse = m_listCtrl.GetCheck(iPos);
  2919. }
  2920. return hrOK;
  2921. }
  2922. /*---------------------------------------------------------------------------
  2923. CNewRtrWizRasProtocols implementation
  2924. ---------------------------------------------------------------------------*/
  2925. CNewRtrWizRasProtocols::CNewRtrWizRasProtocols() :
  2926. CNewRtrWizProtocols(CNewRtrWizRasProtocols::IDD)
  2927. {
  2928. InitWiz97(FALSE,
  2929. IDS_NEWWIZ_RAS_A_PROTOCOLS_TITLE,
  2930. IDS_NEWWIZ_RAS_A_PROTOCOLS_SUBTITLE);
  2931. }
  2932. /*---------------------------------------------------------------------------
  2933. CNewRtrWizRasFinishNeedProtocols Implementation
  2934. ---------------------------------------------------------------------------*/
  2935. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRasFinishNeedProtocols,
  2936. SaveFlag_DoNothing,
  2937. HelpFlag_AddProtocol);
  2938. /*---------------------------------------------------------------------------
  2939. CNewRtrWizRasFinishNeedProtocolsNonLocal Implementation
  2940. ---------------------------------------------------------------------------*/
  2941. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRasFinishNeedProtocolsNonLocal,
  2942. SaveFlag_DoNothing,
  2943. HelpFlag_Nothing);
  2944. /*---------------------------------------------------------------------------
  2945. CNewRtrWizVpnProtocols implementation
  2946. ---------------------------------------------------------------------------*/
  2947. CNewRtrWizVpnProtocols::CNewRtrWizVpnProtocols() :
  2948. CNewRtrWizProtocols(CNewRtrWizVpnProtocols::IDD)
  2949. {
  2950. InitWiz97(FALSE,
  2951. IDS_NEWWIZ_VPN_A_PROTOCOLS_TITLE,
  2952. IDS_NEWWIZ_VPN_A_PROTOCOLS_SUBTITLE);
  2953. }
  2954. /*!--------------------------------------------------------------------------
  2955. CNewRtrWizVpnProtocols::OnSavePage
  2956. -
  2957. Author: KennT
  2958. ---------------------------------------------------------------------------*/
  2959. HRESULT CNewRtrWizVpnProtocols::OnSavePage()
  2960. {
  2961. HRESULT hr = hrOK;
  2962. // First, check to see that IP is checked
  2963. if (m_fUseChecks)
  2964. {
  2965. LV_FINDINFO lvFind;
  2966. INT iPos;
  2967. lvFind.flags = LVFI_PARAM;
  2968. lvFind.psz = NULL;
  2969. // Is IP in use?
  2970. lvFind.lParam = RtrWizProtocol_Ip;
  2971. iPos = m_listCtrl.FindItem(&lvFind, -1);
  2972. if (iPos != -1)
  2973. m_pRtrWizData->m_fIpInUse = m_listCtrl.GetCheck(iPos);
  2974. // IP must be installed for the VPN Case
  2975. if (!m_pRtrWizData->m_fIpInUse)
  2976. {
  2977. AfxMessageBox(IDS_ERR_RTRWIZ_VPN_REQUIRES_IP);
  2978. hr = E_FAIL;
  2979. }
  2980. }
  2981. if (FHrSucceeded(hr))
  2982. hr = CNewRtrWizProtocols::OnSavePage();
  2983. return hr;
  2984. }
  2985. /*---------------------------------------------------------------------------
  2986. CNewRtrWizVpnFinishNeedProtocols Implementation
  2987. ---------------------------------------------------------------------------*/
  2988. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNeedProtocols,
  2989. SaveFlag_DoNothing,
  2990. HelpFlag_AddProtocol);
  2991. /*---------------------------------------------------------------------------
  2992. CNewRtrWizVpnFinishNeedProtocolsNonLocal Implementation
  2993. ---------------------------------------------------------------------------*/
  2994. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNeedProtocolsNonLocal,
  2995. SaveFlag_DoNothing,
  2996. HelpFlag_Nothing);
  2997. /*---------------------------------------------------------------------------
  2998. CNewRtrWizRouterProtocols implementation
  2999. ---------------------------------------------------------------------------*/
  3000. CNewRtrWizRouterProtocols::CNewRtrWizRouterProtocols() :
  3001. CNewRtrWizProtocols(CNewRtrWizRouterProtocols::IDD)
  3002. {
  3003. InitWiz97(FALSE,
  3004. IDS_NEWWIZ_ROUTER_PROTOCOLS_TITLE,
  3005. IDS_NEWWIZ_ROUTER_PROTOCOLS_SUBTITLE);
  3006. // For the router, we do not want to show the checkboxes (it doesn't
  3007. // make sense).
  3008. m_fUseChecks = FALSE;
  3009. }
  3010. /*---------------------------------------------------------------------------
  3011. CNewRtrWizRouterFinishNeedProtocols Implementation
  3012. ---------------------------------------------------------------------------*/
  3013. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRouterFinishNeedProtocols,
  3014. SaveFlag_DoNothing,
  3015. HelpFlag_AddProtocol);
  3016. /*---------------------------------------------------------------------------
  3017. CNewRtrWizRouterFinishNeedProtocolsNonLocal Implementation
  3018. ---------------------------------------------------------------------------*/
  3019. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRouterFinishNeedProtocolsNonLocal,
  3020. SaveFlag_DoNothing,
  3021. HelpFlag_Nothing);
  3022. /*---------------------------------------------------------------------------
  3023. CNewRtrWizAppletalk implementation
  3024. ---------------------------------------------------------------------------*/
  3025. CNewRtrWizAppletalk::CNewRtrWizAppletalk(UINT uDialogId) :
  3026. CNewRtrWizPageBase(uDialogId, CNewRtrWizPageBase::Middle)
  3027. {
  3028. }
  3029. BEGIN_MESSAGE_MAP(CNewRtrWizAppletalk, CNewRtrWizPageBase)
  3030. END_MESSAGE_MAP()
  3031. /*!--------------------------------------------------------------------------
  3032. CNewRtrWizAppletalk::OnInitDialog
  3033. -
  3034. Author: KennT
  3035. ---------------------------------------------------------------------------*/
  3036. BOOL CNewRtrWizAppletalk::OnInitDialog()
  3037. {
  3038. CNewRtrWizPageBase::OnInitDialog();
  3039. // The default is to leave the box unchecked.
  3040. CheckDlgButton(IDC_NEWWIZ_CHECKBOX,
  3041. m_pRtrWizData->m_fAppletalkUseNoAuth);
  3042. return TRUE;
  3043. }
  3044. HRESULT CNewRtrWizAppletalk::OnSavePage()
  3045. {
  3046. m_pRtrWizData->m_fAppletalkUseNoAuth = IsDlgButtonChecked(IDC_NEWWIZ_CHECKBOX);
  3047. return hrOK;
  3048. }
  3049. /*---------------------------------------------------------------------------
  3050. CNewRtrWizRasAppletalk implementation
  3051. ---------------------------------------------------------------------------*/
  3052. CNewRtrWizRasAppletalk::CNewRtrWizRasAppletalk() :
  3053. CNewRtrWizAppletalk(CNewRtrWizRasAppletalk::IDD)
  3054. {
  3055. InitWiz97(FALSE,
  3056. IDS_NEWWIZ_RAS_A_ATALK_TITLE,
  3057. IDS_NEWWIZ_RAS_A_ATALK_SUBTITLE);
  3058. }
  3059. /*---------------------------------------------------------------------------
  3060. CNewRtrWizVpnAppletalk implementation
  3061. ---------------------------------------------------------------------------*/
  3062. CNewRtrWizVpnAppletalk::CNewRtrWizVpnAppletalk() :
  3063. CNewRtrWizAppletalk(CNewRtrWizVpnAppletalk::IDD)
  3064. {
  3065. InitWiz97(FALSE,
  3066. IDS_NEWWIZ_VPN_A_ATALK_TITLE,
  3067. IDS_NEWWIZ_VPN_A_ATALK_SUBTITLE);
  3068. }
  3069. /*---------------------------------------------------------------------------
  3070. CNewRtrWizSelectNetwork implementation
  3071. ---------------------------------------------------------------------------*/
  3072. CNewRtrWizSelectNetwork::CNewRtrWizSelectNetwork(UINT uDialogId) :
  3073. CNewRtrWizPageBase(uDialogId, CNewRtrWizPageBase::Middle)
  3074. {
  3075. }
  3076. void CNewRtrWizSelectNetwork::DoDataExchange(CDataExchange *pDX)
  3077. {
  3078. CNewRtrWizPageBase::DoDataExchange(pDX);
  3079. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  3080. }
  3081. BEGIN_MESSAGE_MAP(CNewRtrWizSelectNetwork, CNewRtrWizPageBase)
  3082. END_MESSAGE_MAP()
  3083. /*!--------------------------------------------------------------------------
  3084. CNewRtrWizSelectNetwork::OnInitDialog
  3085. -
  3086. Author: KennT
  3087. ---------------------------------------------------------------------------*/
  3088. BOOL CNewRtrWizSelectNetwork::OnInitDialog()
  3089. {
  3090. // DWORD dwNICs;
  3091. CNewRtrWizPageBase::OnInitDialog();
  3092. // m_pRtrWizData->GetNumberOfNICS(&dwNICs);
  3093. InitializeInterfaceListControl(NULL,
  3094. &m_listCtrl,
  3095. NULL,
  3096. 0,
  3097. m_pRtrWizData);
  3098. RefreshInterfaceListControl(NULL,
  3099. &m_listCtrl,
  3100. NULL,
  3101. 0,
  3102. m_pRtrWizData);
  3103. m_listCtrl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED );
  3104. return TRUE;
  3105. }
  3106. HRESULT CNewRtrWizSelectNetwork::OnSavePage()
  3107. {
  3108. INT iSel;
  3109. // Check to see that we actually selected an item
  3110. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  3111. if (iSel == -1)
  3112. {
  3113. // We did not select an item
  3114. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  3115. return E_FAIL;
  3116. }
  3117. m_pRtrWizData->m_fCreateDD = FALSE;
  3118. m_pRtrWizData->m_stPrivateInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  3119. return hrOK;
  3120. }
  3121. /*---------------------------------------------------------------------------
  3122. CNewRtrWizRasSelectNetwork implementation
  3123. ---------------------------------------------------------------------------*/
  3124. CNewRtrWizRasSelectNetwork::CNewRtrWizRasSelectNetwork() :
  3125. CNewRtrWizSelectNetwork(CNewRtrWizRasSelectNetwork::IDD)
  3126. {
  3127. InitWiz97(FALSE,
  3128. IDS_NEWWIZ_RAS_A_SELECT_NETWORK_TITLE,
  3129. IDS_NEWWIZ_RAS_A_SELECT_NETWORK_SUBTITLE);
  3130. }
  3131. /*---------------------------------------------------------------------------
  3132. CNewRtrWizRasNoNICs implementation
  3133. ---------------------------------------------------------------------------*/
  3134. CNewRtrWizRasNoNICs::CNewRtrWizRasNoNICs() :
  3135. CNewRtrWizPageBase(CNewRtrWizRasNoNICs::IDD, CNewRtrWizPageBase::Middle)
  3136. {
  3137. InitWiz97(FALSE,
  3138. IDS_NEWWIZ_RAS_NONICS_TITLE,
  3139. IDS_NEWWIZ_RAS_NONICS_SUBTITLE);
  3140. }
  3141. void CNewRtrWizRasNoNICs::DoDataExchange(CDataExchange *pDX)
  3142. {
  3143. CNewRtrWizPageBase::DoDataExchange(pDX);
  3144. }
  3145. BEGIN_MESSAGE_MAP(CNewRtrWizRasNoNICs, CNewRtrWizPageBase)
  3146. END_MESSAGE_MAP()
  3147. /*!--------------------------------------------------------------------------
  3148. CNewRtrWizRasNoNICs::OnInitDialog
  3149. -
  3150. Author: KennT
  3151. ---------------------------------------------------------------------------*/
  3152. BOOL CNewRtrWizRasNoNICs::OnInitDialog()
  3153. {
  3154. CNewRtrWizPageBase::OnInitDialog();
  3155. CheckRadioButton(IDC_NEWWIZ_BTN_YES, IDC_NEWWIZ_BTN_NO,
  3156. IDC_NEWWIZ_BTN_YES);
  3157. // The default is to create a new connection
  3158. // That is, to leave the button unchecked.
  3159. return TRUE;
  3160. }
  3161. HRESULT CNewRtrWizRasNoNICs::OnSavePage()
  3162. {
  3163. m_pRtrWizData->m_fNoNicsAreOk = IsDlgButtonChecked(IDC_NEWWIZ_BTN_NO);
  3164. return hrOK;
  3165. }
  3166. /*---------------------------------------------------------------------------
  3167. CNewRtrWizRasFinishNoNICs Implementation
  3168. ---------------------------------------------------------------------------*/
  3169. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRasFinishNoNICs,
  3170. SaveFlag_DoNothing,
  3171. HelpFlag_Nothing);
  3172. /*---------------------------------------------------------------------------
  3173. CNewRtrWizAddressing implementation
  3174. ---------------------------------------------------------------------------*/
  3175. CNewRtrWizAddressing::CNewRtrWizAddressing(UINT uDialogId) :
  3176. CNewRtrWizPageBase(uDialogId, CNewRtrWizPageBase::Middle)
  3177. {
  3178. }
  3179. void CNewRtrWizAddressing::DoDataExchange(CDataExchange *pDX)
  3180. {
  3181. CNewRtrWizPageBase::DoDataExchange(pDX);
  3182. }
  3183. BEGIN_MESSAGE_MAP(CNewRtrWizAddressing, CNewRtrWizPageBase)
  3184. END_MESSAGE_MAP()
  3185. /*!--------------------------------------------------------------------------
  3186. CNewRtrWizAddressing::OnInitDialog
  3187. -
  3188. Author: KennT
  3189. ---------------------------------------------------------------------------*/
  3190. BOOL CNewRtrWizAddressing::OnInitDialog()
  3191. {
  3192. CNewRtrWizPageBase::OnInitDialog();
  3193. CheckRadioButton(IDC_NEWWIZ_BTN_YES, IDC_NEWWIZ_BTN_NO,
  3194. m_pRtrWizData->m_fUseDHCP ? IDC_NEWWIZ_BTN_YES : IDC_NEWWIZ_BTN_NO);
  3195. return TRUE;
  3196. }
  3197. /*!--------------------------------------------------------------------------
  3198. CNewRtrWizAddressing::OnSavePage
  3199. -
  3200. Author: KennT
  3201. ---------------------------------------------------------------------------*/
  3202. HRESULT CNewRtrWizAddressing::OnSavePage()
  3203. {
  3204. m_pRtrWizData->m_fUseDHCP = IsDlgButtonChecked(IDC_NEWWIZ_BTN_YES);
  3205. return hrOK;
  3206. }
  3207. /*---------------------------------------------------------------------------
  3208. CNewRtrWizRasAddressing implementation
  3209. ---------------------------------------------------------------------------*/
  3210. CNewRtrWizRasAddressing::CNewRtrWizRasAddressing() :
  3211. CNewRtrWizAddressing(CNewRtrWizRasAddressing::IDD)
  3212. {
  3213. InitWiz97(FALSE,
  3214. IDS_NEWWIZ_RAS_A_ADDRESS_ASSIGNMENT_TITLE,
  3215. IDS_NEWWIZ_RAS_A_ADDRESS_ASSIGNMENT_SUBTITLE);
  3216. }
  3217. /*---------------------------------------------------------------------------
  3218. CNewRtrWizRasAddressingNoNICs implementation
  3219. ---------------------------------------------------------------------------*/
  3220. CNewRtrWizRasAddressingNoNICs::CNewRtrWizRasAddressingNoNICs() :
  3221. CNewRtrWizAddressing(CNewRtrWizRasAddressingNoNICs::IDD)
  3222. {
  3223. InitWiz97(FALSE,
  3224. IDS_NEWWIZ_RAS_A_ADDRESSING_NONICS_TITLE,
  3225. IDS_NEWWIZ_RAS_A_ADDRESSING_NONICS_SUBTITLE);
  3226. }
  3227. /*---------------------------------------------------------------------------
  3228. CNewRtrWizVpnAddressing implementation
  3229. ---------------------------------------------------------------------------*/
  3230. CNewRtrWizVpnAddressing::CNewRtrWizVpnAddressing() :
  3231. CNewRtrWizAddressing(CNewRtrWizVpnAddressing::IDD)
  3232. {
  3233. InitWiz97(FALSE,
  3234. IDS_NEWWIZ_VPN_A_ADDRESS_ASSIGNMENT_TITLE,
  3235. IDS_NEWWIZ_VPN_A_ADDRESS_ASSIGNMENT_SUBTITLE);
  3236. }
  3237. /*---------------------------------------------------------------------------
  3238. CNewRtrWizRouterAddressing implementation
  3239. ---------------------------------------------------------------------------*/
  3240. CNewRtrWizRouterAddressing::CNewRtrWizRouterAddressing() :
  3241. CNewRtrWizAddressing(CNewRtrWizRouterAddressing::IDD)
  3242. {
  3243. InitWiz97(FALSE,
  3244. IDS_NEWWIZ_ROUTER_ADDRESS_ASSIGNMENT_TITLE,
  3245. IDS_NEWWIZ_ROUTER_ADDRESS_ASSIGNMENT_SUBTITLE);
  3246. }
  3247. /*---------------------------------------------------------------------------
  3248. CNewRtrWizAddressPool implementation
  3249. ---------------------------------------------------------------------------*/
  3250. CNewRtrWizAddressPool::CNewRtrWizAddressPool(UINT uDialogId) :
  3251. CNewRtrWizPageBase(uDialogId, CNewRtrWizPageBase::Middle)
  3252. {
  3253. }
  3254. void CNewRtrWizAddressPool::DoDataExchange(CDataExchange *pDX)
  3255. {
  3256. CNewRtrWizPageBase::DoDataExchange(pDX);
  3257. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  3258. }
  3259. BEGIN_MESSAGE_MAP(CNewRtrWizAddressPool, CNewRtrWizPageBase)
  3260. ON_BN_CLICKED(IDC_NEWWIZ_BTN_NEW, OnBtnNew)
  3261. ON_BN_CLICKED(IDC_NEWWIZ_BTN_EDIT, OnBtnEdit)
  3262. ON_BN_CLICKED(IDC_NEWWIZ_BTN_DELETE, OnBtnDelete)
  3263. ON_NOTIFY(NM_DBLCLK, IDC_NEWWIZ_LIST, OnListDblClk)
  3264. ON_NOTIFY(LVN_ITEMCHANGED, IDC_NEWWIZ_LIST, OnNotifyListItemChanged)
  3265. END_MESSAGE_MAP()
  3266. /*!--------------------------------------------------------------------------
  3267. CNewRtrWizAddressPool::OnInitDialog
  3268. -
  3269. Author: KennT
  3270. ---------------------------------------------------------------------------*/
  3271. BOOL CNewRtrWizAddressPool::OnInitDialog()
  3272. {
  3273. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  3274. CNewRtrWizPageBase::OnInitDialog();
  3275. InitializeAddressPoolListControl(&m_listCtrl,
  3276. 0,
  3277. &(m_pRtrWizData->m_addressPoolList));
  3278. MultiEnableWindow(GetSafeHwnd(),
  3279. FALSE,
  3280. IDC_NEWWIZ_BTN_EDIT,
  3281. IDC_NEWWIZ_BTN_DELETE,
  3282. 0);
  3283. Assert(m_pRtrWizData->m_addressPoolList.GetCount() == 0);
  3284. return TRUE;
  3285. }
  3286. BOOL CNewRtrWizAddressPool::OnSetActive()
  3287. {
  3288. CNewRtrWizPageBase::OnSetActive();
  3289. if (m_listCtrl.GetItemCount() == 0)
  3290. GetHolder()->SetWizardButtons(PSWIZB_BACK);
  3291. else
  3292. GetHolder()->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  3293. return TRUE;
  3294. }
  3295. HRESULT CNewRtrWizAddressPool::OnSavePage()
  3296. {
  3297. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  3298. // No need to save the information, the list should be kept
  3299. // up to date.
  3300. if (m_pRtrWizData->m_addressPoolList.GetCount() == 0)
  3301. {
  3302. AfxMessageBox(IDS_ERR_ADDRESS_POOL_IS_EMPTY);
  3303. return E_FAIL;
  3304. }
  3305. return hrOK;
  3306. }
  3307. void CNewRtrWizAddressPool::OnBtnNew()
  3308. {
  3309. OnNewAddressPool(GetSafeHwnd(),
  3310. &m_listCtrl,
  3311. 0,
  3312. &(m_pRtrWizData->m_addressPoolList));
  3313. if (m_listCtrl.GetItemCount() > 0)
  3314. GetHolder()->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  3315. // Reset the focus
  3316. if (m_listCtrl.GetNextItem(-1, LVIS_SELECTED) != -1)
  3317. {
  3318. MultiEnableWindow(GetSafeHwnd(),
  3319. TRUE,
  3320. IDC_NEWWIZ_BTN_EDIT,
  3321. IDC_NEWWIZ_BTN_DELETE,
  3322. 0);
  3323. }
  3324. }
  3325. void CNewRtrWizAddressPool::OnListDblClk(NMHDR *pNMHdr, LRESULT *pResult)
  3326. {
  3327. OnBtnEdit();
  3328. *pResult = 0;
  3329. }
  3330. void CNewRtrWizAddressPool::OnNotifyListItemChanged(NMHDR *pNmHdr, LRESULT *pResult)
  3331. {
  3332. NMLISTVIEW * pnmlv = reinterpret_cast<NMLISTVIEW *>(pNmHdr);
  3333. BOOL fEnable = !!(pnmlv->uNewState & LVIS_SELECTED);
  3334. MultiEnableWindow(GetSafeHwnd(),
  3335. fEnable,
  3336. IDC_NEWWIZ_BTN_EDIT,
  3337. IDC_NEWWIZ_BTN_DELETE,
  3338. 0);
  3339. *pResult = 0;
  3340. }
  3341. void CNewRtrWizAddressPool::OnBtnEdit()
  3342. {
  3343. INT iPos;
  3344. OnEditAddressPool(GetSafeHwnd(),
  3345. &m_listCtrl,
  3346. 0,
  3347. &(m_pRtrWizData->m_addressPoolList));
  3348. // reset the selection
  3349. if ((iPos = m_listCtrl.GetNextItem(-1, LVNI_SELECTED)) != -1)
  3350. {
  3351. MultiEnableWindow(GetSafeHwnd(),
  3352. TRUE,
  3353. IDC_NEWWIZ_BTN_EDIT,
  3354. IDC_NEWWIZ_BTN_DELETE,
  3355. 0);
  3356. }
  3357. }
  3358. void CNewRtrWizAddressPool::OnBtnDelete()
  3359. {
  3360. OnDeleteAddressPool(GetSafeHwnd(),
  3361. &m_listCtrl,
  3362. 0,
  3363. &(m_pRtrWizData->m_addressPoolList));
  3364. // There are no items, don't let them go forward
  3365. if (m_listCtrl.GetItemCount() == 0)
  3366. GetHolder()->SetWizardButtons(PSWIZB_BACK);
  3367. }
  3368. /*---------------------------------------------------------------------------
  3369. CNewRtrWizRasAddressPool implementation
  3370. ---------------------------------------------------------------------------*/
  3371. CNewRtrWizRasAddressPool::CNewRtrWizRasAddressPool() :
  3372. CNewRtrWizAddressPool(CNewRtrWizRasAddressPool::IDD)
  3373. {
  3374. InitWiz97(FALSE,
  3375. IDS_NEWWIZ_RAS_A_ADDRESS_POOL_TITLE,
  3376. IDS_NEWWIZ_RAS_A_ADDRESS_POOL_SUBTITLE);
  3377. }
  3378. /*---------------------------------------------------------------------------
  3379. CNewRtrWizVpnAddressPool implementation
  3380. ---------------------------------------------------------------------------*/
  3381. CNewRtrWizVpnAddressPool::CNewRtrWizVpnAddressPool() :
  3382. CNewRtrWizAddressPool(CNewRtrWizVpnAddressPool::IDD)
  3383. {
  3384. InitWiz97(FALSE,
  3385. IDS_NEWWIZ_VPN_A_ADDRESS_POOL_TITLE,
  3386. IDS_NEWWIZ_VPN_A_ADDRESS_POOL_SUBTITLE);
  3387. }
  3388. /*---------------------------------------------------------------------------
  3389. CNewRtrWizRouterAddressPool implementation
  3390. ---------------------------------------------------------------------------*/
  3391. CNewRtrWizRouterAddressPool::CNewRtrWizRouterAddressPool() :
  3392. CNewRtrWizAddressPool(CNewRtrWizRouterAddressPool::IDD)
  3393. {
  3394. InitWiz97(FALSE,
  3395. IDS_NEWWIZ_ROUTER_ADDRESS_POOL_TITLE,
  3396. IDS_NEWWIZ_ROUTER_ADDRESS_POOL_SUBTITLE);
  3397. }
  3398. /*---------------------------------------------------------------------------
  3399. CNewRtrWizRadius implementation
  3400. ---------------------------------------------------------------------------*/
  3401. CNewRtrWizRadius::CNewRtrWizRadius(UINT uDialogId) :
  3402. CNewRtrWizPageBase(uDialogId, CNewRtrWizPageBase::Middle)
  3403. {
  3404. }
  3405. void CNewRtrWizRadius::DoDataExchange(CDataExchange *pDX)
  3406. {
  3407. CNewRtrWizPageBase::DoDataExchange(pDX);
  3408. }
  3409. BEGIN_MESSAGE_MAP(CNewRtrWizRadius, CNewRtrWizPageBase)
  3410. END_MESSAGE_MAP()
  3411. /*!--------------------------------------------------------------------------
  3412. CNewRtrWizRadius::OnInitDialog
  3413. -
  3414. Author: KennT
  3415. ---------------------------------------------------------------------------*/
  3416. BOOL CNewRtrWizRadius::OnInitDialog()
  3417. {
  3418. CNewRtrWizPageBase::OnInitDialog();
  3419. CheckRadioButton(IDC_NEWWIZ_BTN_YES, IDC_NEWWIZ_BTN_NO,
  3420. m_pRtrWizData->m_fUseRadius ? IDC_NEWWIZ_BTN_YES : IDC_NEWWIZ_BTN_NO);
  3421. return TRUE;
  3422. }
  3423. /*!--------------------------------------------------------------------------
  3424. CNewRtrWizRadius::OnSavePage
  3425. -
  3426. Author: KennT
  3427. ---------------------------------------------------------------------------*/
  3428. HRESULT CNewRtrWizRadius::OnSavePage()
  3429. {
  3430. m_pRtrWizData->m_fUseRadius = IsDlgButtonChecked(IDC_NEWWIZ_BTN_YES);
  3431. return hrOK;
  3432. }
  3433. /*---------------------------------------------------------------------------
  3434. CNewRtrWizRasRadius implementation
  3435. ---------------------------------------------------------------------------*/
  3436. CNewRtrWizRasRadius::CNewRtrWizRasRadius() :
  3437. CNewRtrWizRadius(CNewRtrWizRasRadius::IDD)
  3438. {
  3439. InitWiz97(FALSE,
  3440. IDS_NEWWIZ_RAS_A_USERADIUS_TITLE,
  3441. IDS_NEWWIZ_RAS_A_USERADIUS_SUBTITLE);
  3442. }
  3443. /*---------------------------------------------------------------------------
  3444. CNewRtrWizVpnRadius implementation
  3445. ---------------------------------------------------------------------------*/
  3446. CNewRtrWizVpnRadius::CNewRtrWizVpnRadius() :
  3447. CNewRtrWizRadius(CNewRtrWizVpnRadius::IDD)
  3448. {
  3449. InitWiz97(FALSE,
  3450. IDS_NEWWIZ_VPN_A_USERADIUS_TITLE,
  3451. IDS_NEWWIZ_VPN_A_USERADIUS_SUBTITLE);
  3452. }
  3453. /*---------------------------------------------------------------------------
  3454. CNewRtrWizRadiusConfig implementation
  3455. ---------------------------------------------------------------------------*/
  3456. CNewRtrWizRadiusConfig::CNewRtrWizRadiusConfig(UINT uDialogId) :
  3457. CNewRtrWizPageBase(uDialogId, CNewRtrWizPageBase::Middle)
  3458. {
  3459. }
  3460. void CNewRtrWizRadiusConfig::DoDataExchange(CDataExchange *pDX)
  3461. {
  3462. CNewRtrWizPageBase::DoDataExchange(pDX);
  3463. }
  3464. BEGIN_MESSAGE_MAP(CNewRtrWizRadiusConfig, CNewRtrWizPageBase)
  3465. END_MESSAGE_MAP()
  3466. /*!--------------------------------------------------------------------------
  3467. CNewRtrWizRadiusConfig::OnInitDialog
  3468. -
  3469. Author: KennT
  3470. ---------------------------------------------------------------------------*/
  3471. BOOL CNewRtrWizRadiusConfig::OnInitDialog()
  3472. {
  3473. CNewRtrWizPageBase::OnInitDialog();
  3474. return TRUE;
  3475. }
  3476. /*!--------------------------------------------------------------------------
  3477. CNewRtrWizRadiusConfig::OnSavePage
  3478. -
  3479. Author: KennT
  3480. ---------------------------------------------------------------------------*/
  3481. HRESULT CNewRtrWizRadiusConfig::OnSavePage()
  3482. {
  3483. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  3484. CString st;
  3485. DWORD netAddress;
  3486. CWaitCursor wait;
  3487. WSADATA wsadata;
  3488. DWORD wsaerr = 0;
  3489. HRESULT hr = hrOK;
  3490. BOOL fWSInitialized = FALSE;
  3491. // Check to see that we have non-blank names
  3492. // ----------------------------------------------------------------
  3493. GetDlgItemText(IDC_NEWWIZ_EDIT_PRIMARY, m_pRtrWizData->m_stRadius1);
  3494. m_pRtrWizData->m_stRadius1.TrimLeft();
  3495. m_pRtrWizData->m_stRadius1.TrimRight();
  3496. GetDlgItemText(IDC_NEWWIZ_EDIT_SECONDARY, m_pRtrWizData->m_stRadius2);
  3497. m_pRtrWizData->m_stRadius2.TrimLeft();
  3498. m_pRtrWizData->m_stRadius2.TrimRight();
  3499. if (m_pRtrWizData->m_stRadius1.IsEmpty() &&
  3500. m_pRtrWizData->m_stRadius2.IsEmpty())
  3501. {
  3502. AfxMessageBox(IDS_ERR_NO_RADIUS_SERVERS_SPECIFIED);
  3503. return E_FAIL;
  3504. }
  3505. // Start up winsock (for the ResolveName())
  3506. // ----------------------------------------------------------------
  3507. wsaerr = WSAStartup(0x0101, &wsadata);
  3508. if (wsaerr)
  3509. CORg( E_FAIL );
  3510. fWSInitialized = TRUE;
  3511. // Convert name into an IP address
  3512. if (!m_pRtrWizData->m_stRadius1.IsEmpty())
  3513. {
  3514. m_pRtrWizData->m_netRadius1IpAddress = ResolveName(m_pRtrWizData->m_stRadius1);
  3515. if (m_pRtrWizData->m_netRadius1IpAddress == INADDR_NONE)
  3516. {
  3517. CString st;
  3518. st.Format(IDS_WRN_RTRWIZ_CANNOT_RESOLVE_RADIUS,
  3519. (LPCTSTR) m_pRtrWizData->m_stRadius1);
  3520. if (AfxMessageBox(st, MB_OKCANCEL) == IDCANCEL)
  3521. {
  3522. GetDlgItem(IDC_NEWWIZ_EDIT_PRIMARY)->SetFocus();
  3523. return E_FAIL;
  3524. }
  3525. }
  3526. }
  3527. // Convert name into an IP address
  3528. if (!m_pRtrWizData->m_stRadius2.IsEmpty())
  3529. {
  3530. m_pRtrWizData->m_netRadius2IpAddress = ResolveName(m_pRtrWizData->m_stRadius2);
  3531. if (m_pRtrWizData->m_netRadius2IpAddress == INADDR_NONE)
  3532. {
  3533. CString st;
  3534. st.Format(IDS_WRN_RTRWIZ_CANNOT_RESOLVE_RADIUS,
  3535. (LPCTSTR) m_pRtrWizData->m_stRadius2);
  3536. if (AfxMessageBox(st, MB_OKCANCEL) == IDCANCEL)
  3537. {
  3538. GetDlgItem(IDC_NEWWIZ_EDIT_SECONDARY)->SetFocus();
  3539. return E_FAIL;
  3540. }
  3541. }
  3542. }
  3543. // Now get the password and encode it
  3544. // ----------------------------------------------------------------
  3545. GetDlgItemText(IDC_NEWWIZ_EDIT_SECRET, m_pRtrWizData->m_stRadiusSecret);
  3546. // Pick a seed value
  3547. m_pRtrWizData->m_uSeed = 0x9a;
  3548. RtlEncodeW(&m_pRtrWizData->m_uSeed,
  3549. m_pRtrWizData->m_stRadiusSecret.GetBuffer(0));
  3550. m_pRtrWizData->m_stRadiusSecret.ReleaseBuffer(-1);
  3551. Error:
  3552. if (fWSInitialized)
  3553. WSACleanup();
  3554. return hr;
  3555. }
  3556. DWORD CNewRtrWizRadiusConfig::ResolveName(LPCTSTR pszServerName)
  3557. {
  3558. CHAR szName[MAX_PATH+1];
  3559. DWORD netAddress = INADDR_NONE;
  3560. StrnCpyAFromT(szName, pszServerName, MAX_PATH);
  3561. netAddress = inet_addr(szName);
  3562. if (netAddress == INADDR_NONE)
  3563. {
  3564. // resolve name
  3565. struct hostent * phe = gethostbyname(szName);
  3566. if (phe != NULL)
  3567. {
  3568. if (phe->h_addr_list[0] != NULL)
  3569. netAddress = *((PDWORD) phe->h_addr_list[0]);
  3570. }
  3571. else
  3572. {
  3573. Assert(::WSAGetLastError() != WSANOTINITIALISED);
  3574. }
  3575. }
  3576. return netAddress;
  3577. }
  3578. /*---------------------------------------------------------------------------
  3579. CNewRtrWizRasRadiusConfig implementation
  3580. ---------------------------------------------------------------------------*/
  3581. CNewRtrWizRasRadiusConfig::CNewRtrWizRasRadiusConfig() :
  3582. CNewRtrWizRadiusConfig(CNewRtrWizRasRadiusConfig::IDD)
  3583. {
  3584. InitWiz97(FALSE,
  3585. IDS_NEWWIZ_RAS_A_RADIUS_CONFIG_TITLE,
  3586. IDS_NEWWIZ_RAS_A_RADIUS_CONFIG_SUBTITLE);
  3587. }
  3588. /*---------------------------------------------------------------------------
  3589. CNewRtrWizVpnRadiusConfig implementation
  3590. ---------------------------------------------------------------------------*/
  3591. CNewRtrWizVpnRadiusConfig::CNewRtrWizVpnRadiusConfig() :
  3592. CNewRtrWizRadiusConfig(CNewRtrWizVpnRadiusConfig::IDD)
  3593. {
  3594. InitWiz97(FALSE,
  3595. IDS_NEWWIZ_VPN_A_RADIUS_CONFIG_TITLE,
  3596. IDS_NEWWIZ_VPN_A_RADIUS_CONFIG_SUBTITLE);
  3597. }
  3598. /*---------------------------------------------------------------------------
  3599. CNewRtrWizRasFinishAdvanced Implementation
  3600. ---------------------------------------------------------------------------*/
  3601. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRasFinishAdvanced,
  3602. SaveFlag_Advanced,
  3603. HelpFlag_GeneralRAS);
  3604. /*---------------------------------------------------------------------------
  3605. CNewRtrWizVpnFinishNoNICs Implementation
  3606. ---------------------------------------------------------------------------*/
  3607. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNoNICs,
  3608. SaveFlag_DoNothing,
  3609. HelpFlag_Nothing);
  3610. /*---------------------------------------------------------------------------
  3611. CNewRtrWizVpnFinishNoIP Implementation
  3612. ---------------------------------------------------------------------------*/
  3613. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNoIP,
  3614. SaveFlag_DoNothing,
  3615. HelpFlag_AddIp);
  3616. /*---------------------------------------------------------------------------
  3617. CNewRtrWizVpnFinishNoIPNonLocal Implementation
  3618. ---------------------------------------------------------------------------*/
  3619. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNoIPNonLocal,
  3620. SaveFlag_DoNothing,
  3621. HelpFlag_Nothing);
  3622. /*---------------------------------------------------------------------------
  3623. CNewRtrWizVpnFinishAdvanced Implementation
  3624. ---------------------------------------------------------------------------*/
  3625. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishAdvanced,
  3626. SaveFlag_Advanced,
  3627. HelpFlag_Nothing);
  3628. /*---------------------------------------------------------------------------
  3629. CNewRtrWizVpnSelectPublic implementation
  3630. ---------------------------------------------------------------------------*/
  3631. CNewRtrWizVpnSelectPublic::CNewRtrWizVpnSelectPublic() :
  3632. CNewRtrWizPageBase(CNewRtrWizVpnSelectPublic::IDD, CNewRtrWizPageBase::Middle)
  3633. {
  3634. InitWiz97(FALSE,
  3635. IDS_NEWWIZ_VPN_A_SELECT_PUBLIC_TITLE,
  3636. IDS_NEWWIZ_VPN_A_SELECT_PUBLIC_SUBTITLE);
  3637. }
  3638. void CNewRtrWizVpnSelectPublic::DoDataExchange(CDataExchange *pDX)
  3639. {
  3640. CNewRtrWizPageBase::DoDataExchange(pDX);
  3641. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  3642. }
  3643. BEGIN_MESSAGE_MAP(CNewRtrWizVpnSelectPublic, CNewRtrWizPageBase)
  3644. //{{AFX_MSG_MAP(CNewRtrWizVpnSelectPublic)
  3645. ON_BN_CLICKED(IDC_NEWWIZ_VPN_BTN_YES, OnButtonClick)
  3646. ON_BN_CLICKED(IDC_NEWWIZ_VPN_BTN_NO, OnButtonClick)
  3647. //}}AFX_MSG_MAP
  3648. END_MESSAGE_MAP()
  3649. /*!--------------------------------------------------------------------------
  3650. CNewRtrWizVpnSelectPublic::OnInitDialog
  3651. -
  3652. Author: KennT
  3653. ---------------------------------------------------------------------------*/
  3654. BOOL CNewRtrWizVpnSelectPublic::OnInitDialog()
  3655. {
  3656. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  3657. DWORD dwNICs;
  3658. CString st;
  3659. CNewRtrWizPageBase::OnInitDialog();
  3660. // Setup the dialog and add the NICs
  3661. m_pRtrWizData->m_fSetVPNFilter = TRUE;
  3662. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  3663. InitializeInterfaceListControl(NULL,
  3664. &m_listCtrl,
  3665. NULL,
  3666. 0,
  3667. m_pRtrWizData);
  3668. RefreshInterfaceListControl(NULL,
  3669. &m_listCtrl,
  3670. NULL,
  3671. 0,
  3672. m_pRtrWizData);
  3673. if (dwNICs == 0)
  3674. {
  3675. //
  3676. // There are no NICS, you cannot set an interface
  3677. // pointing to the Internet, and hence no filters
  3678. // on it.
  3679. //
  3680. m_pRtrWizData->m_fSetVPNFilter = FALSE;
  3681. GetDlgItem(IDC_NEWWIZ_VPN_BTN_YES)->EnableWindow(FALSE);
  3682. GetDlgItem(IDC_VPN_YES_TEXT)->EnableWindow(FALSE);
  3683. }
  3684. #if 0
  3685. // Windows NT Bug : 389587 - for the VPN case, we have to allow
  3686. // for the case where they want only a single VPN connection (private
  3687. // and no public connection).
  3688. // Thus I add a <<None>> option to the list of interfaces.
  3689. // ----------------------------------------------------------------
  3690. st.LoadString(IDS_NO_PUBLIC_INTERFACE);
  3691. {
  3692. LV_ITEM lvItem;
  3693. int iPos;
  3694. lvItem.mask = LVIF_TEXT | LVIF_PARAM;
  3695. lvItem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
  3696. lvItem.state = 0;
  3697. lvItem.iItem = 0;
  3698. lvItem.iSubItem = 0;
  3699. lvItem.pszText = (LPTSTR)(LPCTSTR) st;
  3700. lvItem.lParam = NULL; //same functionality as SetItemData()
  3701. iPos = m_listCtrl.InsertItem(&lvItem);
  3702. if (iPos != -1)
  3703. {
  3704. m_listCtrl.SetItemText(iPos, IFLISTCOL_NAME,
  3705. (LPCTSTR) st);
  3706. m_listCtrl.SetItemData(iPos, NULL);
  3707. }
  3708. }
  3709. m_listCtrl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED );
  3710. #endif
  3711. CheckRadioButton(
  3712. IDC_NEWWIZ_VPN_BTN_YES,
  3713. IDC_NEWWIZ_VPN_BTN_NO,
  3714. m_pRtrWizData-> m_fSetVPNFilter ?
  3715. IDC_NEWWIZ_VPN_BTN_YES : IDC_NEWWIZ_VPN_BTN_NO
  3716. );
  3717. //
  3718. // If this is NOT a VPN only server, disable the list of
  3719. // interfaces to set filters on
  3720. //
  3721. GetDlgItem(IDC_NEWWIZ_LIST)->EnableWindow(
  3722. m_pRtrWizData-> m_fSetVPNFilter
  3723. );
  3724. return TRUE;
  3725. }
  3726. void CNewRtrWizVpnSelectPublic::OnButtonClick()
  3727. {
  3728. m_pRtrWizData->m_fSetVPNFilter =
  3729. IsDlgButtonChecked(IDC_NEWWIZ_VPN_BTN_YES);
  3730. GetDlgItem(IDC_NEWWIZ_LIST)->EnableWindow(
  3731. m_pRtrWizData-> m_fSetVPNFilter
  3732. );
  3733. }
  3734. HRESULT CNewRtrWizVpnSelectPublic::OnSavePage()
  3735. {
  3736. INT iSel;
  3737. if (m_pRtrWizData->m_fSetVPNFilter)
  3738. {
  3739. DWORD dwNics = 0;
  3740. // Check to see that we actually selected an item
  3741. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  3742. if (iSel == -1)
  3743. {
  3744. // We did not select an item
  3745. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  3746. return E_FAIL;
  3747. }
  3748. m_pRtrWizData->m_fCreateDD = FALSE;
  3749. m_pRtrWizData->m_stPublicInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  3750. // If the user has selected the non-blank interface, then
  3751. // we need to check that there is at least one non-private
  3752. // interface.
  3753. // ------------------------------------------------------------
  3754. m_pRtrWizData->GetNumberOfNICS_IP(&dwNics);
  3755. if (dwNics <= 1)
  3756. {
  3757. // oops, there aren't any NICs left over for the private
  3758. // interface.
  3759. AfxMessageBox(IDS_ERR_VPN_NO_NICS_LEFT_FOR_PRIVATE_IF);
  3760. return E_FAIL;
  3761. }
  3762. }
  3763. else
  3764. {
  3765. m_pRtrWizData->m_stPublicInterfaceId.Empty();
  3766. }
  3767. return hrOK;
  3768. }
  3769. /*---------------------------------------------------------------------------
  3770. CNewRtrWizVpnSelectPrivate
  3771. ---------------------------------------------------------------------------*/
  3772. CNewRtrWizVpnSelectPrivate::CNewRtrWizVpnSelectPrivate() :
  3773. CNewRtrWizPageBase(CNewRtrWizVpnSelectPrivate::IDD, CNewRtrWizPageBase::Middle)
  3774. {
  3775. InitWiz97(FALSE,
  3776. IDS_NEWWIZ_VPN_A_SELECT_PRIVATE_TITLE,
  3777. IDS_NEWWIZ_VPN_A_SELECT_PRIVATE_SUBTITLE);
  3778. }
  3779. void CNewRtrWizVpnSelectPrivate::DoDataExchange(CDataExchange *pDX)
  3780. {
  3781. CNewRtrWizPageBase::DoDataExchange(pDX);
  3782. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  3783. }
  3784. BEGIN_MESSAGE_MAP(CNewRtrWizVpnSelectPrivate, CNewRtrWizPageBase)
  3785. END_MESSAGE_MAP()
  3786. /*!--------------------------------------------------------------------------
  3787. CNewRtrWizVpnSelectPrivate::OnInitDialog
  3788. -
  3789. Author: KennT
  3790. ---------------------------------------------------------------------------*/
  3791. BOOL CNewRtrWizVpnSelectPrivate::OnInitDialog()
  3792. {
  3793. DWORD dwNICs;
  3794. CNewRtrWizPageBase::OnInitDialog();
  3795. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  3796. InitializeInterfaceListControl(NULL,
  3797. &m_listCtrl,
  3798. NULL,
  3799. 0,
  3800. m_pRtrWizData);
  3801. return TRUE;
  3802. }
  3803. /*!--------------------------------------------------------------------------
  3804. CNewRtrWizVpnSelectPrivate::OnSetActive
  3805. -
  3806. Author: KennT
  3807. ---------------------------------------------------------------------------*/
  3808. BOOL CNewRtrWizVpnSelectPrivate::OnSetActive()
  3809. {
  3810. DWORD dwNICs;
  3811. int iSel = 0;
  3812. CNewRtrWizPageBase::OnSetActive();
  3813. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  3814. RefreshInterfaceListControl(NULL,
  3815. &m_listCtrl,
  3816. (LPCTSTR) m_pRtrWizData->m_stPublicInterfaceId,
  3817. 0,
  3818. m_pRtrWizData);
  3819. if (!m_pRtrWizData->m_stPrivateInterfaceId.IsEmpty())
  3820. {
  3821. // Try to reselect the previously selected NIC
  3822. LV_FINDINFO lvfi;
  3823. lvfi.flags = LVFI_PARTIAL | LVFI_STRING;
  3824. lvfi.psz = (LPCTSTR) m_pRtrWizData->m_stPrivateInterfaceId;
  3825. iSel = m_listCtrl.FindItem(&lvfi, -1);
  3826. if (iSel == -1)
  3827. iSel = 0;
  3828. }
  3829. m_listCtrl.SetItemState(iSel, LVIS_SELECTED, LVIS_SELECTED );
  3830. return TRUE;
  3831. }
  3832. /*!--------------------------------------------------------------------------
  3833. CNewRtrWizVpnSelectPrivate::OnSavePage
  3834. -
  3835. Author: KennT
  3836. ---------------------------------------------------------------------------*/
  3837. HRESULT CNewRtrWizVpnSelectPrivate::OnSavePage()
  3838. {
  3839. INT iSel;
  3840. // Check to see that we actually selected an item
  3841. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  3842. if (iSel == LB_ERR)
  3843. {
  3844. // We did not select an item
  3845. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  3846. return E_FAIL;
  3847. }
  3848. m_pRtrWizData->m_stPrivateInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  3849. return hrOK;
  3850. }
  3851. /*---------------------------------------------------------------------------
  3852. CNewRtrWizRouterUseDD implementation
  3853. ---------------------------------------------------------------------------*/
  3854. CNewRtrWizRouterUseDD::CNewRtrWizRouterUseDD() :
  3855. CNewRtrWizPageBase(CNewRtrWizRouterUseDD::IDD, CNewRtrWizPageBase::Middle)
  3856. {
  3857. InitWiz97(FALSE,
  3858. IDS_NEWWIZ_ROUTER_USEDD_TITLE,
  3859. IDS_NEWWIZ_ROUTER_USEDD_SUBTITLE);
  3860. }
  3861. void CNewRtrWizRouterUseDD::DoDataExchange(CDataExchange *pDX)
  3862. {
  3863. CNewRtrWizPageBase::DoDataExchange(pDX);
  3864. }
  3865. BEGIN_MESSAGE_MAP(CNewRtrWizRouterUseDD, CNewRtrWizPageBase)
  3866. END_MESSAGE_MAP()
  3867. /*!--------------------------------------------------------------------------
  3868. CNewRtrWizRouterUseDD::OnInitDialog
  3869. -
  3870. Author: KennT
  3871. ---------------------------------------------------------------------------*/
  3872. BOOL CNewRtrWizRouterUseDD::OnInitDialog()
  3873. {
  3874. CNewRtrWizPageBase::OnInitDialog();
  3875. CheckRadioButton(IDC_NEWWIZ_BTN_YES, IDC_NEWWIZ_BTN_NO,
  3876. m_pRtrWizData->m_fUseDD ? IDC_NEWWIZ_BTN_YES : IDC_NEWWIZ_BTN_NO);
  3877. // The default is to create a new connection
  3878. // That is, to leave the button unchecked.
  3879. return TRUE;
  3880. }
  3881. HRESULT CNewRtrWizRouterUseDD::OnSavePage()
  3882. {
  3883. m_pRtrWizData->m_fUseDD = IsDlgButtonChecked(IDC_NEWWIZ_BTN_YES);
  3884. return hrOK;
  3885. }
  3886. /*---------------------------------------------------------------------------
  3887. CNewRtrWizRouterFinish Implementation
  3888. ---------------------------------------------------------------------------*/
  3889. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRouterFinish,
  3890. SaveFlag_Advanced,
  3891. HelpFlag_Nothing);
  3892. /*---------------------------------------------------------------------------
  3893. CNewRtrWizRouterFinishDD Implementation
  3894. ---------------------------------------------------------------------------*/
  3895. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRouterFinishDD,
  3896. SaveFlag_Advanced,
  3897. HelpFlag_Nothing);
  3898. /*---------------------------------------------------------------------------
  3899. CNewRtrWizManualFinish Implementation
  3900. ---------------------------------------------------------------------------*/
  3901. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizManualFinish,
  3902. SaveFlag_Advanced,
  3903. HelpFlag_Nothing);
  3904. /*!--------------------------------------------------------------------------
  3905. InitializeInterfaceListControl
  3906. -
  3907. Author: KennT
  3908. ---------------------------------------------------------------------------*/
  3909. HRESULT InitializeInterfaceListControl(IRouterInfo *pRouter,
  3910. CListCtrl *pListCtrl,
  3911. LPCTSTR pszExcludedIf,
  3912. LPARAM flags,
  3913. NewRtrWizData *pWizData)
  3914. {
  3915. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  3916. HRESULT hr = hrOK;
  3917. LV_COLUMN lvCol; // list view column struct for radius servers
  3918. RECT rect;
  3919. CString stColCaption;
  3920. LV_ITEM lvItem;
  3921. int iPos;
  3922. CString st;
  3923. int nColWidth;
  3924. Assert(pListCtrl);
  3925. ListView_SetExtendedListViewStyle(pListCtrl->GetSafeHwnd(),
  3926. LVS_EX_FULLROWSELECT);
  3927. // Add the columns to the list control
  3928. pListCtrl->GetClientRect(&rect);
  3929. if (!FHrOK(pWizData->HrIsIPInstalled()))
  3930. flags |= IFLIST_FLAGS_NOIP;
  3931. // Determine the width of the columns (we assume three equal width columns)
  3932. if (flags & IFLIST_FLAGS_NOIP)
  3933. nColWidth = rect.right / (IFLISTCOL_COUNT - 1 );
  3934. else
  3935. nColWidth = rect.right / IFLISTCOL_COUNT;
  3936. lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
  3937. lvCol.fmt = LVCFMT_LEFT;
  3938. lvCol.cx = nColWidth;
  3939. for(int index = 0; index < IFLISTCOL_COUNT; index++)
  3940. {
  3941. // If IP is not installed, do not add the column
  3942. if ((index == IFLISTCOL_IPADDRESS) &&
  3943. (flags & IFLIST_FLAGS_NOIP))
  3944. continue;
  3945. stColCaption.LoadString( s_rgIfListColumnHeaders[index] );
  3946. lvCol.pszText = (LPTSTR)((LPCTSTR) stColCaption);
  3947. pListCtrl->InsertColumn(index, &lvCol);
  3948. }
  3949. return hr;
  3950. }
  3951. /*!--------------------------------------------------------------------------
  3952. RefreshInterfaceListControl
  3953. -
  3954. Author: KennT
  3955. ---------------------------------------------------------------------------*/
  3956. HRESULT RefreshInterfaceListControl(IRouterInfo *pRouter,
  3957. CListCtrl *pListCtrl,
  3958. LPCTSTR pszExcludedIf,
  3959. LPARAM flags,
  3960. NewRtrWizData *pWizData)
  3961. {
  3962. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  3963. HRESULT hr = hrOK;
  3964. LV_COLUMN lvCol; // list view column struct for radius servers
  3965. LV_ITEM lvItem;
  3966. int iPos;
  3967. CString st;
  3968. POSITION pos;
  3969. RtrWizInterface * pRtrWizIf;
  3970. Assert(pListCtrl);
  3971. // If a pointer to a blank string was passed in, set the
  3972. // pointer to NULL.
  3973. if (pszExcludedIf && (*pszExcludedIf == 0))
  3974. pszExcludedIf = NULL;
  3975. // Clear the list control
  3976. pListCtrl->DeleteAllItems();
  3977. // This means that we should use the test data, rather
  3978. // than the actual machine data
  3979. {
  3980. lvItem.mask = LVIF_TEXT | LVIF_PARAM;
  3981. lvItem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
  3982. lvItem.state = 0;
  3983. int nCount = 0;
  3984. pos = pWizData->m_ifMap.GetStartPosition();
  3985. while (pos)
  3986. {
  3987. pWizData->m_ifMap.GetNextAssoc(pos, st, pRtrWizIf);
  3988. if (pszExcludedIf &&
  3989. (pRtrWizIf->m_stId.CompareNoCase(pszExcludedIf) == 0))
  3990. continue;
  3991. lvItem.iItem = nCount;
  3992. lvItem.iSubItem = 0;
  3993. lvItem.pszText = (LPTSTR)(LPCTSTR) pRtrWizIf->m_stName;
  3994. lvItem.lParam = NULL; //same functionality as SetItemData()
  3995. iPos = pListCtrl->InsertItem(&lvItem);
  3996. if (iPos != -1)
  3997. {
  3998. pListCtrl->SetItemText(iPos, IFLISTCOL_NAME,
  3999. (LPCTSTR) pRtrWizIf->m_stName);
  4000. pListCtrl->SetItemText(iPos, IFLISTCOL_DESC,
  4001. (LPCTSTR) pRtrWizIf->m_stDesc);
  4002. if (FHrOK(pWizData->HrIsIPInstalled()))
  4003. {
  4004. CString stAddr;
  4005. stAddr = pRtrWizIf->m_stIpAddress;
  4006. if (pRtrWizIf->m_fDhcpObtained)
  4007. stAddr += _T(" (DHCP)");
  4008. pListCtrl->SetItemText(iPos, IFLISTCOL_IPADDRESS,
  4009. (LPCTSTR) stAddr);
  4010. }
  4011. pListCtrl->SetItemData(iPos,
  4012. (LPARAM) (LPCTSTR) pRtrWizIf->m_stId);
  4013. }
  4014. nCount++;
  4015. }
  4016. }
  4017. return hr;
  4018. }
  4019. /*!--------------------------------------------------------------------------
  4020. CallRouterEntryDlg
  4021. -
  4022. Author: KennT
  4023. ---------------------------------------------------------------------------*/
  4024. HRESULT CallRouterEntryDlg(HWND hWnd, NewRtrWizData *pWizData, LPARAM flags)
  4025. {
  4026. HRESULT hr = hrOK;
  4027. HINSTANCE hInstanceRasDlg = NULL;
  4028. PROUTERENTRYDLG pfnRouterEntry = NULL;
  4029. CString stRouter, stPhoneBook;
  4030. BOOL bStatus;
  4031. RASENTRYDLG info;
  4032. SPSZ spsz;
  4033. SPIInterfaceInfo spIf;
  4034. SPIInfoBase spInfoBase;
  4035. LPCTSTR pszServerName = pWizData->m_stServerName;
  4036. // Get the library (we are dynamically linking to the function).
  4037. // ----------------------------------------------------------------
  4038. hInstanceRasDlg = AfxLoadLibrary(_T("rasdlg.dll"));
  4039. if (hInstanceRasDlg == NULL)
  4040. CORg( E_FAIL );
  4041. pfnRouterEntry = (PROUTERENTRYDLG) ::GetProcAddress(hInstanceRasDlg,
  4042. SZROUTERENTRYDLG);
  4043. if (pfnRouterEntry == NULL)
  4044. CORg( E_FAIL );
  4045. // First create the phone book entry.
  4046. ZeroMemory( &info, sizeof(info) );
  4047. info.dwSize = sizeof(info);
  4048. info.hwndOwner = hWnd;
  4049. info.dwFlags |= RASEDFLAG_NewEntry;
  4050. stRouter = pszServerName;
  4051. IfAdminNodeHandler::GetPhoneBookPath(stRouter, &stPhoneBook);
  4052. if (stRouter.GetLength() == 0)
  4053. {
  4054. stRouter = CString(_T("\\\\")) + GetLocalMachineName();
  4055. }
  4056. bStatus = pfnRouterEntry((LPTSTR)(LPCTSTR)stRouter,
  4057. (LPTSTR)(LPCTSTR)stPhoneBook,
  4058. NULL,
  4059. &info);
  4060. Trace2("RouterEntryDlg=%f,e=%d\n", bStatus, info.dwError);
  4061. if (!bStatus)
  4062. {
  4063. if (info.dwError != NO_ERROR)
  4064. {
  4065. AddHighLevelErrorStringId(IDS_ERR_UNABLETOCONFIGPBK);
  4066. CWRg( info.dwError );
  4067. }
  4068. //$ ASSUMPTION
  4069. // If the dwError field has not been filled, we assume that
  4070. // the user cancelled out of the wizard.
  4071. CWRg( ERROR_CANCELLED );
  4072. }
  4073. // Ok, at this point we have an interface
  4074. // We need to add the IP/IPX routermangers to the interface
  4075. // Create a dummy InterfaceInfo
  4076. CORg( CreateInterfaceInfo(&spIf,
  4077. info.szEntry,
  4078. ROUTER_IF_TYPE_FULL_ROUTER) );
  4079. // This call to get the name doesn't matter (for now). The
  4080. // reason is that DD interfaces do not return GUIDs, but this
  4081. // will work when they do return a GUID.
  4082. // ----------------------------------------------------------------
  4083. hr = InterfaceInfo::FindInterfaceTitle(pszServerName,
  4084. info.szEntry,
  4085. &spsz);
  4086. if (!FHrOK(hr))
  4087. {
  4088. spsz.Free();
  4089. spsz = StrDup(info.szEntry);
  4090. }
  4091. CORg( spIf->SetTitle(spsz) );
  4092. CORg( spIf->SetMachineName(pszServerName) );
  4093. // Load an infobase for use by the routines
  4094. CORg( CreateInfoBase(&spInfoBase) );
  4095. if (info.reserved2 & RASNP_Ip)
  4096. {
  4097. AddIpPerInterfaceBlocks(spIf, spInfoBase);
  4098. // Save this back to the IP RmIf
  4099. RouterEntrySaveInfoBase(pszServerName,
  4100. spIf->GetId(),
  4101. spInfoBase,
  4102. PID_IP);
  4103. }
  4104. if (info.reserved2 & RASNP_Ipx)
  4105. {
  4106. // Remove anything that was loaded previously
  4107. spInfoBase->Unload();
  4108. AddIpxPerInterfaceBlocks(spIf, spInfoBase);
  4109. // Save this back to the IPX RmIf
  4110. RouterEntrySaveInfoBase(pszServerName,
  4111. spIf->GetId(),
  4112. spInfoBase,
  4113. PID_IPX);
  4114. }
  4115. // ok, setup the public interface
  4116. Assert(pWizData->m_stPublicInterfaceId.IsEmpty());
  4117. pWizData->m_stPublicInterfaceId = spIf->GetTitle();
  4118. Error:
  4119. if (!FHrSucceeded(hr) && (hr != HRESULT_FROM_WIN32(ERROR_CANCELLED)))
  4120. {
  4121. TCHAR szErr[2048] = _T(" ");
  4122. if (hr != E_FAIL) // E_FAIL doesn't give user any information
  4123. {
  4124. FormatRasError(hr, szErr, DimensionOf(szErr));
  4125. }
  4126. AddLowLevelErrorString(szErr);
  4127. // If there is no high level error string, add a
  4128. // generic error string. This will be used if no other
  4129. // high level error string is set.
  4130. SetDefaultHighLevelErrorStringId(IDS_ERR_GENERIC_ERROR);
  4131. DisplayTFSErrorMessage(NULL);
  4132. }
  4133. if (hInstanceRasDlg)
  4134. ::FreeLibrary(hInstanceRasDlg);
  4135. return hr;
  4136. }
  4137. /*!--------------------------------------------------------------------------
  4138. RouterEntrySaveInfoBase
  4139. -
  4140. Author: KennT
  4141. ---------------------------------------------------------------------------*/
  4142. HRESULT RouterEntrySaveInfoBase(LPCTSTR pszServerName,
  4143. LPCTSTR pszIfName,
  4144. IInfoBase *pInfoBase,
  4145. DWORD dwTransportId)
  4146. {
  4147. HRESULT hr = hrOK;
  4148. MPR_SERVER_HANDLE hMprServer = NULL;
  4149. HANDLE hInterface = NULL;
  4150. DWORD dwErr = ERROR_SUCCESS;
  4151. MPR_INTERFACE_0 mprInterface;
  4152. LPBYTE pInfoData = NULL;
  4153. DWORD dwInfoSize = 0;
  4154. MPR_CONFIG_HANDLE hMprConfig = NULL;
  4155. HANDLE hIfTransport = NULL;
  4156. Assert(pInfoBase);
  4157. // Convert the infobase into a byte array
  4158. // ----------------------------------------------------------------
  4159. CWRg( pInfoBase->WriteTo(&pInfoData, &dwInfoSize) );
  4160. // Connect to the server
  4161. // ----------------------------------------------------------------
  4162. dwErr = MprAdminServerConnect((LPWSTR) pszServerName, &hMprServer);
  4163. if (dwErr == ERROR_SUCCESS)
  4164. {
  4165. // Get a handle to the interface
  4166. // ------------------------------------------------------------
  4167. dwErr = MprAdminInterfaceGetHandle(hMprServer,
  4168. (LPWSTR) pszIfName,
  4169. &hInterface,
  4170. FALSE);
  4171. if (dwErr != ERROR_SUCCESS)
  4172. {
  4173. // We couldn't get a handle the interface, so let's try
  4174. // to create the interface.
  4175. // --------------------------------------------------------
  4176. ZeroMemory(&mprInterface, sizeof(mprInterface));
  4177. StrCpyWFromT(mprInterface.wszInterfaceName, pszIfName);
  4178. mprInterface.dwIfType = ROUTER_IF_TYPE_FULL_ROUTER;
  4179. mprInterface.fEnabled = TRUE;
  4180. CWRg( MprAdminInterfaceCreate(hMprServer,
  4181. 0,
  4182. (LPBYTE) &mprInterface,
  4183. &hInterface) );
  4184. }
  4185. // Try to write the info out
  4186. // ------------------------------------------------------------
  4187. dwErr = MprAdminInterfaceTransportSetInfo(hMprServer,
  4188. hInterface,
  4189. dwTransportId,
  4190. pInfoData,
  4191. dwInfoSize);
  4192. if (dwErr != NO_ERROR && dwErr != RPC_S_SERVER_UNAVAILABLE)
  4193. {
  4194. // Attempt to add the router-manager on the interface
  4195. // --------------------------------------------------------
  4196. dwErr = ::MprAdminInterfaceTransportAdd(hMprServer,
  4197. hInterface,
  4198. dwTransportId,
  4199. pInfoData,
  4200. dwInfoSize);
  4201. CWRg( dwErr );
  4202. }
  4203. }
  4204. // Ok, now that we've written the info out to the running router,
  4205. // let's try to write the info to the store.
  4206. // ----------------------------------------------------------------
  4207. dwErr = MprConfigServerConnect((LPWSTR) pszServerName, &hMprConfig);
  4208. if (dwErr == ERROR_SUCCESS)
  4209. {
  4210. dwErr = MprConfigInterfaceGetHandle(hMprConfig,
  4211. (LPWSTR) pszIfName,
  4212. &hInterface);
  4213. if (dwErr != ERROR_SUCCESS)
  4214. {
  4215. // We couldn't get a handle the interface, so let's try
  4216. // to create the interface.
  4217. // --------------------------------------------------------
  4218. ZeroMemory(&mprInterface, sizeof(mprInterface));
  4219. StrCpyWFromT(mprInterface.wszInterfaceName, pszIfName);
  4220. mprInterface.dwIfType = ROUTER_IF_TYPE_FULL_ROUTER;
  4221. mprInterface.fEnabled = TRUE;
  4222. CWRg( MprConfigInterfaceCreate(hMprConfig,
  4223. 0,
  4224. (LPBYTE) &mprInterface,
  4225. &hInterface) );
  4226. }
  4227. dwErr = MprConfigInterfaceTransportGetHandle(hMprConfig,
  4228. hInterface,
  4229. dwTransportId,
  4230. &hIfTransport);
  4231. if (dwErr != ERROR_SUCCESS)
  4232. {
  4233. CWRg( MprConfigInterfaceTransportAdd(hMprConfig,
  4234. hInterface,
  4235. dwTransportId,
  4236. NULL,
  4237. pInfoData,
  4238. dwInfoSize,
  4239. &hIfTransport) );
  4240. }
  4241. else
  4242. {
  4243. CWRg( MprConfigInterfaceTransportSetInfo(hMprConfig,
  4244. hInterface,
  4245. hIfTransport,
  4246. pInfoData,
  4247. dwInfoSize) );
  4248. }
  4249. }
  4250. Error:
  4251. if (hMprConfig)
  4252. MprConfigServerDisconnect(hMprConfig);
  4253. if (hMprServer)
  4254. MprAdminServerDisconnect(hMprServer);
  4255. if (pInfoData)
  4256. CoTaskMemFree(pInfoData);
  4257. return hr;
  4258. }
  4259. /*!--------------------------------------------------------------------------
  4260. RouterEntryLoadInfoBase
  4261. This will load the RtrMgrInterfaceInfo infobase.
  4262. Author: KennT
  4263. ---------------------------------------------------------------------------*/
  4264. HRESULT RouterEntryLoadInfoBase(LPCTSTR pszServerName,
  4265. LPCTSTR pszIfName,
  4266. DWORD dwTransportId,
  4267. IInfoBase *pInfoBase)
  4268. {
  4269. HRESULT hr = hrOK;
  4270. MPR_SERVER_HANDLE hMprServer = NULL;
  4271. HANDLE hInterface = NULL;
  4272. DWORD dwErr = ERROR_SUCCESS;
  4273. MPR_INTERFACE_0 mprInterface;
  4274. LPBYTE pByte = NULL;
  4275. DWORD dwSize = 0;
  4276. MPR_CONFIG_HANDLE hMprConfig = NULL;
  4277. HANDLE hIfTransport = NULL;
  4278. Assert(pInfoBase);
  4279. // Connect to the server
  4280. // ----------------------------------------------------------------
  4281. dwErr = MprAdminServerConnect((LPWSTR) pszServerName, &hMprServer);
  4282. if (dwErr == ERROR_SUCCESS)
  4283. {
  4284. // Get a handle to the interface
  4285. // ------------------------------------------------------------
  4286. dwErr = MprAdminInterfaceGetHandle(hMprServer,
  4287. (LPWSTR) pszIfName,
  4288. &hInterface,
  4289. FALSE);
  4290. if (dwErr != ERROR_SUCCESS)
  4291. {
  4292. // We couldn't get a handle the interface, so let's try
  4293. // to create the interface.
  4294. // --------------------------------------------------------
  4295. ZeroMemory(&mprInterface, sizeof(mprInterface));
  4296. StrCpyWFromT(mprInterface.wszInterfaceName, pszIfName);
  4297. mprInterface.dwIfType = ROUTER_IF_TYPE_FULL_ROUTER;
  4298. mprInterface.fEnabled = TRUE;
  4299. CWRg( MprAdminInterfaceCreate(hMprServer,
  4300. 0,
  4301. (LPBYTE) &mprInterface,
  4302. &hInterface) );
  4303. }
  4304. // Try to read the info
  4305. // ------------------------------------------------------------
  4306. dwErr = MprAdminInterfaceTransportGetInfo(hMprServer,
  4307. hInterface,
  4308. dwTransportId,
  4309. &pByte,
  4310. &dwSize);
  4311. if (dwErr == ERROR_SUCCESS)
  4312. pInfoBase->LoadFrom(dwSize, pByte);
  4313. if (pByte)
  4314. MprAdminBufferFree(pByte);
  4315. pByte = NULL;
  4316. dwSize = 0;
  4317. }
  4318. if (dwErr != ERROR_SUCCESS)
  4319. {
  4320. // Ok, we've tried to use the running router but that
  4321. // failed, let's try to read the info from the store.
  4322. // ----------------------------------------------------------------
  4323. dwErr = MprConfigServerConnect((LPWSTR) pszServerName, &hMprConfig);
  4324. if (dwErr == ERROR_SUCCESS)
  4325. {
  4326. dwErr = MprConfigInterfaceGetHandle(hMprConfig,
  4327. (LPWSTR) pszIfName,
  4328. &hInterface);
  4329. if (dwErr != ERROR_SUCCESS)
  4330. {
  4331. // We couldn't get a handle the interface, so let's try
  4332. // to create the interface.
  4333. // --------------------------------------------------------
  4334. ZeroMemory(&mprInterface, sizeof(mprInterface));
  4335. StrCpyWFromT(mprInterface.wszInterfaceName, pszIfName);
  4336. mprInterface.dwIfType = ROUTER_IF_TYPE_FULL_ROUTER;
  4337. mprInterface.fEnabled = TRUE;
  4338. CWRg( MprConfigInterfaceCreate(hMprConfig,
  4339. 0,
  4340. (LPBYTE) &mprInterface,
  4341. &hInterface) );
  4342. }
  4343. CWRg( MprConfigInterfaceTransportGetHandle(hMprConfig,
  4344. hInterface,
  4345. dwTransportId,
  4346. &hIfTransport) );
  4347. CWRg( MprConfigInterfaceTransportGetInfo(hMprConfig,
  4348. hInterface,
  4349. hIfTransport,
  4350. &pByte,
  4351. &dwSize) );
  4352. pInfoBase->LoadFrom(dwSize, pByte);
  4353. if (pByte)
  4354. MprConfigBufferFree(pByte);
  4355. pByte = NULL;
  4356. dwSize = 0;
  4357. }
  4358. }
  4359. CWRg(dwErr);
  4360. Error:
  4361. if (hMprConfig)
  4362. MprConfigServerDisconnect(hMprConfig);
  4363. if (hMprServer)
  4364. MprAdminServerDisconnect(hMprServer);
  4365. return hr;
  4366. }
  4367. /*!--------------------------------------------------------------------------
  4368. LaunchHelpTopic
  4369. -
  4370. Author: KennT
  4371. ---------------------------------------------------------------------------*/
  4372. void LaunchHelpTopic(LPCTSTR pszHelpString)
  4373. {
  4374. TCHAR szBuffer[1024];
  4375. CString st;
  4376. STARTUPINFO si;
  4377. PROCESS_INFORMATION pi;
  4378. if ((pszHelpString == NULL) || (*pszHelpString == 0))
  4379. return;
  4380. ::ZeroMemory(&si, sizeof(STARTUPINFO));
  4381. si.cb = sizeof(STARTUPINFO);
  4382. si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
  4383. si.wShowWindow = SW_SHOW;
  4384. ::ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
  4385. ExpandEnvironmentStrings(pszHelpString,
  4386. szBuffer,
  4387. DimensionOf(szBuffer));
  4388. st.Format(_T("hh.exe %s"), pszHelpString);
  4389. ::CreateProcess(NULL, // ptr to name of executable
  4390. (LPTSTR) (LPCTSTR) st, // pointer to command line string
  4391. NULL, // process security attributes
  4392. NULL, // thread security attributes
  4393. FALSE, // handle inheritance flag
  4394. CREATE_NEW_CONSOLE,// creation flags
  4395. NULL, // ptr to new environment block
  4396. NULL, // ptr to current directory name
  4397. &si,
  4398. &pi);
  4399. ::CloseHandle(pi.hProcess);
  4400. ::CloseHandle(pi.hThread);
  4401. }
  4402. #define REGKEY_NETBT_PARAM_W L"System\\CurrentControlSet\\Services\\NetBT\\Parameters\\Interfaces\\Tcpip_%s"
  4403. #define REGVAL_DISABLE_NETBT 2
  4404. #define TCPIP_PARAMETERS_KEY L"System\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%s"
  4405. #define REGISTRATION_ENABLED L"RegistrationEnabled"
  4406. #define REGVAL_NETBIOSOPTIONS_W L"NetbiosOptions"
  4407. HRESULT DisableDDNSandNetBtOnInterface ( IRouterInfo *pRouter, LPCTSTR pszIfName, RtrWizInterface* pIf)
  4408. {
  4409. HRESULT hr = hrOK;
  4410. DWORD dwErr = ERROR_SUCCESS;
  4411. RegKey regkey;
  4412. DWORD dw = 0;
  4413. WCHAR szKey[1024] = {0};
  4414. //SPIRouter spRouter = pRouter;
  4415. wsprintf ( szKey, TCPIP_PARAMETERS_KEY, pszIfName);
  4416. //Disable Dynamic DNS
  4417. dwErr = regkey.Open( HKEY_LOCAL_MACHINE,
  4418. szKey,
  4419. KEY_ALL_ACCESS,
  4420. pRouter->GetMachineName()
  4421. );
  4422. if ( ERROR_SUCCESS != dwErr )
  4423. goto done;
  4424. dwErr = regkey.SetValue ( REGISTRATION_ENABLED, dw );
  4425. if ( ERROR_SUCCESS != dwErr )
  4426. goto done;
  4427. dwErr = regkey.Close();
  4428. if ( ERROR_SUCCESS != dwErr )
  4429. goto done;
  4430. //Disable netbt on this interface
  4431. wsprintf ( szKey, REGKEY_NETBT_PARAM_W, pszIfName );
  4432. dwErr = regkey.Open ( HKEY_LOCAL_MACHINE,
  4433. szKey,
  4434. KEY_ALL_ACCESS,
  4435. pRouter->GetMachineName()
  4436. );
  4437. if ( ERROR_SUCCESS != dwErr )
  4438. goto done;
  4439. dw = REGVAL_DISABLE_NETBT;
  4440. dwErr = regkey.SetValue ( REGVAL_NETBIOSOPTIONS_W, dw );
  4441. if ( ERROR_SUCCESS != dwErr )
  4442. goto done;
  4443. done:
  4444. regkey.Close();
  4445. return hr;
  4446. }
  4447. /*!--------------------------------------------------------------------------
  4448. AddVPNFiltersToInterface
  4449. This will the PPTP and L2TP filters to the public interface.
  4450. This code will OVERWRITE any filters currently in the filter list.
  4451. (for PPTP)
  4452. input/output IP protocol ID 47
  4453. input/output TCP source port 1723
  4454. input/output TCP destination port 1723
  4455. (for L2TP)
  4456. input/output UDP port 500 (for IPSEC)
  4457. input/output UDP port 1701
  4458. Author: KennT
  4459. ---------------------------------------------------------------------------*/
  4460. // Look at the code below. After copying the filter over, we will
  4461. // convert the source/dest port fields from host to network order!!
  4462. static const FILTER_INFO s_rgVpnFilters[] =
  4463. {
  4464. // PPTP filter (protocol ID 47)
  4465. { 0, 0, 0, 0, 47, 0, 0, 0 },
  4466. // PPTP filter (source port 1723)
  4467. { 0, 0, 0, 0, FILTER_PROTO_TCP, 0, 1723, 0 },
  4468. // PPTP filter (dest port 1723)
  4469. { 0, 0, 0, 0, FILTER_PROTO_TCP, 0, 0, 1723 },
  4470. // L2TP filter source/dest port = 500
  4471. { 0, 0, 0, 0, FILTER_PROTO_UDP, 0, 500, 500 },
  4472. // L2TP filter source/dest port = 1701
  4473. { 0, 0, 0, 0, FILTER_PROTO_UDP, 0, 1701, 1701 }
  4474. };
  4475. HRESULT AddVPNFiltersToInterface(IRouterInfo *pRouter, LPCTSTR pszIfName, RtrWizInterface* pIf)
  4476. {
  4477. HRESULT hr = hrOK;
  4478. SPIInfoBase spInfoBase;
  4479. DWORD dwSize = 0;
  4480. DWORD cFilters = 0;
  4481. DWORD dwIpAddress = 0;
  4482. LPBYTE pData = NULL;
  4483. FILTER_DESCRIPTOR * pIpfDescriptor = NULL;
  4484. CString tempAddrList;
  4485. CString singleAddr;
  4486. FILTER_INFO *pIpfInfo = NULL;
  4487. CDWordArray arrIpAddr;
  4488. int i, j;
  4489. USES_CONVERSION;
  4490. CORg( CreateInfoBase( &spInfoBase ) );
  4491. // First, get the proper infobase (the RmIf)
  4492. // ----------------------------------------------------------------
  4493. CORg( RouterEntryLoadInfoBase(pRouter->GetMachineName(),
  4494. pszIfName,
  4495. PID_IP,
  4496. spInfoBase) );
  4497. // collect all the ip addresses on the interface
  4498. tempAddrList = pIf->m_stIpAddress;
  4499. while (!tempAddrList.IsEmpty())
  4500. {
  4501. i = tempAddrList.Find(_T(','));
  4502. if ( i != -1 )
  4503. {
  4504. singleAddr = tempAddrList.Left(i);
  4505. tempAddrList = tempAddrList.Mid(i + 1);
  4506. }
  4507. else
  4508. {
  4509. singleAddr = tempAddrList;
  4510. tempAddrList.Empty();
  4511. }
  4512. dwIpAddress = inet_addr(T2A((LPCTSTR)singleAddr));
  4513. if (INADDR_NONE != dwIpAddress) // successful
  4514. arrIpAddr.Add(dwIpAddress);
  4515. }
  4516. // Setup the data structure
  4517. // ----------------------------------------------------------------
  4518. // Calculate the size needed
  4519. // ----------------------------------------------------------------
  4520. cFilters = DimensionOf(s_rgVpnFilters);
  4521. // cFilters-1 because FILTER_DESCRIPTOR has one FILTER_INFO object
  4522. // ----------------------------------------------------------------
  4523. dwSize = sizeof(FILTER_DESCRIPTOR) +
  4524. (cFilters * arrIpAddr.GetSize() - 1) * sizeof(FILTER_INFO);
  4525. pData = new BYTE[dwSize];
  4526. ::ZeroMemory(pData, dwSize);
  4527. // Setup the filter descriptor
  4528. // ----------------------------------------------------------------
  4529. pIpfDescriptor = (FILTER_DESCRIPTOR *) pData;
  4530. pIpfDescriptor->faDefaultAction = DROP;
  4531. pIpfDescriptor->dwNumFilters = cFilters * arrIpAddr.GetSize();
  4532. pIpfDescriptor->dwVersion = IP_FILTER_DRIVER_VERSION_1;
  4533. // Add the various filters to the list
  4534. // input filters
  4535. pIpfInfo = (FILTER_INFO *) pIpfDescriptor->fiFilter;
  4536. // for each ip address on the interface
  4537. for ( j = 0; j < arrIpAddr.GetSize(); j++)
  4538. {
  4539. dwIpAddress = arrIpAddr.GetAt(j);
  4540. for (i=0; i<cFilters; i++, pIpfInfo++)
  4541. {
  4542. *pIpfInfo = s_rgVpnFilters[i];
  4543. // Now we convert the appropriate fields from host to
  4544. // network order.
  4545. pIpfInfo->wSrcPort = htons(pIpfInfo->wSrcPort);
  4546. pIpfInfo->wDstPort = htons(pIpfInfo->wDstPort);
  4547. // change dest address and mask
  4548. pIpfInfo->dwDstAddr = dwIpAddress;
  4549. pIpfInfo->dwDstMask = 0xffffffff;
  4550. }
  4551. // inet_addr
  4552. }
  4553. // This will overwrite any of the current filters in the
  4554. // filter list.
  4555. // ----------------------------------------------------------------
  4556. CORg( spInfoBase->AddBlock(IP_IN_FILTER_INFO, dwSize, pData, 1, TRUE) );
  4557. // output filters
  4558. // ----------------------------------------------------------------
  4559. pIpfInfo = (FILTER_INFO *) pIpfDescriptor->fiFilter;
  4560. // for each ip address on the interface
  4561. for ( j = 0; j < arrIpAddr.GetSize(); j++)
  4562. {
  4563. dwIpAddress = arrIpAddr.GetAt(j);
  4564. for (i=0; i<cFilters; i++, pIpfInfo++)
  4565. {
  4566. *pIpfInfo = s_rgVpnFilters[i];
  4567. // Now we convert the appropriate fields from host to
  4568. // network order.
  4569. pIpfInfo->wSrcPort = htons(pIpfInfo->wSrcPort);
  4570. pIpfInfo->wDstPort = htons(pIpfInfo->wDstPort);
  4571. // change source address and mask
  4572. pIpfInfo->dwSrcAddr = dwIpAddress;
  4573. pIpfInfo->dwSrcMask = 0xffffffff;
  4574. }
  4575. } // loop for each ip address on the interface
  4576. // This will overwrite any of the current filters in the
  4577. // filter list.
  4578. // ----------------------------------------------------------------
  4579. CORg( spInfoBase->AddBlock(IP_OUT_FILTER_INFO, dwSize, pData, 1, TRUE) );
  4580. // Save the infobase back
  4581. // ----------------------------------------------------------------
  4582. CORg( RouterEntrySaveInfoBase(pRouter->GetMachineName(),
  4583. pszIfName,
  4584. spInfoBase,
  4585. PID_IP) );
  4586. Error:
  4587. delete [] pData;
  4588. return hr;
  4589. }