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.

271 lines
11 KiB

  1. /*++
  2. Copyright (c) 2000, Microsoft Corporation
  3. Module Name:
  4. eldefs.h
  5. Abstract:
  6. The module contains various
  7. . constants
  8. . definitions
  9. . macros
  10. for the following functions:
  11. - memory-allocation
  12. - logging
  13. - tracing
  14. Revision History:
  15. sachins, Apr 23 2000, Created
  16. --*/
  17. #ifndef _EAPOL_DEFS_H_
  18. #define _EAPOL_DEFS_H_
  19. // Constants
  20. #define PORT_TABLE_BUCKETS 29 // # buckets in the port hash table
  21. #define INTF_TABLE_BUCKETS 29 // # buckets in the interface hash table
  22. #define MAX_PORT_NAME 255 // Max friendly name of the adapter
  23. #define MAX_NDIS_DEVICE_NAME_LEN 255 // NDIS UI device name
  24. #define NOW 0
  25. #define DELTA 1
  26. #define INFINITE_INTERVAL 0x7fffffff // Used in timers
  27. #define INFINITE_SECONDS 0x7ffff // Used in timers
  28. #define MAX_PACKET_SIZE 1518
  29. #define MAX_EAPOL_BUFFER_SIZE 1502
  30. #define SIZE_ETHERNET_CRC 4
  31. #define WAP_LEEWAY 100
  32. #define SIZE_ETHERNET_TYPE 2
  33. #define SIZE_PROTOCOL_VERSION 2
  34. #define EAPOL_8021P_TAG_TYPE 0x0081
  35. #define SIZE_MAC_ADDR 6
  36. #define EAPOL_INIT_START_PERIOD 1 // 1 sec interval between EAPOL_Start
  37. // packets with no user logged on
  38. #define EAPOL_HEAP_INITIAL_SIZE 50000
  39. #define EAPOL_HEAP_MAX_SIZE 0
  40. #define EAPOL_SERVICE_NAME TEXT("EAPOL")
  41. #define EAPOL_MAX_START 3
  42. #define EAPOL_START_PERIOD 60
  43. #define EAPOL_AUTH_PERIOD 30
  44. #define EAPOL_HELD_PERIOD 60
  45. #define EAPOL_MAX_AUTH_FAIL_COUNT 3
  46. #define MAX_CHALLENGE_SIZE 8
  47. #define MAX_RESPONSE_SIZE 24
  48. #define EAP_TYPE_MD5 4
  49. #define EAP_TYPE_TLS 13
  50. #define EAPOL_DISABLED 0
  51. #define EAPOL_ENABLED 1
  52. #define VERSION7 7
  53. #define VERSION8 8
  54. // Default per interface values
  55. #define DEFAULT_EAP_TYPE EAP_TYPE_TLS
  56. #define DEFAULT_EAPOL_STATE EAPOL_ENABLED
  57. #define MAX_NOTIFICATION_MSG_SIZE 255
  58. // Module startup flags
  59. #define DEVICE_MODULE_STARTED 0x0001
  60. #define WMI_MODULE_STARTED 0x0002
  61. #define DEVICE_NOTIF_STARTED 0x0004
  62. #define EAPOL_MODULE_STARTED 0x0008
  63. // Definitions
  64. //#define LOCKSTORE (&(g_dlsDynamicLocksStore))
  65. #define TRACEID g_dwTraceId
  66. #define LOGHANDLE g_hLogEvents
  67. // Macros
  68. #define SWAP(a, b, c) { (c)=(a); (a)=(b); (b)=(c); }
  69. #define MAX(a, b) (((a) >= (b)) ? (a) : (b))
  70. #define MIN(a, b) (((a) <= (b)) ? (a) : (b))
  71. #define ISSET(i, flag) ((i)->dwFlags & (flag))
  72. #define SET(i, flag) ((i)->dwFlags |= (flag))
  73. #define RESET(i, flag) ((i)->dwFlags &= ~(flag))
  74. //
  75. // TIMER
  76. //
  77. // Definitions
  78. #define BLOCKING -1
  79. #define NONBLOCKING NULL
  80. #define MAX_TIME 0xffffffff
  81. #define SECTOMILLISEC(x) ((x) * 1000)
  82. // current time
  83. #define Now() (((ULONG)GetTickCount()) / 1000)
  84. // Macros
  85. // Timers will always be one-shot and they will execute in I/O component
  86. // thread
  87. #define CREATE_TIMER(phHandle, pfn, pvContext, ulWhen, szName, pdwRetCode) \
  88. { \
  89. TRACE2(ANY, "TIMER: Create %-20s\tTime: %u", szName, ulWhen); \
  90. if (CreateTimerQueueTimer((phHandle), \
  91. g_hTimerQueue, \
  92. (pfn), \
  93. (pvContext), \
  94. SECTOMILLISEC(ulWhen), \
  95. INFINITE_INTERVAL, \
  96. WT_EXECUTEINIOTHREAD)) \
  97. { \
  98. *(pdwRetCode) = NO_ERROR; \
  99. } \
  100. else \
  101. { \
  102. *(phHandle) = NULL; \
  103. *(pdwRetCode) = GetLastError(); \
  104. TRACE1(ANY, "Error %u creating timer", *(pdwRetCode)); \
  105. } \
  106. }
  107. // it is safe to hold locks while making this call if
  108. // 1. tType is NONBLOCKING or
  109. // 2. tType is BLOCKING and
  110. // the callback function doesn't acquire any of these locks
  111. #define DELETE_TIMER(hHandle, tType, pdwRetCode) \
  112. { \
  113. if (DeleteTimerQueueTimer(g_hTimerQueue, \
  114. (hHandle), \
  115. (HANDLE)tType)) \
  116. { \
  117. *(pdwRetCode) = NO_ERROR; \
  118. } \
  119. else \
  120. { \
  121. *(pdwRetCode) = GetLastError(); \
  122. TRACE1(ANY, "Error %u deleting timer, continuing...", *(pdwRetCode)); \
  123. } \
  124. }
  125. #define RESTART_TIMER(hHandle, ulWhen, szName, pdwRetCode) \
  126. { \
  127. TRACE2(ANY, "TIMER: Restart %-20s\tTime: %u", szName, ulWhen); \
  128. if (ChangeTimerQueueTimer(g_hTimerQueue, \
  129. (hHandle), \
  130. SECTOMILLISEC(ulWhen), \
  131. INFINITE_INTERVAL)) \
  132. { \
  133. *(pdwRetCode) = NO_ERROR; \
  134. } \
  135. else \
  136. { \
  137. *(pdwRetCode) = GetLastError(); \
  138. TRACE1(ANY, "Error %u restarting timer, continuing...", *(pdwRetCode)); \
  139. DebugBreak (); \
  140. } \
  141. }
  142. // MEMORY ALLOCATION
  143. // MACROS
  144. #define MALLOC(s) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (s))
  145. #define FREE(p) HeapFree(GetProcessHeap(), 0, (p))
  146. //
  147. // TRACING
  148. //
  149. // Definitions
  150. #define EAPOL_TRACE_ANY ((DWORD)0xFFFF0000 | TRACE_USE_MASK)
  151. #define EAPOL_TRACE_EAPOL ((DWORD)0x00010000 | TRACE_USE_MASK)
  152. #define EAPOL_TRACE_EAP ((DWORD)0x00020000 | TRACE_USE_MASK)
  153. #define EAPOL_TRACE_INIT ((DWORD)0x00040000 | TRACE_USE_MASK)
  154. #define EAPOL_TRACE_DEVICE ((DWORD)0x00080000 | TRACE_USE_MASK)
  155. #define EAPOL_TRACE_LOCK ((DWORD)0x00100000 | TRACE_USE_MASK)
  156. #define EAPOL_TRACE_PORT ((DWORD)0x00200000 | TRACE_USE_MASK)
  157. #define EAPOL_TRACE_TIMER ((DWORD)0x00400000 | TRACE_USE_MASK)
  158. #define EAPOL_TRACE_USER ((DWORD)0x00800000 | TRACE_USE_MASK)
  159. // Macros
  160. #define TRACE0(l,a) \
  161. if (TRACEID != INVALID_TRACEID) \
  162. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a)
  163. #define TRACE1(l,a,b) \
  164. if (TRACEID != INVALID_TRACEID) \
  165. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b)
  166. #define TRACE2(l,a,b,c) \
  167. if (TRACEID != INVALID_TRACEID) \
  168. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c)
  169. #define TRACE3(l,a,b,c,d) \
  170. if (TRACEID != INVALID_TRACEID) \
  171. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c, d)
  172. #define TRACE4(l,a,b,c,d,e) \
  173. if (TRACEID != INVALID_TRACEID) \
  174. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c, d, e)
  175. #define TRACE5(l,a,b,c,d,e,f) \
  176. if (TRACEID != INVALID_TRACEID) \
  177. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c, d, e, f)
  178. #define TRACE6(l,a,b,c,d,e,f,g) \
  179. if (TRACEID != INVALID_TRACEID) \
  180. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c, d, e, f, g)
  181. #define EAPOL_DUMPW(pBuf,dwBuf) \
  182. TraceDumpEx(TRACEID, 0x00010000 | TRACE_USE_MASK,(LPBYTE)pbBuf,dwBuf,4,1,NULL)
  183. #define EAPOL_DUMPB(pbBuf,dwBuf) \
  184. TraceDumpEx(TRACEID, 0x00010000 | TRACE_USE_MASK,(LPBYTE)pbBuf,dwBuf,1,0,NULL)
  185. #define EAPOL_DUMPBA(pbBuf,dwBuf) \
  186. TraceDumpExA(TRACEID, 0x00010000 | TRACE_USE_MASK,(LPBYTE)pbBuf,dwBuf,1,0,NULL)
  187. //
  188. // EVENT LOGGING
  189. //
  190. #define EapolLogError( LogId, NumStrings, lpwsSubStringArray, dwRetCode ) \
  191. RouterLogError( g_hLogEvents, LogId, NumStrings, lpwsSubStringArray, \
  192. dwRetCode )
  193. #define EapolLogWarning( LogId, NumStrings, lpwsSubStringArray ) \
  194. RouterLogWarning( g_hLogEvents, LogId, NumStrings, lpwsSubStringArray, 0 )
  195. #define EapolLogInformation( LogId, NumStrings, lpwsSubStringArray ) \
  196. RouterLogInformation(g_hLogEvents,LogId, NumStrings, lpwsSubStringArray,0)
  197. #define EapolLogErrorString(LogId,NumStrings,lpwsSubStringArray,dwRetCode, \
  198. dwPos ) \
  199. RouterLogErrorString( g_hLogEvents, LogId, NumStrings, \
  200. lpwsSubStringArray, dwRetCode, dwPos )
  201. #define EapolLogWarningString( LogId,NumStrings,lpwsSubStringArray,dwRetCode, \
  202. dwPos ) \
  203. RouterLogWarningString( g_hLogEvents, LogId, NumStrings, \
  204. lpwsSubStringArray, dwRetCode, dwPos )
  205. #define EapolLogInformationString( LogId, NumStrings, lpwsSubStringArray, \
  206. dwRetCode, dwPos ) \
  207. RouterLogInformationString( g_hLogEvents, LogId, \
  208. NumStrings, lpwsSubStringArray, dwRetCode,dwPos)
  209. #endif // _EAPOL_DEFS_H_