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.

421 lines
13 KiB

  1. /*++
  2. Copyright (c) 1989 - 1999 Microsoft Corporation
  3. Module Name:
  4. transprt.h
  5. Abstract:
  6. This module implements all transport related functions in the SMB connection
  7. engine
  8. Notes:
  9. --*/
  10. #ifndef _TRANSPRT_H_
  11. #define _TRANSPRT_H_
  12. // The SMBCE_TRANSPORT data structure encapsulates all the information w.r.t a
  13. // particular transport for the connection engine. All the transports that are
  14. // of interest to the SMB mini redirector are maintained in a doubly linked list
  15. //
  16. // The connection engine tries all the transports in this list when trying to
  17. // establish a connection to a server. Currently only connection oriented
  18. // transports are handled.
  19. typedef struct _SMBCE_TRANSPORT_ {
  20. SMBCE_OBJECT_HEADER;
  21. RXCE_TRANSPORT RxCeTransport;
  22. RXCE_ADDRESS RxCeAddress;
  23. ULONG Priority; // the priority in the binding list.
  24. BOOLEAN Active;
  25. // Additional information regarding quality of service and other selection
  26. // criterion for a transport will be included here.
  27. } SMBCE_TRANSPORT, *PSMBCE_TRANSPORT;
  28. typedef struct _SMBCE_TRANSPORT_ARRAY_ {
  29. ULONG ReferenceCount;
  30. ULONG Count;
  31. PSMBCE_TRANSPORT *SmbCeTransports;
  32. PRXCE_ADDRESS *LocalAddresses;
  33. } SMBCE_TRANSPORT_ARRAY, *PSMBCE_TRANSPORT_ARRAY;
  34. typedef struct _SMBCE_TRANSPORTS_ {
  35. RX_SPIN_LOCK Lock;
  36. PSMBCE_TRANSPORT_ARRAY pTransportArray;
  37. } SMBCE_TRANSPORTS, *PSMBCE_TRANSPORTS;
  38. extern SMBCE_TRANSPORTS MRxSmbTransports;
  39. // Transport entries are added to the list of known transports upon receipt of
  40. // PnP notifications. Currently the list is static since transport disabling
  41. // notifications are not handled by the underlying TDI/PnP layer.
  42. // The following routines provide the ability for adding/deleting entries to
  43. // this list.
  44. extern
  45. PSMBCE_TRANSPORT_ARRAY
  46. SmbCeReferenceTransportArray(VOID);
  47. extern NTSTATUS
  48. SmbCeDereferenceTransportArray(PSMBCE_TRANSPORT_ARRAY pTransportArray);
  49. extern NTSTATUS
  50. SmbCeAddTransport(PSMBCE_TRANSPORT pTransport);
  51. extern NTSTATUS
  52. SmbCeRemoveTransport(PSMBCE_TRANSPORT pTransport);
  53. #define SmbCeGetAvailableTransportCount() \
  54. (MRxSmbTransports.Count)
  55. // The connection engine maintains a reference count associated with each transport
  56. // which indicates the number of servers that are using the transport. This will
  57. // eventually provide the mechanism for disabling/enabling transport on receipt
  58. // of PnP notifications.
  59. #define SmbCeReferenceTransport(pTransport) \
  60. SmbCepReferenceTransport(pTransport)
  61. #define SmbCeDereferenceTransport(pTransport) \
  62. SmbCepDereferenceTransport(pTransport)
  63. // The server transport types encapsulate the various usages of the underlying
  64. // transport to communicate with a server.
  65. //
  66. // The interactions are currently classified into four types, MAILSOT, Virtual
  67. // Circuit, Datagram and Htbrid ( VC + Datagram ).
  68. //
  69. // The type chosen will depend upon the characterstics of the available
  70. // connection. Each type is associated with its own dispatch vector which
  71. // encapsulates the interaction between the connection engine and the transport.
  72. //
  73. // This includes Send,Receive, Receive Ind. etc. These are modelled after the
  74. // TDI interfaces.
  75. typedef enum _SMBCE_SERVER_TRANSPORT_TYPE_ {
  76. SMBCE_STT_VC = 1,
  77. SMBCE_STT_DATAGRAM = 2,
  78. SMBCE_STT_HYBRID = 4
  79. } SMBCE_SERVER_TRANSPORT_TYPE, *PSMBCE_SERVER_TRANSPORT_TYPE;
  80. typedef struct SMBCE_SERVER_TRANSPORT {
  81. SMBCE_OBJECT_HEADER;
  82. struct TRANSPORT_DISPATCH_VECTOR *pDispatchVector;
  83. struct _SMBCE_TRANSPORT_ *pTransport;
  84. PKEVENT pRundownEvent; // used for finalization.
  85. ULONG MaximumSendSize; // max data size
  86. } SMBCE_SERVER_TRANSPORT, *PSMBCE_SERVER_TRANSPORT;
  87. // The SMBCE_SERVER_TRANSPORT instances are reference counted. The following
  88. // routines provide the referencing mechanism. Defining them as macros also
  89. // provides us with a easy debugging capability, i.e., it can be easily modified
  90. // to include a FILE/LINE number each time an instance is referenced and
  91. // dereferenced
  92. #define SmbCeReferenceServerTransport(pServerTransportPointer) \
  93. SmbCepReferenceServerTransport(pServerTransportPointer)
  94. #define SmbCeDereferenceServerTransport(pServerTransportPointer) \
  95. SmbCepDereferenceServerTransport(pServerTransportPointer)
  96. // The server transport establishment mechanism requires a callback mechanism
  97. // to handle the asynchronous connection establishment cases.
  98. typedef
  99. VOID
  100. (*PSMBCE_SERVER_TRANSPORT_CONSTRUCTION_CALLBACK)(
  101. PVOID pContext);
  102. typedef
  103. VOID
  104. (*PSMBCE_SERVER_TRANSPORT_DESTRUCTION_CALLBACK)(
  105. PVOID pContext);
  106. typedef enum _SMBCE_SERVER_TRANSPORT_CONSTRUCTION_STATE {
  107. SmbCeServerTransportConstructionBegin,
  108. SmbCeServerVcTransportConstructionBegin,
  109. SmbCeServerVcTransportConstructionEnd,
  110. SmbCeServerTransportConstructionEnd
  111. } SMBCE_SERVER_TRANSPORT_CONSTRUCTION_STATE,
  112. *PSMBCE_SERVER_TRANSPORT_CONSTRUCTION_STATE;
  113. typedef struct _SMBCE_SERVER_TRANSPORT_CONSTRUCTION_CONTEXT {
  114. NTSTATUS Status;
  115. SMBCE_SERVER_TRANSPORT_CONSTRUCTION_STATE State;
  116. PSMBCE_SERVER_TRANSPORT_CONSTRUCTION_CALLBACK pCompletionRoutine;
  117. PMRX_SRVCALL_CALLBACK_CONTEXT pCallbackContext;
  118. PKEVENT pCompletionEvent;
  119. PSMBCEDB_SERVER_ENTRY pServerEntry;
  120. ULONG TransportsToBeConstructed;
  121. PSMBCE_SERVER_TRANSPORT pTransport;
  122. RX_WORK_QUEUE_ITEM WorkQueueItem;
  123. } SMBCE_SERVER_TRANSPORT_CONSTRUCTION_CONTEXT,
  124. *PSMBCE_SERVER_TRANSPORT_CONSTRUCTION_CONTEXT;
  125. // The SERVER transport dispatch vector prototypes
  126. typedef
  127. NTSTATUS
  128. (*PTRANSPORT_DISPATCH_SEND)(
  129. PSMBCE_SERVER_TRANSPORT pTransport,
  130. PSMBCEDB_SERVER_ENTRY pServerEntry,
  131. ULONG SendOptions,
  132. PMDL pSmbMdl,
  133. ULONG SendLength,
  134. PVOID pSendCompletionContext);
  135. typedef
  136. NTSTATUS
  137. (*PTRANSPORT_DISPATCH_SEND_DATAGRAM)(
  138. PSMBCE_SERVER_TRANSPORT pTransport,
  139. PSMBCEDB_SERVER_ENTRY pServerEntry,
  140. ULONG SendOptions,
  141. PMDL pSmbMdl,
  142. ULONG SendLength,
  143. PVOID pSendCompletionContext);
  144. typedef
  145. NTSTATUS
  146. (*PTRANSPORT_DISPATCH_TRANCEIVE)(
  147. PSMBCE_SERVER_TRANSPORT pTransport,
  148. PSMBCEDB_SERVER_ENTRY pServerEntry,
  149. PSMB_EXCHANGE pExchange,
  150. ULONG SendOptions,
  151. PMDL pSmbMdl,
  152. ULONG SendLength,
  153. PVOID pSendCompletionContext);
  154. typedef
  155. NTSTATUS
  156. (*PTRANSPORT_DISPATCH_RECEIVE)(
  157. PSMBCE_SERVER_TRANSPORT pTransport,
  158. PSMBCEDB_SERVER_ENTRY pServerEntry,
  159. PSMB_EXCHANGE pExchange);
  160. typedef
  161. NTSTATUS
  162. (*PTRANSPORT_DISPATCH_INITIALIZE_EXCHANGE)(
  163. PSMBCE_SERVER_TRANSPORT pTransport,
  164. PSMB_EXCHANGE pExchange);
  165. typedef
  166. NTSTATUS
  167. (*PTRANSPORT_DISPATCH_UNINITIALIZE_EXCHANGE)(
  168. PSMBCE_SERVER_TRANSPORT pTransport,
  169. PSMB_EXCHANGE pExchange);
  170. typedef
  171. VOID
  172. (*PTRANSPORT_DISPATCH_TEARDOWN)(
  173. PSMBCE_SERVER_TRANSPORT pTransport);
  174. typedef
  175. NTSTATUS
  176. (*PTRANSPORT_DISPATCH_INITIATE_DISCONNECT)(
  177. PSMBCE_SERVER_TRANSPORT pTransport);
  178. typedef struct TRANSPORT_DISPATCH_VECTOR {
  179. PTRANSPORT_DISPATCH_SEND Send;
  180. PTRANSPORT_DISPATCH_SEND_DATAGRAM SendDatagram;
  181. PTRANSPORT_DISPATCH_TRANCEIVE Tranceive;
  182. PTRANSPORT_DISPATCH_RECEIVE Receive;
  183. PRX_WORKERTHREAD_ROUTINE TimerEventHandler;
  184. PTRANSPORT_DISPATCH_INITIALIZE_EXCHANGE InitializeExchange;
  185. PTRANSPORT_DISPATCH_UNINITIALIZE_EXCHANGE UninitializeExchange;
  186. PTRANSPORT_DISPATCH_TEARDOWN TearDown;
  187. PTRANSPORT_DISPATCH_INITIATE_DISCONNECT InitiateDisconnect;
  188. } TRANSPORT_DISPATCH_VECTOR, *PTRANSPORT_DISPATCH_VECTOR;
  189. // A macro for invoking a routine through the SMBCE_SERVER_TRANSPORT
  190. // dispatch vector.
  191. #define SMBCE_TRANSPORT_DISPATCH(pServerEntry,Routine,Arguments) \
  192. (*((pServerEntry)->pTransport->pDispatchVector->Routine))##Arguments
  193. // The currently known transport type dispatch vectors and the mechanisms
  194. // for instanting an instance.
  195. extern TRANSPORT_DISPATCH_VECTOR MRxSmbVctTransportDispatch;
  196. extern TRANSPORT_DISPATCH_VECTOR MRxSmbMsTransportDispatch;
  197. extern NTSTATUS
  198. MsInstantiateServerTransport(
  199. IN OUT PSMBCE_SERVER_TRANSPORT_CONSTRUCTION_CONTEXT pContext);
  200. extern NTSTATUS
  201. VctInstantiateServerTransport(
  202. IN OUT PSMBCE_SERVER_TRANSPORT_CONSTRUCTION_CONTEXT pContext);
  203. extern VOID
  204. SmbCeConstructServerTransport(
  205. IN OUT PSMBCE_SERVER_TRANSPORT_CONSTRUCTION_CONTEXT pContext);
  206. // The following routines constitute the interface by which the clients of
  207. // the connection engine initialize/send/receive/uninitialize data to the
  208. // remote servers
  209. extern NTSTATUS
  210. SmbCeInitializeExchangeTransport(
  211. PSMB_EXCHANGE pExchange);
  212. extern NTSTATUS
  213. SmbCeUninitializeExchangeTransport(
  214. PSMB_EXCHANGE pExchange);
  215. extern NTSTATUS
  216. SmbCeInitiateDisconnect(
  217. IN OUT PSMBCEDB_SERVER_ENTRY pServerEntry);
  218. // The routines for constructing the transports provide the flexibility to
  219. // construct certain combination of transports. This is provided by the
  220. // SmbCepInitializeServerTransport routine and the different flavours of
  221. // construction routines provided
  222. #define SMBCE_CONSTRUCT_ALL_TRANSPORTS \
  223. (SMBCE_STT_VC)
  224. extern NTSTATUS
  225. SmbCepInitializeServerTransport(
  226. PSMBCEDB_SERVER_ENTRY pServerEntry,
  227. PSMBCE_SERVER_TRANSPORT_CONSTRUCTION_CALLBACK pCallbackRoutine,
  228. PMRX_SRVCALL_CALLBACK_CONTEXT pCallbackContext,
  229. ULONG TransportsToBeConsstructed);
  230. #define SmbCeInitializeServerTransport(pServerEntry,pCallbackRoutine,pCallbackContext) \
  231. SmbCepInitializeServerTransport( \
  232. (pServerEntry), \
  233. (pCallbackRoutine), \
  234. (pCallbackContext), \
  235. SMBCE_CONSTRUCT_ALL_TRANSPORTS)
  236. extern NTSTATUS
  237. SmbCeUninitializeServerTransport(
  238. PSMBCEDB_SERVER_ENTRY pServerEntry,
  239. PSMBCE_SERVER_TRANSPORT_DESTRUCTION_CALLBACK pCallbackRoutine,
  240. PVOID pCallbackContext);
  241. extern VOID
  242. SmbCeCompleteUninitializeServerTransport(
  243. PSMBCEDB_SERVER_ENTRY pServerEntry);
  244. extern NTSTATUS
  245. SmbCepReferenceTransport(
  246. IN OUT PSMBCE_TRANSPORT pTransport);
  247. extern NTSTATUS
  248. SmbCepDereferenceTransport(
  249. IN OUT PSMBCE_TRANSPORT pTransport);
  250. extern PSMBCE_TRANSPORT
  251. SmbCeFindTransport(
  252. PUNICODE_STRING pTransportName);
  253. extern NTSTATUS
  254. SmbCepReferenceServerTransport(
  255. IN OUT PSMBCE_SERVER_TRANSPORT *pTransportPointer);
  256. extern NTSTATUS
  257. SmbCepDereferenceServerTransport(
  258. IN OUT PSMBCE_SERVER_TRANSPORT *pTransportPointer);
  259. extern PFILE_OBJECT
  260. SmbCepReferenceEndpointFileObject(
  261. IN PSMBCE_SERVER_TRANSPORT pTransport);
  262. extern NTSTATUS
  263. SmbCeSend(
  264. PSMB_EXCHANGE pExchange,
  265. ULONG SendOptions,
  266. PMDL pSmbMdl,
  267. ULONG SendLength);
  268. extern NTSTATUS
  269. SmbCeSendToServer(
  270. PSMBCEDB_SERVER_ENTRY pServerEntry,
  271. ULONG SendOptions,
  272. PMDL pSmbMdl,
  273. ULONG SendLength);
  274. extern NTSTATUS
  275. SmbCeSendDatagram(
  276. PSMB_EXCHANGE pExchange,
  277. ULONG SendOptions,
  278. PMDL pSmbMdl,
  279. ULONG SendLength);
  280. extern NTSTATUS
  281. SmbCeTranceive(
  282. PSMB_EXCHANGE pExchange,
  283. ULONG SendOptions,
  284. PMDL pRxCeDataBuffer,
  285. ULONG SendLength);
  286. extern NTSTATUS
  287. SmbCeReceive(
  288. PSMB_EXCHANGE pExchange);
  289. //
  290. // Call ups from the transport to the connection engine
  291. //
  292. extern NTSTATUS
  293. SmbCeReceiveInd(
  294. IN PSMBCEDB_SERVER_ENTRY pServerEntry,
  295. IN ULONG BytesIndicated,
  296. IN ULONG BytesAvailable,
  297. OUT ULONG *pBytesTaken,
  298. IN PVOID pTsdu, // pointer describing this TSDU, typically a lump of bytes
  299. OUT PMDL *pDataBufferPointer, // the buffer in which data is to be copied.
  300. OUT PULONG pDataBufferSize, // amount of data to copy
  301. IN ULONG ReceiveFlags
  302. );
  303. extern NTSTATUS
  304. SmbCeDataReadyInd(
  305. IN PSMBCEDB_SERVER_ENTRY pServerEntry,
  306. IN PMDL pBuffer,
  307. IN ULONG DataSize,
  308. IN NTSTATUS DataReadyStatus
  309. );
  310. extern NTSTATUS
  311. SmbCeErrorInd(
  312. IN PSMBCEDB_SERVER_ENTRY pServerEntry,
  313. IN NTSTATUS IndicatedStatus
  314. );
  315. extern NTSTATUS
  316. SmbCeSendCompleteInd(
  317. IN PSMBCEDB_SERVER_ENTRY pServerEntry,
  318. IN PVOID pCompletionContext,
  319. IN NTSTATUS SendCompletionStatus
  320. );
  321. #endif // _TRANSPRT_H_