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.

331 lines
7.4 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1985-1997 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: raseap.h
  7. //
  8. // Description: Header for EAP module
  9. //
  10. // History: May 11,1997 NarenG Created original version.
  11. //
  12. #ifndef _RASEAP_H_
  13. #define _RASEAP_H_
  14. //General macros
  15. #define GEN_RAND_ENCODE_SEED ((CHAR) ( 1 + rand() % 250 ))
  16. //
  17. // Tracing and event logging for EAP
  18. //
  19. #define EapLogError( LogId, NumStrings, lpwsSubStringArray, dwRetCode ) \
  20. RouterLogError( g_hLogEvents, LogId, NumStrings, lpwsSubStringArray, \
  21. dwRetCode )
  22. #define EapLogWarning( LogId, NumStrings, lpwsSubStringArray ) \
  23. RouterLogWarning( g_hLogEvents, LogId, NumStrings, lpwsSubStringArray, 0 )
  24. #define EapLogInformation( LogId, NumStrings, lpwsSubStringArray ) \
  25. RouterLogInformation(g_hLogEvents,LogId, NumStrings, lpwsSubStringArray,0)
  26. #define EapLogErrorString(LogId,NumStrings,lpwsSubStringArray,dwRetCode, \
  27. dwPos ) \
  28. RouterLogErrorString( g_hLogEvents, LogId, NumStrings, \
  29. lpwsSubStringArray, dwRetCode, dwPos )
  30. #define EapLogWarningString( LogId,NumStrings,lpwsSubStringArray,dwRetCode, \
  31. dwPos ) \
  32. RouterLogWarningString( g_hLogEvents, LogId, NumStrings, \
  33. lpwsSubStringArray, dwRetCode, dwPos )
  34. #define EapLogInformationString( LogId, NumStrings, lpwsSubStringArray, \
  35. dwRetCode, dwPos ) \
  36. RouterLogInformationString( g_hLogEvents, LogId, \
  37. NumStrings, lpwsSubStringArray, dwRetCode,dwPos)
  38. #define TRACE_RASEAP (0x00010000|TRACE_USE_MASK|TRACE_USE_MSEC)
  39. #define EAP_TRACE(a) TracePrintfExA(g_dwTraceIdEap,TRACE_RASEAP,a )
  40. #define EAP_TRACE1(a,b) TracePrintfExA(g_dwTraceIdEap,TRACE_RASEAP,a,b )
  41. #define EAP_TRACE2(a,b,c) TracePrintfExA(g_dwTraceIdEap,TRACE_RASEAP,a,b,c )
  42. #define EAP_TRACE3(a,b,c,d) TracePrintfExA(g_dwTraceIdEap,TRACE_RASEAP,a,b,c,d )
  43. #define EAP_DUMPW(X,Y) TraceDumpEx(g_dwTraceIdEap,1,(LPBYTE)X,Y,4,1,NULL)
  44. #define EAP_DUMPB(X,Y) TraceDumpEx(g_dwTraceIdEap,1,(LPBYTE)X,Y,1,1,NULL)
  45. //
  46. // Defines states within the EAP protocol.
  47. //
  48. typedef enum _EAPSTATE
  49. {
  50. EAPSTATE_Initial,
  51. EAPSTATE_IdentityRequestSent,
  52. EAPSTATE_Working,
  53. EAPSTATE_EapPacketSentToAuthServer,
  54. EAPSTATE_EapPacketSentToClient,
  55. EAPSTATE_NotificationSentToClient
  56. }EAPSTATE;
  57. typedef enum _EAPTYPE
  58. {
  59. EAPTYPE_Identity = 1,
  60. EAPTYPE_Notification,
  61. EAPTYPE_Nak,
  62. EAPTYPE_MD5Challenge,
  63. EAPTYPE_SKey,
  64. EAPTYPE_GenericTokenCard
  65. }EAPTYPE;
  66. typedef struct _EAPCB
  67. {
  68. EAPSTATE EapState;
  69. HPORT hPort;
  70. BOOL fAuthenticator;
  71. BOOL fRouter;
  72. LPVOID pWorkBuffer;
  73. DWORD dwEapIndex;
  74. DWORD dwEapTypeToBeUsed;
  75. CHAR szIdentity[DNLEN+UNLEN+2];
  76. DWORD dwIdExpected;
  77. HANDLE hTokenImpersonateUser;
  78. PRAS_CUSTOM_AUTH_DATA pCustomAuthConnData;
  79. PRAS_CUSTOM_AUTH_DATA pCustomAuthUserData;
  80. PPP_EAP_UI_DATA EapUIData;
  81. BOOL fLogon;
  82. BOOL fNonInteractive;
  83. BOOL fPortWillBeBundled;
  84. BOOL fThisIsACallback;
  85. CHAR szPassword[ PWLEN + 1 ];
  86. DWORD dwUIInvocationId;
  87. RAS_AUTH_ATTRIBUTE * pUserAttributes;
  88. RAS_AUTH_ATTRIBUTE * pSavedAttributesFromAuthenticator;
  89. DWORD dwSavedAuthResultCode;
  90. PBYTE pEAPSendBuf;
  91. DWORD cbEAPSendBuf;
  92. BOOL fSentPacketToRadiusServer;
  93. BOOL fSendWithTimeoutInteractive;
  94. BYTE * pStateAttribute;
  95. DWORD cbStateAttribute;
  96. CHAR chSeed; //Random seed used for encoding password
  97. } EAPCB, *PEAPCB;
  98. typedef struct _EAP_INFO
  99. {
  100. HINSTANCE hInstance;
  101. DWORD (APIENTRY *RasEapGetCredentials)(
  102. IN DWORD dwTypeId,
  103. IN VOID * pWorkBuf,
  104. OUT VOID ** pInfo);
  105. PPP_EAP_INFO RasEapInfo;
  106. } EAP_INFO, *PEAP_INFO;
  107. //
  108. // Prototypes
  109. //
  110. DWORD
  111. EapBegin(
  112. OUT VOID** ppWorkBuf,
  113. IN VOID* pInfo
  114. );
  115. DWORD
  116. EapEnd(
  117. IN VOID* pWorkBuf
  118. );
  119. DWORD
  120. EapMakeMessage(
  121. IN VOID* pWorkBuf,
  122. IN PPP_CONFIG* pReceiveBuf,
  123. OUT PPP_CONFIG* pSendBuf,
  124. IN DWORD cbSendBuf,
  125. OUT PPPAP_RESULT* pResult,
  126. IN PPPAP_INPUT* pInput
  127. );
  128. DWORD
  129. MakeRequestAttributes(
  130. IN EAPCB * pEapCb,
  131. IN PPP_CONFIG* pReceiveBuf
  132. );
  133. DWORD
  134. MakeAuthenticateeMessage(
  135. IN EAPCB* pEapCb,
  136. IN PPP_CONFIG* pReceiveBuf,
  137. OUT PPP_CONFIG* pSendBuf,
  138. IN DWORD cbSendBuf,
  139. OUT PPPAP_RESULT* pResult,
  140. IN PPPAP_INPUT* pInput
  141. );
  142. DWORD
  143. MakeAuthenticatorMessage(
  144. IN EAPCB* pEapCb,
  145. IN PPP_CONFIG* pReceiveBuf,
  146. OUT PPP_CONFIG* pSendBuf,
  147. IN DWORD cbSendBuf,
  148. OUT PPPAP_RESULT* pResult,
  149. IN PPPAP_INPUT* pInput
  150. );
  151. DWORD
  152. EapDllBegin(
  153. IN EAPCB * pEapCb,
  154. IN DWORD dwEapIndex
  155. );
  156. BOOL
  157. InRadiusMode(
  158. VOID
  159. );
  160. DWORD
  161. EapDllWork(
  162. IN EAPCB * pEapCb,
  163. IN PPP_CONFIG* pReceiveBuf,
  164. OUT PPP_CONFIG* pSendBuf,
  165. IN DWORD cbSendBuf,
  166. OUT PPPAP_RESULT* pResult,
  167. IN PPPAP_INPUT* pInput
  168. );
  169. DWORD
  170. EapDllEnd(
  171. EAPCB * pEapCb
  172. );
  173. DWORD
  174. GetEapTypeIndex(
  175. IN DWORD dwEapType
  176. );
  177. DWORD
  178. ChapWrapperBegin(
  179. OUT VOID ** ppWorkBuffer,
  180. IN PPP_EAP_INPUT * pPppEapInput
  181. );
  182. DWORD
  183. ChapWrapperEnd(
  184. IN VOID* pWorkBuf
  185. );
  186. DWORD
  187. ChapWrapperMakeMessage(
  188. IN VOID* pWorkBuf,
  189. IN PPP_EAP_PACKET* pReceivePacket,
  190. OUT PPP_EAP_PACKET* pSendPacket,
  191. IN DWORD cbSendPacket,
  192. OUT PPP_EAP_OUTPUT* pEapOutput,
  193. IN PPP_EAP_INPUT* pEapInput
  194. );
  195. VOID
  196. MapEapInputToApInput(
  197. IN PPP_EAP_INPUT* pPppEapInput,
  198. OUT PPPAP_INPUT * pInput
  199. );
  200. //
  201. // Globals.
  202. //
  203. #ifdef RASEAPGLOBALS
  204. #define GLOBALS
  205. #define EXTERN
  206. #else
  207. #define EXTERN extern
  208. #endif
  209. EXTERN EAP_INFO * gblpEapTable
  210. #ifdef GLOBALS
  211. = NULL;
  212. #endif
  213. ;
  214. EXTERN DWORD gbldwNumEapProtocols
  215. #ifdef GLOBALS
  216. = 0;
  217. #endif
  218. ;
  219. EXTERN DWORD gbldwGuid
  220. #ifdef GLOBALS
  221. = 1;
  222. #endif
  223. ;
  224. /* Next packet identifier to assign. Unlike CPs, APs must handle updating
  225. ** this sequence number themselves because the engine can't make as many
  226. ** assumptions about the protocol. It is stored global to all ports and
  227. ** authentication sessions to make it less likely that an ID will be used in
  228. ** sequential authentication sessions. Not to be confused with the 'bIdSent'
  229. ** updated on a per-port basis and used for matching.
  230. */
  231. EXTERN BYTE bNextId
  232. #ifdef GLOBALS
  233. = 0
  234. #endif
  235. ;
  236. EXTERN DWORD g_dwTraceIdEap
  237. #ifdef GLOBALS
  238. = INVALID_TRACEID;
  239. #endif
  240. ;
  241. EXTERN HANDLE g_hLogEvents
  242. #ifdef GLOBALS
  243. = NULL;
  244. #endif
  245. ;
  246. #undef EXTERN
  247. #undef GLOBALS
  248. #endif // _RASEAP_H_