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

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