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.

215 lines
6.4 KiB

  1. /*+r
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. afd.h
  5. Abstract:
  6. This is the local header file for AFD. It includes all other
  7. necessary header files for AFD.
  8. Author:
  9. David Treadwell (davidtr) 21-Feb-1992
  10. Revision History:
  11. --*/
  12. #ifndef _AFDP_
  13. #define _AFDP_
  14. #ifdef _AFD_W4_
  15. //
  16. // These are warning that we are willing to ignore.
  17. //
  18. #pragma warning(disable:4214) // bit field types other than int
  19. #pragma warning(disable:4201) // nameless struct/union
  20. #pragma warning(disable:4127) // condition expression is constant
  21. #pragma warning(disable:4115) // named type definition in parentheses
  22. //#pragma warning(disable:4206) // translation unit empty
  23. //#pragma warning(disable:4706) // assignment within conditional
  24. #pragma warning(disable:4324) // structure was padded
  25. #pragma warning(disable:4327) // idirection alignment of LHS is greater than RHS
  26. #pragma warning(disable:4328) // greater alignment than needed
  27. #pragma warning(disable:4054) // cast of function pointer to PVOID
  28. //
  29. // Extra initialization to allow compiler check for use of uninitialized
  30. // variables at w4 level. Currently this mostly affects status set
  31. // inside of the exception filter as follows:
  32. // __try {} __except (status=1,EXCEPTION_EXECUTE_HANDLER) { NT_ERROR (status)}
  33. // NT_ERROR(status) - generates uninitialized variable warning and it shouldn't
  34. //
  35. #define AFD_W4_INIT
  36. #else
  37. #define AFD_W4_INIT if (FALSE)
  38. #endif
  39. #include <ntosp.h>
  40. #include <zwapi.h>
  41. #include <tdikrnl.h>
  42. #ifndef _AFDKDP_H_
  43. extern POBJECT_TYPE *ExEventObjectType;
  44. #endif // _AFDKDP_H_
  45. #if DBG
  46. #ifndef AFD_PERF_DBG
  47. #define AFD_PERF_DBG 1
  48. #endif
  49. #ifndef AFD_KEEP_STATS
  50. #define AFD_KEEP_STATS 1
  51. #endif
  52. #else
  53. #ifndef AFD_PERF_DBG
  54. #define AFD_PERF_DBG 0
  55. #endif
  56. #ifndef AFD_KEEP_STATS
  57. #define AFD_KEEP_STATS 0
  58. #endif
  59. #endif // DBG
  60. //
  61. // Hack-O-Rama. TDI has a fundamental flaw in that it is often impossible
  62. // to determine exactly when a TDI protocol is "done" with a connection
  63. // object. The biggest problem here is that AFD may get a suprious TDI
  64. // indication *after* an abort request has completed. As a temporary work-
  65. // around, whenever an abort request completes, we'll start a timer. AFD
  66. // will defer further processing on the connection until that timer fires.
  67. //
  68. // If the following symbol is defined, then our timer hack is enabled.
  69. // Afd now uses InterlockedCompareExchange to protect itself
  70. //
  71. // #define ENABLE_ABORT_TIMER_HACK 0
  72. //
  73. // The following constant defines the relative time interval (in seconds)
  74. // for the "post abort request complete" timer.
  75. //
  76. // #define AFD_ABORT_TIMER_TIMEOUT_VALUE 5 // seconds
  77. //
  78. // Goodies stolen from other header files.
  79. //
  80. #ifndef FAR
  81. #define FAR
  82. #endif
  83. #ifndef max
  84. #define max(a,b) (((a) > (b)) ? (a) : (b))
  85. #endif
  86. #ifndef min
  87. #define min(a,b) (((a) < (b)) ? (a) : (b))
  88. #endif
  89. typedef unsigned short u_short;
  90. #ifndef SG_UNCONSTRAINED_GROUP
  91. #define SG_UNCONSTRAINED_GROUP 0x01
  92. #endif
  93. #ifndef SG_CONSTRAINED_GROUP
  94. #define SG_CONSTRAINED_GROUP 0x02
  95. #endif
  96. #include <afd.h>
  97. #include "afdstr.h"
  98. #include "afddata.h"
  99. #include "afdprocs.h"
  100. #define AFD_EA_POOL_TAG ( (ULONG)'AdfA' | PROTECTED_POOL )
  101. #define AFD_DATA_BUFFER_POOL_TAG ( (ULONG)'BdfA' | PROTECTED_POOL )
  102. #define AFD_CONNECTION_POOL_TAG ( (ULONG)'CdfA' | PROTECTED_POOL )
  103. #define AFD_CONNECT_DATA_POOL_TAG ( (ULONG)'cdfA' | PROTECTED_POOL )
  104. #define AFD_DEBUG_POOL_TAG ( (ULONG)'DdfA' | PROTECTED_POOL )
  105. #define AFD_ENDPOINT_POOL_TAG ( (ULONG)'EdfA' | PROTECTED_POOL )
  106. #define AFD_TRANSMIT_INFO_POOL_TAG ( (ULONG)'FdfA' | PROTECTED_POOL )
  107. #define AFD_GROUP_POOL_TAG ( (ULONG)'GdfA' | PROTECTED_POOL )
  108. #define AFD_ADDRESS_CHANGE_POOL_TAG ( (ULONG)'hdfA' | PROTECTED_POOL )
  109. #define AFD_TDI_POOL_TAG ( (ULONG)'IdfA' | PROTECTED_POOL )
  110. #define AFD_LOCAL_ADDRESS_POOL_TAG ( (ULONG)'LdfA' | PROTECTED_POOL )
  111. #define AFD_POLL_POOL_TAG ( (ULONG)'PdfA' | PROTECTED_POOL )
  112. #define AFD_TRANSPORT_IRP_POOL_TAG ( (ULONG)'pdfA' | PROTECTED_POOL )
  113. #define AFD_ROUTING_QUERY_POOL_TAG ( (ULONG)'qdfA' | PROTECTED_POOL )
  114. #define AFD_REMOTE_ADDRESS_POOL_TAG ( (ULONG)'RdfA' | PROTECTED_POOL )
  115. #define AFD_RESOURCE_POOL_TAG ( (ULONG)'rdfA' | PROTECTED_POOL )
  116. // Can't be protected - freed by kernel.
  117. #define AFD_SECURITY_POOL_TAG ( (ULONG)'SdfA' )
  118. // Can't be protected - freed by kernel.
  119. #define AFD_SYSTEM_BUFFER_POOL_TAG ( (ULONG)'sdfA' )
  120. #define AFD_TRANSPORT_ADDRESS_POOL_TAG ( (ULONG)'tdfA' | PROTECTED_POOL )
  121. #define AFD_TRANSPORT_INFO_POOL_TAG ( (ULONG)'TdfA' | PROTECTED_POOL )
  122. #define AFD_TEMPORARY_POOL_TAG ( (ULONG)' dfA' | PROTECTED_POOL )
  123. #define AFD_CONTEXT_POOL_TAG ( (ULONG)'XdfA' | PROTECTED_POOL )
  124. #define AFD_SAN_CONTEXT_POOL_TAG ( (ULONG)'xdfA' | PROTECTED_POOL )
  125. #define MyFreePoolWithTag(a,t) ExFreePoolWithTag(a,t)
  126. #if DBG
  127. extern ULONG AfdDebug;
  128. #undef IF_DEBUG
  129. #define IF_DEBUG(a) if ( (AFD_DEBUG_ ## a & AfdDebug) != 0 )
  130. #define AFD_DEBUG_OPEN_CLOSE 0x00000001
  131. #define AFD_DEBUG_ENDPOINT 0x00000002
  132. #define AFD_DEBUG_CONNECTION 0x00000004
  133. #define AFD_DEBUG_EVENT_SELECT 0x00000008
  134. #define AFD_DEBUG_BIND 0x00000010
  135. #define AFD_DEBUG_CONNECT 0x00000020
  136. #define AFD_DEBUG_LISTEN 0x00000040
  137. #define AFD_DEBUG_ACCEPT 0x00000080
  138. #define AFD_DEBUG_SEND 0x00000100
  139. #define AFD_DEBUG_QUOTA 0x00000200
  140. #define AFD_DEBUG_RECEIVE 0x00000400
  141. #define AFD_DEBUG_11 0x00000800
  142. #define AFD_DEBUG_POLL 0x00001000
  143. #define AFD_DEBUG_FAST_IO 0x00002000
  144. #define AFD_DEBUG_ROUTING_QUERY 0x00010000
  145. #define AFD_DEBUG_ADDRESS_LIST 0x00020000
  146. #define AFD_DEBUG_TRANSMIT 0x00100000
  147. #define AFD_DEBUG_SAN_SWITCH 0x00200000
  148. #define DEBUG
  149. #else // DBG
  150. #undef IF_DEBUG
  151. #define IF_DEBUG(a) if (FALSE)
  152. #define DEBUG if ( FALSE )
  153. #endif // DBG
  154. //
  155. // Make some of the receive code a bit prettier.
  156. //
  157. #define TDI_RECEIVE_EITHER ( TDI_RECEIVE_NORMAL | TDI_RECEIVE_EXPEDITED )
  158. #endif // ndef _AFDP_