Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4121 lines
124 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. rtrcfg.cpp
  7. Router configuration property sheet and pages
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "rtrutilp.h"
  12. #include "ipaddr.h"
  13. #include "rtrcfg.h"
  14. #include "ipctrl.h"
  15. #include "atlkenv.h"
  16. #include "cservice.h"
  17. #include "register.h"
  18. #include "helper.h"
  19. #include "rtrutil.h"
  20. #include "iphlpapi.h"
  21. #include "rtrwiz.h"
  22. #include "snaputil.h"
  23. #include "addrpool.h"
  24. extern "C" {
  25. #include "rasman.h"
  26. #include "rasppp.h"
  27. };
  28. #include "ipxrtdef.h"
  29. #define RAS_LOGGING_NONE 0
  30. #define RAS_LOGGING_ERROR 1
  31. #define RAS_LOGGING_WARN 2
  32. #define RAS_LOGGING_INFO 3
  33. const int c_nRadix10 = 10;
  34. typedef DWORD (APIENTRY* PRASRPCCONNECTSERVER)(LPTSTR, HANDLE *);
  35. typedef DWORD (APIENTRY* PRASRPCDISCONNECTSERVER)(HANDLE);
  36. //**********************************************************************
  37. // General router configuration page
  38. //**********************************************************************
  39. BEGIN_MESSAGE_MAP(RtrGenCfgPage, RtrPropertyPage)
  40. //{{AFX_MSG_MAP(RtrGenCfgPage)
  41. ON_BN_CLICKED(IDC_RTR_GEN_CB_SVRASRTR, OnCbSrvAsRtr)
  42. ON_BN_CLICKED(IDC_RTR_GEN_RB_LAN, OnButtonClick)
  43. ON_BN_CLICKED(IDC_RTR_GEN_RB_LANWAN, OnButtonClick)
  44. ON_BN_CLICKED(IDC_RTR_GEN_CB_RAS, OnButtonClick)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /*!--------------------------------------------------------------------------
  48. RtrGenCfgPage::RtrGenCfgPage
  49. -
  50. Author: KennT
  51. ---------------------------------------------------------------------------*/
  52. RtrGenCfgPage::RtrGenCfgPage(UINT nIDTemplate, UINT nIDCaption /* = 0*/)
  53. : RtrPropertyPage(nIDTemplate, nIDCaption)
  54. {
  55. //{{AFX_DATA_INIT(RtrGenCfgPage)
  56. //}}AFX_DATA_INIT
  57. }
  58. /*!--------------------------------------------------------------------------
  59. RtrGenCfgPage::~RtrGenCfgPage
  60. -
  61. Author: KennT
  62. ---------------------------------------------------------------------------*/
  63. RtrGenCfgPage::~RtrGenCfgPage()
  64. {
  65. }
  66. /*!--------------------------------------------------------------------------
  67. RtrGenCfgPage::DoDataExchange
  68. -
  69. Author: KennT
  70. ---------------------------------------------------------------------------*/
  71. void RtrGenCfgPage::DoDataExchange(CDataExchange* pDX)
  72. {
  73. RtrPropertyPage::DoDataExchange(pDX);
  74. //{{AFX_DATA_MAP(RtrGenCfgPage)
  75. //}}AFX_DATA_MAP
  76. }
  77. /*!--------------------------------------------------------------------------
  78. RtrGenCfgPage::Init
  79. -
  80. Author: KennT
  81. ---------------------------------------------------------------------------*/
  82. HRESULT RtrGenCfgPage::Init(RtrCfgSheet * pRtrCfgSheet,
  83. const RouterVersionInfo& routerVersion)
  84. {
  85. Assert (pRtrCfgSheet);
  86. m_pRtrCfgSheet=pRtrCfgSheet;
  87. m_DataGeneral.LoadFromReg(m_pRtrCfgSheet->m_stServerName);
  88. return S_OK;
  89. };
  90. /*!--------------------------------------------------------------------------
  91. RtrGenCfgPage::OnInitDialog
  92. -
  93. Author: KennT
  94. ---------------------------------------------------------------------------*/
  95. BOOL RtrGenCfgPage::OnInitDialog()
  96. {
  97. HRESULT hr= hrOK;
  98. RtrPropertyPage::OnInitDialog();
  99. CheckRadioButton(IDC_RTR_GEN_RB_LAN,IDC_RTR_GEN_RB_LANWAN,
  100. (m_DataGeneral.m_dwRouterType & ROUTER_TYPE_WAN) ? IDC_RTR_GEN_RB_LANWAN : IDC_RTR_GEN_RB_LAN);
  101. CheckDlgButton(IDC_RTR_GEN_CB_SVRASRTR,
  102. (m_DataGeneral.m_dwRouterType & ROUTER_TYPE_LAN) || (m_DataGeneral.m_dwRouterType & ROUTER_TYPE_WAN));
  103. CheckDlgButton(IDC_RTR_GEN_CB_RAS, m_DataGeneral.m_dwRouterType & ROUTER_TYPE_RAS );
  104. EnableRtrCtrls();
  105. SetDirty(FALSE);
  106. if ( !FHrSucceeded(hr) )
  107. Cancel();
  108. return FHrSucceeded(hr) ? TRUE : FALSE;
  109. }
  110. /*!--------------------------------------------------------------------------
  111. RtrGenCfgPage::OnApply
  112. -
  113. Author: KennT
  114. ---------------------------------------------------------------------------*/
  115. BOOL RtrGenCfgPage::OnApply()
  116. {
  117. BOOL fReturn=TRUE;
  118. HRESULT hr = hrOK;
  119. if ( m_pRtrCfgSheet->IsCancel() )
  120. return TRUE;
  121. // Windows NT Bug : 153007
  122. // One of the options MUST be selected
  123. // ----------------------------------------------------------------
  124. if ((m_DataGeneral.m_dwRouterType & (ROUTER_TYPE_LAN | ROUTER_TYPE_WAN | ROUTER_TYPE_RAS)) == 0)
  125. {
  126. AfxMessageBox(IDS_WRN_MUST_SELECT_ROUTER_TYPE);
  127. // Return to this page
  128. GetParent()->PostMessage(PSM_SETCURSEL, 0, (LPARAM) GetSafeHwnd());
  129. return FALSE;
  130. }
  131. // This will save the m_DataGeneral, if needed.
  132. // ----------------------------------------------------------------
  133. hr = m_pRtrCfgSheet->SaveRequiredRestartChanges(GetSafeHwnd());
  134. if (FHrSucceeded(hr))
  135. fReturn = RtrPropertyPage::OnApply();
  136. if ( !FHrSucceeded(hr) )
  137. fReturn = FALSE;
  138. return fReturn;
  139. }
  140. /*!--------------------------------------------------------------------------
  141. RtrGenCfgPage::OnButtonClick
  142. -
  143. Author: KennT
  144. ---------------------------------------------------------------------------*/
  145. void RtrGenCfgPage::OnButtonClick()
  146. {
  147. SaveSettings();
  148. SetDirty(TRUE);
  149. SetModified();
  150. }
  151. /*!--------------------------------------------------------------------------
  152. RtrGenCfgPage::OnCbSrvAsRtr
  153. -
  154. Author: KennT
  155. ---------------------------------------------------------------------------*/
  156. void RtrGenCfgPage::OnCbSrvAsRtr()
  157. {
  158. EnableRtrCtrls();
  159. SaveSettings();
  160. SetDirty(TRUE);
  161. SetModified();
  162. }
  163. /*!--------------------------------------------------------------------------
  164. RtrGenCfgPage::EnableRtrCtrls
  165. -
  166. Author: KennT
  167. ---------------------------------------------------------------------------*/
  168. void RtrGenCfgPage::EnableRtrCtrls()
  169. {
  170. BOOL fEnable=(IsDlgButtonChecked(IDC_RTR_GEN_CB_SVRASRTR)!=0);
  171. GetDlgItem(IDC_RTR_GEN_RB_LAN)->EnableWindow(fEnable);
  172. GetDlgItem(IDC_RTR_GEN_RB_LANWAN)->EnableWindow(fEnable);
  173. }
  174. /*!--------------------------------------------------------------------------
  175. RtrGenCfgPage::SaveSettings
  176. Author: KennT
  177. ---------------------------------------------------------------------------*/
  178. void RtrGenCfgPage::SaveSettings()
  179. {
  180. // Clear the router type of flags
  181. // ----------------------------------------------------------------
  182. m_DataGeneral.m_dwRouterType &= ~(ROUTER_TYPE_LAN | ROUTER_TYPE_WAN | ROUTER_TYPE_RAS);
  183. // Get the actual type
  184. // ----------------------------------------------------------------
  185. if ( IsDlgButtonChecked(IDC_RTR_GEN_CB_SVRASRTR) )
  186. {
  187. if ( IsDlgButtonChecked(IDC_RTR_GEN_RB_LAN) )
  188. m_DataGeneral.m_dwRouterType |= ROUTER_TYPE_LAN;
  189. else
  190. m_DataGeneral.m_dwRouterType |= (ROUTER_TYPE_WAN | ROUTER_TYPE_LAN);
  191. }
  192. if ( IsDlgButtonChecked(IDC_RTR_GEN_CB_RAS) )
  193. {
  194. m_DataGeneral.m_dwRouterType |= ROUTER_TYPE_RAS;
  195. }
  196. }
  197. //**********************************************************************
  198. // Authentication router configuration page
  199. //**********************************************************************
  200. BEGIN_MESSAGE_MAP(RtrAuthCfgPage, RtrPropertyPage)
  201. //{{AFX_MSG_MAP(RtrAuthCfgPage)
  202. ON_BN_CLICKED(IDC_RTR_AUTH_BTN_AUTHCFG, OnConfigureAuthProv)
  203. ON_BN_CLICKED(IDC_RTR_AUTH_BTN_ACCTCFG, OnConfigureAcctProv)
  204. ON_BN_CLICKED(IDC_RTR_AUTH_BTN_SETTINGS, OnAuthSettings)
  205. ON_BN_CLICKED(IDC_AUTH_CHK_CUSTOM_IPSEC_POLICY, OnChangeCustomPolicySettings)
  206. ON_CBN_SELENDOK(IDC_RTR_AUTH_COMBO_AUTHPROV, OnChangeAuthProv)
  207. ON_CBN_SELENDOK(IDC_RTR_AUTH_COMBO_ACCTPROV, OnChangeAcctProv)
  208. ON_EN_CHANGE(IDC_TXT_PRESHARED_KEY, OnChangePreSharedKey)
  209. //}}AFX_MSG_MAP
  210. END_MESSAGE_MAP()
  211. RtrAuthCfgPage::RtrAuthCfgPage(UINT nIDTemplate, UINT nIDCaption /* = 0*/)
  212. : RtrPropertyPage(nIDTemplate, nIDCaption),
  213. m_dwAuthFlags(0)
  214. {
  215. //{{AFX_DATA_INIT(RtrAuthCfgPage)
  216. //}}AFX_DATA_INIT
  217. }
  218. RtrAuthCfgPage::~RtrAuthCfgPage()
  219. {
  220. }
  221. void RtrAuthCfgPage::DoDataExchange(CDataExchange* pDX)
  222. {
  223. RtrPropertyPage::DoDataExchange(pDX);
  224. //{{AFX_DATA_MAP(RtrAuthCfgPage)
  225. DDX_Control(pDX, IDC_RTR_AUTH_COMBO_AUTHPROV, m_authprov);
  226. DDX_Control(pDX, IDC_RTR_AUTH_COMBO_ACCTPROV, m_acctprov);
  227. //}}AFX_DATA_MAP
  228. }
  229. HRESULT RtrAuthCfgPage::Init(RtrCfgSheet * pRtrCfgSheet,
  230. const RouterVersionInfo& routerVersion)
  231. {
  232. Assert (pRtrCfgSheet);
  233. m_pRtrCfgSheet=pRtrCfgSheet;
  234. m_DataAuth.LoadFromReg(m_pRtrCfgSheet->m_stServerName,
  235. routerVersion);
  236. // initialize our settings
  237. // ----------------------------------------------------------------
  238. m_dwAuthFlags = m_DataAuth.m_dwFlags;
  239. m_stActiveAuthProv = m_DataAuth.m_stGuidActiveAuthProv;
  240. m_stActiveAcctProv = m_DataAuth.m_stGuidActiveAcctProv;
  241. m_RouterInfo = routerVersion;
  242. return S_OK;
  243. };
  244. BOOL RtrAuthCfgPage::OnInitDialog()
  245. {
  246. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  247. HRESULT hr= hrOK;
  248. int iRow;
  249. CString st;
  250. RtrPropertyPage::OnInitDialog();
  251. // Add the providers to the listboxes
  252. // ----------------------------------------------------------------
  253. FillProviderListBox(m_authprov, m_DataAuth.m_authProvList,
  254. m_stActiveAuthProv);
  255. // Trigger the changes made to the combo box
  256. // ----------------------------------------------------------------
  257. OnChangeAuthProv();
  258. if ( m_DataAuth.m_authProvList.GetCount() == 0 )
  259. {
  260. m_authprov.InsertString(0, _T("No providers available"));
  261. m_authprov.SetCurSel(0);
  262. m_authprov.EnableWindow(FALSE);
  263. GetDlgItem(IDC_RTR_AUTH_BTN_AUTHCFG)->EnableWindow(FALSE);
  264. }
  265. FillProviderListBox(m_acctprov, m_DataAuth.m_acctProvList,
  266. m_stActiveAcctProv);
  267. // Windows NT bug : 132649, need to add <none> as an option
  268. // ----------------------------------------------------------------
  269. st.LoadString(IDS_ACCOUNTING_PROVIDERS_NONE);
  270. iRow = m_acctprov.InsertString(0, st);
  271. Assert(iRow == 0);
  272. m_acctprov.SetItemData(iRow, 0);
  273. if ( m_acctprov.GetCurSel() == LB_ERR )
  274. m_acctprov.SetCurSel(0);
  275. // Trigger the changes made to the combo box
  276. // ----------------------------------------------------------------
  277. OnChangeAcctProv();
  278. //Check to see if the router version
  279. if ( m_RouterInfo.dwOsBuildNo > RASMAN_PPP_KEY_LAST_WIN2k_VERSION)
  280. {
  281. //If this is > win2k then
  282. //Set the initial state state etc.
  283. //if ( IsRouterServiceRunning(m_pRtrCfgSheet->m_stServerName, NULL) == hrOK )
  284. if ( m_DataAuth.m_fRouterRunning )
  285. {
  286. CheckDlgButton(IDC_AUTH_CHK_CUSTOM_IPSEC_POLICY, m_DataAuth.m_fUseCustomIPSecPolicy);
  287. GetDlgItem(IDC_TXT_PRESHARED_KEY)->SendMessage(EM_LIMITTEXT, DATA_SRV_AUTH_MAX_SHARED_KEY_LEN, 0L);
  288. if ( m_DataAuth.m_fUseCustomIPSecPolicy )
  289. {
  290. //populate the pre-shared key field
  291. GetDlgItem(IDC_TXT_PRESHARED_KEY)->SetWindowText(m_DataAuth.m_szPreSharedKey);
  292. }
  293. else
  294. {
  295. GetDlgItem(IDC_STATIC_PRESHARED_KEY1)->EnableWindow(FALSE);
  296. GetDlgItem(IDC_TXT_PRESHARED_KEY)->EnableWindow(FALSE);
  297. }
  298. }
  299. else
  300. {
  301. GetDlgItem(IDC_AUTH_CHK_CUSTOM_IPSEC_POLICY)->EnableWindow(FALSE);
  302. GetDlgItem(IDC_STATIC_PRESHARED_KEY1)->EnableWindow(FALSE);
  303. GetDlgItem(IDC_TXT_PRESHARED_KEY)->EnableWindow(FALSE);
  304. }
  305. }
  306. else
  307. {
  308. //hide all the related fields
  309. GetDlgItem(IDC_STATIC_PRESHARED_KEY)->ShowWindow(SW_HIDE);
  310. GetDlgItem(IDC_AUTH_CHK_CUSTOM_IPSEC_POLICY)->ShowWindow(SW_HIDE);
  311. GetDlgItem(IDC_STATIC_PRESHARED_KEY1)->ShowWindow(SW_HIDE);
  312. GetDlgItem(IDC_TXT_PRESHARED_KEY)->ShowWindow(SW_HIDE);
  313. }
  314. SetDirty(FALSE);
  315. if ( !FHrSucceeded(hr) )
  316. Cancel();
  317. return FHrSucceeded(hr) ? TRUE : FALSE;
  318. }
  319. /*!--------------------------------------------------------------------------
  320. RtrAuthCfgPage::OnApply
  321. -
  322. Author: KennT
  323. ---------------------------------------------------------------------------*/
  324. BOOL RtrAuthCfgPage::OnApply()
  325. {
  326. BOOL fReturn=TRUE;
  327. HRESULT hr = hrOK;
  328. RegKey regkey;
  329. DWORD dwAuthMask;
  330. if ( m_pRtrCfgSheet->IsCancel() )
  331. return TRUE;
  332. // check to see if user's chosen a new provider without configure it
  333. // authentication
  334. // ----------------------------------------------------------------
  335. if ( m_stActiveAuthProv != m_DataAuth.m_stGuidActiveAuthProv )
  336. {
  337. AuthProviderData * pData = NULL;
  338. // Find if configure has been called
  339. // ----------------------------------------------------------------
  340. pData = m_DataAuth.FindProvData(m_DataAuth.m_authProvList, m_stActiveAuthProv);
  341. // ------------------------------------------------------------
  342. if (pData && !pData->m_stConfigCLSID.IsEmpty() && !pData->m_fConfiguredInThisSession)
  343. {
  344. CString str1, str;
  345. str1.LoadString(IDS_WRN_AUTH_CONFIG_AUTH);
  346. str.Format(str1, pData->m_stTitle);
  347. if ( AfxMessageBox(str, MB_YESNO) == IDYES )
  348. OnConfigureAuthProv();
  349. }
  350. }
  351. // accounting
  352. // Warn the user that they will need to restart the server in
  353. // order to change the accounting provider.
  354. // ----------------------------------------------------------------
  355. if ( m_stActiveAcctProv != m_DataAuth.m_stGuidOriginalAcctProv )
  356. {
  357. AuthProviderData * pData = NULL;
  358. // Find if configure has been called
  359. // ----------------------------------------------------------------
  360. pData = m_DataAuth.FindProvData(m_DataAuth.m_acctProvList, m_stActiveAcctProv);
  361. //
  362. if (pData && !pData->m_stConfigCLSID.IsEmpty() && !pData->m_fConfiguredInThisSession)
  363. {
  364. CString str1, str;
  365. str1.LoadString(IDS_WRN_AUTH_CONFIG_ACCT);
  366. str.Format(str1, pData->m_stTitle);
  367. if ( AfxMessageBox(str, MB_YESNO) == IDYES )
  368. OnConfigureAcctProv();
  369. }
  370. }
  371. // Check to see if one of the "special" provider flags has
  372. // changed. If so, then we bring up a help dialog.
  373. // ----------------------------------------------------------------
  374. // Create a mask of the authorization flags
  375. // Add in IPSec so that it doesn't cause us to bring up the
  376. // dialog unnecessarily.
  377. dwAuthMask = ~((m_DataAuth.m_dwFlags | PPPCFG_RequireIPSEC) & USE_PPPCFG_AUTHFLAGS);
  378. // Check to see if any of the bits were flipped
  379. if (dwAuthMask & (m_dwAuthFlags & USE_PPPCFG_AUTHFLAGS))
  380. {
  381. // Bring up the messsagebox here.
  382. if (AfxMessageBox(IDS_WRN_MORE_STEPS_FOR_AUTHEN, MB_YESNO) == IDYES)
  383. {
  384. HtmlHelpA(NULL, c_sazAuthenticationHelpTopic, HH_DISPLAY_TOPIC, 0);
  385. }
  386. }
  387. // Check to see if user has chosen a custom ipsec policy with no preshared key
  388. if ( m_DataAuth.m_fUseCustomIPSecPolicy )
  389. {
  390. //Get the preshared key
  391. GetDlgItem(IDC_TXT_PRESHARED_KEY)->GetWindowText(m_DataAuth.m_szPreSharedKey, DATA_SRV_AUTH_MAX_SHARED_KEY_LEN-1);
  392. if ( !_tcslen(m_DataAuth.m_szPreSharedKey) )
  393. {
  394. //Show a error message
  395. AfxMessageBox ( IDS_ERR_NO_PRESHARED_KEY, MB_OK);
  396. return FALSE;
  397. }
  398. }
  399. // Windows NT Bug : 292661
  400. // Only do these checks if the router is started, if it's not
  401. // started, then they don't matter.
  402. // ----------------------------------------------------------------
  403. //if (FHrOK(IsRouterServiceRunning(m_pRtrCfgSheet->m_stServerName, NULL)))
  404. if ( m_DataAuth.m_fRouterRunning )
  405. {
  406. /*
  407. // fix 121763
  408. // fix 8155 rajeshp 06/15/1998 RADIUS: Updating of the radius server entries in the snapin requires a restart of remoteaccess.
  409. DWORD dwMajor = 0, dwMinor = 0, dwBuildNo = 0;
  410. HKEY hkeyMachine = NULL;
  411. // Ignore the failure code, what else can we do?
  412. // ------------------------------------------------------------
  413. DWORD dwErr = ConnectRegistry(m_pRtrCfgSheet->m_stServerName, &hkeyMachine);
  414. if (dwErr == ERROR_SUCCESS)
  415. {
  416. dwErr = GetNTVersion(hkeyMachine, &dwMajor, &dwMinor, &dwBuildNo);
  417. DisconnectRegistry(hkeyMachine);
  418. }
  419. DWORD dwVersionCombine = MAKELONG( dwBuildNo, MAKEWORD(dwMinor, dwMajor));
  420. DWORD dwVersionCombineNT50 = MAKELONG ( VER_BUILD_WIN2K, MAKEWORD(VER_MINOR_WIN2K, VER_MAJOR_WIN2K));
  421. // if the version is greater than Win2K release
  422. if(dwVersionCombine > dwVersionCombineNT50)
  423. ; // skip the restart message
  424. else
  425. */
  426. // end if fix 8155
  427. {
  428. // Warn the user that they will need to restart the server in
  429. // order to change the authentication provider.
  430. // ----------------------------------------------------------------
  431. if ( m_stActiveAuthProv != m_DataAuth.m_stGuidActiveAuthProv )
  432. {
  433. if ( AfxMessageBox(IDS_WRN_AUTH_RESTART_NEEDED, MB_OKCANCEL) != IDOK )
  434. return FALSE;
  435. }
  436. // Warn the user that they will need to restart the server in
  437. // order to change the accounting provider.
  438. // ----------------------------------------------------------------
  439. if ( m_stActiveAcctProv != m_DataAuth.m_stGuidOriginalAcctProv )
  440. {
  441. if ( AfxMessageBox(IDS_WRN_ACCT_RESTART_NEEDED, MB_OKCANCEL) != IDOK )
  442. return FALSE;
  443. }
  444. }
  445. }
  446. // Copy the data over to the DataAuth
  447. // ----------------------------------------------------------------
  448. m_DataAuth.m_dwFlags = m_dwAuthFlags;
  449. m_DataAuth.m_stGuidActiveAuthProv = m_stActiveAuthProv;
  450. m_DataAuth.m_stGuidActiveAcctProv = m_stActiveAcctProv;
  451. fReturn = RtrPropertyPage::OnApply();
  452. if ( !FHrSucceeded(hr) )
  453. fReturn = FALSE;
  454. return fReturn;
  455. }
  456. /*!--------------------------------------------------------------------------
  457. RtrAuthCfgPage::FillProviderListBox
  458. Fill in provCtrl with the data provider from provList.
  459. Author: KennT
  460. ---------------------------------------------------------------------------*/
  461. void RtrAuthCfgPage::FillProviderListBox(CComboBox& provCtrl,
  462. AuthProviderList& provList,
  463. const CString& stGuid)
  464. {
  465. POSITION pos;
  466. AuthProviderData * pData;
  467. int cRows = 0;
  468. int iSel = -1;
  469. int iRow;
  470. TCHAR szAcctGuid[128];
  471. TCHAR szAuthGuid[128];
  472. StringFromGUID2(GUID_AUTHPROV_RADIUS, szAuthGuid, DimensionOf(szAuthGuid));
  473. StringFromGUID2(GUID_ACCTPROV_RADIUS, szAcctGuid, DimensionOf(szAcctGuid));
  474. pos = provList.GetHeadPosition();
  475. while ( pos )
  476. {
  477. pData = &provList.GetNext(pos);
  478. // Windows NT Bug : 127189
  479. // If IP is not installed, and this is RADIUS, do not
  480. // show the RADIUS provider. (For both auth and acct).
  481. // ------------------------------------------------------------
  482. if (!m_pRtrCfgSheet->m_fIpLoaded &&
  483. ((pData->m_stProviderTypeGUID.CompareNoCase(szAuthGuid) == 0) ||
  484. (pData->m_stProviderTypeGUID.CompareNoCase(szAcctGuid) == 0))
  485. )
  486. {
  487. continue;
  488. }
  489. // Ok, this is a valid entry, add it to the list box
  490. // ------------------------------------------------------------
  491. iRow = provCtrl.InsertString(cRows, pData->m_stTitle);
  492. provCtrl.SetItemData(iRow, (LONG_PTR) pData);
  493. // Now we need to look for the match with the active provider
  494. // ------------------------------------------------------------
  495. if ( StriCmp(pData->m_stGuid, stGuid) == 0 )
  496. iSel = iRow;
  497. cRows ++;
  498. }
  499. if ( iSel != -1 )
  500. provCtrl.SetCurSel(iSel);
  501. }
  502. void RtrAuthCfgPage::OnChangePreSharedKey()
  503. {
  504. SetDirty(TRUE);
  505. SetModified();
  506. }
  507. void RtrAuthCfgPage::OnChangeCustomPolicySettings()
  508. {
  509. //Custom policy check box has been toggled.
  510. //Get the state here and either
  511. m_DataAuth.m_fUseCustomIPSecPolicy = IsDlgButtonChecked(IDC_AUTH_CHK_CUSTOM_IPSEC_POLICY);
  512. if ( m_DataAuth.m_fUseCustomIPSecPolicy )
  513. {
  514. //populate the pre-shared key field
  515. GetDlgItem(IDC_TXT_PRESHARED_KEY)->SetWindowText(m_DataAuth.m_szPreSharedKey);
  516. GetDlgItem(IDC_STATIC_PRESHARED_KEY1)->EnableWindow(TRUE);
  517. GetDlgItem(IDC_TXT_PRESHARED_KEY)->EnableWindow(TRUE);
  518. }
  519. else
  520. {
  521. //erase the pre-shared key
  522. m_DataAuth.m_szPreSharedKey[0]= 0;
  523. GetDlgItem(IDC_TXT_PRESHARED_KEY)->SetWindowText(m_DataAuth.m_szPreSharedKey);
  524. GetDlgItem(IDC_STATIC_PRESHARED_KEY1)->EnableWindow(FALSE);
  525. GetDlgItem(IDC_TXT_PRESHARED_KEY)->EnableWindow(FALSE);
  526. }
  527. SetDirty(TRUE);
  528. SetModified();
  529. }
  530. /*!--------------------------------------------------------------------------
  531. RtrAuthCfgPage::OnChangeAuthProv
  532. -
  533. Author: KennT
  534. ---------------------------------------------------------------------------*/
  535. void RtrAuthCfgPage::OnChangeAuthProv()
  536. {
  537. AuthProviderData * pData;
  538. int iSel;
  539. iSel = m_authprov.GetCurSel();
  540. if ( iSel == LB_ERR )
  541. {
  542. GetDlgItem(IDC_RTR_AUTH_BTN_AUTHCFG)->EnableWindow(FALSE);
  543. return;
  544. }
  545. pData = (AuthProviderData *) m_authprov.GetItemData(iSel);
  546. Assert(pData);
  547. m_stActiveAuthProv = pData->m_stGuid;
  548. GetDlgItem(IDC_RTR_AUTH_BTN_AUTHCFG)->EnableWindow(
  549. !pData->m_stConfigCLSID.IsEmpty());
  550. SetDirty(TRUE);
  551. SetModified();
  552. }
  553. /*!--------------------------------------------------------------------------
  554. RtrAuthCfgPage::OnChangeAcctProv
  555. -
  556. Author: KennT
  557. ---------------------------------------------------------------------------*/
  558. void RtrAuthCfgPage::OnChangeAcctProv()
  559. {
  560. AuthProviderData * pData;
  561. int iSel;
  562. iSel = m_acctprov.GetCurSel();
  563. if ( iSel == LB_ERR )
  564. {
  565. GetDlgItem(IDC_RTR_AUTH_BTN_ACCTCFG)->EnableWindow(FALSE);
  566. return;
  567. }
  568. pData = (AuthProviderData *) m_acctprov.GetItemData(iSel);
  569. if ( pData )
  570. {
  571. m_stActiveAcctProv = pData->m_stGuid;
  572. GetDlgItem(IDC_RTR_AUTH_BTN_ACCTCFG)->EnableWindow(
  573. !pData->m_stConfigCLSID.IsEmpty());
  574. }
  575. else
  576. {
  577. m_stActiveAcctProv.Empty();
  578. GetDlgItem(IDC_RTR_AUTH_BTN_ACCTCFG)->EnableWindow(FALSE);
  579. }
  580. SetDirty(TRUE);
  581. SetModified();
  582. }
  583. /*!--------------------------------------------------------------------------
  584. RtrAuthCfgPage::OnConfigureAcctProv
  585. -
  586. Author: KennT
  587. ---------------------------------------------------------------------------*/
  588. void RtrAuthCfgPage::OnConfigureAcctProv()
  589. {
  590. AuthProviderData * pData = NULL;
  591. GUID guid;
  592. SPIAccountingProviderConfig spAcctConfig;
  593. HRESULT hr = hrOK;
  594. ULONG_PTR uConnection = 0;
  595. // Find the ConfigCLSID for this Guid
  596. // ----------------------------------------------------------------
  597. pData = m_DataAuth.FindProvData(m_DataAuth.m_acctProvList,
  598. m_stActiveAcctProv);
  599. // Did we find a provider?
  600. // ----------------------------------------------------------------
  601. if ( pData == NULL )
  602. {
  603. Panic0("Should have found a provider");
  604. return;
  605. }
  606. CORg( CLSIDFromString((LPTSTR) (LPCTSTR)(pData->m_stConfigCLSID), &guid) );
  607. // Create the EAP provider object
  608. // ----------------------------------------------------------------
  609. CORg( CoCreateInstance(guid,
  610. NULL,
  611. CLSCTX_INPROC_SERVER | CLSCTX_ENABLE_CODE_DOWNLOAD,
  612. IID_IAccountingProviderConfig,
  613. (LPVOID *) &spAcctConfig) );
  614. hr = spAcctConfig->Initialize(m_pRtrCfgSheet->m_stServerName,
  615. &uConnection);
  616. if ( FHrSucceeded(hr) )
  617. {
  618. hr = spAcctConfig->Configure(uConnection,
  619. GetSafeHwnd(),
  620. m_dwAuthFlags,
  621. 0, 0);
  622. // mark this provider has been configured
  623. if (hr == S_OK)
  624. pData->m_fConfiguredInThisSession = TRUE;
  625. spAcctConfig->Uninitialize(uConnection);
  626. }
  627. if ( hr == E_NOTIMPL )
  628. hr = hrOK;
  629. CORg( hr );
  630. Error:
  631. if ( !FHrSucceeded(hr) )
  632. DisplayTFSErrorMessage(GetSafeHwnd());
  633. }
  634. /*!--------------------------------------------------------------------------
  635. RtrAuthCfgPage::OnConfigureAuthProv
  636. -
  637. Author: KennT
  638. ---------------------------------------------------------------------------*/
  639. void RtrAuthCfgPage::OnConfigureAuthProv()
  640. {
  641. AuthProviderData * pData = NULL;
  642. GUID guid;
  643. SPIAuthenticationProviderConfig spAuthConfig;
  644. HRESULT hr = hrOK;
  645. ULONG_PTR uConnection = 0;
  646. // Find the ConfigCLSID for this Guid
  647. // ----------------------------------------------------------------
  648. pData = m_DataAuth.FindProvData(m_DataAuth.m_authProvList,
  649. m_stActiveAuthProv);
  650. // Did we find a provider?
  651. // ----------------------------------------------------------------
  652. if ( pData == NULL )
  653. {
  654. Panic0("Should have found a provider");
  655. return;
  656. }
  657. CORg( CLSIDFromString((LPTSTR) (LPCTSTR)(pData->m_stConfigCLSID), &guid) );
  658. // Create the EAP provider object
  659. // ----------------------------------------------------------------
  660. CORg( CoCreateInstance(guid,
  661. NULL,
  662. CLSCTX_INPROC_SERVER | CLSCTX_ENABLE_CODE_DOWNLOAD,
  663. IID_IAuthenticationProviderConfig,
  664. (LPVOID *) &spAuthConfig) );
  665. hr = spAuthConfig->Initialize(m_pRtrCfgSheet->m_stServerName,
  666. &uConnection);
  667. if (FHrSucceeded(hr))
  668. {
  669. hr = spAuthConfig->Configure(uConnection,
  670. GetSafeHwnd(),
  671. m_dwAuthFlags,
  672. 0, 0);
  673. // mark this provider has been configured
  674. if (hr == S_OK)
  675. pData->m_fConfiguredInThisSession = TRUE;
  676. spAuthConfig->Uninitialize(uConnection);
  677. }
  678. if ( hr == E_NOTIMPL )
  679. hr = hrOK;
  680. CORg( hr );
  681. Error:
  682. if ( !FHrSucceeded(hr) )
  683. DisplayTFSErrorMessage(GetSafeHwnd());
  684. }
  685. /*!--------------------------------------------------------------------------
  686. RtrAuthCfgPage::OnAuthSettings
  687. Bring up the settings dialog
  688. Author: KennT
  689. ---------------------------------------------------------------------------*/
  690. void RtrAuthCfgPage::OnAuthSettings()
  691. {
  692. AuthenticationSettingsDialog dlg(m_pRtrCfgSheet->m_stServerName,
  693. &m_DataAuth.m_eapProvList);
  694. dlg.SetAuthFlags(m_dwAuthFlags);
  695. if (dlg.DoModal() == IDOK)
  696. {
  697. m_dwAuthFlags = dlg.GetAuthFlags();
  698. SetDirty(TRUE);
  699. SetModified();
  700. }
  701. }
  702. //**********************************************************************
  703. // ARAP router configuration page
  704. //**********************************************************************
  705. BEGIN_MESSAGE_MAP(RtrARAPCfgPage, RtrPropertyPage)
  706. //{{AFX_MSG_MAP(RtrARAPCfgPage)
  707. ON_BN_CLICKED(IDC_RTR_ARAP_CB_REMOTEARAP, OnRtrArapCbRemotearap)
  708. //}}AFX_MSG_MAP
  709. END_MESSAGE_MAP()
  710. RtrARAPCfgPage::RtrARAPCfgPage(UINT nIDTemplate, UINT nIDCaption /* = 0*/)
  711. : RtrPropertyPage(nIDTemplate, nIDCaption)
  712. {
  713. //{{AFX_DATA_INIT(RtrARAPCfgPage)
  714. //}}AFX_DATA_INIT
  715. m_bApplied = FALSE;
  716. }
  717. RtrARAPCfgPage::~RtrARAPCfgPage()
  718. {
  719. }
  720. HRESULT RtrARAPCfgPage::Init(RtrCfgSheet * pRtrCfgSheet,
  721. const RouterVersionInfo& routerVersion)
  722. {
  723. Assert (pRtrCfgSheet);
  724. m_pRtrCfgSheet=pRtrCfgSheet;
  725. m_DataARAP.LoadFromReg(m_pRtrCfgSheet->m_stServerName, m_pRtrCfgSheet->m_fNT4);
  726. return S_OK;
  727. };
  728. BOOL RtrARAPCfgPage::OnInitDialog()
  729. {
  730. HRESULT hr= hrOK;
  731. CWaitCursor wait;
  732. BOOL bEnable;
  733. m_bApplied = FALSE;
  734. RtrPropertyPage::OnInitDialog();
  735. if ( m_pRtrCfgSheet->m_fNT4 )
  736. {
  737. bEnable = FALSE;
  738. GetDlgItem(IDC_RTR_ARAP_CB_REMOTEARAP)->EnableWindow(FALSE);
  739. }
  740. else
  741. {
  742. CheckDlgButton(IDC_RTR_ARAP_CB_REMOTEARAP, m_DataARAP.m_dwEnableIn );
  743. bEnable = m_DataARAP.m_dwEnableIn;
  744. }
  745. m_AdapterInfo.SetServerName(m_pRtrCfgSheet->m_stServerName);
  746. m_AdapterInfo.GetAdapterInfo();
  747. if ( !FHrSucceeded(m_AdapterInfo.GetAdapterInfo()) )
  748. {
  749. wait.Restore();
  750. AfxMessageBox(IDS_ERR_ARAP_NOADAPTINFO);
  751. }
  752. SetDirty(FALSE);
  753. if ( !FHrSucceeded(hr) )
  754. Cancel();
  755. return FHrSucceeded(hr) ? TRUE : FALSE;
  756. }
  757. BOOL RtrARAPCfgPage::OnApply()
  758. {
  759. BOOL fReturn=TRUE;
  760. HRESULT hr = hrOK;
  761. CString szLower, szUpper;
  762. CString szZone;
  763. if ( m_pRtrCfgSheet->IsCancel() )
  764. return TRUE;
  765. m_DataARAP.m_dwEnableIn = IsDlgButtonChecked(IDC_RTR_ARAP_CB_REMOTEARAP);
  766. m_bApplied = TRUE;
  767. fReturn = RtrPropertyPage::OnApply();
  768. if ( !FHrSucceeded(hr) )
  769. fReturn = FALSE;
  770. return fReturn;
  771. }
  772. void RtrARAPCfgPage::DoDataExchange(CDataExchange* pDX)
  773. {
  774. CPropertyPage::DoDataExchange(pDX);
  775. //{{AFX_DATA_MAP(RtrARAPCfgPage)
  776. //}}AFX_DATA_MAP
  777. }
  778. void RtrARAPCfgPage::OnRtrArapCbRemotearap()
  779. {
  780. SetDirty(TRUE);
  781. SetModified();
  782. }
  783. //**********************************************************************
  784. // IP router configuration page
  785. //**********************************************************************
  786. BEGIN_MESSAGE_MAP(RtrIPCfgPage, RtrPropertyPage)
  787. //{{AFX_MSG_MAP(RtrIPCfgPage)
  788. ON_BN_CLICKED(IDC_RTR_IP_CB_ALLOW_REMOTETCPIP, OnAllowRemoteTcpip)
  789. ON_BN_CLICKED(IDC_RTR_IP_BTN_ENABLE_IPROUTING, OnRtrEnableIPRouting)
  790. ON_BN_CLICKED(IDC_RTR_IP_RB_DHCP, OnRtrIPRbDhcp)
  791. ON_BN_CLICKED(IDC_RTR_IP_RB_POOL, OnRtrIPRbPool)
  792. ON_CBN_SELENDOK(IDC_RTR_IP_COMBO_ADAPTER, OnSelendOkAdapter)
  793. ON_BN_CLICKED(IDC_RTR_IP_BTN_ADD, OnBtnAdd)
  794. ON_BN_CLICKED(IDC_RTR_IP_BTN_EDIT, OnBtnEdit)
  795. ON_BN_CLICKED(IDC_RTR_IP_BTN_REMOVE, OnBtnRemove)
  796. ON_BN_CLICKED(IDC_RTR_IP_BTN_ENABLE_NETBT_BCAST_FWD, OnEnableNetbtBcastFwd)
  797. ON_NOTIFY(NM_DBLCLK, IDC_RTR_IP_LIST, OnListDblClk)
  798. ON_NOTIFY(LVN_ITEMCHANGED, IDC_RTR_IP_LIST, OnListChange)
  799. //}}AFX_MSG_MAP
  800. END_MESSAGE_MAP()
  801. RtrIPCfgPage::RtrIPCfgPage(UINT nIDTemplate, UINT nIDCaption /* = 0*/)
  802. : RtrPropertyPage(nIDTemplate, nIDCaption), m_bReady(FALSE)
  803. {
  804. //{{AFX_DATA_INIT(RtrIPCfgPage)
  805. //}}AFX_DATA_INIT
  806. }
  807. RtrIPCfgPage::~RtrIPCfgPage()
  808. {
  809. }
  810. void RtrIPCfgPage::DoDataExchange(CDataExchange* pDX)
  811. {
  812. RtrPropertyPage::DoDataExchange(pDX);
  813. //{{AFX_DATA_MAP(RtrIPCfgPage)
  814. DDX_Control(pDX, IDC_RTR_IP_COMBO_ADAPTER, m_adapter);
  815. DDX_Control(pDX, IDC_RTR_IP_LIST, m_listCtrl);
  816. //}}AFX_DATA_MAP
  817. }
  818. HRESULT RtrIPCfgPage::Init(RtrCfgSheet * pRtrCfgSheet,
  819. const RouterVersionInfo& routerVersion)
  820. {
  821. Assert (pRtrCfgSheet);
  822. m_pRtrCfgSheet=pRtrCfgSheet;
  823. m_DataIP.LoadFromReg(m_pRtrCfgSheet->m_stServerName,
  824. routerVersion);
  825. return S_OK;
  826. };
  827. void RtrIPCfgPage::FillAdapterListBox(CComboBox& adapterCtrl,
  828. AdapterList& adapterList,
  829. const CString& stGuid)
  830. {
  831. POSITION pos;
  832. AdapterData * pData;
  833. int cRows = 0;
  834. int iSel = -1;
  835. int iRow;
  836. pos = adapterList.GetHeadPosition();
  837. while ( pos )
  838. {
  839. pData = &adapterList.GetNext(pos);
  840. iRow = adapterCtrl.InsertString(cRows, pData->m_stFriendlyName);
  841. adapterCtrl.SetItemData(iRow, (LONG_PTR) pData);
  842. // Now we need to look for the match with the active provider
  843. // ------------------------------------------------------------
  844. if ( StriCmp(pData->m_stGuid, stGuid) == 0 )
  845. iSel = iRow;
  846. cRows ++;
  847. }
  848. if ( iSel != -1 )
  849. adapterCtrl.SetCurSel(iSel);
  850. if ( cRows <= 2 )
  851. {
  852. // 2: One for the NIC and one for "allow RAS to select"
  853. adapterCtrl.ShowWindow(SW_HIDE);
  854. GetDlgItem(IDC_RTR_IP_TEXT_ADAPTER)->ShowWindow(SW_HIDE);
  855. GetDlgItem(IDC_RTR_IP_TEXT_LABEL_ADAPTER)->ShowWindow(SW_HIDE);
  856. }
  857. }
  858. /*!--------------------------------------------------------------------------
  859. RtrIPCfgPage::OnInitDialog
  860. -
  861. Author: KennT
  862. ---------------------------------------------------------------------------*/
  863. BOOL RtrIPCfgPage::OnInitDialog()
  864. {
  865. HRESULT hr= hrOK;
  866. RtrPropertyPage::OnInitDialog();
  867. CheckDlgButton(IDC_RTR_IP_CB_ALLOW_REMOTETCPIP,
  868. m_DataIP.m_dwEnableIn);
  869. CheckRadioButton(IDC_RTR_IP_RB_DHCP, IDC_RTR_IP_RB_POOL,
  870. (m_DataIP.m_dwUseDhcp) ? IDC_RTR_IP_RB_DHCP : IDC_RTR_IP_RB_POOL);
  871. CheckDlgButton(IDC_RTR_IP_BTN_ENABLE_IPROUTING, m_DataIP.m_dwAllowNetworkAccess );
  872. CheckDlgButton(
  873. IDC_RTR_IP_BTN_ENABLE_NETBT_BCAST_FWD,
  874. m_DataIP.m_dwEnableNetbtBcastFwd
  875. );
  876. m_bReady=TRUE;
  877. InitializeAddressPoolListControl(&m_listCtrl,
  878. ADDRPOOL_LONG,
  879. &m_DataIP.m_addressPoolList);
  880. //enable/disable static pools fields
  881. // ----------------------------------------------------------------
  882. EnableStaticPoolCtrls( m_DataIP.m_dwUseDhcp==0 );
  883. // Load the information for all of the adapters
  884. // ----------------------------------------------------------------
  885. m_DataIP.LoadAdapters(m_pRtrCfgSheet->m_spRouter,
  886. &m_DataIP.m_adapterList);
  887. // Add the adapters to the listbox
  888. // ----------------------------------------------------------------
  889. FillAdapterListBox(m_adapter, m_DataIP.m_adapterList,
  890. m_DataIP.m_stNetworkAdapterGUID);
  891. SetDirty(FALSE);
  892. if ( !FHrSucceeded(hr) )
  893. Cancel();
  894. return FHrSucceeded(hr) ? TRUE : FALSE;
  895. }
  896. BOOL RtrIPCfgPage::OnApply()
  897. {
  898. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  899. BOOL fReturn=TRUE;
  900. HRESULT hr = hrOK;
  901. if ( m_pRtrCfgSheet->IsCancel() )
  902. return TRUE;
  903. hr = m_pRtrCfgSheet->SaveRequiredRestartChanges(GetSafeHwnd());
  904. fReturn = RtrPropertyPage::OnApply();
  905. if ( !FHrSucceeded(hr) )
  906. fReturn = FALSE;
  907. return fReturn;
  908. }
  909. HRESULT RtrIPCfgPage::SaveSettings(HWND hWnd)
  910. {
  911. DWORD dwAddr;
  912. DWORD dwMask;
  913. DWORD dwUseDhcp;
  914. AdapterData * pData;
  915. int iSel;
  916. CString stAddr, stMask, stRange, stInvalidRange;
  917. HRESULT hr = hrOK;
  918. if (!IsDirty())
  919. return hr;
  920. dwUseDhcp = IsDlgButtonChecked(IDC_RTR_IP_RB_DHCP);
  921. if (dwUseDhcp)
  922. {
  923. //24323 Static IP address pools should be persisted in UI, even when DCHP is chosen.
  924. // m_DataIP.m_addressPoolList.RemoveAll();
  925. }
  926. else
  927. {
  928. // Check to see that we have at least one address pool
  929. // ------------------------------------------------------------
  930. if (m_DataIP.m_addressPoolList.GetCount() == 0)
  931. {
  932. AfxMessageBox(IDS_ERR_ADDRESS_POOL_IS_EMPTY);
  933. return E_FAIL;
  934. }
  935. }
  936. if (FHrSucceeded(hr))
  937. {
  938. m_DataIP.m_dwEnableIn = IsDlgButtonChecked(IDC_RTR_IP_CB_ALLOW_REMOTETCPIP);
  939. m_DataIP.m_dwAllowNetworkAccess = IsDlgButtonChecked(IDC_RTR_IP_BTN_ENABLE_IPROUTING);
  940. m_DataIP.m_dwUseDhcp = dwUseDhcp;
  941. m_DataIP.m_dwEnableNetbtBcastFwd =
  942. IsDlgButtonChecked(IDC_RTR_IP_BTN_ENABLE_NETBT_BCAST_FWD);
  943. }
  944. iSel = m_adapter.GetCurSel();
  945. if ( iSel == LB_ERR )
  946. {
  947. iSel = 0;
  948. }
  949. pData = (AdapterData *) m_adapter.GetItemData(iSel);
  950. Assert(pData);
  951. m_DataIP.m_stNetworkAdapterGUID = pData->m_stGuid;
  952. return hr;
  953. }
  954. void RtrIPCfgPage::OnAllowRemoteTcpip()
  955. {
  956. SetDirty(TRUE);
  957. SetModified();
  958. }
  959. void RtrIPCfgPage::OnRtrEnableIPRouting()
  960. {
  961. SetDirty(TRUE);
  962. SetModified();
  963. }
  964. void RtrIPCfgPage::OnRtrIPRbDhcp()
  965. {
  966. EnableStaticPoolCtrls(FALSE);
  967. SetDirty(TRUE);
  968. SetModified();
  969. }
  970. void RtrIPCfgPage::EnableStaticPoolCtrls(BOOL fEnable)
  971. {
  972. MultiEnableWindow(GetSafeHwnd(),
  973. fEnable,
  974. IDC_RTR_IP_BTN_ADD,
  975. IDC_RTR_IP_BTN_EDIT,
  976. IDC_RTR_IP_BTN_REMOVE,
  977. IDC_RTR_IP_LIST,
  978. 0);
  979. if (fEnable)
  980. {
  981. if ((m_listCtrl.GetItemCount() == 0) ||
  982. (m_listCtrl.GetNextItem(-1, LVNI_SELECTED) == -1))
  983. {
  984. MultiEnableWindow(GetSafeHwnd(),
  985. FALSE,
  986. IDC_RTR_IP_BTN_EDIT,
  987. IDC_RTR_IP_BTN_REMOVE,
  988. 0);
  989. }
  990. // If we have > 0 items and we do not support multiple
  991. // address pools then stop
  992. if ((m_listCtrl.GetItemCount() > 0) &&
  993. !m_DataIP.m_addressPoolList.FUsesMultipleAddressPools())
  994. {
  995. MultiEnableWindow(GetSafeHwnd(),
  996. FALSE,
  997. IDC_RTR_IP_BTN_ADD,
  998. 0);
  999. }
  1000. }
  1001. }
  1002. void RtrIPCfgPage::OnRtrIPRbPool()
  1003. {
  1004. EnableStaticPoolCtrls(TRUE);
  1005. SetDirty(TRUE);
  1006. SetModified();
  1007. }
  1008. void RtrIPCfgPage::OnSelendOkAdapter()
  1009. {
  1010. SetDirty(TRUE);
  1011. SetModified();
  1012. }
  1013. void RtrIPCfgPage::OnBtnAdd()
  1014. {
  1015. OnNewAddressPool(GetSafeHwnd(),
  1016. &m_listCtrl,
  1017. ADDRPOOL_LONG,
  1018. &(m_DataIP.m_addressPoolList));
  1019. // Disable the ADD button if it's ok to add pools.
  1020. if ((m_listCtrl.GetItemCount() > 0) &&
  1021. !m_DataIP.m_addressPoolList.FUsesMultipleAddressPools())
  1022. {
  1023. MultiEnableWindow(GetSafeHwnd(),
  1024. FALSE,
  1025. IDC_RTR_IP_BTN_ADD,
  1026. 0);
  1027. }
  1028. SetDirty(TRUE);
  1029. SetModified();
  1030. }
  1031. void RtrIPCfgPage::OnBtnEdit()
  1032. {
  1033. INT iPos;
  1034. OnEditAddressPool(GetSafeHwnd(),
  1035. &m_listCtrl,
  1036. ADDRPOOL_LONG,
  1037. &(m_DataIP.m_addressPoolList));
  1038. // reset the selection
  1039. if ((iPos = m_listCtrl.GetNextItem(-1, LVNI_SELECTED)) != -1)
  1040. {
  1041. MultiEnableWindow(GetSafeHwnd(),
  1042. TRUE,
  1043. IDC_RTR_IP_BTN_EDIT,
  1044. IDC_RTR_IP_BTN_REMOVE,
  1045. 0);
  1046. }
  1047. SetDirty(TRUE);
  1048. SetModified();
  1049. }
  1050. void RtrIPCfgPage::OnBtnRemove()
  1051. {
  1052. OnDeleteAddressPool(GetSafeHwnd(),
  1053. &m_listCtrl,
  1054. ADDRPOOL_LONG,
  1055. &(m_DataIP.m_addressPoolList));
  1056. // Enable the ADD button if it's ok to add pools.
  1057. if ((m_listCtrl.GetItemCount() == 0) ||
  1058. m_DataIP.m_addressPoolList.FUsesMultipleAddressPools())
  1059. {
  1060. MultiEnableWindow(GetSafeHwnd(),
  1061. TRUE,
  1062. IDC_RTR_IP_BTN_ADD,
  1063. 0);
  1064. }
  1065. SetDirty(TRUE);
  1066. SetModified();
  1067. }
  1068. void RtrIPCfgPage::OnEnableNetbtBcastFwd()
  1069. {
  1070. SetDirty(TRUE);
  1071. SetModified();
  1072. }
  1073. void RtrIPCfgPage::OnListDblClk(NMHDR *pNMHdr, LRESULT *pResult)
  1074. {
  1075. OnBtnEdit();
  1076. *pResult = 0;
  1077. }
  1078. void RtrIPCfgPage::OnListChange(NMHDR *pNmHdr, LRESULT *pResult)
  1079. {
  1080. NMLISTVIEW * pnmlv = reinterpret_cast<NMLISTVIEW *>(pNmHdr);
  1081. BOOL fEnable = !!(pnmlv->uNewState & LVIS_SELECTED);
  1082. MultiEnableWindow(GetSafeHwnd(),
  1083. fEnable,
  1084. IDC_RTR_IP_BTN_EDIT,
  1085. IDC_RTR_IP_BTN_REMOVE,
  1086. 0);
  1087. *pResult = 0;
  1088. }
  1089. //**********************************************************************
  1090. // IPX router configuration page
  1091. //**********************************************************************
  1092. BEGIN_MESSAGE_MAP(RtrIPXCfgPage, RtrPropertyPage)
  1093. //{{AFX_MSG_MAP(RtrIPXCfgPage)
  1094. ON_BN_CLICKED(IDC_RB_ENTIRE_NETWORK, OnChangeSomething)
  1095. ON_BN_CLICKED(IDC_RTR_IPX_CB_ALLOW_CLIENT, OnChangeSomething)
  1096. ON_BN_CLICKED(IDC_RTR_IPX_CB_REMOTEIPX, OnChangeSomething)
  1097. ON_BN_CLICKED(IDC_RTR_IPX_CB_SAME_ADDRESS, OnChangeSomething)
  1098. ON_BN_CLICKED(IDC_RTR_IPX_RB_AUTO, OnRtrIPxRbAuto)
  1099. ON_BN_CLICKED(IDC_RTR_IPX_RB_POOL, OnRtrIPxRbPool)
  1100. ON_EN_CHANGE(IDC_RTR_IPX_EB_FIRST, OnChangeSomething)
  1101. ON_EN_CHANGE(IDC_RTR_IPX_EB_LAST, OnChangeSomething)
  1102. //}}AFX_MSG_MAP
  1103. END_MESSAGE_MAP()
  1104. RtrIPXCfgPage::RtrIPXCfgPage(UINT nIDTemplate, UINT nIDCaption /* = 0*/)
  1105. : RtrPropertyPage(nIDTemplate, nIDCaption)
  1106. {
  1107. //{{AFX_DATA_INIT(RtrIPXCfgPage)
  1108. //}}AFX_DATA_INIT
  1109. }
  1110. RtrIPXCfgPage::~RtrIPXCfgPage()
  1111. {
  1112. }
  1113. void RtrIPXCfgPage::DoDataExchange(CDataExchange* pDX)
  1114. {
  1115. RtrPropertyPage::DoDataExchange(pDX);
  1116. //{{AFX_DATA_MAP(RtrIPXCfgPage)
  1117. //}}AFX_DATA_MAP
  1118. }
  1119. HRESULT RtrIPXCfgPage::Init(RtrCfgSheet * pRtrCfgSheet,
  1120. const RouterVersionInfo& routerVersion)
  1121. {
  1122. Assert (pRtrCfgSheet);
  1123. m_pRtrCfgSheet=pRtrCfgSheet;
  1124. m_DataIPX.LoadFromReg(m_pRtrCfgSheet->m_stServerName, m_pRtrCfgSheet->m_fNT4);
  1125. return S_OK;
  1126. };
  1127. BOOL RtrIPXCfgPage::OnInitDialog()
  1128. {
  1129. HRESULT hr= hrOK;
  1130. RtrPropertyPage::OnInitDialog();
  1131. CheckDlgButton(IDC_RB_ENTIRE_NETWORK,
  1132. m_DataIPX.m_dwAllowNetworkAccess);
  1133. CheckRadioButton(IDC_RTR_IPX_RB_AUTO, IDC_RTR_IPX_RB_POOL,
  1134. (m_DataIPX.m_dwUseAutoAddr) ? IDC_RTR_IPX_RB_AUTO : IDC_RTR_IPX_RB_POOL);
  1135. CheckDlgButton(IDC_RTR_IPX_CB_SAME_ADDRESS, m_DataIPX.m_dwUseSameNetNum );
  1136. CheckDlgButton(IDC_RTR_IPX_CB_ALLOW_CLIENT, m_DataIPX.m_dwAllowClientNetNum );
  1137. CheckDlgButton(IDC_RTR_IPX_CB_REMOTEIPX, m_DataIPX.m_dwEnableIn );
  1138. if ( m_DataIPX.m_dwIpxNetFirst || m_DataIPX.m_dwIpxNetLast )
  1139. {
  1140. TCHAR szNumFirst [40] = TEXT("");
  1141. _ultot(m_DataIPX.m_dwIpxNetFirst, szNumFirst, DATA_SRV_IPX::mc_nIpxNetNumRadix);
  1142. if ( szNumFirst[0] == TEXT('\0') )
  1143. return FALSE;
  1144. TCHAR szNumLast [40] = TEXT("");
  1145. _ultot(m_DataIPX.m_dwIpxNetLast, szNumLast, DATA_SRV_IPX::mc_nIpxNetNumRadix);
  1146. if ( szNumLast[0] == TEXT('\0') )
  1147. return FALSE;
  1148. GetDlgItem(IDC_RTR_IPX_EB_FIRST)->SetWindowText(szNumFirst);
  1149. GetDlgItem(IDC_RTR_IPX_EB_LAST)->SetWindowText(szNumLast);
  1150. }
  1151. EnableNetworkRangeCtrls(!m_DataIPX.m_dwUseAutoAddr);
  1152. SetDirty(FALSE);
  1153. if ( !FHrSucceeded(hr) )
  1154. Cancel();
  1155. return FHrSucceeded(hr) ? TRUE : FALSE;
  1156. }
  1157. void RtrIPXCfgPage::EnableNetworkRangeCtrls(BOOL fEnable)
  1158. {
  1159. MultiEnableWindow(GetSafeHwnd(),
  1160. fEnable,
  1161. IDC_RTR_IPX_EB_FIRST,
  1162. IDC_RTR_IPX_EB_LAST,
  1163. 0);
  1164. }
  1165. BOOL RtrIPXCfgPage::OnApply()
  1166. {
  1167. BOOL fReturn=TRUE;
  1168. HRESULT hr = hrOK;
  1169. if ( m_pRtrCfgSheet->IsCancel() )
  1170. return TRUE;
  1171. // Only get the information if we are using them
  1172. if (IsDlgButtonChecked(IDC_RTR_IPX_RB_POOL))
  1173. {
  1174. TCHAR szNumFirst [16] = {0};
  1175. GetDlgItemText(IDC_RTR_IPX_EB_FIRST, szNumFirst, DimensionOf(szNumFirst));
  1176. m_DataIPX.m_dwIpxNetFirst = _tcstoul(szNumFirst, NULL,
  1177. DATA_SRV_IPX::mc_nIpxNetNumRadix);
  1178. TCHAR szNumLast [16] = {0};
  1179. GetDlgItemText(IDC_RTR_IPX_EB_LAST, szNumLast, DimensionOf(szNumLast));
  1180. m_DataIPX.m_dwIpxNetLast = _tcstoul(szNumLast, NULL,
  1181. DATA_SRV_IPX::mc_nIpxNetNumRadix);
  1182. // Check to see that the last is bigger than the first
  1183. if (m_DataIPX.m_dwIpxNetLast < m_DataIPX.m_dwIpxNetFirst)
  1184. {
  1185. AfxMessageBox(IDS_ERR_IPX_LAST_MUST_BE_MORE_THAN_FIRST);
  1186. return TRUE;
  1187. }
  1188. }
  1189. m_DataIPX.m_dwUseSameNetNum = IsDlgButtonChecked(IDC_RTR_IPX_CB_SAME_ADDRESS);
  1190. m_DataIPX.m_dwAllowClientNetNum = IsDlgButtonChecked(IDC_RTR_IPX_CB_ALLOW_CLIENT);
  1191. m_DataIPX.m_dwAllowNetworkAccess = IsDlgButtonChecked(IDC_RB_ENTIRE_NETWORK);
  1192. m_DataIPX.m_dwUseAutoAddr = IsDlgButtonChecked(IDC_RTR_IPX_RB_AUTO);
  1193. m_DataIPX.m_dwEnableIn = IsDlgButtonChecked(IDC_RTR_IPX_CB_REMOTEIPX);
  1194. fReturn = RtrPropertyPage::OnApply();
  1195. if ( !FHrSucceeded(hr) )
  1196. fReturn = FALSE;
  1197. return fReturn;
  1198. }
  1199. void RtrIPXCfgPage::OnChangeSomething()
  1200. {
  1201. SetDirty(TRUE);
  1202. SetModified();
  1203. }
  1204. void RtrIPXCfgPage::OnRtrIPxRbAuto()
  1205. {
  1206. EnableNetworkRangeCtrls(FALSE);
  1207. SetDirty(TRUE);
  1208. SetModified();
  1209. }
  1210. void RtrIPXCfgPage::OnRtrIPxRbPool()
  1211. {
  1212. EnableNetworkRangeCtrls(TRUE);
  1213. SetDirty(TRUE);
  1214. SetModified();
  1215. }
  1216. //**********************************************************************
  1217. // NetBEUI router configuration page
  1218. //**********************************************************************
  1219. BEGIN_MESSAGE_MAP(RtrNBFCfgPage, RtrPropertyPage)
  1220. //{{AFX_MSG_MAP(RtrNBFCfgPage)
  1221. ON_BN_CLICKED(IDC_RB_ENTIRE_NETWORK, OnButtonClick)
  1222. ON_BN_CLICKED(IDC_RB_THIS_COMPUTER, OnButtonClick)
  1223. ON_BN_CLICKED(IDC_RTR_IPX_CB_REMOTENETBEUI, OnButtonClick)
  1224. //}}AFX_MSG_MAP
  1225. END_MESSAGE_MAP()
  1226. RtrNBFCfgPage::RtrNBFCfgPage(UINT nIDTemplate, UINT nIDCaption /* = 0*/)
  1227. : RtrPropertyPage(nIDTemplate, nIDCaption)
  1228. {
  1229. //{{AFX_DATA_INIT(RtrNBFCfgPage)
  1230. //}}AFX_DATA_INIT
  1231. }
  1232. RtrNBFCfgPage::~RtrNBFCfgPage()
  1233. {
  1234. }
  1235. void RtrNBFCfgPage::DoDataExchange(CDataExchange* pDX)
  1236. {
  1237. RtrPropertyPage::DoDataExchange(pDX);
  1238. //{{AFX_DATA_MAP(RtrNBFCfgPage)
  1239. // NOTE: the ClassWizard will add DDX and DDV calls here
  1240. //}}AFX_DATA_MAP
  1241. }
  1242. HRESULT RtrNBFCfgPage::Init(RtrCfgSheet * pRtrCfgSheet,
  1243. const RouterVersionInfo& routerVersion)
  1244. {
  1245. Assert (pRtrCfgSheet);
  1246. m_pRtrCfgSheet=pRtrCfgSheet;
  1247. m_DataNBF.LoadFromReg(m_pRtrCfgSheet->m_stServerName, m_pRtrCfgSheet->m_fNT4);
  1248. return S_OK;
  1249. };
  1250. BOOL RtrNBFCfgPage::OnInitDialog()
  1251. {
  1252. HRESULT hr= hrOK;
  1253. RtrPropertyPage::OnInitDialog();
  1254. CheckRadioButton(IDC_RB_ENTIRE_NETWORK,IDC_RB_THIS_COMPUTER,
  1255. (m_DataNBF.m_dwAllowNetworkAccess) ? IDC_RB_ENTIRE_NETWORK : IDC_RB_THIS_COMPUTER);
  1256. CheckDlgButton(IDC_RTR_IPX_CB_REMOTENETBEUI, m_DataNBF.m_dwEnableIn );
  1257. SetDirty(FALSE);
  1258. if ( !FHrSucceeded(hr) )
  1259. Cancel();
  1260. return FHrSucceeded(hr) ? TRUE : FALSE;
  1261. }
  1262. BOOL RtrNBFCfgPage::OnApply()
  1263. {
  1264. BOOL fReturn = TRUE;
  1265. HRESULT hr = hrOK;
  1266. BOOL fRestartNeeded = FALSE;
  1267. BOOL dwNewAllowNetworkAccess;
  1268. if ( m_pRtrCfgSheet->IsCancel() )
  1269. return TRUE;
  1270. hr = m_pRtrCfgSheet->SaveRequiredRestartChanges(GetSafeHwnd());
  1271. if (FHrSucceeded(hr))
  1272. fReturn = RtrPropertyPage::OnApply();
  1273. if ( !FHrSucceeded(hr) )
  1274. fReturn = FALSE;
  1275. return fReturn;
  1276. }
  1277. void RtrNBFCfgPage::OnButtonClick()
  1278. {
  1279. SaveSettings();
  1280. SetDirty(TRUE);
  1281. SetModified();
  1282. }
  1283. void RtrNBFCfgPage::SaveSettings()
  1284. {
  1285. m_DataNBF.m_dwAllowNetworkAccess = IsDlgButtonChecked(IDC_RB_ENTIRE_NETWORK);
  1286. m_DataNBF.m_dwEnableIn = IsDlgButtonChecked(IDC_RTR_IPX_CB_REMOTENETBEUI);
  1287. }
  1288. //******************************************************************************
  1289. //
  1290. // Router configuration property sheet
  1291. //
  1292. //******************************************************************************
  1293. RtrCfgSheet::RtrCfgSheet(ITFSNode *pNode,
  1294. IRouterInfo *pRouter,
  1295. IComponentData *pComponentData,
  1296. ITFSComponentData *pTFSCompData,
  1297. LPCTSTR pszSheetName,
  1298. CWnd *pParent,
  1299. UINT iPage,
  1300. BOOL fScopePane)
  1301. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  1302. pszSheetName, pParent, iPage, fScopePane)
  1303. {
  1304. m_fNT4=FALSE;
  1305. m_spNode.Set(pNode);
  1306. m_spRouter.Set(pRouter);
  1307. m_fIpLoaded=FALSE;
  1308. m_fIpxLoaded=FALSE;
  1309. m_fNbfLoaded=FALSE;
  1310. m_fARAPLoaded=FALSE;
  1311. }
  1312. RtrCfgSheet::~RtrCfgSheet()
  1313. {
  1314. }
  1315. /*!--------------------------------------------------------------------------
  1316. RtrCfgSheet::Init
  1317. Initialize the property sheets. The general action here will be
  1318. to initialize/add the various pages.
  1319. ---------------------------------------------------------------------------*/
  1320. HRESULT RtrCfgSheet::Init(LPCTSTR pServerName)
  1321. {
  1322. HKEY hkey=NULL;
  1323. RegKey regkey;
  1324. m_stServerName=pServerName;
  1325. {
  1326. HKEY hkeyMachine = 0;
  1327. // Connect to the registry
  1328. // ----------------------------------------------------------------
  1329. if ( FHrSucceeded( ConnectRegistry(pServerName, &hkeyMachine)) )
  1330. IsNT4Machine(hkeyMachine, &m_fNT4);
  1331. // Get the version information for this machine.
  1332. // ----------------------------------------------------------------
  1333. QueryRouterVersionInfo(hkeyMachine, &m_routerVersion);
  1334. if(hkeyMachine != NULL)
  1335. DisconnectRegistry(hkeyMachine);
  1336. }
  1337. // The pages are embedded members of the class
  1338. // do not delete them.
  1339. // ----------------------------------------------------------------
  1340. m_bAutoDeletePages = FALSE;
  1341. //load General Page
  1342. // ----------------------------------------------------------------
  1343. m_pRtrGenCfgPage = new RtrGenCfgPage(IDD_RTR_GENERAL);
  1344. m_pRtrGenCfgPage->Init(this, m_routerVersion);
  1345. AddPageToList((CPropertyPageBase*) m_pRtrGenCfgPage);
  1346. //load Authentication Page
  1347. // ----------------------------------------------------------------
  1348. m_pRtrAuthCfgPage = new RtrAuthCfgPage(IDD_RTR_AUTHENTICATION);
  1349. m_pRtrAuthCfgPage->Init(this, m_routerVersion);
  1350. AddPageToList((CPropertyPageBase*) m_pRtrAuthCfgPage);
  1351. //load IP page
  1352. // ----------------------------------------------------------------
  1353. if (HrIsProtocolSupported(pServerName,
  1354. c_szRegKeyTcpip,
  1355. c_szRegKeyRasIp,
  1356. c_szRegKeyRasIpRtrMgr) == hrOK)
  1357. {
  1358. m_pRtrIPCfgPage = new RtrIPCfgPage(IDD_RTR_IP);
  1359. m_pRtrIPCfgPage->Init(this, m_routerVersion);
  1360. AddPageToList((CPropertyPageBase*) m_pRtrIPCfgPage);
  1361. m_fIpLoaded=TRUE;
  1362. }
  1363. //load IPX page
  1364. // ----------------------------------------------------------------
  1365. if (HrIsProtocolSupported(pServerName,
  1366. c_szRegKeyNwlnkIpx,
  1367. c_szRegKeyRasIpx,
  1368. NULL) == hrOK)
  1369. {
  1370. m_pRtrIPXCfgPage = new RtrIPXCfgPage(IDD_RTR_IPX);
  1371. m_pRtrIPXCfgPage->Init(this, m_routerVersion);
  1372. AddPageToList((CPropertyPageBase*) m_pRtrIPXCfgPage);
  1373. m_fIpxLoaded=TRUE;
  1374. }
  1375. //load NetBEUI page
  1376. // ----------------------------------------------------------------
  1377. if ( m_routerVersion.dwOsBuildNo <= RASMAN_PPP_KEY_LAST_WIN2k_VERSION )
  1378. {
  1379. //If this is Win2k or less
  1380. if (HrIsProtocolSupported(pServerName,
  1381. c_szRegKeyNbf,
  1382. c_szRegKeyRasNbf,
  1383. NULL) == hrOK)
  1384. {
  1385. m_pRtrNBFCfgPage = new RtrNBFCfgPage(IDD_RTR_NBF);
  1386. m_pRtrNBFCfgPage->Init(this, m_routerVersion);
  1387. AddPageToList((CPropertyPageBase*) m_pRtrNBFCfgPage);
  1388. m_fNbfLoaded=TRUE;
  1389. }
  1390. }
  1391. // Check to see if this is the local machine,
  1392. // if so then we can check to see if we should add ARAP
  1393. // ----------------------------------------------------------------
  1394. BOOL fLocal = IsLocalMachine(pServerName);
  1395. if ( fLocal )
  1396. {
  1397. //load ARAP page
  1398. if (HrIsProtocolSupported(NULL,
  1399. c_szRegKeyAppletalk,
  1400. c_szRegKeyRasAppletalk,
  1401. NULL) == hrOK)
  1402. {
  1403. m_pRtrARAPCfgPage = new RtrARAPCfgPage(IDD_RTR_ARAP);
  1404. m_pRtrARAPCfgPage->Init(this, m_routerVersion);
  1405. AddPageToList((CPropertyPageBase*) m_pRtrARAPCfgPage);
  1406. m_fARAPLoaded=TRUE;
  1407. }
  1408. }
  1409. // load PPP Page
  1410. // ----------------------------------------------------------------
  1411. m_pRtrPPPCfgPage = new RtrPPPCfgPage(IDD_PPP_CONFIG);
  1412. m_pRtrPPPCfgPage->Init(this, m_routerVersion);
  1413. AddPageToList((CPropertyPageBase*) m_pRtrPPPCfgPage);
  1414. // Load RAS Error logging page
  1415. // ----------------------------------------------------------------
  1416. m_pRtrLogLevelCfgPage = new RtrLogLevelCfgPage(IDD_RTR_EVENTLOGGING);
  1417. m_pRtrLogLevelCfgPage->Init(this, m_routerVersion);
  1418. AddPageToList((CPropertyPageBase *) m_pRtrLogLevelCfgPage);
  1419. // if ( m_fNbfLoaded || m_fIpxLoaded || m_fIpLoaded || m_fARAPLoaded)
  1420. // return hrOK;
  1421. // else
  1422. // {
  1423. // //this call to Notify is a hack so that it can be properly deleted
  1424. // int nMessage = TFS_NOTIFY_RESULT_CREATEPROPSHEET;
  1425. // m_spNode->Notify(nMessage, (DWORD) this);
  1426. //
  1427. // return hrFail;
  1428. // }
  1429. return hrOK;
  1430. }
  1431. /*!--------------------------------------------------------------------------
  1432. RtrCfgSheet::SaveSheetData
  1433. -
  1434. ---------------------------------------------------------------------------*/
  1435. BOOL RtrCfgSheet::SaveSheetData()
  1436. {
  1437. HRESULT hr = hrOK;
  1438. if (IsCancel())
  1439. return TRUE;
  1440. if ( m_fIpLoaded )
  1441. CORg( m_pRtrIPCfgPage->m_DataIP.SaveToReg(m_spRouter, m_routerVersion) );
  1442. if ( m_fIpxLoaded )
  1443. CORg( m_pRtrIPXCfgPage->m_DataIPX.SaveToReg(NULL) );
  1444. if ( m_fNbfLoaded )
  1445. CORg( m_pRtrNBFCfgPage->m_DataNBF.SaveToReg() );
  1446. if ( m_fARAPLoaded )
  1447. {
  1448. CORg( m_pRtrARAPCfgPage->m_DataARAP.SaveToReg() );
  1449. // PnP notification
  1450. if(m_pRtrARAPCfgPage->m_bApplied)
  1451. {
  1452. CStop_StartAppleTalkPrint MacPrint;
  1453. CORg( m_pRtrARAPCfgPage->m_AdapterInfo.HrAtlkPnPReconfigParams(TRUE) );
  1454. m_pRtrARAPCfgPage->m_bApplied = FALSE;
  1455. }
  1456. }
  1457. CORg( m_pRtrAuthCfgPage->m_DataAuth.SaveToReg(NULL) );
  1458. CORg( m_pRtrPPPCfgPage->m_DataPPP.SaveToReg() );
  1459. CORg( m_pRtrLogLevelCfgPage->m_DataRASErrLog.SaveToReg() );
  1460. CORg( m_pRtrGenCfgPage->m_DataGeneral.SaveToReg() );
  1461. Error:
  1462. ForceGlobalRefresh(m_spRouter);
  1463. return FHrSucceeded(hr);
  1464. }
  1465. /*!--------------------------------------------------------------------------
  1466. RtrCfgSheet::SaveRequiredRestartChanges
  1467. This does require that the changes to the various DATA_SRV_XXX
  1468. structures be saved BEFORE this function gets called. This means
  1469. that the pages cannot wait till the OnApply() before saving the
  1470. data back. They have to do as the control is changed.
  1471. Author: KennT
  1472. ---------------------------------------------------------------------------*/
  1473. HRESULT RtrCfgSheet::SaveRequiredRestartChanges(HWND hWnd)
  1474. {
  1475. HRESULT hr = hrOK;
  1476. BOOL fRestart = FALSE;
  1477. // First, tell the various pages to save their settings (this
  1478. // is the same as an OnApply()).
  1479. // ----------------------------------------------------------------
  1480. if (m_pRtrIPCfgPage)
  1481. CORg( m_pRtrIPCfgPage->SaveSettings(hWnd) );
  1482. // Second, determine if we need to stop the router
  1483. // If so, stop the router (and mark it for restart).
  1484. // There are three pages that need to be asked,
  1485. // the general page, log level, and nbf.
  1486. // ----------------------------------------------------------------
  1487. if (m_pRtrGenCfgPage->m_DataGeneral.FNeedRestart() ||
  1488. m_pRtrLogLevelCfgPage->m_DataRASErrLog.FNeedRestart() ||
  1489. (m_pRtrNBFCfgPage && m_pRtrNBFCfgPage->m_DataNBF.FNeedRestart()) ||
  1490. (m_pRtrIPCfgPage && m_pRtrIPCfgPage->m_DataIP.FNeedRestart())
  1491. )
  1492. {
  1493. BOOL fRouterIsRunning = FALSE;
  1494. fRouterIsRunning = FHrOK(IsRouterServiceRunning(m_stServerName, NULL));
  1495. // If the router is running, tell the user that it is necessary
  1496. // to restart the router.
  1497. // ------------------------------------------------------------
  1498. if (fRouterIsRunning)
  1499. {
  1500. // Ask the user if they want to restart.
  1501. // --------------------------------------------------------
  1502. if (AfxMessageBox(IDS_WRN_CHANGING_ROUTER_CONFIG, MB_YESNO)==IDNO)
  1503. CORg( HResultFromWin32(ERROR_CANCELLED) );
  1504. hr = StopRouterService(m_stServerName);
  1505. // We have successfully stopped the router. Set the flag
  1506. // so that the router will be restarted after the change
  1507. // has been made.
  1508. // --------------------------------------------------------
  1509. if (FHrSucceeded(hr))
  1510. fRestart = TRUE;
  1511. else
  1512. {
  1513. DisplayIdErrorMessage2(NULL,
  1514. IDS_ERR_COULD_NOT_STOP_ROUTER,
  1515. hr);
  1516. }
  1517. }
  1518. if (m_pRtrIPCfgPage)
  1519. CORg( m_pRtrIPCfgPage->m_DataIP.SaveToReg(m_spRouter, m_routerVersion) );
  1520. // Windows NT Bug : 183083, 171594 - a change to the NetBEUI config
  1521. // requires that the service be restarted.
  1522. // ----------------------------------------------------------------
  1523. if (m_pRtrNBFCfgPage)
  1524. CORg( m_pRtrNBFCfgPage->m_DataNBF.SaveToReg() );
  1525. CORg( m_pRtrLogLevelCfgPage->m_DataRASErrLog.SaveToReg() );
  1526. CORg( m_pRtrGenCfgPage->m_DataGeneral.SaveToReg() );
  1527. }
  1528. // Restart the router if needed.
  1529. // ----------------------------------------------------------------
  1530. // If this call fails, it's not necessary to abort the whole
  1531. // procedure.
  1532. // ------------------------------------------------------------
  1533. if (fRestart)
  1534. StartRouterService(m_stServerName);
  1535. Error:
  1536. return hr;
  1537. }
  1538. //------------------------------------------------------------------------
  1539. // DATA_SRV_GENERAL
  1540. //------------------------------------------------------------------------
  1541. DATA_SRV_GENERAL::DATA_SRV_GENERAL()
  1542. {
  1543. GetDefault();
  1544. }
  1545. /*!--------------------------------------------------------------------------
  1546. DATA_SRV_GENERAL::LoadFromReg
  1547. -
  1548. Author: KennT
  1549. ---------------------------------------------------------------------------*/
  1550. HRESULT DATA_SRV_GENERAL::LoadFromReg(LPCTSTR pServerName /*=NULL*/)
  1551. {
  1552. DWORD dwErr = ERROR_SUCCESS;
  1553. HKEY hkMachine = 0;
  1554. LPCTSTR pszRouterTypeKey = NULL;
  1555. m_stServerName = pServerName;
  1556. // Windows NT Bug : 137200
  1557. // Look for the RemoteAccess\Parameters location first, then
  1558. // try the RAS\Protocols.
  1559. // If neither key exists, return failure.
  1560. // ----------------------------------------------------------------
  1561. // Connect to the machine and get its version informatioin
  1562. // ----------------------------------------------------------------
  1563. dwErr = ConnectRegistry(m_stServerName, &hkMachine);
  1564. if (dwErr != ERROR_SUCCESS)
  1565. return HResultFromWin32(dwErr);
  1566. for (int i=0; i<2; i++)
  1567. {
  1568. if (i == 0)
  1569. pszRouterTypeKey = c_szRegKeyRemoteAccessParameters;
  1570. else
  1571. pszRouterTypeKey = c_szRegKeyRasProtocols;
  1572. // Try to connect to the key
  1573. // ------------------------------------------------------------
  1574. m_regkey.Close();
  1575. dwErr = m_regkey.Open(hkMachine, pszRouterTypeKey);
  1576. if (dwErr != ERROR_SUCCESS)
  1577. {
  1578. if (i != 0)
  1579. {
  1580. // Setup the registry error
  1581. // ----------------------------------------------------
  1582. SetRegError(0, HResultFromWin32(dwErr),
  1583. IDS_ERR_REG_OPEN_CALL_FAILED,
  1584. c_szHKLM, pszRouterTypeKey, NULL);
  1585. }
  1586. continue;
  1587. }
  1588. dwErr = m_regkey.QueryValue( c_szRouterType, m_dwRouterType);
  1589. // If we succeeded, great! break out of the loop
  1590. // ------------------------------------------------------------
  1591. if (dwErr == ERROR_SUCCESS)
  1592. break;
  1593. if (i != 0)
  1594. {
  1595. // Setup the registry error
  1596. // ----------------------------------------------------
  1597. SetRegError(0, HResultFromWin32(dwErr),
  1598. IDS_ERR_REG_QUERYVALUE_CALL_FAILED,
  1599. c_szHKLM, pszRouterTypeKey, c_szRouterType, NULL);
  1600. }
  1601. }
  1602. //Error:
  1603. m_dwOldRouterType = m_dwRouterType;
  1604. if (hkMachine)
  1605. DisconnectRegistry(hkMachine);
  1606. return HResultFromWin32(dwErr);
  1607. }
  1608. HRESULT DATA_SRV_GENERAL::SaveToReg()
  1609. {
  1610. HRESULT hr = hrOK;
  1611. DWORD dw=0;
  1612. if (m_dwOldRouterType != m_dwRouterType)
  1613. {
  1614. CWRg( m_regkey.SetValue( c_szRouterType,m_dwRouterType) );
  1615. // If the configuration is a LAN-only router, remove the
  1616. // router.pbk
  1617. // ------------------------------------------------------------
  1618. if (m_dwRouterType == ROUTER_TYPE_LAN)
  1619. {
  1620. DeleteRouterPhonebook( m_stServerName );
  1621. }
  1622. m_dwOldRouterType = m_dwRouterType;
  1623. }
  1624. Error:
  1625. return hr;
  1626. }
  1627. void DATA_SRV_GENERAL::GetDefault()
  1628. {
  1629. // Windows NT Bug : 273419
  1630. // Change default to be RAS-server only
  1631. m_dwRouterType = ROUTER_TYPE_RAS;
  1632. m_dwOldRouterType = m_dwRouterType;
  1633. };
  1634. /*!--------------------------------------------------------------------------
  1635. DATA_SRV_GENERAL::FNeedRestart
  1636. Returns TRUE if a restart is needed.
  1637. Returns FALSE otherwise.
  1638. Author: KennT
  1639. ---------------------------------------------------------------------------*/
  1640. BOOL DATA_SRV_GENERAL::FNeedRestart()
  1641. {
  1642. // We need a restart only if the router type changed.
  1643. // ----------------------------------------------------------------
  1644. return (m_dwRouterType != m_dwOldRouterType);
  1645. }
  1646. //------------------------------------------------------------------------
  1647. // DATA_SRV_IP
  1648. //------------------------------------------------------------------------
  1649. DATA_SRV_IP::DATA_SRV_IP()
  1650. {
  1651. GetDefault();
  1652. }
  1653. /*!--------------------------------------------------------------------------
  1654. DATA_SRV_IP::LoadFromReg
  1655. -
  1656. Author: KennT
  1657. ---------------------------------------------------------------------------*/
  1658. HRESULT DATA_SRV_IP::LoadFromReg(LPCTSTR pServerName,
  1659. const RouterVersionInfo& routerVersion)
  1660. {
  1661. HRESULT hr = hrOK;
  1662. m_fNT4 = (routerVersion.dwRouterVersion <= 4);
  1663. m_routerVersion = routerVersion;
  1664. m_stServerName = pServerName;
  1665. m_regkey.Close();
  1666. if ( ERROR_SUCCESS == m_regkey.Open(HKEY_LOCAL_MACHINE,c_szRegKeyRasIp, KEY_ALL_ACCESS, pServerName) )
  1667. {
  1668. if ( m_fNT4 )
  1669. {
  1670. if ( ERROR_SUCCESS == m_regkeyNT4.Open(HKEY_LOCAL_MACHINE,
  1671. c_szRegKeyRasProtocols,
  1672. KEY_ALL_ACCESS,
  1673. pServerName) )
  1674. m_regkeyNT4.QueryValue( c_szRegValTcpIpAllowed,
  1675. m_dwAllowNetworkAccess);
  1676. }
  1677. else
  1678. {
  1679. m_regkey.QueryValue(c_szRegValAllowNetAccess,
  1680. m_dwAllowNetworkAccess);
  1681. }
  1682. m_regkey.QueryValue(c_szRegValDhcpAddressing, m_dwUseDhcp);
  1683. m_regkey.QueryValue(c_szRegValNetworkAdapterGUID, m_stNetworkAdapterGUID);
  1684. m_regkey.QueryValue(c_szRegValEnableIn,m_dwEnableIn);
  1685. //
  1686. // Query whether NETBT broadcasts need to be forwarded
  1687. //
  1688. if ( ERROR_SUCCESS !=
  1689. m_regkey.QueryValue(
  1690. c_szRegValEnableNetbtBcastFwd,
  1691. m_dwEnableNetbtBcastFwd
  1692. ) )
  1693. {
  1694. //
  1695. // if query fails, set bcast fwd to be TRUE (default)
  1696. // and set the registry key
  1697. //
  1698. m_dwEnableNetbtBcastFwd = TRUE;
  1699. m_regkey.SetValueExplicit(
  1700. c_szRegValEnableNetbtBcastFwd,
  1701. REG_DWORD,
  1702. sizeof(DWORD),
  1703. (LPBYTE)&m_dwEnableNetbtBcastFwd
  1704. );
  1705. }
  1706. // Load the addressing information
  1707. m_addressPoolList.RemoveAll();
  1708. // Always load the list
  1709. m_addressPoolList.LoadFromReg(m_regkey, routerVersion.dwOsBuildNo);
  1710. m_dwOldAllowNetworkAccess = m_dwAllowNetworkAccess;
  1711. m_dwOldEnableNetbtBcastFwd = m_dwEnableNetbtBcastFwd;
  1712. }
  1713. return hr;
  1714. }
  1715. /*!--------------------------------------------------------------------------
  1716. DATA_SRV_IP::UseDefaults
  1717. -
  1718. Author: KennT
  1719. ---------------------------------------------------------------------------*/
  1720. HRESULT DATA_SRV_IP::UseDefaults(LPCTSTR pServerName, BOOL fNT4)
  1721. {
  1722. HRESULT hr = hrOK;
  1723. m_fNT4 = fNT4;
  1724. m_stServerName = pServerName;
  1725. m_regkey.Close();
  1726. hr = m_regkey.Open(HKEY_LOCAL_MACHINE,
  1727. c_szRegKeyRasIp,
  1728. KEY_ALL_ACCESS,
  1729. pServerName);
  1730. GetDefault();
  1731. m_dwOldAllowNetworkAccess = m_dwAllowNetworkAccess;
  1732. m_dwOldEnableNetbtBcastFwd = m_dwEnableNetbtBcastFwd;
  1733. m_stPublicAdapterGUID.Empty();
  1734. //Error:
  1735. return hr;
  1736. }
  1737. /*!--------------------------------------------------------------------------
  1738. DATA_SRV_IP::SaveToReg
  1739. -
  1740. Author: KennT
  1741. ---------------------------------------------------------------------------*/
  1742. HRESULT DATA_SRV_IP::SaveToReg(IRouterInfo *pRouter,
  1743. const RouterVersionInfo& routerVersion)
  1744. {
  1745. HRESULT hr = hrOK;
  1746. if ( m_fNT4 )
  1747. CWRg( m_regkeyNT4.SetValue(c_szRegValTcpIpAllowed, m_dwAllowNetworkAccess) );
  1748. else
  1749. CWRg(m_regkey.SetValue( c_szRegValAllowNetAccess, m_dwAllowNetworkAccess));
  1750. CWRg( m_regkey.SetValue( c_szRegValDhcpAddressing, m_dwUseDhcp) );
  1751. m_addressPoolList.SaveToReg(m_regkey, routerVersion.dwOsBuildNo);
  1752. CWRg( m_regkey.SetValue( c_szRegValNetworkAdapterGUID, (LPCTSTR) m_stNetworkAdapterGUID) );
  1753. CWRg( m_regkey.SetValue( c_szRegValEnableIn,m_dwEnableIn ) );
  1754. CWRg( m_regkey.SetValue( c_szRegValEnableNetbtBcastFwd, m_dwEnableNetbtBcastFwd ) );
  1755. if (m_dwAllowNetworkAccess != m_dwOldAllowNetworkAccess)
  1756. {
  1757. // We need to change the registry keys appropriately
  1758. // and do the proper notifications.
  1759. if (m_dwAllowNetworkAccess)
  1760. {
  1761. InstallGlobalSettings((LPCTSTR) m_stServerName,
  1762. pRouter);
  1763. }
  1764. else
  1765. {
  1766. UninstallGlobalSettings((LPCTSTR) m_stServerName,
  1767. pRouter,
  1768. m_fNT4,
  1769. FALSE /* fSnapinChanges */);
  1770. }
  1771. }
  1772. m_dwOldAllowNetworkAccess = m_dwAllowNetworkAccess;
  1773. m_dwOldEnableNetbtBcastFwd = m_dwEnableNetbtBcastFwd;
  1774. Error:
  1775. return hr;
  1776. }
  1777. /*!--------------------------------------------------------------------------
  1778. DATA_SRV_IP::GetDefault
  1779. -
  1780. Author: KennT
  1781. ---------------------------------------------------------------------------*/
  1782. void DATA_SRV_IP::GetDefault()
  1783. {
  1784. m_dwAllowNetworkAccess = TRUE;
  1785. m_dwOldAllowNetworkAccess = TRUE;
  1786. m_dwUseDhcp = TRUE;
  1787. m_dwEnableIn = TRUE;
  1788. m_dwOldEnableNetbtBcastFwd = TRUE;
  1789. m_dwEnableNetbtBcastFwd = TRUE;
  1790. m_addressPoolList.RemoveAll();
  1791. };
  1792. /*!--------------------------------------------------------------------------
  1793. DATA_SRV_IP::FNeedRestart
  1794. Returns TRUE if a restart is needed.
  1795. Returns FALSE otherwise.
  1796. Author: KennT
  1797. ---------------------------------------------------------------------------*/
  1798. BOOL DATA_SRV_IP::FNeedRestart()
  1799. {
  1800. // we need to do this check ONLY on recent builds
  1801. // Otherwise, we need to do this.
  1802. // ----------------------------------------------------------------
  1803. if (m_routerVersion.dwOsBuildNo <= USE_IPENABLEROUTER_VERSION)
  1804. {
  1805. // We need a restart only if the dwAllowNetworkAccess flag
  1806. // was toggled.
  1807. // ----------------------------------------------------------------
  1808. return (m_dwAllowNetworkAccess != m_dwOldAllowNetworkAccess);
  1809. }
  1810. else
  1811. {
  1812. return ( m_dwOldEnableNetbtBcastFwd != m_dwEnableNetbtBcastFwd );
  1813. // (Awaiting the signal from vijay/amritansh)
  1814. // A restart is no longer needed, now that the router will call
  1815. // the EnableRouter function.
  1816. // return FALSE;
  1817. }
  1818. }
  1819. typedef DWORD (WINAPI* PGETADAPTERSINFO)(PIP_ADAPTER_INFO, PULONG);
  1820. HRESULT DATA_SRV_IP::LoadAdapters(IRouterInfo *pRouter, AdapterList *pAdapterList)
  1821. {
  1822. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1823. AdapterData data;
  1824. SPIInterfaceInfo spIf;
  1825. SPIEnumInterfaceInfo spEnumIf;
  1826. HRESULT hr = hrOK;
  1827. data.m_stGuid = _T("");
  1828. data.m_stFriendlyName.LoadString(IDS_DEFAULT_ADAPTER);
  1829. pAdapterList->AddTail(data);
  1830. pRouter->EnumInterface(&spEnumIf);
  1831. for (;spEnumIf->Next(1, &spIf, NULL) == hrOK; spIf.Release())
  1832. {
  1833. if (spIf->GetInterfaceType() == ROUTER_IF_TYPE_DEDICATED)
  1834. {
  1835. // Windows NT Bug : ?
  1836. // Need to filter out the non-IP adapters
  1837. if (spIf->FindRtrMgrInterface(PID_IP, NULL) == hrOK)
  1838. {
  1839. data.m_stFriendlyName = spIf->GetTitle();
  1840. data.m_stGuid = spIf->GetId();
  1841. pAdapterList->AddTail(data);
  1842. }
  1843. }
  1844. }
  1845. return hr;
  1846. }
  1847. //------------------------------------------------------------------------
  1848. // DATA_SRV_IPX
  1849. //------------------------------------------------------------------------
  1850. DATA_SRV_IPX::DATA_SRV_IPX()
  1851. {
  1852. GetDefault();
  1853. }
  1854. // IPX network numbers are shown in hex.
  1855. //
  1856. const int DATA_SRV_IPX::mc_nIpxNetNumRadix = 16;
  1857. HRESULT DATA_SRV_IPX::LoadFromReg (LPCTSTR pServerName /*=NULL*/, BOOL fNT4 /*=FALSE*/)
  1858. {
  1859. HRESULT hr = hrOK;
  1860. m_fNT4=fNT4;
  1861. m_regkey.Close();
  1862. m_regkeyNT4.Close();
  1863. if ( ERROR_SUCCESS == m_regkey.Open(HKEY_LOCAL_MACHINE,c_szRegKeyRasIpx,KEY_ALL_ACCESS, pServerName) )
  1864. {
  1865. if ( m_fNT4 )
  1866. {
  1867. if ( ERROR_SUCCESS == m_regkeyNT4.Open(HKEY_LOCAL_MACHINE,c_szRegKeyRasProtocols,KEY_ALL_ACCESS,pServerName) )
  1868. m_regkeyNT4.QueryValue( c_szRegValIpxAllowed, m_dwAllowNetworkAccess);
  1869. }
  1870. else
  1871. {
  1872. m_regkey.QueryValue( c_szRegValAllowNetAccess, m_dwAllowNetworkAccess);
  1873. }
  1874. m_regkey.QueryValue( c_szRegValAutoWanNet, m_dwUseAutoAddr);
  1875. m_regkey.QueryValue( c_szRegValGlobalWanNet, m_dwUseSameNetNum);
  1876. m_regkey.QueryValue( c_szRegValRemoteNode, m_dwAllowClientNetNum);
  1877. m_regkey.QueryValue( c_szRegValFirstWanNet, m_dwIpxNetFirst);
  1878. // Windows NT Bug : 260262
  1879. // We need to look at the WanNetPoolSize value
  1880. // rather than the LastWanNet value.
  1881. // We've just read in the pool size, now we need to adjust
  1882. // the last value.
  1883. // last = first + size - 1;
  1884. // ------------------------------------------------------------
  1885. if (m_regkey.QueryValue( c_szRegValWanNetPoolSize, m_dwIpxNetLast) == ERROR_SUCCESS)
  1886. {
  1887. m_dwIpxNetLast += (m_dwIpxNetFirst - 1);
  1888. }
  1889. else
  1890. {
  1891. // If there is no key, assume a pool size of 1.
  1892. // --------------------------------------------------------
  1893. m_dwIpxNetLast = m_dwIpxNetFirst;
  1894. }
  1895. m_regkey.QueryValue( c_szRegValEnableIn, m_dwEnableIn);
  1896. }
  1897. return hr;
  1898. }
  1899. /*!--------------------------------------------------------------------------
  1900. DATA_SRV_IPX::UseDefaults
  1901. -
  1902. Author: KennT
  1903. ---------------------------------------------------------------------------*/
  1904. HRESULT DATA_SRV_IPX::UseDefaults(LPCTSTR pServerName, BOOL fNT4)
  1905. {
  1906. HRESULT hr = hrOK;
  1907. m_fNT4 = fNT4;
  1908. m_regkey.Close();
  1909. m_regkeyNT4.Close();
  1910. CWRg( m_regkey.Open(HKEY_LOCAL_MACHINE,
  1911. c_szRegKeyRasIpx,
  1912. KEY_ALL_ACCESS,
  1913. pServerName) );
  1914. if ( m_fNT4 )
  1915. {
  1916. CWRg( m_regkeyNT4.Open(HKEY_LOCAL_MACHINE,
  1917. c_szRegKeyRasProtocols,
  1918. KEY_ALL_ACCESS,
  1919. pServerName) );
  1920. }
  1921. GetDefault();
  1922. Error:
  1923. return hr;
  1924. }
  1925. HRESULT DATA_SRV_IPX::SaveToReg (IRouterInfo *pRouter)
  1926. {
  1927. HRESULT hr = hrOK;
  1928. DWORD dwTemp;
  1929. SPIEnumInterfaceInfo spEnumIf;
  1930. SPIInterfaceInfo spIf;
  1931. SPIRtrMgrInterfaceInfo spRmIf;
  1932. SPIInfoBase spInfoBase;
  1933. IPX_IF_INFO * pIpxIf = NULL;
  1934. if ( m_fNT4 )
  1935. CWRg( m_regkeyNT4.SetValue( c_szRegValIpxAllowed, m_dwAllowNetworkAccess) );
  1936. else
  1937. CWRg( m_regkey.SetValue( c_szRegValAllowNetAccess, m_dwAllowNetworkAccess) );
  1938. CWRg( m_regkey.SetValue( c_szRegValAutoWanNet, m_dwUseAutoAddr) );
  1939. CWRg( m_regkey.SetValue( c_szRegValGlobalWanNet, m_dwUseSameNetNum) );
  1940. CWRg( m_regkey.SetValue( c_szRegValRemoteNode, m_dwAllowClientNetNum) );
  1941. CWRg( m_regkey.SetValue( c_szRegValFirstWanNet, m_dwIpxNetFirst) );
  1942. // Windows NT Bug : 260262
  1943. // We need to look at the WanNetPoolSize value
  1944. // rather than the LastWanNet value.
  1945. dwTemp = m_dwIpxNetLast - m_dwIpxNetFirst + 1;
  1946. CWRg( m_regkey.SetValue( c_szRegValWanNetPoolSize, dwTemp ) );
  1947. CWRg( m_regkey.SetValue( c_szRegValEnableIn, m_dwEnableIn) );
  1948. // Windows NT Bug : 281100
  1949. // If the pRouter argument is non-NULL, then we will set the
  1950. // interfaces up for Type20 broadcast.
  1951. // Optimization! The only time this case should get invoked is
  1952. // upon initial configuration. In that case, the default is
  1953. // ADMIN_STATE_ENABLED and we do not need to run this code!
  1954. // ----------------------------------------------------------------
  1955. if (pRouter && (m_fEnableType20Broadcasts == FALSE))
  1956. {
  1957. pRouter->EnumInterface(&spEnumIf);
  1958. for (spEnumIf->Reset();
  1959. spEnumIf->Next(1, &spIf, NULL) == hrOK;
  1960. spIf.Release())
  1961. {
  1962. if (spIf->GetInterfaceType() != ROUTER_IF_TYPE_DEDICATED)
  1963. continue;
  1964. // Now look for IPX
  1965. // ------------------------------------------------------------
  1966. spRmIf.Release();
  1967. if (FHrOK(spIf->FindRtrMgrInterface(PID_IPX, &spRmIf)))
  1968. {
  1969. spInfoBase.Release();
  1970. if (spRmIf->GetInfoBase(NULL, NULL, NULL, &spInfoBase) != hrOK)
  1971. continue;
  1972. spInfoBase->GetData(IPX_INTERFACE_INFO_TYPE, 0, (PBYTE *) &pIpxIf);
  1973. if (pIpxIf == NULL)
  1974. {
  1975. IPX_IF_INFO ipx;
  1976. ipx.AdminState = ADMIN_STATE_ENABLED;
  1977. ipx.NetbiosAccept = ADMIN_STATE_DISABLED;
  1978. ipx.NetbiosDeliver = ADMIN_STATE_DISABLED;
  1979. // We couldn't find a block for this interface,
  1980. // we need to add a block.
  1981. // ------------------------------------------------
  1982. spInfoBase->AddBlock(IPX_INTERFACE_INFO_TYPE,
  1983. sizeof(ipx),
  1984. (PBYTE) &ipx,
  1985. 1 /* count */,
  1986. FALSE /* bRemoveFirst */);
  1987. }
  1988. else
  1989. {
  1990. pIpxIf->NetbiosDeliver = ADMIN_STATE_DISABLED;
  1991. }
  1992. spRmIf->Save(spIf->GetMachineName(),
  1993. NULL, NULL, NULL, spInfoBase, 0);
  1994. }
  1995. }
  1996. }
  1997. Error:
  1998. return hr;
  1999. }
  2000. void DATA_SRV_IPX::GetDefault ()
  2001. {
  2002. m_dwAllowNetworkAccess = TRUE;
  2003. m_dwUseAutoAddr = TRUE;
  2004. m_dwUseSameNetNum = TRUE;
  2005. m_dwAllowClientNetNum = FALSE;
  2006. m_dwIpxNetFirst = 0;
  2007. m_dwIpxNetLast = 0;
  2008. m_dwEnableIn = 0;
  2009. // The default is TRUE so that the code to set it won't be run
  2010. // by default. This is especially important for the Router
  2011. // properties.
  2012. // ----------------------------------------------------------------
  2013. m_fEnableType20Broadcasts = TRUE;
  2014. };
  2015. //------------------------------------------------------------------------
  2016. // DATA_SRV_NBF
  2017. //------------------------------------------------------------------------
  2018. DATA_SRV_NBF::DATA_SRV_NBF()
  2019. {
  2020. GetDefault();
  2021. }
  2022. /*!--------------------------------------------------------------------------
  2023. DATA_SRV_NBF::LoadFromReg
  2024. -
  2025. Author: KennT
  2026. ---------------------------------------------------------------------------*/
  2027. HRESULT DATA_SRV_NBF::LoadFromReg(LPCTSTR pServerName /*=NULL*/, BOOL fNT4 /*=FALSE*/)
  2028. {
  2029. HRESULT hr = hrOK;
  2030. m_fNT4 = fNT4;
  2031. m_stServerName = pServerName;
  2032. m_regkey.Close();
  2033. m_regkeyNT4.Close();
  2034. // Get Access to the base NBF key
  2035. // ----------------------------------------------------------------
  2036. CWRg( m_regkey.Open(HKEY_LOCAL_MACHINE, c_szRegKeyRasNbf, KEY_ALL_ACCESS,
  2037. pServerName) );
  2038. if ( m_fNT4 )
  2039. {
  2040. if ( ERROR_SUCCESS == m_regkeyNT4.Open(HKEY_LOCAL_MACHINE,c_szRegKeyRasProtocols,KEY_ALL_ACCESS,pServerName) )
  2041. m_regkeyNT4.QueryValue( c_szRegValNetBeuiAllowed, m_dwAllowNetworkAccess);
  2042. }
  2043. else
  2044. {
  2045. m_regkey.QueryValue( c_szRegValAllowNetAccess, m_dwAllowNetworkAccess);
  2046. }
  2047. m_dwOldAllowNetworkAccess = m_dwAllowNetworkAccess;
  2048. m_regkey.QueryValue( c_szRegValEnableIn, m_dwEnableIn);
  2049. m_dwOldEnableIn = m_dwEnableIn;
  2050. Error:
  2051. return hr;
  2052. }
  2053. /*!--------------------------------------------------------------------------
  2054. DATA_SRV_NBF::UseDefaults
  2055. -
  2056. Author: KennT
  2057. ---------------------------------------------------------------------------*/
  2058. HRESULT DATA_SRV_NBF::UseDefaults(LPCTSTR pServerName, BOOL fNT4)
  2059. {
  2060. HRESULT hr = hrOK;
  2061. m_fNT4 = fNT4;
  2062. m_stServerName = pServerName;
  2063. m_regkey.Close();
  2064. m_regkeyNT4.Close();
  2065. // Get Access to the base NBF key
  2066. // ----------------------------------------------------------------
  2067. CWRg( m_regkey.Open(HKEY_LOCAL_MACHINE, c_szRegKeyRasNbf, KEY_ALL_ACCESS,
  2068. pServerName) );
  2069. if ( m_fNT4 )
  2070. {
  2071. CWRg( m_regkeyNT4.Open(HKEY_LOCAL_MACHINE,
  2072. c_szRegKeyRasProtocols,
  2073. KEY_ALL_ACCESS,
  2074. pServerName) );
  2075. }
  2076. GetDefault();
  2077. m_dwOldEnableIn = m_dwEnableIn;
  2078. m_dwOldAllowNetworkAccess = m_dwAllowNetworkAccess;
  2079. Error:
  2080. return hr;
  2081. }
  2082. /*!--------------------------------------------------------------------------
  2083. DATA_SRV_NBF::SaveToReg
  2084. -
  2085. Author: KennT
  2086. ---------------------------------------------------------------------------*/
  2087. HRESULT DATA_SRV_NBF::SaveToReg()
  2088. {
  2089. HRESULT hr = hrOK;
  2090. if ( m_fNT4 )
  2091. CWRg( m_regkeyNT4.SetValue( c_szRegValNetBeuiAllowed, m_dwAllowNetworkAccess) );
  2092. else
  2093. CWRg( m_regkey.SetValue( c_szRegValAllowNetAccess, m_dwAllowNetworkAccess) );
  2094. m_dwOldAllowNetworkAccess = m_dwAllowNetworkAccess;
  2095. CWRg( m_regkey.SetValue( c_szRegValEnableIn, m_dwEnableIn) );
  2096. m_dwOldEnableIn = m_dwEnableIn;
  2097. // Windows NT Bug: 106486
  2098. // Update the NetBIOS LANA map when we toggle the config
  2099. // ----------------------------------------------------------------
  2100. UpdateLanaMapForDialinClients(m_stServerName, m_dwAllowNetworkAccess);
  2101. Error:
  2102. return hr;
  2103. }
  2104. /*!--------------------------------------------------------------------------
  2105. DATA_SRV_NBF::GetDefault
  2106. -
  2107. Author: KennT
  2108. ---------------------------------------------------------------------------*/
  2109. void DATA_SRV_NBF::GetDefault()
  2110. {
  2111. m_dwAllowNetworkAccess = TRUE;
  2112. m_dwOldAllowNetworkAccess = m_dwAllowNetworkAccess;
  2113. m_dwEnableIn = TRUE;
  2114. m_dwOldEnableIn = m_dwEnableIn;
  2115. };
  2116. /*!--------------------------------------------------------------------------
  2117. DATA_SRV_NBF::FNeedRestart
  2118. -
  2119. Author: KennT
  2120. ---------------------------------------------------------------------------*/
  2121. BOOL DATA_SRV_NBF::FNeedRestart()
  2122. {
  2123. return ((m_dwOldEnableIn != m_dwEnableIn) ||
  2124. (m_dwOldAllowNetworkAccess != m_dwAllowNetworkAccess));
  2125. }
  2126. //------------------------------------------------------------------------
  2127. // DATA_SRV_ARAP
  2128. //------------------------------------------------------------------------
  2129. DATA_SRV_ARAP::DATA_SRV_ARAP()
  2130. {
  2131. GetDefault();
  2132. }
  2133. HRESULT DATA_SRV_ARAP::LoadFromReg(LPCTSTR pServerName /*=NULL*/, BOOL fNT4 /*=FALSE*/)
  2134. {
  2135. HRESULT hr = hrOK;
  2136. if ( ERROR_SUCCESS == m_regkey.Open(HKEY_LOCAL_MACHINE,c_szRegKeyRasAppletalk,KEY_ALL_ACCESS,pServerName) )
  2137. {
  2138. m_regkey.QueryValue( c_szRegValEnableIn,m_dwEnableIn);
  2139. }
  2140. return hr;
  2141. }
  2142. /*!--------------------------------------------------------------------------
  2143. DATA_SRV_ARAP::UseDefaults
  2144. -
  2145. Author: KennT
  2146. ---------------------------------------------------------------------------*/
  2147. HRESULT DATA_SRV_ARAP::UseDefaults(LPCTSTR pServerName, BOOL fNT4)
  2148. {
  2149. HRESULT hr = hrOK;
  2150. CWRg( m_regkey.Open(HKEY_LOCAL_MACHINE,
  2151. c_szRegKeyRasAppletalk,
  2152. KEY_ALL_ACCESS,
  2153. pServerName) );
  2154. GetDefault();
  2155. Error:
  2156. return hr;
  2157. }
  2158. HRESULT DATA_SRV_ARAP::SaveToReg()
  2159. {
  2160. HRESULT hr = hrOK;
  2161. CWRg( m_regkey.SetValue( c_szRegValEnableIn,m_dwEnableIn) );
  2162. Error:
  2163. return hr;
  2164. }
  2165. void DATA_SRV_ARAP::GetDefault()
  2166. {
  2167. m_dwEnableIn = TRUE;
  2168. };
  2169. //------------------------------------------------------------------------
  2170. // DATA_SRV_AUTH
  2171. //------------------------------------------------------------------------
  2172. DATA_SRV_AUTH::DATA_SRV_AUTH()
  2173. {
  2174. GetDefault();
  2175. }
  2176. HRESULT DATA_SRV_AUTH::LoadFromReg(LPCTSTR pServerName,
  2177. const RouterVersionInfo& routerVersion)
  2178. {
  2179. HRESULT hr = hrOK;
  2180. RegKey regkeyAuthProv;
  2181. CString stActive;
  2182. AuthProviderData * pAcctProv;
  2183. AuthProviderData * pAuthProv;
  2184. RegKey regkeyEap;
  2185. LPCTSTR pszServerFlagsKey = NULL;
  2186. // Setup initial defaults
  2187. // ----------------------------------------------------------------
  2188. GetDefault();
  2189. m_stServer = pServerName;
  2190. //Check to see if the router service is running
  2191. m_fRouterRunning = FHrOK(IsRouterServiceRunning(m_stServer, NULL));
  2192. // Depending on the version depends on where we look for the
  2193. // key.
  2194. // ----------------------------------------------------------------
  2195. if (routerVersion.dwOsBuildNo < RASMAN_PPP_KEY_LAST_VERSION)
  2196. pszServerFlagsKey = c_szRasmanPPPKey;
  2197. else
  2198. pszServerFlagsKey = c_szRegKeyRemoteAccessParameters;
  2199. // Get the flags for the current settings
  2200. // ----------------------------------------------------------------
  2201. if ( ERROR_SUCCESS == m_regkeyRemoteAccess.Open(HKEY_LOCAL_MACHINE,
  2202. pszServerFlagsKey,
  2203. KEY_ALL_ACCESS,pServerName) )
  2204. {
  2205. m_regkeyRemoteAccess.QueryValue( c_szServerFlags, m_dwFlags );
  2206. }
  2207. // Get the list of EAP providers
  2208. // ----------------------------------------------------------------
  2209. if ( ERROR_SUCCESS == m_regkeyRasmanPPP.Open(HKEY_LOCAL_MACHINE,c_szRasmanPPPKey,KEY_ALL_ACCESS,pServerName) )
  2210. {
  2211. if ( ERROR_SUCCESS == regkeyEap.Open(m_regkeyRasmanPPP, c_szEAP) )
  2212. LoadEapProviders(regkeyEap, &m_eapProvList);
  2213. }
  2214. // Get to the currently active auth provider
  2215. // ----------------------------------------------------------------
  2216. if ( ERROR_SUCCESS == m_regkeyAuth.Open(HKEY_LOCAL_MACHINE,c_szRegKeyRouterAuthenticationProviders,KEY_ALL_ACCESS,pServerName) )
  2217. {
  2218. m_regkeyAuth.QueryValue( c_szActiveProvider, stActive );
  2219. m_stGuidActiveAuthProv = stActive;
  2220. m_stGuidOriginalAuthProv = stActive;
  2221. // Now read in the list of active providers (and their data)
  2222. // ------------------------------------------------------------
  2223. LoadProviders(m_regkeyAuth, &m_authProvList);
  2224. }
  2225. // Get the accounting provider
  2226. // ----------------------------------------------------------------
  2227. if ( ERROR_SUCCESS == m_regkeyAcct.Open(HKEY_LOCAL_MACHINE,c_szRegKeyRouterAccountingProviders,KEY_ALL_ACCESS,pServerName) )
  2228. {
  2229. m_regkeyAcct.QueryValue( c_szActiveProvider, stActive );
  2230. m_stGuidActiveAcctProv = stActive;
  2231. m_stGuidOriginalAcctProv = stActive;
  2232. // Now read in the list of active providers (and their data)
  2233. // ------------------------------------------------------------
  2234. LoadProviders(m_regkeyAcct, &m_acctProvList);
  2235. }
  2236. //Get the preshared key if one is set
  2237. if ( m_fRouterRunning )
  2238. {
  2239. hr = LoadPSK();
  2240. }
  2241. return hr;
  2242. }
  2243. HRESULT DATA_SRV_AUTH::LoadPSK()
  2244. {
  2245. DWORD dwErr = ERROR_SUCCESS;
  2246. HANDLE hMprServer = NULL;
  2247. HRESULT hr = hrOK;
  2248. PMPR_CREDENTIALSEX_0 pMprCredentials = NULL;
  2249. dwErr = ::MprAdminServerConnect((LPWSTR)(LPCWSTR)m_stServer, &hMprServer);
  2250. if ( ERROR_SUCCESS != dwErr )
  2251. {
  2252. hr = HRESULT_FROM_WIN32(dwErr);
  2253. goto Error;
  2254. }
  2255. dwErr = MprAdminServerGetCredentials( hMprServer, 0, (LPBYTE *)&pMprCredentials );
  2256. if ( ERROR_SUCCESS != dwErr )
  2257. {
  2258. hr = HRESULT_FROM_WIN32(dwErr);
  2259. goto Error;
  2260. }
  2261. if ( pMprCredentials->dwSize )
  2262. {
  2263. m_fUseCustomIPSecPolicy = TRUE;
  2264. ZeroMemory ( m_szPreSharedKey, DATA_SRV_AUTH_MAX_SHARED_KEY_LEN * sizeof(TCHAR) );
  2265. CopyMemory ( m_szPreSharedKey, pMprCredentials->lpbCredentialsInfo, pMprCredentials->dwSize );
  2266. }
  2267. else
  2268. {
  2269. m_fUseCustomIPSecPolicy = FALSE;
  2270. m_szPreSharedKey[0] = 0;
  2271. }
  2272. Error:
  2273. if ( pMprCredentials )
  2274. ::MprAdminBufferFree(pMprCredentials);
  2275. if ( hMprServer )
  2276. ::MprAdminServerDisconnect(hMprServer);
  2277. return hr;
  2278. }
  2279. HRESULT DATA_SRV_AUTH::SetPSK()
  2280. {
  2281. DWORD dwErr = ERROR_SUCCESS;
  2282. HANDLE hMprServer = NULL;
  2283. HRESULT hr = hrOK;
  2284. MPR_CREDENTIALSEX_0 MprCredentials;
  2285. dwErr = ::MprAdminServerConnect((LPWSTR)(LPCWSTR) m_stServer, &hMprServer);
  2286. if ( ERROR_SUCCESS != dwErr )
  2287. {
  2288. hr = HRESULT_FROM_WIN32(dwErr);
  2289. goto Error;
  2290. }
  2291. ZeroMemory(&MprCredentials, sizeof(MprCredentials));
  2292. //Setup the MprCredentials structure
  2293. MprCredentials.dwSize = _tcslen(m_szPreSharedKey) * sizeof(TCHAR);
  2294. MprCredentials.lpbCredentialsInfo = (LPBYTE)m_szPreSharedKey;
  2295. //irrespective of whether the flag is set, we need to set the credentials.
  2296. dwErr = MprAdminServerSetCredentials( hMprServer, 0, (LPBYTE)&MprCredentials );
  2297. if ( ERROR_SUCCESS != dwErr )
  2298. {
  2299. if ( ERROR_IPSEC_MM_AUTH_IN_USE == dwErr )
  2300. {
  2301. //Special case. This means that IPSEC is currently using the
  2302. //psk and we need to restart rras to let IPSEC re-pickup the PSK
  2303. //Show a message to this effect.
  2304. AfxMessageBox(IDS_RESTART_RRAS_PSK, MB_OK|MB_ICONINFORMATION);
  2305. }
  2306. else
  2307. {
  2308. hr = HRESULT_FROM_WIN32(dwErr);
  2309. goto Error;
  2310. }
  2311. }
  2312. Error:
  2313. if ( hMprServer )
  2314. ::MprAdminServerDisconnect(hMprServer);
  2315. return hr;
  2316. }
  2317. /*!--------------------------------------------------------------------------
  2318. DATA_SRV_AUTH::SaveToReg
  2319. -
  2320. Author: KennT
  2321. ---------------------------------------------------------------------------*/
  2322. // This is the list of flags that we use
  2323. #define PPPPAGE_MASK (PPPCFG_NegotiateMultilink | PPPCFG_NegotiateBacp | PPPCFG_UseLcpExtensions | PPPCFG_UseSwCompression)
  2324. HRESULT DATA_SRV_AUTH::SaveToReg(HWND hWnd)
  2325. {
  2326. HRESULT hr = hrOK;
  2327. DWORD dwFlags;
  2328. // Save the flags key
  2329. // ----------------------------------------------------------------
  2330. // Reread the key so that any changes made to the key by the
  2331. // PPP page don't get overwritten
  2332. // ----------------------------------------------------------------
  2333. m_regkeyRemoteAccess.QueryValue(c_szServerFlags, dwFlags);
  2334. // Apply whatever settings are in the PPP key to the m_dwFlags
  2335. // ----------------------------------------------------------------
  2336. // Clear the bits
  2337. // ----------------------------------------------------------------
  2338. m_dwFlags &= ~PPPPAGE_MASK;
  2339. // Now reset the bits
  2340. // ----------------------------------------------------------------
  2341. m_dwFlags |= (dwFlags & PPPPAGE_MASK);
  2342. m_regkeyRemoteAccess.SetValue( c_szServerFlags, m_dwFlags );
  2343. CORg( SetNewActiveAuthProvider(hWnd) );
  2344. CORg( SetNewActiveAcctProvider(hWnd) );
  2345. if ( m_fRouterRunning )
  2346. CORg( SetPSK() );
  2347. Error:
  2348. return hr;
  2349. }
  2350. void DATA_SRV_AUTH::GetDefault()
  2351. {
  2352. TCHAR szGuid[DATA_SRV_AUTH_MAX_SHARED_KEY_LEN];
  2353. m_dwFlags = 0;
  2354. m_stGuidActiveAuthProv.Empty();
  2355. m_stGuidActiveAcctProv.Empty();
  2356. m_stGuidOriginalAuthProv.Empty();
  2357. m_stGuidOriginalAcctProv.Empty();
  2358. // Default is Windows NT Authentication
  2359. StringFromGUID2(CLSID_RouterAuthNT, szGuid, DimensionOf(szGuid));
  2360. m_stGuidActiveAuthProv = szGuid;
  2361. // Default is Windows NT Accounting
  2362. StringFromGUID2(CLSID_RouterAcctNT, szGuid, DimensionOf(szGuid));
  2363. m_stGuidActiveAcctProv = szGuid;
  2364. //By default the router is not running
  2365. m_fRouterRunning = FALSE;
  2366. m_stServer.Empty();
  2367. m_fUseCustomIPSecPolicy = FALSE;
  2368. m_szPreSharedKey[0] = 0;
  2369. };
  2370. HRESULT DATA_SRV_AUTH::UseDefaults(LPCTSTR pServerName, BOOL fNT4)
  2371. {
  2372. HRESULT hr = hrOK;
  2373. LPCTSTR pszServerFlagsKey = NULL;
  2374. RegKey regkeyEap;
  2375. CString stActive;
  2376. m_stServer = pServerName;
  2377. // Depending on the version depends on where we look for the
  2378. // key.
  2379. // ----------------------------------------------------------------
  2380. if (fNT4)
  2381. pszServerFlagsKey = c_szRasmanPPPKey;
  2382. else
  2383. pszServerFlagsKey = c_szRegKeyRemoteAccessParameters;
  2384. // Get the various registry keys.
  2385. // ----------------------------------------------------------------
  2386. CWRg( m_regkeyRemoteAccess.Open(HKEY_LOCAL_MACHINE,
  2387. pszServerFlagsKey,
  2388. KEY_ALL_ACCESS,pServerName) );
  2389. // Get the list of EAP providers
  2390. // ----------------------------------------------------------------
  2391. if ( ERROR_SUCCESS == m_regkeyRasmanPPP.Open(HKEY_LOCAL_MACHINE,c_szRasmanPPPKey,KEY_ALL_ACCESS,pServerName) )
  2392. {
  2393. if ( ERROR_SUCCESS == regkeyEap.Open(m_regkeyRasmanPPP, c_szEAP) )
  2394. LoadEapProviders(regkeyEap, &m_eapProvList);
  2395. }
  2396. // Get to the currently active auth provider
  2397. // ----------------------------------------------------------------
  2398. if ( ERROR_SUCCESS == m_regkeyAuth.Open(HKEY_LOCAL_MACHINE,c_szRegKeyRouterAuthenticationProviders,KEY_ALL_ACCESS,pServerName) )
  2399. {
  2400. m_regkeyAuth.QueryValue( c_szActiveProvider, stActive );
  2401. m_stGuidActiveAuthProv = stActive;
  2402. m_stGuidOriginalAuthProv = stActive;
  2403. m_authProvList.RemoveAll();
  2404. // Now read in the list of active providers (and their data)
  2405. // ------------------------------------------------------------
  2406. LoadProviders(m_regkeyAuth, &m_authProvList);
  2407. }
  2408. // Get the accounting provider
  2409. // ----------------------------------------------------------------
  2410. if ( ERROR_SUCCESS == m_regkeyAcct.Open(HKEY_LOCAL_MACHINE,c_szRegKeyRouterAccountingProviders,KEY_ALL_ACCESS,pServerName) )
  2411. {
  2412. m_regkeyAcct.QueryValue( c_szActiveProvider, stActive );
  2413. m_stGuidActiveAcctProv = stActive;
  2414. m_stGuidOriginalAcctProv = stActive;
  2415. m_acctProvList.RemoveAll();
  2416. // Now read in the list of active providers (and their data)
  2417. // ------------------------------------------------------------
  2418. LoadProviders(m_regkeyAcct, &m_acctProvList);
  2419. }
  2420. // Now get the defaults
  2421. // This may overwrite some of the previous data.
  2422. // ----------------------------------------------------------------
  2423. GetDefault();
  2424. Error:
  2425. return hr;
  2426. }
  2427. /*!--------------------------------------------------------------------------
  2428. DATA_SRV_AUTH::LoadProviders
  2429. Load the data for a given provider type (accounting/authentication).
  2430. Author: KennT
  2431. ---------------------------------------------------------------------------*/
  2432. HRESULT DATA_SRV_AUTH::LoadProviders(HKEY hkeyBase, AuthProviderList *pProvList)
  2433. {
  2434. RegKey regkeyProviders;
  2435. HRESULT hr = hrOK;
  2436. HRESULT hrIter;
  2437. RegKeyIterator regkeyIter;
  2438. CString stKey;
  2439. RegKey regkeyProv;
  2440. AuthProviderData data;
  2441. DWORD dwErr;
  2442. Assert(hkeyBase);
  2443. Assert(pProvList);
  2444. // Open the providers key
  2445. // ----------------------------------------------------------------
  2446. regkeyProviders.Attach(hkeyBase);
  2447. CORg( regkeyIter.Init(&regkeyProviders) );
  2448. for ( hrIter=regkeyIter.Next(&stKey); hrIter == hrOK;
  2449. hrIter=regkeyIter.Next(&stKey), regkeyProv.Close() )
  2450. {
  2451. // Open the key
  2452. // ------------------------------------------------------------
  2453. dwErr = regkeyProv.Open(regkeyProviders, stKey, KEY_READ);
  2454. if ( dwErr != ERROR_SUCCESS )
  2455. continue;
  2456. // Initialize the data structure
  2457. // ------------------------------------------------------------
  2458. data.m_stTitle.Empty();
  2459. data.m_stConfigCLSID.Empty();
  2460. data.m_stProviderTypeGUID.Empty();
  2461. data.m_stGuid.Empty();
  2462. data.m_fSupportsEncryption = FALSE;
  2463. data.m_fConfiguredInThisSession = FALSE;
  2464. // Read in the values that we require
  2465. // ------------------------------------------------------------
  2466. data.m_stGuid = stKey;
  2467. regkeyProv.QueryValue(c_szDisplayName, data.m_stTitle);
  2468. regkeyProv.QueryValue(c_szConfigCLSID, data.m_stConfigCLSID);
  2469. regkeyProv.QueryValue(c_szProviderTypeGUID, data.m_stProviderTypeGUID);
  2470. pProvList->AddTail(data);
  2471. }
  2472. Error:
  2473. regkeyProviders.Detach();
  2474. return hr;
  2475. }
  2476. /*!--------------------------------------------------------------------------
  2477. DATA_SRV_AUTH::LoadEapProviders
  2478. -
  2479. Author: KennT
  2480. ---------------------------------------------------------------------------*/
  2481. HRESULT DATA_SRV_AUTH::LoadEapProviders(HKEY hkeyBase, AuthProviderList *pProvList)
  2482. {
  2483. RegKey regkeyProviders;
  2484. HRESULT hr = hrOK;
  2485. HRESULT hrIter;
  2486. RegKeyIterator regkeyIter;
  2487. CString stKey;
  2488. RegKey regkeyProv;
  2489. AuthProviderData data;
  2490. DWORD dwErr;
  2491. DWORD dwData;
  2492. Assert(hkeyBase);
  2493. Assert(pProvList);
  2494. // Open the providers key
  2495. // ----------------------------------------------------------------
  2496. regkeyProviders.Attach(hkeyBase);
  2497. CORg( regkeyIter.Init(&regkeyProviders) );
  2498. for ( hrIter=regkeyIter.Next(&stKey); hrIter == hrOK;
  2499. hrIter=regkeyIter.Next(&stKey), regkeyProv.Close() )
  2500. {
  2501. // Open the key
  2502. // ------------------------------------------------------------
  2503. dwErr = regkeyProv.Open(regkeyProviders, stKey, KEY_READ);
  2504. if ( dwErr != ERROR_SUCCESS )
  2505. continue;
  2506. // Initialize the data structure
  2507. // ------------------------------------------------------------
  2508. data.m_stKey = stKey;
  2509. data.m_stTitle.Empty();
  2510. data.m_stConfigCLSID.Empty();
  2511. data.m_stGuid.Empty();
  2512. data.m_fSupportsEncryption = FALSE;
  2513. data.m_dwFlags = 0;
  2514. // Read in the values that we require
  2515. // ------------------------------------------------------------
  2516. regkeyProv.QueryValue(c_szFriendlyName, data.m_stTitle);
  2517. regkeyProv.QueryValue(c_szConfigCLSID, data.m_stConfigCLSID);
  2518. regkeyProv.QueryValue(c_szMPPEEncryptionSupported, dwData);
  2519. data.m_fSupportsEncryption = (dwData != 0);
  2520. // Read in the standalone supported value.
  2521. // ------------------------------------------------------------
  2522. if (!FHrOK(regkeyProv.QueryValue(c_szStandaloneSupported, dwData)))
  2523. dwData = 1; // the default
  2524. data.m_dwFlags = dwData;
  2525. pProvList->AddTail(data);
  2526. }
  2527. Error:
  2528. regkeyProviders.Detach();
  2529. return hr;
  2530. }
  2531. /*!--------------------------------------------------------------------------
  2532. DATA_SRV_AUTH::SetNewActiveAuthProvider
  2533. -
  2534. Author: KennT
  2535. ---------------------------------------------------------------------------*/
  2536. HRESULT DATA_SRV_AUTH::SetNewActiveAuthProvider(HWND hWnd)
  2537. {
  2538. GUID guid;
  2539. HRESULT hr = hrOK;
  2540. SPIAuthenticationProviderConfig spAuthConfigOld;
  2541. SPIAuthenticationProviderConfig spAuthConfigNew;
  2542. AuthProviderData * pData;
  2543. ULONG_PTR uConnectionNew = 0;
  2544. ULONG_PTR uConnectionOld = 0;
  2545. if ( m_stGuidOriginalAuthProv == m_stGuidActiveAuthProv )
  2546. return hrOK;
  2547. // Create an instance of the old auth provider
  2548. // ----------------------------------------------------------------
  2549. if ( !m_stGuidOriginalAuthProv.IsEmpty() )
  2550. {
  2551. pData = FindProvData(m_authProvList,
  2552. m_stGuidOriginalAuthProv);
  2553. //$ TODO : need better error handling
  2554. // ------------------------------------------------------------
  2555. if ( pData == NULL )
  2556. CORg( E_FAIL );
  2557. if ( !pData->m_stConfigCLSID.IsEmpty() )
  2558. {
  2559. CORg( CLSIDFromString((LPTSTR) (LPCTSTR)(pData->m_stConfigCLSID),
  2560. &guid) );
  2561. CORg( CoCreateInstance(guid,
  2562. NULL,
  2563. CLSCTX_INPROC_SERVER | CLSCTX_ENABLE_CODE_DOWNLOAD,
  2564. IID_IAuthenticationProviderConfig,
  2565. (LPVOID *) &spAuthConfigOld) );
  2566. Assert(spAuthConfigOld);
  2567. CORg( spAuthConfigOld->Initialize(m_stServer,
  2568. &uConnectionOld) );
  2569. }
  2570. }
  2571. // Create an instance of the new auth provider
  2572. // ----------------------------------------------------------------
  2573. if ( !m_stGuidActiveAuthProv.IsEmpty() )
  2574. {
  2575. pData = FindProvData(m_authProvList,
  2576. m_stGuidActiveAuthProv);
  2577. //$ TODO : need better error handling
  2578. // ------------------------------------------------------------
  2579. if ( pData == NULL )
  2580. CORg( E_FAIL );
  2581. if ( !pData->m_stConfigCLSID.IsEmpty() )
  2582. {
  2583. CORg( CLSIDFromString((LPTSTR) (LPCTSTR)(pData->m_stConfigCLSID),
  2584. &guid) );
  2585. CORg( CoCreateInstance(guid,
  2586. NULL,
  2587. CLSCTX_INPROC_SERVER | CLSCTX_ENABLE_CODE_DOWNLOAD,
  2588. IID_IAuthenticationProviderConfig,
  2589. (LPVOID *) &spAuthConfigNew) );
  2590. Assert(spAuthConfigNew);
  2591. CORg( spAuthConfigNew->Initialize(m_stServer, &uConnectionNew) );
  2592. }
  2593. }
  2594. // Deactivate the current auth provider
  2595. //$ TODO : need to enhance the error reporting
  2596. // ----------------------------------------------------------------
  2597. if ( spAuthConfigOld )
  2598. CORg( spAuthConfigOld->Deactivate(uConnectionOld, 0, 0) );
  2599. // Set the new GUID in the registry
  2600. // ----------------------------------------------------------------
  2601. m_regkeyAuth.SetValue(c_szActiveProvider, m_stGuidActiveAuthProv);
  2602. m_stGuidOriginalAuthProv = m_stGuidActiveAuthProv;
  2603. // Activate the new auth provider
  2604. // ----------------------------------------------------------------
  2605. if ( spAuthConfigNew )
  2606. CORg( spAuthConfigNew->Activate(uConnectionNew, 0, 0) );
  2607. Error:
  2608. // Cleanup
  2609. if (spAuthConfigOld && uConnectionOld)
  2610. spAuthConfigOld->Uninitialize(uConnectionOld);
  2611. if (spAuthConfigNew && uConnectionNew)
  2612. spAuthConfigNew->Uninitialize(uConnectionNew);
  2613. if ( !FHrSucceeded(hr) )
  2614. Trace1("DATA_SRV_AUTH::SetNewActiveAuthProvider failed. Hr = %lx", hr);
  2615. return hr;
  2616. }
  2617. /*!--------------------------------------------------------------------------
  2618. DATA_SRV_AUTH::SetNewActiveAcctProvider
  2619. -
  2620. Author: KennT
  2621. ---------------------------------------------------------------------------*/
  2622. HRESULT DATA_SRV_AUTH::SetNewActiveAcctProvider(HWND hWnd)
  2623. {
  2624. GUID guid;
  2625. HRESULT hr = hrOK;
  2626. SPIAccountingProviderConfig spAcctConfigOld;
  2627. SPIAccountingProviderConfig spAcctConfigNew;
  2628. AuthProviderData * pData;
  2629. ULONG_PTR uConnectionOld = 0;
  2630. ULONG_PTR uConnectionNew = 0;
  2631. if ( m_stGuidOriginalAcctProv == m_stGuidActiveAcctProv )
  2632. return hrOK;
  2633. // Create an instance of the old Acct provider
  2634. // ----------------------------------------------------------------
  2635. if ( !m_stGuidOriginalAcctProv.IsEmpty() )
  2636. {
  2637. pData = FindProvData(m_acctProvList,
  2638. m_stGuidOriginalAcctProv);
  2639. //$ TODO : need better error handling
  2640. // ------------------------------------------------------------
  2641. if ( pData == NULL )
  2642. CORg( E_FAIL );
  2643. if ( !pData->m_stConfigCLSID.IsEmpty() )
  2644. {
  2645. CORg( CLSIDFromString((LPTSTR) (LPCTSTR)(pData->m_stConfigCLSID),
  2646. &guid) );
  2647. CORg( CoCreateInstance(guid,
  2648. NULL,
  2649. CLSCTX_INPROC_SERVER | CLSCTX_ENABLE_CODE_DOWNLOAD,
  2650. IID_IAccountingProviderConfig,
  2651. (LPVOID *) &spAcctConfigOld) );
  2652. Assert(spAcctConfigOld);
  2653. CORg( spAcctConfigOld->Initialize(m_stServer, &uConnectionOld) );
  2654. }
  2655. }
  2656. // Create an instance of the new Acct provider
  2657. // ----------------------------------------------------------------
  2658. if ( !m_stGuidActiveAcctProv.IsEmpty() )
  2659. {
  2660. pData = FindProvData(m_acctProvList,
  2661. m_stGuidActiveAcctProv);
  2662. //$ TODO : need better error handling
  2663. // ------------------------------------------------------------
  2664. if ( pData == NULL )
  2665. CORg( E_FAIL );
  2666. if ( !pData->m_stConfigCLSID.IsEmpty() )
  2667. {
  2668. CORg( CLSIDFromString((LPTSTR) (LPCTSTR)(pData->m_stConfigCLSID), &guid) );
  2669. CORg( CoCreateInstance(guid,
  2670. NULL,
  2671. CLSCTX_INPROC_SERVER | CLSCTX_ENABLE_CODE_DOWNLOAD,
  2672. IID_IAccountingProviderConfig,
  2673. (LPVOID *) &spAcctConfigNew) );
  2674. Assert(spAcctConfigNew);
  2675. CORg( spAcctConfigNew->Initialize(m_stServer, &uConnectionNew) );
  2676. }
  2677. }
  2678. // Deactivate the current Acct provider
  2679. //$ TODO : need to enhance the error reporting
  2680. // ----------------------------------------------------------------
  2681. if ( spAcctConfigOld )
  2682. CORg( spAcctConfigOld->Deactivate(uConnectionOld, 0, 0) );
  2683. // Set the new GUID in the registry
  2684. // ----------------------------------------------------------------
  2685. m_regkeyAcct.SetValue(c_szActiveProvider, m_stGuidActiveAcctProv);
  2686. m_stGuidOriginalAcctProv = m_stGuidActiveAcctProv;
  2687. // Activate the new Acct provider
  2688. // ----------------------------------------------------------------
  2689. if ( spAcctConfigNew )
  2690. CORg( spAcctConfigNew->Activate(uConnectionNew, 0, 0) );
  2691. Error:
  2692. if (spAcctConfigOld && uConnectionOld)
  2693. spAcctConfigOld->Uninitialize(uConnectionOld);
  2694. if (spAcctConfigNew && uConnectionNew)
  2695. spAcctConfigNew->Uninitialize(uConnectionNew);
  2696. if ( !FHrSucceeded(hr) )
  2697. Trace1("DATA_SRV_AUTH::SetNewActiveAcctProvider failed. hr = %lx", hr);
  2698. return hr;
  2699. }
  2700. /*!--------------------------------------------------------------------------
  2701. DATA_SRV_AUTH::FindProvData
  2702. -
  2703. Author: KennT
  2704. ---------------------------------------------------------------------------*/
  2705. AuthProviderData * DATA_SRV_AUTH::FindProvData(AuthProviderList &provList,
  2706. const TCHAR *pszGuid)
  2707. {
  2708. POSITION pos;
  2709. AuthProviderData * pData = NULL;
  2710. pos = provList.GetHeadPosition();
  2711. while ( pos )
  2712. {
  2713. pData = &provList.GetNext(pos);
  2714. if ( pData->m_stGuid == pszGuid )
  2715. break;
  2716. pData = NULL;
  2717. }
  2718. return pData;
  2719. }
  2720. /*---------------------------------------------------------------------------
  2721. EAPConfigurationDialog implementation
  2722. ---------------------------------------------------------------------------*/
  2723. BEGIN_MESSAGE_MAP(EAPConfigurationDialog, CBaseDialog)
  2724. //{{AFX_MSG_MAP(EAPConfigurationDialog)
  2725. // ON_COMMAND(IDC_RTR_EAPCFG_BTN_CFG, OnConfigure)
  2726. ON_CONTROL(LBN_SELCHANGE, IDC_RTR_EAPCFG_LIST, OnListChange)
  2727. //}}AFX_MSG_MAP
  2728. END_MESSAGE_MAP()
  2729. /*!--------------------------------------------------------------------------
  2730. EAPConfigurationDialog::~EAPConfigurationDialog
  2731. -
  2732. Author: KennT
  2733. ---------------------------------------------------------------------------*/
  2734. EAPConfigurationDialog::~EAPConfigurationDialog()
  2735. {
  2736. }
  2737. void EAPConfigurationDialog::DoDataExchange(CDataExchange *pDX)
  2738. {
  2739. CBaseDialog::DoDataExchange(pDX);
  2740. DDX_Control(pDX, IDC_RTR_EAPCFG_LIST, m_listBox);
  2741. }
  2742. /*!--------------------------------------------------------------------------
  2743. EAPConfigurationDialog::OnInitDialog
  2744. -
  2745. Author: KennT
  2746. ---------------------------------------------------------------------------*/
  2747. BOOL EAPConfigurationDialog::OnInitDialog()
  2748. {
  2749. HRESULT hr = hrOK;
  2750. BOOL fStandalone;
  2751. POSITION pos;
  2752. AuthProviderData *pData;
  2753. int cRows = 0;
  2754. int iIndex;
  2755. CBaseDialog::OnInitDialog();
  2756. // Are we a standalone server?
  2757. // ----------------------------------------------------------------
  2758. fStandalone = (HrIsStandaloneServer(m_stMachine) == hrOK);
  2759. // Now add what is in the cfg list to the listbox
  2760. // ----------------------------------------------------------------
  2761. pos = m_pProvList->GetHeadPosition();
  2762. while ( pos )
  2763. {
  2764. pData = &m_pProvList->GetNext(pos);
  2765. // Windows NT Bug : 180374
  2766. // If this is a standalone machine and the standalone flag
  2767. // is not here, then do not add this machine to the list.
  2768. // ------------------------------------------------------------
  2769. if (fStandalone && ((pData->m_dwFlags & 0x1) == 0))
  2770. continue;
  2771. if (pData->m_stTitle.IsEmpty())
  2772. {
  2773. CString stTemp;
  2774. stTemp.Format(IDS_ERR_EAP_BOGUS_NAME, pData->m_stKey);
  2775. iIndex = m_listBox.AddString(stTemp);
  2776. }
  2777. else
  2778. {
  2779. iIndex = m_listBox.AddString(pData->m_stTitle);
  2780. }
  2781. if ( iIndex == LB_ERR )
  2782. break;
  2783. // Store a pointer to the EAPCfgData in the list box item data
  2784. // ------------------------------------------------------------
  2785. m_listBox.SetItemData(iIndex, (LONG_PTR) pData);
  2786. cRows++;
  2787. }
  2788. // enable/disable the configure button depending if something
  2789. // is selected.
  2790. // ----------------------------------------------------------------
  2791. // GetDlgItem(IDC_RTR_EAPCFG_BTN_CFG)->EnableWindow(
  2792. // m_listBox.GetCurSel() != LB_ERR);
  2793. //Error:
  2794. if ( !FHrSucceeded(hr) )
  2795. OnCancel();
  2796. return FHrSucceeded(hr) ? TRUE : FALSE;
  2797. }
  2798. /*!--------------------------------------------------------------------------
  2799. EAPConfigurationDialog::OnListChange
  2800. -
  2801. Author: KennT
  2802. ---------------------------------------------------------------------------*/
  2803. void EAPConfigurationDialog::OnListChange()
  2804. {
  2805. int iSel;
  2806. iSel = m_listBox.GetCurSel();
  2807. // Enable/disable the window appropriately
  2808. // ----------------------------------------------------------------
  2809. // GetDlgItem(IDC_RTR_EAPCFG_BTN_CFG)->EnableWindow(iSel != LB_ERR);
  2810. }
  2811. /*!--------------------------------------------------------------------------
  2812. EAPConfigurationDialog::OnConfigure
  2813. -
  2814. Author: KennT
  2815. ---------------------------------------------------------------------------*/
  2816. /* configure button is moved to NAP/Profile/Authentication page
  2817. void EAPConfigurationDialog::OnConfigure()
  2818. {
  2819. // Bring up the configuration UI for this EAP
  2820. // ----------------------------------------------------------------
  2821. AuthProviderData * pData;
  2822. int iSel;
  2823. SPIEAPProviderConfig spEAPConfig;
  2824. GUID guid;
  2825. HRESULT hr = hrOK;
  2826. ULONG_PTR uConnection = 0;
  2827. iSel = m_listBox.GetCurSel();
  2828. if ( iSel == LB_ERR )
  2829. return;
  2830. pData = (AuthProviderData *) m_listBox.GetItemData(iSel);
  2831. Assert(pData);
  2832. if ( pData == NULL )
  2833. return;
  2834. if ( pData->m_stConfigCLSID.IsEmpty() )
  2835. {
  2836. AfxMessageBox(IDS_ERR_NO_EAP_PROVIDER_CONFIG);
  2837. return;
  2838. }
  2839. CORg( CLSIDFromString((LPTSTR) (LPCTSTR)(pData->m_stConfigCLSID), &guid) );
  2840. // Create the EAP provider object
  2841. // ----------------------------------------------------------------
  2842. CORg( CoCreateInstance(guid,
  2843. NULL,
  2844. CLSCTX_INPROC_SERVER | CLSCTX_ENABLE_CODE_DOWNLOAD,
  2845. IID_IEAPProviderConfig,
  2846. (LPVOID *) &spEAPConfig) );
  2847. // Configure this EAP provider
  2848. // ----------------------------------------------------------------
  2849. hr = spEAPConfig->Initialize(m_stMachine, &uConnection);
  2850. if ( FHrSucceeded(hr) )
  2851. {
  2852. hr = spEAPConfig->Configure(uConnection, GetSafeHwnd(), 0, 0);
  2853. spEAPConfig->Uninitialize(uConnection);
  2854. }
  2855. if ( hr == E_NOTIMPL )
  2856. hr = hrOK;
  2857. CORg( hr );
  2858. Error:
  2859. if ( !FHrSucceeded(hr) )
  2860. {
  2861. // Bring up an error message
  2862. // ------------------------------------------------------------
  2863. DisplayTFSErrorMessage(GetSafeHwnd());
  2864. }
  2865. }
  2866. */
  2867. //------------------------------------------------------------------------
  2868. // DATA_SRV_PPP
  2869. //------------------------------------------------------------------------
  2870. DATA_SRV_PPP::DATA_SRV_PPP()
  2871. {
  2872. GetDefault();
  2873. }
  2874. HRESULT DATA_SRV_PPP::LoadFromReg(LPCTSTR pServerName,
  2875. const RouterVersionInfo& routerVersion)
  2876. {
  2877. HRESULT hr = hrOK;
  2878. DWORD dwFlags = 0;
  2879. LPCTSTR pszServerFlagsKey = NULL;
  2880. CServiceManager sm;
  2881. CService svr;
  2882. DWORD dwState;
  2883. // Depending on the version depends on where we look for the
  2884. // key.
  2885. // ----------------------------------------------------------------
  2886. if (routerVersion.dwOsBuildNo < RASMAN_PPP_KEY_LAST_VERSION)
  2887. pszServerFlagsKey = c_szRasmanPPPKey;
  2888. else
  2889. pszServerFlagsKey = c_szRegKeyRemoteAccessParameters;
  2890. // If we have any error reading in the data, go with the defaults
  2891. // ----------------------------------------------------------------
  2892. if ( ERROR_SUCCESS == m_regkey.Open(HKEY_LOCAL_MACHINE,
  2893. pszServerFlagsKey,
  2894. KEY_ALL_ACCESS,
  2895. pServerName) )
  2896. {
  2897. if (ERROR_SUCCESS == m_regkey.QueryValue( c_szServerFlags, dwFlags))
  2898. {
  2899. m_fUseMultilink = ((dwFlags & PPPCFG_NegotiateMultilink) != 0);
  2900. m_fUseBACP = ((dwFlags & PPPCFG_NegotiateBacp) != 0);
  2901. m_fUseLCPExtensions = ((dwFlags & PPPCFG_UseLcpExtensions) != 0);
  2902. m_fUseSwCompression = ((dwFlags & PPPCFG_UseSwCompression) != 0);
  2903. }
  2904. }
  2905. return hr;
  2906. }
  2907. HRESULT DATA_SRV_PPP::SaveToReg()
  2908. {
  2909. HRESULT hr = hrOK;
  2910. DWORD dwFlags = 0;
  2911. // Need to reread server flags in case some other page set the flags
  2912. // ----------------------------------------------------------------
  2913. CWRg( m_regkey.QueryValue( c_szServerFlags, dwFlags) );
  2914. if ( m_fUseMultilink )
  2915. dwFlags |= PPPCFG_NegotiateMultilink;
  2916. else
  2917. dwFlags &= ~PPPCFG_NegotiateMultilink;
  2918. if ( m_fUseBACP )
  2919. dwFlags |= PPPCFG_NegotiateBacp;
  2920. else
  2921. dwFlags &= ~PPPCFG_NegotiateBacp;
  2922. if ( m_fUseLCPExtensions )
  2923. dwFlags |= PPPCFG_UseLcpExtensions;
  2924. else
  2925. dwFlags &= ~PPPCFG_UseLcpExtensions;
  2926. if ( m_fUseSwCompression )
  2927. dwFlags |= PPPCFG_UseSwCompression;
  2928. else
  2929. dwFlags &= ~PPPCFG_UseSwCompression;
  2930. CWRg( m_regkey.SetValue( c_szServerFlags, dwFlags) );
  2931. //TODO$:now call rasman api to load the qos stuff.
  2932. Error:
  2933. return hr;
  2934. }
  2935. void DATA_SRV_PPP::GetDefault()
  2936. {
  2937. m_fUseMultilink = TRUE;
  2938. m_fUseBACP = TRUE;
  2939. m_fUseLCPExtensions = TRUE;
  2940. m_fUseSwCompression = TRUE;
  2941. ;
  2942. };
  2943. //**********************************************************************
  2944. // PPP router configuration page
  2945. //**********************************************************************
  2946. BEGIN_MESSAGE_MAP(RtrPPPCfgPage, RtrPropertyPage)
  2947. //{{AFX_MSG_MAP(RtrPPPCfgPage)
  2948. ON_BN_CLICKED(IDC_PPPCFG_BTN_MULTILINK, OnButtonClickMultilink)
  2949. ON_BN_CLICKED(IDC_PPPCFG_BTN_BACP, OnButtonClick)
  2950. ON_BN_CLICKED(IDC_PPPCFG_BTN_LCP, OnButtonClick)
  2951. ON_BN_CLICKED(IDC_PPPCFG_BTN_SWCOMP, OnButtonClick)
  2952. //}}AFX_MSG_MAP
  2953. END_MESSAGE_MAP()
  2954. RtrPPPCfgPage::RtrPPPCfgPage(UINT nIDTemplate, UINT nIDCaption /* = 0*/)
  2955. : RtrPropertyPage(nIDTemplate, nIDCaption)
  2956. {
  2957. //{{AFX_DATA_INIT(RtrPPPCfgPage)
  2958. //}}AFX_DATA_INIT
  2959. }
  2960. RtrPPPCfgPage::~RtrPPPCfgPage()
  2961. {
  2962. }
  2963. void RtrPPPCfgPage::DoDataExchange(CDataExchange* pDX)
  2964. {
  2965. RtrPropertyPage::DoDataExchange(pDX);
  2966. //{{AFX_DATA_MAP(RtrPPPCfgPage)
  2967. //}}AFX_DATA_MAP
  2968. }
  2969. HRESULT RtrPPPCfgPage::Init(RtrCfgSheet * pRtrCfgSheet,
  2970. const RouterVersionInfo& routerVersion)
  2971. {
  2972. Assert (pRtrCfgSheet);
  2973. m_pRtrCfgSheet=pRtrCfgSheet;
  2974. m_DataPPP.LoadFromReg(m_pRtrCfgSheet->m_stServerName,
  2975. routerVersion);
  2976. return S_OK;
  2977. };
  2978. BOOL RtrPPPCfgPage::OnInitDialog()
  2979. {
  2980. HRESULT hr= hrOK;
  2981. RtrPropertyPage::OnInitDialog();
  2982. CheckDlgButton(IDC_PPPCFG_BTN_MULTILINK, m_DataPPP.m_fUseMultilink);
  2983. CheckDlgButton(IDC_PPPCFG_BTN_BACP, m_DataPPP.m_fUseBACP);
  2984. CheckDlgButton(IDC_PPPCFG_BTN_LCP, m_DataPPP.m_fUseLCPExtensions);
  2985. CheckDlgButton(IDC_PPPCFG_BTN_SWCOMP, m_DataPPP.m_fUseSwCompression);
  2986. BOOL fMultilink = IsDlgButtonChecked(IDC_PPPCFG_BTN_MULTILINK);
  2987. GetDlgItem(IDC_PPPCFG_BTN_BACP)->EnableWindow(fMultilink);
  2988. SetDirty(FALSE);
  2989. if ( !FHrSucceeded(hr) )
  2990. Cancel();
  2991. return FHrSucceeded(hr) ? TRUE : FALSE;
  2992. }
  2993. BOOL RtrPPPCfgPage::OnApply()
  2994. {
  2995. BOOL fReturn=TRUE;
  2996. HRESULT hr = hrOK;
  2997. if ( m_pRtrCfgSheet->IsCancel() )
  2998. return TRUE;
  2999. m_DataPPP.m_fUseMultilink = IsDlgButtonChecked(IDC_PPPCFG_BTN_MULTILINK);
  3000. m_DataPPP.m_fUseBACP = IsDlgButtonChecked(IDC_PPPCFG_BTN_BACP);
  3001. m_DataPPP.m_fUseLCPExtensions = IsDlgButtonChecked(IDC_PPPCFG_BTN_LCP);
  3002. m_DataPPP.m_fUseSwCompression = IsDlgButtonChecked(IDC_PPPCFG_BTN_SWCOMP);
  3003. fReturn = RtrPropertyPage::OnApply();
  3004. return fReturn;
  3005. }
  3006. void RtrPPPCfgPage::OnButtonClick()
  3007. {
  3008. SetDirty(TRUE);
  3009. SetModified();
  3010. }
  3011. void RtrPPPCfgPage::OnButtonClickMultilink()
  3012. {
  3013. BOOL fMultilink = IsDlgButtonChecked(IDC_PPPCFG_BTN_MULTILINK);
  3014. GetDlgItem(IDC_PPPCFG_BTN_BACP)->EnableWindow(fMultilink);
  3015. SetDirty(TRUE);
  3016. SetModified();
  3017. }
  3018. //------------------------------------------------------------------------
  3019. // DATA_SRV_RASERRLOG
  3020. //------------------------------------------------------------------------
  3021. DATA_SRV_RASERRLOG::DATA_SRV_RASERRLOG()
  3022. {
  3023. GetDefault();
  3024. }
  3025. HRESULT DATA_SRV_RASERRLOG::LoadFromReg(LPCTSTR pszServerName /*=NULL*/)
  3026. {
  3027. HRESULT hr = hrOK;
  3028. // Default value is to have maximum logging (per Gibbs)
  3029. // ----------------------------------------------------------------
  3030. DWORD dwFlags = RAS_LOGGING_WARN;
  3031. DWORD dwTracing = FALSE;
  3032. if ( ERROR_SUCCESS == m_regkey.Open(HKEY_LOCAL_MACHINE,
  3033. c_szRegKeyRemoteAccessParameters,
  3034. KEY_ALL_ACCESS,
  3035. pszServerName) )
  3036. {
  3037. if (m_regkey.QueryValue( c_szRegValLoggingFlags, dwFlags) != ERROR_SUCCESS)
  3038. dwFlags = RAS_LOGGING_WARN;
  3039. }
  3040. if ( ERROR_SUCCESS == m_regkeyFileLogging.Open(HKEY_LOCAL_MACHINE,
  3041. c_szRegKeyPPPTracing,
  3042. KEY_ALL_ACCESS,
  3043. pszServerName) )
  3044. {
  3045. if (m_regkeyFileLogging.QueryValue(c_szRegValEnableFileTracing, dwTracing) != ERROR_SUCCESS)
  3046. dwTracing = FALSE;
  3047. }
  3048. m_stServer = pszServerName;
  3049. m_dwLogLevel = dwFlags;
  3050. m_dwEnableFileTracing = dwTracing;
  3051. m_dwOldEnableFileTracing = dwTracing;
  3052. return hr;
  3053. }
  3054. HRESULT DATA_SRV_RASERRLOG::SaveToReg()
  3055. {
  3056. HRESULT hr = hrOK;
  3057. if ((HKEY) m_regkey == 0)
  3058. {
  3059. // Try to create the regkey
  3060. // ------------------------------------------------------------
  3061. CWRg( m_regkey.Create(HKEY_LOCAL_MACHINE,
  3062. c_szRegKeyRemoteAccessParameters,
  3063. REG_OPTION_NON_VOLATILE,
  3064. KEY_ALL_ACCESS,
  3065. NULL,
  3066. (LPCTSTR) m_stServer
  3067. ) );
  3068. }
  3069. CWRg( m_regkey.SetValue( c_szRegValLoggingFlags, m_dwLogLevel) );
  3070. if (m_dwOldEnableFileTracing != m_dwEnableFileTracing)
  3071. {
  3072. if ((HKEY) m_regkeyFileLogging == 0)
  3073. {
  3074. // Try to create the regkey
  3075. // ------------------------------------------------------------
  3076. CWRg( m_regkeyFileLogging.Create(HKEY_LOCAL_MACHINE,
  3077. c_szRegKeyPPPTracing,
  3078. REG_OPTION_NON_VOLATILE,
  3079. KEY_ALL_ACCESS,
  3080. NULL,
  3081. (LPCTSTR) m_stServer
  3082. ) );
  3083. }
  3084. CWRg( m_regkeyFileLogging.SetValue( c_szRegValEnableFileTracing,
  3085. m_dwEnableFileTracing) );
  3086. m_dwOldEnableFileTracing = m_dwEnableFileTracing;
  3087. }
  3088. Error:
  3089. return hr;
  3090. }
  3091. void DATA_SRV_RASERRLOG::GetDefault()
  3092. {
  3093. // Default value is to log errors and warnings (per Gibbs)
  3094. // ----------------------------------------------------------------
  3095. m_dwLogLevel = RAS_LOGGING_WARN;
  3096. // Default is to have no file logging
  3097. // ----------------------------------------------------------------
  3098. m_dwEnableFileTracing = FALSE;
  3099. m_dwOldEnableFileTracing = FALSE;
  3100. };
  3101. HRESULT DATA_SRV_RASERRLOG::UseDefaults(LPCTSTR pServerName, BOOL fNT4)
  3102. {
  3103. HRESULT hr = hrOK;
  3104. m_stServer = pServerName;
  3105. GetDefault();
  3106. //Error:
  3107. return hr;
  3108. }
  3109. BOOL DATA_SRV_RASERRLOG::FNeedRestart()
  3110. {
  3111. // We only need a restart if the enable file tracing is changed.
  3112. // ----------------------------------------------------------------
  3113. return FALSE;
  3114. //BugID:390829. Enable tracing does not require a restart.
  3115. //return (m_dwEnableFileTracing != m_dwOldEnableFileTracing);
  3116. }
  3117. /*---------------------------------------------------------------------------
  3118. RtrLogLevelCfgPage implementation
  3119. ---------------------------------------------------------------------------*/
  3120. BEGIN_MESSAGE_MAP(RtrLogLevelCfgPage, RtrPropertyPage)
  3121. //{{AFX_MSG_MAP(RtrLogLevelCfgPage)
  3122. ON_BN_CLICKED(IDC_ELOG_BTN_LOGNONE, OnButtonClick)
  3123. ON_BN_CLICKED(IDC_ELOG_BTN_LOGERROR, OnButtonClick)
  3124. ON_BN_CLICKED(IDC_ELOG_BTN_LOGWARN, OnButtonClick)
  3125. ON_BN_CLICKED(IDC_ELOG_BTN_LOGINFO, OnButtonClick)
  3126. ON_BN_CLICKED(IDC_ELOG_BTN_PPP, OnButtonClick)
  3127. //}}AFX_MSG_MAP
  3128. END_MESSAGE_MAP()
  3129. RtrLogLevelCfgPage::RtrLogLevelCfgPage(UINT nIDTemplate, UINT nIDCaption /* = 0*/)
  3130. : RtrPropertyPage(nIDTemplate, nIDCaption)
  3131. {
  3132. //{{AFX_DATA_INIT(RtrLogLevelCfgPage)
  3133. //}}AFX_DATA_INIT
  3134. }
  3135. RtrLogLevelCfgPage::~RtrLogLevelCfgPage()
  3136. {
  3137. }
  3138. void RtrLogLevelCfgPage::DoDataExchange(CDataExchange* pDX)
  3139. {
  3140. RtrPropertyPage::DoDataExchange(pDX);
  3141. //{{AFX_DATA_MAP(RtrLogLevelCfgPage)
  3142. //}}AFX_DATA_MAP
  3143. }
  3144. HRESULT RtrLogLevelCfgPage::Init(RtrCfgSheet * pRtrCfgSheet,
  3145. const RouterVersionInfo& routerVersion)
  3146. {
  3147. Assert (pRtrCfgSheet);
  3148. m_pRtrCfgSheet=pRtrCfgSheet;
  3149. m_DataRASErrLog.LoadFromReg(m_pRtrCfgSheet->m_stServerName);
  3150. return S_OK;
  3151. };
  3152. BOOL RtrLogLevelCfgPage::OnInitDialog()
  3153. {
  3154. HRESULT hr= hrOK;
  3155. int nButton;
  3156. RtrPropertyPage::OnInitDialog();
  3157. switch (m_DataRASErrLog.m_dwLogLevel)
  3158. {
  3159. case RAS_LOGGING_NONE:
  3160. nButton = IDC_ELOG_BTN_LOGNONE;
  3161. break;
  3162. case RAS_LOGGING_ERROR:
  3163. nButton = IDC_ELOG_BTN_LOGERROR;
  3164. break;
  3165. case RAS_LOGGING_WARN:
  3166. nButton = IDC_ELOG_BTN_LOGWARN;
  3167. break;
  3168. case RAS_LOGGING_INFO:
  3169. nButton = IDC_ELOG_BTN_LOGINFO;
  3170. break;
  3171. default:
  3172. Panic0("Unknown logging type");
  3173. break;
  3174. }
  3175. CheckRadioButton(IDC_ELOG_BTN_LOGNONE,
  3176. IDC_ELOG_BTN_LOGINFO,
  3177. nButton);
  3178. CheckDlgButton(IDC_ELOG_BTN_PPP, m_DataRASErrLog.m_dwEnableFileTracing);
  3179. SetDirty(FALSE);
  3180. if ( !FHrSucceeded(hr) )
  3181. Cancel();
  3182. return FHrSucceeded(hr) ? TRUE : FALSE;
  3183. }
  3184. BOOL RtrLogLevelCfgPage::OnApply()
  3185. {
  3186. BOOL fReturn=TRUE;
  3187. HRESULT hr = hrOK;
  3188. if ( m_pRtrCfgSheet->IsCancel() )
  3189. return TRUE;
  3190. // This will save the data if needed.
  3191. // ----------------------------------------------------------------
  3192. hr = m_pRtrCfgSheet->SaveRequiredRestartChanges(GetSafeHwnd());
  3193. if (FHrSucceeded(hr))
  3194. fReturn = RtrPropertyPage::OnApply();
  3195. if ( !FHrSucceeded(hr) )
  3196. fReturn = FALSE;
  3197. return fReturn;
  3198. }
  3199. void RtrLogLevelCfgPage::OnButtonClick()
  3200. {
  3201. SaveSettings();
  3202. SetDirty(TRUE);
  3203. SetModified();
  3204. }
  3205. void RtrLogLevelCfgPage::SaveSettings()
  3206. {
  3207. if (IsDlgButtonChecked(IDC_ELOG_BTN_LOGERROR))
  3208. {
  3209. m_DataRASErrLog.m_dwLogLevel = RAS_LOGGING_ERROR;
  3210. }
  3211. else if (IsDlgButtonChecked(IDC_ELOG_BTN_LOGNONE))
  3212. {
  3213. m_DataRASErrLog.m_dwLogLevel = RAS_LOGGING_NONE;
  3214. }
  3215. else if (IsDlgButtonChecked(IDC_ELOG_BTN_LOGINFO))
  3216. {
  3217. m_DataRASErrLog.m_dwLogLevel = RAS_LOGGING_INFO;
  3218. }
  3219. else if (IsDlgButtonChecked(IDC_ELOG_BTN_LOGWARN))
  3220. {
  3221. m_DataRASErrLog.m_dwLogLevel = RAS_LOGGING_WARN;
  3222. }
  3223. else
  3224. {
  3225. Panic0("Nothing is selected");
  3226. }
  3227. m_DataRASErrLog.m_dwEnableFileTracing = IsDlgButtonChecked(IDC_ELOG_BTN_PPP);
  3228. }
  3229. /*---------------------------------------------------------------------------
  3230. AuthenticationSettingsDialog Implementation
  3231. ---------------------------------------------------------------------------*/
  3232. BEGIN_MESSAGE_MAP(AuthenticationSettingsDialog, CBaseDialog)
  3233. //{{AFX_MSG_MAP(AuthenticationSettingsDialog)
  3234. ON_BN_CLICKED(IDC_RTR_AUTH_BTN_DETAILS, OnRtrAuthCfgEAP)
  3235. //}}AFX_MSG_MAP
  3236. END_MESSAGE_MAP()
  3237. const DWORD s_rgdwAuth[] =
  3238. {
  3239. IDC_RTR_AUTH_BTN_NOAUTH, PPPCFG_AllowNoAuthentication,
  3240. IDC_RTR_AUTH_BTN_EAP, PPPCFG_NegotiateEAP,
  3241. IDC_RTR_AUTH_BTN_CHAP, PPPCFG_NegotiateMD5CHAP,
  3242. IDC_RTR_AUTH_BTN_MSCHAP, PPPCFG_NegotiateMSCHAP,
  3243. IDC_RTR_AUTH_BTN_PAP, PPPCFG_NegotiatePAP,
  3244. IDC_RTR_AUTH_BTN_SPAP, PPPCFG_NegotiateSPAP,
  3245. IDC_RTR_AUTH_BTN_MSCHAPV2, PPPCFG_NegotiateStrongMSCHAP,
  3246. 0, 0,
  3247. };
  3248. /*!--------------------------------------------------------------------------
  3249. AuthenticationSettingsDialog::SetAuthFlags
  3250. -
  3251. Author: KennT
  3252. ---------------------------------------------------------------------------*/
  3253. void AuthenticationSettingsDialog::SetAuthFlags(DWORD dwFlags)
  3254. {
  3255. m_dwFlags = dwFlags;
  3256. }
  3257. /*!--------------------------------------------------------------------------
  3258. AuthenticationSettingsDialog::GetAuthFlags
  3259. -
  3260. Author: KennT
  3261. ---------------------------------------------------------------------------*/
  3262. DWORD AuthenticationSettingsDialog::GetAuthFlags()
  3263. {
  3264. return m_dwFlags;
  3265. }
  3266. /*!--------------------------------------------------------------------------
  3267. AuthenticationSettingsDialog::ReadFlagState
  3268. -
  3269. Author: KennT
  3270. ---------------------------------------------------------------------------*/
  3271. void AuthenticationSettingsDialog::ReadFlagState()
  3272. {
  3273. int iPos = 0;
  3274. DWORD dwTemp;
  3275. for ( iPos = 0; s_rgdwAuth[iPos] != 0; iPos += 2 )
  3276. {
  3277. dwTemp = s_rgdwAuth[iPos+1];
  3278. if ( IsDlgButtonChecked(s_rgdwAuth[iPos]) )
  3279. m_dwFlags |= dwTemp;
  3280. else
  3281. m_dwFlags &= ~dwTemp;
  3282. Assert(iPos < DimensionOf(s_rgdwAuth));
  3283. }
  3284. }
  3285. /*!--------------------------------------------------------------------------
  3286. AuthenticationSettingsDialog::CheckAuthenticationControls
  3287. -
  3288. Author: KennT
  3289. ---------------------------------------------------------------------------*/
  3290. void AuthenticationSettingsDialog::CheckAuthenticationControls(DWORD dwFlags)
  3291. {
  3292. int iPos = 0;
  3293. for ( iPos = 0; s_rgdwAuth[iPos] != 0; iPos += 2 )
  3294. {
  3295. CheckDlgButton(s_rgdwAuth[iPos],
  3296. (dwFlags & s_rgdwAuth[iPos+1]) != 0);
  3297. }
  3298. }
  3299. void AuthenticationSettingsDialog::DoDataExchange(CDataExchange *pDX)
  3300. {
  3301. CBaseDialog::DoDataExchange(pDX);
  3302. }
  3303. BOOL AuthenticationSettingsDialog::OnInitDialog()
  3304. {
  3305. CBaseDialog::OnInitDialog();
  3306. CheckAuthenticationControls(m_dwFlags);
  3307. return TRUE;
  3308. }
  3309. void AuthenticationSettingsDialog::OnOK()
  3310. {
  3311. ReadFlagState();
  3312. // Windows NT Bug : ???
  3313. // At least one of the authentication checkboxes must be checked.
  3314. // ----------------------------------------------------------------
  3315. if (!(m_dwFlags & USE_PPPCFG_ALL_METHODS))
  3316. {
  3317. // None of the flags are checked!
  3318. // ------------------------------------------------------------
  3319. AfxMessageBox(IDS_ERR_NO_AUTH_PROTOCOLS_SELECTED, MB_OK);
  3320. return;
  3321. }
  3322. CBaseDialog::OnOK();
  3323. }
  3324. /*!--------------------------------------------------------------------------
  3325. AuthenticationSettingsDialog::OnRtrAuthCfgEAP
  3326. Brings up the EAP configuration dialog.
  3327. Author: KennT
  3328. ---------------------------------------------------------------------------*/
  3329. void AuthenticationSettingsDialog::OnRtrAuthCfgEAP()
  3330. {
  3331. EAPConfigurationDialog eapdlg(m_stMachine, m_pProvList);
  3332. eapdlg.DoModal();
  3333. }