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

7287 lines
232 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. #include "rrasqry.h"
  24. #define _USTRINGP_NO_UNICODE_STRING
  25. #include "ustringp.h"
  26. #include <ntddip.h> // to resolve ipfltdrv dependancies
  27. #include "ipfltdrv.h" // for the filter stuff
  28. #include "raputil.h" // for UpdateDefaultPolicy
  29. #include "iphlpapi.h"
  30. #include "dnsapi.h" // for dns stuff
  31. extern "C" {
  32. #define _NOUIUTIL_H_
  33. #include "dtl.h"
  34. #include "pbuser.h"
  35. #include "shlobjp.h"
  36. };
  37. extern BOOL WINAPI LinkWindow_RegisterClass();
  38. WATERMARKINFO g_wmi = {0};
  39. #ifdef UNICODE
  40. #define SZROUTERENTRYDLG "RouterEntryDlgW"
  41. #else
  42. #define SZROUTERENTRYDLG "RouterEntryDlgA"
  43. #endif
  44. // Useful functions
  45. // defines for the flags parameter
  46. HRESULT CallRouterEntryDlg(HWND hWnd, NewRtrWizData *pWizData, LPARAM flags);
  47. HRESULT RouterEntryLoadInfoBase(LPCTSTR pszServerName,
  48. LPCTSTR pszIfName,
  49. DWORD dwTransportId,
  50. IInfoBase *pInfoBase);
  51. HRESULT RouterEntrySaveInfoBase(LPCTSTR pszServerName,
  52. LPCTSTR pszIfName,
  53. IInfoBase *pInfoBase,
  54. DWORD dwTransportId);
  55. void LaunchHelpTopic(LPCTSTR pszHelpString);
  56. HRESULT AddVPNFiltersToInterface(IRouterInfo *pRouter, LPCTSTR pszIfId, RtrWizInterface* pIf);
  57. HRESULT DisableDDNSandNetBtOnInterface ( IRouterInfo *pRouter, LPCTSTR pszIfName, RtrWizInterface* pIf);
  58. // This is the command line that I use to launch the Connections UI shell
  59. const TCHAR s_szConnectionUICommandLine[] =
  60. _T("\"%SystemRoot%\\explorer.exe\" ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007acc7-3202-11d1-aad2-00805fc1270e}");
  61. // Help strings
  62. const TCHAR s_szHowToAddICS[] =
  63. _T("%systemdir%\\help\\netcfg.chm::/howto_share_conn.htm");
  64. const TCHAR s_szHowToAddAProtocol[] =
  65. _T("%systemdir%\\help\\netcfg.chm::/HowTo_Add_Component.htm");
  66. const TCHAR s_szHowToAddInboundConnections[] =
  67. _T("%systemdir%\\help\\netcfg.chm::/howto_conn_incoming.htm");
  68. const TCHAR s_szGeneralNATHelp[] =
  69. _T("%systemdir%\\help\\RRASconcepts.chm::/sag_RRAS-Ch3_06b.htm");
  70. const TCHAR s_szGeneralRASHelp[] =
  71. _T("%systemdir%\\help\\RRASconcepts.chm::/sag_RRAS-Ch1_1.htm");
  72. const TCHAR s_szUserAccounts[] =
  73. _T("%systemdir%\\help\\RRASconcepts.chm::/sag_RRAS-Ch1_46.htm");
  74. const TCHAR s_szDhcp[] =
  75. _T("%systemdir%\\help\\dhcpconcepts.chm");
  76. const TCHAR s_szDemandDialHelp[] =
  77. _T("%systemdir%\\help\\RRASconcepts.chm::/sag_RRAS-Ch3_08d.htm");
  78. /*---------------------------------------------------------------------------
  79. This enum defines the columns for the Interface list controls.
  80. ---------------------------------------------------------------------------*/
  81. enum
  82. {
  83. IFLISTCOL_NAME = 0,
  84. IFLISTCOL_DESC,
  85. IFLISTCOL_IPADDRESS,
  86. IFLISTCOL_COUNT
  87. };
  88. // This array must match the column indices above
  89. INT s_rgIfListColumnHeaders[] =
  90. {
  91. IDS_IFLIST_COL_NAME,
  92. IDS_IFLIST_COL_DESC,
  93. IDS_IFLIST_COL_IPADDRESS,
  94. 0
  95. };
  96. /*
  97. IsIcsIcfIcEnabled: This fucntion returns TRUE if ICS (connection sharing) or
  98. ICF (connection firewall) or IC (incoming connections) is enabled on the machine
  99. author: kmurthy
  100. */
  101. BOOL IsIcsIcfIcEnabled(IRouterInfo * spRouterInfo, BOOL suppressMesg)
  102. {
  103. HRESULT hr = hrOK;
  104. COSERVERINFO csi;
  105. COAUTHINFO cai;
  106. COAUTHIDENTITY caid;
  107. SPIRemoteICFICSConfig spConfig;
  108. IUnknown * punk = NULL;
  109. BOOL fwEnabled=FALSE, csEnabled=FALSE, icEnabled = FALSE;
  110. RegKey regkey;
  111. CString szKey = "SYSTEM\\CurrentControlSet\\Services\\RemoteAccess\\Parameters";
  112. CString szValue = "IcConfigured";
  113. CString szMachineName;
  114. DWORD dwErr, szResult=0;
  115. ZeroMemory(&csi, sizeof(csi));
  116. ZeroMemory(&cai, sizeof(cai));
  117. ZeroMemory(&caid, sizeof(caid));
  118. csi.pAuthInfo = &cai;
  119. cai.pAuthIdentityData = &caid;
  120. szMachineName = spRouterInfo->GetMachineName();
  121. // Create the remote config object
  122. hr = CoCreateRouterConfig(szMachineName ,
  123. spRouterInfo,
  124. &csi,
  125. IID_IRemoteICFICSConfig,
  126. &punk);
  127. if (FHrOK(hr))
  128. {
  129. spConfig = (IRemoteICFICSConfig *)punk;
  130. punk = NULL;
  131. //Is ICF enabled?
  132. hr = spConfig->GetIcfEnabled(&fwEnabled);
  133. if(FHrOK(hr))
  134. {
  135. if(fwEnabled) {
  136. if(!suppressMesg){
  137. CString stErr, st;
  138. stErr.LoadString(IDS_NEWWIZ_ICF_ERROR);
  139. st.Format(stErr, ((szMachineName.GetLength() == 0) ? GetLocalMachineName() : szMachineName));
  140. AfxMessageBox(st);
  141. }
  142. spConfig->Release();
  143. return TRUE;
  144. }
  145. }
  146. //Is ICS enabled?
  147. hr = spConfig->GetIcsEnabled(&csEnabled);
  148. if(FHrOK(hr))
  149. {
  150. if(csEnabled) {
  151. if(!suppressMesg){
  152. CString stErr, st;
  153. stErr.LoadString(IDS_NEWWIZ_ICS_ERROR);
  154. st.Format(stErr, ((szMachineName.GetLength() == 0) ? GetLocalMachineName() : szMachineName));
  155. AfxMessageBox(st);
  156. }
  157. spConfig->Release();
  158. return TRUE;
  159. }
  160. }
  161. }
  162. //Now check to see if IC is enabled
  163. dwErr = regkey.Open( HKEY_LOCAL_MACHINE,
  164. szKey,
  165. KEY_QUERY_VALUE,
  166. szMachineName
  167. );
  168. if ( ERROR_SUCCESS == dwErr ){
  169. dwErr = regkey.QueryValue( szValue, szResult);
  170. if(ERROR_SUCCESS == dwErr ){
  171. if(szResult == 1){
  172. //IC is enabled!
  173. if(!suppressMesg){
  174. CString stErr, st;
  175. stErr.LoadString(IDS_NEWWIZ_IC_ERROR);
  176. st.Format(stErr, ((szMachineName.GetLength() == 0) ? GetLocalMachineName() : szMachineName));
  177. AfxMessageBox(st);
  178. }
  179. regkey.Close();
  180. return TRUE;
  181. }
  182. }
  183. }
  184. regkey.Close();
  185. return FALSE;
  186. }
  187. /*!--------------------------------------------------------------------------
  188. MachineHandler::OnNewRtrRASConfigWiz
  189. -
  190. Author: KennT
  191. ---------------------------------------------------------------------------*/
  192. HRESULT MachineHandler::OnNewRtrRASConfigWiz(ITFSNode *pNode, BOOL fTest)
  193. {
  194. Assert(pNode);
  195. HRESULT hr = hrOK;
  196. CString strRtrWizTitle;
  197. SPIComponentData spComponentData;
  198. COSERVERINFO csi;
  199. COAUTHINFO cai;
  200. COAUTHIDENTITY caid;
  201. SPIRemoteNetworkConfig spNetwork;
  202. IUnknown * punk = NULL;
  203. CNewRtrWiz * pRtrWiz = NULL;
  204. DWORD dwErr, szResult=0;
  205. CString szMachineName;
  206. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  207. szMachineName = m_spRouterInfo->GetMachineName();
  208. //kmurthy: We should not let the wizard run, if ICF/ICS/IC is already enabled on the machine
  209. if(IsIcsIcfIcEnabled(m_spRouterInfo)){
  210. return S_FALSE;
  211. }
  212. // Windows NT Bug : 407878
  213. // We need to reset the registry information (to ensure
  214. // that it is reasonably accurate).
  215. // ----------------------------------------------------------------
  216. ZeroMemory(&csi, sizeof(csi));
  217. ZeroMemory(&cai, sizeof(cai));
  218. ZeroMemory(&caid, sizeof(caid));
  219. csi.pAuthInfo = &cai;
  220. cai.pAuthIdentityData = &caid;
  221. // Create the remote config object
  222. // ----------------------------------------------------------------
  223. hr = CoCreateRouterConfig(szMachineName ,
  224. m_spRouterInfo,
  225. &csi,
  226. IID_IRemoteNetworkConfig,
  227. &punk);
  228. if (FHrOK(hr))
  229. {
  230. spNetwork = (IRemoteNetworkConfig *) punk;
  231. punk = NULL;
  232. // Upgrade the configuration (ensure that the registry keys
  233. // are populated correctly).
  234. // ------------------------------------------------------------
  235. spNetwork->UpgradeRouterConfig();
  236. }
  237. hr = SecureRouterInfo(pNode, TRUE /* fShowUI */);
  238. if(FAILED(hr)) return hr;
  239. m_spNodeMgr->GetComponentData(&spComponentData);
  240. strRtrWizTitle.LoadString(IDS_MENU_RTRWIZ);
  241. //Load the watermark and
  242. //set it in m_spTFSCompData
  243. InitWatermarkInfo(AfxGetInstanceHandle(),
  244. &g_wmi,
  245. IDB_WIZBANNER, // Header ID
  246. IDB_WIZWATERMARK, // Watermark ID
  247. NULL, // hPalette
  248. FALSE); // bStretch
  249. m_spTFSCompData->SetWatermarkInfo(&g_wmi);
  250. //
  251. //we dont have to free handles. MMC does it for us
  252. //
  253. pRtrWiz = new CNewRtrWiz(pNode,
  254. m_spRouterInfo,
  255. spComponentData,
  256. m_spTFSCompData,
  257. strRtrWizTitle);
  258. if (fTest)
  259. {
  260. // Pure TEST code
  261. if (!FHrOK(pRtrWiz->QueryForTestData()))
  262. {
  263. delete pRtrWiz;
  264. return S_FALSE;
  265. }
  266. }
  267. if ( FAILED(pRtrWiz->Init( szMachineName )) )
  268. {
  269. delete pRtrWiz;
  270. return S_FALSE;
  271. }
  272. else
  273. {
  274. return pRtrWiz->DoModalWizard();
  275. }
  276. if (csi.pAuthInfo)
  277. delete csi.pAuthInfo->pAuthIdentityData->Password;
  278. return hr;
  279. }
  280. NewRtrWizData::~NewRtrWizData()
  281. {
  282. POSITION pos;
  283. CString st;
  284. RtrWizInterface * pRtrWizIf;
  285. pos = m_ifMap.GetStartPosition();
  286. while (pos)
  287. {
  288. m_ifMap.GetNextAssoc(pos, st, pRtrWizIf);
  289. delete pRtrWizIf;
  290. }
  291. m_ifMap.RemoveAll();
  292. // Clear out the RADIUS secret
  293. ::SecureZeroMemory(m_stRadiusSecret.GetBuffer(0),
  294. m_stRadiusSecret.GetLength() * sizeof(TCHAR));
  295. m_stRadiusSecret.ReleaseBuffer(-1);
  296. }
  297. /*!--------------------------------------------------------------------------
  298. NewRtrWizData::Init
  299. -
  300. Author: KennT
  301. ---------------------------------------------------------------------------*/
  302. HRESULT NewRtrWizData::Init(LPCTSTR pszServerName, IRouterInfo *pRouter, DWORD dwExpressType)
  303. {
  304. DWORD dwServiceStatus = 0;
  305. DWORD dwErrorCode = 0;
  306. m_stServerName = pszServerName;
  307. m_dwExpressType = dwExpressType;
  308. // Initialize internal wizard data
  309. m_RtrConfigData.Init(pszServerName, pRouter);
  310. m_RtrConfigData.m_fIpSetup = TRUE;
  311. // Move some of the RtrConfigData info over
  312. m_fIpInstalled = m_RtrConfigData.m_fUseIp;
  313. m_fIpxInstalled = m_RtrConfigData.m_fUseIpx;
  314. m_fNbfInstalled = m_RtrConfigData.m_fUseNbf;
  315. m_fAppletalkInstalled = m_RtrConfigData.m_fUseArap;
  316. m_fIpInUse = m_fIpInstalled;
  317. m_fIpxInUse = m_fIpxInstalled;
  318. m_fAppletalkInUse = m_fAppletalkInstalled;
  319. m_fNbfInUse = m_fNbfInstalled;
  320. // Test the server to see if DNS/DHCP is installed
  321. m_fIsDNSRunningOnServer = FALSE;
  322. m_fIsDHCPRunningOnServer = FALSE;
  323. // Get the status of the DHCP service
  324. // ----------------------------------------------------------------
  325. if (FHrSucceeded(TFSGetServiceStatus(pszServerName,
  326. _T("DHCPServer"),
  327. &dwServiceStatus,
  328. &dwErrorCode)))
  329. {
  330. // Note, if the service is not running, we assume it will
  331. // stay off and not assume that it will be turned on.
  332. // ------------------------------------------------------------
  333. m_fIsDHCPRunningOnServer = (dwServiceStatus == SERVICE_RUNNING);
  334. }
  335. //$ TODO : is this the correct name for the DNS Server?
  336. // Get the status of the DNS service
  337. // ----------------------------------------------------------------
  338. if (FHrSucceeded(TFSGetServiceStatus(pszServerName,
  339. _T("DNSServer"),
  340. &dwServiceStatus,
  341. &dwErrorCode)))
  342. {
  343. // Note, if the service is not running, we assume it will
  344. // stay off and not assume that it will be turned on.
  345. // ------------------------------------------------------------
  346. m_fIsDNSRunningOnServer = (dwServiceStatus == SERVICE_RUNNING);
  347. }
  348. //Based on the express type set some of the parameters upfront here
  349. switch ( m_dwExpressType )
  350. {
  351. case MPRSNAP_CYS_EXPRESS_NAT:
  352. m_fAdvanced = TRUE;
  353. m_wizType = NewRtrWizData::NewWizardRouterType_NAT;
  354. m_dwNewRouterType = NEWWIZ_ROUTER_TYPE_NAT;
  355. break;
  356. case MPRSNAP_CYS_EXPRESS_NONE:
  357. default:
  358. //do nothing here
  359. break;
  360. }
  361. LoadInterfaceData(pRouter);
  362. return hrOK;
  363. }
  364. UINT NewRtrWizData::GetStartPageId ()
  365. {
  366. // Get a better scheme in place for this stuff. This
  367. // is the index into the array m_pagelist.
  368. switch ( m_dwExpressType )
  369. {
  370. case MPRSNAP_CYS_EXPRESS_NAT:
  371. return (6);
  372. break;
  373. case MPRSNAP_CYS_EXPRESS_NONE:
  374. default:
  375. return (0);
  376. break;
  377. }
  378. return 0;
  379. }
  380. /*!--------------------------------------------------------------------------
  381. NewRtrWizData::QueryForTestData
  382. -
  383. Author: KennT
  384. ---------------------------------------------------------------------------*/
  385. BOOL NewRtrWizData::s_fIpInstalled = FALSE;
  386. BOOL NewRtrWizData::s_fIpxInstalled = FALSE;
  387. BOOL NewRtrWizData::s_fAppletalkInstalled = FALSE;
  388. BOOL NewRtrWizData::s_fNbfInstalled = FALSE;
  389. BOOL NewRtrWizData::s_fIsLocalMachine = FALSE;
  390. BOOL NewRtrWizData::s_fIsDNSRunningOnPrivateInterface = FALSE;
  391. BOOL NewRtrWizData::s_fIsDHCPRunningOnPrivateInterface = FALSE;
  392. BOOL NewRtrWizData::s_fIsSharedAccessRunningOnServer = FALSE;
  393. BOOL NewRtrWizData::s_fIsMemberOfDomain = FALSE;
  394. DWORD NewRtrWizData::s_dwNumberOfNICs = 0;
  395. /*!--------------------------------------------------------------------------
  396. NewRtrWizData::QueryForTestData
  397. -
  398. Author: KennT
  399. ---------------------------------------------------------------------------*/
  400. HRESULT NewRtrWizData::QueryForTestData()
  401. {
  402. HRESULT hr = hrOK;
  403. CNewWizTestParams dlgParams;
  404. m_fTest = TRUE;
  405. // Get the initial parameters
  406. // ----------------------------------------------------------------
  407. dlgParams.SetData(this);
  408. if (dlgParams.DoModal() == IDCANCEL)
  409. {
  410. return S_FALSE;
  411. }
  412. return hr;
  413. }
  414. /*!--------------------------------------------------------------------------
  415. NewRtrWizData::HrIsIPInstalled
  416. -
  417. Author: KennT
  418. ---------------------------------------------------------------------------*/
  419. HRESULT NewRtrWizData::HrIsIPInstalled()
  420. {
  421. if (m_fTest)
  422. return s_fIpInstalled ? S_OK : S_FALSE;
  423. else
  424. return m_fIpInstalled ? S_OK : S_FALSE;
  425. }
  426. /*!--------------------------------------------------------------------------
  427. NewRtrWizData::HrIsIPInUse
  428. -
  429. Author: KennT
  430. ---------------------------------------------------------------------------*/
  431. HRESULT NewRtrWizData::HrIsIPInUse()
  432. {
  433. HRESULT hr = hrOK;
  434. hr = HrIsIPInstalled();
  435. if (FHrOK(hr))
  436. return m_fIpInUse ? S_OK : S_FALSE;
  437. else
  438. return hr;
  439. }
  440. /*!--------------------------------------------------------------------------
  441. NewRtrWizData::HrIsIPXInstalled
  442. -
  443. Author: KennT
  444. ---------------------------------------------------------------------------*/
  445. HRESULT NewRtrWizData::HrIsIPXInstalled()
  446. {
  447. if (m_fTest)
  448. return s_fIpxInstalled ? S_OK : S_FALSE;
  449. else
  450. return m_fIpxInstalled ? S_OK : S_FALSE;
  451. }
  452. /*!--------------------------------------------------------------------------
  453. NewRtrWizData::HrIsIPXInUse
  454. -
  455. Author: KennT
  456. ---------------------------------------------------------------------------*/
  457. HRESULT NewRtrWizData::HrIsIPXInUse()
  458. {
  459. HRESULT hr = hrOK;
  460. hr = HrIsIPXInstalled();
  461. if (FHrOK(hr))
  462. return m_fIpxInUse ? S_OK : S_FALSE;
  463. else
  464. return hr;
  465. }
  466. /*!--------------------------------------------------------------------------
  467. NewRtrWizData::HrIsAppletalkInstalled
  468. -
  469. Author: KennT
  470. ---------------------------------------------------------------------------*/
  471. HRESULT NewRtrWizData::HrIsAppletalkInstalled()
  472. {
  473. if (m_fTest)
  474. return s_fAppletalkInstalled ? S_OK : S_FALSE;
  475. else
  476. return m_fAppletalkInstalled ? S_OK : S_FALSE;
  477. }
  478. /*!--------------------------------------------------------------------------
  479. NewRtrWizData::HrIsAppletalkInUse
  480. -
  481. Author: KennT
  482. ---------------------------------------------------------------------------*/
  483. HRESULT NewRtrWizData::HrIsAppletalkInUse()
  484. {
  485. HRESULT hr = hrOK;
  486. hr = HrIsAppletalkInstalled();
  487. if (FHrOK(hr))
  488. return m_fAppletalkInUse ? S_OK : S_FALSE;
  489. else
  490. return hr;
  491. }
  492. /*!--------------------------------------------------------------------------
  493. NewRtrWizData::HrIsNbfInstalled
  494. -
  495. Author: KennT
  496. ---------------------------------------------------------------------------*/
  497. HRESULT NewRtrWizData::HrIsNbfInstalled()
  498. {
  499. if (m_fTest)
  500. return s_fNbfInstalled ? S_OK : S_FALSE;
  501. else
  502. return m_fNbfInstalled ? S_OK : S_FALSE;
  503. }
  504. /*!--------------------------------------------------------------------------
  505. NewRtrWizData::HrIsNbfInUse
  506. -
  507. Author: KennT
  508. ---------------------------------------------------------------------------*/
  509. HRESULT NewRtrWizData::HrIsNbfInUse()
  510. {
  511. HRESULT hr = hrOK;
  512. hr = HrIsNbfInstalled();
  513. if (FHrOK(hr))
  514. return m_fNbfInUse ? S_OK : S_FALSE;
  515. else
  516. return hr;
  517. }
  518. /*!--------------------------------------------------------------------------
  519. NewRtrWizData::HrIsLocalMachine
  520. -
  521. Author: KennT
  522. ---------------------------------------------------------------------------*/
  523. HRESULT NewRtrWizData::HrIsLocalMachine()
  524. {
  525. if (m_fTest)
  526. return s_fIsLocalMachine ? S_OK : S_FALSE;
  527. else
  528. return IsLocalMachine(m_stServerName) ? S_OK : S_FALSE;
  529. }
  530. /*!--------------------------------------------------------------------------
  531. NewRtrWizData::HrIsDNSRunningOnInterface
  532. -
  533. Author: KennT
  534. ---------------------------------------------------------------------------*/
  535. HRESULT NewRtrWizData::HrIsDNSRunningOnInterface()
  536. {
  537. if (m_fTest)
  538. return s_fIsDNSRunningOnPrivateInterface ? S_OK : S_FALSE;
  539. else
  540. {
  541. // Search for the private interface in our list
  542. // ------------------------------------------------------------
  543. RtrWizInterface * pRtrWizIf = NULL;
  544. m_ifMap.Lookup(m_stPrivateInterfaceId, pRtrWizIf);
  545. if (pRtrWizIf)
  546. return pRtrWizIf->m_fIsDnsEnabled ? S_OK : S_FALSE;
  547. else
  548. return S_FALSE;
  549. }
  550. }
  551. HRESULT NewRtrWizData::HrIsDNSRunningOnGivenInterface(CString InterfaceId)
  552. {
  553. if (m_fTest)
  554. return s_fIsDNSRunningOnPrivateInterface ? S_OK : S_FALSE;
  555. else
  556. {
  557. // Search for the interface in our list
  558. // ------------------------------------------------------------
  559. RtrWizInterface * pRtrWizIf = NULL;
  560. m_ifMap.Lookup(InterfaceId, pRtrWizIf);
  561. if (pRtrWizIf)
  562. return pRtrWizIf->m_fIsDnsEnabled ? S_OK : S_FALSE;
  563. else
  564. return S_FALSE;
  565. }
  566. }
  567. HRESULT NewRtrWizData::HrIsDNSRunningOnNATInterface()
  568. {
  569. if (m_fTest)
  570. return s_fIsDNSRunningOnPrivateInterface ? S_OK : S_FALSE;
  571. else
  572. {
  573. // Search for the private interface in our list
  574. // ------------------------------------------------------------
  575. RtrWizInterface * pRtrWizIf = NULL;
  576. m_ifMap.Lookup(m_stNATPrivateInterfaceId, pRtrWizIf);
  577. if (pRtrWizIf)
  578. return pRtrWizIf->m_fIsDnsEnabled ? S_OK : S_FALSE;
  579. else
  580. return S_FALSE;
  581. }
  582. }
  583. /*!--------------------------------------------------------------------------
  584. NewRtrWizData::HrIsDHCPRunningOnInterface
  585. -
  586. Author: KennT
  587. ---------------------------------------------------------------------------*/
  588. HRESULT NewRtrWizData::HrIsDHCPRunningOnInterface()
  589. {
  590. if (m_fTest)
  591. return s_fIsDHCPRunningOnPrivateInterface ? S_OK : S_FALSE;
  592. else
  593. {
  594. // Search for the private interface in our list
  595. // ------------------------------------------------------------
  596. RtrWizInterface * pRtrWizIf = NULL;
  597. m_ifMap.Lookup(m_stPrivateInterfaceId, pRtrWizIf);
  598. if (pRtrWizIf)
  599. return pRtrWizIf->m_fIsDhcpEnabled ? S_OK : S_FALSE;
  600. else
  601. return S_FALSE;
  602. }
  603. }
  604. HRESULT NewRtrWizData::HrIsDHCPRunningOnGivenInterface(CString InterfaceId)
  605. {
  606. if (m_fTest)
  607. return s_fIsDHCPRunningOnPrivateInterface ? S_OK : S_FALSE;
  608. else
  609. {
  610. // Search for the private interface in our list
  611. // ------------------------------------------------------------
  612. RtrWizInterface * pRtrWizIf = NULL;
  613. m_ifMap.Lookup(InterfaceId, pRtrWizIf);
  614. if (pRtrWizIf)
  615. return pRtrWizIf->m_fIsDhcpEnabled ? S_OK : S_FALSE;
  616. else
  617. return S_FALSE;
  618. }
  619. }
  620. HRESULT NewRtrWizData::HrIsDHCPRunningOnNATInterface()
  621. {
  622. if (m_fTest)
  623. return s_fIsDHCPRunningOnPrivateInterface ? S_OK : S_FALSE;
  624. else
  625. {
  626. // Search for the private interface in our list
  627. // ------------------------------------------------------------
  628. RtrWizInterface * pRtrWizIf = NULL;
  629. m_ifMap.Lookup(m_stNATPrivateInterfaceId, pRtrWizIf);
  630. if (pRtrWizIf)
  631. return pRtrWizIf->m_fIsDhcpEnabled ? S_OK : S_FALSE;
  632. else
  633. return S_FALSE;
  634. }
  635. }
  636. /*!--------------------------------------------------------------------------
  637. NewRtrWizData::HrIsDNSRunningOnServer
  638. -
  639. Author: KennT
  640. ---------------------------------------------------------------------------*/
  641. HRESULT NewRtrWizData::HrIsDNSRunningOnServer()
  642. {
  643. return m_fIsDNSRunningOnServer ? S_OK : S_FALSE;
  644. }
  645. /*!--------------------------------------------------------------------------
  646. NewRtrWizData::HrIsDHCPRunningOnServer
  647. -
  648. Author: KennT
  649. ---------------------------------------------------------------------------*/
  650. HRESULT NewRtrWizData::HrIsDHCPRunningOnServer()
  651. {
  652. return m_fIsDHCPRunningOnServer ? S_OK : S_FALSE;
  653. }
  654. /*!--------------------------------------------------------------------------
  655. NewRtrWizData::HrIsSharedAccessRunningOnServer
  656. -
  657. Author: KennT
  658. ---------------------------------------------------------------------------*/
  659. HRESULT NewRtrWizData::HrIsSharedAccessRunningOnServer()
  660. {
  661. if (m_fTest)
  662. return s_fIsSharedAccessRunningOnServer ? S_OK : S_FALSE;
  663. else
  664. return NatConflictExists(m_stServerName) ? S_OK : S_FALSE;
  665. }
  666. /*!--------------------------------------------------------------------------
  667. NewRtrWizData::HrIsMemberOfDomain
  668. -
  669. Author: KennT
  670. ---------------------------------------------------------------------------*/
  671. HRESULT NewRtrWizData::HrIsMemberOfDomain()
  672. {
  673. if (m_fTest)
  674. return s_fIsMemberOfDomain ? S_OK : S_FALSE;
  675. else
  676. {
  677. // flip the meaning
  678. HRESULT hr = HrIsStandaloneServer(m_stServerName);
  679. if (FHrSucceeded(hr))
  680. return FHrOK(hr) ? S_FALSE : S_OK;
  681. else
  682. return hr;
  683. }
  684. }
  685. /*!--------------------------------------------------------------------------
  686. NewRtrWizData::GetNextPage
  687. -
  688. Author: KennT
  689. ---------------------------------------------------------------------------*/
  690. LRESULT NewRtrWizData::GetNextPage(UINT uDialogId)
  691. {
  692. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  693. LRESULT lNextPage = 0;
  694. DWORD dwNICs;
  695. CString stTemp;
  696. switch (uDialogId)
  697. {
  698. default:
  699. Panic0("We should not be here, this is a finish page!");
  700. break;
  701. case IDD_NEWRTRWIZ_WELCOME:
  702. lNextPage = IDD_NEWRTRWIZ_COMMONCONFIG;
  703. break;
  704. case IDD_NEWRTRWIZ_COMMONCONFIG:
  705. switch (m_wizType)
  706. {
  707. case NewWizardRouterType_DialupOrVPN:
  708. if (FHrOK(HrIsIPInstalled()))
  709. {
  710. lNextPage = IDD_NEWRTRWIZ_RRASVPN;
  711. }
  712. else
  713. {
  714. if (FHrOK(HrIsLocalMachine()))
  715. lNextPage = IDD_NEWRTRWIZ_VPN_NOIP;
  716. else
  717. lNextPage = IDD_NEWRTRWIZ_VPN_NOIP_NONLOCAL;
  718. }
  719. break;
  720. case NewWizardRouterType_NAT:
  721. if ( !FHrOK(HrIsIPInstalled()) )
  722. {
  723. if (FHrOK(HrIsLocalMachine()))
  724. lNextPage = IDD_NEWRTRWIZ_NAT_NOIP;
  725. else
  726. lNextPage = IDD_NEWRTRWIZ_NAT_NOIP_NONLOCAL;
  727. }
  728. else
  729. {
  730. // This is always in advanced mode of operation.
  731. if (FHrOK(HrIsSharedAccessRunningOnServer()))
  732. {
  733. if (FHrOK(HrIsLocalMachine()))
  734. lNextPage = IDD_NEWRTRWIZ_NAT_A_CONFLICT;
  735. else
  736. lNextPage = IDD_NEWRTRWIZ_NAT_A_CONFLICT_NONLOCAL;
  737. }
  738. else
  739. {
  740. lNextPage = IDD_NEWRTRWIZ_NAT_A_PUBLIC;
  741. }
  742. }
  743. break;
  744. case NewWizardRouterType_VPNandNAT:
  745. GetNumberOfNICS_IP(&dwNICs);
  746. if ( dwNICs < 1 )
  747. {
  748. lNextPage = IDD_NEWRTRWIZ_VPN_A_FINISH_NONICS;
  749. }
  750. else
  751. {
  752. m_dwNewRouterType |= (NEWWIZ_ROUTER_TYPE_VPN|NEWWIZ_ROUTER_TYPE_NAT);
  753. lNextPage = IDD_NEWRTRWIZ_VPN_A_PUBLIC;
  754. }
  755. break;
  756. case NewWizardRouterType_DOD:
  757. //Use demand dial
  758. lNextPage = IDD_NEWRTRWIZ_ROUTER_USEDD;
  759. break;
  760. case NewWizardRouterType_Custom:
  761. lNextPage = IDD_NEWRTRWIZ_CUSTOM_CONFIG;
  762. break;
  763. }
  764. break;
  765. case IDD_NEWRTRWIZ_CUSTOM_CONFIG:
  766. lNextPage = IDD_NEWRTRWIZ_MANUAL_FINISH;
  767. break;
  768. case IDD_NEWRTRWIZ_RRASVPN:
  769. //
  770. //Check to see what the router type is set to.
  771. //based on that make a decision what page is next
  772. //
  773. GetNumberOfNICS_IP(&dwNICs);
  774. if ( dwNICs > 1 )
  775. {
  776. //
  777. //There are more than one nics
  778. //So check to see if it is RAS or VPN or both
  779. //
  780. lNextPage = IDD_NEWRTRWIZ_VPN_A_FINISH_NONICS;
  781. if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN &&
  782. m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP
  783. )
  784. {
  785. //
  786. //This is both a dialup and VPN server
  787. //
  788. //So show the public private network page
  789. //as the next page.
  790. //
  791. lNextPage = IDD_NEWRTRWIZ_VPN_A_PUBLIC;
  792. }
  793. else if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN )
  794. {
  795. //
  796. //This is only a VPN server. So show the public
  797. //private network page next
  798. //
  799. lNextPage = IDD_NEWRTRWIZ_VPN_A_PUBLIC;
  800. }
  801. else if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  802. {
  803. //
  804. //This is only a dialup server. So show the private
  805. //network page next.
  806. //
  807. lNextPage = IDD_NEWRTRWIZ_RAS_A_NETWORK;
  808. }
  809. }
  810. else if ( dwNICs == 0 )
  811. {
  812. //
  813. //No Nics. So this if this is a VPN,
  814. //this is an error state. If RAS then
  815. //we should be able to install dialup
  816. //even without a NIC.
  817. //Since we dont Enable VPN if there are
  818. //no nics in the machine, this will
  819. //only have a dialup case.
  820. //
  821. lNextPage = IDD_NEWRTRWIZ_RAS_A_NONICS;
  822. }
  823. else
  824. {
  825. //
  826. //Only one nic so in either case, show
  827. //the addressing page. Collapse addressing
  828. //into one page
  829. AutoSelectPrivateInterface();
  830. lNextPage = IDD_NEWRTRWIZ_ADDRESSING;
  831. }
  832. break;
  833. case IDD_NEWRTRWIZ_NAT_A_PUBLIC:
  834. {
  835. // Determine the number of NICs
  836. GetNumberOfNICS_IP(&dwNICs);
  837. // Adjust the number of NICs (depending on whether
  838. // we selected to create a DD or not).
  839. if (dwNICs)
  840. {
  841. if (!m_fCreateDD)
  842. dwNICs--;
  843. }
  844. // Now switch depending on the number of NICs
  845. if (dwNICs == 0)
  846. lNextPage = IDD_NEWRTRWIZ_NAT_A_NONICS_FINISH;
  847. else if (dwNICs > 1)
  848. lNextPage = IDD_NEWRTRWIZ_NAT_A_PRIVATE;
  849. if (lNextPage)
  850. break;
  851. }
  852. // Fall through to the next case
  853. // At this stage, we now have the case that the
  854. // remaining number of NICs == 1, and we need to
  855. // autoselect the NIC and go on to the next test.
  856. AutoSelectPrivateInterface();
  857. case IDD_NEWRTRWIZ_NAT_A_PRIVATE:
  858. if ( m_wizType == NewWizardRouterType_VPNandNAT )
  859. {
  860. stTemp = m_stNATPrivateInterfaceId;
  861. }
  862. else
  863. {
  864. stTemp = m_stPrivateInterfaceId;
  865. }
  866. if (FHrOK(HrIsDNSRunningOnGivenInterface(stTemp)) ||
  867. FHrOK(HrIsDHCPRunningOnGivenInterface(stTemp)) ||
  868. FHrOK(HrIsDNSRunningOnServer()) ||
  869. FHrOK(HrIsDHCPRunningOnServer()))
  870. {
  871. // Popup a warning box
  872. // AfxMessageBox(IDS_WRN_RTRWIZ_NAT_DHCPDNS_FOUND,
  873. // MB_ICONEXCLAMATION);
  874. m_fNatUseSimpleServers = FALSE;
  875. //continue on down, and fall through
  876. }
  877. else
  878. {
  879. //
  880. //check to see if we are in express path
  881. //if so, we fall thru' again. no showing
  882. //this page.
  883. if ( MPRSNAP_CYS_EXPRESS_NAT == m_dwExpressType )
  884. {
  885. m_fNatUseSimpleServers = FALSE;
  886. }
  887. else
  888. {
  889. lNextPage = IDD_NEWRTRWIZ_NAT_A_DHCPDNS;
  890. break;
  891. }
  892. }
  893. case IDD_NEWRTRWIZ_NAT_A_DHCPDNS:
  894. if (m_fNatUseSimpleServers)
  895. lNextPage = IDD_NEWRTRWIZ_NAT_A_DHCP_WARNING;
  896. else
  897. {
  898. if (m_fCreateDD)
  899. lNextPage = IDD_NEWRTRWIZ_NAT_A_DD_WARNING;
  900. else
  901. {
  902. if ( m_wizType == NewWizardRouterType_VPNandNAT )
  903. {
  904. lNextPage = IDD_NEWRTRWIZ_USERADIUS;
  905. }
  906. else
  907. lNextPage = IDD_NEWRTRWIZ_NAT_A_EXTERNAL_FINISH;
  908. }
  909. }
  910. break;
  911. case IDD_NEWRTRWIZ_NAT_A_DHCP_WARNING:
  912. Assert(m_fNatUseSimpleServers);
  913. if (m_fCreateDD)
  914. lNextPage = IDD_NEWRTRWIZ_NAT_A_DD_WARNING;
  915. else
  916. {
  917. if ( m_wizType == NewWizardRouterType_VPNandNAT )
  918. {
  919. lNextPage = IDD_NEWRTRWIZ_USERADIUS;
  920. }
  921. else
  922. lNextPage = IDD_NEWRTRWIZ_NAT_A_FINISH;
  923. }
  924. break;
  925. case IDD_NEWRTRWIZ_NAT_A_DD_WARNING:
  926. if (!FHrSucceeded(m_hrDDError))
  927. lNextPage = IDD_NEWRTRWIZ_NAT_A_DD_ERROR;
  928. else
  929. {
  930. if (m_fNatUseSimpleServers)
  931. lNextPage = IDD_NEWRTRWIZ_NAT_A_FINISH;
  932. else
  933. lNextPage = IDD_NEWRTRWIZ_NAT_A_EXTERNAL_FINISH;
  934. }
  935. break;
  936. case IDD_NEWRTRWIZ_RAS_A_ATALK:
  937. if (FHrOK(HrIsIPInUse()))
  938. {
  939. GetNumberOfNICS_IP(&dwNICs);
  940. if (dwNICs > 1)
  941. lNextPage = IDD_NEWRTRWIZ_RAS_A_NETWORK;
  942. else if (dwNICs == 0)
  943. lNextPage = IDD_NEWRTRWIZ_RAS_A_NONICS;
  944. else
  945. {
  946. AutoSelectPrivateInterface();
  947. lNextPage = IDD_NEWRTRWIZ_ADDRESSING;
  948. }
  949. break;
  950. }
  951. // default catch
  952. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  953. break;
  954. case IDD_NEWRTRWIZ_RAS_A_NONICS:
  955. if (m_fNoNicsAreOk)
  956. lNextPage = IDD_NEWRTRWIZ_ADDRESSING;
  957. else
  958. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH_NONICS;
  959. break;
  960. case IDD_NEWRTRWIZ_RAS_A_NETWORK:
  961. lNextPage = IDD_NEWRTRWIZ_ADDRESSING;
  962. break;
  963. case IDD_NEWRTRWIZ_ADDRESSING:
  964. GetNumberOfNICS_IP(&dwNICs);
  965. if ( m_wizType == NewWizardRouterType_VPNandNAT )
  966. {
  967. //This is a VPN and NAT case
  968. if ( m_fUseDHCP )
  969. {
  970. // Determine how many choices are available for
  971. // NAT private interface
  972. // The public interface cannot be used as a NAT private
  973. if ( !m_stPublicInterfaceId.IsEmpty() )
  974. dwNICs --;
  975. // If there is only one NIC left, then pick that as the
  976. // NAT private interface. By now that same NIC has already
  977. // been selected as VPN private interface
  978. // After that, goto the DHCP/DNS page
  979. // Or else show the nat private interface selection page
  980. // At this point dwNICs should never be less than 1
  981. Assert(dwNICs > 0);
  982. if ( dwNICs == 1 )
  983. {
  984. m_stNATPrivateInterfaceId = m_stPrivateInterfaceId;
  985. if (FHrOK(HrIsDNSRunningOnNATInterface()) ||
  986. FHrOK(HrIsDHCPRunningOnNATInterface()) ||
  987. FHrOK(HrIsDNSRunningOnServer()) ||
  988. FHrOK(HrIsDHCPRunningOnServer()))
  989. {
  990. m_fNatUseSimpleServers = FALSE;
  991. //
  992. //Continue on with the VPN wizard part
  993. //
  994. lNextPage = IDD_NEWRTRWIZ_USERADIUS;
  995. }
  996. else
  997. {
  998. lNextPage = IDD_NEWRTRWIZ_NAT_A_DHCPDNS;
  999. }
  1000. }
  1001. else
  1002. {
  1003. lNextPage = IDD_NEWRTRWIZ_NAT_A_PRIVATE;
  1004. }
  1005. }
  1006. else
  1007. {
  1008. //
  1009. //Since static address pool was selected, show the
  1010. //addressing page.
  1011. //
  1012. lNextPage = IDD_NEWRTRWIZ_ADDRESSPOOL;
  1013. }
  1014. }
  1015. else if ( ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN) ||
  1016. ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  1017. )
  1018. {
  1019. if ( !dwNICs && m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  1020. {
  1021. //No NICS. This should happen only in case of dialup.
  1022. if (m_fUseDHCP)
  1023. {
  1024. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  1025. }
  1026. else
  1027. lNextPage = IDD_NEWRTRWIZ_ADDRESSPOOL;
  1028. }
  1029. else if (m_fUseDHCP)
  1030. {
  1031. //
  1032. //Logic is the same irrespective of whether it is
  1033. //VPN or DIALUP.
  1034. //
  1035. lNextPage = IDD_NEWRTRWIZ_USERADIUS;
  1036. }
  1037. else
  1038. lNextPage = IDD_NEWRTRWIZ_ADDRESSPOOL;
  1039. }
  1040. else if ( m_dwNewRouterType && NEWWIZ_ROUTER_TYPE_DOD )
  1041. {
  1042. if (m_fUseDHCP)
  1043. lNextPage = IDD_NEWRTRWIZ_ROUTER_FINISH_DD;
  1044. else
  1045. lNextPage = IDD_NEWRTRWIZ_ADDRESSPOOL;
  1046. }
  1047. break;
  1048. case IDD_NEWRTRWIZ_ADDRESSPOOL:
  1049. GetNumberOfNICS_IP(&dwNICs);
  1050. if ( m_wizType == NewWizardRouterType_VPNandNAT )
  1051. {
  1052. // Determine how many choices are available for
  1053. // NAT private interface
  1054. // The public interface cannot be used as a NAT private
  1055. if ( !m_stPublicInterfaceId.IsEmpty() )
  1056. dwNICs --;
  1057. // If there is only one NIC left, then pick that as the
  1058. // NAT private interface. By now that same NIC has already
  1059. // been selected as VPN private interface
  1060. // After that, goto the DHCP/DNS page
  1061. // Or else show the nat private interface selection page
  1062. // At this point dwNICs should never be less than 1
  1063. Assert(dwNICs > 0);
  1064. if ( dwNICs == 1 )
  1065. {
  1066. m_stNATPrivateInterfaceId = m_stPrivateInterfaceId;
  1067. if (FHrOK(HrIsDNSRunningOnNATInterface()) ||
  1068. FHrOK(HrIsDHCPRunningOnNATInterface()) ||
  1069. FHrOK(HrIsDNSRunningOnServer()) ||
  1070. FHrOK(HrIsDHCPRunningOnServer()))
  1071. {
  1072. m_fNatUseSimpleServers = FALSE;
  1073. //
  1074. //Continue on with the VPN wizard part
  1075. //
  1076. lNextPage = IDD_NEWRTRWIZ_USERADIUS;
  1077. }
  1078. else
  1079. {
  1080. lNextPage = IDD_NEWRTRWIZ_NAT_A_DHCPDNS;
  1081. }
  1082. }
  1083. else
  1084. {
  1085. lNextPage = IDD_NEWRTRWIZ_NAT_A_PRIVATE;
  1086. }
  1087. }
  1088. else if ( ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN) ||
  1089. ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  1090. )
  1091. {
  1092. if (dwNICs == 0)
  1093. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  1094. else
  1095. lNextPage = IDD_NEWRTRWIZ_USERADIUS;
  1096. }
  1097. else if ( m_dwNewRouterType && NEWWIZ_ROUTER_TYPE_DOD )
  1098. {
  1099. lNextPage = IDD_NEWRTRWIZ_ROUTER_FINISH_DD;
  1100. }
  1101. break;
  1102. case IDD_NEWRTRWIZ_USERADIUS:
  1103. if (m_fUseRadius)
  1104. lNextPage = IDD_NEWRTRWIZ_RADIUS_CONFIG;
  1105. else
  1106. if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN &&
  1107. m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT
  1108. )
  1109. {
  1110. //NAT and VPN
  1111. lNextPage = IDD_NEWRTRWIZ_NAT_VPN_A_FINISH;
  1112. }
  1113. else if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP &&
  1114. m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN
  1115. )
  1116. {
  1117. //RAS and VPN
  1118. lNextPage = IDD_NEWRTRWIZ_RAS_VPN_A_FINISH;
  1119. }
  1120. else if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  1121. {
  1122. //RAS only
  1123. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  1124. }
  1125. else
  1126. {
  1127. //VPN only
  1128. lNextPage = IDD_NEWRTRWIZ_VPN_A_FINISH;
  1129. }
  1130. break;
  1131. case IDD_NEWRTRWIZ_RADIUS_CONFIG:
  1132. if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN &&
  1133. m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT
  1134. )
  1135. {
  1136. //NAT and VPN
  1137. lNextPage = IDD_NEWRTRWIZ_NAT_VPN_A_FINISH;
  1138. }
  1139. else if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP &&
  1140. m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN
  1141. )
  1142. {
  1143. //RAS and VPN
  1144. lNextPage = IDD_NEWRTRWIZ_RAS_VPN_A_FINISH;
  1145. }
  1146. else if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  1147. {
  1148. //RAS only
  1149. lNextPage = IDD_NEWRTRWIZ_RAS_A_FINISH;
  1150. }
  1151. else
  1152. {
  1153. //VPN only
  1154. lNextPage = IDD_NEWRTRWIZ_VPN_A_FINISH;
  1155. }
  1156. break;
  1157. case IDD_NEWRTRWIZ_VPN_A_ATALK:
  1158. GetNumberOfNICS_IP(&dwNICs);
  1159. Assert(dwNICs >= 1);
  1160. lNextPage = IDD_NEWRTRWIZ_VPN_A_PUBLIC;
  1161. break;
  1162. case IDD_NEWRTRWIZ_VPN_A_PUBLIC:
  1163. GetNumberOfNICS_IP(&dwNICs);
  1164. // Are there any NICs left?
  1165. if (((dwNICs == 1) && m_stPublicInterfaceId.IsEmpty()) ||
  1166. ((dwNICs == 2) && !m_stPublicInterfaceId.IsEmpty()))
  1167. {
  1168. AutoSelectPrivateInterface();
  1169. lNextPage = IDD_NEWRTRWIZ_ADDRESSING;
  1170. }
  1171. else
  1172. lNextPage = IDD_NEWRTRWIZ_VPN_A_PRIVATE;
  1173. break;
  1174. case IDD_NEWRTRWIZ_VPN_A_PRIVATE:
  1175. Assert(!m_stPrivateInterfaceId.IsEmpty());
  1176. lNextPage = IDD_NEWRTRWIZ_ADDRESSING;
  1177. break;
  1178. case IDD_NEWRTRWIZ_VPN_A_ADDRESSPOOL:
  1179. break;
  1180. case IDD_NEWRTRWIZ_ROUTER_USEDD:
  1181. if (m_fUseDD)
  1182. lNextPage = IDD_NEWRTRWIZ_ADDRESSING;
  1183. else
  1184. lNextPage = IDD_NEWRTRWIZ_ROUTER_FINISH;
  1185. break;
  1186. case IDD_NEWRTRWIZ_ROUTER_ADDRESSPOOL:
  1187. lNextPage = IDD_NEWRTRWIZ_ROUTER_FINISH_DD;
  1188. break;
  1189. }
  1190. return lNextPage;
  1191. }
  1192. /*!--------------------------------------------------------------------------
  1193. NewRtrWizData::GetNumberOfNICS
  1194. -
  1195. Author: KennT
  1196. ---------------------------------------------------------------------------*/
  1197. HRESULT NewRtrWizData::GetNumberOfNICS_IP(DWORD *pdwNumber)
  1198. {
  1199. if (m_fTest)
  1200. {
  1201. Assert(s_dwNumberOfNICs == m_ifMap.GetCount());
  1202. }
  1203. *pdwNumber = m_ifMap.GetCount();
  1204. return hrOK;
  1205. }
  1206. /*!--------------------------------------------------------------------------
  1207. NewRtrWizData::GetNumberOfNICS_IPorIPX
  1208. -
  1209. Author: KennT
  1210. ---------------------------------------------------------------------------*/
  1211. HRESULT NewRtrWizData::GetNumberOfNICS_IPorIPX(DWORD *pdwNumber)
  1212. {
  1213. *pdwNumber = m_dwNumberOfNICs_IPorIPX;
  1214. return hrOK;
  1215. }
  1216. void NewRtrWizData::AutoSelectNATPrivateInterface()
  1217. {
  1218. POSITION pos;
  1219. RtrWizInterface * pRtrWizIf = NULL;
  1220. CString st;
  1221. m_stNATPrivateInterfaceId.Empty();
  1222. pos = m_ifMap.GetStartPosition();
  1223. while (pos)
  1224. {
  1225. m_ifMap.GetNextAssoc(pos, st, pRtrWizIf);
  1226. if (m_stPublicInterfaceId != st &&
  1227. m_stPrivateInterfaceId != st )
  1228. {
  1229. m_stNATPrivateInterfaceId = st;
  1230. break;
  1231. }
  1232. }
  1233. Assert(!m_stNATPrivateInterfaceId.IsEmpty());
  1234. return;
  1235. }
  1236. /*!--------------------------------------------------------------------------
  1237. NewRtrWizData::AutoSelectPrivateInterface
  1238. -
  1239. Author: KennT
  1240. ---------------------------------------------------------------------------*/
  1241. void NewRtrWizData::AutoSelectPrivateInterface()
  1242. {
  1243. POSITION pos;
  1244. RtrWizInterface * pRtrWizIf = NULL;
  1245. CString st;
  1246. m_stPrivateInterfaceId.Empty();
  1247. pos = m_ifMap.GetStartPosition();
  1248. while (pos)
  1249. {
  1250. m_ifMap.GetNextAssoc(pos, st, pRtrWizIf);
  1251. if (m_stPublicInterfaceId != st)
  1252. {
  1253. m_stPrivateInterfaceId = st;
  1254. break;
  1255. }
  1256. }
  1257. Assert(!m_stPrivateInterfaceId.IsEmpty());
  1258. return;
  1259. }
  1260. /*!--------------------------------------------------------------------------
  1261. NewRtrWizData::LoadInterfaceData
  1262. -
  1263. Author: KennT
  1264. ---------------------------------------------------------------------------*/
  1265. void NewRtrWizData::LoadInterfaceData(IRouterInfo *pRouter)
  1266. {
  1267. HRESULT hr = hrOK;
  1268. HKEY hkeyMachine = NULL;
  1269. if (!m_fTest)
  1270. {
  1271. // Try to get the real information
  1272. SPIEnumInterfaceInfo spEnumIf;
  1273. SPIInterfaceInfo spIf;
  1274. RtrWizInterface * pRtrWizIf = NULL;
  1275. CStringList listAddress;
  1276. CStringList listMask;
  1277. BOOL fDhcp;
  1278. BOOL fDns;
  1279. pRouter->EnumInterface(&spEnumIf);
  1280. CWRg( ConnectRegistry(pRouter->GetMachineName(), &hkeyMachine) );
  1281. for (; hrOK == spEnumIf->Next(1, &spIf, NULL); spIf.Release())
  1282. {
  1283. // Only look at NICs
  1284. if (spIf->GetInterfaceType() != ROUTER_IF_TYPE_DEDICATED)
  1285. continue;
  1286. // count the interface bound to IP or IPX
  1287. if (FHrOK(spIf->FindRtrMgrInterface(PID_IP, NULL)) || FHrOK(spIf->FindRtrMgrInterface(PID_IPX, NULL)))
  1288. {
  1289. m_dwNumberOfNICs_IPorIPX++;
  1290. }
  1291. // Only allow those interfaces bound to IP to show up
  1292. if (!FHrOK(spIf->FindRtrMgrInterface(PID_IP, NULL)))
  1293. {
  1294. continue;
  1295. }
  1296. pRtrWizIf = new RtrWizInterface;
  1297. pRtrWizIf->m_stName = spIf->GetTitle();
  1298. pRtrWizIf->m_stId = spIf->GetId();
  1299. pRtrWizIf->m_stDesc = spIf->GetDeviceName();
  1300. if (FHrOK(HrIsIPInstalled()))
  1301. {
  1302. POSITION pos;
  1303. DWORD netAddress, dwAddress;
  1304. CString stAddress, stDhcpServer;
  1305. // Clear the lists before getting them again.
  1306. // ----------------------------------------------------
  1307. listAddress.RemoveAll();
  1308. listMask.RemoveAll();
  1309. fDhcp = fDns = FALSE;
  1310. QueryIpAddressList(pRouter->GetMachineName(),
  1311. hkeyMachine,
  1312. spIf->GetId(),
  1313. &listAddress,
  1314. &listMask,
  1315. &fDhcp,
  1316. &fDns,
  1317. &stDhcpServer);
  1318. // Iterate through the list of strings looking
  1319. // for an autonet address
  1320. // ----------------------------------------------------
  1321. pos = listAddress.GetHeadPosition();
  1322. while (pos)
  1323. {
  1324. stAddress = listAddress.GetNext(pos);
  1325. netAddress = INET_ADDR((LPCTSTR) stAddress);
  1326. dwAddress = ntohl(netAddress);
  1327. // Check for reserved address ranges, this indicates
  1328. // an autonet address
  1329. // ------------------------------------------------
  1330. if ((dwAddress & 0xFFFF0000) == MAKEIPADDRESS(169,254,0,0))
  1331. {
  1332. // This is not a DHCP address, it is an
  1333. // autonet address.
  1334. // --------------------------------------------
  1335. fDhcp = FALSE;
  1336. break;
  1337. }
  1338. }
  1339. FormatListString(listAddress, pRtrWizIf->m_stIpAddress,
  1340. _T(","));
  1341. FormatListString(listMask, pRtrWizIf->m_stMask,
  1342. _T(","));
  1343. stDhcpServer.TrimLeft();
  1344. stDhcpServer.TrimRight();
  1345. pRtrWizIf->m_stDhcpServer = stDhcpServer;
  1346. pRtrWizIf->m_fDhcpObtained = fDhcp;
  1347. pRtrWizIf->m_fIsDhcpEnabled = fDhcp;
  1348. pRtrWizIf->m_fIsDnsEnabled = fDns;
  1349. }
  1350. m_ifMap.SetAt(pRtrWizIf->m_stId, pRtrWizIf);
  1351. pRtrWizIf = NULL;
  1352. }
  1353. delete pRtrWizIf;
  1354. }
  1355. else
  1356. {
  1357. CString st;
  1358. RtrWizInterface * pRtrWizIf;
  1359. // For now just the debug data
  1360. for (DWORD i=0; i<s_dwNumberOfNICs; i++)
  1361. {
  1362. pRtrWizIf = new RtrWizInterface;
  1363. pRtrWizIf->m_stName.Format(_T("Local Area Connection #%d"), i);
  1364. pRtrWizIf->m_stId.Format(_T("{%d-GUID...}"), i);
  1365. pRtrWizIf->m_stDesc = _T("Generic Intel hardware");
  1366. if (FHrOK(HrIsIPInstalled()))
  1367. {
  1368. pRtrWizIf->m_stIpAddress = _T("11.22.33.44");
  1369. pRtrWizIf->m_stMask = _T("255.255.0.0");
  1370. // These parameters are dependent on other things
  1371. pRtrWizIf->m_fDhcpObtained = FALSE;
  1372. pRtrWizIf->m_fIsDhcpEnabled = FALSE;
  1373. pRtrWizIf->m_fIsDnsEnabled = FALSE;
  1374. }
  1375. m_ifMap.SetAt(pRtrWizIf->m_stId, pRtrWizIf);
  1376. pRtrWizIf = NULL;
  1377. }
  1378. }
  1379. Error:
  1380. if (hkeyMachine)
  1381. DisconnectRegistry(hkeyMachine);
  1382. }
  1383. /*!--------------------------------------------------------------------------
  1384. NewRtrWizData::SaveToRtrConfigData
  1385. -
  1386. Author: KennT
  1387. ---------------------------------------------------------------------------*/
  1388. HRESULT NewRtrWizData::SaveToRtrConfigData()
  1389. {
  1390. HRESULT hr = hrOK;
  1391. POSITION pos;
  1392. AddressPoolInfo poolInfo;
  1393. m_dwRouterType = 0;
  1394. // Sync up with the general structure
  1395. // ----------------------------------------------------------------
  1396. if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT )
  1397. {
  1398. m_dwRouterType |= ROUTER_TYPE_LAN;
  1399. // If we have been told to create a DD interface
  1400. // then we must have a WAN router.
  1401. if (m_fCreateDD)
  1402. m_dwRouterType |= ROUTER_TYPE_WAN;
  1403. }
  1404. if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  1405. {
  1406. m_dwRouterType |= ROUTER_TYPE_RAS;
  1407. }
  1408. if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN )
  1409. {
  1410. m_dwRouterType |= (ROUTER_TYPE_LAN | ROUTER_TYPE_WAN | ROUTER_TYPE_RAS);
  1411. }
  1412. if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DOD )
  1413. {
  1414. m_dwRouterType |= ROUTER_TYPE_WAN;
  1415. }
  1416. if ( m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_LAN_ROUTING )
  1417. {
  1418. m_dwRouterType |= ROUTER_TYPE_LAN;
  1419. }
  1420. m_RtrConfigData.m_dwRouterType = m_dwRouterType;
  1421. // Setup the NAT-specific information
  1422. // ----------------------------------------------------------------
  1423. if ((m_wizType != NewWizardRouterType_Custom) && (m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT))
  1424. {
  1425. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_NAT;
  1426. if (m_fNatUseSimpleServers)
  1427. {
  1428. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_DNS_PROXY;
  1429. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_DHCP_ALLOCATOR;
  1430. }
  1431. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_ALG; // savasg added
  1432. }
  1433. // Sync up with the IP structure
  1434. // ----------------------------------------------------------------
  1435. if (m_fIpInstalled)
  1436. {
  1437. DWORD dwNICs;
  1438. // Set the private interface id into the IP structure
  1439. Assert(!m_stPrivateInterfaceId.IsEmpty());
  1440. m_RtrConfigData.m_ipData.m_dwAllowNetworkAccess = TRUE;
  1441. m_RtrConfigData.m_ipData.m_dwUseDhcp = m_fUseDHCP;
  1442. // If there is only one NIC, leave this the way it is (RAS
  1443. // to select the adapter). Otherwise, people can get stuck.
  1444. // Install 1, remove it and install a new one.
  1445. //
  1446. // ------------------------------------------------------------
  1447. GetNumberOfNICS_IP(&dwNICs);
  1448. if (dwNICs > 1)
  1449. m_RtrConfigData.m_ipData.m_stNetworkAdapterGUID = m_stPrivateInterfaceId;
  1450. m_RtrConfigData.m_ipData.m_stPrivateAdapterGUID = m_stPrivateInterfaceId;
  1451. m_RtrConfigData.m_ipData.m_stPublicAdapterGUID = m_stPublicInterfaceId;
  1452. m_RtrConfigData.m_ipData.m_dwEnableIn = TRUE;
  1453. // copy over the address pool list
  1454. m_RtrConfigData.m_ipData.m_addressPoolList.RemoveAll();
  1455. if (m_addressPoolList.GetCount())
  1456. {
  1457. pos = m_addressPoolList.GetHeadPosition();
  1458. while (pos)
  1459. {
  1460. poolInfo = m_addressPoolList.GetNext(pos);
  1461. m_RtrConfigData.m_ipData.m_addressPoolList.AddTail(poolInfo);
  1462. }
  1463. }
  1464. }
  1465. // Sync up with the IPX structure
  1466. // ----------------------------------------------------------------
  1467. if (m_fIpxInstalled)
  1468. {
  1469. m_RtrConfigData.m_ipxData.m_dwAllowNetworkAccess = TRUE;
  1470. m_RtrConfigData.m_ipxData.m_dwEnableIn = TRUE;
  1471. m_RtrConfigData.m_ipxData.m_fEnableType20Broadcasts = m_fUseIpxType20Broadcasts;
  1472. // The other parameters will be left at their defaults
  1473. }
  1474. // Sync up with the Appletalk structure
  1475. // ----------------------------------------------------------------
  1476. if (m_fAppletalkInstalled)
  1477. {
  1478. m_RtrConfigData.m_arapData.m_dwEnableIn = TRUE;
  1479. }
  1480. // Sync up with the NBF structure
  1481. // ----------------------------------------------------------------
  1482. if (m_fNbfInstalled)
  1483. {
  1484. m_RtrConfigData.m_nbfData.m_dwAllowNetworkAccess = TRUE;
  1485. m_RtrConfigData.m_nbfData.m_dwEnableIn = TRUE;
  1486. }
  1487. // Sync up with the PPP structure
  1488. // ----------------------------------------------------------------
  1489. // Use the defaults
  1490. // Sync up with the Error log structure
  1491. // ----------------------------------------------------------------
  1492. // Use the defaults
  1493. // Sync up with the Auth structure
  1494. // ----------------------------------------------------------------
  1495. m_RtrConfigData.m_authData.m_dwFlags = USE_PPPCFG_DEFAULT_METHODS;
  1496. if (m_fAppletalkUseNoAuth)
  1497. m_RtrConfigData.m_authData.m_dwFlags |=
  1498. PPPCFG_AllowNoAuthentication;
  1499. if (m_fUseRadius)
  1500. {
  1501. TCHAR szGuid[128];
  1502. // Setup the active auth/acct providers to be RADIUS
  1503. StringFromGUID2(CLSID_RouterAuthRADIUS, szGuid, DimensionOf(szGuid));
  1504. m_RtrConfigData.m_authData.m_stGuidActiveAuthProv = szGuid;
  1505. StringFromGUID2(CLSID_RouterAcctRADIUS, szGuid, DimensionOf(szGuid));
  1506. m_RtrConfigData.m_authData.m_stGuidActiveAcctProv = szGuid;
  1507. }
  1508. // Other parameters left at their defaults
  1509. return hr;
  1510. }
  1511. // --------------------------------------------------------------------
  1512. // Windows NT Bug : 408722
  1513. // Use this code to grab the WM_HELP message from the property sheet.
  1514. // --------------------------------------------------------------------
  1515. static WNDPROC s_lpfnOldWindowProc = NULL;
  1516. LONG FAR PASCAL HelpSubClassWndFunc(HWND hWnd,
  1517. UINT uMsg,
  1518. WPARAM wParam,
  1519. LPARAM lParam)
  1520. {
  1521. if (uMsg == WM_HELP)
  1522. {
  1523. HWND hWndOwner = PropSheet_GetCurrentPageHwnd(hWnd);
  1524. HELPINFO * pHelpInfo = (HELPINFO *) lParam;
  1525. // Reset the context ID, since we know exactly what we're
  1526. // sending (ahem, unless someone reuses this).
  1527. // ------------------------------------------------------------
  1528. pHelpInfo->dwContextId = 0xdeadbeef;
  1529. // Send the WM_HELP message to the prop page
  1530. // ------------------------------------------------------------
  1531. ::SendMessage(hWndOwner, uMsg, wParam, lParam);
  1532. return TRUE;
  1533. }
  1534. return CallWindowProc(s_lpfnOldWindowProc, hWnd, uMsg, wParam, lParam);
  1535. }
  1536. /*!--------------------------------------------------------------------------
  1537. NewRtrWizData::FinishTheDamnWizard
  1538. This is the code that actually does the work of saving the
  1539. data and doing all the operations.
  1540. Author: KennT
  1541. ---------------------------------------------------------------------------*/
  1542. HRESULT NewRtrWizData::FinishTheDamnWizard(HWND hwndOwner,
  1543. IRouterInfo *pRouter, BOOL mesgflag)
  1544. {
  1545. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  1546. DWORD dwError = ERROR_SUCCESS;
  1547. SPIRemoteNetworkConfig spNetwork;
  1548. SPIRemoteSetDnsConfig spDns;
  1549. IUnknown * punk = NULL;
  1550. CWaitCursor wait;
  1551. COSERVERINFO csi;
  1552. COAUTHINFO cai;
  1553. COAUTHIDENTITY caid;
  1554. HRESULT hr = hrOK, dnsHr = hrOK;
  1555. CString sTempPrivateIfID = m_stPrivateInterfaceId;
  1556. if (m_fSaved)
  1557. return hr;
  1558. // Synchronize the RtrConfigData with this structure
  1559. // ----------------------------------------------------------------
  1560. CORg( SaveToRtrConfigData() );
  1561. // Ok, we now have the synchronized RtrConfigData.
  1562. // We can do everything else that we did before to save the
  1563. // information.
  1564. ZeroMemory(&csi, sizeof(csi));
  1565. ZeroMemory(&cai, sizeof(cai));
  1566. ZeroMemory(&caid, sizeof(caid));
  1567. csi.pAuthInfo = &cai;
  1568. cai.pAuthIdentityData = &caid;
  1569. // Create the remote config object
  1570. // ----------------------------------------------------------------
  1571. CORg( CoCreateRouterConfig(m_RtrConfigData.m_stServerName,
  1572. pRouter,
  1573. &csi,
  1574. IID_IRemoteNetworkConfig,
  1575. &punk) );
  1576. spNetwork = (IRemoteNetworkConfig *) punk;
  1577. punk = NULL;
  1578. // Upgrade the configuration (ensure that the registry keys
  1579. // are populated correctly).
  1580. // ------------------------------------------------------------
  1581. CORg( spNetwork->UpgradeRouterConfig() );
  1582. if ( !m_stPublicInterfaceId.IsEmpty()){
  1583. //kmurthy: Mark the public interface selected as uninteresting to DNS. Bug:380423
  1584. dnsHr = CoCreateRouterConfig(m_RtrConfigData.m_stServerName,
  1585. pRouter,
  1586. &csi,
  1587. IID_IRemoteSetDnsConfig,
  1588. &punk);
  1589. if(FHrSucceeded(dnsHr)){
  1590. spDns = (IRemoteSetDnsConfig *)punk;
  1591. CORg(spDns->SetDnsConfig((DWORD)DnsConfigWaitForNameErrorOnAll, NULL));
  1592. }
  1593. punk = NULL;
  1594. }
  1595. #ifdef KSL_IPINIP
  1596. // Remove the IP-in-IP tunnel names (since the registry has
  1597. // been cleared).
  1598. // ------------------------------------------------------------
  1599. CleanupTunnelFriendlyNames(pRouter);
  1600. #endif //KSL_IPINIP
  1601. // At this point, the current IRouterInfo pointer is invalid.
  1602. // We will need to release the pointer and reload the info.
  1603. // ------------------------------------------------------------
  1604. if (pRouter)
  1605. {
  1606. pRouter->DoDisconnect();
  1607. pRouter->Unload();
  1608. pRouter->Load(m_stServerName, NULL);
  1609. }
  1610. dwError = RtrWizFinish( &m_RtrConfigData, pRouter );
  1611. hr = HResultFromWin32(dwError);
  1612. // Windows NT Bug : 173564
  1613. // Depending on the router type, we will go through and enable the
  1614. // devices.
  1615. // If routing only is enabled : set devices to ROUTING
  1616. // If ras-only : set devices to RAS
  1617. // If ras/routing : set devices to RAS/ROUTING
  1618. // 5/19/98 - need some resolution from DavidEi on what to do here.
  1619. // ------------------------------------------------------------
  1620. // Setup the entries in the list
  1621. // ------------------------------------------------------------
  1622. if (m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN )
  1623. SetDeviceType(m_stServerName, m_dwRouterType, 256);
  1624. else
  1625. SetDeviceType(m_stServerName, m_dwRouterType, 10);
  1626. // Update the RADIUS config
  1627. // ----------------------------------------------------------------
  1628. SaveRadiusConfig();
  1629. //
  1630. //Add the NAT protocol if tcpip routing is selected
  1631. //
  1632. if ( (m_wizType != NewWizardRouterType_Custom) && (m_wizType != NewWizardRouterType_DialupOrVPN)
  1633. && m_RtrConfigData.m_ipData.m_dwAllowNetworkAccess )
  1634. AddNATToServer(this, &m_RtrConfigData, pRouter, m_fCreateDD, TRUE);
  1635. // Ok at this point we try to establish the server in the domain
  1636. // If this fails, we ignore the error and popup a warning message.
  1637. //
  1638. // Windows NT Bug : 202776
  1639. // Do not register the router if we are a LAN-only router.
  1640. // ----------------------------------------------------------------
  1641. if ( FHrSucceeded(hr) &&
  1642. (m_dwRouterType != ROUTER_TYPE_LAN) &&
  1643. (!m_fUseRadius))
  1644. {
  1645. HRESULT hrT = hrOK;
  1646. hrT = ::RegisterRouterInDomain(m_stServerName, TRUE);
  1647. if (hrT != ERROR_NO_SUCH_DOMAIN)
  1648. {
  1649. if (!FHrSucceeded(hrT))
  1650. {
  1651. CRasWarning dlg((char *)c_sazRRASDomainHelpTopic, IDS_ERR_CANNOT_REGISTER_IN_DS);
  1652. dlg.DoModal();
  1653. }
  1654. }
  1655. }
  1656. // NT Bug : 239384
  1657. // Install IGMP on the router by default (for RAS server only)
  1658. // Boing!, Change to whenever RAS is installed.
  1659. // ----------------------------------------------------------------
  1660. // We do NOT do this if we are using NAT. The reason is that
  1661. // NAT may want to be added to a demand dial interface.
  1662. // ----------------------------------------------------------------
  1663. //
  1664. // if ( m_wizType == NewWizardRouterType_VPNandNAT )
  1665. // m_stPrivateInterfaceId = m_stNATPrivateInterfaceId;
  1666. //
  1667. if (!(m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT ) ||
  1668. ((m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT ) && !m_fCreateDD))
  1669. {
  1670. // The path that NAT takes when creating the DD interface
  1671. // is somewhere else.
  1672. // ------------------------------------------------------------
  1673. Assert(m_fCreateDD == FALSE);
  1674. if (pRouter)
  1675. {
  1676. if (m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT )
  1677. {
  1678. AddIGMPToNATServer(this, &m_RtrConfigData, pRouter, (m_wizType == NewWizardRouterType_VPNandNAT));
  1679. }
  1680. else if (m_RtrConfigData.m_dwRouterType & ROUTER_TYPE_RAS)
  1681. {
  1682. AddIGMPToRasServer(&m_RtrConfigData, pRouter);
  1683. }
  1684. }
  1685. if (m_RtrConfigData.m_dwConfigFlags & RTRCONFIG_SETUP_NAT)
  1686. {
  1687. AddNATToServer(this, &m_RtrConfigData, pRouter, m_fCreateDD, FALSE);
  1688. }
  1689. else if ( m_wizType == NewWizardRouterType_Custom )
  1690. {
  1691. //
  1692. //If this is custom config and NAT is selected. Just add the protocol and
  1693. //nothing else.
  1694. //
  1695. AddNATToServer(this, &m_RtrConfigData, pRouter, m_fCreateDD, TRUE);
  1696. }
  1697. // Windows NT Bug : 371493
  1698. // Add the DHCP relay agent protocol
  1699. if (m_RtrConfigData.m_dwRouterType & ROUTER_TYPE_RAS)
  1700. {
  1701. DWORD dwDhcpServer = 0;
  1702. if (!m_stPrivateInterfaceId.IsEmpty())
  1703. {
  1704. RtrWizInterface * pRtrWizIf = NULL;
  1705. m_ifMap.Lookup(m_stPrivateInterfaceId, pRtrWizIf);
  1706. if (pRtrWizIf)
  1707. {
  1708. if (!pRtrWizIf->m_stDhcpServer.IsEmpty())
  1709. dwDhcpServer = INET_ADDR((LPCTSTR) pRtrWizIf->m_stDhcpServer);
  1710. // If we have a value of 0, or if the address
  1711. // is all 1's then we have a bogus address.
  1712. if ((dwDhcpServer == 0) ||
  1713. (dwDhcpServer == MAKEIPADDRESS(255,255,255,255))){
  1714. CRasWarning dlg("RRASconcepts.chm::/mpr_how_dhcprelay.htm", IDS_WRN_RTRWIZ_NO_DHCP_SERVER);
  1715. dlg.DoModal();
  1716. }
  1717. }
  1718. }
  1719. AddIPBOOTPToServer(&m_RtrConfigData, pRouter, dwDhcpServer);
  1720. }
  1721. }
  1722. // if ( m_wizType == NewWizardRouterType_VPNandNAT )
  1723. // m_stPrivateInterfaceId = sTempPrivateIfID;
  1724. // If this is a VPN, add the filters to the public interface
  1725. // ----------------------------------------------------------------
  1726. if ( (m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN) &&
  1727. (m_wizType == NewWizardRouterType_DialupOrVPN) &&
  1728. m_fSetVPNFilter )
  1729. {
  1730. if ((!m_stPublicInterfaceId.IsEmpty()) && (m_fSetVPNFilter == TRUE))
  1731. {
  1732. #if __USE_ICF__
  1733. m_RtrConfigData.m_dwConfigFlags |= RTRCONFIG_SETUP_NAT;
  1734. AddNATToServer(this, &m_RtrConfigData, pRouter, m_fCreateDD, FALSE);
  1735. #else
  1736. RtrWizInterface* pIf = NULL;
  1737. m_ifMap.Lookup(m_stPublicInterfaceId, pIf);
  1738. AddVPNFiltersToInterface(pRouter, m_stPublicInterfaceId, pIf);
  1739. DisableDDNSandNetBtOnInterface ( pRouter, m_stPublicInterfaceId, pIf);
  1740. #endif
  1741. }
  1742. }
  1743. //
  1744. // Bug 519414
  1745. // Since IAS now has a Microsoft policy with the appropriate settings,
  1746. // there is no longer a single default policy. In addition there is
  1747. // no need to update any policy to have the required settings since the
  1748. // Microsoft VPN server policy does the job.
  1749. //
  1750. #if __DEFAULT_POLICY
  1751. // Try to update the policy.
  1752. // ----------------------------------------------------------------
  1753. // This should check the auth flags and the value of the flags
  1754. // should follow that.
  1755. // ----------------------------------------------------------------
  1756. if ((m_RtrConfigData.m_dwRouterType & ROUTER_TYPE_RAS) && !m_fUseRadius)
  1757. {
  1758. LPWSTR pswzServerName = NULL;
  1759. DWORD dwFlags;
  1760. BOOL fRequireEncryption;
  1761. if (!IsLocalMachine(m_stServerName))
  1762. pswzServerName = (LPTSTR)(LPCTSTR) m_stServerName;
  1763. dwFlags = m_RtrConfigData.m_authData.m_dwFlags;
  1764. // Only require encryption if this is a VPN server
  1765. // do not set the PPPCFG_RequireEncryption flag
  1766. // ------------------------------------------------------------
  1767. fRequireEncryption = (m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN );
  1768. hr = UpdateDefaultPolicy(pswzServerName,
  1769. !!(dwFlags & PPPCFG_NegotiateMSCHAP),
  1770. !!(dwFlags & PPPCFG_NegotiateStrongMSCHAP),
  1771. fRequireEncryption);
  1772. if (!FHrSucceeded(hr))
  1773. {
  1774. if (hr == ERROR_NO_DEFAULT_PROFILE)
  1775. {
  1776. // Do one thing
  1777. AfxMessageBox(IDS_ERR_CANNOT_FIND_DEFAULT_RAP, MB_OK | MB_ICONEXCLAMATION);
  1778. // since we already displayed the warning
  1779. hr = S_OK;
  1780. }
  1781. else
  1782. {
  1783. // Format the message
  1784. AddSystemErrorMessage(hr);
  1785. // popup a warning dialog
  1786. AddHighLevelErrorStringId(IDS_ERR_CANNOT_SYNC_WITH_RAP);
  1787. DisplayTFSErrorMessage(NULL);
  1788. }
  1789. }
  1790. }
  1791. #endif
  1792. // Always start the router.
  1793. // ----------------------------------------------------------------
  1794. SetRouterServiceStartType(m_stServerName,
  1795. SERVICE_AUTO_START);
  1796. {
  1797. if(!mesgflag){ //If the mesgflag is TRUE, all UI should be suppressed and service need not be started.
  1798. // If this is manual start, we need to prompt them
  1799. // ------------------------------------------------------------
  1800. if ((m_wizType != NewWizardRouterType_Custom) ||
  1801. (AfxMessageBox(IDS_PROMPT_START_ROUTER_AFTER_INSTALL,
  1802. MB_YESNO | MB_TASKMODAL | MB_SETFOREGROUND) == IDYES))
  1803. {
  1804. CWaitCursor wait;
  1805. StartRouterService(m_RtrConfigData.m_stServerName);
  1806. }
  1807. }
  1808. }
  1809. if ( m_fUseDD && m_wizType == NewWizardRouterType_DOD)
  1810. {
  1811. HRESULT hr;
  1812. hr = CallRouterEntryDlg(NULL,
  1813. this,
  1814. 0);
  1815. if (!FHrSucceeded(hr)){
  1816. DisableRRAS((TCHAR *)(LPCTSTR)m_stServerName);
  1817. }
  1818. }
  1819. // Mark this data structure as been saved. This way, when we
  1820. // reennter this function it doesn't get run again.
  1821. // ----------------------------------------------------------------
  1822. m_fSaved = TRUE;
  1823. Error:
  1824. // Force a router reconfiguration
  1825. // ----------------------------------------------------------------
  1826. // Force a full disconnect
  1827. // This will force the handles to be released
  1828. // ----------------------------------------------------------------
  1829. pRouter->DoDisconnect();
  1830. // ForceGlobalRefresh(m_spRouter);
  1831. // Get the error back
  1832. // ----------------------------------------------------------------
  1833. if (!FHrSucceeded(hr))
  1834. {
  1835. AddSystemErrorMessage(hr);
  1836. AddHighLevelErrorStringId(IDS_ERR_CANNOT_INSTALL_ROUTER);
  1837. DisplayTFSErrorMessage(NULL);
  1838. }
  1839. if (csi.pAuthInfo)
  1840. delete csi.pAuthInfo->pAuthIdentityData->Password;
  1841. m_hr = hr;
  1842. return hr;
  1843. }
  1844. /*!--------------------------------------------------------------------------
  1845. NewRtrWizData::SaveRadiusConfig
  1846. -
  1847. Author: KennT
  1848. ---------------------------------------------------------------------------*/
  1849. HRESULT NewRtrWizData::SaveRadiusConfig()
  1850. {
  1851. HRESULT hr = hrOK;
  1852. HKEY hkeyMachine = NULL;
  1853. RADIUSSERVER rgServers[2];
  1854. RADIUSSERVER * pServers = NULL;
  1855. CRadiusServers oldServers;
  1856. BOOL fServerAdded = FALSE;
  1857. CWRg( ConnectRegistry((LPTSTR) (LPCTSTR) m_stServerName, &hkeyMachine) );
  1858. if (m_fUseRadius)
  1859. {
  1860. pServers = rgServers;
  1861. Assert(!m_stRadius1.IsEmpty() || !m_stRadius2.IsEmpty());
  1862. // Setup the pServers
  1863. if (!m_stRadius1.IsEmpty() && m_stRadius1.GetLength())
  1864. {
  1865. pServers->UseDefaults();
  1866. pServers->cScore = MAXSCORE;
  1867. // For compatibility with other RADIUS servers, we
  1868. // default this to OFF.
  1869. pServers->fUseDigitalSignatures = FALSE;
  1870. StrnCpy(pServers->szName, (LPCTSTR) m_stRadius1, MAX_PATH);
  1871. StrnCpy(pServers->wszSecret, (LPCTSTR) m_stRadiusSecret, MAX_PATH);
  1872. pServers->cchSecret = m_stRadiusSecret.GetLength();
  1873. pServers->IPAddress.sin_addr.s_addr = m_netRadius1IpAddress;
  1874. pServers->ucSeed = m_uSeed;
  1875. pServers->pNext = NULL;
  1876. fServerAdded = TRUE;
  1877. }
  1878. if (!m_stRadius2.IsEmpty() && m_stRadius2.GetLength())
  1879. {
  1880. // Have the previous one point here
  1881. if (fServerAdded)
  1882. {
  1883. pServers->pNext = pServers+1;
  1884. pServers++;
  1885. }
  1886. pServers->UseDefaults();
  1887. pServers->cScore = MAXSCORE - 1;
  1888. // For compatibility with other RADIUS servers, we
  1889. // default this to OFF.
  1890. pServers->fUseDigitalSignatures = FALSE;
  1891. StrnCpy(pServers->szName, (LPCTSTR) m_stRadius2, MAX_PATH);
  1892. StrnCpy(pServers->wszSecret, (LPCTSTR) m_stRadiusSecret, MAX_PATH);
  1893. pServers->cchSecret = m_stRadiusSecret.GetLength();
  1894. pServers->IPAddress.sin_addr.s_addr = m_netRadius2IpAddress;
  1895. pServers->ucSeed = m_uSeed;
  1896. pServers->pNext = NULL;
  1897. fServerAdded = TRUE;
  1898. }
  1899. // Ok, reset pServers
  1900. if (fServerAdded)
  1901. pServers = rgServers;
  1902. }
  1903. // Load the original server list and remove it from the
  1904. // LSA database.
  1905. LoadRadiusServers(m_stServerName,
  1906. hkeyMachine,
  1907. TRUE,
  1908. &oldServers,
  1909. RADIUS_FLAG_NOUI | RADIUS_FLAG_NOIP);
  1910. DeleteRadiusServers(m_stServerName,
  1911. oldServers.GetNextServer(TRUE));
  1912. oldServers.FreeAllServers();
  1913. LoadRadiusServers(m_stServerName,
  1914. hkeyMachine,
  1915. FALSE,
  1916. &oldServers,
  1917. RADIUS_FLAG_NOUI | RADIUS_FLAG_NOIP);
  1918. DeleteRadiusServers(m_stServerName,
  1919. oldServers.GetNextServer(TRUE));
  1920. // Save the authentication servers
  1921. CORg( SaveRadiusServers(m_stServerName,
  1922. hkeyMachine,
  1923. TRUE,
  1924. pServers) );
  1925. // Save the accounting servers
  1926. CORg( SaveRadiusServers(m_stServerName,
  1927. hkeyMachine,
  1928. FALSE,
  1929. pServers) );
  1930. Error:
  1931. if (hkeyMachine)
  1932. DisconnectRegistry(hkeyMachine);
  1933. m_hr = hr;
  1934. return hr;
  1935. }
  1936. /*---------------------------------------------------------------------------
  1937. CNewRtrWizPageBase Implementation
  1938. ---------------------------------------------------------------------------*/
  1939. PageStack CNewRtrWizPageBase::m_pagestack;
  1940. CNewRtrWizPageBase::CNewRtrWizPageBase(UINT idd, PageType pt)
  1941. : CPropertyPageBase(idd),
  1942. m_pagetype(pt),
  1943. m_pRtrWizData(NULL),
  1944. m_uDialogId(idd)
  1945. {
  1946. }
  1947. BEGIN_MESSAGE_MAP(CNewRtrWizPageBase, CPropertyPageBase)
  1948. //{{AFX_MSG_MAP(CNewWizTestParams)
  1949. ON_MESSAGE(WM_HELP, OnHelp)
  1950. //}}AFX_MSG_MAP
  1951. END_MESSAGE_MAP()
  1952. static DWORD s_rgBulletId[] =
  1953. {
  1954. IDC_NEWWIZ_BULLET_1,
  1955. IDC_NEWWIZ_BULLET_2,
  1956. IDC_NEWWIZ_BULLET_3,
  1957. IDC_NEWWIZ_BULLET_4,
  1958. 0
  1959. };
  1960. BOOL CNewRtrWizPageBase::OnInitDialog()
  1961. {
  1962. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  1963. CWnd * pWnd = GetDlgItem(IDC_NEWWIZ_BIGTEXT);
  1964. HICON hIcon;
  1965. CWnd * pBulletWnd;
  1966. CString strFontName;
  1967. CString strFontSize;
  1968. BOOL fCreateFont = FALSE;
  1969. CPropertyPageBase::OnInitDialog();
  1970. if (pWnd)
  1971. {
  1972. // Ok we have to create the font
  1973. strFontName.LoadString(IDS_LARGEFONTNAME);
  1974. strFontSize.LoadString(IDS_LARGEFONTSIZE);
  1975. if (m_fontBig.CreatePointFont(10*_ttoi(strFontSize), strFontName))
  1976. {
  1977. pWnd->SetFont(&m_fontBig);
  1978. }
  1979. }
  1980. // Set the fonts to show up as bullets
  1981. for (int i=0; s_rgBulletId[i] != 0; i++)
  1982. {
  1983. pBulletWnd = GetDlgItem(s_rgBulletId[i]);
  1984. if (pBulletWnd)
  1985. {
  1986. // Only create the font if needed
  1987. if (!fCreateFont)
  1988. {
  1989. strFontName.LoadString(IDS_BULLETFONTNAME);
  1990. strFontSize.LoadString(IDS_BULLETFONTSIZE);
  1991. m_fontBullet.CreatePointFont(10*_ttoi(strFontSize), strFontName);
  1992. fCreateFont = TRUE;
  1993. }
  1994. pBulletWnd->SetFont(&m_fontBullet);
  1995. }
  1996. }
  1997. pWnd = GetDlgItem(IDC_NEWWIZ_ICON_WARNING);
  1998. if (pWnd)
  1999. {
  2000. hIcon = AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION);
  2001. ((CStatic *) pWnd)->SetIcon(hIcon);
  2002. }
  2003. pWnd = GetDlgItem(IDC_NEWWIZ_ICON_INFORMATION);
  2004. if (pWnd)
  2005. {
  2006. hIcon = AfxGetApp()->LoadStandardIcon(IDI_INFORMATION);
  2007. ((CStatic *) pWnd)->SetIcon(hIcon);
  2008. }
  2009. return TRUE;
  2010. }
  2011. /*!--------------------------------------------------------------------------
  2012. CNewRtrWizPageBase::PushPage
  2013. -
  2014. Author: KennT
  2015. ---------------------------------------------------------------------------*/
  2016. void CNewRtrWizPageBase::PushPage(UINT idd)
  2017. {
  2018. m_pagestack.AddHead(idd);
  2019. }
  2020. /*!--------------------------------------------------------------------------
  2021. CNewRtrWizPageBase::PopPage
  2022. -
  2023. Author: KennT
  2024. ---------------------------------------------------------------------------*/
  2025. UINT CNewRtrWizPageBase::PopPage()
  2026. {
  2027. if (m_pagestack.IsEmpty())
  2028. return 0;
  2029. return m_pagestack.RemoveHead();
  2030. }
  2031. /*!--------------------------------------------------------------------------
  2032. CNewRtrWizPageBase::OnSetActive
  2033. -
  2034. Author: KennT
  2035. ---------------------------------------------------------------------------*/
  2036. BOOL CNewRtrWizPageBase::OnSetActive()
  2037. {
  2038. switch (m_pagetype)
  2039. {
  2040. case Start:
  2041. GetHolder()->SetWizardButtonsFirst(TRUE);
  2042. break;
  2043. case Middle:
  2044. GetHolder()->SetWizardButtonsMiddle(TRUE);
  2045. break;
  2046. default:
  2047. case Finish:
  2048. GetHolder()->SetWizardButtonsLast(TRUE);
  2049. break;
  2050. }
  2051. return CPropertyPageBase::OnSetActive();
  2052. }
  2053. /*!--------------------------------------------------------------------------
  2054. CNewRtrWizPageBase::OnCancel
  2055. -
  2056. Author: KennT
  2057. ---------------------------------------------------------------------------*/
  2058. void CNewRtrWizPageBase::OnCancel()
  2059. {
  2060. m_pRtrWizData->m_hr = HResultFromWin32(ERROR_CANCELLED);
  2061. }
  2062. /*!--------------------------------------------------------------------------
  2063. CNewRtrWizPageBase::OnWizardNext
  2064. -
  2065. Author: KennT
  2066. ---------------------------------------------------------------------------*/
  2067. LRESULT CNewRtrWizPageBase::OnWizardNext()
  2068. {
  2069. HRESULT hr = hrOK;
  2070. LRESULT lResult;
  2071. // Tell the page to save it's state
  2072. m_pRtrWizData->m_hr = hr = OnSavePage();
  2073. if (FHrSucceeded(hr))
  2074. {
  2075. // Now figure out where to go next
  2076. Assert(m_pRtrWizData);
  2077. lResult = m_pRtrWizData->GetNextPage(m_uDialogId);
  2078. switch (lResult)
  2079. {
  2080. case ERR_IDD_FINISH_WIZARD:
  2081. OnWizardFinish();
  2082. // fall through to the cancel case
  2083. case ERR_IDD_CANCEL_WIZARD:
  2084. GetHolder()->PressButton(PSBTN_CANCEL);
  2085. m_pRtrWizData->m_hr = HResultFromWin32(ERROR_CANCELLED);
  2086. lResult = -1;
  2087. break;
  2088. default:
  2089. // Push the page only if we are going to another page
  2090. // The other cases will cause the wizard to exit, and
  2091. // we don't need the page stack.
  2092. // ----------------------------------------------------
  2093. if (lResult != -1)
  2094. PushPage(m_uDialogId);
  2095. break;
  2096. }
  2097. return lResult;
  2098. }
  2099. else
  2100. return (LRESULT) -1; // error! do not change the page
  2101. }
  2102. /*!--------------------------------------------------------------------------
  2103. CNewRtrWizPageBase::OnWizardBack
  2104. -
  2105. Author: KennT
  2106. ---------------------------------------------------------------------------*/
  2107. LRESULT CNewRtrWizPageBase::OnWizardBack()
  2108. {
  2109. Assert(!m_pagestack.IsEmpty());
  2110. // a special case
  2111. if(m_uDialogId == IDD_NEWRTRWIZ_USERADIUS){
  2112. m_pRtrWizData->m_fUseRadius = FALSE;
  2113. }
  2114. return PopPage();
  2115. }
  2116. /*!--------------------------------------------------------------------------
  2117. CNewRtrWizPageBase::OnWizardFinish
  2118. -
  2119. Author: KennT
  2120. ---------------------------------------------------------------------------*/
  2121. BOOL CNewRtrWizPageBase::OnWizardFinish()
  2122. {
  2123. GetHolder()->OnFinish();
  2124. return TRUE;
  2125. }
  2126. HRESULT CNewRtrWizPageBase::OnSavePage()
  2127. {
  2128. return hrOK;
  2129. }
  2130. LRESULT CNewRtrWizPageBase::OnHelp(WPARAM, LPARAM lParam)
  2131. {
  2132. HELPINFO * pHelpInfo = (HELPINFO *) lParam;
  2133. // Windows NT Bug : 408722
  2134. // Put the help call here, this should only come in from
  2135. // the call from the dialog.
  2136. if (pHelpInfo->dwContextId == 0xdeadbeef)
  2137. {
  2138. HtmlHelpA(NULL, c_sazRRASDomainHelpTopic, HH_DISPLAY_TOPIC, 0);
  2139. return TRUE;
  2140. }
  2141. return FALSE;
  2142. }
  2143. /*---------------------------------------------------------------------------
  2144. CNewRtrWizFinishPageBase Implementation
  2145. ---------------------------------------------------------------------------*/
  2146. CNewRtrWizFinishPageBase::CNewRtrWizFinishPageBase(UINT idd,
  2147. RtrWizFinishSaveFlag SaveFlag,
  2148. RtrWizFinishHelpFlag HelpFlag)
  2149. : CNewRtrWizPageBase(idd, CNewRtrWizPageBase::Finish),
  2150. m_SaveFlag(SaveFlag),
  2151. m_HelpFlag(HelpFlag)
  2152. {
  2153. }
  2154. BEGIN_MESSAGE_MAP(CNewRtrWizFinishPageBase, CNewRtrWizPageBase)
  2155. //{{AFX_MSG_MAP(CNewWizTestParams)
  2156. //}}AFX_MSG_MAP
  2157. END_MESSAGE_MAP()
  2158. static DWORD s_rgServerNameId[] =
  2159. {
  2160. IDC_NEWWIZ_TEXT_SERVER_NAME,
  2161. IDC_NEWWIZ_TEXT_SERVER_NAME_2,
  2162. 0
  2163. };
  2164. static DWORD s_rgInterfaceId[] =
  2165. {
  2166. IDC_NEWWIZ_TEXT_INTERFACE_1, IDS_RTRWIZ_INTERFACE_NAME_1,
  2167. IDC_NEWWIZ_TEXT_INTERFACE_2, IDS_RTRWIZ_INTERFACE_2,
  2168. 0,0
  2169. };
  2170. /*!--------------------------------------------------------------------------
  2171. CNewRtrWizFinishPageBase::OnInitDialog
  2172. -
  2173. Author: KennT
  2174. ---------------------------------------------------------------------------*/
  2175. BOOL CNewRtrWizFinishPageBase::OnInitDialog()
  2176. {
  2177. CString st, stBase;
  2178. CNewRtrWizPageBase::OnInitDialog();
  2179. // If there is a control that wants a server name, replace it
  2180. for (int i=0; s_rgServerNameId[i]; i++)
  2181. {
  2182. if (GetDlgItem(s_rgServerNameId[i]))
  2183. {
  2184. GetDlgItemText(s_rgServerNameId[i], stBase);
  2185. st.Format((LPCTSTR) stBase,
  2186. (LPCTSTR) m_pRtrWizData->m_stServerName);
  2187. SetDlgItemText(s_rgServerNameId[i], st);
  2188. }
  2189. }
  2190. if (GetDlgItem(IDC_NEWWIZ_TEXT_ERROR))
  2191. {
  2192. TCHAR szErr[2048];
  2193. Assert(!FHrOK(m_pRtrWizData->m_hrDDError));
  2194. FormatRasError(m_pRtrWizData->m_hrDDError, szErr, DimensionOf(szErr));
  2195. GetDlgItemText(IDC_NEWWIZ_TEXT_ERROR, stBase);
  2196. st.Format((LPCTSTR) stBase,
  2197. szErr);
  2198. SetDlgItemText(IDC_NEWWIZ_TEXT_ERROR, (LPCTSTR) st);
  2199. }
  2200. return TRUE;
  2201. }
  2202. /*!--------------------------------------------------------------------------
  2203. CNewRtrWizFinishPageBase::OnSetActive
  2204. -
  2205. Author: KennT
  2206. ---------------------------------------------------------------------------*/
  2207. BOOL CNewRtrWizFinishPageBase::OnSetActive()
  2208. {
  2209. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  2210. DWORD i;
  2211. CString st;
  2212. CString stIfName;
  2213. RtrWizInterface * pRtrWizIf = NULL;
  2214. // Handle support for displaying the interface name on the
  2215. // finish page. We need to do it in the OnSetActive() rather
  2216. // than the OnInitDialog() since the interface chosen can change.
  2217. // Try to find the inteface name
  2218. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPublicInterfaceId,
  2219. pRtrWizIf);
  2220. if (pRtrWizIf)
  2221. stIfName = pRtrWizIf->m_stName;
  2222. else
  2223. {
  2224. // This may be the dd interface case. If we are creating
  2225. // a DD interface the name will never have been added to the
  2226. // interface map.
  2227. stIfName = m_pRtrWizData->m_stPublicInterfaceId;
  2228. }
  2229. for (i=0; s_rgInterfaceId[i] != 0; i+=2)
  2230. {
  2231. if (GetDlgItem(s_rgInterfaceId[i]))
  2232. {
  2233. st.Format(s_rgInterfaceId[i+1], (LPCTSTR) stIfName);
  2234. SetDlgItemText(s_rgInterfaceId[i], st);
  2235. }
  2236. }
  2237. return CNewRtrWizPageBase::OnSetActive();
  2238. }
  2239. /*!--------------------------------------------------------------------------
  2240. CNewRtrWizFinishPageBase::OnWizardFinish
  2241. -
  2242. Author: KennT
  2243. ---------------------------------------------------------------------------*/
  2244. BOOL CNewRtrWizFinishPageBase::OnWizardFinish()
  2245. {
  2246. m_pRtrWizData->m_SaveFlag = m_SaveFlag;
  2247. // If there is a help button and it is not checked,
  2248. // then do not bring up the help.
  2249. if (!GetDlgItem(IDC_NEWWIZ_CHK_HELP) ||
  2250. (GetDlgItem(IDC_NEWWIZ_CHK_HELP) &&
  2251. !IsDlgButtonChecked(IDC_NEWWIZ_CHK_HELP)))
  2252. m_pRtrWizData->m_HelpFlag = HelpFlag_Nothing;
  2253. else
  2254. m_pRtrWizData->m_HelpFlag = m_HelpFlag;
  2255. return CNewRtrWizPageBase::OnWizardFinish();
  2256. }
  2257. /////////////////////////////////////////////////////////////////////////////
  2258. //
  2259. // CNewRtrWiz holder
  2260. //
  2261. /////////////////////////////////////////////////////////////////////////////
  2262. CNewRtrWiz::CNewRtrWiz(
  2263. ITFSNode * pNode,
  2264. IRouterInfo * pRouter,
  2265. IComponentData * pComponentData,
  2266. ITFSComponentData * pTFSCompData,
  2267. LPCTSTR pszSheetName,
  2268. BOOL fInvokedInMMC,
  2269. DWORD dwExpressType
  2270. ) :
  2271. CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  2272. {
  2273. LinkWindow_RegisterClass();
  2274. //ASSERT(pFolderNode == GetContainerNode());
  2275. //if this is not done, deadlock can happen
  2276. EnablePeekMessageDuringNotifyConsole(TRUE);
  2277. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  2278. Assert(pTFSCompData != NULL);
  2279. m_spTFSCompData.Set(pTFSCompData);
  2280. m_bWiz97 = TRUE;
  2281. m_fInvokedInMMC = fInvokedInMMC;
  2282. m_dwExpressType = dwExpressType;
  2283. m_spRouter.Set(pRouter);
  2284. if ( MPRSNAP_CYS_EXPRESS_NONE != dwExpressType )
  2285. m_bAutoDelete = FALSE;
  2286. }
  2287. CNewRtrWiz::~CNewRtrWiz()
  2288. {
  2289. POSITION pos;
  2290. CNewRtrWizPageBase *pPageBase;
  2291. pos = m_pagelist.GetHeadPosition();
  2292. while (pos)
  2293. {
  2294. pPageBase = m_pagelist.GetNext(pos);
  2295. RemovePageFromList(static_cast<CPropertyPageBase *>(pPageBase), FALSE);
  2296. }
  2297. m_pagelist.RemoveAll();
  2298. }
  2299. /*!--------------------------------------------------------------------------
  2300. CNewRtrWiz::Init
  2301. -
  2302. Author: KennT
  2303. ---------------------------------------------------------------------------*/
  2304. HRESULT CNewRtrWiz::Init(LPCTSTR pServerName)
  2305. {
  2306. HRESULT hr = hrOK;
  2307. POSITION pos;
  2308. CNewRtrWizPageBase *pPageBase;
  2309. m_RtrWizData.Init(pServerName, m_spRouter, m_dwExpressType);
  2310. m_RtrWizData.m_stServerName = pServerName;
  2311. // Setup the list of pages
  2312. //0
  2313. m_pagelist.AddTail(&m_pageWelcome);
  2314. //1
  2315. m_pagelist.AddTail(&m_pageCommonConfig);
  2316. //2
  2317. m_pagelist.AddTail(&m_pageNatFinishAConflict);
  2318. //3
  2319. m_pagelist.AddTail(&m_pageNatFinishAConflictNonLocal);
  2320. //4
  2321. m_pagelist.AddTail(&m_pageNatFinishNoIP);
  2322. //5
  2323. m_pagelist.AddTail(&m_pageNatFinishNoIPNonLocal);
  2324. //6
  2325. m_pagelist.AddTail(&m_pageNatSelectPublic);
  2326. // 7
  2327. m_pagelist.AddTail ( &m_pageCustomConfig);
  2328. // 8
  2329. m_pagelist.AddTail ( &m_pageRRasVPN);
  2330. // 9
  2331. m_pagelist.AddTail(&m_pageNatSelectPrivate);
  2332. m_pagelist.AddTail(&m_pageNatFinishAdvancedNoNICs);
  2333. m_pagelist.AddTail(&m_pageNatDHCPDNS);
  2334. m_pagelist.AddTail(&m_pageNatDHCPWarning);
  2335. m_pagelist.AddTail(&m_pageNatDDWarning);
  2336. m_pagelist.AddTail(&m_pageNatFinish);
  2337. m_pagelist.AddTail(&m_pageNatFinishExternal);
  2338. m_pagelist.AddTail(&m_pageNatFinishDDError);
  2339. m_pagelist.AddTail(&m_pageRasFinishNeedProtocols);
  2340. m_pagelist.AddTail(&m_pageRasFinishNeedProtocolsNonLocal);
  2341. m_pagelist.AddTail(&m_pageRasNoNICs);
  2342. m_pagelist.AddTail(&m_pageRasFinishNoNICs);
  2343. m_pagelist.AddTail(&m_pageRasNetwork);
  2344. m_pagelist.AddTail(&m_pageRasFinishAdvanced);
  2345. m_pagelist.AddTail(&m_pageVpnFinishNoNICs);
  2346. m_pagelist.AddTail(&m_pageVpnFinishNoIP);
  2347. m_pagelist.AddTail(&m_pageVpnFinishNoIPNonLocal);
  2348. m_pagelist.AddTail(&m_pageVpnFinishNeedProtocols);
  2349. m_pagelist.AddTail(&m_pageVpnFinishNeedProtocolsNonLocal);
  2350. m_pagelist.AddTail(&m_pageVpnSelectPublic);
  2351. m_pagelist.AddTail(&m_pageVpnSelectPrivate);
  2352. m_pagelist.AddTail(&m_pageVpnFinishAdvanced);
  2353. m_pagelist.AddTail(&m_pageRASVpnFinishAdvanced);
  2354. m_pagelist.AddTail(&m_pageNATVpnFinishAdvanced);
  2355. m_pagelist.AddTail(&m_pageRouterFinishNeedProtocols);
  2356. m_pagelist.AddTail(&m_pageRouterFinishNeedProtocolsNonLocal);
  2357. m_pagelist.AddTail(&m_pageRouterUseDD);
  2358. m_pagelist.AddTail(&m_pageRouterFinish);
  2359. m_pagelist.AddTail(&m_pageRouterFinishDD);
  2360. m_pagelist.AddTail(&m_pageManualFinish);
  2361. m_pagelist.AddTail(&m_pageAddressing);
  2362. m_pagelist.AddTail(&m_pageAddressPool);
  2363. m_pagelist.AddTail(&m_pageRadius);
  2364. m_pagelist.AddTail(&m_pageRadiusConfig);
  2365. // Initialize all of the pages
  2366. pos = m_pagelist.GetHeadPosition();
  2367. while (pos)
  2368. {
  2369. pPageBase = m_pagelist.GetNext(pos);
  2370. pPageBase->Init(&m_RtrWizData, this);
  2371. }
  2372. // Add all of the pages to the property sheet
  2373. pos = m_pagelist.GetHeadPosition();
  2374. while (pos)
  2375. {
  2376. pPageBase = m_pagelist.GetNext(pos);
  2377. AddPageToList(static_cast<CPropertyPageBase *>(pPageBase));
  2378. }
  2379. return hr;
  2380. }
  2381. //
  2382. //This is the real Wiz97 flag. Dont use PSH_WIZARD97.
  2383. //You'll get unpredictable results.
  2384. #define REAL_PSH_WIZARD97 0x01000000
  2385. HRESULT CNewRtrWiz::DoModalWizard()
  2386. {
  2387. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2388. HRESULT hr = hrOK;
  2389. if ( m_fInvokedInMMC )
  2390. {
  2391. return CPropertyPageHolderBase::DoModalWizard();
  2392. }
  2393. else
  2394. {
  2395. m_fSetDefaultSheetPos = NULL;
  2396. PROPSHEETHEADER psh;
  2397. ZeroMemory ( &psh, sizeof(psh) );
  2398. psh.dwSize = sizeof(psh);
  2399. psh.dwFlags = REAL_PSH_WIZARD97|
  2400. PSH_USEHBMHEADER|
  2401. PSH_USEHBMWATERMARK|
  2402. PSH_WATERMARK|
  2403. PSH_HEADER|
  2404. PSH_NOAPPLYNOW;
  2405. psh.hwndParent = GetActiveWindow();
  2406. psh.hInstance = AfxGetInstanceHandle();
  2407. psh.pszCaption = (LPCTSTR)m_stSheetTitle.GetBuffer(m_stSheetTitle.GetLength()+1);
  2408. psh.hbmHeader = g_wmi.hHeader;
  2409. psh.hbmWatermark = g_wmi.hWatermark;
  2410. psh.hplWatermark = g_wmi.hPalette;
  2411. psh.nStartPage = m_RtrWizData.GetStartPageId();
  2412. psh.nPages = m_pageList.GetCount();
  2413. psh.phpage = new HPROPSHEETPAGE[psh.nPages ];
  2414. if ( NULL == psh.phpage )
  2415. {
  2416. m_RtrWizData.m_hr = E_OUTOFMEMORY;
  2417. return m_RtrWizData.m_hr;
  2418. }
  2419. //now setup all the pages in the psh structure
  2420. POSITION pos;
  2421. DWORD dw=0;
  2422. //For cys we do only wiz97 standard
  2423. for( pos = m_pageList.GetHeadPosition(); pos != NULL; )
  2424. {
  2425. CPropertyPageBase* pPage = m_pageList.GetNext(pos);
  2426. pPage->m_psp97.dwFlags &= ~PSP_HASHELP;
  2427. HPROPSHEETPAGE hPage;
  2428. hPage = ::CreatePropertySheetPage(&pPage->m_psp97);
  2429. if (hPage == NULL)
  2430. {
  2431. m_RtrWizData.m_hr = E_UNEXPECTED;
  2432. return m_RtrWizData.m_hr;
  2433. }
  2434. else
  2435. {
  2436. pPage->m_hPage = hPage;
  2437. *(psh.phpage+dw) = hPage;
  2438. dw++;
  2439. }
  2440. }
  2441. if ( PropertySheet (&psh ) == -1 )
  2442. {
  2443. m_RtrWizData.m_hr = HResultFromWin32(GetLastError());
  2444. }
  2445. }
  2446. return m_RtrWizData.m_hr;
  2447. }
  2448. /*!--------------------------------------------------------------------------
  2449. CNewRtrWiz::OnFinish
  2450. Called from the OnWizardFinish
  2451. Author: KennT
  2452. ---------------------------------------------------------------------------*/
  2453. DWORD CNewRtrWiz::OnFinish()
  2454. {
  2455. DWORD dwError = ERROR_SUCCESS;
  2456. RtrWizInterface * pRtrWizIf = NULL;
  2457. TCHAR szBuffer[1024];
  2458. CString st;
  2459. LPCTSTR pszHelpString = NULL;
  2460. STARTUPINFO si;
  2461. PROCESS_INFORMATION pi;
  2462. #if defined(DEBUG) && defined(kennt)
  2463. if (m_RtrWizData.m_SaveFlag != SaveFlag_Advanced)
  2464. st += _T("NO configuration change required\n\n");
  2465. // For now, just display the test parameter output
  2466. switch (m_RtrWizData.m_wizType)
  2467. {
  2468. case NewRtrWizData::WizardRouterType_NAT:
  2469. st += _T("NAT\n");
  2470. break;
  2471. case NewRtrWizData::WizardRouterType_RAS:
  2472. st += _T("RAS\n");
  2473. break;
  2474. case NewRtrWizData::WizardRouterType_VPN:
  2475. st += _T("VPN\n");
  2476. break;
  2477. case NewRtrWizData::WizardRouterType_Router:
  2478. st += _T("Router\n");
  2479. break;
  2480. case NewRtrWizData::WizardRouterType_Manual:
  2481. st += _T("Manual\n");
  2482. break;
  2483. }
  2484. if (m_RtrWizData.m_fAdvanced)
  2485. st += _T("Advanced path\n");
  2486. else
  2487. st += _T("Simple path\n");
  2488. if (m_RtrWizData.m_fNeedMoreProtocols)
  2489. st += _T("Need to install more protocols\n");
  2490. if (m_RtrWizData.m_fCreateDD)
  2491. st += _T("Need to create a DD interface\n");
  2492. st += _T("Public interface : ");
  2493. m_RtrWizData.m_ifMap.Lookup(m_RtrWizData.m_stPublicInterfaceId, pRtrWizIf);
  2494. if (pRtrWizIf)
  2495. st += pRtrWizIf->m_stName;
  2496. st += _T("\n");
  2497. st += _T("Private interface : ");
  2498. m_RtrWizData.m_ifMap.Lookup(m_RtrWizData.m_stPrivateInterfaceId, pRtrWizIf);
  2499. if (pRtrWizIf)
  2500. st += pRtrWizIf->m_stName;
  2501. st += _T("\n");
  2502. if (m_RtrWizData.m_wizType == NewRtrWizData::WizardRouterType_NAT)
  2503. {
  2504. if (m_RtrWizData.m_fNatUseSimpleServers)
  2505. st += _T("NAT - use simple DHCP and DNS\n");
  2506. else
  2507. st += _T("NAT - use external DHCP and DNS\n");
  2508. }
  2509. if (m_RtrWizData.m_fWillBeInDomain)
  2510. st += _T("Will be in a domain\n");
  2511. if (m_RtrWizData.m_fNoNicsAreOk)
  2512. st += _T("No NICs is ok\n");
  2513. if (m_RtrWizData.m_fUseIpxType20Broadcasts)
  2514. st += _T("IPX should deliver Type20 broadcasts\n");
  2515. if (m_RtrWizData.m_fAppletalkUseNoAuth)
  2516. st += _T("Use unauthenticated access\n");
  2517. if (m_RtrWizData.m_fUseDHCP)
  2518. st += _T("Use DHCP for addressing\n");
  2519. else
  2520. st += _T("Use Static pools for addressing\n");
  2521. if (m_RtrWizData.m_fUseRadius)
  2522. {
  2523. st += _T("Use RADIUS\n");
  2524. st += _T("Server 1 : ");
  2525. st += m_RtrWizData.m_stRadius1;
  2526. st += _T("\n");
  2527. st += _T("Server 2 : ");
  2528. st += m_RtrWizData.m_stRadius2;
  2529. st += _T("\n");
  2530. }
  2531. if (m_RtrWizData.m_fTest)
  2532. {
  2533. if (AfxMessageBox(st, MB_OKCANCEL) == IDCANCEL)
  2534. return 0;
  2535. }
  2536. #endif
  2537. // else continue on, saving the real data
  2538. if (m_RtrWizData.m_SaveFlag == SaveFlag_Simple)
  2539. {
  2540. ::ZeroMemory(&si, sizeof(STARTUPINFO));
  2541. si.cb = sizeof(STARTUPINFO);
  2542. si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
  2543. si.wShowWindow = SW_SHOW;
  2544. ::ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
  2545. ExpandEnvironmentStrings(s_szConnectionUICommandLine,
  2546. szBuffer,
  2547. DimensionOf(szBuffer));
  2548. ::CreateProcess(NULL, // ptr to name of executable
  2549. szBuffer, // pointer to command line string
  2550. NULL, // process security attributes
  2551. NULL, // thread security attributes
  2552. FALSE, // handle inheritance flag
  2553. CREATE_NEW_CONSOLE,// creation flags
  2554. NULL, // ptr to new environment block
  2555. NULL, // ptr to current directory name
  2556. &si,
  2557. &pi);
  2558. ::CloseHandle(pi.hProcess);
  2559. ::CloseHandle(pi.hThread);
  2560. }
  2561. else if (m_RtrWizData.m_SaveFlag == SaveFlag_Advanced)
  2562. {
  2563. // Ok, we're done!
  2564. if (!m_RtrWizData.m_fTest)
  2565. {
  2566. // Get the owner window (i.e. the page)
  2567. // --------------------------------------------------------
  2568. HWND hWndOwner = PropSheet_GetCurrentPageHwnd(m_hSheetWindow);
  2569. m_RtrWizData.FinishTheDamnWizard(hWndOwner, m_spRouter);
  2570. }
  2571. }
  2572. if (m_RtrWizData.m_HelpFlag != HelpFlag_Nothing)
  2573. {
  2574. switch (m_RtrWizData.m_HelpFlag)
  2575. {
  2576. case HelpFlag_Nothing:
  2577. break;
  2578. case HelpFlag_ICS:
  2579. pszHelpString = s_szHowToAddICS;
  2580. break;
  2581. case HelpFlag_AddIp:
  2582. case HelpFlag_AddProtocol:
  2583. pszHelpString = s_szHowToAddAProtocol;
  2584. break;
  2585. case HelpFlag_InboundConnections:
  2586. pszHelpString = s_szHowToAddInboundConnections;
  2587. break;
  2588. case HelpFlag_GeneralNAT:
  2589. pszHelpString = s_szGeneralNATHelp;
  2590. break;
  2591. case HelpFlag_GeneralRAS:
  2592. pszHelpString = s_szGeneralRASHelp;
  2593. break;
  2594. case HelpFlag_UserAccounts:
  2595. pszHelpString = s_szUserAccounts;
  2596. break;
  2597. case HelpFlag_DemandDial:
  2598. pszHelpString = s_szDemandDialHelp;
  2599. break;
  2600. default:
  2601. Panic0("Unknown help flag specified!");
  2602. break;
  2603. }
  2604. LaunchHelpTopic(pszHelpString);
  2605. }
  2606. //
  2607. //Now for a special case
  2608. //check to see if the dhcp help has been set.
  2609. //if so show that help.
  2610. //
  2611. if ( m_RtrWizData.m_fShowDhcpHelp )
  2612. {
  2613. LaunchHelpTopic(s_szDhcp);
  2614. }
  2615. return dwError;
  2616. }
  2617. /*---------------------------------------------------------------------------
  2618. CNewWizTestParams Implementation
  2619. ---------------------------------------------------------------------------*/
  2620. BEGIN_MESSAGE_MAP(CNewWizTestParams, CBaseDialog)
  2621. //{{AFX_MSG_MAP(CNewWizTestParams)
  2622. //}}AFX_MSG_MAP
  2623. END_MESSAGE_MAP()
  2624. BOOL CNewWizTestParams::OnInitDialog()
  2625. {
  2626. CBaseDialog::OnInitDialog();
  2627. CheckDlgButton(IDC_NEWWIZ_TEST_LOCAL, m_pWizData->s_fIsLocalMachine);
  2628. CheckDlgButton(IDC_NEWWIZ_TEST_USE_IP, m_pWizData->s_fIpInstalled);
  2629. CheckDlgButton(IDC_NEWWIZ_TEST_USE_IPX, m_pWizData->s_fIpxInstalled);
  2630. CheckDlgButton(IDC_NEWWIZ_TEST_USE_ATLK, m_pWizData->s_fAppletalkInstalled);
  2631. CheckDlgButton(IDC_NEWWIZ_TEST_DNS, m_pWizData->s_fIsDNSRunningOnPrivateInterface);
  2632. CheckDlgButton(IDC_NEWWIZ_TEST_DHCP, m_pWizData->s_fIsDHCPRunningOnPrivateInterface);
  2633. CheckDlgButton(IDC_NEWWIZ_TEST_DOMAIN, m_pWizData->s_fIsMemberOfDomain);
  2634. CheckDlgButton(IDC_NEWWIZ_TEST_SHAREDACCESS, m_pWizData->s_fIsSharedAccessRunningOnServer);
  2635. SetDlgItemInt(IDC_NEWWIZ_TEST_EDIT_NUMNICS, m_pWizData->s_dwNumberOfNICs);
  2636. return TRUE;
  2637. }
  2638. void CNewWizTestParams::OnOK()
  2639. {
  2640. m_pWizData->s_fIsLocalMachine = IsDlgButtonChecked(IDC_NEWWIZ_TEST_LOCAL);
  2641. m_pWizData->s_fIpInstalled = IsDlgButtonChecked(IDC_NEWWIZ_TEST_USE_IP);
  2642. m_pWizData->s_fIpxInstalled = IsDlgButtonChecked(IDC_NEWWIZ_TEST_USE_IPX);
  2643. m_pWizData->s_fAppletalkInstalled = IsDlgButtonChecked(IDC_NEWWIZ_TEST_USE_ATLK);
  2644. m_pWizData->s_fIsDNSRunningOnPrivateInterface = IsDlgButtonChecked(IDC_NEWWIZ_TEST_DNS);
  2645. m_pWizData->s_fIsDHCPRunningOnPrivateInterface = IsDlgButtonChecked(IDC_NEWWIZ_TEST_DHCP);
  2646. m_pWizData->s_fIsMemberOfDomain = IsDlgButtonChecked(IDC_NEWWIZ_TEST_DOMAIN);
  2647. m_pWizData->s_dwNumberOfNICs = GetDlgItemInt(IDC_NEWWIZ_TEST_EDIT_NUMNICS);
  2648. m_pWizData->s_fIsSharedAccessRunningOnServer = IsDlgButtonChecked(IDC_NEWWIZ_TEST_SHAREDACCESS);
  2649. CBaseDialog::OnOK();
  2650. }
  2651. /*---------------------------------------------------------------------------
  2652. CNewRtrWizWelcome Implementation
  2653. ---------------------------------------------------------------------------*/
  2654. CNewRtrWizWelcome::CNewRtrWizWelcome() :
  2655. CNewRtrWizPageBase(CNewRtrWizWelcome::IDD, CNewRtrWizPageBase::Start)
  2656. {
  2657. InitWiz97(TRUE, 0, 0);
  2658. }
  2659. BEGIN_MESSAGE_MAP(CNewRtrWizWelcome, CNewRtrWizPageBase)
  2660. END_MESSAGE_MAP()
  2661. /*---------------------------------------------------------------------------
  2662. CNewRtrWizCustomConfig Implementation
  2663. ---------------------------------------------------------------------------*/
  2664. CNewRtrWizCustomConfig::CNewRtrWizCustomConfig() :
  2665. CNewRtrWizPageBase( CNewRtrWizCustomConfig::IDD, CNewRtrWizPageBase::Middle )
  2666. {
  2667. InitWiz97(FALSE,
  2668. IDS_NEWWIZ_CUSTOMCONFIG_TITLE,
  2669. IDS_NEWWIZ_CUSTOMCONFIG_SUBTITLE);
  2670. }
  2671. BEGIN_MESSAGE_MAP(CNewRtrWizCustomConfig, CNewRtrWizPageBase)
  2672. END_MESSAGE_MAP()
  2673. BOOL CNewRtrWizCustomConfig::OnInitDialog()
  2674. {
  2675. //
  2676. //Based on what has already been selected by the user,
  2677. //setup the new buttons.
  2678. //
  2679. if ( !m_pRtrWizData->m_dwNewRouterType )
  2680. {
  2681. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT &&
  2682. m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_BASIC_FIREWALL
  2683. )
  2684. {
  2685. CheckDlgButton ( IDC_NEWWIZ_BTN_NAT,
  2686. BST_CHECKED
  2687. );
  2688. }
  2689. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  2690. {
  2691. CheckDlgButton ( IDC_NEWWIZ_BTN_DIALUP_ACCESS,
  2692. BST_CHECKED
  2693. );
  2694. }
  2695. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN )
  2696. {
  2697. CheckDlgButton ( IDC_NEWWIZ_BTN_VPN_ACCESS,
  2698. BST_CHECKED
  2699. );
  2700. }
  2701. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DOD )
  2702. {
  2703. CheckDlgButton ( IDC_NEWWIZ_BTN_DOD,
  2704. BST_CHECKED
  2705. );
  2706. }
  2707. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_LAN_ROUTING )
  2708. {
  2709. CheckDlgButton ( IDC_NEWWIZ_BTN_LAN_ROUTING,
  2710. BST_CHECKED
  2711. );
  2712. }
  2713. }
  2714. return TRUE;
  2715. }
  2716. HRESULT CNewRtrWizCustomConfig::OnSavePage()
  2717. {
  2718. DWORD dwNewRouterType = NEWWIZ_ROUTER_TYPE_UNKNOWN;
  2719. //
  2720. //Based on what the user has selected, setup
  2721. //the selection.
  2722. //
  2723. if ( IsDlgButtonChecked( IDC_NEWWIZ_BTN_NAT ) )
  2724. {
  2725. dwNewRouterType |= NEWWIZ_ROUTER_TYPE_NAT | NEWWIZ_ROUTER_TYPE_BASIC_FIREWALL;
  2726. }
  2727. if ( IsDlgButtonChecked( IDC_NEWWIZ_BTN_DIALUP_ACCESS ) )
  2728. {
  2729. dwNewRouterType |= NEWWIZ_ROUTER_TYPE_DIALUP;
  2730. }
  2731. if ( IsDlgButtonChecked( IDC_NEWWIZ_BTN_VPN_ACCESS ) )
  2732. {
  2733. dwNewRouterType |= NEWWIZ_ROUTER_TYPE_VPN;
  2734. }
  2735. if ( IsDlgButtonChecked( IDC_NEWWIZ_BTN_DOD ) )
  2736. {
  2737. dwNewRouterType |= NEWWIZ_ROUTER_TYPE_DOD;
  2738. }
  2739. if ( IsDlgButtonChecked( IDC_NEWWIZ_BTN_LAN_ROUTING ) )
  2740. {
  2741. dwNewRouterType |= NEWWIZ_ROUTER_TYPE_LAN_ROUTING;
  2742. }
  2743. //Check to see if at least one of the types is selected
  2744. if ( NEWWIZ_ROUTER_TYPE_UNKNOWN == dwNewRouterType )
  2745. {
  2746. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_OPTION);
  2747. return E_FAIL;
  2748. }
  2749. m_pRtrWizData->m_dwNewRouterType = dwNewRouterType;
  2750. return hrOK;
  2751. }
  2752. /*---------------------------------------------------------------------------
  2753. CNewRtrWizRRasVPN Implementation
  2754. ---------------------------------------------------------------------------*/
  2755. CNewRtrWizRRasVPN::CNewRtrWizRRasVPN() :
  2756. CNewRtrWizPageBase( CNewRtrWizRRasVPN::IDD, CNewRtrWizPageBase::Middle )
  2757. {
  2758. InitWiz97(FALSE,
  2759. IDS_NEWWIZ_RRASVPN_TITLE,
  2760. IDS_NEWWIZ_RRASVPN_SUBTITLE);
  2761. }
  2762. BEGIN_MESSAGE_MAP(CNewRtrWizRRasVPN, CNewRtrWizPageBase)
  2763. ON_BN_CLICKED(IDC_NEWWIZ_BTN_VPN, OnChkBtnClicked)
  2764. ON_BN_CLICKED(IDC_NEWWIZ_BTN_DIALUP_RAS, OnChkBtnClicked)
  2765. END_MESSAGE_MAP()
  2766. BOOL CNewRtrWizRRasVPN::OnInitDialog()
  2767. {
  2768. DWORD dwNICs=0;
  2769. CWnd * pVpnCheck = GetDlgItem ( IDC_NEWWIZ_BTN_VPN );
  2770. DWORD dwRouterType = m_pRtrWizData->m_dwNewRouterType;
  2771. if ( dwRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  2772. {
  2773. CheckDlgButton( IDC_NEWWIZ_BTN_DIALUP_RAS, BST_CHECKED );
  2774. }
  2775. //Check to see if there is no NIC. If no NIC then
  2776. //gray out the VPN option
  2777. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  2778. if ( dwNICs < 1 )
  2779. {
  2780. //
  2781. //Gray out the VPN button since there is only
  2782. //one NIC in the machine.
  2783. //
  2784. pVpnCheck->EnableWindow(FALSE);
  2785. }
  2786. else if ( dwRouterType & NEWWIZ_ROUTER_TYPE_VPN )
  2787. {
  2788. CheckDlgButton( IDC_NEWWIZ_BTN_VPN, BST_CHECKED );
  2789. }
  2790. return TRUE;
  2791. }
  2792. BOOL CNewRtrWizRRasVPN::OnSetActive()
  2793. {
  2794. CWnd * pVpnCheck = GetDlgItem ( IDC_NEWWIZ_BTN_VPN );
  2795. BOOL bRet = CNewRtrWizPageBase::OnSetActive();
  2796. if ((pVpnCheck->IsWindowEnabled() && IsDlgButtonChecked(IDC_NEWWIZ_BTN_VPN)) ||
  2797. IsDlgButtonChecked(IDC_NEWWIZ_BTN_DIALUP_RAS)) {
  2798. //Next button should be enabled in this case
  2799. GetHolder()->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  2800. }
  2801. else {
  2802. //Next button is disabled
  2803. GetHolder()->SetWizardButtons(PSWIZB_BACK);
  2804. }
  2805. return bRet;
  2806. }
  2807. void CNewRtrWizRRasVPN::OnChkBtnClicked()
  2808. {
  2809. CWnd * pVpnCheck = GetDlgItem ( IDC_NEWWIZ_BTN_VPN );
  2810. if ((pVpnCheck->IsWindowEnabled() && IsDlgButtonChecked(IDC_NEWWIZ_BTN_VPN)) ||
  2811. IsDlgButtonChecked(IDC_NEWWIZ_BTN_DIALUP_RAS)) {
  2812. //Next button should be enabled in this case
  2813. GetHolder()->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  2814. }
  2815. else {
  2816. //Next button is disabled
  2817. GetHolder()->SetWizardButtons(PSWIZB_BACK);
  2818. }
  2819. }
  2820. HRESULT CNewRtrWizRRasVPN::OnSavePage()
  2821. {
  2822. DWORD dwRouterType = NEWWIZ_ROUTER_TYPE_UNKNOWN;
  2823. CWnd * pVpnCheck = GetDlgItem ( IDC_NEWWIZ_BTN_VPN );
  2824. //
  2825. //check to see which buttons are set and based on that
  2826. //set the router type.
  2827. //
  2828. if ( pVpnCheck->IsWindowEnabled() && IsDlgButtonChecked(IDC_NEWWIZ_BTN_VPN) )
  2829. {
  2830. DWORD dwNics = 0;
  2831. m_pRtrWizData->GetNumberOfNICS_IP(&dwNics);
  2832. if (dwNics <= 1)
  2833. {
  2834. //Not enough for VPN standard config
  2835. AfxMessageBox(IDS_ERR_VPN_NO_NICS_LEFT_FOR_PRIVATE_IF);
  2836. return E_FAIL;
  2837. }
  2838. dwRouterType |= NEWWIZ_ROUTER_TYPE_VPN;
  2839. }
  2840. if ( IsDlgButtonChecked(IDC_NEWWIZ_BTN_DIALUP_RAS) )
  2841. {
  2842. dwRouterType |= NEWWIZ_ROUTER_TYPE_DIALUP;
  2843. }
  2844. if ( dwRouterType == NEWWIZ_ROUTER_TYPE_UNKNOWN )
  2845. {
  2846. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_OPTION);
  2847. return E_FAIL;
  2848. }
  2849. m_pRtrWizData->m_dwNewRouterType = dwRouterType;
  2850. return hrOK;
  2851. }
  2852. /*---------------------------------------------------------------------------
  2853. CNewRtrWizCommonConfig Implementation
  2854. ---------------------------------------------------------------------------*/
  2855. CNewRtrWizCommonConfig::CNewRtrWizCommonConfig() :
  2856. CNewRtrWizPageBase(CNewRtrWizCommonConfig::IDD, CNewRtrWizPageBase::Middle)
  2857. {
  2858. InitWiz97(FALSE,
  2859. IDS_NEWWIZ_COMMONCONFIG_TITLE,
  2860. IDS_NEWWIZ_COMMONCONFIG_SUBTITLE);
  2861. }
  2862. BEGIN_MESSAGE_MAP(CNewRtrWizCommonConfig, CNewRtrWizPageBase)
  2863. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizCommonConfig::OnHelpClick )
  2864. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizCommonConfig::OnHelpClick )
  2865. END_MESSAGE_MAP()
  2866. // This list of IDs will have their controls made bold.
  2867. const DWORD s_rgCommonConfigOptionIds[] =
  2868. {
  2869. IDC_NEWWIZ_CONFIG_BTN_RAS_DIALUP_VPN,
  2870. IDC_NEWWIZ_CONFIG_BTN_NAT1,
  2871. IDC_NEWWIZ_CONFIG_BTN_VPNNAT,
  2872. IDC_NEWWIZ_CONFIG_BTN_DOD,
  2873. IDC_NEWWIZ_CONFIG_BTN_CUSTOM,
  2874. 0
  2875. };
  2876. void CNewRtrWizCommonConfig::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  2877. {
  2878. if(!pNMHDR || !pResult)
  2879. return;
  2880. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  2881. return;
  2882. HtmlHelpA(NULL, "RRASconcepts.chm::/ras_common_configuration.htm", HH_DISPLAY_TOPIC, 0);
  2883. *pResult = 0;
  2884. }
  2885. BOOL CNewRtrWizCommonConfig::OnInitDialog()
  2886. {
  2887. Assert(m_pRtrWizData);
  2888. UINT idSelection;
  2889. LOGFONT LogFont;
  2890. CFont * pOldFont;
  2891. CNewRtrWizPageBase::OnInitDialog();
  2892. #if 0
  2893. //No need to bold the font in this new wizard.
  2894. // Create a bold text font for the options
  2895. pOldFont = GetDlgItem(s_rgCommonConfigOptionIds[0])->GetFont();
  2896. pOldFont->GetLogFont(&LogFont);
  2897. LogFont.lfWeight = 700; // make this a bold font
  2898. m_boldFont.CreateFontIndirect(&LogFont);
  2899. // Set all of the options to use the bold font
  2900. for (int i=0; s_rgCommonConfigOptionIds[i]; i++)
  2901. {
  2902. GetDlgItem(s_rgCommonConfigOptionIds[i])->SetFont(&m_boldFont);
  2903. }
  2904. #endif
  2905. switch (m_pRtrWizData->m_wizType)
  2906. {
  2907. case NewRtrWizData::NewWizardRouterType_DialupOrVPN:
  2908. idSelection = IDC_NEWWIZ_CONFIG_BTN_RAS_DIALUP_VPN;
  2909. break;
  2910. case NewRtrWizData::NewWizardRouterType_NAT:
  2911. idSelection = IDC_NEWWIZ_CONFIG_BTN_NAT1;
  2912. break;
  2913. case NewRtrWizData::NewWizardRouterType_VPNandNAT:
  2914. idSelection = IDC_NEWWIZ_CONFIG_BTN_VPNNAT;
  2915. break;
  2916. case NewRtrWizData::NewWizardRouterType_DOD:
  2917. idSelection = IDC_NEWWIZ_CONFIG_BTN_DOD;
  2918. break;
  2919. case NewRtrWizData::NewWizardRouterType_Custom:
  2920. idSelection = IDC_NEWWIZ_CONFIG_BTN_CUSTOM;
  2921. break;
  2922. default:
  2923. Panic1("Unknown Wizard Router Type : %d",
  2924. m_pRtrWizData->m_wizType);
  2925. idSelection = IDC_NEWWIZ_CONFIG_BTN_RAS_DIALUP_VPN;
  2926. break;
  2927. }
  2928. CheckRadioButton(IDC_NEWWIZ_CONFIG_BTN_RAS_DIALUP_VPN,
  2929. IDC_NEWWIZ_CONFIG_BTN_CUSTOM,
  2930. idSelection);
  2931. return TRUE; // return TRUE unless you set the focus to a control
  2932. // EXCEPTION: OCX Property Pages should return FALSE
  2933. }
  2934. HRESULT CNewRtrWizCommonConfig::OnSavePage()
  2935. {
  2936. // Record the change
  2937. if (IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_RAS_DIALUP_VPN))
  2938. {
  2939. m_pRtrWizData->m_wizType = NewRtrWizData::NewWizardRouterType_DialupOrVPN;
  2940. //Dont know yet what the router type is
  2941. }
  2942. else if (IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_NAT1))
  2943. {
  2944. m_pRtrWizData->m_wizType = NewRtrWizData::NewWizardRouterType_NAT;
  2945. m_pRtrWizData->m_dwNewRouterType = NEWWIZ_ROUTER_TYPE_NAT;
  2946. }
  2947. else if (IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_VPNNAT))
  2948. {
  2949. DWORD dwNics = 0;
  2950. m_pRtrWizData->GetNumberOfNICS_IP(&dwNics);
  2951. if (dwNics <= 1)
  2952. {
  2953. //Not enough for VPN standard config
  2954. AfxMessageBox(IDS_ERR_VPN_NO_NICS_LEFT_FOR_PRIVATE_IF);
  2955. return E_FAIL;
  2956. }
  2957. m_pRtrWizData->m_wizType = NewRtrWizData::NewWizardRouterType_VPNandNAT;
  2958. m_pRtrWizData->m_dwNewRouterType = NEWWIZ_ROUTER_TYPE_NAT|NEWWIZ_ROUTER_TYPE_VPN;
  2959. }
  2960. else if (IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_DOD))
  2961. {
  2962. m_pRtrWizData->m_wizType = NewRtrWizData::NewWizardRouterType_DOD;
  2963. m_pRtrWizData->m_dwNewRouterType = NEWWIZ_ROUTER_TYPE_DOD;
  2964. }
  2965. else
  2966. {
  2967. //
  2968. //Router type is still unknown here. next property page will tell
  2969. //what should be the actual type.
  2970. //
  2971. Assert(IsDlgButtonChecked(IDC_NEWWIZ_CONFIG_BTN_CUSTOM));
  2972. m_pRtrWizData->m_wizType = NewRtrWizData::NewWizardRouterType_Custom;
  2973. }
  2974. return hrOK;
  2975. }
  2976. /*---------------------------------------------------------------------------
  2977. CNewRtrWizNatFinishAConflict Implementation
  2978. ---------------------------------------------------------------------------*/
  2979. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishAConflict,
  2980. SaveFlag_DoNothing,
  2981. HelpFlag_Nothing);
  2982. /*---------------------------------------------------------------------------
  2983. CNewRtrWizNatFinishAConflictNonLocal Implementation
  2984. ---------------------------------------------------------------------------*/
  2985. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishAConflictNonLocal,
  2986. SaveFlag_DoNothing,
  2987. HelpFlag_Nothing);
  2988. /*---------------------------------------------------------------------------
  2989. CNewRtrWizNatFinishNoIP Implementation
  2990. ---------------------------------------------------------------------------*/
  2991. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishNoIP,
  2992. SaveFlag_DoNothing,
  2993. HelpFlag_AddIp);
  2994. /*---------------------------------------------------------------------------
  2995. CNewRtrWizNatFinishNoIPNonLocal Implementation
  2996. ---------------------------------------------------------------------------*/
  2997. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishNoIPNonLocal,
  2998. SaveFlag_DoNothing,
  2999. HelpFlag_Nothing);
  3000. /*---------------------------------------------------------------------------
  3001. CNewRtrWizNatSelectPublic implementation
  3002. ---------------------------------------------------------------------------*/
  3003. CNewRtrWizNatSelectPublic::CNewRtrWizNatSelectPublic() :
  3004. CNewRtrWizPageBase(CNewRtrWizNatSelectPublic::IDD, CNewRtrWizPageBase::Middle)
  3005. {
  3006. InitWiz97(FALSE,
  3007. IDS_NEWWIZ_NAT_A_PUBLIC_TITLE,
  3008. IDS_NEWWIZ_NAT_A_PUBLIC_SUBTITLE);
  3009. }
  3010. void CNewRtrWizNatSelectPublic::DoDataExchange(CDataExchange *pDX)
  3011. {
  3012. CNewRtrWizPageBase::DoDataExchange(pDX);
  3013. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  3014. }
  3015. BEGIN_MESSAGE_MAP(CNewRtrWizNatSelectPublic, CNewRtrWizPageBase)
  3016. ON_BN_CLICKED(IDC_NEWWIZ_BTN_NEW, OnBtnClicked)
  3017. ON_BN_CLICKED(IDC_NEWWIZ_BTN_EXISTING, OnBtnClicked)
  3018. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizNatSelectPublic::OnHelpClick )
  3019. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizNatSelectPublic::OnHelpClick )
  3020. END_MESSAGE_MAP()
  3021. void CNewRtrWizNatSelectPublic::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  3022. {
  3023. if(!pNMHDR || !pResult)
  3024. return;
  3025. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  3026. return;
  3027. HtmlHelpA(NULL, "RRASconcepts.chm::/mpr_und_interfaces.htm", HH_DISPLAY_TOPIC, 0);
  3028. *pResult = 0;
  3029. }
  3030. BOOL CNewRtrWizNatSelectPublic::OnSetActive()
  3031. {
  3032. //Need a generic way of finding out if
  3033. //this is the start page or not. But for now
  3034. //just use the hard coded value
  3035. //$TODO: Need to find a generic way of doing this.
  3036. if ( m_pRtrWizData->m_dwExpressType == MPRSNAP_CYS_EXPRESS_NAT )
  3037. m_pagetype = CNewRtrWizPageBase::Start;
  3038. return CNewRtrWizPageBase::OnSetActive();
  3039. }
  3040. /*!--------------------------------------------------------------------------
  3041. CNewRtrWizNatSelectPublic::OnInitDialog
  3042. -
  3043. Author: KennT
  3044. ---------------------------------------------------------------------------*/
  3045. BOOL CNewRtrWizNatSelectPublic::OnInitDialog()
  3046. {
  3047. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  3048. DWORD dwNICs;
  3049. UINT uSelection;
  3050. CNewRtrWizPageBase::OnInitDialog();
  3051. // Setup the dialog and add the NICs
  3052. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  3053. //::PostMessage( ::GetParent(m_hWnd), PSM_SETWIZBUTTONS, 0 , PSWIZB_NEXT);
  3054. if (dwNICs == 0)
  3055. {
  3056. // Have to use new, there is no other choice.
  3057. CheckRadioButton(IDC_NEWWIZ_BTN_NEW, IDC_NEWWIZ_BTN_EXISTING,
  3058. IDC_NEWWIZ_BTN_NEW);
  3059. // There are no NICs, so just disable the entire listbox
  3060. MultiEnableWindow(GetSafeHwnd(),
  3061. FALSE,
  3062. IDC_NEWWIZ_LIST,
  3063. IDC_NEWWIZ_BTN_EXISTING,
  3064. 0);
  3065. }
  3066. else if (dwNICs == 1)
  3067. {
  3068. // Have to use new, there is no other choice because the single
  3069. // available interface can't be both the public and the private.
  3070. CheckRadioButton(IDC_NEWWIZ_BTN_NEW, IDC_NEWWIZ_BTN_EXISTING,
  3071. IDC_NEWWIZ_BTN_NEW);
  3072. InitializeInterfaceListControl(NULL,
  3073. &m_listCtrl,
  3074. NULL,
  3075. 0,
  3076. m_pRtrWizData);
  3077. RefreshInterfaceListControl(NULL,
  3078. &m_listCtrl,
  3079. NULL,
  3080. 0,
  3081. m_pRtrWizData);
  3082. // disable the listbox
  3083. MultiEnableWindow(GetSafeHwnd(),
  3084. FALSE,
  3085. IDC_NEWWIZ_LIST,
  3086. IDC_NEWWIZ_BTN_EXISTING,
  3087. 0);
  3088. }
  3089. else
  3090. {
  3091. // The default is to use an existing connection.
  3092. CheckRadioButton(IDC_NEWWIZ_BTN_NEW, IDC_NEWWIZ_BTN_EXISTING,
  3093. IDC_NEWWIZ_BTN_EXISTING);
  3094. InitializeInterfaceListControl(NULL,
  3095. &m_listCtrl,
  3096. NULL,
  3097. 0,
  3098. m_pRtrWizData);
  3099. RefreshInterfaceListControl(NULL,
  3100. &m_listCtrl,
  3101. NULL,
  3102. 0,
  3103. m_pRtrWizData);
  3104. OnBtnClicked();
  3105. }
  3106. if ( m_pRtrWizData->m_fNATEnableFireWall < 0 )
  3107. {
  3108. //
  3109. //This is the first time that this dialog has
  3110. //been entered. So check the box and set
  3111. //the flag
  3112. m_pRtrWizData->m_fNATEnableFireWall = TRUE;
  3113. }
  3114. if (m_pRtrWizData->m_fNATEnableFireWall == TRUE)
  3115. CheckDlgButton(IDC_CHK_BASIC_FIREWALL, TRUE);
  3116. else
  3117. CheckDlgButton(IDC_CHK_BASIC_FIREWALL, FALSE);
  3118. return TRUE;
  3119. }
  3120. HRESULT CNewRtrWizNatSelectPublic::OnSavePage()
  3121. {
  3122. if (IsDlgButtonChecked(IDC_NEWWIZ_BTN_NEW))
  3123. {
  3124. m_pRtrWizData->m_fCreateDD = TRUE;
  3125. m_pRtrWizData->m_stPublicInterfaceId.Empty();
  3126. }
  3127. else
  3128. {
  3129. INT iSel;
  3130. // Check to see that we actually selected an item
  3131. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  3132. if (iSel == -1)
  3133. {
  3134. // We did not select an item
  3135. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  3136. //This is not an error that we would return to user
  3137. return E_FAIL;
  3138. }
  3139. m_pRtrWizData->m_fCreateDD = FALSE;
  3140. m_pRtrWizData->m_stPublicInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  3141. }
  3142. if ( IsDlgButtonChecked(IDC_CHK_BASIC_FIREWALL) )
  3143. m_pRtrWizData->m_fNATEnableFireWall = TRUE;
  3144. else
  3145. m_pRtrWizData->m_fNATEnableFireWall = FALSE;
  3146. return hrOK;
  3147. }
  3148. void CNewRtrWizNatSelectPublic::OnBtnClicked()
  3149. {
  3150. int iSel = 0;
  3151. DWORD status;
  3152. MIB_IFROW ifRow;
  3153. CString stRouter;
  3154. ULONG index;
  3155. HANDLE mprConfig;
  3156. WCHAR guidName[64] = L"\\DEVICE\\TCPIP_";
  3157. MultiEnableWindow(GetSafeHwnd(),
  3158. IsDlgButtonChecked(IDC_NEWWIZ_BTN_EXISTING),
  3159. IDC_NEWWIZ_LIST,
  3160. 0);
  3161. // If use an existing button is checked,
  3162. // auto-select the interface that is enabled and plugged.
  3163. if (IsDlgButtonChecked(IDC_NEWWIZ_BTN_EXISTING)) {
  3164. //Get name of machine if local.
  3165. stRouter = m_pRtrWizData->m_stServerName;
  3166. if (stRouter.GetLength() == 0)
  3167. {
  3168. stRouter = CString(_T("\\\\")) + GetLocalMachineName();
  3169. }
  3170. status = MprConfigServerConnect((LPWSTR)(LPCTSTR)stRouter, &mprConfig );
  3171. if ( status == NO_ERROR ) {
  3172. //Check each interface, looking for a plugged, enabled interface
  3173. for (int i=0;i < m_listCtrl.GetItemCount();i++)
  3174. {
  3175. //Get guid from friendly name
  3176. status = MprConfigGetGuidName(mprConfig, (PWCHAR)(LPCTSTR)m_listCtrl.GetItemText(i, IFLISTCOL_NAME), &guidName[14], sizeof(guidName ));
  3177. if (status != NO_ERROR ) {
  3178. continue;
  3179. }
  3180. status = GetAdapterIndex( guidName, &index );
  3181. if ( status != NO_ERROR ) {
  3182. continue;
  3183. }
  3184. //Now get info abt the Interface
  3185. ifRow.dwIndex = index;
  3186. status = GetIfEntry(&ifRow);
  3187. if(status != NO_ERROR){
  3188. continue;
  3189. }
  3190. if((ifRow.dwAdminStatus == TRUE) && (ifRow.dwOperStatus != MIB_IF_OPER_STATUS_NON_OPERATIONAL)
  3191. && (ifRow.dwOperStatus != MIB_IF_OPER_STATUS_UNREACHABLE) && (ifRow.dwOperStatus != MIB_IF_OPER_STATUS_DISCONNECTED)) {
  3192. //Found the default
  3193. iSel = i;
  3194. break;
  3195. }
  3196. }
  3197. }
  3198. m_listCtrl.SetItemState(iSel, LVIS_SELECTED, LVIS_SELECTED );
  3199. }
  3200. }
  3201. /*---------------------------------------------------------------------------
  3202. CNewRtrWizNatFinishAdvancedNoNICs
  3203. ---------------------------------------------------------------------------*/
  3204. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizNatFinishAdvancedNoNICs,
  3205. SaveFlag_DoNothing,
  3206. HelpFlag_Nothing);
  3207. /*---------------------------------------------------------------------------
  3208. CNewRtrWizNatSelectPrivate
  3209. ---------------------------------------------------------------------------*/
  3210. CNewRtrWizNatSelectPrivate::CNewRtrWizNatSelectPrivate() :
  3211. CNewRtrWizPageBase(CNewRtrWizNatSelectPrivate::IDD, CNewRtrWizPageBase::Middle)
  3212. {
  3213. InitWiz97(FALSE,
  3214. IDS_NEWWIZ_NAT_A_PRIVATE_TITLE,
  3215. IDS_NEWWIZ_NAT_A_PRIVATE_SUBTITLE);
  3216. }
  3217. void CNewRtrWizNatSelectPrivate::DoDataExchange(CDataExchange *pDX)
  3218. {
  3219. CNewRtrWizPageBase::DoDataExchange(pDX);
  3220. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  3221. }
  3222. BEGIN_MESSAGE_MAP(CNewRtrWizNatSelectPrivate, CNewRtrWizPageBase)
  3223. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizNatSelectPrivate::OnHelpClick )
  3224. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizNatSelectPrivate::OnHelpClick )
  3225. END_MESSAGE_MAP()
  3226. void CNewRtrWizNatSelectPrivate::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  3227. {
  3228. if(!pNMHDR || !pResult)
  3229. return;
  3230. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  3231. return;
  3232. HtmlHelpA(NULL, "dhcpconcepts.chm", HH_DISPLAY_TOPIC, 0);
  3233. *pResult = 0;
  3234. }
  3235. /*!--------------------------------------------------------------------------
  3236. CNewRtrWizNatSelectPrivate::OnInitDialog
  3237. -
  3238. Author: KennT
  3239. ---------------------------------------------------------------------------*/
  3240. BOOL CNewRtrWizNatSelectPrivate::OnInitDialog()
  3241. {
  3242. DWORD dwNICs;
  3243. CNewRtrWizPageBase::OnInitDialog();
  3244. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  3245. InitializeInterfaceListControl(NULL,
  3246. &m_listCtrl,
  3247. NULL,
  3248. 0,
  3249. m_pRtrWizData);
  3250. return TRUE;
  3251. }
  3252. BOOL CNewRtrWizNatSelectPrivate::OnSetActive()
  3253. {
  3254. DWORD dwNICs;
  3255. int iSel = 0;
  3256. DWORD dwErr, status;
  3257. MIB_IFROW ifRow;
  3258. CString stRouter;
  3259. CString stPreviousId;
  3260. ULONG index;
  3261. HANDLE mprConfig;
  3262. WCHAR guidName[64] = L"\\DEVICE\\TCPIP_";
  3263. CNewRtrWizPageBase::OnSetActive();
  3264. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  3265. RefreshInterfaceListControl(NULL,
  3266. &m_listCtrl,
  3267. (LPCTSTR) m_pRtrWizData->m_stPublicInterfaceId,
  3268. 0,
  3269. m_pRtrWizData);
  3270. // Try to reselect the previously selected NIC
  3271. if (m_pRtrWizData->m_wizType == NewRtrWizData::NewWizardRouterType_VPNandNAT)
  3272. {
  3273. // If this page has come up as a part of VPN and NAT wizard, then we
  3274. // should see if NAT private interface selection has been made.
  3275. // If yes, use that
  3276. // If not then default to the VPN private interface
  3277. if ( !m_pRtrWizData->m_stNATPrivateInterfaceId.IsEmpty() )
  3278. {
  3279. stPreviousId = m_pRtrWizData->m_stNATPrivateInterfaceId;
  3280. }
  3281. else if ( !m_pRtrWizData->m_stPrivateInterfaceId.IsEmpty() )
  3282. {
  3283. stPreviousId = m_pRtrWizData->m_stPrivateInterfaceId;
  3284. }
  3285. }
  3286. else
  3287. {
  3288. if ( !m_pRtrWizData->m_stPrivateInterfaceId.IsEmpty() )
  3289. {
  3290. stPreviousId = m_pRtrWizData->m_stPrivateInterfaceId;
  3291. }
  3292. }
  3293. if (!stPreviousId.IsEmpty())
  3294. {
  3295. CString data;
  3296. for (int i=0;i < m_listCtrl.GetItemCount();i++)
  3297. {
  3298. data = (LPCTSTR) m_listCtrl.GetItemData(i);
  3299. if(data == stPreviousId) {
  3300. iSel = i;
  3301. break;
  3302. }
  3303. }
  3304. /*
  3305. LV_FINDINFO lvfi;
  3306. lvfi.flags = LVFI_STRING;
  3307. lvfi.psz = (LPCTSTR) m_pRtrWizData->m_stPrivateInterfaceId;
  3308. iSel = m_listCtrl.FindItem(&lvfi, -1);
  3309. if (iSel == -1)
  3310. iSel = 0;
  3311. */
  3312. }
  3313. else {
  3314. // Make an interface that is not disabled or unplugged as default-selected.
  3315. // Get name of machine if local.
  3316. stRouter = m_pRtrWizData->m_stServerName;
  3317. if (stRouter.GetLength() == 0)
  3318. {
  3319. stRouter = CString(_T("\\\\")) + GetLocalMachineName();
  3320. }
  3321. status = MprConfigServerConnect((LPWSTR)(LPCTSTR)stRouter, &mprConfig );
  3322. if ( status == NO_ERROR )
  3323. {
  3324. //Check each interface, looking for a plugged, enabled interface
  3325. for (int i=0;i < m_listCtrl.GetItemCount();i++)
  3326. {
  3327. //Get guid from friendly name
  3328. status = MprConfigGetGuidName(mprConfig, (PWCHAR)(LPCTSTR)m_listCtrl.GetItemText(i, IFLISTCOL_NAME), &guidName[14], sizeof(guidName ));
  3329. if (status != NO_ERROR )
  3330. {
  3331. continue;
  3332. }
  3333. status = GetAdapterIndex( guidName, &index );
  3334. if ( status != NO_ERROR )
  3335. {
  3336. continue;
  3337. }
  3338. //Now get info abt the Interface
  3339. ifRow.dwIndex = index;
  3340. status = GetIfEntry(&ifRow);
  3341. if(status != NO_ERROR)
  3342. {
  3343. continue;
  3344. }
  3345. if((ifRow.dwAdminStatus == TRUE) && (ifRow.dwOperStatus != MIB_IF_OPER_STATUS_NON_OPERATIONAL)
  3346. && (ifRow.dwOperStatus != MIB_IF_OPER_STATUS_UNREACHABLE) && (ifRow.dwOperStatus != MIB_IF_OPER_STATUS_DISCONNECTED))
  3347. {
  3348. //Found the default
  3349. iSel = i;
  3350. break;
  3351. }
  3352. }
  3353. }
  3354. }
  3355. m_listCtrl.SetItemState(iSel, LVIS_SELECTED, LVIS_SELECTED );
  3356. // CheckDlgButton( IDC_CHK_DHCP_HELP, m_pRtrWizData->m_fShowDhcpHelp );
  3357. return TRUE;
  3358. }
  3359. HRESULT CNewRtrWizNatSelectPrivate::OnSavePage()
  3360. {
  3361. INT iSel;
  3362. // Check to see that we actually selected an item
  3363. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  3364. if (iSel == -1)
  3365. {
  3366. // We did not select an item
  3367. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  3368. //this is not an error we send back to the client
  3369. return E_FAIL;
  3370. }
  3371. if ( m_pRtrWizData->m_wizType == NewRtrWizData::NewWizardRouterType_VPNandNAT)
  3372. m_pRtrWizData->m_stNATPrivateInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  3373. else
  3374. m_pRtrWizData->m_stPrivateInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  3375. // m_pRtrWizData->m_fShowDhcpHelp = IsDlgButtonChecked( IDC_CHK_DHCP_HELP );
  3376. return hrOK;
  3377. }
  3378. /*---------------------------------------------------------------------------
  3379. CNewRtrWizNatDHCPDNS
  3380. ---------------------------------------------------------------------------*/
  3381. CNewRtrWizNatDHCPDNS::CNewRtrWizNatDHCPDNS() :
  3382. CNewRtrWizPageBase(CNewRtrWizNatDHCPDNS::IDD, CNewRtrWizPageBase::Middle)
  3383. {
  3384. InitWiz97(FALSE,
  3385. IDS_NEWWIZ_NAT_A_DHCPDNS_TITLE,
  3386. IDS_NEWWIZ_NAT_A_DHCPDNS_SUBTITLE);
  3387. }
  3388. BEGIN_MESSAGE_MAP(CNewRtrWizNatDHCPDNS, CNewRtrWizPageBase)
  3389. END_MESSAGE_MAP()
  3390. BOOL CNewRtrWizNatDHCPDNS::OnInitDialog()
  3391. {
  3392. CheckRadioButton(IDC_NEWWIZ_NAT_USE_SIMPLE,
  3393. IDC_NEWWIZ_NAT_USE_EXTERNAL,
  3394. m_pRtrWizData->m_fNatUseSimpleServers ? IDC_NEWWIZ_NAT_USE_SIMPLE : IDC_NEWWIZ_NAT_USE_EXTERNAL);
  3395. return TRUE;
  3396. }
  3397. HRESULT CNewRtrWizNatDHCPDNS::OnSavePage()
  3398. {
  3399. m_pRtrWizData->m_fNatUseSimpleServers = IsDlgButtonChecked(IDC_NEWWIZ_NAT_USE_SIMPLE);
  3400. if ( !m_pRtrWizData->m_fNatUseSimpleServers )
  3401. m_pRtrWizData->m_fNatUseExternal = TRUE;
  3402. return hrOK;
  3403. }
  3404. /*---------------------------------------------------------------------------
  3405. CNewRtrWizNatDHCPWarning
  3406. ---------------------------------------------------------------------------*/
  3407. CNewRtrWizNatDHCPWarning::CNewRtrWizNatDHCPWarning() :
  3408. CNewRtrWizPageBase(CNewRtrWizNatDHCPWarning::IDD, CNewRtrWizPageBase::Middle)
  3409. {
  3410. InitWiz97(FALSE,
  3411. IDS_NEWWIZ_NAT_A_DHCP_WARNING_TITLE,
  3412. IDS_NEWWIZ_NAT_A_DHCP_WARNING_SUBTITLE);
  3413. }
  3414. BEGIN_MESSAGE_MAP(CNewRtrWizNatDHCPWarning, CNewRtrWizPageBase)
  3415. END_MESSAGE_MAP()
  3416. BOOL CNewRtrWizNatDHCPWarning::OnSetActive()
  3417. {
  3418. CNewRtrWizPageBase::OnSetActive();
  3419. RtrWizInterface * pRtrWizIf = NULL;
  3420. // Get the information for the private interface
  3421. // If we are in "VPN and NAT" wizard, use m_stNATPrivateInterfaceId
  3422. // else use the m_stPrivateInterfaceId
  3423. if (m_pRtrWizData->m_wizType == NewRtrWizData::NewWizardRouterType_VPNandNAT)
  3424. {
  3425. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stNATPrivateInterfaceId,
  3426. pRtrWizIf);
  3427. }
  3428. else
  3429. {
  3430. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPrivateInterfaceId,
  3431. pRtrWizIf);
  3432. }
  3433. if (pRtrWizIf)
  3434. {
  3435. DWORD netAddress, netMask;
  3436. CString st;
  3437. // We have to calculate the beginning of the subnet
  3438. netAddress = INET_ADDR(pRtrWizIf->m_stIpAddress);
  3439. netMask = INET_ADDR(pRtrWizIf->m_stMask);
  3440. netAddress = netAddress & netMask;
  3441. st = INET_NTOA(netAddress);
  3442. // Now write out the subnet information for the page
  3443. SetDlgItemText(IDC_NEWWIZ_TEXT_SUBNET, st);
  3444. SetDlgItemText(IDC_NEWWIZ_TEXT_MASK, pRtrWizIf->m_stMask);
  3445. }
  3446. else
  3447. {
  3448. // An error! we do not have a private interface
  3449. // Just leave things blank
  3450. SetDlgItemText(IDC_NEWWIZ_TEXT_SUBNET, _T(""));
  3451. SetDlgItemText(IDC_NEWWIZ_TEXT_MASK, _T(""));
  3452. }
  3453. return TRUE;
  3454. }
  3455. /*---------------------------------------------------------------------------
  3456. CNewRtrWizNatDDWarning
  3457. ---------------------------------------------------------------------------*/
  3458. CNewRtrWizNatDDWarning::CNewRtrWizNatDDWarning() :
  3459. CNewRtrWizPageBase(CNewRtrWizNatDDWarning::IDD, CNewRtrWizPageBase::Middle)
  3460. {
  3461. InitWiz97(FALSE,
  3462. IDS_NEWWIZ_NAT_A_DD_WARNING_TITLE,
  3463. IDS_NEWWIZ_NAT_A_DD_WARNING_SUBTITLE);
  3464. }
  3465. BEGIN_MESSAGE_MAP(CNewRtrWizNatDDWarning, CNewRtrWizPageBase)
  3466. END_MESSAGE_MAP()
  3467. BOOL CNewRtrWizNatDDWarning::OnSetActive()
  3468. {
  3469. CNewRtrWizPageBase::OnSetActive();
  3470. // If we came back here from the DD error page, then
  3471. // we don't allow them to go anywhere else.
  3472. if (!FHrOK(m_pRtrWizData->m_hrDDError))
  3473. {
  3474. CancelToClose();
  3475. GetHolder()->SetWizardButtons(PSWIZB_NEXT);
  3476. }
  3477. return TRUE;
  3478. }
  3479. HRESULT CNewRtrWizNatDDWarning::OnSavePage()
  3480. {
  3481. HRESULT hr = hrOK;
  3482. BOOL fDhcpHelp = m_pRtrWizData->m_fShowDhcpHelp;
  3483. CWaitCursor wait;
  3484. if (m_pRtrWizData->m_fTest)
  3485. return hr;
  3486. m_pRtrWizData->m_fShowDhcpHelp = FALSE;
  3487. //Save the Dhcp Flag in a temp va
  3488. // Save the wizard data, the service will be started
  3489. OnWizardFinish();
  3490. // Ok, at this point, all of the changes have been committed
  3491. // so we can't go away or go back
  3492. CancelToClose();
  3493. GetHolder()->SetWizardButtons(PSWIZB_NEXT);
  3494. // Start the DD wizard
  3495. Assert(m_pRtrWizData->m_fCreateDD);
  3496. hr = CallRouterEntryDlg(GetSafeHwnd(),
  3497. m_pRtrWizData,
  3498. RASEDFLAG_NAT);
  3499. // We need to force the RouterInfo to reload it's information
  3500. // ----------------------------------------------------------------
  3501. if (m_pRtrWiz && m_pRtrWiz->m_spRouter)
  3502. {
  3503. m_pRtrWiz->m_spRouter->DoDisconnect();
  3504. m_pRtrWiz->m_spRouter->Unload();
  3505. m_pRtrWiz->m_spRouter->Load(m_pRtrWiz->m_spRouter->GetMachineName(), NULL);
  3506. }
  3507. if (FHrSucceeded(hr))
  3508. {
  3509. // If we're setting up NAT, we can now add IGMP/NAT because
  3510. // the dd interface will have been created.
  3511. // ----------------------------------------------------------------
  3512. if (m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT )
  3513. {
  3514. // Setup the data structure for the next couple of functions
  3515. m_pRtrWizData->m_RtrConfigData.m_ipData.m_stPrivateAdapterGUID = m_pRtrWizData->m_stPrivateInterfaceId;
  3516. m_pRtrWizData->m_RtrConfigData.m_ipData.m_stPublicAdapterGUID = m_pRtrWizData->m_stPublicInterfaceId;
  3517. AddIGMPToNATServer(m_pRtrWizData, &m_pRtrWizData->m_RtrConfigData,
  3518. m_pRtrWiz->m_spRouter,
  3519. ( m_pRtrWizData->m_wizType == NewRtrWizData::NewWizardRouterType_VPNandNAT));
  3520. AddNATToServer(m_pRtrWizData, &m_pRtrWizData->m_RtrConfigData, m_pRtrWiz->m_spRouter, m_pRtrWizData->m_fCreateDD, FALSE);
  3521. }
  3522. }
  3523. else {
  3524. //Disable RRAS
  3525. DisableRRAS((TCHAR *)(LPCTSTR)m_pRtrWizData->m_stServerName);
  3526. }
  3527. m_pRtrWizData->m_fShowDhcpHelp = fDhcpHelp;
  3528. m_pRtrWizData->m_hrDDError = hr;
  3529. // Ignore the error, always go on to the next page
  3530. return hrOK;
  3531. }
  3532. /*---------------------------------------------------------------------------
  3533. CNewRtrWizNatFinish
  3534. ---------------------------------------------------------------------------*/
  3535. CNewRtrWizNatFinish::CNewRtrWizNatFinish() :
  3536. CNewRtrWizFinishPageBase(CNewRtrWizNatFinish::IDD, SaveFlag_Advanced, HelpFlag_GeneralNAT)
  3537. {
  3538. InitWiz97(TRUE, 0, 0);
  3539. }
  3540. BEGIN_MESSAGE_MAP(CNewRtrWizNatFinish, CNewRtrWizFinishPageBase)
  3541. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizNatFinish::OnHelpClick )
  3542. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizNatFinish::OnHelpClick )
  3543. END_MESSAGE_MAP()
  3544. void CNewRtrWizNatFinish::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  3545. {
  3546. if(!pNMHDR || !pResult)
  3547. return;
  3548. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  3549. return;
  3550. HtmlHelpA(NULL, "RRASconcepts.chm::/sag_RRAS-Ch3_06b.htm", HH_DISPLAY_TOPIC, 0);
  3551. *pResult = 0;
  3552. }
  3553. BOOL CNewRtrWizNatFinish::OnSetActive()
  3554. {
  3555. CNewRtrWizFinishPageBase::OnSetActive();
  3556. RtrWizInterface * pRtrWizIf = NULL;
  3557. CString sFormat;
  3558. CString sText;
  3559. CString sPublicInterfaceName;
  3560. CString sFirewall;
  3561. CNewRtrWizFinishPageBase::OnSetActive();
  3562. // If we just got here because we created a DD interface
  3563. // we can't go back.
  3564. if (m_pRtrWizData->m_fCreateDD)
  3565. {
  3566. CancelToClose();
  3567. GetHolder()->SetWizardButtons(PSWIZB_FINISH);
  3568. }
  3569. //Setup the text that goes in the summary box
  3570. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPublicInterfaceId,
  3571. pRtrWizIf);
  3572. if (pRtrWizIf)
  3573. sPublicInterfaceName = pRtrWizIf->m_stName;
  3574. else
  3575. {
  3576. // This may be the dd interface case. If we are creating
  3577. // a DD interface the name will never have been added to the
  3578. // interface map.
  3579. sPublicInterfaceName = m_pRtrWizData->m_stPublicInterfaceId;
  3580. }
  3581. CString sIPAddr;
  3582. CString sIPMask;
  3583. // Get the information for the private interface
  3584. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPrivateInterfaceId,
  3585. pRtrWizIf);
  3586. if (pRtrWizIf)
  3587. {
  3588. DWORD netAddress, netMask;
  3589. CString st;
  3590. // We have to calculate the beginning of the subnet
  3591. netAddress = INET_ADDR(pRtrWizIf->m_stIpAddress);
  3592. netMask = INET_ADDR(pRtrWizIf->m_stMask);
  3593. netAddress = netAddress & netMask;
  3594. sIPAddr = INET_NTOA(netAddress);
  3595. sIPMask = pRtrWizIf->m_stMask;
  3596. }
  3597. else
  3598. {
  3599. // An error! we do not have a private interface
  3600. // Just leave things blank
  3601. sIPAddr = L"192.168.0.0";
  3602. sIPMask = L"255.255.0.0";
  3603. }
  3604. /*
  3605. if ( m_pRtrWizData->m_fNatUseExternal )
  3606. {
  3607. sFormat.LoadString(IDS_NAT_A_FINISH_SUMMARY_SIMPLE);
  3608. sText.Format(sFormat,
  3609. (m_pRtrWizData->m_fNATEnableFireWall?sFirewall:""),
  3610. sPublicInterfaceName );
  3611. }
  3612. else
  3613. {
  3614. */
  3615. sFirewall.LoadString(IDS_NAT_SUMMARY_BASIC_FIREWALL);
  3616. if ( m_pRtrWizData->m_dwExpressType == MPRSNAP_CYS_EXPRESS_NAT )
  3617. {
  3618. sFormat.LoadString(IDS_NAT_EXTERNAL_FINISH_SUMMARY_CYS);
  3619. sText.Format(sFormat,
  3620. (m_pRtrWizData->m_fNATEnableFireWall?sFirewall:""),
  3621. sPublicInterfaceName );
  3622. }
  3623. else {
  3624. sFormat.LoadString(IDS_NAT_A_FINISH_SUMMARY);
  3625. sText.Format(sFormat,
  3626. (m_pRtrWizData->m_fNATEnableFireWall?sFirewall:""),
  3627. sPublicInterfaceName, sIPAddr, sIPMask );
  3628. }
  3629. SetDlgItemText(IDC_TXT_NAT_SUMMARY, sText);
  3630. // GetDlgItem(IDC_NEWWIZ_CHK_HELP)->SetFocus();
  3631. SetFocus();
  3632. return TRUE;
  3633. }
  3634. /*---------------------------------------------------------------------------
  3635. CNewRtrWizNatFinishExternal
  3636. ---------------------------------------------------------------------------*/
  3637. CNewRtrWizNatFinishExternal::CNewRtrWizNatFinishExternal() :
  3638. CNewRtrWizFinishPageBase(CNewRtrWizNatFinishExternal::IDD, SaveFlag_Advanced, HelpFlag_GeneralNAT)
  3639. {
  3640. InitWiz97(TRUE, 0, 0);
  3641. }
  3642. BEGIN_MESSAGE_MAP(CNewRtrWizNatFinishExternal, CNewRtrWizFinishPageBase)
  3643. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizNatFinishExternal::OnHelpClick )
  3644. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizNatFinishExternal::OnHelpClick )
  3645. END_MESSAGE_MAP()
  3646. void CNewRtrWizNatFinishExternal::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  3647. {
  3648. if(!pNMHDR || !pResult)
  3649. return;
  3650. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  3651. return;
  3652. HtmlHelpA(NULL, "RRASconcepts.chm::/sag_RRAS-Ch3_06b.htm", HH_DISPLAY_TOPIC, 0);
  3653. *pResult = 0;
  3654. }
  3655. BOOL CNewRtrWizNatFinishExternal::OnSetActive()
  3656. {
  3657. CNewRtrWizFinishPageBase::OnSetActive();
  3658. RtrWizInterface * pRtrWizIf = NULL;
  3659. CString sFormat;
  3660. CString sText;
  3661. CString sPublicInterfaceName;
  3662. CString sFirewall;
  3663. CNewRtrWizFinishPageBase::OnSetActive();
  3664. // If we just got here because we created a DD interface
  3665. // we can't go back.
  3666. if (m_pRtrWizData->m_fCreateDD)
  3667. {
  3668. CancelToClose();
  3669. GetHolder()->SetWizardButtons(PSWIZB_FINISH);
  3670. }
  3671. //Setup the text that goes in the summary box
  3672. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPublicInterfaceId,
  3673. pRtrWizIf);
  3674. if (pRtrWizIf)
  3675. sPublicInterfaceName = pRtrWizIf->m_stName;
  3676. else
  3677. {
  3678. // This may be the dd interface case. If we are creating
  3679. // a DD interface the name will never have been added to the
  3680. // interface map.
  3681. sPublicInterfaceName = m_pRtrWizData->m_stPublicInterfaceId;
  3682. }
  3683. sFirewall.LoadString(IDS_NAT_SUMMARY_BASIC_FIREWALL);
  3684. if ( m_pRtrWizData->m_dwExpressType == MPRSNAP_CYS_EXPRESS_NAT )
  3685. {
  3686. sFormat.LoadString(IDS_NAT_EXTERNAL_FINISH_SUMMARY_CYS);
  3687. sText.Format(sFormat,
  3688. (m_pRtrWizData->m_fNATEnableFireWall?sFirewall:""),
  3689. sPublicInterfaceName );
  3690. }
  3691. else if ( m_pRtrWizData->m_fNatUseExternal )
  3692. {
  3693. sFormat.LoadString(IDS_NAT_A_FINISH_SUMMARY_SIMPLE);
  3694. sText.Format(sFormat,
  3695. (m_pRtrWizData->m_fNATEnableFireWall?sFirewall:""),
  3696. sPublicInterfaceName );
  3697. }
  3698. else if (FHrOK(m_pRtrWizData->HrIsDHCPRunningOnInterface()) ||
  3699. FHrOK(m_pRtrWizData->HrIsDNSRunningOnInterface())
  3700. )
  3701. {
  3702. //
  3703. //Dhcp enabled on private interface.
  3704. //
  3705. sFormat.LoadString(IDS_NAT_EXTERNAL_FINISH_SUMMARY_DHCP_PRIVATE);
  3706. sText.Format(sFormat,
  3707. (m_pRtrWizData->m_fNATEnableFireWall?sFirewall:""),
  3708. sPublicInterfaceName );
  3709. }
  3710. else
  3711. {
  3712. sFormat.LoadString(IDS_NAT_EXTERNAL_FINISH_SUMMARY);
  3713. sText.Format(sFormat,
  3714. (m_pRtrWizData->m_fNATEnableFireWall?sFirewall:""),
  3715. sPublicInterfaceName );
  3716. }
  3717. SetDlgItemText(IDC_TXT_NAT_EXTERNAL_FINISH_SUMMARY, sText);
  3718. // GetDlgItem(IDC_NEWWIZ_CHK_HELP)->SetFocus();
  3719. SetFocus();
  3720. return TRUE;
  3721. }
  3722. /*---------------------------------------------------------------------------
  3723. CNewRtrWizNatDDError
  3724. ---------------------------------------------------------------------------*/
  3725. CNewRtrWizNatFinishDDError::CNewRtrWizNatFinishDDError() :
  3726. CNewRtrWizFinishPageBase(CNewRtrWizNatFinishDDError::IDD, SaveFlag_DoNothing, HelpFlag_Nothing)
  3727. {
  3728. InitWiz97(TRUE, 0, 0);
  3729. }
  3730. BEGIN_MESSAGE_MAP(CNewRtrWizNatFinishDDError, CNewRtrWizFinishPageBase)
  3731. END_MESSAGE_MAP()
  3732. BOOL CNewRtrWizNatFinishDDError::OnInitDialog()
  3733. {
  3734. CFont font;
  3735. CWnd * wnd;
  3736. CNewRtrWizFinishPageBase::OnInitDialog();
  3737. font.CreatePointFont( 120, TEXT("Verdana Bold"), NULL);
  3738. if(wnd = GetDlgItem(IDC_COMPLETE_ERROR)){
  3739. wnd->SetFont(&font);
  3740. }
  3741. return TRUE;
  3742. }
  3743. BOOL CNewRtrWizNatFinishDDError::OnSetActive()
  3744. {
  3745. CNewRtrWizFinishPageBase::OnSetActive();
  3746. GetHolder()->SetWizardButtons(PSWIZB_FINISH);
  3747. return TRUE;
  3748. }
  3749. /*---------------------------------------------------------------------------
  3750. CNewRtrWizRasFinishNeedProtocols Implementation
  3751. ---------------------------------------------------------------------------*/
  3752. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRasFinishNeedProtocols,
  3753. SaveFlag_DoNothing,
  3754. HelpFlag_AddProtocol);
  3755. /*---------------------------------------------------------------------------
  3756. CNewRtrWizRasFinishNeedProtocolsNonLocal Implementation
  3757. ---------------------------------------------------------------------------*/
  3758. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRasFinishNeedProtocolsNonLocal,
  3759. SaveFlag_DoNothing,
  3760. HelpFlag_Nothing);
  3761. /*---------------------------------------------------------------------------
  3762. CNewRtrWizVpnFinishNeedProtocols Implementation
  3763. ---------------------------------------------------------------------------*/
  3764. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNeedProtocols,
  3765. SaveFlag_DoNothing,
  3766. HelpFlag_AddProtocol);
  3767. /*---------------------------------------------------------------------------
  3768. CNewRtrWizVpnFinishNeedProtocolsNonLocal Implementation
  3769. ---------------------------------------------------------------------------*/
  3770. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNeedProtocolsNonLocal,
  3771. SaveFlag_DoNothing,
  3772. HelpFlag_Nothing);
  3773. /*---------------------------------------------------------------------------
  3774. CNewRtrWizRouterFinishNeedProtocols Implementation
  3775. ---------------------------------------------------------------------------*/
  3776. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRouterFinishNeedProtocols,
  3777. SaveFlag_DoNothing,
  3778. HelpFlag_AddProtocol);
  3779. /*---------------------------------------------------------------------------
  3780. CNewRtrWizRouterFinishNeedProtocolsNonLocal Implementation
  3781. ---------------------------------------------------------------------------*/
  3782. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRouterFinishNeedProtocolsNonLocal,
  3783. SaveFlag_DoNothing,
  3784. HelpFlag_Nothing);
  3785. /*---------------------------------------------------------------------------
  3786. CNewRtrWizSelectNetwork implementation
  3787. ---------------------------------------------------------------------------*/
  3788. CNewRtrWizSelectNetwork::CNewRtrWizSelectNetwork(UINT uDialogId) :
  3789. CNewRtrWizPageBase(uDialogId, CNewRtrWizPageBase::Middle)
  3790. {
  3791. }
  3792. void CNewRtrWizSelectNetwork::DoDataExchange(CDataExchange *pDX)
  3793. {
  3794. CNewRtrWizPageBase::DoDataExchange(pDX);
  3795. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  3796. }
  3797. BEGIN_MESSAGE_MAP(CNewRtrWizSelectNetwork, CNewRtrWizPageBase)
  3798. END_MESSAGE_MAP()
  3799. /*!--------------------------------------------------------------------------
  3800. CNewRtrWizSelectNetwork::OnInitDialog
  3801. -
  3802. Author: KennT
  3803. ---------------------------------------------------------------------------*/
  3804. BOOL CNewRtrWizSelectNetwork::OnInitDialog()
  3805. {
  3806. // DWORD dwNICs;
  3807. CNewRtrWizPageBase::OnInitDialog();
  3808. // m_pRtrWizData->GetNumberOfNICS(&dwNICs);
  3809. InitializeInterfaceListControl(NULL,
  3810. &m_listCtrl,
  3811. NULL,
  3812. 0,
  3813. m_pRtrWizData);
  3814. RefreshInterfaceListControl(NULL,
  3815. &m_listCtrl,
  3816. NULL,
  3817. 0,
  3818. m_pRtrWizData);
  3819. m_listCtrl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED );
  3820. return TRUE;
  3821. }
  3822. HRESULT CNewRtrWizSelectNetwork::OnSavePage()
  3823. {
  3824. INT iSel;
  3825. // Check to see that we actually selected an item
  3826. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  3827. if (iSel == -1)
  3828. {
  3829. // We did not select an item
  3830. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  3831. return E_FAIL;
  3832. }
  3833. m_pRtrWizData->m_fCreateDD = FALSE;
  3834. m_pRtrWizData->m_stPrivateInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  3835. return hrOK;
  3836. }
  3837. /*---------------------------------------------------------------------------
  3838. CNewRtrWizRasSelectNetwork implementation
  3839. ---------------------------------------------------------------------------*/
  3840. CNewRtrWizRasSelectNetwork::CNewRtrWizRasSelectNetwork() :
  3841. CNewRtrWizSelectNetwork(CNewRtrWizRasSelectNetwork::IDD)
  3842. {
  3843. InitWiz97(FALSE,
  3844. IDS_NEWWIZ_RAS_A_SELECT_NETWORK_TITLE,
  3845. IDS_NEWWIZ_RAS_A_SELECT_NETWORK_SUBTITLE);
  3846. }
  3847. /*---------------------------------------------------------------------------
  3848. CNewRtrWizRasNoNICs implementation
  3849. ---------------------------------------------------------------------------*/
  3850. CNewRtrWizRasNoNICs::CNewRtrWizRasNoNICs() :
  3851. CNewRtrWizPageBase(CNewRtrWizRasNoNICs::IDD, CNewRtrWizPageBase::Middle)
  3852. {
  3853. InitWiz97(FALSE,
  3854. IDS_NEWWIZ_RAS_NONICS_TITLE,
  3855. IDS_NEWWIZ_RAS_NONICS_SUBTITLE);
  3856. }
  3857. void CNewRtrWizRasNoNICs::DoDataExchange(CDataExchange *pDX)
  3858. {
  3859. CNewRtrWizPageBase::DoDataExchange(pDX);
  3860. }
  3861. BEGIN_MESSAGE_MAP(CNewRtrWizRasNoNICs, CNewRtrWizPageBase)
  3862. END_MESSAGE_MAP()
  3863. /*!--------------------------------------------------------------------------
  3864. CNewRtrWizRasNoNICs::OnInitDialog
  3865. -
  3866. Author: KennT
  3867. ---------------------------------------------------------------------------*/
  3868. BOOL CNewRtrWizRasNoNICs::OnInitDialog()
  3869. {
  3870. CNewRtrWizPageBase::OnInitDialog();
  3871. CheckRadioButton(IDC_NEWWIZ_BTN_YES, IDC_NEWWIZ_BTN_NO,
  3872. IDC_NEWWIZ_BTN_YES);
  3873. // The default is to create a new connection
  3874. // That is, to leave the button unchecked.
  3875. return TRUE;
  3876. }
  3877. HRESULT CNewRtrWizRasNoNICs::OnSavePage()
  3878. {
  3879. m_pRtrWizData->m_fNoNicsAreOk = IsDlgButtonChecked(IDC_NEWWIZ_BTN_NO);
  3880. return hrOK;
  3881. }
  3882. /*---------------------------------------------------------------------------
  3883. CNewRtrWizRasFinishNoNICs Implementation
  3884. ---------------------------------------------------------------------------*/
  3885. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizRasFinishNoNICs,
  3886. SaveFlag_DoNothing,
  3887. HelpFlag_Nothing);
  3888. /*---------------------------------------------------------------------------
  3889. CNewRtrWizAddressing implementation
  3890. ---------------------------------------------------------------------------*/
  3891. CNewRtrWizAddressing::CNewRtrWizAddressing() :
  3892. CNewRtrWizPageBase(CNewRtrWizAddressing::IDD, CNewRtrWizPageBase::Middle)
  3893. {
  3894. InitWiz97(FALSE,
  3895. IDS_NEWWIZ_ADDRESS_ASSIGNMENT_TITLE,
  3896. IDS_NEWWIZ_ADDRESS_ASSIGNMENT_SUBTITLE);
  3897. }
  3898. void CNewRtrWizAddressing::DoDataExchange(CDataExchange *pDX)
  3899. {
  3900. CNewRtrWizPageBase::DoDataExchange(pDX);
  3901. }
  3902. BEGIN_MESSAGE_MAP(CNewRtrWizAddressing, CNewRtrWizPageBase)
  3903. END_MESSAGE_MAP()
  3904. /*!--------------------------------------------------------------------------
  3905. CNewRtrWizAddressing::OnInitDialog
  3906. -
  3907. Author: KennT
  3908. ---------------------------------------------------------------------------*/
  3909. BOOL CNewRtrWizAddressing::OnInitDialog()
  3910. {
  3911. CNewRtrWizPageBase::OnInitDialog();
  3912. CheckRadioButton(IDC_NEWWIZ_BTN_YES, IDC_NEWWIZ_BTN_NO,
  3913. m_pRtrWizData->m_fUseDHCP ? IDC_NEWWIZ_BTN_YES : IDC_NEWWIZ_BTN_NO);
  3914. return TRUE;
  3915. }
  3916. /*!--------------------------------------------------------------------------
  3917. CNewRtrWizAddressing::OnSavePage
  3918. -
  3919. Author: KennT
  3920. ---------------------------------------------------------------------------*/
  3921. HRESULT CNewRtrWizAddressing::OnSavePage()
  3922. {
  3923. m_pRtrWizData->m_fUseDHCP = IsDlgButtonChecked(IDC_NEWWIZ_BTN_YES);
  3924. return hrOK;
  3925. }
  3926. /*---------------------------------------------------------------------------
  3927. CNewRtrWizAddressPool implementation
  3928. ---------------------------------------------------------------------------*/
  3929. CNewRtrWizAddressPool::CNewRtrWizAddressPool() :
  3930. CNewRtrWizPageBase(CNewRtrWizAddressPool::IDD, CNewRtrWizPageBase::Middle)
  3931. {
  3932. InitWiz97(FALSE,
  3933. IDS_NEWWIZ_ADDRESS_POOL_TITLE,
  3934. IDS_NEWWIZ_ADDRESS_POOL_SUBTITLE);
  3935. }
  3936. void CNewRtrWizAddressPool::DoDataExchange(CDataExchange *pDX)
  3937. {
  3938. CNewRtrWizPageBase::DoDataExchange(pDX);
  3939. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  3940. }
  3941. BEGIN_MESSAGE_MAP(CNewRtrWizAddressPool, CNewRtrWizPageBase)
  3942. ON_BN_CLICKED(IDC_NEWWIZ_BTN_NEW, OnBtnNew)
  3943. ON_BN_CLICKED(IDC_NEWWIZ_BTN_EDIT, OnBtnEdit)
  3944. ON_BN_CLICKED(IDC_NEWWIZ_BTN_DELETE, OnBtnDelete)
  3945. ON_NOTIFY(NM_DBLCLK, IDC_NEWWIZ_LIST, OnListDblClk)
  3946. ON_NOTIFY(LVN_ITEMCHANGED, IDC_NEWWIZ_LIST, OnNotifyListItemChanged)
  3947. END_MESSAGE_MAP()
  3948. /*!--------------------------------------------------------------------------
  3949. CNewRtrWizAddressPool::OnInitDialog
  3950. -
  3951. Author: KennT
  3952. ---------------------------------------------------------------------------*/
  3953. BOOL CNewRtrWizAddressPool::OnInitDialog()
  3954. {
  3955. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  3956. CNewRtrWizPageBase::OnInitDialog();
  3957. InitializeAddressPoolListControl(&m_listCtrl,
  3958. 0,
  3959. &(m_pRtrWizData->m_addressPoolList));
  3960. MultiEnableWindow(GetSafeHwnd(),
  3961. FALSE,
  3962. IDC_NEWWIZ_BTN_EDIT,
  3963. IDC_NEWWIZ_BTN_DELETE,
  3964. 0);
  3965. Assert(m_pRtrWizData->m_addressPoolList.GetCount() == 0);
  3966. return TRUE;
  3967. }
  3968. BOOL CNewRtrWizAddressPool::OnSetActive()
  3969. {
  3970. CNewRtrWizPageBase::OnSetActive();
  3971. if (m_listCtrl.GetItemCount() == 0)
  3972. GetHolder()->SetWizardButtons(PSWIZB_BACK);
  3973. else
  3974. GetHolder()->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  3975. return TRUE;
  3976. }
  3977. HRESULT CNewRtrWizAddressPool::OnSavePage()
  3978. {
  3979. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  3980. // No need to save the information, the list should be kept
  3981. // up to date.
  3982. if (m_pRtrWizData->m_addressPoolList.GetCount() == 0)
  3983. {
  3984. AfxMessageBox(IDS_ERR_ADDRESS_POOL_IS_EMPTY);
  3985. //we dont return this to client
  3986. return E_FAIL;
  3987. }
  3988. return hrOK;
  3989. }
  3990. void CNewRtrWizAddressPool::OnBtnNew()
  3991. {
  3992. OnNewAddressPool(GetSafeHwnd(),
  3993. &m_listCtrl,
  3994. 0,
  3995. &(m_pRtrWizData->m_addressPoolList));
  3996. if (m_listCtrl.GetItemCount() > 0)
  3997. GetHolder()->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  3998. // Reset the focus
  3999. if (m_listCtrl.GetNextItem(-1, LVIS_SELECTED) != -1)
  4000. {
  4001. MultiEnableWindow(GetSafeHwnd(),
  4002. TRUE,
  4003. IDC_NEWWIZ_BTN_EDIT,
  4004. IDC_NEWWIZ_BTN_DELETE,
  4005. 0);
  4006. }
  4007. }
  4008. void CNewRtrWizAddressPool::OnListDblClk(NMHDR *pNMHdr, LRESULT *pResult)
  4009. {
  4010. OnBtnEdit();
  4011. *pResult = 0;
  4012. }
  4013. void CNewRtrWizAddressPool::OnNotifyListItemChanged(NMHDR *pNmHdr, LRESULT *pResult)
  4014. {
  4015. NMLISTVIEW * pnmlv = reinterpret_cast<NMLISTVIEW *>(pNmHdr);
  4016. BOOL fEnable = !!(pnmlv->uNewState & LVIS_SELECTED);
  4017. MultiEnableWindow(GetSafeHwnd(),
  4018. fEnable,
  4019. IDC_NEWWIZ_BTN_EDIT,
  4020. IDC_NEWWIZ_BTN_DELETE,
  4021. 0);
  4022. *pResult = 0;
  4023. }
  4024. void CNewRtrWizAddressPool::OnBtnEdit()
  4025. {
  4026. INT iPos;
  4027. OnEditAddressPool(GetSafeHwnd(),
  4028. &m_listCtrl,
  4029. 0,
  4030. &(m_pRtrWizData->m_addressPoolList));
  4031. // reset the selection
  4032. if ((iPos = m_listCtrl.GetNextItem(-1, LVNI_SELECTED)) != -1)
  4033. {
  4034. MultiEnableWindow(GetSafeHwnd(),
  4035. TRUE,
  4036. IDC_NEWWIZ_BTN_EDIT,
  4037. IDC_NEWWIZ_BTN_DELETE,
  4038. 0);
  4039. }
  4040. SetFocus();
  4041. }
  4042. void CNewRtrWizAddressPool::OnBtnDelete()
  4043. {
  4044. OnDeleteAddressPool(GetSafeHwnd(),
  4045. &m_listCtrl,
  4046. 0,
  4047. &(m_pRtrWizData->m_addressPoolList));
  4048. // There are no items, don't let them go forward
  4049. if (m_listCtrl.GetItemCount() == 0)
  4050. GetHolder()->SetWizardButtons(PSWIZB_BACK);
  4051. SetFocus();
  4052. }
  4053. /*---------------------------------------------------------------------------
  4054. CNewRtrWizRadius implementation
  4055. ---------------------------------------------------------------------------*/
  4056. CNewRtrWizRadius::CNewRtrWizRadius() :
  4057. CNewRtrWizPageBase(CNewRtrWizRadius::IDD, CNewRtrWizPageBase::Middle)
  4058. {
  4059. InitWiz97(FALSE,
  4060. IDS_NEWWIZ_USERADIUS_TITLE,
  4061. IDS_NEWWIZ_USERADIUS_SUBTITLE);
  4062. }
  4063. void CNewRtrWizRadius::DoDataExchange(CDataExchange *pDX)
  4064. {
  4065. CNewRtrWizPageBase::DoDataExchange(pDX);
  4066. }
  4067. BEGIN_MESSAGE_MAP(CNewRtrWizRadius, CNewRtrWizPageBase)
  4068. END_MESSAGE_MAP()
  4069. /*!--------------------------------------------------------------------------
  4070. CNewRtrWizRadius::OnInitDialog
  4071. -
  4072. Author: KennT
  4073. ---------------------------------------------------------------------------*/
  4074. BOOL CNewRtrWizRadius::OnInitDialog()
  4075. {
  4076. CNewRtrWizPageBase::OnInitDialog();
  4077. CheckRadioButton(IDC_NEWWIZ_BTN_YES, IDC_NEWWIZ_BTN_NO,
  4078. m_pRtrWizData->m_fUseRadius ? IDC_NEWWIZ_BTN_YES : IDC_NEWWIZ_BTN_NO);
  4079. return TRUE;
  4080. }
  4081. /*!--------------------------------------------------------------------------
  4082. CNewRtrWizRadius::OnSavePage
  4083. -
  4084. Author: KennT
  4085. ---------------------------------------------------------------------------*/
  4086. HRESULT CNewRtrWizRadius::OnSavePage()
  4087. {
  4088. m_pRtrWizData->m_fUseRadius = IsDlgButtonChecked(IDC_NEWWIZ_BTN_YES);
  4089. return hrOK;
  4090. }
  4091. /*---------------------------------------------------------------------------
  4092. CNewRtrWizRadiusConfig implementation
  4093. ---------------------------------------------------------------------------*/
  4094. CNewRtrWizRadiusConfig::CNewRtrWizRadiusConfig() :
  4095. CNewRtrWizPageBase(IDD_NEWRTRWIZ_RADIUS_CONFIG, CNewRtrWizPageBase::Middle)
  4096. {
  4097. InitWiz97(FALSE,
  4098. IDS_NEWWIZ_RADIUS_CONFIG_TITLE,
  4099. IDS_NEWWIZ_RADIUS_CONFIG_SUBTITLE);
  4100. }
  4101. void CNewRtrWizRadiusConfig::DoDataExchange(CDataExchange *pDX)
  4102. {
  4103. CNewRtrWizPageBase::DoDataExchange(pDX);
  4104. }
  4105. BEGIN_MESSAGE_MAP(CNewRtrWizRadiusConfig, CNewRtrWizPageBase)
  4106. END_MESSAGE_MAP()
  4107. #define MAX_RADIUS_SRV_LEN 255
  4108. /*!--------------------------------------------------------------------------
  4109. CNewRtrWizRadiusConfig::OnInitDialog
  4110. -
  4111. Author: KennT
  4112. ---------------------------------------------------------------------------*/
  4113. BOOL CNewRtrWizRadiusConfig::OnInitDialog()
  4114. {
  4115. CNewRtrWizPageBase::OnInitDialog();
  4116. GetDlgItem(IDC_NEWWIZ_EDIT_PRIMARY)->SendMessage(EM_LIMITTEXT, MAX_RADIUS_SRV_LEN, 0L);
  4117. GetDlgItem(IDC_NEWWIZ_EDIT_SECONDARY)->SendMessage(EM_LIMITTEXT, MAX_RADIUS_SRV_LEN, 0L);
  4118. return TRUE;
  4119. }
  4120. /*!--------------------------------------------------------------------------
  4121. CNewRtrWizRadiusConfig::OnSavePage
  4122. -
  4123. Author: KennT
  4124. ---------------------------------------------------------------------------*/
  4125. HRESULT CNewRtrWizRadiusConfig::OnSavePage()
  4126. {
  4127. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  4128. CString st;
  4129. DWORD netAddress;
  4130. CWaitCursor wait;
  4131. WSADATA wsadata;
  4132. DWORD wsaerr = 0;
  4133. HRESULT hr = hrOK;
  4134. BOOL fWSInitialized = FALSE;
  4135. // Check to see that we have non-blank names
  4136. // ----------------------------------------------------------------
  4137. GetDlgItemText(IDC_NEWWIZ_EDIT_PRIMARY, m_pRtrWizData->m_stRadius1);
  4138. m_pRtrWizData->m_stRadius1.TrimLeft();
  4139. m_pRtrWizData->m_stRadius1.TrimRight();
  4140. GetDlgItemText(IDC_NEWWIZ_EDIT_SECONDARY, m_pRtrWizData->m_stRadius2);
  4141. m_pRtrWizData->m_stRadius2.TrimLeft();
  4142. m_pRtrWizData->m_stRadius2.TrimRight();
  4143. if (m_pRtrWizData->m_stRadius1.IsEmpty() &&
  4144. m_pRtrWizData->m_stRadius2.IsEmpty())
  4145. {
  4146. AfxMessageBox(IDS_ERR_NO_RADIUS_SERVERS_SPECIFIED);
  4147. return E_FAIL;
  4148. }
  4149. // Start up winsock (for the ResolveName())
  4150. // ----------------------------------------------------------------
  4151. wsaerr = WSAStartup(0x0101, &wsadata);
  4152. if (wsaerr)
  4153. CORg( E_FAIL );
  4154. fWSInitialized = TRUE;
  4155. // Convert name into an IP address
  4156. if (!m_pRtrWizData->m_stRadius1.IsEmpty())
  4157. {
  4158. m_pRtrWizData->m_netRadius1IpAddress = ResolveName(m_pRtrWizData->m_stRadius1);
  4159. if (m_pRtrWizData->m_netRadius1IpAddress == INADDR_NONE)
  4160. {
  4161. CString st;
  4162. st.Format(IDS_WRN_RTRWIZ_CANNOT_RESOLVE_RADIUS,
  4163. (LPCTSTR) m_pRtrWizData->m_stRadius1);
  4164. if (AfxMessageBox(st, MB_OKCANCEL) == IDCANCEL)
  4165. {
  4166. GetDlgItem(IDC_NEWWIZ_EDIT_PRIMARY)->SetFocus();
  4167. return E_FAIL;
  4168. }
  4169. }
  4170. }
  4171. // Convert name into an IP address
  4172. if (!m_pRtrWizData->m_stRadius2.IsEmpty())
  4173. {
  4174. m_pRtrWizData->m_netRadius2IpAddress = ResolveName(m_pRtrWizData->m_stRadius2);
  4175. if (m_pRtrWizData->m_netRadius2IpAddress == INADDR_NONE)
  4176. {
  4177. CString st;
  4178. st.Format(IDS_WRN_RTRWIZ_CANNOT_RESOLVE_RADIUS,
  4179. (LPCTSTR) m_pRtrWizData->m_stRadius2);
  4180. if (AfxMessageBox(st, MB_OKCANCEL) == IDCANCEL)
  4181. {
  4182. GetDlgItem(IDC_NEWWIZ_EDIT_SECONDARY)->SetFocus();
  4183. return E_FAIL;
  4184. }
  4185. }
  4186. }
  4187. // Now get the password and encode it
  4188. // ----------------------------------------------------------------
  4189. GetDlgItemText(IDC_NEWWIZ_EDIT_SECRET, m_pRtrWizData->m_stRadiusSecret);
  4190. // Pick a seed value
  4191. m_pRtrWizData->m_uSeed = 0x9a;
  4192. RtlEncodeW(&m_pRtrWizData->m_uSeed,
  4193. m_pRtrWizData->m_stRadiusSecret.GetBuffer(0));
  4194. m_pRtrWizData->m_stRadiusSecret.ReleaseBuffer(-1);
  4195. Error:
  4196. if (fWSInitialized)
  4197. WSACleanup();
  4198. return hr;
  4199. }
  4200. DWORD CNewRtrWizRadiusConfig::ResolveName(LPCTSTR pszServerName)
  4201. {
  4202. CHAR szName[MAX_PATH+1];
  4203. DWORD netAddress = INADDR_NONE;
  4204. StrnCpyAFromT(szName, pszServerName, MAX_PATH);
  4205. netAddress = inet_addr(szName);
  4206. if (netAddress == INADDR_NONE)
  4207. {
  4208. // resolve name
  4209. struct hostent * phe = gethostbyname(szName);
  4210. if (phe != NULL)
  4211. {
  4212. if (phe->h_addr_list[0] != NULL)
  4213. netAddress = *((PDWORD) phe->h_addr_list[0]);
  4214. }
  4215. else
  4216. {
  4217. Assert(::WSAGetLastError() != WSANOTINITIALISED);
  4218. }
  4219. }
  4220. return netAddress;
  4221. }
  4222. /*---------------------------------------------------------------------------
  4223. CNewRtrWizRasFinishAdvanced Implementation
  4224. ---------------------------------------------------------------------------*/
  4225. CNewRtrWizRasFinishAdvanced::CNewRtrWizRasFinishAdvanced() :
  4226. CNewRtrWizFinishPageBase(CNewRtrWizRasFinishAdvanced::IDD, SaveFlag_Advanced, HelpFlag_GeneralRAS)
  4227. {
  4228. InitWiz97(TRUE, 0, 0);
  4229. }
  4230. BEGIN_MESSAGE_MAP(CNewRtrWizRasFinishAdvanced, CNewRtrWizFinishPageBase)
  4231. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizRasFinishAdvanced::OnHelpClick )
  4232. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizRasFinishAdvanced::OnHelpClick )
  4233. END_MESSAGE_MAP()
  4234. void CNewRtrWizRasFinishAdvanced::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  4235. {
  4236. if(!pNMHDR || !pResult)
  4237. return;
  4238. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  4239. return;
  4240. HtmlHelpA(NULL, "RRASconcepts.chm::/sag_RRAS-Ch1_1.htm", HH_DISPLAY_TOPIC, 0);
  4241. *pResult = 0;
  4242. }
  4243. BOOL CNewRtrWizRasFinishAdvanced::OnSetActive()
  4244. {
  4245. CString sText = L"";
  4246. CString sFormat;
  4247. CString sPolicy;
  4248. CString sPrivateInterfaceName;
  4249. RtrWizInterface * pRtrWizIf = NULL;
  4250. CNewRtrWizFinishPageBase::OnSetActive();
  4251. sFormat.LoadString(IDS_RAS_A_FINISH_SUMMARY);
  4252. if ( m_pRtrWizData->m_fUseRadius )
  4253. {
  4254. sPolicy.LoadString(IDS_VPN_A_FINISH_RADIUS);
  4255. }
  4256. else
  4257. {
  4258. sPolicy.LoadString(IDS_VPN_A_FINISH_POLICIES);
  4259. }
  4260. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPrivateInterfaceId,
  4261. pRtrWizIf);
  4262. if (pRtrWizIf)
  4263. sPrivateInterfaceName = pRtrWizIf->m_stName;
  4264. else
  4265. {
  4266. // This may be the dd interface case. If we are creating
  4267. // a DD interface the name will never have been added to the
  4268. // interface map.
  4269. sPrivateInterfaceName = m_pRtrWizData->m_stPrivateInterfaceId;
  4270. }
  4271. sText.Format ( sFormat,
  4272. sPrivateInterfaceName,
  4273. sPolicy
  4274. );
  4275. SetDlgItemText(IDC_TXT_RAS_SUMMARY, sText);
  4276. DestroyCaret();
  4277. return TRUE;
  4278. }
  4279. /*---------------------------------------------------------------------------
  4280. CNewRtrWizVpnFinishNoNICs Implementation
  4281. ---------------------------------------------------------------------------*/
  4282. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNoNICs,
  4283. SaveFlag_DoNothing,
  4284. HelpFlag_Nothing);
  4285. /*---------------------------------------------------------------------------
  4286. CNewRtrWizVpnFinishNoIP Implementation
  4287. ---------------------------------------------------------------------------*/
  4288. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNoIP,
  4289. SaveFlag_DoNothing,
  4290. HelpFlag_AddIp);
  4291. /*---------------------------------------------------------------------------
  4292. CNewRtrWizVpnFinishNoIPNonLocal Implementation
  4293. ---------------------------------------------------------------------------*/
  4294. IMPLEMENT_NEWRTRWIZ_FINISH_PAGE(CNewRtrWizVpnFinishNoIPNonLocal,
  4295. SaveFlag_DoNothing,
  4296. HelpFlag_Nothing);
  4297. /*---------------------------------------------------------------------------
  4298. CNewRtrWizNATVpnFinishAdvanced Implementation
  4299. ---------------------------------------------------------------------------*/
  4300. CNewRtrWizNATVpnFinishAdvanced::CNewRtrWizNATVpnFinishAdvanced() :
  4301. CNewRtrWizFinishPageBase(CNewRtrWizNATVpnFinishAdvanced::IDD, SaveFlag_Advanced, HelpFlag_Nothing)
  4302. {
  4303. InitWiz97(TRUE, 0, 0);
  4304. }
  4305. BEGIN_MESSAGE_MAP(CNewRtrWizNATVpnFinishAdvanced, CNewRtrWizFinishPageBase)
  4306. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizNATVpnFinishAdvanced::OnHelpClick )
  4307. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizNATVpnFinishAdvanced::OnHelpClick )
  4308. END_MESSAGE_MAP()
  4309. void CNewRtrWizNATVpnFinishAdvanced::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  4310. {
  4311. if(!pNMHDR || !pResult)
  4312. return;
  4313. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  4314. return;
  4315. HtmlHelpA(NULL, "RRASconcepts.chm::/sag_RRAS-Ch1_46.htm", HH_DISPLAY_TOPIC, 0);
  4316. *pResult = 0;
  4317. }
  4318. BOOL CNewRtrWizNATVpnFinishAdvanced::OnSetActive()
  4319. {
  4320. CString sText = L"";
  4321. CString sTextNAT;
  4322. CString sFormat;
  4323. CString sPolicy;
  4324. CString sPrivateInterfaceName;
  4325. CString sPublicInterfaceName;
  4326. RtrWizInterface * pRtrWizIf = NULL;
  4327. CNewRtrWizFinishPageBase::OnSetActive();
  4328. sFormat.LoadString(IDS_RAS_VPN_A_FINISH_SUMMARY);
  4329. if ( m_pRtrWizData->m_fUseRadius )
  4330. {
  4331. sPolicy.LoadString(IDS_VPN_A_FINISH_RADIUS);
  4332. }
  4333. else
  4334. {
  4335. sPolicy.LoadString(IDS_VPN_A_FINISH_POLICIES);
  4336. }
  4337. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPublicInterfaceId,
  4338. pRtrWizIf);
  4339. if (pRtrWizIf)
  4340. sPublicInterfaceName = pRtrWizIf->m_stName;
  4341. else
  4342. {
  4343. // This may be the dd interface case. If we are creating
  4344. // a DD interface the name will never have been added to the
  4345. // interface map.
  4346. sPublicInterfaceName = m_pRtrWizData->m_stPublicInterfaceId;
  4347. }
  4348. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPrivateInterfaceId,
  4349. pRtrWizIf);
  4350. if (pRtrWizIf)
  4351. sPrivateInterfaceName = pRtrWizIf->m_stName;
  4352. else
  4353. {
  4354. // This may be the dd interface case. If we are creating
  4355. // a DD interface the name will never have been added to the
  4356. // interface map.
  4357. sPrivateInterfaceName = m_pRtrWizData->m_stPrivateInterfaceId;
  4358. }
  4359. sText.Format ( sFormat,
  4360. sPublicInterfaceName,
  4361. sPrivateInterfaceName,
  4362. sPolicy
  4363. );
  4364. CString sIPAddr;
  4365. CString sIPMask;
  4366. // Now generate the NAT related information
  4367. // Get the information for the private interface
  4368. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stNATPrivateInterfaceId,
  4369. pRtrWizIf);
  4370. if (pRtrWizIf)
  4371. {
  4372. DWORD netAddress, netMask;
  4373. CString st;
  4374. // We have to calculate the beginning of the subnet
  4375. netAddress = INET_ADDR(pRtrWizIf->m_stIpAddress);
  4376. netMask = INET_ADDR(pRtrWizIf->m_stMask);
  4377. netAddress = netAddress & netMask;
  4378. sIPAddr = INET_NTOA(netAddress);
  4379. sIPMask = pRtrWizIf->m_stMask;
  4380. }
  4381. else
  4382. {
  4383. // An error! we do not have a private interface
  4384. // Just leave things blank
  4385. sIPAddr = L"192.168.0.0";
  4386. sIPMask = L"255.255.0.0";
  4387. }
  4388. sFormat.LoadString(IDS_NAT_A_FINISH_SUMMARY);
  4389. sTextNAT.Format(sFormat, "", sPublicInterfaceName, sIPAddr, sIPMask );
  4390. sText = sText + L"\r\n" + sTextNAT;
  4391. SetDlgItemText(IDC_TXT_NAT_VPN_SUMMARY, sText);
  4392. return TRUE;
  4393. }
  4394. /*---------------------------------------------------------------------------
  4395. CNewRtrWizRASVpnFinishAdvanced Implementation
  4396. ---------------------------------------------------------------------------*/
  4397. CNewRtrWizRASVpnFinishAdvanced::CNewRtrWizRASVpnFinishAdvanced() :
  4398. CNewRtrWizFinishPageBase(CNewRtrWizRASVpnFinishAdvanced::IDD, SaveFlag_Advanced, HelpFlag_UserAccounts)
  4399. {
  4400. InitWiz97(TRUE, 0, 0);
  4401. }
  4402. BEGIN_MESSAGE_MAP(CNewRtrWizRASVpnFinishAdvanced, CNewRtrWizFinishPageBase)
  4403. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizRASVpnFinishAdvanced::OnHelpClick )
  4404. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizRASVpnFinishAdvanced::OnHelpClick )
  4405. END_MESSAGE_MAP()
  4406. void CNewRtrWizRASVpnFinishAdvanced::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  4407. {
  4408. if(!pNMHDR || !pResult)
  4409. return;
  4410. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  4411. return;
  4412. HtmlHelpA(NULL, "RRASconcepts.chm::/sag_RRAS-Ch1_46.htm", HH_DISPLAY_TOPIC, 0);
  4413. *pResult = 0;
  4414. }
  4415. BOOL CNewRtrWizRASVpnFinishAdvanced::OnSetActive()
  4416. {
  4417. CString sText = L"";
  4418. CString sFormat;
  4419. CString sPolicy;
  4420. CString sPrivateInterfaceName;
  4421. CString sPublicInterfaceName;
  4422. RtrWizInterface * pRtrWizIf = NULL;
  4423. CNewRtrWizFinishPageBase::OnSetActive();
  4424. sFormat.LoadString(IDS_RAS_VPN_A_FINISH_SUMMARY);
  4425. if ( m_pRtrWizData->m_fUseRadius )
  4426. {
  4427. sPolicy.LoadString(IDS_VPN_A_FINISH_RADIUS);
  4428. }
  4429. else
  4430. {
  4431. sPolicy.LoadString(IDS_VPN_A_FINISH_POLICIES);
  4432. }
  4433. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPublicInterfaceId,
  4434. pRtrWizIf);
  4435. if (pRtrWizIf)
  4436. sPublicInterfaceName = pRtrWizIf->m_stName;
  4437. else
  4438. {
  4439. // This may be the dd interface case. If we are creating
  4440. // a DD interface the name will never have been added to the
  4441. // interface map.
  4442. sPublicInterfaceName = m_pRtrWizData->m_stPublicInterfaceId;
  4443. }
  4444. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPrivateInterfaceId,
  4445. pRtrWizIf);
  4446. if (pRtrWizIf)
  4447. sPrivateInterfaceName = pRtrWizIf->m_stName;
  4448. else
  4449. {
  4450. // This may be the dd interface case. If we are creating
  4451. // a DD interface the name will never have been added to the
  4452. // interface map.
  4453. sPrivateInterfaceName = m_pRtrWizData->m_stPrivateInterfaceId;
  4454. }
  4455. sText.Format ( sFormat,
  4456. sPublicInterfaceName,
  4457. sPrivateInterfaceName,
  4458. sPolicy
  4459. );
  4460. SetDlgItemText(IDC_TXT_RAS_VPN_SUMMARY, sText);
  4461. GetDlgItem(IDC_DUMMY_CONTROL)->SetFocus();
  4462. return TRUE;
  4463. }
  4464. /*---------------------------------------------------------------------------
  4465. CNewRtrWizVpnFinishAdvanced Implementation
  4466. ---------------------------------------------------------------------------*/
  4467. CNewRtrWizVpnFinishAdvanced::CNewRtrWizVpnFinishAdvanced() :
  4468. CNewRtrWizFinishPageBase(CNewRtrWizVpnFinishAdvanced::IDD, SaveFlag_Advanced, HelpFlag_UserAccounts)
  4469. {
  4470. InitWiz97(TRUE, 0, 0);
  4471. }
  4472. BEGIN_MESSAGE_MAP(CNewRtrWizVpnFinishAdvanced, CNewRtrWizFinishPageBase)
  4473. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizVpnFinishAdvanced::OnHelpClick )
  4474. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizVpnFinishAdvanced::OnHelpClick )
  4475. END_MESSAGE_MAP()
  4476. void CNewRtrWizVpnFinishAdvanced::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  4477. {
  4478. if(!pNMHDR || !pResult)
  4479. return;
  4480. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  4481. return;
  4482. HtmlHelpA(NULL, "RRASconcepts.chm::/sag_RRAS-Ch1_46.htm", HH_DISPLAY_TOPIC, 0);
  4483. *pResult = 0;
  4484. }
  4485. BOOL CNewRtrWizVpnFinishAdvanced::OnSetActive()
  4486. {
  4487. CString sText = L"";
  4488. CString sFormat;
  4489. CString sPolicy;
  4490. CString sPrivateInterfaceName;
  4491. CString sPublicInterfaceName;
  4492. RtrWizInterface * pRtrWizIf = NULL;
  4493. CNewRtrWizFinishPageBase::OnSetActive();
  4494. sFormat.LoadString(IDS_VPN_A_FINISH_SUMMARY);
  4495. if ( m_pRtrWizData->m_fUseRadius )
  4496. {
  4497. sPolicy.LoadString(IDS_VPN_A_FINISH_RADIUS);
  4498. }
  4499. else
  4500. {
  4501. sPolicy.LoadString(IDS_VPN_A_FINISH_POLICIES);
  4502. }
  4503. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPublicInterfaceId,
  4504. pRtrWizIf);
  4505. if (pRtrWizIf)
  4506. sPublicInterfaceName = pRtrWizIf->m_stName;
  4507. else
  4508. {
  4509. // This may be the dd interface case. If we are creating
  4510. // a DD interface the name will never have been added to the
  4511. // interface map.
  4512. sPublicInterfaceName = m_pRtrWizData->m_stPublicInterfaceId;
  4513. }
  4514. m_pRtrWizData->m_ifMap.Lookup(m_pRtrWizData->m_stPrivateInterfaceId,
  4515. pRtrWizIf);
  4516. if (pRtrWizIf)
  4517. sPrivateInterfaceName = pRtrWizIf->m_stName;
  4518. else
  4519. {
  4520. // This may be the dd interface case. If we are creating
  4521. // a DD interface the name will never have been added to the
  4522. // interface map.
  4523. sPrivateInterfaceName = m_pRtrWizData->m_stPrivateInterfaceId;
  4524. }
  4525. sText.Format ( sFormat,
  4526. sPublicInterfaceName,
  4527. sPrivateInterfaceName,
  4528. sPolicy
  4529. );
  4530. SetDlgItemText(IDC_TXT_VPN_SUMMARY, sText);
  4531. // GetDlgItem(IDC_NEWWIZ_CHK_HELP)->SetFocus();
  4532. SetFocus();
  4533. return TRUE;
  4534. }
  4535. /*---------------------------------------------------------------------------
  4536. CNewRtrWizVpnSelectPublic implementation
  4537. ---------------------------------------------------------------------------*/
  4538. CNewRtrWizVpnSelectPublic::CNewRtrWizVpnSelectPublic() :
  4539. CNewRtrWizPageBase(CNewRtrWizVpnSelectPublic::IDD, CNewRtrWizPageBase::Middle)
  4540. {
  4541. InitWiz97(FALSE,
  4542. IDS_NEWWIZ_VPN_A_SELECT_PUBLIC_TITLE,
  4543. IDS_NEWWIZ_VPN_A_SELECT_PUBLIC_SUBTITLE);
  4544. }
  4545. void CNewRtrWizVpnSelectPublic::DoDataExchange(CDataExchange *pDX)
  4546. {
  4547. CNewRtrWizPageBase::DoDataExchange(pDX);
  4548. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  4549. }
  4550. BEGIN_MESSAGE_MAP(CNewRtrWizVpnSelectPublic, CNewRtrWizPageBase)
  4551. //{{AFX_MSG_MAP(CNewRtrWizVpnSelectPublic)
  4552. ON_BN_CLICKED(IDC_CHK_ENABLE_SECURITY, OnButtonClick)
  4553. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizVpnSelectPublic::OnHelpClick )
  4554. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizVpnSelectPublic::OnHelpClick )
  4555. //}}AFX_MSG_MAP
  4556. END_MESSAGE_MAP()
  4557. void CNewRtrWizVpnSelectPublic::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  4558. {
  4559. if(!pNMHDR || !pResult)
  4560. return;
  4561. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  4562. return;
  4563. HtmlHelpA(NULL, "RRASconcepts.chm::/mpr_und_interfaces.htm", HH_DISPLAY_TOPIC, 0);
  4564. *pResult = 0;
  4565. }
  4566. /*!--------------------------------------------------------------------------
  4567. CNewRtrWizVpnSelectPublic::OnInitDialog
  4568. -
  4569. Author: KennT
  4570. ---------------------------------------------------------------------------*/
  4571. BOOL CNewRtrWizVpnSelectPublic::OnInitDialog()
  4572. {
  4573. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  4574. CString st;
  4575. CNewRtrWizPageBase::OnInitDialog();
  4576. // Setup the dialog and add the NICs
  4577. m_pRtrWizData->m_fSetVPNFilter = TRUE;
  4578. InitializeInterfaceListControl(NULL,
  4579. &m_listCtrl,
  4580. NULL,
  4581. 0,
  4582. m_pRtrWizData);
  4583. RefreshInterfaceListControl(NULL,
  4584. &m_listCtrl,
  4585. NULL,
  4586. 0,
  4587. m_pRtrWizData);
  4588. /*
  4589. if (dwNICs == 0)
  4590. {
  4591. //
  4592. // There are no NICS, you cannot set an interface
  4593. // pointing to the Internet, and hence no filters
  4594. // on it.
  4595. //
  4596. m_pRtrWizData->m_fSetVPNFilter = FALSE;
  4597. GetDlgItem(IDC_NEWWIZ_VPN_BTN_YES)->EnableWindow(FALSE);
  4598. GetDlgItem(IDC_VPN_YES_TEXT)->EnableWindow(FALSE);
  4599. }
  4600. */
  4601. #if 0
  4602. // Windows NT Bug : 389587 - for the VPN case, we have to allow
  4603. // for the case where they want only a single VPN connection (private
  4604. // and no public connection).
  4605. // Thus I add a <<None>> option to the list of interfaces.
  4606. // ----------------------------------------------------------------
  4607. st.LoadString(IDS_NO_PUBLIC_INTERFACE);
  4608. {
  4609. LV_ITEM lvItem;
  4610. int iPos;
  4611. lvItem.mask = LVIF_TEXT | LVIF_PARAM;
  4612. lvItem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
  4613. lvItem.state = 0;
  4614. lvItem.iItem = 0;
  4615. lvItem.iSubItem = 0;
  4616. lvItem.pszText = (LPTSTR)(LPCTSTR) st;
  4617. lvItem.lParam = NULL; //same functionality as SetItemData()
  4618. iPos = m_listCtrl.InsertItem(&lvItem);
  4619. if (iPos != -1)
  4620. {
  4621. m_listCtrl.SetItemText(iPos, IFLISTCOL_NAME,
  4622. (LPCTSTR) st);
  4623. m_listCtrl.SetItemData(iPos, NULL);
  4624. }
  4625. }
  4626. m_listCtrl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED );
  4627. #endif
  4628. CheckDlgButton(IDC_CHK_ENABLE_SECURITY,
  4629. m_pRtrWizData-> m_fSetVPNFilter );
  4630. //
  4631. //Preselect an interface if there is no public interface yet
  4632. //
  4633. if( m_pRtrWizData->m_stPublicInterfaceId.IsEmpty() )
  4634. m_listCtrl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED );
  4635. return TRUE;
  4636. }
  4637. BOOL CNewRtrWizVpnSelectPublic::OnSetActive()
  4638. {
  4639. CNewRtrWizPageBase::OnSetActive();
  4640. if(m_pRtrWizData->m_wizType == NewRtrWizData::NewWizardRouterType_VPNandNAT)
  4641. {
  4642. CString st;
  4643. st.LoadString(IDS_BASIC_FIREWALL);
  4644. SetDlgItemText(IDC_CHK_ENABLE_SECURITY, st);
  4645. st.LoadString(IDS_BASIC_FIREWALL_TEXT);
  4646. SetDlgItemText(IDC_VPN_PUBLIC_TEXT, st);
  4647. }
  4648. else {
  4649. CString st;
  4650. st.LoadString(IDS_STATIC_FILTER);
  4651. SetDlgItemText(IDC_CHK_ENABLE_SECURITY, st);
  4652. st.LoadString(IDS_STATIC_FILTER_TEXT);
  4653. SetDlgItemText(IDC_VPN_PUBLIC_TEXT, st);
  4654. }
  4655. return TRUE;
  4656. }
  4657. void CNewRtrWizVpnSelectPublic::OnButtonClick()
  4658. {
  4659. m_pRtrWizData->m_fSetVPNFilter =
  4660. IsDlgButtonChecked(IDC_CHK_ENABLE_SECURITY);
  4661. }
  4662. HRESULT CNewRtrWizVpnSelectPublic::OnSavePage()
  4663. {
  4664. INT iSel;
  4665. // Check to see that we actually selected an item
  4666. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  4667. if (iSel == -1)
  4668. {
  4669. // We did not select an item
  4670. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  4671. return E_FAIL;
  4672. }
  4673. m_pRtrWizData->m_fCreateDD = FALSE;
  4674. m_pRtrWizData->m_stPublicInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  4675. if ( m_pRtrWizData->m_wizType == NewRtrWizData::NewWizardRouterType_VPNandNAT )
  4676. {
  4677. m_pRtrWizData->m_fNATEnableFireWall = m_pRtrWizData->m_fSetVPNFilter;
  4678. }
  4679. return hrOK;
  4680. }
  4681. /*---------------------------------------------------------------------------
  4682. CNewRtrWizVpnSelectPrivate
  4683. ---------------------------------------------------------------------------*/
  4684. CNewRtrWizVpnSelectPrivate::CNewRtrWizVpnSelectPrivate() :
  4685. CNewRtrWizPageBase(CNewRtrWizVpnSelectPrivate::IDD, CNewRtrWizPageBase::Middle)
  4686. {
  4687. InitWiz97(FALSE,
  4688. IDS_NEWWIZ_VPN_A_SELECT_PRIVATE_TITLE,
  4689. IDS_NEWWIZ_VPN_A_SELECT_PRIVATE_SUBTITLE);
  4690. }
  4691. void CNewRtrWizVpnSelectPrivate::DoDataExchange(CDataExchange *pDX)
  4692. {
  4693. CNewRtrWizPageBase::DoDataExchange(pDX);
  4694. DDX_Control(pDX, IDC_NEWWIZ_LIST, m_listCtrl);
  4695. }
  4696. BEGIN_MESSAGE_MAP(CNewRtrWizVpnSelectPrivate, CNewRtrWizPageBase)
  4697. END_MESSAGE_MAP()
  4698. /*!--------------------------------------------------------------------------
  4699. CNewRtrWizVpnSelectPrivate::OnInitDialog
  4700. -
  4701. Author: KennT
  4702. ---------------------------------------------------------------------------*/
  4703. BOOL CNewRtrWizVpnSelectPrivate::OnInitDialog()
  4704. {
  4705. DWORD dwNICs;
  4706. CNewRtrWizPageBase::OnInitDialog();
  4707. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  4708. InitializeInterfaceListControl(NULL,
  4709. &m_listCtrl,
  4710. NULL,
  4711. 0,
  4712. m_pRtrWizData);
  4713. return TRUE;
  4714. }
  4715. /*!--------------------------------------------------------------------------
  4716. CNewRtrWizVpnSelectPrivate::OnSetActive
  4717. -
  4718. Author: KennT
  4719. ---------------------------------------------------------------------------*/
  4720. BOOL CNewRtrWizVpnSelectPrivate::OnSetActive()
  4721. {
  4722. DWORD dwNICs;
  4723. int iSel = 0;
  4724. CNewRtrWizPageBase::OnSetActive();
  4725. m_pRtrWizData->GetNumberOfNICS_IP(&dwNICs);
  4726. RefreshInterfaceListControl(NULL,
  4727. &m_listCtrl,
  4728. (LPCTSTR) m_pRtrWizData->m_stPublicInterfaceId,
  4729. 0,
  4730. m_pRtrWizData);
  4731. if (!m_pRtrWizData->m_stPrivateInterfaceId.IsEmpty())
  4732. {
  4733. // Try to reselect the previously selected NIC
  4734. LV_FINDINFO lvfi;
  4735. lvfi.flags = LVFI_PARTIAL | LVFI_STRING;
  4736. lvfi.psz = (LPCTSTR) m_pRtrWizData->m_stPrivateInterfaceId;
  4737. iSel = m_listCtrl.FindItem(&lvfi, -1);
  4738. if (iSel == -1)
  4739. iSel = 0;
  4740. }
  4741. m_listCtrl.SetItemState(iSel, LVIS_SELECTED, LVIS_SELECTED );
  4742. return TRUE;
  4743. }
  4744. /*!--------------------------------------------------------------------------
  4745. CNewRtrWizVpnSelectPrivate::OnSavePage
  4746. -
  4747. Author: KennT
  4748. ---------------------------------------------------------------------------*/
  4749. HRESULT CNewRtrWizVpnSelectPrivate::OnSavePage()
  4750. {
  4751. INT iSel;
  4752. // Check to see that we actually selected an item
  4753. iSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  4754. if (iSel == LB_ERR)
  4755. {
  4756. // We did not select an item
  4757. AfxMessageBox(IDS_PROMPT_PLEASE_SELECT_INTERFACE);
  4758. return E_FAIL;
  4759. }
  4760. m_pRtrWizData->m_stPrivateInterfaceId = (LPCTSTR) m_listCtrl.GetItemData(iSel);
  4761. return hrOK;
  4762. }
  4763. /*---------------------------------------------------------------------------
  4764. CNewRtrWizRouterUseDD implementation
  4765. ---------------------------------------------------------------------------*/
  4766. CNewRtrWizRouterUseDD::CNewRtrWizRouterUseDD() :
  4767. CNewRtrWizPageBase(CNewRtrWizRouterUseDD::IDD, CNewRtrWizPageBase::Middle)
  4768. {
  4769. InitWiz97(FALSE,
  4770. IDS_NEWWIZ_ROUTER_USEDD_TITLE,
  4771. IDS_NEWWIZ_ROUTER_USEDD_SUBTITLE);
  4772. }
  4773. void CNewRtrWizRouterUseDD::DoDataExchange(CDataExchange *pDX)
  4774. {
  4775. CNewRtrWizPageBase::DoDataExchange(pDX);
  4776. }
  4777. BEGIN_MESSAGE_MAP(CNewRtrWizRouterUseDD, CNewRtrWizPageBase)
  4778. END_MESSAGE_MAP()
  4779. /*!--------------------------------------------------------------------------
  4780. CNewRtrWizRouterUseDD::OnInitDialog
  4781. -
  4782. Author: KennT
  4783. ---------------------------------------------------------------------------*/
  4784. BOOL CNewRtrWizRouterUseDD::OnInitDialog()
  4785. {
  4786. CNewRtrWizPageBase::OnInitDialog();
  4787. CheckRadioButton(IDC_NEWWIZ_BTN_YES, IDC_NEWWIZ_BTN_NO,
  4788. m_pRtrWizData->m_fUseDD ? IDC_NEWWIZ_BTN_YES : IDC_NEWWIZ_BTN_NO);
  4789. // The default is to create a new connection
  4790. // That is, to leave the button unchecked.
  4791. return TRUE;
  4792. }
  4793. HRESULT CNewRtrWizRouterUseDD::OnSavePage()
  4794. {
  4795. m_pRtrWizData->m_fUseDD = IsDlgButtonChecked(IDC_NEWWIZ_BTN_YES);
  4796. return hrOK;
  4797. }
  4798. /*---------------------------------------------------------------------------
  4799. CNewRtrWizRouterFinish Implementation
  4800. ---------------------------------------------------------------------------*/
  4801. CNewRtrWizRouterFinish::CNewRtrWizRouterFinish () :
  4802. CNewRtrWizFinishPageBase(CNewRtrWizRouterFinish::IDD, SaveFlag_Advanced, HelpFlag_Nothing)
  4803. {
  4804. InitWiz97(TRUE, 0, 0);
  4805. }
  4806. BEGIN_MESSAGE_MAP(CNewRtrWizRouterFinish, CNewRtrWizFinishPageBase)
  4807. END_MESSAGE_MAP()
  4808. BOOL CNewRtrWizRouterFinish::OnSetActive ()
  4809. {
  4810. CString sText;
  4811. CNewRtrWizFinishPageBase::OnSetActive();
  4812. sText.LoadString(IDS_ROUTER_FINISH_DD_SUMMARY);
  4813. SetDlgItemText(IDC_TXT_ROUTER_FINISH_SUMMARY, sText);
  4814. return TRUE;
  4815. }
  4816. /*---------------------------------------------------------------------------
  4817. CNewRtrWizRouterFinishDD Implementation
  4818. ---------------------------------------------------------------------------*/
  4819. CNewRtrWizRouterFinishDD::CNewRtrWizRouterFinishDD () :
  4820. CNewRtrWizFinishPageBase(CNewRtrWizRouterFinishDD::IDD, SaveFlag_Advanced, HelpFlag_DemandDial)
  4821. {
  4822. InitWiz97(TRUE, 0, 0);
  4823. }
  4824. BEGIN_MESSAGE_MAP(CNewRtrWizRouterFinishDD, CNewRtrWizFinishPageBase)
  4825. ON_NOTIFY( NM_CLICK, IDC_HELP_LINK, CNewRtrWizRouterFinishDD::OnHelpClick )
  4826. ON_NOTIFY( NM_RETURN, IDC_HELP_LINK, CNewRtrWizRouterFinishDD::OnHelpClick )
  4827. END_MESSAGE_MAP()
  4828. void CNewRtrWizRouterFinishDD::OnHelpClick( NMHDR* pNMHDR, LRESULT* pResult)
  4829. {
  4830. if(!pNMHDR || !pResult)
  4831. return;
  4832. if((pNMHDR->idFrom != IDC_HELP_LINK) ||((pNMHDR->code != NM_CLICK) && (pNMHDR->code != NM_RETURN)))
  4833. return;
  4834. HtmlHelpA(NULL, "RRASconcepts.chm::/sag_RRAS-Ch3_08d.htm", HH_DISPLAY_TOPIC, 0);
  4835. *pResult = 0;
  4836. }
  4837. BOOL CNewRtrWizRouterFinishDD::OnSetActive ()
  4838. {
  4839. CString sText;
  4840. CNewRtrWizFinishPageBase::OnSetActive();
  4841. sText.LoadString(IDS_ROUTER_FINISH_DD_SUMMARY);
  4842. SetDlgItemText(IDC_TXT_ROUTER_FINISH_DD_SUMMARY, sText);
  4843. return TRUE;
  4844. }
  4845. /*---------------------------------------------------------------------------
  4846. CNewRtrWizManualFinish Implementation
  4847. ---------------------------------------------------------------------------*/
  4848. CNewRtrWizManualFinish::CNewRtrWizManualFinish () :
  4849. CNewRtrWizFinishPageBase(CNewRtrWizManualFinish ::IDD, SaveFlag_Advanced, HelpFlag_Nothing)
  4850. {
  4851. InitWiz97(TRUE, 0, 0);
  4852. }
  4853. BEGIN_MESSAGE_MAP(CNewRtrWizManualFinish, CNewRtrWizFinishPageBase)
  4854. END_MESSAGE_MAP()
  4855. BOOL CNewRtrWizManualFinish ::OnSetActive()
  4856. {
  4857. CString sText = L"";
  4858. CString sTemp = L"";
  4859. CString sBullet = L"";
  4860. WCHAR * pwszLineBreak = L"\r\n";
  4861. //
  4862. //Check to see which options are set and based on that,
  4863. //make the display message
  4864. //
  4865. CNewRtrWizFinishPageBase::OnSetActive();
  4866. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_VPN )
  4867. {
  4868. sText += sBullet;
  4869. sTemp.LoadString(IDS_SUMMARY_VPN_ACCESS);
  4870. sText += sTemp;
  4871. sText += pwszLineBreak;
  4872. }
  4873. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DIALUP )
  4874. {
  4875. sText += sBullet;
  4876. sTemp.LoadString(IDS_SUMMARY_DIALUP_ACCESS);
  4877. sText += sTemp;
  4878. sText += pwszLineBreak;
  4879. }
  4880. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_DOD )
  4881. {
  4882. sText += sBullet;
  4883. sTemp.LoadString(IDS_SUMMARY_DEMAND_DIAL);
  4884. sText += sTemp;
  4885. sText += pwszLineBreak;
  4886. }
  4887. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_NAT )
  4888. {
  4889. sText += sBullet;
  4890. sTemp.LoadString(IDS_SUMMARY_NAT);
  4891. sText += sTemp;
  4892. }
  4893. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_BASIC_FIREWALL )
  4894. {
  4895. //kmurthy: this should always come with type NAT
  4896. sTemp.LoadString(IDS_SUMMARY_BASIC_FIREWALL);
  4897. sText += sTemp;
  4898. sText += pwszLineBreak;
  4899. }
  4900. if ( m_pRtrWizData->m_dwNewRouterType & NEWWIZ_ROUTER_TYPE_LAN_ROUTING )
  4901. {
  4902. sText += sBullet;
  4903. sTemp.LoadString(IDS_SUMMARY_LAN_ROUTING);
  4904. sText += sTemp;
  4905. sText += pwszLineBreak;
  4906. }
  4907. SetDlgItemText(IDC_TXT_SUMMARY, sText);
  4908. GetDlgItem(IDC_STATIC_DUMMY)->SetFocus();
  4909. return TRUE;
  4910. }
  4911. CRasWarning::CRasWarning(char * helpTopic, int strId, CWnd* pParent /*=NULL*/)
  4912. :CDialog(CRasWarning::IDD, pParent)
  4913. {
  4914. m_helpTopic = helpTopic;
  4915. m_strId = strId;
  4916. }
  4917. void CRasWarning::DoDataExchange(CDataExchange* pDX)
  4918. {
  4919. CDialog::DoDataExchange(pDX);
  4920. }
  4921. BEGIN_MESSAGE_MAP(CRasWarning, CDialog)
  4922. //{{AFX_MSG_MAP(CDhcp)
  4923. ON_BN_CLICKED(ID_OK, OnOkBtn)
  4924. ON_BN_CLICKED(ID_HELP_BTN, OnHelpBtn)
  4925. //}}AFX_MSG_MAP
  4926. END_MESSAGE_MAP()
  4927. BOOL CRasWarning::OnInitDialog()
  4928. {
  4929. CString stText;
  4930. CDialog::OnInitDialog();
  4931. stText.LoadString(m_strId);
  4932. SetDlgItemText(IDC_RAS_WARNING, stText);
  4933. return TRUE;
  4934. }
  4935. void CRasWarning::OnOkBtn()
  4936. {
  4937. CDialog::OnOK();
  4938. }
  4939. void CRasWarning::OnHelpBtn()
  4940. {
  4941. if(m_helpTopic)
  4942. HtmlHelpA(NULL, m_helpTopic, HH_DISPLAY_TOPIC, 0);
  4943. CDialog::OnOK();
  4944. }
  4945. //This function disables RRAS on the server(basically what cliking Disable RRAs on menu does)
  4946. HRESULT DisableRRAS(TCHAR * szMachineName)
  4947. {
  4948. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  4949. DWORD dwErr = ERROR_SUCCESS;
  4950. RtrConfigData wizData;
  4951. NewRtrWizData rtrWizData;
  4952. IRouterInfo * pRouterInfo = NULL;
  4953. TCHAR szLocalName[MAX_COMPUTERNAME_LENGTH + 1] ={0};
  4954. DWORD dw = MAX_COMPUTERNAME_LENGTH;
  4955. GUID guidConfig = GUID_RouterNull;
  4956. IRouterProtocolConfig * spRouterConfig = NULL;
  4957. IRtrMgrProtocolInfo * spRmProt = NULL;
  4958. RtrMgrProtocolCB RmProtCB;
  4959. CWaitCursor wait;
  4960. HRESULT hr = hrOK;
  4961. RouterVersionInfo RVI;
  4962. if(!szMachineName || szMachineName[0] == 0){
  4963. //Get local Machine Name
  4964. GetComputerName ( szLocalName, &dw );
  4965. szMachineName = szLocalName;
  4966. }
  4967. //Create the RouterInfo
  4968. hr = CreateRouterInfo(&pRouterInfo, NULL, szMachineName);
  4969. Assert(pRouterInfo != NULL);
  4970. // Stop the router service
  4971. hr = StopRouterService((LPCTSTR) szMachineName);
  4972. if (!FHrSucceeded(hr))
  4973. {
  4974. AddHighLevelErrorStringId(IDS_ERR_COULD_NOT_REMOVE_ROUTER);
  4975. CORg(hr);
  4976. }
  4977. //
  4978. //Do some of the SecureRouterInfo functionality here
  4979. //
  4980. CORg(InitiateServerConnection(szMachineName,
  4981. NULL,
  4982. FALSE,
  4983. pRouterInfo));
  4984. CORg(pRouterInfo->Load(T2COLE(szMachineName),
  4985. NULL));
  4986. {
  4987. USES_CONVERSION;
  4988. if(S_OK == pRouterInfo->GetRouterVersionInfo(&RVI) && RVI.dwRouterVersion >= 5)
  4989. {
  4990. hr = RRASDelRouterIdObj(T2W(szMachineName));
  4991. Assert(hr == S_OK);
  4992. }
  4993. }
  4994. // Windows NT Bug : 389469
  4995. // This is hardcoded for NAT (not to change too much).
  4996. // Find the config GUID for NAT, and then remove the protocol.
  4997. hr = LookupRtrMgrProtocol(pRouterInfo,
  4998. PID_IP,
  4999. MS_IP_NAT,
  5000. &spRmProt);
  5001. // If the lookup returns S_FALSE, then it couldn't find the
  5002. // protocol.
  5003. if (FHrOK(hr))
  5004. {
  5005. spRmProt->CopyCB(&RmProtCB);
  5006. CORg( CoCreateProtocolConfig(RmProtCB.guidConfig,
  5007. pRouterInfo,
  5008. PID_IP,
  5009. MS_IP_NAT,
  5010. &spRouterConfig) );
  5011. if (spRouterConfig)
  5012. hr = spRouterConfig->RemoveProtocol(pRouterInfo->GetMachineName(),
  5013. PID_IP,
  5014. MS_IP_NAT,
  5015. NULL,
  5016. 0,
  5017. pRouterInfo,
  5018. 0);
  5019. }
  5020. // Perform any removal/cleanup action
  5021. UninstallGlobalSettings(szMachineName,
  5022. pRouterInfo,
  5023. RVI.dwRouterVersion == 4,
  5024. TRUE);
  5025. // Remove the router from the domain
  5026. if (pRouterInfo->GetRouterType() != ROUTER_TYPE_LAN)
  5027. RegisterRouterInDomain(szMachineName, FALSE);
  5028. // Disable the service
  5029. SetRouterServiceStartType((LPCTSTR) szMachineName,
  5030. SERVICE_DISABLED);
  5031. //
  5032. // Bug 519414
  5033. // Since IAS now has a Microsoft policy with the appropriate settings,
  5034. // there is no longer a single default policy. In addition there is
  5035. // no need to update any policy to have the required settings since the
  5036. // Microsoft VPN server policy does the job.
  5037. //
  5038. #if __DEFAULT_POLICY
  5039. //Now update the default policy
  5040. CORg( UpdateDefaultPolicy(szMachineName,
  5041. FALSE,
  5042. FALSE,
  5043. 0
  5044. ) );
  5045. #endif
  5046. Error:
  5047. if (!FHrSucceeded(hr))
  5048. {
  5049. AddSystemErrorMessage(hr);
  5050. }
  5051. return hr;
  5052. }
  5053. /*!--------------------------------------------------------------------------
  5054. InitializeInterfaceListControl
  5055. -
  5056. Author: KennT
  5057. ---------------------------------------------------------------------------*/
  5058. HRESULT InitializeInterfaceListControl(IRouterInfo *pRouter,
  5059. CListCtrl *pListCtrl,
  5060. LPCTSTR pszExcludedIf,
  5061. LPARAM flags,
  5062. NewRtrWizData *pWizData)
  5063. {
  5064. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  5065. HRESULT hr = hrOK;
  5066. LV_COLUMN lvCol; // list view column struct for radius servers
  5067. RECT rect;
  5068. CString stColCaption;
  5069. LV_ITEM lvItem;
  5070. int iPos;
  5071. CString st;
  5072. int nColWidth;
  5073. Assert(pListCtrl);
  5074. ListView_SetExtendedListViewStyle(pListCtrl->GetSafeHwnd(),
  5075. LVS_EX_FULLROWSELECT);
  5076. // Add the columns to the list control
  5077. pListCtrl->GetClientRect(&rect);
  5078. if (!FHrOK(pWizData->HrIsIPInstalled()))
  5079. flags |= IFLIST_FLAGS_NOIP;
  5080. // Determine the width of the columns (we assume three equal width columns)
  5081. if (flags & IFLIST_FLAGS_NOIP)
  5082. nColWidth = rect.right / (IFLISTCOL_COUNT - 1 );
  5083. else
  5084. nColWidth = rect.right / IFLISTCOL_COUNT;
  5085. lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
  5086. lvCol.fmt = LVCFMT_LEFT;
  5087. lvCol.cx = nColWidth;
  5088. for(int index = 0; index < IFLISTCOL_COUNT; index++)
  5089. {
  5090. // If IP is not installed, do not add the column
  5091. if ((index == IFLISTCOL_IPADDRESS) &&
  5092. (flags & IFLIST_FLAGS_NOIP))
  5093. continue;
  5094. stColCaption.LoadString( s_rgIfListColumnHeaders[index] );
  5095. lvCol.pszText = (LPTSTR)((LPCTSTR) stColCaption);
  5096. pListCtrl->InsertColumn(index, &lvCol);
  5097. }
  5098. return hr;
  5099. }
  5100. /*!--------------------------------------------------------------------------
  5101. RefreshInterfaceListControl
  5102. -
  5103. Author: KennT
  5104. ---------------------------------------------------------------------------*/
  5105. HRESULT RefreshInterfaceListControl(IRouterInfo *pRouter,
  5106. CListCtrl *pListCtrl,
  5107. LPCTSTR pszExcludedIf,
  5108. LPARAM flags,
  5109. NewRtrWizData *pWizData)
  5110. {
  5111. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  5112. HRESULT hr = hrOK;
  5113. LV_COLUMN lvCol; // list view column struct for radius servers
  5114. LV_ITEM lvItem;
  5115. int iPos;
  5116. CString st;
  5117. POSITION pos;
  5118. RtrWizInterface * pRtrWizIf;
  5119. Assert(pListCtrl);
  5120. // If a pointer to a blank string was passed in, set the
  5121. // pointer to NULL.
  5122. if (pszExcludedIf && (*pszExcludedIf == 0))
  5123. pszExcludedIf = NULL;
  5124. // Clear the list control
  5125. pListCtrl->DeleteAllItems();
  5126. // This means that we should use the test data, rather
  5127. // than the actual machine data
  5128. {
  5129. lvItem.mask = LVIF_TEXT | LVIF_PARAM;
  5130. lvItem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
  5131. lvItem.state = 0;
  5132. int nCount = 0;
  5133. pos = pWizData->m_ifMap.GetStartPosition();
  5134. while (pos)
  5135. {
  5136. pWizData->m_ifMap.GetNextAssoc(pos, st, pRtrWizIf);
  5137. if (pszExcludedIf &&
  5138. (pRtrWizIf->m_stId.CompareNoCase(pszExcludedIf) == 0))
  5139. continue;
  5140. lvItem.iItem = nCount;
  5141. lvItem.iSubItem = 0;
  5142. lvItem.pszText = (LPTSTR)(LPCTSTR) pRtrWizIf->m_stName;
  5143. lvItem.lParam = NULL; //same functionality as SetItemData()
  5144. iPos = pListCtrl->InsertItem(&lvItem);
  5145. if (iPos != -1)
  5146. {
  5147. pListCtrl->SetItemText(iPos, IFLISTCOL_NAME,
  5148. (LPCTSTR) pRtrWizIf->m_stName);
  5149. pListCtrl->SetItemText(iPos, IFLISTCOL_DESC,
  5150. (LPCTSTR) pRtrWizIf->m_stDesc);
  5151. if (FHrOK(pWizData->HrIsIPInstalled()))
  5152. {
  5153. CString stAddr;
  5154. stAddr = pRtrWizIf->m_stIpAddress;
  5155. if (pRtrWizIf->m_fDhcpObtained)
  5156. stAddr += _T(" (DHCP)");
  5157. pListCtrl->SetItemText(iPos, IFLISTCOL_IPADDRESS,
  5158. (LPCTSTR) stAddr);
  5159. }
  5160. pListCtrl->SetItemData(iPos,
  5161. (LPARAM) (LPCTSTR) pRtrWizIf->m_stId);
  5162. }
  5163. nCount++;
  5164. }
  5165. }
  5166. return hr;
  5167. }
  5168. /*!--------------------------------------------------------------------------
  5169. CallRouterEntryDlg
  5170. -
  5171. Author: KennT
  5172. ---------------------------------------------------------------------------*/
  5173. HRESULT CallRouterEntryDlg(HWND hWnd, NewRtrWizData *pWizData, LPARAM flags)
  5174. {
  5175. HRESULT hr = hrOK;
  5176. HINSTANCE hInstanceRasDlg = NULL;
  5177. PROUTERENTRYDLG pfnRouterEntry = NULL;
  5178. CString stRouter, stPhoneBook;
  5179. BOOL bStatus;
  5180. RASENTRYDLG info;
  5181. SPSZ spsz;
  5182. SPIInterfaceInfo spIf;
  5183. SPIInfoBase spInfoBase;
  5184. LPCTSTR pszServerName = pWizData->m_stServerName;
  5185. // Get the library (we are dynamically linking to the function).
  5186. // ----------------------------------------------------------------
  5187. hInstanceRasDlg = AfxLoadLibrary(_T("rasdlg.dll"));
  5188. if (hInstanceRasDlg == NULL)
  5189. CORg( E_FAIL );
  5190. pfnRouterEntry = (PROUTERENTRYDLG) ::GetProcAddress(hInstanceRasDlg,
  5191. SZROUTERENTRYDLG);
  5192. if (pfnRouterEntry == NULL)
  5193. CORg( E_FAIL );
  5194. // First create the phone book entry.
  5195. ZeroMemory( &info, sizeof(info) );
  5196. info.dwSize = sizeof(info);
  5197. info.hwndOwner = hWnd;
  5198. info.dwFlags |= RASEDFLAG_NewEntry;
  5199. if(flags == RASEDFLAG_NAT)
  5200. info.dwFlags |= RASEDFLAG_NAT;
  5201. stRouter = pszServerName;
  5202. IfAdminNodeHandler::GetPhoneBookPath(stRouter, &stPhoneBook);
  5203. if (stRouter.GetLength() == 0)
  5204. {
  5205. stRouter = CString(_T("\\\\")) + GetLocalMachineName();
  5206. }
  5207. bStatus = pfnRouterEntry((LPTSTR)(LPCTSTR)stRouter,
  5208. (LPTSTR)(LPCTSTR)stPhoneBook,
  5209. NULL,
  5210. &info);
  5211. Trace2("RouterEntryDlg=%f,e=%d\n", bStatus, info.dwError);
  5212. if (!bStatus)
  5213. {
  5214. if (info.dwError != NO_ERROR)
  5215. {
  5216. AddHighLevelErrorStringId(IDS_ERR_UNABLETOCONFIGPBK);
  5217. CWRg( info.dwError );
  5218. }
  5219. //$ ASSUMPTION
  5220. // If the dwError field has not been filled, we assume that
  5221. // the user cancelled out of the wizard.
  5222. CWRg( ERROR_CANCELLED );
  5223. }
  5224. // Ok, at this point we have an interface
  5225. // We need to add the IP/IPX routermangers to the interface
  5226. // Create a dummy InterfaceInfo
  5227. CORg( CreateInterfaceInfo(&spIf,
  5228. info.szEntry,
  5229. ROUTER_IF_TYPE_FULL_ROUTER) );
  5230. // This call to get the name doesn't matter (for now). The
  5231. // reason is that DD interfaces do not return GUIDs, but this
  5232. // will work when they do return a GUID.
  5233. // ----------------------------------------------------------------
  5234. hr = InterfaceInfo::FindInterfaceTitle(pszServerName,
  5235. info.szEntry,
  5236. &spsz);
  5237. if (!FHrOK(hr))
  5238. {
  5239. spsz.Free();
  5240. spsz = StrDup(info.szEntry);
  5241. }
  5242. CORg( spIf->SetTitle(spsz) );
  5243. CORg( spIf->SetMachineName(pszServerName) );
  5244. // Load an infobase for use by the routines
  5245. CORg( CreateInfoBase(&spInfoBase) );
  5246. if (info.reserved2 & RASNP_Ip)
  5247. {
  5248. AddIpPerInterfaceBlocks(spIf, spInfoBase);
  5249. // ok, setup the public interface
  5250. Assert(pWizData->m_stPublicInterfaceId.IsEmpty());
  5251. pWizData->m_stPublicInterfaceId = spIf->GetTitle();
  5252. HANDLE hMachine = INVALID_HANDLE_VALUE;
  5253. HKEY hkeyMachine = NULL;
  5254. RouterVersionInfo routerversion;
  5255. InfoBlock * pBlock;
  5256. DWORD dwErr = ::MprConfigServerConnect((LPWSTR)pszServerName, &hMachine);
  5257. if(dwErr != NOERROR || hMachine == INVALID_HANDLE_VALUE)
  5258. goto Error;
  5259. if (ERROR_SUCCESS == ConnectRegistry(pszServerName, &hkeyMachine))
  5260. QueryRouterVersionInfo(hkeyMachine, &routerversion);
  5261. else
  5262. routerversion.dwRouterVersion = 5;
  5263. if (hkeyMachine)
  5264. DisconnectRegistry(hkeyMachine);
  5265. // Get the IP_ROUTE_INFO block from the interface
  5266. spInfoBase->GetBlock(IP_ROUTE_INFO, &pBlock, 0);
  5267. //
  5268. //Add static routes here if any
  5269. //
  5270. SROUTEINFOLIST * pSRouteList = (SROUTEINFOLIST * )info.reserved;
  5271. MIB_IPFORWARDROW * pForwardRow = NULL;
  5272. MIB_IPFORWARDROW * pRoute = NULL;
  5273. DWORD dwItemCount = 0;
  5274. while ( pSRouteList )
  5275. {
  5276. LPVOID pTemp;
  5277. dwItemCount ++;
  5278. if ( pForwardRow == NULL )
  5279. {
  5280. pTemp = LocalAlloc(LPTR, sizeof(MIB_IPFORWARDROW));
  5281. }
  5282. else
  5283. {
  5284. pTemp = LocalReAlloc(pForwardRow ,
  5285. sizeof(MIB_IPFORWARDROW) * dwItemCount,
  5286. LMEM_ZEROINIT|LMEM_MOVEABLE);
  5287. }
  5288. if(pTemp)
  5289. {
  5290. pForwardRow = (MIB_IPFORWARDROW *)pTemp;
  5291. pRoute = pForwardRow + ( dwItemCount - 1 );
  5292. pRoute->dwForwardDest = INET_ADDR(pSRouteList->RouteInfo.pszDestIP);
  5293. pRoute->dwForwardMask = INET_ADDR(pSRouteList->RouteInfo.pszNetworkMask);
  5294. pRoute->dwForwardMetric1 = _ttol(pSRouteList->RouteInfo.pszMetric );
  5295. pRoute->dwForwardMetric5 = RTM_VIEW_MASK_UCAST | RTM_VIEW_MASK_MCAST;
  5296. pRoute->dwForwardNextHop = 0;
  5297. if (routerversion.dwRouterVersion < 5)
  5298. pRoute->dwForwardProto = PROTO_IP_LOCAL;
  5299. else
  5300. pRoute->dwForwardProto = PROTO_IP_NT_STATIC;
  5301. }
  5302. else
  5303. {
  5304. dwItemCount--;
  5305. }
  5306. //Free all the entry items
  5307. pTemp = pSRouteList->pNext;
  5308. GlobalFree(pSRouteList->RouteInfo.pszDestIP);
  5309. GlobalFree(pSRouteList->RouteInfo.pszNetworkMask);
  5310. GlobalFree(pSRouteList->RouteInfo.pszMetric);
  5311. GlobalFree(pSRouteList);
  5312. pSRouteList = (SROUTEINFOLIST *)pTemp;
  5313. }
  5314. if ( dwItemCount )
  5315. {
  5316. CORg( AddStaticRoute(pForwardRow, spInfoBase, pBlock, dwItemCount) );
  5317. LocalFree(pForwardRow);
  5318. }
  5319. // Save this back to the IP RmIf
  5320. RouterEntrySaveInfoBase(pszServerName,
  5321. spIf->GetId(),
  5322. spInfoBase,
  5323. PID_IP);
  5324. // disconnect it
  5325. if(hMachine != INVALID_HANDLE_VALUE)
  5326. {
  5327. ::MprAdminServerDisconnect(hMachine);
  5328. }
  5329. }
  5330. if (info.reserved2 & RASNP_Ipx)
  5331. {
  5332. // Remove anything that was loaded previously
  5333. spInfoBase->Unload();
  5334. AddIpxPerInterfaceBlocks(spIf, spInfoBase);
  5335. // Save this back to the IPX RmIf
  5336. RouterEntrySaveInfoBase(pszServerName,
  5337. spIf->GetId(),
  5338. spInfoBase,
  5339. PID_IPX);
  5340. }
  5341. Error:
  5342. if (!FHrSucceeded(hr) && (hr != HRESULT_FROM_WIN32(ERROR_CANCELLED)))
  5343. {
  5344. TCHAR szErr[2048] = _T(" ");
  5345. if (hr != E_FAIL) // E_FAIL doesn't give user any information
  5346. {
  5347. FormatRasError(hr, szErr, DimensionOf(szErr));
  5348. }
  5349. AddLowLevelErrorString(szErr);
  5350. // If there is no high level error string, add a
  5351. // generic error string. This will be used if no other
  5352. // high level error string is set.
  5353. SetDefaultHighLevelErrorStringId(IDS_ERR_GENERIC_ERROR);
  5354. DisplayTFSErrorMessage(NULL);
  5355. }
  5356. if (hInstanceRasDlg)
  5357. ::FreeLibrary(hInstanceRasDlg);
  5358. return hr;
  5359. }
  5360. /*!--------------------------------------------------------------------------
  5361. RouterEntrySaveInfoBase
  5362. -
  5363. Author: KennT
  5364. ---------------------------------------------------------------------------*/
  5365. HRESULT RouterEntrySaveInfoBase(LPCTSTR pszServerName,
  5366. LPCTSTR pszIfName,
  5367. IInfoBase *pInfoBase,
  5368. DWORD dwTransportId)
  5369. {
  5370. HRESULT hr = hrOK;
  5371. MPR_SERVER_HANDLE hMprServer = NULL;
  5372. HANDLE hInterface = NULL;
  5373. DWORD dwErr = ERROR_SUCCESS;
  5374. MPR_INTERFACE_0 mprInterface;
  5375. LPBYTE pInfoData = NULL;
  5376. DWORD dwInfoSize = 0;
  5377. MPR_CONFIG_HANDLE hMprConfig = NULL;
  5378. HANDLE hIfTransport = NULL;
  5379. Assert(pInfoBase);
  5380. // Convert the infobase into a byte array
  5381. // ----------------------------------------------------------------
  5382. CWRg( pInfoBase->WriteTo(&pInfoData, &dwInfoSize) );
  5383. // Connect to the server
  5384. // ----------------------------------------------------------------
  5385. dwErr = MprAdminServerConnect((LPWSTR) pszServerName, &hMprServer);
  5386. if (dwErr == ERROR_SUCCESS)
  5387. {
  5388. // Get a handle to the interface
  5389. // ------------------------------------------------------------
  5390. dwErr = MprAdminInterfaceGetHandle(hMprServer,
  5391. (LPWSTR) pszIfName,
  5392. &hInterface,
  5393. FALSE);
  5394. if (dwErr != ERROR_SUCCESS)
  5395. {
  5396. // We couldn't get a handle the interface, so let's try
  5397. // to create the interface.
  5398. // --------------------------------------------------------
  5399. ZeroMemory(&mprInterface, sizeof(mprInterface));
  5400. StrCpyWFromT(mprInterface.wszInterfaceName, pszIfName);
  5401. mprInterface.dwIfType = ROUTER_IF_TYPE_FULL_ROUTER;
  5402. mprInterface.fEnabled = TRUE;
  5403. CWRg( MprAdminInterfaceCreate(hMprServer,
  5404. 0,
  5405. (LPBYTE) &mprInterface,
  5406. &hInterface) );
  5407. }
  5408. // Try to write the info out
  5409. // ------------------------------------------------------------
  5410. dwErr = MprAdminInterfaceTransportSetInfo(hMprServer,
  5411. hInterface,
  5412. dwTransportId,
  5413. pInfoData,
  5414. dwInfoSize);
  5415. if (dwErr != NO_ERROR && dwErr != RPC_S_SERVER_UNAVAILABLE)
  5416. {
  5417. // Attempt to add the router-manager on the interface
  5418. // --------------------------------------------------------
  5419. dwErr = ::MprAdminInterfaceTransportAdd(hMprServer,
  5420. hInterface,
  5421. dwTransportId,
  5422. pInfoData,
  5423. dwInfoSize);
  5424. CWRg( dwErr );
  5425. }
  5426. }
  5427. // Ok, now that we've written the info out to the running router,
  5428. // let's try to write the info to the store.
  5429. // ----------------------------------------------------------------
  5430. dwErr = MprConfigServerConnect((LPWSTR) pszServerName, &hMprConfig);
  5431. if (dwErr == ERROR_SUCCESS)
  5432. {
  5433. dwErr = MprConfigInterfaceGetHandle(hMprConfig,
  5434. (LPWSTR) pszIfName,
  5435. &hInterface);
  5436. if (dwErr != ERROR_SUCCESS)
  5437. {
  5438. // We couldn't get a handle the interface, so let's try
  5439. // to create the interface.
  5440. // --------------------------------------------------------
  5441. ZeroMemory(&mprInterface, sizeof(mprInterface));
  5442. StrCpyWFromT(mprInterface.wszInterfaceName, pszIfName);
  5443. mprInterface.dwIfType = ROUTER_IF_TYPE_FULL_ROUTER;
  5444. mprInterface.fEnabled = TRUE;
  5445. CWRg( MprConfigInterfaceCreate(hMprConfig,
  5446. 0,
  5447. (LPBYTE) &mprInterface,
  5448. &hInterface) );
  5449. }
  5450. dwErr = MprConfigInterfaceTransportGetHandle(hMprConfig,
  5451. hInterface,
  5452. dwTransportId,
  5453. &hIfTransport);
  5454. if (dwErr != ERROR_SUCCESS)
  5455. {
  5456. CWRg( MprConfigInterfaceTransportAdd(hMprConfig,
  5457. hInterface,
  5458. dwTransportId,
  5459. NULL,
  5460. pInfoData,
  5461. dwInfoSize,
  5462. &hIfTransport) );
  5463. }
  5464. else
  5465. {
  5466. CWRg( MprConfigInterfaceTransportSetInfo(hMprConfig,
  5467. hInterface,
  5468. hIfTransport,
  5469. pInfoData,
  5470. dwInfoSize) );
  5471. }
  5472. }
  5473. Error:
  5474. if (hMprConfig)
  5475. MprConfigServerDisconnect(hMprConfig);
  5476. if (hMprServer)
  5477. MprAdminServerDisconnect(hMprServer);
  5478. if (pInfoData)
  5479. CoTaskMemFree(pInfoData);
  5480. return hr;
  5481. }
  5482. /*!--------------------------------------------------------------------------
  5483. RouterEntryLoadInfoBase
  5484. This will load the RtrMgrInterfaceInfo infobase.
  5485. Author: KennT
  5486. ---------------------------------------------------------------------------*/
  5487. HRESULT RouterEntryLoadInfoBase(LPCTSTR pszServerName,
  5488. LPCTSTR pszIfName,
  5489. DWORD dwTransportId,
  5490. IInfoBase *pInfoBase)
  5491. {
  5492. HRESULT hr = hrOK;
  5493. MPR_SERVER_HANDLE hMprServer = NULL;
  5494. HANDLE hInterface = NULL;
  5495. DWORD dwErr = ERROR_SUCCESS;
  5496. MPR_INTERFACE_0 mprInterface;
  5497. LPBYTE pByte = NULL;
  5498. DWORD dwSize = 0;
  5499. MPR_CONFIG_HANDLE hMprConfig = NULL;
  5500. HANDLE hIfTransport = NULL;
  5501. Assert(pInfoBase);
  5502. // Connect to the server
  5503. // ----------------------------------------------------------------
  5504. dwErr = MprAdminServerConnect((LPWSTR) pszServerName, &hMprServer);
  5505. if (dwErr == ERROR_SUCCESS)
  5506. {
  5507. // Get a handle to the interface
  5508. // ------------------------------------------------------------
  5509. dwErr = MprAdminInterfaceGetHandle(hMprServer,
  5510. (LPWSTR) pszIfName,
  5511. &hInterface,
  5512. FALSE);
  5513. if (dwErr != ERROR_SUCCESS)
  5514. {
  5515. // We couldn't get a handle the interface, so let's try
  5516. // to create the interface.
  5517. // --------------------------------------------------------
  5518. ZeroMemory(&mprInterface, sizeof(mprInterface));
  5519. StrCpyWFromT(mprInterface.wszInterfaceName, pszIfName);
  5520. mprInterface.dwIfType = ROUTER_IF_TYPE_FULL_ROUTER;
  5521. mprInterface.fEnabled = TRUE;
  5522. CWRg( MprAdminInterfaceCreate(hMprServer,
  5523. 0,
  5524. (LPBYTE) &mprInterface,
  5525. &hInterface) );
  5526. }
  5527. // Try to read the info
  5528. // ------------------------------------------------------------
  5529. dwErr = MprAdminInterfaceTransportGetInfo(hMprServer,
  5530. hInterface,
  5531. dwTransportId,
  5532. &pByte,
  5533. &dwSize);
  5534. if (dwErr == ERROR_SUCCESS)
  5535. pInfoBase->LoadFrom(dwSize, pByte);
  5536. if (pByte)
  5537. MprAdminBufferFree(pByte);
  5538. pByte = NULL;
  5539. dwSize = 0;
  5540. }
  5541. if (dwErr != ERROR_SUCCESS)
  5542. {
  5543. // Ok, we've tried to use the running router but that
  5544. // failed, let's try to read the info from the store.
  5545. // ----------------------------------------------------------------
  5546. dwErr = MprConfigServerConnect((LPWSTR) pszServerName, &hMprConfig);
  5547. if (dwErr == ERROR_SUCCESS)
  5548. {
  5549. dwErr = MprConfigInterfaceGetHandle(hMprConfig,
  5550. (LPWSTR) pszIfName,
  5551. &hInterface);
  5552. if (dwErr != ERROR_SUCCESS)
  5553. {
  5554. // We couldn't get a handle the interface, so let's try
  5555. // to create the interface.
  5556. // --------------------------------------------------------
  5557. ZeroMemory(&mprInterface, sizeof(mprInterface));
  5558. StrCpyWFromT(mprInterface.wszInterfaceName, pszIfName);
  5559. mprInterface.dwIfType = ROUTER_IF_TYPE_FULL_ROUTER;
  5560. mprInterface.fEnabled = TRUE;
  5561. CWRg( MprConfigInterfaceCreate(hMprConfig,
  5562. 0,
  5563. (LPBYTE) &mprInterface,
  5564. &hInterface) );
  5565. }
  5566. CWRg( MprConfigInterfaceTransportGetHandle(hMprConfig,
  5567. hInterface,
  5568. dwTransportId,
  5569. &hIfTransport) );
  5570. CWRg( MprConfigInterfaceTransportGetInfo(hMprConfig,
  5571. hInterface,
  5572. hIfTransport,
  5573. &pByte,
  5574. &dwSize) );
  5575. pInfoBase->LoadFrom(dwSize, pByte);
  5576. if (pByte)
  5577. MprConfigBufferFree(pByte);
  5578. pByte = NULL;
  5579. dwSize = 0;
  5580. }
  5581. }
  5582. CWRg(dwErr);
  5583. Error:
  5584. if (hMprConfig)
  5585. MprConfigServerDisconnect(hMprConfig);
  5586. if (hMprServer)
  5587. MprAdminServerDisconnect(hMprServer);
  5588. return hr;
  5589. }
  5590. /*!--------------------------------------------------------------------------
  5591. LaunchHelpTopic
  5592. -
  5593. Author: KennT
  5594. ---------------------------------------------------------------------------*/
  5595. void LaunchHelpTopic(LPCTSTR pszHelpString)
  5596. {
  5597. TCHAR szBuffer[1024];
  5598. CString st;
  5599. STARTUPINFO si;
  5600. PROCESS_INFORMATION pi;
  5601. if ((pszHelpString == NULL) || (*pszHelpString == 0))
  5602. return;
  5603. ::ZeroMemory(&si, sizeof(STARTUPINFO));
  5604. si.cb = sizeof(STARTUPINFO);
  5605. si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
  5606. si.wShowWindow = SW_SHOW;
  5607. ::ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
  5608. ExpandEnvironmentStrings(pszHelpString,
  5609. szBuffer,
  5610. DimensionOf(szBuffer));
  5611. st.Format(_T("hh.exe %s"), pszHelpString);
  5612. ::CreateProcess(NULL, // ptr to name of executable
  5613. (LPTSTR) (LPCTSTR) st, // pointer to command line string
  5614. NULL, // process security attributes
  5615. NULL, // thread security attributes
  5616. FALSE, // handle inheritance flag
  5617. CREATE_NEW_CONSOLE,// creation flags
  5618. NULL, // ptr to new environment block
  5619. NULL, // ptr to current directory name
  5620. &si,
  5621. &pi);
  5622. ::CloseHandle(pi.hProcess);
  5623. ::CloseHandle(pi.hThread);
  5624. }
  5625. #define REGKEY_NETBT_PARAM_W L"System\\CurrentControlSet\\Services\\NetBT\\Parameters\\Interfaces\\Tcpip_%s"
  5626. #define REGVAL_DISABLE_NETBT 2
  5627. #define TCPIP_PARAMETERS_KEY L"System\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%s"
  5628. #define REGISTRATION_ENABLED L"RegistrationEnabled"
  5629. #define REGVAL_NETBIOSOPTIONS_W L"NetbiosOptions"
  5630. HRESULT DisableDDNSandNetBtOnInterface ( IRouterInfo *pRouter, LPCTSTR pszIfName, RtrWizInterface* pIf)
  5631. {
  5632. HRESULT hr = hrOK;
  5633. DWORD dwErr = ERROR_SUCCESS;
  5634. RegKey regkey;
  5635. DWORD dw = 0;
  5636. WCHAR szKey[1024] = {0};
  5637. //SPIRouter spRouter = pRouter;
  5638. wsprintf ( szKey, TCPIP_PARAMETERS_KEY, pszIfName);
  5639. //Disable Dynamic DNS
  5640. dwErr = regkey.Open( HKEY_LOCAL_MACHINE,
  5641. szKey,
  5642. KEY_ALL_ACCESS,
  5643. pRouter->GetMachineName()
  5644. );
  5645. if ( ERROR_SUCCESS != dwErr )
  5646. goto Error;
  5647. dwErr = regkey.SetValue ( REGISTRATION_ENABLED, dw );
  5648. if ( ERROR_SUCCESS != dwErr )
  5649. goto Error;
  5650. dwErr = regkey.Close();
  5651. if ( ERROR_SUCCESS != dwErr )
  5652. goto Error;
  5653. //Disable netbt on this interface
  5654. wsprintf ( szKey, REGKEY_NETBT_PARAM_W, pszIfName );
  5655. dwErr = regkey.Open ( HKEY_LOCAL_MACHINE,
  5656. szKey,
  5657. KEY_ALL_ACCESS,
  5658. pRouter->GetMachineName()
  5659. );
  5660. if ( ERROR_SUCCESS != dwErr )
  5661. goto Error;
  5662. dw = REGVAL_DISABLE_NETBT;
  5663. dwErr = regkey.SetValue ( REGVAL_NETBIOSOPTIONS_W, dw );
  5664. if ( ERROR_SUCCESS != dwErr )
  5665. goto Error;
  5666. CWRg(dwErr);
  5667. Error:
  5668. regkey.Close();
  5669. return hr;
  5670. }
  5671. /*!--------------------------------------------------------------------------
  5672. AddVPNFiltersToInterface
  5673. This will the PPTP and L2TP filters to the public interface.
  5674. This code will OVERWRITE any filters currently in the filter list.
  5675. (for PPTP)
  5676. input/output IP protocol ID 47
  5677. input/output TCP source port 1723
  5678. input/output TCP destination port 1723
  5679. (for L2TP)
  5680. input/output UDP port 500 (for IPSEC)
  5681. input/output UDP port 1701
  5682. Author: KennT
  5683. ---------------------------------------------------------------------------*/
  5684. // Look at the code below. After copying the filter over, we will
  5685. // convert the source/dest port fields from host to network order!!
  5686. static const FILTER_INFO s_rgVpnInputFilters[] =
  5687. {
  5688. // GRE PPTP filter (protocol ID 47)
  5689. { 0, 0, 0, 0, 47, 0, 0, 0 },
  5690. // PPTP filter (source port 1723), TCP established (0x40)
  5691. { 0, 0, 0, 0, FILTER_PROTO_TCP, 0x40, 1723, 0 },
  5692. // PPTP filter (dest port 1723)
  5693. { 0, 0, 0, 0, FILTER_PROTO_TCP, 0, 0, 1723 },
  5694. // IKE filter (dest port = 500)
  5695. { 0, 0, 0, 0, FILTER_PROTO_UDP, 0, 0, 500 },
  5696. // L2TP filter (dest port = 1701)
  5697. { 0, 0, 0, 0, FILTER_PROTO_UDP, 0, 0, 1701 },
  5698. // IKE NAT-T filter (dest port = 4500)
  5699. { 0, 0, 0, 0, FILTER_PROTO_UDP, 0, 0, 4500 }
  5700. };
  5701. static const FILTER_INFO s_rgVpnOutputFilters[] =
  5702. {
  5703. // GRE PPTP filter (protocol ID 47)
  5704. { 0, 0, 0, 0, 47, 0, 0, 0 },
  5705. // PPTP filter (source port 1723)
  5706. { 0, 0, 0, 0, FILTER_PROTO_TCP, 0, 1723, 0 },
  5707. // PPTP filter (dest port 1723)
  5708. { 0, 0, 0, 0, FILTER_PROTO_TCP, 0, 0, 1723 },
  5709. // IKE filter (source port = 500)
  5710. { 0, 0, 0, 0, FILTER_PROTO_UDP, 0, 500, 0 },
  5711. // L2TP filter (source port = 1701
  5712. { 0, 0, 0, 0, FILTER_PROTO_UDP, 0, 1701, 0 },
  5713. // IKE NAT-T filter (source port = 4500)
  5714. { 0, 0, 0, 0, FILTER_PROTO_UDP, 0, 4500, 0 }
  5715. };
  5716. HRESULT AddVPNFiltersToInterface(IRouterInfo *pRouter, LPCTSTR pszIfName, RtrWizInterface* pIf)
  5717. {
  5718. HRESULT hr = hrOK;
  5719. SPIInfoBase spInfoBase;
  5720. DWORD dwSize = 0;
  5721. DWORD cFilters = 0;
  5722. DWORD dwIpAddress = 0;
  5723. LPBYTE pData = NULL;
  5724. FILTER_DESCRIPTOR * pIpfDescriptor = NULL;
  5725. CString tempAddrList;
  5726. CString singleAddr;
  5727. FILTER_INFO *pIpfInfo = NULL;
  5728. CDWordArray arrIpAddr;
  5729. int i, j;
  5730. USES_CONVERSION;
  5731. CORg( CreateInfoBase( &spInfoBase ) );
  5732. // First, get the proper infobase (the RmIf)
  5733. // ----------------------------------------------------------------
  5734. CORg( RouterEntryLoadInfoBase(pRouter->GetMachineName(),
  5735. pszIfName,
  5736. PID_IP,
  5737. spInfoBase) );
  5738. // collect all the ip addresses on the interface
  5739. tempAddrList = pIf->m_stIpAddress;
  5740. while (!tempAddrList.IsEmpty())
  5741. {
  5742. i = tempAddrList.Find(_T(','));
  5743. if ( i != -1 )
  5744. {
  5745. singleAddr = tempAddrList.Left(i);
  5746. tempAddrList = tempAddrList.Mid(i + 1);
  5747. }
  5748. else
  5749. {
  5750. singleAddr = tempAddrList;
  5751. tempAddrList.Empty();
  5752. }
  5753. dwIpAddress = inet_addr(T2A((LPCTSTR)singleAddr));
  5754. if (INADDR_NONE != dwIpAddress) // successful
  5755. arrIpAddr.Add(dwIpAddress);
  5756. }
  5757. // Setup the data structure for input filters
  5758. // ----------------------------------------------------------------
  5759. // Calculate the size needed
  5760. // ----------------------------------------------------------------
  5761. cFilters = DimensionOf(s_rgVpnInputFilters);
  5762. // cFilters-1 because FILTER_DESCRIPTOR has one FILTER_INFO object
  5763. // ----------------------------------------------------------------
  5764. dwSize = sizeof(FILTER_DESCRIPTOR) +
  5765. (cFilters * arrIpAddr.GetSize() - 1) * sizeof(FILTER_INFO);
  5766. pData = new BYTE[dwSize];
  5767. ::ZeroMemory(pData, dwSize);
  5768. // Setup the filter descriptor
  5769. // ----------------------------------------------------------------
  5770. pIpfDescriptor = (FILTER_DESCRIPTOR *) pData;
  5771. pIpfDescriptor->faDefaultAction = DROP;
  5772. pIpfDescriptor->dwNumFilters = cFilters * arrIpAddr.GetSize();
  5773. pIpfDescriptor->dwVersion = IP_FILTER_DRIVER_VERSION_1;
  5774. // Add the various filters to the list
  5775. // input filters
  5776. pIpfInfo = (FILTER_INFO *) pIpfDescriptor->fiFilter;
  5777. // for each ip address on the interface
  5778. for ( j = 0; j < arrIpAddr.GetSize(); j++)
  5779. {
  5780. dwIpAddress = arrIpAddr.GetAt(j);
  5781. for (i=0; i<cFilters; i++, pIpfInfo++)
  5782. {
  5783. *pIpfInfo = s_rgVpnInputFilters[i];
  5784. // Now we convert the appropriate fields from host to
  5785. // network order.
  5786. pIpfInfo->wSrcPort = htons(pIpfInfo->wSrcPort);
  5787. pIpfInfo->wDstPort = htons(pIpfInfo->wDstPort);
  5788. // change dest address and mask
  5789. pIpfInfo->dwDstAddr = dwIpAddress;
  5790. pIpfInfo->dwDstMask = 0xffffffff;
  5791. }
  5792. // inet_addr
  5793. }
  5794. // This will overwrite any of the current filters in the
  5795. // filter list.
  5796. // ----------------------------------------------------------------
  5797. CORg( spInfoBase->AddBlock(IP_IN_FILTER_INFO, dwSize, pData, 1, TRUE) );
  5798. delete [] pData;
  5799. // output filters
  5800. // ----------------------------------------------------------------
  5801. // Setup the data structure for output filters
  5802. // ----------------------------------------------------------------
  5803. // Calculate the size needed
  5804. // ----------------------------------------------------------------
  5805. cFilters = DimensionOf(s_rgVpnOutputFilters);
  5806. // cFilters-1 because FILTER_DESCRIPTOR has one FILTER_INFO object
  5807. // ----------------------------------------------------------------
  5808. dwSize = sizeof(FILTER_DESCRIPTOR) +
  5809. (cFilters * arrIpAddr.GetSize() - 1) * sizeof(FILTER_INFO);
  5810. pData = new BYTE[dwSize];
  5811. ::ZeroMemory(pData, dwSize);
  5812. // Setup the filter descriptor
  5813. // ----------------------------------------------------------------
  5814. pIpfDescriptor = (FILTER_DESCRIPTOR *) pData;
  5815. pIpfDescriptor->faDefaultAction = DROP;
  5816. pIpfDescriptor->dwNumFilters = cFilters * arrIpAddr.GetSize();
  5817. pIpfDescriptor->dwVersion = IP_FILTER_DRIVER_VERSION_1;
  5818. // Add the various filters to the list
  5819. // input filters
  5820. pIpfInfo = (FILTER_INFO *) pIpfDescriptor->fiFilter;
  5821. // for each ip address on the interface
  5822. for ( j = 0; j < arrIpAddr.GetSize(); j++)
  5823. {
  5824. dwIpAddress = arrIpAddr.GetAt(j);
  5825. for (i=0; i<cFilters; i++, pIpfInfo++)
  5826. {
  5827. *pIpfInfo = s_rgVpnOutputFilters[i];
  5828. // Now we convert the appropriate fields from host to
  5829. // network order.
  5830. pIpfInfo->wSrcPort = htons(pIpfInfo->wSrcPort);
  5831. pIpfInfo->wDstPort = htons(pIpfInfo->wDstPort);
  5832. // change source address and mask
  5833. pIpfInfo->dwSrcAddr = dwIpAddress;
  5834. pIpfInfo->dwSrcMask = 0xffffffff;
  5835. }
  5836. } // loop for each ip address on the interface
  5837. // This will overwrite any of the current filters in the
  5838. // filter list.
  5839. // ----------------------------------------------------------------
  5840. CORg( spInfoBase->AddBlock(IP_OUT_FILTER_INFO, dwSize, pData, 1, TRUE) );
  5841. // Save the infobase back
  5842. // ----------------------------------------------------------------
  5843. CORg( RouterEntrySaveInfoBase(pRouter->GetMachineName(),
  5844. pszIfName,
  5845. spInfoBase,
  5846. PID_IP) );
  5847. Error:
  5848. delete [] pData;
  5849. return hr;
  5850. }
  5851. HRESULT WINAPI SetupWithCYS (DWORD dwType, PVOID * pOutData)
  5852. {
  5853. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  5854. IRemoteNetworkConfig * spNetwork;
  5855. IRouterInfo * spRouterInfo;
  5856. COSERVERINFO csi;
  5857. COAUTHINFO cai;
  5858. COAUTHIDENTITY caid;
  5859. IUnknown * punk = NULL;
  5860. CNewRtrWiz * pRtrWiz = NULL;
  5861. HRESULT hr = hrOK;
  5862. TCHAR szMachineName[MAX_COMPUTERNAME_LENGTH + 1] ={0};
  5863. CString strRtrWizTitle;
  5864. DWORD dw = MAX_COMPUTERNAME_LENGTH;
  5865. NewRtrWizData * pRtrWizData = NULL;
  5866. if ( MPRSNAP_CYS_EXPRESS_NAT != dwType && MPRSNAP_CYS_EXPRESS_NONE != dwType )
  5867. {
  5868. hr = HResultFromWin32(ERROR_INVALID_PARAMETER);
  5869. goto Error;
  5870. }
  5871. hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
  5872. if (FAILED(hr) && (RPC_E_CHANGED_MODE != hr))
  5873. {
  5874. return hr;
  5875. }
  5876. //Get Machine Name
  5877. GetComputerName ( szMachineName, &dw );
  5878. //Create the RouterInfo
  5879. hr = CreateRouterInfo(&spRouterInfo, NULL, szMachineName);
  5880. Assert(spRouterInfo != NULL);
  5881. ZeroMemory(&csi, sizeof(csi));
  5882. ZeroMemory(&cai, sizeof(cai));
  5883. ZeroMemory(&caid, sizeof(caid));
  5884. csi.pAuthInfo = &cai;
  5885. cai.pAuthIdentityData = &caid;
  5886. hr = CoCreateRouterConfig(szMachineName,
  5887. spRouterInfo,
  5888. &csi,
  5889. IID_IRemoteNetworkConfig,
  5890. &punk);
  5891. if (FHrOK(hr))
  5892. {
  5893. spNetwork = (IRemoteNetworkConfig *) punk;
  5894. punk = NULL;
  5895. // Upgrade the configuration (ensure that the registry keys
  5896. // are populated correctly).
  5897. // ------------------------------------------------------------
  5898. spNetwork->UpgradeRouterConfig();
  5899. }
  5900. else
  5901. {
  5902. goto Error;
  5903. }
  5904. //
  5905. //Do some of the SecureRouterInfo functionality here
  5906. //
  5907. hr = InitiateServerConnection(szMachineName,
  5908. NULL,
  5909. FALSE,
  5910. spRouterInfo);
  5911. if (!FHrOK(hr))
  5912. {
  5913. // though this case when user chooses cancel on user/password dlg,
  5914. // this is considered as FAIL to connect
  5915. if (hr == S_FALSE)
  5916. hr = HResultFromWin32(ERROR_CANCELLED);
  5917. goto Error;
  5918. }
  5919. hr = spRouterInfo->Load(T2COLE(szMachineName),
  5920. NULL);
  5921. if ( hrOK != hr )
  5922. {
  5923. goto Error;
  5924. }
  5925. //If ICS/ICF/IC is enabled, then do not allow RRAS to be configured
  5926. if(IsIcsIcfIcEnabled(spRouterInfo)){
  5927. hr = HResultFromWin32(ERROR_CANCELLED);
  5928. goto Error;
  5929. }
  5930. //Create a new router wizard and show it here
  5931. strRtrWizTitle.LoadString(IDS_MENU_RTRWIZ);
  5932. //Load the watermark and
  5933. //set it in m_spTFSCompData
  5934. InitWatermarkInfo( AfxGetInstanceHandle(),
  5935. &g_wmi,
  5936. IDB_WIZBANNER, // Header ID
  5937. IDB_WIZWATERMARK, // Watermark ID
  5938. NULL, // hPalette
  5939. FALSE); // bStretch
  5940. //
  5941. //we dont have to free handles. MMC does it for us
  5942. //
  5943. pRtrWiz = new CNewRtrWiz(NULL,
  5944. spRouterInfo,
  5945. NULL,
  5946. NULL,
  5947. strRtrWizTitle,
  5948. FALSE,
  5949. MPRSNAP_CYS_EXPRESS_NAT);
  5950. hr = pRtrWiz->Init( spRouterInfo->GetMachineName() );
  5951. if ( hrOK != hr )
  5952. {
  5953. hr = S_FALSE;
  5954. goto Error;
  5955. }
  5956. else
  5957. {
  5958. hr = pRtrWiz->DoModalWizard();
  5959. //
  5960. //now if the error is S_OK then
  5961. //send the interface information back to cys
  5962. //
  5963. if ( hrOK == hr )
  5964. {
  5965. //get the interface id and send it back
  5966. if ( MPRSNAP_CYS_EXPRESS_NAT == dwType )
  5967. {
  5968. pRtrWizData = pRtrWiz->GetWizData();
  5969. //
  5970. //get the private interface id
  5971. //and send it back to CYS
  5972. //$TODO: Find a better way of doing this
  5973. //
  5974. //ppvoid that comes in get's the private interface back if any
  5975. //
  5976. if ( !pRtrWizData->m_stPrivateInterfaceId.IsEmpty() )
  5977. {
  5978. *pOutData = LocalAlloc(LPTR, (pRtrWizData->m_stPrivateInterfaceId.GetLength()+ 1) * sizeof(WCHAR) );
  5979. if ( NULL == *pOutData )
  5980. {
  5981. hr = E_OUTOFMEMORY;
  5982. goto Error;
  5983. }
  5984. lstrcpy ( (LPTSTR)(*pOutData), (LPTSTR)(LPCTSTR)pRtrWizData->m_stPrivateInterfaceId );
  5985. }
  5986. }
  5987. }
  5988. }
  5989. Error:
  5990. if ( spNetwork )
  5991. spNetwork->Release();
  5992. if ( spRouterInfo)
  5993. spRouterInfo->Release();
  5994. if (
  5995. csi.pAuthInfo &&
  5996. csi.pAuthInfo->pAuthIdentityData->Password
  5997. )
  5998. {
  5999. delete csi.pAuthInfo->pAuthIdentityData->Password;
  6000. }
  6001. if (pRtrWiz)
  6002. delete pRtrWiz;
  6003. CoUninitialize();
  6004. return hr;
  6005. }