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.

238 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 2000, Microsoft Corporation
  3. Module Name:
  4. elnotify.cpp
  5. Abstract:
  6. Module to handle the notification from 802.1X state machine to netshell
  7. Revision History:
  8. sachins, Jan 04, 2001, Created
  9. --*/
  10. #include "pcheapol.h"
  11. #pragma hdrstop
  12. #include <netconp.h>
  13. #include <dbt.h>
  14. #include "elnotify.h"
  15. HRESULT QueueEvent(EAPOLMAN_EVENT * pEvent)
  16. {
  17. HRESULT hr = S_OK;
  18. INetConnectionEAPOLEventNotify *pEAPOLNotify = NULL;
  19. TRACE0 (NOTIFY, "QueueEvent: Entered");
  20. hr = CoInitializeEx (NULL, COINIT_MULTITHREADED);
  21. if (SUCCEEDED (hr))
  22. {
  23. hr = CoCreateInstance (
  24. CLSID_EAPOLManager,
  25. NULL,
  26. CLSCTX_ALL,
  27. IID_INetConnectionEAPOLEventNotify,
  28. (LPVOID *)&pEAPOLNotify);
  29. if (SUCCEEDED (hr))
  30. {
  31. TRACE0 (NOTIFY, "QueueEvent: CoCreateInstance succeeded");
  32. pEAPOLNotify->UpdateEAPOLInfo (pEvent);
  33. pEAPOLNotify->Release ();
  34. }
  35. else
  36. {
  37. TRACE0 (NOTIFY, "QueueEvent: CoCreateInstance failed");
  38. }
  39. CoUninitialize ();
  40. }
  41. else
  42. {
  43. TRACE0 (NOTIFY, "QueueEvent: CoInitializeEx failed");
  44. }
  45. TRACE0 (NOTIFY, "QueueEvent completed");
  46. CoTaskMemFree (pEvent);
  47. return hr;
  48. }
  49. //+---------------------------------------------------------------------------
  50. //
  51. // EAPOLMANAuthenticationStarted
  52. //
  53. // Purpose: Called by EAPOL module to indicate to netshell that
  54. // authentication has started
  55. //
  56. // Arguments:
  57. // Interface GUID
  58. //
  59. // Returns: nothing
  60. //
  61. //
  62. HRESULT EAPOLMANAuthenticationStarted(GUID * InterfaceId)
  63. {
  64. EAPOLMAN_EVENT * pEvent = NULL;
  65. HRESULT hr = S_OK;
  66. TRACE0 (NOTIFY, "EAPOLMANAuthenticationStarted entered");
  67. pEvent = (EAPOLMAN_EVENT *) CoTaskMemAlloc (sizeof (EAPOLMAN_EVENT));
  68. if(!pEvent)
  69. {
  70. TRACE0 (NOTIFY, "EAPOLMANAuthenticationStarted: Out of memory for pEvent");
  71. return E_OUTOFMEMORY;
  72. }
  73. ZeroMemory(pEvent, sizeof(EAPOLMAN_EVENT));
  74. pEvent->Type = EAPOLMAN_STARTED;
  75. memcpy ((BYTE *)&pEvent->InterfaceId, (BYTE *)InterfaceId, sizeof (GUID));
  76. hr = QueueEvent(pEvent);
  77. TRACE0 (NOTIFY, "EAPOLMANAuthenticationStarted completed");
  78. return hr;
  79. }
  80. //
  81. //
  82. // EAPOLMANAuthenticationSucceeded
  83. //
  84. // Purpose: Called by EAPOL module to indicate to netshell that
  85. // authentication succeeded
  86. //
  87. // Arguments:
  88. // Interface GUID
  89. //
  90. // Returns: nothing
  91. //
  92. HRESULT EAPOLMANAuthenticationSucceeded(GUID * InterfaceId)
  93. {
  94. EAPOLMAN_EVENT * pEvent = NULL;
  95. HRESULT hr = S_OK;
  96. TRACE0 (NOTIFY, "EAPOLMANAuthenticationSucceeded entered");
  97. pEvent = (EAPOLMAN_EVENT *) CoTaskMemAlloc (sizeof (EAPOLMAN_EVENT));
  98. if(!pEvent)
  99. {
  100. TRACE0 (NOTIFY, "EAPOLMANAuthenticationSucceeded: Out of memory for pEvent");
  101. return E_OUTOFMEMORY;
  102. }
  103. ZeroMemory(pEvent, sizeof(EAPOLMAN_EVENT));
  104. pEvent->Type = EAPOLMAN_SUCCEEDED;
  105. memcpy ((BYTE *)&pEvent->InterfaceId, (BYTE *)InterfaceId, sizeof (GUID));
  106. hr = QueueEvent(pEvent);
  107. TRACE0 (NOTIFY, "EAPOLMANAuthenticationSucceeded completed");
  108. return hr;
  109. }
  110. //
  111. //
  112. // EAPOLMANAuthenticationFailed
  113. //
  114. // Purpose: Called by EAPOL module to indicate to netshell that
  115. // authentication failed
  116. //
  117. // Arguments:
  118. // InterfaceId - Interface GUID
  119. // dwType - Type of error
  120. //
  121. // Returns: nothing
  122. //
  123. HRESULT EAPOLMANAuthenticationFailed(
  124. GUID * InterfaceId,
  125. DWORD dwType)
  126. {
  127. EAPOLMAN_EVENT * pEvent = NULL;
  128. HRESULT hr = S_OK;
  129. TRACE0 (NOTIFY, "EAPOLMANAuthenticationFailed entered");
  130. pEvent = (EAPOLMAN_EVENT *) CoTaskMemAlloc (sizeof (EAPOLMAN_EVENT));
  131. if(!pEvent)
  132. {
  133. return E_OUTOFMEMORY;
  134. }
  135. ZeroMemory(pEvent, sizeof(EAPOLMAN_EVENT));
  136. pEvent->Type = EAPOLMAN_FAILED;
  137. memcpy ((BYTE *)&pEvent->InterfaceId, (BYTE *)InterfaceId, sizeof (GUID));
  138. pEvent->dwType = dwType;
  139. hr = QueueEvent(pEvent);
  140. TRACE0 (NOTIFY, "EAPOLMANAuthenticationFailed completed");
  141. return hr;
  142. }
  143. //
  144. //
  145. // EAPOLMANNotification
  146. //
  147. // Purpose: Called by EAPOL module to indicate to netshell that
  148. // notification message needs to be displayed
  149. //
  150. // Arguments:
  151. // InterfaceId - Interface GUID
  152. // pszwNotificationMessage - Pointer to notification string to be displayed
  153. // dwType - Type of error
  154. //
  155. // Returns: nothing
  156. //
  157. HRESULT EAPOLMANNotification(
  158. GUID * InterfaceId,
  159. LPWSTR pszwNotificationMessage,
  160. DWORD dwType)
  161. {
  162. EAPOLMAN_EVENT * pEvent = NULL;
  163. HRESULT hr = S_OK;
  164. TRACE0 (NOTIFY, "EAPOLMANNotification entered");
  165. pEvent = (EAPOLMAN_EVENT *) CoTaskMemAlloc (sizeof (EAPOLMAN_EVENT));
  166. if(!pEvent)
  167. {
  168. return E_OUTOFMEMORY;
  169. }
  170. ZeroMemory(pEvent, sizeof(EAPOLMAN_EVENT));
  171. pEvent->Type = EAPOLMAN_NOTIFICATION;
  172. memcpy ((BYTE *)&pEvent->InterfaceId, (BYTE *)InterfaceId, sizeof (GUID));
  173. pEvent->dwType = dwType;
  174. wcscpy (pEvent->szwMessage, pszwNotificationMessage);
  175. TRACE2 (NOTIFY, "EAPOLMANNotification: Got string = %ws :: Event string = %ws", pszwNotificationMessage, pEvent->szwMessage);
  176. hr = QueueEvent(pEvent);
  177. TRACE0 (NOTIFY, "EAPOLMANNotification completed");
  178. return hr;
  179. }