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.

449 lines
15 KiB

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