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.

364 lines
9.4 KiB

  1. /*++
  2. Copyright (c) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. ultdi.h
  5. Abstract:
  6. This module defines the interface to the TDI/MUX/SSL component.
  7. Author:
  8. Keith Moore (keithmo) 12-Jun-1998
  9. Revision History:
  10. --*/
  11. #ifndef _ULTDI_H_
  12. #define _ULTDI_H_
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. //
  17. // Opaque structure pointers. These are defined (privately) in ULTDIP.H.
  18. //
  19. typedef struct _UL_ENDPOINT *PUL_ENDPOINT;
  20. typedef struct _UL_CONNECTION *PUL_CONNECTION;
  21. //
  22. // Routine invoked after an incoming TCP/MUX connection has been
  23. // received (but not yet accepted).
  24. //
  25. // Arguments:
  26. //
  27. // pListeningContext - Supplies an uninterpreted context value
  28. // as passed to the UlCreateListeningEndpoint() API.
  29. //
  30. // pConnection - Supplies the connection being established.
  31. //
  32. // pRemoteAddress - Supplies the remote (client-side) address
  33. // requesting the connection.
  34. //
  35. // RemoteAddressLength - Supplies the total byte length of the
  36. // pRemoteAddress structure.
  37. //
  38. // ppConnectionContext - Receives a pointer to an uninterpreted
  39. // context value to be associated with the new connection if
  40. // accepted. If the new connection is not accepted, this
  41. // parameter is ignored.
  42. //
  43. // Return Value:
  44. //
  45. // BOOLEAN - TRUE if the connection was accepted, FALSE if not.
  46. //
  47. typedef
  48. BOOLEAN
  49. (*PUL_CONNECTION_REQUEST)(
  50. IN PVOID pListeningContext,
  51. IN PUL_CONNECTION pConnection,
  52. IN PTRANSPORT_ADDRESS pRemoteAddress,
  53. IN ULONG RemoteAddressLength,
  54. OUT PVOID *ppConnectionContext
  55. );
  56. //
  57. // Routine invoked after an incoming TCP/MUX connection has been fully
  58. // accepted.
  59. //
  60. // This routine is also invoked if an incoming connection was not accepted
  61. // *after* PUL_CONNECTION_REQUEST returned TRUE. In other words, if
  62. // PUL_CONNECTION_REQUEST indicated that the connection should be accepted
  63. // but a fatal error occurred later, then PUL_CONNECTION_COMPLETE is
  64. // invoked.
  65. //
  66. // Arguments:
  67. //
  68. // pListeningContext - Supplies an uninterpreted context value
  69. // as passed to the UlCreateListeningEndpoint() API.
  70. //
  71. // pConnectionContext - Supplies the uninterpreted context value
  72. // as returned by PUL_CONNECTION_REQUEST.
  73. //
  74. // Status - Supplie the completion status. If this value is
  75. // STATUS_SUCCESS, then the connection is now fully accepted.
  76. // Otherwise, the connection has been aborted.
  77. //
  78. typedef
  79. VOID
  80. (*PUL_CONNECTION_COMPLETE)(
  81. IN PVOID pListeningContext,
  82. IN PVOID pConnectionContext,
  83. IN NTSTATUS Status
  84. );
  85. //
  86. // Routine invoked after an established TCP/MUX connection has been
  87. // disconnected by the remote (client) side.
  88. //
  89. // Arguments:
  90. //
  91. // pListeningContext - Supplies an uninterpreted context value
  92. // as passed to the UlCreateListeningEndpoint() API.
  93. //
  94. // pConnectionContext - Supplies an uninterpreted context value
  95. // as returned from the PUL_CONNECTION_REQUEST callback.
  96. //
  97. // Status - Supplies the termination status.
  98. //
  99. // CODEWORK:
  100. //
  101. // This indication is not currently invoked when the local
  102. // machine initiates an abortive disconnect. Faking an indication
  103. // during a local abort would probably be a Good Thing.
  104. //
  105. typedef
  106. VOID
  107. (*PUL_CONNECTION_DISCONNECT)(
  108. IN PVOID pListeningContext,
  109. IN PVOID pConnectionContext,
  110. IN NTSTATUS Status
  111. );
  112. //
  113. // Routine invoked when a graceful disconnect requested by the client
  114. // is complete. The client may want to drain the indicated data on the
  115. // tdi connection to get the above indication.
  116. //
  117. typedef
  118. VOID
  119. (*PUL_CONNECTION_DISCONNECT_COMPLETE)(
  120. IN PVOID pListeningContext,
  121. IN PVOID pConnectionContext
  122. );
  123. //
  124. // Routine invoked just before the internal state for a connection
  125. // is destroyed. This is the last chance to cleanup before the
  126. // connection fully disappears.
  127. //
  128. // Arguments:
  129. //
  130. // pListeningContext - Supplies an uninterpreted context value
  131. // as passed to the UlCreateListeningEndpoint() API.
  132. //
  133. // pConnectionContext - Supplies an uninterpreted context value
  134. // as returned from the PUL_CONNECTION_REQUEST callback.
  135. //
  136. typedef
  137. VOID
  138. (*PUL_CONNECTION_DESTROYED)(
  139. IN PVOID pListeningContext,
  140. IN PVOID pConnectionContext
  141. );
  142. //
  143. // Routine invoked after data has been received on an established
  144. // TCP/MUX connection.
  145. //
  146. // Arguments:
  147. //
  148. // pListeningContext - Supplies an uninterpreted context value
  149. // as passed to the UlCreateListeningEndpoint() API.
  150. //
  151. // pConnectionContext - Supplies an uninterpreted context value
  152. // as returned from the PUL_CONNECTION_REQUEST callback.
  153. //
  154. // pBuffer - Supplies a pointer to the received data.
  155. //
  156. // IndicatedLength - Supplies the length of the received data
  157. // available in pBuffer.
  158. //
  159. // pTakenLength - Receives the number of bytes consumed by
  160. // the receive handler.
  161. //
  162. // Return Value:
  163. //
  164. // NTSTATUS - The status of the consumed data. The behavior of
  165. // the TDI/MUX component is dependent on the return value
  166. // and the value set in *pTakenLength, and is defined as
  167. // follows:
  168. //
  169. // STATUS_SUCCESS, *pTakenLength == IndicatedLength -
  170. // All indicated data was consumed by the receive
  171. // handler. Additional incoming data will cause
  172. // subsequent receive indications.
  173. //
  174. // STATUS_SUCCESS, *pTakenLength < IndicatedLength -
  175. // Part of the indicated data was consumed by the
  176. // receive handler. The network transport will
  177. // buffer data and no further indications will be
  178. // made until UlReceiveData() is called.
  179. //
  180. // STATUS_MORE_PROCESSING_REQUIRED - Part of the
  181. // indicated data was consumed by the receive handler.
  182. // A subsequent receive indication will be made
  183. // when additional data is available. The subsequent
  184. // indication will include the unconsumed data from
  185. // the current indication plus any additional data
  186. // received.
  187. //
  188. // Any other status - Indicates a fatal error in the
  189. // receive handler. The connection will be aborted.
  190. //
  191. // *pTakenLength > IndicatedLength - This is an error
  192. // condition and should never occur.
  193. //
  194. //
  195. // Public (within UL.SYS) entrypoints.
  196. //
  197. NTSTATUS
  198. UlInitializeTdi(
  199. VOID
  200. );
  201. VOID
  202. UlTerminateTdi(
  203. VOID
  204. );
  205. VOID
  206. UlWaitForEndpointDrain(
  207. VOID
  208. );
  209. ULONG
  210. UlpComputeHttpRawConnectionLength(
  211. IN PVOID pConnectionContext
  212. );
  213. ULONG
  214. UlpGenerateHttpRawConnectionInfo(
  215. IN PVOID pContext,
  216. IN PUCHAR pKernelBuffer,
  217. IN PVOID pUserBuffer,
  218. IN ULONG OutputBufferLength,
  219. IN PUCHAR pBuffer,
  220. IN ULONG InitialLength
  221. );
  222. NTSTATUS
  223. UlCreateListeningEndpoint(
  224. IN PTRANSPORT_ADDRESS pLocalAddress,
  225. IN ULONG LocalAddressLength,
  226. IN BOOLEAN Secure,
  227. IN ULONG InitialBacklog,
  228. IN PUL_CONNECTION_REQUEST pConnectionRequestHandler,
  229. IN PUL_CONNECTION_COMPLETE pConnectionCompleteHandler,
  230. IN PUL_CONNECTION_DISCONNECT pConnectionDisconnectHandler,
  231. IN PUL_CONNECTION_DISCONNECT_COMPLETE pConnectionDisconnectCompleteHandler,
  232. IN PUL_CONNECTION_DESTROYED pConnectionDestroyedHandler,
  233. IN PUL_DATA_RECEIVE pDataReceiveHandler,
  234. IN PVOID pListeningContext,
  235. OUT PUL_ENDPOINT *ppListeningEndpoint
  236. );
  237. NTSTATUS
  238. UlCloseListeningEndpoint(
  239. IN PUL_ENDPOINT pListeningEndpoint,
  240. IN PUL_COMPLETION_ROUTINE pCompletionRoutine,
  241. IN PVOID pCompletionContext
  242. );
  243. NTSTATUS
  244. UlCloseConnection(
  245. IN PVOID pObject,
  246. IN BOOLEAN AbortiveDisconnect,
  247. IN PUL_COMPLETION_ROUTINE pCompletionRoutine,
  248. IN PVOID pCompletionContext
  249. );
  250. NTSTATUS
  251. UlSendData(
  252. IN PUL_CONNECTION pConnection,
  253. IN PMDL pMdlChain,
  254. IN ULONG Length,
  255. IN PUL_COMPLETION_ROUTINE pCompletionRoutine,
  256. IN PVOID pCompletionContext,
  257. IN PIRP pOwnIrp,
  258. IN PUL_IRP_CONTEXT pOwnIrpContext,
  259. IN BOOLEAN InitiateDisconnect
  260. );
  261. NTSTATUS
  262. UlReceiveData(
  263. IN PVOID pConnectionContext,
  264. IN PVOID pBuffer,
  265. IN ULONG BufferLength,
  266. IN PUL_COMPLETION_ROUTINE pCompletionRoutine,
  267. IN PVOID pCompletionContext
  268. );
  269. NTSTATUS
  270. UlAddSiteToEndpointList(
  271. IN PWSTR pSiteUrl
  272. );
  273. NTSTATUS
  274. UlRemoveSiteFromEndpointList(
  275. IN PWSTR pSiteUrl
  276. );
  277. VOID
  278. UlReferenceConnection(
  279. IN PVOID pObject
  280. REFERENCE_DEBUG_FORMAL_PARAMS
  281. );
  282. VOID
  283. UlDereferenceConnection(
  284. IN PVOID pObject
  285. REFERENCE_DEBUG_FORMAL_PARAMS
  286. );
  287. #define REFERENCE_CONNECTION( pconn ) \
  288. UlReferenceConnection( \
  289. (pconn) \
  290. REFERENCE_DEBUG_ACTUAL_PARAMS \
  291. )
  292. #define DEREFERENCE_CONNECTION( pconn ) \
  293. UlDereferenceConnection( \
  294. (pconn) \
  295. REFERENCE_DEBUG_ACTUAL_PARAMS \
  296. )
  297. //
  298. // Prototype for TCP Send routine if Fast Send is possible.
  299. //
  300. typedef
  301. NTSTATUS
  302. (*PUL_TCPSEND_DISPATCH) (
  303. IN PIRP Irp,
  304. IN PIO_STACK_LOCATION IrpSp
  305. );
  306. #ifdef __cplusplus
  307. }; // extern "C"
  308. #endif
  309. #endif // _ULTDI_H_