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.

274 lines
12 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 0x1ffffc // Used in timers
  28. #define MAX_PACKET_SIZE 1518
  29. #define MAX_EAPOL_BUFFER_SIZE 1498 // Ethernet header + CRC + 802.1P
  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_MIN_RESTART_INTERVAL 2000 // Minimum msec between 2 restarts
  39. #define EAPOL_HEAP_INITIAL_SIZE 50000
  40. #define EAPOL_HEAP_MAX_SIZE 0
  41. #define EAPOL_SERVICE_NAME TEXT("EAPOL")
  42. #define EAPOL_MAX_START 3
  43. #define EAPOL_START_PERIOD 60
  44. #define EAPOL_AUTH_PERIOD 30
  45. #define EAPOL_HELD_PERIOD 60
  46. #define EAPOL_MAX_AUTH_FAIL_COUNT 3
  47. #define EAPOL_TOTAL_MAX_AUTH_FAIL_COUNT 9
  48. #define MAX_CHALLENGE_SIZE 8
  49. #define MAX_RESPONSE_SIZE 24
  50. #define EAP_TYPE_MD5 4
  51. #define EAP_TYPE_TLS 13
  52. #define NDIS_802_11_SSID_LEN 36
  53. #define GUID_STRING_LEN_WITH_TERM 39
  54. #define MAX_NOTIFICATION_MSG_SIZE 255
  55. // Module startup flags
  56. #define WMI_MODULE_STARTED 0x0001
  57. #define DEVICE_NOTIF_STARTED 0x0002
  58. #define EAPOL_MODULE_STARTED 0x0004
  59. #define BINDINGS_MODULE_STARTED 0x0008
  60. #define LOGON_MODULE_STARTED 0x0010
  61. #ifndef ZEROCONFIG_LINKED
  62. #define ALL_MODULES_STARTED 0x001f
  63. #else
  64. #define ALL_MODULES_STARTED 0x0014
  65. #endif
  66. // Definitions
  67. //#define LOCKSTORE (&(g_dlsDynamicLocksStore))
  68. #define TRACEID g_dwTraceId
  69. #define LOGHANDLE g_hLogEvents
  70. // Macros
  71. #define SWAP(a, b, c) { (c)=(a); (a)=(b); (b)=(c); }
  72. #define MAX(a, b) (((a) >= (b)) ? (a) : (b))
  73. #define MIN(a, b) (((a) <= (b)) ? (a) : (b))
  74. #define ISSET(i, flag) ((i)->dwFlags & (flag))
  75. #define SET(i, flag) ((i)->dwFlags |= (flag))
  76. #define RESET(i, flag) ((i)->dwFlags &= ~(flag))
  77. //
  78. // TIMER
  79. //
  80. // Definitions
  81. #define BLOCKING -1
  82. #define NONBLOCKING NULL
  83. #define MAX_TIME 0xffffffff
  84. #define SECTOMILLISEC(x) ((x) * 1000)
  85. // current time
  86. #define Now() (((ULONG)GetTickCount()) / 1000)
  87. // Macros
  88. // Timers will always be one-shot and they will execute in I/O component
  89. // thread
  90. #define CREATE_TIMER(phHandle, pfn, pvContext, ulWhen, szName, pdwRetCode) \
  91. { \
  92. TRACE2(ANY, "TIMER: Create %-20s\tTime: %u", szName, ulWhen); \
  93. if (CreateTimerQueueTimer((phHandle), \
  94. g_hTimerQueue, \
  95. (pfn), \
  96. (pvContext), \
  97. SECTOMILLISEC(ulWhen), \
  98. INFINITE_INTERVAL, \
  99. WT_EXECUTEDEFAULT)) \
  100. { \
  101. *(pdwRetCode) = NO_ERROR; \
  102. } \
  103. else \
  104. { \
  105. *(phHandle) = NULL; \
  106. *(pdwRetCode) = GetLastError(); \
  107. TRACE1(ANY, "Error %u creating timer", *(pdwRetCode)); \
  108. } \
  109. }
  110. // it is safe to hold locks while making this call if
  111. // 1. tType is NONBLOCKING or
  112. // 2. tType is BLOCKING and
  113. // the callback function doesn't acquire any of these locks
  114. #define DELETE_TIMER(hHandle, tType, pdwRetCode) \
  115. { \
  116. if (DeleteTimerQueueTimer(g_hTimerQueue, \
  117. (hHandle), \
  118. (HANDLE)tType)) \
  119. { \
  120. *(pdwRetCode) = NO_ERROR; \
  121. } \
  122. else \
  123. { \
  124. *(pdwRetCode) = GetLastError(); \
  125. TRACE1(ANY, "Error %u deleting timer, continuing...", *(pdwRetCode)); \
  126. } \
  127. }
  128. #define RESTART_TIMER(hHandle, ulWhen, szName, pdwRetCode) \
  129. { \
  130. TRACE2(ANY, "TIMER: Restart %-20s\tTime: %u", szName, ulWhen); \
  131. if (ChangeTimerQueueTimer(g_hTimerQueue, \
  132. (hHandle), \
  133. SECTOMILLISEC(ulWhen), \
  134. INFINITE_INTERVAL)) \
  135. { \
  136. *(pdwRetCode) = NO_ERROR; \
  137. } \
  138. else \
  139. { \
  140. *(pdwRetCode) = GetLastError(); \
  141. TRACE1(ANY, "Error %u restarting timer, continuing...", *(pdwRetCode)); \
  142. } \
  143. }
  144. // MEMORY ALLOCATION
  145. // MACROS
  146. #define MALLOC(s) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (s))
  147. #define FREE(p) HeapFree(GetProcessHeap(), 0, (p))
  148. //
  149. // TRACING
  150. //
  151. // Definitions
  152. #define EAPOL_TRACE_ANY ((DWORD)0xFFFF0000 | TRACE_USE_MASK)
  153. #define EAPOL_TRACE_EAPOL ((DWORD)0x00010000 | TRACE_USE_MASK)
  154. #define EAPOL_TRACE_EAP ((DWORD)0x00020000 | TRACE_USE_MASK)
  155. #define EAPOL_TRACE_INIT ((DWORD)0x00040000 | TRACE_USE_MASK)
  156. #define EAPOL_TRACE_DEVICE ((DWORD)0x00080000 | TRACE_USE_MASK)
  157. #define EAPOL_TRACE_LOCK ((DWORD)0x00100000 | TRACE_USE_MASK)
  158. #define EAPOL_TRACE_PORT ((DWORD)0x00200000 | TRACE_USE_MASK)
  159. #define EAPOL_TRACE_TIMER ((DWORD)0x00400000 | TRACE_USE_MASK)
  160. #define EAPOL_TRACE_USER ((DWORD)0x00800000 | TRACE_USE_MASK)
  161. #define EAPOL_TRACE_NOTIFY ((DWORD)0x01000000 | TRACE_USE_MASK)
  162. #define EAPOL_TRACE_RPC ((DWORD)0x02000000 | TRACE_USE_MASK)
  163. // Macros
  164. #define TRACE0(l,a) \
  165. if (TRACEID != INVALID_TRACEID) \
  166. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a)
  167. #define TRACE1(l,a,b) \
  168. if (TRACEID != INVALID_TRACEID) \
  169. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b)
  170. #define TRACE2(l,a,b,c) \
  171. if (TRACEID != INVALID_TRACEID) \
  172. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c)
  173. #define TRACE3(l,a,b,c,d) \
  174. if (TRACEID != INVALID_TRACEID) \
  175. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c, d)
  176. #define TRACE4(l,a,b,c,d,e) \
  177. if (TRACEID != INVALID_TRACEID) \
  178. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c, d, e)
  179. #define TRACE5(l,a,b,c,d,e,f) \
  180. if (TRACEID != INVALID_TRACEID) \
  181. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c, d, e, f)
  182. #define TRACE6(l,a,b,c,d,e,f,g) \
  183. if (TRACEID != INVALID_TRACEID) \
  184. TracePrintfExA(TRACEID, EAPOL_TRACE_ ## l, a, b, c, d, e, f, g)
  185. #define EAPOL_DUMPW(pBuf,dwBuf) \
  186. TraceDumpEx(TRACEID, 0x00010000 | TRACE_USE_MASK,(LPBYTE)pbBuf,dwBuf,4,1,NULL)
  187. #define EAPOL_DUMPB(pbBuf,dwBuf) \
  188. TraceDumpEx(TRACEID, 0x00010000 | TRACE_USE_MASK,(LPBYTE)pbBuf,dwBuf,1,0,NULL)
  189. #define EAPOL_DUMPBA(pbBuf,dwBuf) \
  190. TraceDumpExA(TRACEID, 0x00010000 | TRACE_USE_MASK,(LPBYTE)pbBuf,dwBuf,1,0,NULL)
  191. //
  192. // EVENT LOGGING
  193. //
  194. #define EapolLogError( LogId, NumStrings, lpwsSubStringArray, dwRetCode ) \
  195. RouterLogError( g_hLogEvents, LogId, NumStrings, lpwsSubStringArray, \
  196. dwRetCode )
  197. #define EapolLogWarning( LogId, NumStrings, lpwsSubStringArray ) \
  198. RouterLogWarning( g_hLogEvents, LogId, NumStrings, lpwsSubStringArray, 0 )
  199. #define EapolLogInformation( LogId, NumStrings, lpwsSubStringArray ) \
  200. RouterLogInformation(g_hLogEvents,LogId, NumStrings, lpwsSubStringArray,0)
  201. #define EapolLogErrorString(LogId,NumStrings,lpwsSubStringArray,dwRetCode, \
  202. dwPos ) \
  203. RouterLogErrorString( g_hLogEvents, LogId, NumStrings, \
  204. lpwsSubStringArray, dwRetCode, dwPos )
  205. #define EapolLogWarningString( LogId,NumStrings,lpwsSubStringArray,dwRetCode, \
  206. dwPos ) \
  207. RouterLogWarningString( g_hLogEvents, LogId, NumStrings, \
  208. lpwsSubStringArray, dwRetCode, dwPos )
  209. #define EapolLogInformationString( LogId, NumStrings, lpwsSubStringArray, \
  210. dwRetCode, dwPos ) \
  211. RouterLogInformationString( g_hLogEvents, LogId, \
  212. NumStrings, lpwsSubStringArray, dwRetCode,dwPos)
  213. #endif // _EAPOL_DEFS_H_