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.

323 lines
7.6 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. iisendp.hxx
  5. Abstract:
  6. This file contains type definitions for IIS_ENDPOINT.
  7. Each IIS_ENDPOINT corresponds to an ATQ_ENDPOINT structure.
  8. This structure is used to hold multiple instances listening
  9. on the same ATQ_ENDPOINT.
  10. Author:
  11. Johnson Apacible (JohnsonA) Jun-04-1996
  12. Revision History:
  13. --*/
  14. #ifndef _IISENDP_H_
  15. #define _IISENDP_H_
  16. #include <reftrace.h>
  17. //
  18. // Determines if iis_endpoint reference count tracking is enabled
  19. //
  20. #if DBG
  21. #define IE_REF_TRACKING 1
  22. #else
  23. #define IE_REF_TRACKING 0
  24. #endif
  25. //
  26. // Forward references.
  27. //
  28. class IIS_ASSOCIATION;
  29. typedef class IIS_ASSOCIATION *PIIS_ASSOCIATION;
  30. //
  31. // Instance qualifiers.
  32. //
  33. typedef enum _INSTANCE_QUALIFIER {
  34. FullyQualified, // "1.2.3.4:80:foo.com"
  35. QualifiedByIpAddress, // "1.2.3.4:80:"
  36. QualifiedByHostName, // ":80:foo.com"
  37. NumInstanceQualifiers, // sentinel for qualified instances
  38. WildcardInstance // ":80:"
  39. } INSTANCE_QUALIFIER, *PINSTANCE_QUALIFIER;
  40. //
  41. // Each head block corresponds to an ATQ endpoint
  42. //
  43. class IIS_ENDPOINT {
  44. private:
  45. //
  46. // Signature for this block
  47. //
  48. DWORD m_signature;
  49. //
  50. // ref count.
  51. //
  52. LONG m_reference;
  53. //
  54. // Does this contain secure sockets. It cannot contain both!
  55. //
  56. BOOL m_isSecure;
  57. //
  58. // pointer to the service (this is a reference)
  59. //
  60. PIIS_SERVICE m_service;
  61. //
  62. // State of this block
  63. //
  64. BLOCK_STATE m_state;
  65. //
  66. // Instance associations
  67. //
  68. DWORD m_NumQualifiedInstances;
  69. DWORD m_nInstances;
  70. PIIS_ASSOCIATION m_QualifiedInstances[NumInstanceQualifiers];
  71. PIIS_SERVER_INSTANCE m_WildcardInstance;
  72. INSTANCE_QUALIFIER
  73. CalcQualifier(
  74. IN DWORD IpAddress,
  75. IN const CHAR * HostName
  76. ) {
  77. if( IpAddress == INADDR_ANY ) {
  78. return *HostName == '\0'
  79. ? WildcardInstance
  80. : QualifiedByHostName;
  81. } else {
  82. return *HostName == '\0'
  83. ? QualifiedByIpAddress
  84. : FullyQualified;
  85. }
  86. };
  87. //
  88. // Is the ATQ endpoint already stopped?
  89. // NYI: This should be included in the m_state itself
  90. //
  91. BOOL m_fAtqEpStopped;
  92. public:
  93. //
  94. // list entry for the list of endpoints
  95. //
  96. LIST_ENTRY m_EndpointListEntry;
  97. //
  98. // Pointer to the endpoint object
  99. //
  100. PVOID m_atqEndpoint;
  101. //
  102. // Port & IP address used
  103. //
  104. USHORT m_Port;
  105. DWORD m_IpAddress;
  106. //
  107. // AcceptEx Outstanding
  108. //
  109. DWORD m_nAcceptExOutstanding;
  110. DWORD m_nMaximumAcceptExOutstanding;
  111. //
  112. // AcceptEx Timeout
  113. //
  114. DWORD m_AcceptExTimeout;
  115. //
  116. // Lock to protect endpoint objects
  117. //
  118. CRITICAL_SECTION m_endpointLock;
  119. public:
  120. #if IE_REF_TRACKING
  121. //
  122. // For object local refcount tracing
  123. //
  124. PTRACE_LOG _pDbgIERefTraceLog;
  125. #endif
  126. //
  127. // add and remove a server instance
  128. //
  129. BOOL
  130. AddInstance(
  131. IN PIIS_SERVER_INSTANCE pInstance,
  132. IN DWORD IpAddress,
  133. IN const CHAR * HostName
  134. );
  135. BOOL
  136. RemoveInstance(
  137. IN PIIS_SERVER_INSTANCE pInstance,
  138. IN DWORD IpAddress,
  139. IN const CHAR * HostName
  140. );
  141. //
  142. // member access
  143. //
  144. BLOCK_STATE QueryState( VOID ) {return m_state;}
  145. BOOL IsSecure( ) { return m_isSecure; }
  146. USHORT QueryPort( ) {return m_Port;}
  147. DWORD QueryIpAddress( ) {return m_IpAddress;}
  148. PIIS_SERVICE QueryService() {return m_service;}
  149. VOID SetService( PIIS_SERVICE pservice ) { m_service = pservice; }
  150. BOOL CheckSignature( DWORD signature ) { return (m_signature == signature); }
  151. //
  152. // Find the instance
  153. //
  154. dllexp
  155. PIIS_SERVER_INSTANCE FindAndReferenceInstance(
  156. IN LPCSTR szDomainName,
  157. IN const DWORD LocalIpAddress,
  158. OUT LPBOOL pbMaxConnExceeded
  159. );
  160. IIS_ENDPOINT(
  161. IN PIIS_SERVICE pService,
  162. IN USHORT Port,
  163. IN DWORD IpAddress,
  164. IN BOOL IsSecure
  165. );
  166. dllexp
  167. ~IIS_ENDPOINT( VOID );
  168. VOID LockEndpoint( VOID ) {EnterCriticalSection(&m_endpointLock);}
  169. VOID UnlockEndpoint( VOID ) {LeaveCriticalSection(&m_endpointLock);}
  170. BOOL ActivateEndpoint( VOID );
  171. BOOL StopEndpoint( VOID);
  172. VOID ShutdownEndpoint( VOID );
  173. dllexp VOID Reference( VOID );
  174. dllexp VOID Dereference( );
  175. };
  176. typedef IIS_ENDPOINT *PIIS_ENDPOINT;
  177. //
  178. // signatures
  179. //
  180. #define IIS_ENDPOINT_SIGNATURE (DWORD)' BHE'
  181. #define IIS_ENDPOINT_SIGNATURE_FREE (DWORD)'fBHE'
  182. /*******************************************************************
  183. Support for IIS_ENDPPOINT debug ref trace logging
  184. SYNOPSIS: Macro for writing to debug ref trace log.
  185. HISTORY:
  186. MCourage 31-Oct-1997 Created
  187. ********************************************************************/
  188. //
  189. // NOTE we avoid compile failure by hokey double typecast, below
  190. // (since endpState is an enum, we must first cast it to int).
  191. //
  192. #define IE_SHARED_LOG_REF_COUNT( \
  193. cRefs \
  194. , pIisEndp \
  195. , endpState \
  196. , patqEndp \
  197. , dummy \
  198. ) \
  199. \
  200. if( g_pDbgIERefTraceLog != NULL ) { \
  201. \
  202. DWORD i = (int) endpState; \
  203. PVOID pv = (PVOID) (ULONG_PTR)i; \
  204. \
  205. WriteRefTraceLogEx( \
  206. g_pDbgIERefTraceLog \
  207. , cRefs \
  208. , pIisEndp \
  209. , pv \
  210. , patqEndp \
  211. , (PVOID)(ULONG_PTR) dummy \
  212. ); \
  213. } \
  214. //
  215. // This macro logs the CLIENT_CONN specific ref trace log
  216. //
  217. #define IE_LOCAL_LOG_REF_COUNT( \
  218. cRefs \
  219. , pIisEndp \
  220. , endpState \
  221. , patqEndp \
  222. , dummy \
  223. ) \
  224. \
  225. if( _pDbgIERefTraceLog != NULL ) { \
  226. \
  227. DWORD i = (int) endpState; \
  228. PVOID pv = (PVOID) (ULONG_PTR)i; \
  229. \
  230. WriteRefTraceLogEx( \
  231. _pDbgIERefTraceLog \
  232. , cRefs \
  233. , pIisEndp \
  234. , pv \
  235. , patqEndp \
  236. , (PVOID)(ULONG_PTR) dummy \
  237. ); \
  238. } \
  239. #endif // _IISENDP_H_