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.

389 lines
14 KiB

  1. /*++ BUILD Version: 0009 // Increment this if a change has global effects
  2. Copyright (c) 1987-1993 Microsoft Corporation
  3. Module Name:
  4. rxce.h
  5. Abstract:
  6. This is the include file that defines all constants and types for
  7. accessing the redirector file system connection engine.
  8. Revision History:
  9. Balan Sethu Raman (SethuR) 06-Feb-95 Created
  10. Notes:
  11. The Connection engine is designed to map and emulate the TDI specs. as closely
  12. as possible. This implies that on NT we will have a very efficient mechanism
  13. which fully exploits the underlying TDI implementation.
  14. There are four important data structures that are created/manipulated by the
  15. various functions associated with the connection engine. Thesr are
  16. RXCE_TRANSPORT,RXCE_ADDRESS,RXCE_CONNECTION and RXCE_VC.
  17. The mini redirector writers can embed these data structures in the corresponding
  18. definitions and invoke the two routines provided for each type to build and
  19. tear down the connection engine portions. These routines do not allocate/free
  20. the memory associated with these instances. This provides a flexible mechanism
  21. for the mini redirector writers to manage instances.
  22. --*/
  23. #ifndef _RXCE_H_
  24. #define _RXCE_H_
  25. #include <nodetype.h>
  26. #include <rxcehdlr.h> // TDI related definitions.
  27. #include <rxworkq.h>
  28. //
  29. // The connection engine deals with three kinds of entities, transports, transport
  30. // addresses and transport connections. The transports are bindings to the various
  31. // transport service providers on any system. The transport addresses are the
  32. // local connection end points. The connections are transport connections between
  33. // endpoints. Each connection encapsulates a number of virtual circuits
  34. // ( typically 1 ).
  35. //
  36. // All the four node types are tagged with the following signature which is used
  37. // extensively in validating them
  38. typedef struct _RXCE_SIGNATURE_ {
  39. union {
  40. struct {
  41. USHORT Type;
  42. CSHORT Size;
  43. };
  44. ULONG Signature;
  45. };
  46. } RXCE_SIGNATURE, *PRXCE_SIGNATURE;
  47. //
  48. // RXCE_TRANSPORT encapsulates all the parameters w.r.t. a TRANSPORT
  49. // as regards the connection engine.
  50. //
  51. #ifdef __cplusplus
  52. typedef struct _RXCE_TRANSPORT_ : public RXCE_SIGNATURE {
  53. #else // !__cplusplus
  54. typedef struct _RXCE_TRANSPORT_ {
  55. RXCE_SIGNATURE;
  56. #endif // __cplusplus
  57. UNICODE_STRING Name;
  58. PDEVICE_OBJECT pDeviceObject; // Device object for transport
  59. HANDLE ControlChannel; // Control Channel
  60. PFILE_OBJECT pControlChannelFileObject; // File object for the control channel
  61. PRXCE_TRANSPORT_PROVIDER_INFO pProviderInfo; // Transport Provider Information.
  62. LONG ConnectionCount; // Number of connections on xport.
  63. LONG VirtualCircuitCount; // no. of connections
  64. ULONG QualityOfService; // quality of service provided.
  65. } RXCE_TRANSPORT;
  66. #define RXCE_TRANSPORT_SIGNATURE ((sizeof(RXCE_TRANSPORT) << 16) | RDBSS_NTC_RXCE_TRANSPORT)
  67. #define RxCeIsTransportValid(pTransport) \
  68. ((pTransport)->Signature == RXCE_TRANSPORT_SIGNATURE)
  69. extern NTSTATUS
  70. NTAPI
  71. RxCeBuildTransport(
  72. IN PRXCE_TRANSPORT pRxCeTransport,
  73. IN PUNICODE_STRING pTransportName,
  74. IN ULONG QualityOfService);
  75. extern NTSTATUS
  76. NTAPI
  77. RxCeTearDownTransport(
  78. IN PRXCE_TRANSPORT pTransport);
  79. extern NTSTATUS
  80. RxCeQueryAdapterStatus(
  81. PRXCE_TRANSPORT pTransport,
  82. struct _ADAPTER_STATUS *pAdapterStatus);
  83. extern NTSTATUS
  84. RxCeQueryTransportInformation(
  85. PRXCE_TRANSPORT pTransport,
  86. PRXCE_TRANSPORT_INFORMATION pTransportInformation);
  87. //
  88. // RXCE_ADDRESS encapsulates all the parameters w.r.t. a local transport address
  89. // as regards the connection engine.
  90. //
  91. #ifdef __cplusplus
  92. typedef struct _RXCE_ADDRESS_ : public RXCE_SIGNATURE {
  93. #else // !__cplusplus
  94. typedef struct _RXCE_ADDRESS_ {
  95. RXCE_SIGNATURE;
  96. #endif // __cplusplus
  97. PRXCE_TRANSPORT pTransport; // the transport handle
  98. PTRANSPORT_ADDRESS pTransportAddress; // the transport address
  99. PVOID pContext; // the context used in event dispatch
  100. PRXCE_ADDRESS_EVENT_HANDLER pHandler; // the address event handler
  101. PMDL pReceiveMdl; // the MDL for handling Receives Supplied by client
  102. HANDLE hAddress; // handle to the address object
  103. PFILE_OBJECT pFileObject; // the file object for the address
  104. LONG ConnectionCount; // no. of connections
  105. LONG VirtualCircuitCount; // no. of vcs
  106. } RXCE_ADDRESS;
  107. #define RXCE_ADDRESS_SIGNATURE ((sizeof(RXCE_ADDRESS) << 16) | RDBSS_NTC_RXCE_ADDRESS)
  108. #define RxCeIsAddressValid(pAddress) \
  109. ((pAddress)->Signature == RXCE_ADDRESS_SIGNATURE)
  110. extern NTSTATUS
  111. NTAPI
  112. RxCeBuildAddress(
  113. IN OUT PRXCE_ADDRESS pAddress,
  114. IN PRXCE_TRANSPORT pTransport,
  115. IN PTRANSPORT_ADDRESS pTransportAddress,
  116. IN PRXCE_ADDRESS_EVENT_HANDLER pHandler,
  117. IN PVOID pEventContext);
  118. extern NTSTATUS
  119. NTAPI
  120. RxCeTearDownAddress(
  121. IN PRXCE_ADDRESS pAddress);
  122. //
  123. // RxCe Connection Establishment methods ....
  124. //
  125. //
  126. // RXCE_CONNECTION encapsulates all the information w.r.t. a connection
  127. // as regards the connection engine.
  128. //
  129. #ifdef __cplusplus
  130. typedef struct _RXCE_CONNECTION_ : public RXCE_SIGNATURE {
  131. #else // !__cplusplus
  132. typedef struct _RXCE_CONNECTION_ {
  133. RXCE_SIGNATURE;
  134. #endif // __cplusplus
  135. PRXCE_ADDRESS pAddress; // the local address for this connection
  136. ULONG VirtualCircuitCount; // the number of virtual circuits associated with the connection
  137. PVOID pContext; // the context used in event dispatch
  138. PRXCE_CONNECTION_EVENT_HANDLER pHandler; // the event handler for the connection
  139. PRXCE_CONNECTION_INFORMATION pConnectionInformation; // the remote address ...
  140. } RXCE_CONNECTION;
  141. #define RXCE_CONNECTION_SIGNATURE ((sizeof(RXCE_CONNECTION) << 16) | RDBSS_NTC_RXCE_CONNECTION)
  142. #define RxCeIsConnectionValid(pConnection) \
  143. ((pConnection)->Signature == RXCE_CONNECTION_SIGNATURE)
  144. //
  145. // The following enumerated type defines the various choices presented for
  146. // selecting the transport over which a connection should be established
  147. //
  148. typedef enum _RXCE_CONNECTION_CREATE_OPTIONS_ {
  149. RxCeSelectFirstSuccessfulTransport,
  150. RxCeSelectBestSuccessfulTransport,
  151. RxCeSelectAllSuccessfulTransports
  152. } RXCE_CONNECTION_CREATE_OPTIONS,
  153. *PRXCE_CONNECTION_CREATE_OPTIONS;
  154. typedef struct _RXCE_CONNECTION_COMPLETION_CONTEXT_ {
  155. NTSTATUS Status;
  156. ULONG AddressIndex;
  157. PRXCE_CONNECTION pConnection;
  158. PRXCE_VC pVc;
  159. RX_WORK_QUEUE_ITEM WorkQueueItem;
  160. // This is used to pass the UNICODE DNS name returned back from TDI
  161. PRXCE_CONNECTION_INFORMATION pConnectionInformation;
  162. } RXCE_CONNECTION_COMPLETION_CONTEXT,
  163. *PRXCE_CONNECTION_COMPLETION_CONTEXT;
  164. typedef
  165. NTSTATUS
  166. (*PRXCE_CONNECTION_COMPLETION_ROUTINE)(
  167. PRXCE_CONNECTION_COMPLETION_CONTEXT pCompletionContext);
  168. extern NTSTATUS
  169. NTAPI
  170. RxCeBuildConnection(
  171. IN PRXCE_ADDRESS pLocalAddress,
  172. IN PRXCE_CONNECTION_INFORMATION pConnectionInformation,
  173. IN PRXCE_CONNECTION_EVENT_HANDLER pHandler,
  174. IN PVOID pEventContext,
  175. IN OUT PRXCE_CONNECTION pConnection,
  176. IN OUT PRXCE_VC pVc);
  177. extern NTSTATUS
  178. NTAPI
  179. RxCeBuildConnectionOverMultipleTransports(
  180. IN OUT PRDBSS_DEVICE_OBJECT pMiniRedirectorDeviceObject,
  181. IN RXCE_CONNECTION_CREATE_OPTIONS CreateOption,
  182. IN ULONG NumberOfAddresses,
  183. IN PRXCE_ADDRESS *pLocalAddressPointers,
  184. IN PUNICODE_STRING pServerName,
  185. IN PRXCE_CONNECTION_INFORMATION pConnectionInformation,
  186. IN PRXCE_CONNECTION_EVENT_HANDLER pHandler,
  187. IN PVOID pEventContext,
  188. IN PRXCE_CONNECTION_COMPLETION_ROUTINE pCompletionRoutine,
  189. IN OUT PRXCE_CONNECTION_COMPLETION_CONTEXT pCompletionContext);
  190. extern NTSTATUS
  191. NTAPI
  192. RxCeTearDownConnection(
  193. IN PRXCE_CONNECTION pConnection);
  194. extern NTSTATUS
  195. NTAPI
  196. RxCeCancelConnectRequest(
  197. IN PRXCE_ADDRESS pLocalAddress,
  198. IN PUNICODE_STRING pServerName,
  199. IN PRXCE_CONNECTION_INFORMATION pConnectionInformation);
  200. //
  201. // RXCE_VC encapsulates all the information w.r.t a virtual circuit (VC)
  202. // connection to a particular server as regards the connection engine.
  203. //
  204. // Typically one VC is associated with a connection. However, there are instances in
  205. // which more than one VC can be associated with a connection. In order to efficiently
  206. // handle the common case well and at the same time provide an extensible mechanism we
  207. // define a collection data structure ( a list ) which subsumes the allocation for
  208. // one virtual circuit. It is also imperative that we restrict the knowledge of
  209. // how this collection is organized to as few methods as possible in order to
  210. // enable optimization/restructuring of this data structure at a later time.
  211. //
  212. #define RXCE_VC_ACTIVE ((LONG)0xaa)
  213. #define RXCE_VC_DISCONNECTED ((LONG)0xdd)
  214. #define RXCE_VC_TEARDOWN ((LONG)0xbb)
  215. #ifdef __cplusplus
  216. typedef struct _RXCE_VC_ : public RXCE_SIGNATURE {
  217. #else // !__cplusplus
  218. typedef struct _RXCE_VC_ {
  219. RXCE_SIGNATURE;
  220. #endif // __cplusplus
  221. PRXCE_CONNECTION pConnection; // the referenced connection instance
  222. HANDLE hEndpoint; // local endpoint for the connection
  223. PFILE_OBJECT pEndpointFileObject; // the end point file object.
  224. LONG State; // status of the Vc.
  225. CONNECTION_CONTEXT ConnectionId; // local endpoint for the connection.
  226. PMDL pReceiveMdl; // the MDl for handling receives.
  227. PKEVENT pCleanUpEvent; // sychronize event for clean up transports
  228. } RXCE_VC;
  229. #define RXCE_VC_SIGNATURE ((sizeof(RXCE_VC) << 16) | RDBSS_NTC_RXCE_VC)
  230. #define RxCeIsVcValid(pVc) \
  231. ((pVc)->Signature == RXCE_VC_SIGNATURE)
  232. extern NTSTATUS
  233. NTAPI
  234. RxCeBuildVC(
  235. IN OUT PRXCE_VC pVc,
  236. IN PRXCE_CONNECTION Connection);
  237. extern NTSTATUS
  238. NTAPI
  239. RxCeTearDownVC(
  240. IN PRXCE_VC pVc);
  241. extern NTSTATUS
  242. NTAPI
  243. RxCeInitiateVCDisconnect(
  244. IN PRXCE_VC pVc);
  245. extern NTSTATUS
  246. NTAPI
  247. RxCeQueryInformation(
  248. IN PRXCE_VC pVc,
  249. IN RXCE_CONNECTION_INFORMATION_CLASS InformationClass,
  250. OUT PVOID pInformation,
  251. IN ULONG Length);
  252. //
  253. // RxCe Data transmission methods
  254. //
  255. //
  256. // Send options
  257. //
  258. // The following flags are equivalent to the TDI flags. In addition
  259. // there are RXCE specific flags which are defined from the other end of
  260. // a dword.
  261. //
  262. #define RXCE_SEND_EXPEDITED TDI_SEND_EXPEDITED
  263. #define RXCE_SEND_NO_RESPONSE_EXPECTED TDI_SEND_NO_RESPONSE_EXPECTED
  264. #define RXCE_SEND_NON_BLOCKING TDI_SEND_NON_BLOCKING
  265. //
  266. // The ASYNCHRONOUS and SYNCHRONOUS option available RxCeSend and RxCeSendDatagram
  267. // distinguish between two situations. In the asynchronous case control returns to
  268. // the caller once the request has been successfully submitted to the underlying
  269. // transport. The results for any given request are communicated back using the
  270. // SendCompletion callback routine. The pCompletionContext parameter in RxCeSend and
  271. // RxCeSendDatagram is passed back in the callback routine to assist the caller in
  272. // disambiguating the requests.
  273. //
  274. // In the synchronous case the request is submitted to the underlying transport and the
  275. // control does not return to the caller till the request completes.
  276. //
  277. // Note that in the synchrnous case the pCompletionContext parameter is ignored and the
  278. // status that is returned correpsonds to the completion status of the operations.
  279. //
  280. // The benefit of ASYNCHRONOUS and SYNCHRONOUS options depends on the underlying
  281. // transport. In a Virtual Circuit environment a SYNCHRONOUS option implies that the
  282. // control does not return till the data reaches the server. On the other hand
  283. // for datagram oriented transports there is very little difference between the two.
  284. //
  285. #define RXCE_FLAGS_MASK (0xff000000)
  286. #define RXCE_SEND_SYNCHRONOUS (0x10000000)
  287. // The following bit signifies if an RX_MEM_DESC(MDL) is to be sent in its entirety
  288. // or only portions of it need to be sent.
  289. #define RXCE_SEND_PARTIAL (0x20000000)
  290. extern NTSTATUS
  291. NTAPI
  292. RxCeSend(
  293. IN PRXCE_VC pVc,
  294. IN ULONG SendOptions,
  295. IN PMDL pMdl,
  296. IN ULONG SendLength,
  297. IN PVOID pCompletionContext);
  298. extern NTSTATUS
  299. NTAPI
  300. RxCeSendDatagram(
  301. IN PRXCE_ADDRESS hAddress,
  302. IN PRXCE_CONNECTION_INFORMATION pConnectionInformation,
  303. IN ULONG SendOptions,
  304. IN PMDL pMdl,
  305. IN ULONG SendLength,
  306. IN PVOID pCompletionContext);
  307. extern PIRP
  308. RxCeAllocateIrpWithMDL(
  309. IN CCHAR StackSize,
  310. IN BOOLEAN ChargeQuota,
  311. IN PMDL Buffer);
  312. extern VOID
  313. RxCeFreeIrp(PIRP pIrp);
  314. #endif // _RXCE_H_