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

847 lines
23 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2001.
  5. //
  6. // File: Nfaa.cpp
  7. //
  8. // Contents: Wireless Policy Snapin - IEEE 8021.x property page for each PS.
  9. //
  10. //
  11. // History: TaroonM
  12. // 10/30/01
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "stdafx.h"
  16. #include "NFAa.h"
  17. #include "wzcsapi.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CPS8021XPropPage property page
  25. IMPLEMENT_DYNCREATE(CPS8021XPropPage, CWirelessBasePage)
  26. CPS8021XPropPage::CPS8021XPropPage(UINT nIDTemplate) : CWirelessBasePage(nIDTemplate)
  27. {
  28. //{{AFX_DATA_INIT(CPS8021XPropPage)
  29. m_dwEnable8021x = FALSE;
  30. m_dwValidateServerCertificate = FALSE;
  31. m_dwMachineAuthentication = FALSE;
  32. m_dwGuestAuthentication = FALSE;
  33. dwEAPUpdated = 0;
  34. pListEapcfgs = NULL;
  35. m_bHasApplied = FALSE;
  36. //}}AFX_DATA_INIT
  37. }
  38. CPS8021XPropPage::CPS8021XPropPage() : CWirelessBasePage(CPS8021XPropPage::IDD)
  39. {
  40. //{{AFX_DATA_INIT(CPS8021XPropPage)
  41. m_dwEnable8021x = FALSE;
  42. m_dwValidateServerCertificate = FALSE;
  43. m_dwMachineAuthentication = FALSE;
  44. m_dwGuestAuthentication = FALSE;
  45. dwEAPUpdated = 0;
  46. pListEapcfgs = NULL;
  47. m_bHasApplied = FALSE;
  48. //}}AFX_DATA_INIT
  49. }
  50. CPS8021XPropPage::~CPS8021XPropPage()
  51. {
  52. EAPCFG* pEapcfg = NULL;
  53. DTLNODE *pNodeEap = NULL;
  54. if (pListEapcfgs) {
  55. // Delete the data allocated using AllocPolMem
  56. for (pNodeEap = DtlGetFirstNode(pListEapcfgs);
  57. pNodeEap;
  58. pNodeEap = DtlGetNextNode(pNodeEap)
  59. )
  60. {
  61. pEapcfg = (EAPCFG* )DtlGetData(pNodeEap);
  62. ASSERT( pEapcfg );
  63. if (pEapcfg->pData) {
  64. FreePolMem(pEapcfg->pData);
  65. }
  66. pEapcfg->pData = NULL;
  67. pEapcfg->cbData = 0;
  68. }
  69. DtlDestroyList (pListEapcfgs, DestroyEapcfgNode);
  70. }
  71. pListEapcfgs = NULL;
  72. }
  73. void CPS8021XPropPage::DoDataExchange(CDataExchange* pDX)
  74. {
  75. CWirelessBasePage::DoDataExchange(pDX);
  76. //{{AFX_DATA_MAP(CPS8021XPropPage)
  77. DDX_Check(pDX, IDC_ENABLE_8021X, m_dwEnable8021x);
  78. DDX_Control(pDX, IDC_COMBO_8021X_MODE, m_cb8021xMode);
  79. DDX_Check(pDX, IDC_MACHINE_AUTHENTICATION, m_dwMachineAuthentication);
  80. DDX_Check(pDX, IDC_GUEST_AUTHENTICATION, m_dwGuestAuthentication);
  81. DDX_Control(pDX, IDC_COMBO_MC_AUTH_TYPE, m_cbMachineAuthenticationType);
  82. DDX_Text(pDX, IDC_IEEE8021X_MAX_START, m_dwIEEE8021xMaxStart);
  83. DDX_Text(pDX, IDC_IEEE8021X_START_PERIOD, m_dwIEEE8021xStartPeriod);
  84. DDX_Text(pDX, IDC_IEEE8021X_AUTH_PERIOD, m_dwIEEE8021xAuthPeriod);
  85. DDX_Text(pDX, IDC_IEEE8021X_HELD_PERIOD, m_dwIEEE8021xHeldPeriod);
  86. DDX_Control(pDX, IDC_EAP_TYPE_COMBO, m_cbEapType);
  87. //}}AFX_DATA_MAP
  88. }
  89. BEGIN_MESSAGE_MAP(CPS8021XPropPage, CWirelessBasePage)
  90. //{{AFX_MSG_MAP(CPS8021XPropPage)
  91. ON_CBN_SELENDOK(IDC_COMBO_8021X_MODE, OnSel8021xMode)
  92. ON_BN_CLICKED(IDC_ENABLE_8021X, OnCheck8021x)
  93. ON_CBN_SELENDOK(IDC_COMBO_MC_AUTH_TYPE, OnSelMachineAuthenticationType)
  94. ON_BN_CLICKED(IDC_GUEST_AUTHENTICATION, OnCheckGuestAuthentication)
  95. ON_BN_CLICKED(IDC_MACHINE_AUTHENTICATION, OnCheckMachineAuthentication)
  96. ON_EN_CHANGE(IDC_IEEE8021X_MAX_START,OnIEEE8021xParams)
  97. ON_EN_CHANGE(IDC_IEEE8021X_START_PERIOD,OnIEEE8021xParams)
  98. ON_EN_CHANGE(IDC_IEEE8021X_HELD_PERIOD,OnIEEE8021xParams)
  99. ON_EN_CHANGE(IDC_IEEE8021X_AUTH_PERIOD,OnIEEE8021xParams)
  100. ON_CBN_SELENDOK(IDC_EAP_TYPE_COMBO, OnSelEapType)
  101. ON_BN_CLICKED(IDC_EAP_CONFIGURE, OnProperties)
  102. ON_WM_HELPINFO()
  103. //}}AFX_MSG_MAP
  104. END_MESSAGE_MAP()
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CPS8021XPropPage message handlers
  107. BOOL CPS8021XPropPage::OnInitDialog()
  108. {
  109. DWORD dwIEEE8021xMaxStart;
  110. DWORD dwIEEE8021xStartPeriod;
  111. DWORD dwIEEE8021xAuthPeriod;
  112. DWORD dwIEEE8021xHeldPeriod;
  113. CString pszIEEE8021xMaxStart;
  114. CString pszIEEE8021xStartPeriod;
  115. CString pszIEEE8021xAuthPeriod;
  116. CString pszIEEE8021xHeldPeriod;
  117. CString pszTemp;
  118. DWORD dwEapIndex;
  119. DWORD dw8021xModeIndex;
  120. DWORD dwMachineAuthenticationTypeIndex;
  121. DWORD dwCertTypeIndex;
  122. DWORD dwEAPType = 0;
  123. DWORD dwEAPDataLen = 0;
  124. LPBYTE pbEAPData = NULL;
  125. DTLNODE* pOriginalEapcfgNode = NULL;
  126. BYTE *pbData = NULL;
  127. DWORD cbData = 0;
  128. DTLNODE* pNode = NULL;
  129. DWORD i = 0;
  130. DWORD dwEAPSel = 0;
  131. m_bHasApplied = FALSE;
  132. CWirelessBasePage::OnInitDialog();
  133. ASSERT( NULL != WirelessPS() );
  134. // get data from storage
  135. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  136. pWirelessPSData = WirelessPS();
  137. dwEAPType = pWirelessPSData->dwEapType;
  138. dwEAPDataLen = pWirelessPSData->dwEAPDataLen;
  139. pbEAPData = pWirelessPSData->pbEAPData;
  140. // Initialize EAP package list
  141. // Read the EAPCFG information from the registry and find the node
  142. // selected in the entry, or the default, if none.
  143. pListEapcfgs = NULL;
  144. pListEapcfgs = ::ReadEapcfgList (EAPOL_MUTUAL_AUTH_EAP_ONLY);
  145. if (pListEapcfgs)
  146. {
  147. for (pNode = DtlGetFirstNode(pListEapcfgs);
  148. pNode;
  149. pNode = DtlGetNextNode(pNode)
  150. )
  151. {
  152. EAPCFG* pEapcfg = (EAPCFG* )DtlGetData(pNode);
  153. ASSERT( pEapcfg );
  154. cbData = 0;
  155. pbData = NULL;
  156. i = m_cbEapType.AddString(pEapcfg->pszFriendlyName);
  157. m_cbEapType.SetItemDataPtr(i, pNode);
  158. if (pEapcfg->dwKey == dwEAPType) {
  159. cbData = dwEAPDataLen;
  160. if (dwEAPDataLen) {
  161. pbData = (LPBYTE) AllocPolMem(dwEAPDataLen);
  162. if (!pbData) {
  163. return FALSE;
  164. }
  165. memcpy(pbData, pbEAPData, dwEAPDataLen);
  166. }
  167. dwEAPSel = i;
  168. }
  169. pEapcfg->pData = pbData;
  170. pEapcfg->cbData = cbData;
  171. }
  172. // Choose the EAP name that will appear in the combo box
  173. m_cbEapType.SetCurSel(dwEAPSel);
  174. }
  175. m_dwIEEE8021xMaxStart =
  176. pWirelessPSData->dwIEEE8021xMaxStart;
  177. m_dwIEEE8021xStartPeriod =
  178. pWirelessPSData->dwIEEE8021xStartPeriod;
  179. m_dwIEEE8021xAuthPeriod =
  180. pWirelessPSData->dwIEEE8021xAuthPeriod;
  181. m_dwIEEE8021xHeldPeriod =
  182. pWirelessPSData->dwIEEE8021xHeldPeriod;
  183. m_dwGuestAuthentication =
  184. pWirelessPSData->dwGuestAuthentication ? TRUE : FALSE;
  185. m_dwEnable8021x =
  186. pWirelessPSData->dwEnable8021x ? TRUE : FALSE;
  187. pszTemp.LoadString(IDS_8021X_MODE_NO_TRANSMIT);
  188. m_cb8021xMode.AddString(pszTemp);
  189. pszTemp.LoadString(IDS_8021X_MODE_NAS_TRANSMIT);
  190. m_cb8021xMode.AddString(pszTemp);
  191. pszTemp.LoadString(IDS_8021X_MODE_TRANSMIT);
  192. m_cb8021xMode.AddString(pszTemp);
  193. switch (pWirelessPSData->dw8021xMode)
  194. {
  195. case WIRELESS_8021X_MODE_NO_TRANSMIT_EAPOLSTART_WIRED:
  196. dw8021xModeIndex = 0;
  197. break;
  198. case WIRELESS_8021X_MODE_NAS_TRANSMIT_EAPOLSTART_WIRED:
  199. dw8021xModeIndex = 1;
  200. break;
  201. case WIRELESS_8021X_MODE_TRANSMIT_EAPOLSTART_WIRED:
  202. dw8021xModeIndex = 2;
  203. break;
  204. default:
  205. dw8021xModeIndex = 0;
  206. break;
  207. }
  208. m_cb8021xMode.SetCurSel(dw8021xModeIndex);
  209. m_dwMachineAuthentication =
  210. pWirelessPSData->dwMachineAuthentication ? TRUE : FALSE;
  211. pszTemp.LoadString(IDS_MC_AUTH_TYPE_MC_NO_USER);
  212. m_cbMachineAuthenticationType.AddString(pszTemp);
  213. pszTemp.LoadString(IDS_MC_AUTH_TYPE_USER_DONTCARE_MC);
  214. m_cbMachineAuthenticationType.AddString(pszTemp);
  215. pszTemp.LoadString(IDS_MC_AUTH_TYPE_MC_ONLY);
  216. m_cbMachineAuthenticationType.AddString(pszTemp);
  217. switch (pWirelessPSData->dwMachineAuthenticationType)
  218. {
  219. case WIRELESS_MC_AUTH_TYPE_MC_NO_USER:
  220. dwMachineAuthenticationTypeIndex = 0;
  221. break;
  222. case WIRELESS_MC_AUTH_TYPE_USER_DONTCARE_MC:
  223. dwMachineAuthenticationTypeIndex = 1;
  224. break;
  225. case WIRELESS_MC_AUTH_TYPE_MC_ONLY:
  226. dwMachineAuthenticationTypeIndex = 2;
  227. break;
  228. default:
  229. dwMachineAuthenticationTypeIndex = 0;
  230. break;
  231. }
  232. m_cbMachineAuthenticationType.SetCurSel(dwMachineAuthenticationTypeIndex);
  233. DisplayEnable8021x();
  234. if (m_bReadOnly) {
  235. DisableControls();
  236. }
  237. // set radio correctly
  238. UpdateData (FALSE);
  239. // set radio controled edits correctly
  240. //OnRadioAdapterType();
  241. // OK, we can start paying attention to modifications made via dlg controls now.
  242. // This should be the last call before returning from OnInitDialog.
  243. OnFinishInitDialog();
  244. return TRUE; // return TRUE unless you set the focus to a control
  245. // EXCEPTION: OCX Property Pages should return FALSE
  246. }
  247. void
  248. CPS8021XPropPage::DisplayEnable8021x()
  249. {
  250. if(m_dwEnable8021x) {
  251. SAFE_ENABLEWINDOW(IDC_COMBO_8021X_MODE, TRUE);
  252. SAFE_ENABLEWINDOW(IDC_STATIC_8021X_MODE, TRUE);
  253. SAFE_ENABLEWINDOW(IDC_EAP_TYPE_COMBO, TRUE);
  254. SAFE_ENABLEWINDOW(IDC_STATIC_EAP_TYPE, TRUE);
  255. SAFE_ENABLEWINDOW(IDC_IEEE8021X_MAX_START, TRUE);
  256. SAFE_ENABLEWINDOW(IDC_IEEE8021X_START_PERIOD, TRUE);
  257. SAFE_ENABLEWINDOW(IDC_IEEE8021X_HELD_PERIOD, TRUE);
  258. SAFE_ENABLEWINDOW(IDC_IEEE8021X_AUTH_PERIOD, TRUE);
  259. SAFE_ENABLEWINDOW(IDC_STATIC_MAX_START, TRUE);
  260. SAFE_ENABLEWINDOW(IDC_STATIC_START_PERIOD, TRUE);
  261. SAFE_ENABLEWINDOW(IDC_STATIC_HELD_PERIOD, TRUE);
  262. SAFE_ENABLEWINDOW(IDC_STATIC_AUTH_PERIOD, TRUE);
  263. SAFE_ENABLEWINDOW(IDC_STATIC_8021X_PARAMS, TRUE);
  264. DisplayEapType();
  265. } else {
  266. SAFE_ENABLEWINDOW(IDC_COMBO_8021X_MODE,FALSE);
  267. SAFE_ENABLEWINDOW(IDC_STATIC_8021X_MODE,FALSE);
  268. SAFE_ENABLEWINDOW(IDC_EAP_TYPE_COMBO,FALSE);
  269. SAFE_ENABLEWINDOW(IDC_STATIC_EAP_TYPE, FALSE);
  270. SAFE_ENABLEWINDOW(IDC_IEEE8021X_MAX_START, FALSE);
  271. SAFE_ENABLEWINDOW(IDC_IEEE8021X_START_PERIOD, FALSE);
  272. SAFE_ENABLEWINDOW(IDC_IEEE8021X_HELD_PERIOD, FALSE);
  273. SAFE_ENABLEWINDOW(IDC_IEEE8021X_AUTH_PERIOD, FALSE);
  274. SAFE_ENABLEWINDOW(IDC_STATIC_MAX_START, FALSE);
  275. SAFE_ENABLEWINDOW(IDC_STATIC_START_PERIOD, FALSE);
  276. SAFE_ENABLEWINDOW(IDC_STATIC_HELD_PERIOD, FALSE);
  277. SAFE_ENABLEWINDOW(IDC_STATIC_AUTH_PERIOD, FALSE);
  278. SAFE_ENABLEWINDOW(IDC_STATIC_8021X_PARAMS, FALSE);
  279. SAFE_ENABLEWINDOW(IDC_STATIC_CERT_TYPE,FALSE);
  280. SAFE_ENABLEWINDOW(IDC_MACHINE_AUTHENTICATION,FALSE);
  281. SAFE_ENABLEWINDOW(IDC_GUEST_AUTHENTICATION,FALSE);
  282. SAFE_ENABLEWINDOW(IDC_EAP_CONFIGURE, FALSE);
  283. SAFE_ENABLEWINDOW(IDC_COMBO_MC_AUTH_TYPE,FALSE);
  284. SAFE_ENABLEWINDOW(IDC_STATIC_AUTH_TYPE,FALSE);
  285. }
  286. return;
  287. }
  288. void
  289. CPS8021XPropPage::DisplayEapType()
  290. {
  291. DWORD dwEapIndex = 0;
  292. DTLNODE *pNode = NULL;
  293. EAPCFG *pEapcfg = NULL;
  294. DWORD dwEAPType = 0;
  295. dwEapIndex = m_cbEapType.GetCurSel();
  296. pNode = (DTLNODE *) m_cbEapType.GetItemDataPtr(dwEapIndex);
  297. ASSERT( pNode );
  298. pEapcfg = (EAPCFG* )DtlGetData( pNode );
  299. ASSERT( pEapcfg );
  300. dwEAPType = pEapcfg->dwKey;
  301. switch (dwEAPType) {
  302. case EAP_TYPE_MD5:
  303. // dwEapType = WIRELESS_EAP_TYPE_MD5;
  304. SAFE_ENABLEWINDOW(IDC_STATIC_CERT_TYPE,FALSE);
  305. SAFE_ENABLEWINDOW(IDC_MACHINE_AUTHENTICATION,FALSE);
  306. SAFE_ENABLEWINDOW(IDC_GUEST_AUTHENTICATION,FALSE);
  307. SAFE_ENABLEWINDOW(IDC_EAP_CONFIGURE, FALSE);
  308. SAFE_ENABLEWINDOW(IDC_COMBO_MC_AUTH_TYPE,FALSE);
  309. SAFE_ENABLEWINDOW(IDC_STATIC_AUTH_TYPE,FALSE);
  310. break;
  311. default :
  312. SAFE_ENABLEWINDOW(IDC_STATIC_CERT_TYPE,TRUE);
  313. SAFE_ENABLEWINDOW(IDC_MACHINE_AUTHENTICATION,TRUE);
  314. SAFE_ENABLEWINDOW(IDC_GUEST_AUTHENTICATION,TRUE);
  315. SAFE_ENABLEWINDOW(IDC_EAP_CONFIGURE, TRUE);
  316. DisplayMachineAuthentication();
  317. break;
  318. }
  319. }
  320. void
  321. CPS8021XPropPage::DisplayMachineAuthentication()
  322. {
  323. if (m_dwMachineAuthentication) {
  324. SAFE_ENABLEWINDOW(IDC_COMBO_MC_AUTH_TYPE,TRUE);
  325. SAFE_ENABLEWINDOW(IDC_STATIC_AUTH_TYPE, TRUE);
  326. } else {
  327. SAFE_ENABLEWINDOW(IDC_COMBO_MC_AUTH_TYPE,FALSE);
  328. SAFE_ENABLEWINDOW(IDC_STATIC_AUTH_TYPE,FALSE);
  329. }
  330. }
  331. BOOL CPS8021XPropPage::OnWizardFinish()
  332. {
  333. // just transfer to our OnApply, as it does the right stuff
  334. if (OnApply())
  335. {
  336. // go ahead and finish
  337. return TRUE;
  338. }
  339. // don't allow us to finish
  340. return FALSE;
  341. }
  342. LRESULT CPS8021XPropPage::OnWizardNext()
  343. {
  344. // just transfer to our OnApply, as it does the right stuff
  345. if (ControlDataToWirelessPS())
  346. {
  347. // go ahead and move to next page
  348. return CWirelessBasePage::OnWizardNext();
  349. }
  350. // don't allow us to go on to the next page
  351. return -1;
  352. }
  353. BOOL CPS8021XPropPage::OnApply()
  354. {
  355. if (!m_bReadOnly) {
  356. // Save data from page
  357. if (!m_bHasApplied)
  358. {
  359. ControlDataToWirelessPS();
  360. }
  361. }
  362. // ok, everything is cool
  363. return CWirelessBasePage::OnApply();
  364. }
  365. void CPS8021XPropPage::OnCheck8021x()
  366. {
  367. UpdateData(TRUE);
  368. SetModified();
  369. DisplayEnable8021x();
  370. }
  371. void CPS8021XPropPage::OnSel8021xMode()
  372. {
  373. UpdateData(TRUE);
  374. SetModified();
  375. }
  376. void CPS8021XPropPage::OnSelCertType()
  377. {
  378. UpdateData(TRUE);
  379. SetModified();
  380. }
  381. void CPS8021XPropPage::OnCheckValidateServerCert()
  382. {
  383. UpdateData(TRUE);
  384. SetModified();
  385. //DisableWindow(m_hwnd8021xCheck);
  386. }
  387. void CPS8021XPropPage::OnSelMachineAuthenticationType()
  388. {
  389. UpdateData(TRUE);
  390. SetModified();
  391. }
  392. void CPS8021XPropPage::OnCheckGuestAuthentication()
  393. {
  394. UpdateData (TRUE);
  395. SetModified();
  396. }
  397. void CPS8021XPropPage::OnCheckMachineAuthentication()
  398. {
  399. UpdateData (TRUE);
  400. SetModified();
  401. DisplayMachineAuthentication();
  402. }
  403. void CPS8021XPropPage::OnIEEE8021xParams()
  404. {
  405. UpdateData (TRUE);
  406. SetModified();
  407. }
  408. void CPS8021XPropPage::OnSelEapType()
  409. {
  410. UpdateData(TRUE);
  411. SetModified();
  412. dwEAPUpdated = 1;
  413. DisplayEapType();
  414. }
  415. BOOL CPS8021XPropPage::OnHelpInfo(HELPINFO* pHelpInfo)
  416. {
  417. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  418. {
  419. DWORD* pdwHelp = (DWORD*) &g_aHelpIDs_IDD_8021X_PROPERTY_PAGE[0];
  420. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  421. c_szWlsnpHelpFile,
  422. HELP_WM_HELP,
  423. (DWORD_PTR)(LPVOID)pdwHelp);
  424. }
  425. return CWirelessBasePage::OnHelpInfo(pHelpInfo);
  426. }
  427. BOOL CPS8021XPropPage::ControlDataToWirelessPS()
  428. {
  429. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  430. LPWSTR pszNewInterfaceName = NULL;
  431. DWORD dwIEEE8021xMaxStart;
  432. DWORD dwIEEE8021xStartPeriod;
  433. DWORD dwIEEE8021xAuthPeriod;
  434. DWORD dwIEEE8021xHeldPeriod;
  435. CString pszIEEE8021xMaxStart;
  436. CString pszIEEE8021xStartPeriod;
  437. CString pszIEEE8021xAuthPeriod;
  438. CString pszIEEE8021xHeldPeriod;
  439. DWORD dwEnable8021x;
  440. DWORD dw8021xMode;
  441. DWORD dwEapType;
  442. DWORD dwCertificateType;
  443. DWORD dwValidateServerCertificate;
  444. DWORD dwMachineAuthentication;
  445. DWORD dwMachineAuthenticationType;
  446. DWORD dwGuestAuthentication;
  447. DWORD dwEapIndex;
  448. DWORD dw8021xModeIndex;
  449. DWORD dwMachineAuthenticationTypeIndex;
  450. DWORD dwCertificateTypeIndex;
  451. DTLNODE *pNode = NULL;
  452. EAPCFG *pEapcfg = NULL;
  453. pWirelessPSData = WirelessPS();
  454. UpdateData (TRUE);
  455. dwEnable8021x =
  456. m_dwEnable8021x ? 1 : 0;
  457. dw8021xModeIndex = m_cb8021xMode.GetCurSel();
  458. switch (dw8021xModeIndex) {
  459. case 0 :
  460. dw8021xMode =
  461. WIRELESS_8021X_MODE_NO_TRANSMIT_EAPOLSTART_WIRED;
  462. break;
  463. case 1 :
  464. dw8021xMode =
  465. WIRELESS_8021X_MODE_NAS_TRANSMIT_EAPOLSTART_WIRED;
  466. break;
  467. case 2 :
  468. dw8021xMode =
  469. WIRELESS_8021X_MODE_TRANSMIT_EAPOLSTART_WIRED;
  470. break;
  471. }
  472. dwEapIndex = m_cbEapType.GetCurSel();
  473. pNode = (DTLNODE *) m_cbEapType.GetItemDataPtr(dwEapIndex);
  474. ASSERT( pNode );
  475. pEapcfg = (EAPCFG* )DtlGetData( pNode );
  476. ASSERT( pEapcfg );
  477. dwEapType = pEapcfg->dwKey;
  478. if (dwEAPUpdated) {
  479. // since pEapcfg->pData is created by us, copy the pointer as is.
  480. if (pWirelessPSData->pbEAPData) {
  481. FreePolMem(pWirelessPSData->pbEAPData);
  482. }
  483. pWirelessPSData->dwEAPDataLen = pEapcfg->cbData;
  484. pWirelessPSData->pbEAPData = pEapcfg->pData;
  485. pEapcfg->cbData = 0;
  486. pEapcfg->pData = NULL;
  487. }
  488. dwCertificateTypeIndex = m_cbCertificateType.GetCurSel();
  489. switch (dwCertificateTypeIndex) {
  490. case 0 :
  491. dwCertificateType =
  492. WIRELESS_CERT_TYPE_SMARTCARD;
  493. break;
  494. case 1 :
  495. dwCertificateType =
  496. WIRELESS_CERT_TYPE_MC_CERT;
  497. break;
  498. }
  499. dwValidateServerCertificate =
  500. m_dwValidateServerCertificate ? 1 : 0;
  501. dwMachineAuthentication =
  502. m_dwMachineAuthentication ? 1 : 0;
  503. dwMachineAuthenticationTypeIndex = m_cbMachineAuthenticationType.GetCurSel();
  504. switch (dwMachineAuthenticationTypeIndex)
  505. {
  506. case 0 :
  507. dwMachineAuthenticationType =
  508. WIRELESS_MC_AUTH_TYPE_MC_NO_USER;
  509. break;
  510. case 1 :
  511. dwMachineAuthenticationType =
  512. WIRELESS_MC_AUTH_TYPE_USER_DONTCARE_MC;
  513. break;
  514. case 2 :
  515. dwMachineAuthenticationType =
  516. WIRELESS_MC_AUTH_TYPE_MC_ONLY;
  517. break;
  518. }
  519. dwGuestAuthentication =
  520. m_dwGuestAuthentication ? 1 : 0;
  521. pWirelessPSData->dwEnable8021x = dwEnable8021x;
  522. pWirelessPSData->dw8021xMode = dw8021xMode;
  523. pWirelessPSData->dwEapType = dwEapType;
  524. pWirelessPSData->dwMachineAuthentication = dwMachineAuthentication;
  525. pWirelessPSData->dwMachineAuthenticationType = dwMachineAuthenticationType;
  526. pWirelessPSData->dwGuestAuthentication = dwGuestAuthentication;
  527. pWirelessPSData->dwIEEE8021xMaxStart =
  528. m_dwIEEE8021xMaxStart;
  529. pWirelessPSData->dwIEEE8021xStartPeriod =
  530. m_dwIEEE8021xStartPeriod;
  531. pWirelessPSData->dwIEEE8021xAuthPeriod =
  532. m_dwIEEE8021xAuthPeriod;
  533. pWirelessPSData->dwIEEE8021xHeldPeriod =
  534. m_dwIEEE8021xHeldPeriod;
  535. m_bHasApplied = TRUE;
  536. return TRUE;
  537. }
  538. void
  539. CPS8021XPropPage::Initialize (
  540. PWIRELESS_PS_DATA pWirelessPSData,
  541. CComponentDataImpl* pComponentDataImpl,
  542. BOOL dwFlags = WLSTORE_READWRITE
  543. )
  544. {
  545. m_bReadOnly = dwFlags & WLSTORE_READONLY;
  546. CWirelessBasePage::Initialize(pWirelessPSData, pComponentDataImpl);
  547. }
  548. void CPS8021XPropPage::DisableControls()
  549. {
  550. SAFE_ENABLEWINDOW(IDC_ENABLE_8021X, FALSE);
  551. SAFE_ENABLEWINDOW(IDC_COMBO_8021X_MODE,FALSE);
  552. SAFE_ENABLEWINDOW(IDC_STATIC_8021X_MODE,FALSE);
  553. SAFE_ENABLEWINDOW(IDC_EAP_TYPE_COMBO,FALSE);
  554. SAFE_ENABLEWINDOW(IDC_STATIC_EAP_TYPE, FALSE);
  555. SAFE_ENABLEWINDOW(IDC_IEEE8021X_MAX_START, FALSE);
  556. SAFE_ENABLEWINDOW(IDC_IEEE8021X_START_PERIOD, FALSE);
  557. SAFE_ENABLEWINDOW(IDC_IEEE8021X_HELD_PERIOD, FALSE);
  558. SAFE_ENABLEWINDOW(IDC_IEEE8021X_AUTH_PERIOD, FALSE);
  559. SAFE_ENABLEWINDOW(IDC_STATIC_MAX_START, FALSE);
  560. SAFE_ENABLEWINDOW(IDC_STATIC_START_PERIOD, FALSE);
  561. SAFE_ENABLEWINDOW(IDC_STATIC_HELD_PERIOD, FALSE);
  562. SAFE_ENABLEWINDOW(IDC_STATIC_AUTH_PERIOD, FALSE);
  563. SAFE_ENABLEWINDOW(IDC_STATIC_8021X_PARAMS, FALSE);
  564. SAFE_ENABLEWINDOW(IDC_STATIC_CERT_TYPE,FALSE);
  565. SAFE_ENABLEWINDOW(IDC_MACHINE_AUTHENTICATION,FALSE);
  566. SAFE_ENABLEWINDOW(IDC_GUEST_AUTHENTICATION,FALSE);
  567. SAFE_ENABLEWINDOW(IDC_COMBO_MC_AUTH_TYPE,FALSE);
  568. SAFE_ENABLEWINDOW(IDC_STATIC_AUTH_TYPE,FALSE);
  569. }
  570. DWORD
  571. CPS8021XPropPage::OnProperties(
  572. )
  573. {
  574. DWORD dwError = 0;
  575. DTLNODE* pNode = NULL;
  576. EAPCFG* pEapcfg = NULL;
  577. RASEAPINVOKECONFIGUI pInvokeConfigUi;
  578. RASEAPFREE pFreeConfigUIData;
  579. HINSTANCE h;
  580. BYTE* pbEAPData = NULL;
  581. DWORD cbEAPData = 0;
  582. HWND hWnd;
  583. LPBYTE pbNewEAPData = NULL;
  584. DWORD dwEapTypeIndex = 0;
  585. // Look up the selected package configuration and load the associated
  586. // configuration DLL.
  587. dwEapTypeIndex = m_cbEapType.GetCurSel();
  588. pNode = (DTLNODE *) m_cbEapType.GetItemDataPtr(dwEapTypeIndex);
  589. if (!pNode)
  590. {
  591. return E_UNEXPECTED;
  592. }
  593. pEapcfg = (EAPCFG* )DtlGetData( pNode );
  594. ASSERT( pEapcfg );
  595. if (!pEapcfg) {
  596. return E_UNEXPECTED;
  597. }
  598. h = NULL;
  599. if (!(h = LoadLibrary( pEapcfg->pszConfigDll ))
  600. || !(pInvokeConfigUi =
  601. (RASEAPINVOKECONFIGUI )GetProcAddress(
  602. h, "RasEapInvokeConfigUI" ))
  603. || !(pFreeConfigUIData =
  604. (RASEAPFREE) GetProcAddress(
  605. h, "RasEapFreeMemory" )))
  606. {
  607. // Cannot load configuration DLL
  608. if (h)
  609. {
  610. FreeLibrary( h );
  611. }
  612. return E_FAIL;
  613. }
  614. // Call the configuration DLL to popup it's custom configuration UI.
  615. pbEAPData = NULL;
  616. cbEAPData = 0;
  617. hWnd = GetParent()->m_hWnd;
  618. dwError = pInvokeConfigUi(
  619. pEapcfg->dwKey,
  620. hWnd,
  621. 0,
  622. pEapcfg->pData,
  623. pEapcfg->cbData,
  624. &pbEAPData,
  625. &cbEAPData
  626. );
  627. /*TAROON* User hitting cancel is also an error */
  628. if (dwError)
  629. {
  630. FreeLibrary( h );
  631. return E_FAIL;
  632. }
  633. if (pbEAPData && cbEAPData)
  634. {
  635. // Copy it into the eap node
  636. pbNewEAPData = (LPBYTE) AllocPolMem(cbEAPData);
  637. if (!pbNewEAPData)
  638. {
  639. dwError = GetLastError();
  640. return(dwError);
  641. }
  642. memcpy(pbNewEAPData, pbEAPData, cbEAPData);
  643. }
  644. pFreeConfigUIData( pbEAPData );
  645. if (pEapcfg->pData) {
  646. FreePolMem(pEapcfg->pData);
  647. }
  648. pEapcfg->pData = pbNewEAPData;
  649. pEapcfg->cbData = cbEAPData;
  650. dwEAPUpdated = 1;
  651. FreeLibrary( h );
  652. return dwError;
  653. }
  654. void
  655. CPS8021XPropPage::OnCancel()
  656. {
  657. EAPCFG* pEapcfg = NULL;
  658. DTLNODE *pNodeEap = NULL;
  659. if (pListEapcfgs) {
  660. // Delete the data allocated using AllocPolMem
  661. for (pNodeEap = DtlGetFirstNode(pListEapcfgs);
  662. pNodeEap;
  663. pNodeEap = DtlGetNextNode(pNodeEap)
  664. )
  665. {
  666. pEapcfg = (EAPCFG* )DtlGetData(pNodeEap);
  667. ASSERT( pEapcfg );
  668. if (pEapcfg->pData) {
  669. FreePolMem(pEapcfg->pData);
  670. }
  671. pEapcfg->pData = NULL;
  672. pEapcfg->cbData = 0;
  673. }
  674. DtlDestroyList (pListEapcfgs, DestroyEapcfgNode);
  675. }
  676. pListEapcfgs = NULL;
  677. }