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.

361 lines
7.5 KiB

  1. /*++
  2. Copyright (c) 1999-2002 Microsoft Corporation
  3. Module Name:
  4. sendresponsep.h
  5. Abstract:
  6. The private definition of response sending interfaces.
  7. Author:
  8. Michael Courage (mcourage) 15-Jun-1999
  9. Revision History:
  10. --*/
  11. #ifndef _SENDRESPONSEP_H_
  12. #define _SENDRESPONSEP_H_
  13. //
  14. // Private constants.
  15. //
  16. //
  17. // Convenience macro to test if a MDL describes locked memory.
  18. //
  19. #define IS_MDL_LOCKED(pmdl) (((pmdl)->MdlFlags & MDL_PAGES_LOCKED) != 0)
  20. #define HEADER_CHUNK_COUNT 2
  21. //
  22. // Private prototypes.
  23. //
  24. ULONG
  25. UlpComputeFixedHeaderSize(
  26. IN PHTTP_RESPONSE pUserResponse
  27. );
  28. VOID
  29. UlpComputeChunkBufferSizes(
  30. IN ULONG ChunkCount,
  31. IN PHTTP_DATA_CHUNK pDataChunks,
  32. IN UL_CAPTURE_FLAGS Flags,
  33. OUT PULONG pAuxBufferSize,
  34. OUT PULONG pCopiedMemorySize,
  35. OUT PULONG pUncopiedMemorySize
  36. );
  37. VOID
  38. UlpDestroyCapturedResponse(
  39. IN PUL_INTERNAL_RESPONSE pResponse
  40. );
  41. VOID
  42. UlpEnqueueSendHttpResponse(
  43. IN PUL_CHUNK_TRACKER pTracker,
  44. IN BOOLEAN FromKernelMode
  45. );
  46. VOID
  47. UlpDequeueSendHttpResponse(
  48. IN PUL_INTERNAL_REQUEST pRequest
  49. );
  50. VOID
  51. UlpSendHttpResponseWorker(
  52. IN PUL_WORK_ITEM pWorkItem
  53. );
  54. VOID
  55. UlpCloseConnectionComplete(
  56. IN PVOID pCompletionContext,
  57. IN NTSTATUS Status,
  58. IN ULONG_PTR Information
  59. );
  60. NTSTATUS
  61. UlpProbeHttpResponse(
  62. IN PHTTP_RESPONSE pUserResponse,
  63. IN USHORT ChunkCount,
  64. IN PHTTP_DATA_CHUNK pCapturedDataChunks,
  65. IN UL_CAPTURE_FLAGS Flags,
  66. IN PHTTP_LOG_FIELDS_DATA pCapturedLogData,
  67. IN KPROCESSOR_MODE RequestorMode
  68. );
  69. PUL_CHUNK_TRACKER
  70. UlpAllocateChunkTracker(
  71. IN UL_TRACKER_TYPE TrackerType,
  72. IN CCHAR SendIrpStackSize,
  73. IN CCHAR ReadIrpStackSize,
  74. IN BOOLEAN FirstResponse,
  75. IN PUL_HTTP_CONNECTION pHttpConnection,
  76. IN PUL_INTERNAL_RESPONSE pResponse
  77. );
  78. VOID
  79. UlpFreeChunkTracker(
  80. IN PUL_WORK_ITEM pWorkItem
  81. );
  82. VOID
  83. UlpCompleteSendResponseWorker(
  84. IN PUL_WORK_ITEM pWorkItem
  85. );
  86. NTSTATUS
  87. UlpRestartMdlRead(
  88. IN PDEVICE_OBJECT pDeviceObject,
  89. IN PIRP pIrp,
  90. IN PVOID pContext
  91. );
  92. VOID
  93. UlpMdlReadCompleteWorker(
  94. IN PUL_WORK_ITEM pWorkItem
  95. );
  96. VOID
  97. UlpRestartMdlSend(
  98. IN PVOID pCompletionContext,
  99. IN NTSTATUS Status,
  100. IN ULONG_PTR Information
  101. );
  102. NTSTATUS
  103. UlpCopySend(
  104. IN PUL_CHUNK_TRACKER pTracker,
  105. IN PMDL pMdl,
  106. IN ULONG Length,
  107. IN BOOLEAN InitiateDisconnect,
  108. IN BOOLEAN RequestComplete
  109. );
  110. VOID
  111. UlpRestartCopySend(
  112. IN PVOID pCompletionContext,
  113. IN NTSTATUS Status,
  114. IN ULONG_PTR Information
  115. );
  116. VOID
  117. UlpMdlSendCompleteWorker(
  118. IN PUL_WORK_ITEM pWorkItem
  119. );
  120. NTSTATUS
  121. UlpFlushMdlRuns(
  122. IN PUL_CHUNK_TRACKER pTracker
  123. );
  124. VOID
  125. UlpFreeMdlRuns(
  126. IN PUL_CHUNK_TRACKER pTracker
  127. );
  128. VOID
  129. UlpFreeFileMdlRun(
  130. IN OUT PUL_CHUNK_TRACKER pTracker,
  131. IN OUT PUL_MDL_RUN pMdlRun
  132. );
  133. VOID
  134. UlpIncrementChunkPointer(
  135. IN OUT PUL_INTERNAL_RESPONSE pResponse
  136. );
  137. __inline
  138. VOID
  139. UlpInitMdlRuns(
  140. IN OUT PUL_CHUNK_TRACKER pTracker
  141. )
  142. {
  143. pTracker->SendInfo.pMdlHead = NULL;
  144. pTracker->SendInfo.pMdlLink = &pTracker->SendInfo.pMdlHead;
  145. pTracker->SendInfo.MdlRunCount = 0;
  146. pTracker->SendInfo.BytesBuffered = 0;
  147. }
  148. __inline
  149. VOID
  150. UlpBuildExtendedSearchKey(
  151. IN PUL_INTERNAL_REQUEST pRequest,
  152. OUT PURI_SEARCH_KEY pSearchKey
  153. )
  154. {
  155. ASSERT(pSearchKey);
  156. ASSERT(UL_IS_VALID_INTERNAL_REQUEST(pRequest));
  157. ASSERT(pRequest->CookedUrl.Length > 0);
  158. ASSERT(DIFF(pRequest->CookedUrl.pAbsPath - pRequest->CookedUrl.pUrl) > 0);
  159. pSearchKey->Type = UriKeyTypeExtended;
  160. pSearchKey->ExKey.pAbsPath = pRequest->CookedUrl.pAbsPath;
  161. pSearchKey->ExKey.AbsPathLength = pRequest->CookedUrl.Length
  162. - (DIFF(pRequest->CookedUrl.pAbsPath - pRequest->CookedUrl.pUrl) * sizeof(WCHAR));
  163. ASSERT(pSearchKey->ExKey.AbsPathLength > 0);
  164. ASSERT(wcslen(pSearchKey->ExKey.pAbsPath) * sizeof(WCHAR)
  165. == pSearchKey->ExKey.AbsPathLength);
  166. pSearchKey->ExKey.Hash = pRequest->CookedUrl.RoutingHash;
  167. pSearchKey->ExKey.pToken = pRequest->CookedUrl.pRoutingToken;
  168. pSearchKey->ExKey.TokenLength = pRequest->CookedUrl.RoutingTokenLength;
  169. ASSERT(pSearchKey->ExKey.TokenLength > 0);
  170. ASSERT(wcslen(pSearchKey->ExKey.pToken) * sizeof(WCHAR)
  171. == pSearchKey->ExKey.TokenLength);
  172. }
  173. //
  174. // read stuff into the cache
  175. //
  176. NTSTATUS
  177. UlpBuildCacheEntry(
  178. IN PUL_INTERNAL_REQUEST pRequest,
  179. IN PUL_INTERNAL_RESPONSE pResponse,
  180. IN PUL_APP_POOL_PROCESS pProcess,
  181. IN HTTP_CACHE_POLICY CachePolicy,
  182. IN PUL_COMPLETION_ROUTINE pCompletionRoutine,
  183. IN PVOID pCompletionContext
  184. );
  185. VOID
  186. UlpBuildCacheEntryWorker(
  187. IN PUL_WORK_ITEM pWorkItem
  188. );
  189. NTSTATUS
  190. UlpRestartCacheMdlRead(
  191. IN PDEVICE_OBJECT pDeviceObject,
  192. IN PIRP pIrp,
  193. IN PVOID pContext
  194. );
  195. VOID
  196. UlpCacheMdlReadCompleteWorker(
  197. IN PUL_WORK_ITEM pWorkItem
  198. );
  199. NTSTATUS
  200. UlpRestartCacheMdlFree(
  201. IN PDEVICE_OBJECT pDeviceObject,
  202. IN PIRP pIrp,
  203. IN PVOID pContext
  204. );
  205. VOID
  206. UlpCompleteCacheBuild(
  207. IN PUL_CHUNK_TRACKER pTracker,
  208. IN NTSTATUS Status
  209. );
  210. VOID
  211. UlpCompleteCacheBuildWorker(
  212. IN PUL_WORK_ITEM pWorkItem
  213. );
  214. //
  215. // send cache entry across the wire
  216. //
  217. NTSTATUS
  218. UlpSendCacheEntry(
  219. PUL_HTTP_CONNECTION pHttpConnection,
  220. ULONG Flags,
  221. PUL_URI_CACHE_ENTRY pUriCacheEntry,
  222. PUL_COMPLETION_ROUTINE pCompletionRoutine,
  223. PVOID pCompletionContext,
  224. PUL_LOG_DATA_BUFFER pLogData,
  225. UL_RESUME_PARSING_TYPE ResumeParsingType
  226. );
  227. VOID
  228. UlpSendCacheEntryWorker(
  229. IN PUL_WORK_ITEM pWorkItem
  230. );
  231. VOID
  232. UlpCompleteSendCacheEntry(
  233. IN PVOID pCompletionContext,
  234. IN NTSTATUS Status,
  235. IN ULONG_PTR Information
  236. );
  237. VOID
  238. UlpCompleteSendCacheEntry(
  239. IN PVOID pCompletionContext,
  240. IN NTSTATUS Status,
  241. IN ULONG_PTR Information
  242. );
  243. VOID
  244. UlpCompleteSendCacheEntryWorker(
  245. IN PUL_WORK_ITEM pWorkItem
  246. );
  247. PUL_FULL_TRACKER
  248. UlpAllocateCacheTracker(
  249. IN CCHAR SendIrpStackSize
  250. );
  251. VOID
  252. UlpFreeCacheTracker(
  253. IN PUL_FULL_TRACKER pTracker
  254. );
  255. VOID
  256. UlReferenceChunkTracker(
  257. IN PUL_CHUNK_TRACKER pTracker
  258. REFERENCE_DEBUG_FORMAL_PARAMS
  259. );
  260. VOID
  261. UlDereferenceChunkTracker(
  262. IN PUL_CHUNK_TRACKER pTracker
  263. REFERENCE_DEBUG_FORMAL_PARAMS
  264. );
  265. #define UL_REFERENCE_CHUNK_TRACKER( pTracker ) \
  266. UlReferenceChunkTracker( \
  267. (pTracker) \
  268. REFERENCE_DEBUG_ACTUAL_PARAMS \
  269. )
  270. #define UL_DEREFERENCE_CHUNK_TRACKER( pTracker ) \
  271. UlDereferenceChunkTracker( \
  272. (pTracker) \
  273. REFERENCE_DEBUG_ACTUAL_PARAMS \
  274. )
  275. __inline
  276. VOID
  277. UlpQueueResponseWorkItem(
  278. IN PUL_WORK_ITEM pWorkItem,
  279. IN PUL_WORK_ROUTINE pWorkRoutine,
  280. IN BOOLEAN SyncItem
  281. )
  282. {
  283. if (SyncItem)
  284. {
  285. UL_QUEUE_SYNC_ITEM( pWorkItem, pWorkRoutine );
  286. }
  287. else
  288. {
  289. UL_QUEUE_WORK_ITEM( pWorkItem, pWorkRoutine );
  290. }
  291. }
  292. #endif // _SENDRESPONSEP_H_