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.

509 lines
13 KiB

  1. /*++
  2. Copyright (c) 1999, Microsoft Corporation
  3. Module Name:
  4. elrpc.c
  5. Abstract:
  6. This module deals with RPC requests
  7. Revision History:
  8. sachins, Mar 19 2000, Created
  9. --*/
  10. #include "pcheapol.h"
  11. #pragma hdrstop
  12. DWORD
  13. RpcEapolGetCustomAuthData (
  14. STRING_HANDLE pSrvAddr,
  15. PWCHAR pwszGuid,
  16. DWORD dwEapTypeId,
  17. RAW_DATA rdSSID,
  18. PRAW_DATA prdConnInfo
  19. )
  20. {
  21. DWORD dwRetCode = NO_ERROR;
  22. InterlockedIncrement (&g_lWorkerThreads);
  23. do
  24. {
  25. if ((dwRetCode = WZCSvcCheckRPCAccess (WZC_ACCESS_QUERY)) != NO_ERROR)
  26. {
  27. break;
  28. }
  29. if (!(g_dwModulesStarted & ALL_MODULES_STARTED))
  30. {
  31. dwRetCode = ERROR_INVALID_STATE;
  32. break;
  33. }
  34. if ((pwszGuid == NULL) || (prdConnInfo == NULL))
  35. {
  36. dwRetCode = ERROR_INVALID_PARAMETER;
  37. break;
  38. }
  39. dwRetCode = ElGetCustomAuthData (
  40. pwszGuid,
  41. dwEapTypeId,
  42. rdSSID.dwDataLen,
  43. rdSSID.pData,
  44. prdConnInfo->pData,
  45. &(prdConnInfo->dwDataLen)
  46. );
  47. }
  48. while (FALSE);
  49. InterlockedDecrement (&g_lWorkerThreads);
  50. return dwRetCode;
  51. }
  52. DWORD
  53. RpcEapolSetCustomAuthData (
  54. STRING_HANDLE pSrvAddr,
  55. PWCHAR pwszGuid,
  56. DWORD dwEapTypeId,
  57. RAW_DATA rdSSID,
  58. PRAW_DATA prdConnInfo
  59. )
  60. {
  61. EAPOL_POLICY_DATA *pEAPOLPolicyData = NULL;
  62. BOOLEAN fPolicyFound = FALSE;
  63. PBYTE pbAuthData = NULL;
  64. DWORD dwSizeOfAuthData = 0;
  65. DWORD dwRetCode = NO_ERROR;
  66. InterlockedIncrement (&g_lWorkerThreads);
  67. do
  68. {
  69. if ((dwRetCode = WZCSvcCheckRPCAccess (WZC_ACCESS_SET)) != NO_ERROR)
  70. {
  71. break;
  72. }
  73. if (!(g_dwModulesStarted & ALL_MODULES_STARTED))
  74. {
  75. dwRetCode = ERROR_INVALID_STATE;
  76. break;
  77. }
  78. if ((pwszGuid == NULL) || (prdConnInfo == NULL))
  79. {
  80. dwRetCode = ERROR_INVALID_PARAMETER;
  81. break;
  82. }
  83. ACQUIRE_WRITE_LOCK (&g_PolicyLock);
  84. if (ElFindPolicyData (
  85. rdSSID.dwDataLen,
  86. rdSSID.pData,
  87. g_pEAPOLPolicyList,
  88. &pEAPOLPolicyData
  89. ) == NO_ERROR)
  90. {
  91. fPolicyFound = TRUE;
  92. }
  93. RELEASE_WRITE_LOCK (&g_PolicyLock);
  94. if (fPolicyFound)
  95. {
  96. if ((dwRetCode = ElGetCustomAuthData (
  97. pwszGuid,
  98. dwEapTypeId,
  99. rdSSID.dwDataLen,
  100. rdSSID.pData,
  101. NULL,
  102. &dwSizeOfAuthData
  103. )) == ERROR_BUFFER_TOO_SMALL)
  104. {
  105. if (dwSizeOfAuthData != prdConnInfo->dwDataLen)
  106. {
  107. TRACE0 (RPC, "RpcEapolSetCustomAuthData: POLICY: Cannot change data for global setting data: unequal size");
  108. dwRetCode = ERROR_ACCESS_DENIED;
  109. break;
  110. }
  111. else
  112. {
  113. pbAuthData = MALLOC (dwSizeOfAuthData);
  114. if (pbAuthData == NULL)
  115. {
  116. dwRetCode = ERROR_NOT_ENOUGH_MEMORY;
  117. TRACE0 (RPC, "RpcEapolSetCustomAuthData: Error in memory allocation for EAP blob");
  118. break;
  119. }
  120. if ((dwRetCode = ElGetCustomAuthData (
  121. pwszGuid,
  122. dwEapTypeId,
  123. rdSSID.dwDataLen,
  124. rdSSID.pData,
  125. pbAuthData,
  126. &dwSizeOfAuthData
  127. )) != NO_ERROR)
  128. {
  129. TRACE1 (USER, "ElReadPerPortRegistryParams: ElGetCustomAuthData failed with %ld",
  130. dwRetCode);
  131. break;
  132. }
  133. if (memcmp (prdConnInfo->pData, pbAuthData,
  134. dwSizeOfAuthData) != 0)
  135. {
  136. TRACE0 (RPC, "RpcEapolSetCustomAuthData: POLICY: Cannot change data for global setting data: Content change");
  137. dwRetCode = ERROR_ACCESS_DENIED;
  138. break;
  139. }
  140. // ignore setting
  141. dwRetCode = NO_ERROR;
  142. break;
  143. }
  144. }
  145. else
  146. {
  147. break;
  148. }
  149. }
  150. if ((dwRetCode = ElSetCustomAuthData (
  151. pwszGuid,
  152. dwEapTypeId,
  153. rdSSID.dwDataLen,
  154. rdSSID.pData,
  155. prdConnInfo->pData,
  156. &(prdConnInfo->dwDataLen)
  157. )) != NO_ERROR)
  158. {
  159. break;
  160. }
  161. }
  162. while (FALSE);
  163. if (pbAuthData != NULL)
  164. {
  165. FREE (pbAuthData);
  166. }
  167. InterlockedDecrement (&g_lWorkerThreads);
  168. return dwRetCode;
  169. }
  170. DWORD
  171. RpcEapolGetInterfaceParams (
  172. STRING_HANDLE pSrvAddr,
  173. PWCHAR pwszGuid,
  174. PEAPOL_INTF_PARAMS pIntfParams
  175. )
  176. {
  177. DWORD dwRetCode = NO_ERROR;
  178. InterlockedIncrement (&g_lWorkerThreads);
  179. do
  180. {
  181. if ((dwRetCode = WZCSvcCheckRPCAccess (WZC_ACCESS_QUERY)) != NO_ERROR)
  182. {
  183. break;
  184. }
  185. if (!(g_dwModulesStarted & ALL_MODULES_STARTED))
  186. {
  187. dwRetCode = ERROR_INVALID_STATE;
  188. break;
  189. }
  190. if ((pwszGuid == NULL) || (pIntfParams == NULL))
  191. {
  192. dwRetCode = ERROR_INVALID_PARAMETER;
  193. break;
  194. }
  195. dwRetCode = ElGetInterfaceParams (
  196. pwszGuid,
  197. pIntfParams
  198. );
  199. }
  200. while (FALSE);
  201. InterlockedDecrement (&g_lWorkerThreads);
  202. return dwRetCode;
  203. }
  204. DWORD
  205. RpcEapolSetInterfaceParams (
  206. STRING_HANDLE pSrvAddr,
  207. PWCHAR pwszGuid,
  208. PEAPOL_INTF_PARAMS pIntfParams
  209. )
  210. {
  211. EAPOL_POLICY_DATA *pEAPOLPolicyData = NULL;
  212. EAPOL_INTF_PARAMS PolicyIntfParams = {0};
  213. BOOLEAN fPolicyFound = FALSE;
  214. DWORD dwRetCode = NO_ERROR;
  215. InterlockedIncrement (&g_lWorkerThreads);
  216. do
  217. {
  218. if ((dwRetCode = WZCSvcCheckRPCAccess (WZC_ACCESS_SET)) != NO_ERROR)
  219. {
  220. break;
  221. }
  222. if (!(g_dwModulesStarted & ALL_MODULES_STARTED))
  223. {
  224. dwRetCode = ERROR_INVALID_STATE;
  225. break;
  226. }
  227. if ((pwszGuid == NULL) || (pIntfParams == NULL))
  228. {
  229. dwRetCode = ERROR_INVALID_PARAMETER;
  230. break;
  231. }
  232. ACQUIRE_WRITE_LOCK (&g_PolicyLock);
  233. if (ElFindPolicyData (
  234. pIntfParams->dwSizeOfSSID,
  235. pIntfParams->bSSID,
  236. g_pEAPOLPolicyList,
  237. &pEAPOLPolicyData
  238. ) == NO_ERROR)
  239. {
  240. fPolicyFound = TRUE;
  241. }
  242. RELEASE_WRITE_LOCK (&g_PolicyLock);
  243. if (fPolicyFound)
  244. {
  245. if ((dwRetCode = ElGetInterfaceParams (
  246. pwszGuid,
  247. &PolicyIntfParams
  248. )) == NO_ERROR)
  249. {
  250. if (memcmp ((PVOID)pIntfParams, (PVOID)&PolicyIntfParams,
  251. sizeof(EAPOL_INTF_PARAMS)) != 0)
  252. {
  253. TRACE0 (RPC, "RpcEapolSetInterfaceParams: POLICY: Cannot change data for global setting data");
  254. dwRetCode = ERROR_ACCESS_DENIED;
  255. break;
  256. }
  257. else
  258. {
  259. // ignore setting
  260. break;
  261. }
  262. }
  263. else
  264. {
  265. break;
  266. }
  267. }
  268. if ((dwRetCode = ElSetInterfaceParams (
  269. pwszGuid,
  270. pIntfParams
  271. )) != NO_ERROR)
  272. {
  273. break;
  274. }
  275. // Setting interface params will be the only action that will
  276. // cause 802.1X to restart state machine
  277. if ((dwRetCode = ElPostEapConfigChanged (
  278. pwszGuid,
  279. pIntfParams))
  280. != NO_ERROR)
  281. {
  282. break;
  283. }
  284. }
  285. while (FALSE);
  286. InterlockedDecrement (&g_lWorkerThreads);
  287. return dwRetCode;
  288. }
  289. DWORD
  290. RpcEapolReAuthenticateInterface (
  291. STRING_HANDLE pSrvAddr,
  292. PWCHAR pwszGuid
  293. )
  294. {
  295. DWORD dwRetCode = NO_ERROR;
  296. InterlockedIncrement (&g_lWorkerThreads);
  297. do
  298. {
  299. if ((dwRetCode = WZCSvcCheckRPCAccess (WZC_ACCESS_QUERY)) != NO_ERROR)
  300. {
  301. break;
  302. }
  303. if (!(g_dwModulesStarted & ALL_MODULES_STARTED))
  304. {
  305. dwRetCode = ERROR_INVALID_STATE;
  306. break;
  307. }
  308. if (pwszGuid == NULL)
  309. {
  310. dwRetCode = ERROR_INVALID_PARAMETER;
  311. break;
  312. }
  313. if ((dwRetCode = ElReAuthenticateInterface (
  314. pwszGuid))
  315. != NO_ERROR)
  316. {
  317. TRACE1 (RPC, "RpcEapolReAuthenticateInterface: ElEnumAndOpenInterfaces returned error %ld",
  318. dwRetCode);
  319. }
  320. }
  321. while (FALSE);
  322. InterlockedDecrement (&g_lWorkerThreads);
  323. return dwRetCode;
  324. }
  325. DWORD
  326. RpcEapolQueryInterfaceState (
  327. STRING_HANDLE pSrvAddr,
  328. PWCHAR pwszGuid,
  329. PEAPOL_INTF_STATE pIntfState
  330. )
  331. {
  332. DWORD dwRetCode = NO_ERROR;
  333. InterlockedIncrement (&g_lWorkerThreads);
  334. do
  335. {
  336. if ((dwRetCode = WZCSvcCheckRPCAccess (WZC_ACCESS_QUERY)) != NO_ERROR)
  337. {
  338. break;
  339. }
  340. if (!(g_dwModulesStarted & ALL_MODULES_STARTED))
  341. {
  342. dwRetCode = ERROR_INVALID_STATE;
  343. break;
  344. }
  345. if (pwszGuid == NULL)
  346. {
  347. dwRetCode = ERROR_INVALID_PARAMETER;
  348. break;
  349. }
  350. if ((dwRetCode = ElQueryInterfaceState (
  351. pwszGuid,
  352. pIntfState
  353. )) != NO_ERROR)
  354. {
  355. TRACE1 (RPC, "RpcEapolQueryInterfaceState: ElQueryInterfaceState failed with error %ld",
  356. dwRetCode);
  357. }
  358. }
  359. while (FALSE);
  360. InterlockedDecrement (&g_lWorkerThreads);
  361. return dwRetCode;
  362. }
  363. DWORD
  364. RpcEapolUIResponse (
  365. IN LPWSTR pSrvAddr,
  366. IN EAPOL_EAP_UI_CONTEXT EapolUIContext,
  367. IN EAPOLUI_RESP EapolUIResp
  368. )
  369. {
  370. EAPOLUIRESPFUNC *pEapolUIRespFunc = NULL;
  371. DWORD dwIndex = 0;
  372. DWORD dwBlob = 0;
  373. DWORD dwRetCode = NO_ERROR;
  374. InterlockedIncrement (&g_lWorkerThreads);
  375. do
  376. {
  377. if ((dwRetCode = WZCSvcCheckRPCAccess (WZC_ACCESS_QUERY)) != NO_ERROR)
  378. {
  379. break;
  380. }
  381. if (!(g_dwModulesStarted & ALL_MODULES_STARTED))
  382. {
  383. dwRetCode = ERROR_INVALID_STATE;
  384. break;
  385. }
  386. for (dwIndex=0; dwIndex < NUM_EAPOL_DLG_MSGS; dwIndex++)
  387. {
  388. if (EapolUIContext.dwEAPOLUIMsgType ==
  389. EapolUIRespFuncMap[dwIndex].dwEAPOLUIMsgType)
  390. {
  391. if (EapolUIRespFuncMap[dwIndex].EapolRespUIFunc)
  392. {
  393. // Verify if right number of data blobs are passed
  394. // Blobs may have '0' length
  395. for (dwBlob=0; dwBlob < EapolUIRespFuncMap[dwIndex].dwNumBlobs; dwBlob++)
  396. {
  397. #if 0
  398. if (IsBadReadPtr (EapolUIResp.rdData[dwBlob].pData,
  399. EapolUIResp.rdData[dwBlob].dwDataLen))
  400. {
  401. TRACE1 (RPC, "RpcEapolUIResponse: Bad blob %ld",
  402. dwBlob);
  403. dwRetCode = ERROR_INVALID_DATA;
  404. goto Error;
  405. }
  406. #endif
  407. }
  408. TRACE1 (RPC, "RpcEapolUIResponse: Response function found, msg (%ld)",
  409. EapolUIContext.dwEAPOLUIMsgType);
  410. if ((dwRetCode =
  411. EapolUIRespFuncMap[dwIndex].EapolRespUIFunc (
  412. EapolUIContext,
  413. EapolUIResp
  414. )) != NO_ERROR)
  415. {
  416. TRACE1 (RPC, "RpcEapolUIResponse: Response function failed with error %ld",
  417. dwRetCode);
  418. }
  419. }
  420. else
  421. {
  422. TRACE1 (RPC, "RpcEapolUIResponse: No response function, msg (%ld)",
  423. EapolUIContext.dwEAPOLUIMsgType);
  424. }
  425. break;
  426. }
  427. }
  428. }
  429. while (FALSE);
  430. // Error:
  431. InterlockedDecrement (&g_lWorkerThreads);
  432. return dwRetCode;
  433. }