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.

337 lines
7.8 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|TRACE_USE_DATE)
  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. DATA_BLOB DBPassword;
  98. } EAPCB, *PEAPCB;
  99. #define EAP_FLAG_RESUME_FROM_HIBERNATE 0x00000001
  100. typedef struct _EAP_INFO
  101. {
  102. HINSTANCE hInstance;
  103. DWORD fFlags;
  104. DWORD (APIENTRY *RasEapGetCredentials)(
  105. IN DWORD dwTypeId,
  106. IN VOID * pWorkBuf,
  107. OUT VOID ** pInfo);
  108. PPP_EAP_INFO RasEapInfo;
  109. } EAP_INFO, *PEAP_INFO;
  110. //
  111. // Prototypes
  112. //
  113. DWORD
  114. EapBegin(
  115. OUT VOID** ppWorkBuf,
  116. IN VOID* pInfo
  117. );
  118. DWORD
  119. EapEnd(
  120. IN VOID* pWorkBuf
  121. );
  122. DWORD
  123. EapMakeMessage(
  124. IN VOID* pWorkBuf,
  125. IN PPP_CONFIG* pReceiveBuf,
  126. OUT PPP_CONFIG* pSendBuf,
  127. IN DWORD cbSendBuf,
  128. OUT PPPAP_RESULT* pResult,
  129. IN PPPAP_INPUT* pInput
  130. );
  131. DWORD
  132. MakeRequestAttributes(
  133. IN EAPCB * pEapCb,
  134. IN PPP_CONFIG* pReceiveBuf
  135. );
  136. DWORD
  137. MakeAuthenticateeMessage(
  138. IN EAPCB* pEapCb,
  139. IN PPP_CONFIG* pReceiveBuf,
  140. OUT PPP_CONFIG* pSendBuf,
  141. IN DWORD cbSendBuf,
  142. OUT PPPAP_RESULT* pResult,
  143. IN PPPAP_INPUT* pInput
  144. );
  145. DWORD
  146. MakeAuthenticatorMessage(
  147. IN EAPCB* pEapCb,
  148. IN PPP_CONFIG* pReceiveBuf,
  149. OUT PPP_CONFIG* pSendBuf,
  150. IN DWORD cbSendBuf,
  151. OUT PPPAP_RESULT* pResult,
  152. IN PPPAP_INPUT* pInput
  153. );
  154. DWORD
  155. EapDllBegin(
  156. IN EAPCB * pEapCb,
  157. IN DWORD dwEapIndex
  158. );
  159. BOOL
  160. InRadiusMode(
  161. VOID
  162. );
  163. DWORD
  164. EapDllWork(
  165. IN EAPCB * pEapCb,
  166. IN PPP_CONFIG* pReceiveBuf,
  167. OUT PPP_CONFIG* pSendBuf,
  168. IN DWORD cbSendBuf,
  169. OUT PPPAP_RESULT* pResult,
  170. IN PPPAP_INPUT* pInput
  171. );
  172. DWORD
  173. EapDllEnd(
  174. EAPCB * pEapCb
  175. );
  176. DWORD
  177. GetEapTypeIndex(
  178. IN DWORD dwEapType
  179. );
  180. DWORD
  181. ChapWrapperBegin(
  182. OUT VOID ** ppWorkBuffer,
  183. IN PPP_EAP_INPUT * pPppEapInput
  184. );
  185. DWORD
  186. ChapWrapperEnd(
  187. IN VOID* pWorkBuf
  188. );
  189. DWORD
  190. ChapWrapperMakeMessage(
  191. IN VOID* pWorkBuf,
  192. IN PPP_EAP_PACKET* pReceivePacket,
  193. OUT PPP_EAP_PACKET* pSendPacket,
  194. IN DWORD cbSendPacket,
  195. OUT PPP_EAP_OUTPUT* pEapOutput,
  196. IN PPP_EAP_INPUT* pEapInput
  197. );
  198. VOID
  199. MapEapInputToApInput(
  200. IN PPP_EAP_INPUT* pPppEapInput,
  201. OUT PPPAP_INPUT * pInput
  202. );
  203. //
  204. // Globals.
  205. //
  206. #ifdef RASEAPGLOBALS
  207. #define GLOBALS
  208. #define EXTERN
  209. #else
  210. #define EXTERN extern
  211. #endif
  212. EXTERN EAP_INFO * gblpEapTable
  213. #ifdef GLOBALS
  214. = NULL;
  215. #endif
  216. ;
  217. EXTERN DWORD gbldwNumEapProtocols
  218. #ifdef GLOBALS
  219. = 0;
  220. #endif
  221. ;
  222. EXTERN DWORD gbldwGuid
  223. #ifdef GLOBALS
  224. = 1;
  225. #endif
  226. ;
  227. /* Next packet identifier to assign. Unlike CPs, APs must handle updating
  228. ** this sequence number themselves because the engine can't make as many
  229. ** assumptions about the protocol. It is stored global to all ports and
  230. ** authentication sessions to make it less likely that an ID will be used in
  231. ** sequential authentication sessions. Not to be confused with the 'bIdSent'
  232. ** updated on a per-port basis and used for matching.
  233. */
  234. EXTERN BYTE bNextId
  235. #ifdef GLOBALS
  236. = 0
  237. #endif
  238. ;
  239. EXTERN DWORD g_dwTraceIdEap
  240. #ifdef GLOBALS
  241. = INVALID_TRACEID;
  242. #endif
  243. ;
  244. EXTERN HANDLE g_hLogEvents
  245. #ifdef GLOBALS
  246. = NULL;
  247. #endif
  248. ;
  249. #undef EXTERN
  250. #undef GLOBALS
  251. #endif // _RASEAP_H_