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.

447 lines
16 KiB

  1. /*
  2. * tptif.h
  3. *
  4. * Copyright (c) 1993 - 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the TransportInterface class.
  8. * This class provides a seamless interface to the TCP transport stack.
  9. *
  10. * The public interface of this class includes a member function for each
  11. * of the API routines that a user application would need to call. The
  12. * only API routines not directly accessible are those used for
  13. * initialization and cleanup (which are automatically executed in the
  14. * constructor and destructor, respectively). When a user application
  15. * needs to call one of the available API routines, it merely calls the
  16. * equivalent member function within the proper instance of this class.
  17. * The API routine will then be invoked using the same parameters.
  18. *
  19. * The destructor calls the cleanup routine within the DLL for which it is
  20. * responsible.
  21. *
  22. * The management plane functions include support for initialization and
  23. * setup, as well as functions allowing MCS to poll the transport
  24. * interfaces for activity.
  25. *
  26. * Caveats:
  27. * None.
  28. *
  29. * Author:
  30. * James P. Galvin, Jr.
  31. */
  32. #ifndef _TRANSPORTINTERFACE_
  33. #define _TRANSPORTINTERFACE_
  34. #include "tprtsec.h"
  35. /*
  36. * This typedef defines the errors that can be returned from calls that are
  37. * specific to TransportInterface classes. Note that the public member
  38. * functions that map to transport stack calls do not return an error of this
  39. * type. Rather, they return an error as defined by the transport API (TRAPI).
  40. */
  41. typedef enum
  42. {
  43. TRANSPORT_INTERFACE_NO_ERROR,
  44. TRANSPORT_INTERFACE_INITIALIZATION_FAILED,
  45. TRANSPORT_INTERFACE_ALLOCATION_FAILED,
  46. TRANSPORT_INTERFACE_NO_SUCH_CONNECTION,
  47. TRANSPORT_INTERFACE_CONNECTION_ALREADY_EXISTS
  48. } TransportInterfaceError;
  49. typedef TransportInterfaceError * PTransportInterfaceError;
  50. class CTransportConnList2 : public CList2
  51. {
  52. DEFINE_CLIST2(CTransportConnList2, PConnection, UINT)
  53. void AppendEx(PConnection p, TransportConnection XprtConn)
  54. {
  55. UINT nKey = PACK_XPRTCONN(XprtConn);
  56. Append(nKey, p);
  57. }
  58. PConnection FindEx(TransportConnection XprtConn)
  59. {
  60. UINT nKey = PACK_XPRTCONN(XprtConn);
  61. return Find(nKey);
  62. }
  63. PConnection RemoveEx(TransportConnection XprtConn)
  64. {
  65. UINT nKey = PACK_XPRTCONN(XprtConn);
  66. return Remove(nKey);
  67. }
  68. };
  69. /*
  70. * These are the owner callback messages that a transport interface object
  71. * can send. They correspond directly to the messages that will be received
  72. * from the various transport stacks.
  73. */
  74. #define CONNECT_CONFIRM 0
  75. #define DISCONNECT_INDICATION 1
  76. #define DATA_INDICATION 2
  77. #define STATUS_INDICATION 3
  78. #define BUFFER_EMPTY_INDICATION 4
  79. #define WAIT_UPDATE_INDICATION 5
  80. /*
  81. * This is simply a forward reference for the class defined below. It is used
  82. * in the definition of the owner callback structure defined in this section.
  83. */
  84. class TransportInterface;
  85. typedef TransportInterface * PTransportInterface;
  86. /*
  87. * Owner Callback: CONNECT_CONFIRM
  88. * Parameter1: Unused
  89. * Parameter2: TransportConnection transport_connection
  90. *
  91. * Usage:
  92. * This owner callback is sent when a connect confirm is received from
  93. * the transport layer. This is to inform the recipient that a transport
  94. * connection is now available for use. Connect confirm will occur
  95. * on outbound connections. They represent a new transport connection
  96. * that has resulted from this system calling a remote one. As such,
  97. * there should always be a registered owner of the transport connection
  98. * (registration is a side-effect of the call to ConnectRequest).
  99. *
  100. * So the connect confirm will be routed to the object that is the
  101. * registered owner of the transport connection. That object may now
  102. * utilize the connection to transfer data.
  103. */
  104. /*
  105. * Owner Callback: DISCONNECT_INDICATION
  106. * Parameter1: Unused
  107. * Parameter2: TransportConnection transport_connection
  108. *
  109. * Usage:
  110. * This owner callback is sent when a disconnect indication is received
  111. * from the transport layer. This is to inform the recipient that a
  112. * transport connection is no longer available for use. If an object
  113. * has explicitly registered itself as the owner of a transport connection,
  114. * then it will receive the disconnect indication. If there has been no
  115. * such registration, then the disconnect indication will be sent to the
  116. * default owner callback.
  117. *
  118. * Once a disconnect indication has been issued for a given transport
  119. * connection, that connection can no longer be used for anything.
  120. */
  121. /*
  122. * Owner Callback: DATA_INDICATION
  123. * Parameter1: PDataIndicationInfo data_indication_info
  124. * Parameter2: TransportConnection transport_connection
  125. *
  126. * Usage:
  127. * This owner callback is sent when a data indication is received from
  128. * the transport layer. The transport data structure contains the address
  129. * and length of the user data field that is associated with the data
  130. * indication. If an object in the system has explicitly registered
  131. * ownership of the transport connection that carried the data (either
  132. * through ConnectRequest or RegisterTransportConnection), then this
  133. * callback will be sent to that object. If no object has registered
  134. * this transport connection, then the data will be sent to the default
  135. * owner.
  136. */
  137. /*
  138. * Owner Callback: STATUS_INDICATION
  139. * Parameter1: PTransportStatus transport_status
  140. * Parameter2: Unused
  141. *
  142. * Usage:
  143. * This owner callback is just a pass-through of the status indication
  144. * that comes from the transport layer. It contains a pointer to a
  145. * transport status structure that contains status information that
  146. * originated from the stack represented by this object. This is always
  147. * passed to the default owner object.
  148. */
  149. /*
  150. * Owner Callback: BUFFER_EMPTY_INDICATION
  151. * Parameter1: Unused
  152. * Parameter2: TransportConnection transport_connection
  153. *
  154. * Usage:
  155. * This owner callback is a pass-through of the buffer empty indication
  156. * that comes from the transport layer. It is sent to the object that
  157. * has registered ownership of the specified transport connection. This
  158. * indication tells that object that the transport layer can now accept
  159. * more data.
  160. */
  161. class Connection;
  162. typedef Connection *PConnection;
  163. /*
  164. * This is the class definition for the TransportInterface class. Remember,
  165. * this class contains pure virtual functions which makes it an abstract base
  166. * class. It cannot be instantiated, but rather, exists to be inherited from.
  167. * These derived classes will implement the behavior that is specific to a
  168. * particular transport stack (or possibly just the interface to a particular
  169. * transport stack).
  170. */
  171. class TransportInterface
  172. {
  173. public:
  174. TransportInterface (
  175. HANDLE transport_transmit_event,
  176. PTransportInterfaceError
  177. transport_interface_error);
  178. ~TransportInterface ();
  179. TransportInterfaceError RegisterTransportConnection (
  180. TransportConnection transport_connection,
  181. PConnection owner_object,
  182. BOOL bNoNagle);
  183. #ifdef NM_RESET_DEVICE
  184. TransportError ResetDevice (
  185. PChar device_identifier);
  186. #endif // NM_RESET_DEVICE
  187. TransportError ConnectRequest (
  188. TransportAddress transport_address,
  189. BOOL fSecure,
  190. BOOL bNoNagle,
  191. PConnection owner_object,
  192. PTransportConnection
  193. transport_connection);
  194. void DisconnectRequest (
  195. TransportConnection transport_connection);
  196. void DataRequestReady () {
  197. SetEvent (Transport_Transmit_Event);
  198. };
  199. void ReceiveBufferAvailable ();
  200. BOOL GetSecurity( TransportConnection transport_connection );
  201. PSecurityInterface pSecurityInterface;
  202. BOOL bInServiceContext;
  203. TransportInterfaceError CreateConnectionCallback (
  204. TransportConnection transport_connection,
  205. PConnection owner_object);
  206. void ConnectIndication (
  207. TransportConnection transport_connection);
  208. void ConnectConfirm (
  209. TransportConnection transport_connection);
  210. void DisconnectIndication (
  211. TransportConnection transport_connection,
  212. ULONG ulReason);
  213. TransportError DataIndication (
  214. PTransportData transport_data);
  215. void BufferEmptyIndication (
  216. TransportConnection transport_connection);
  217. private:
  218. CTransportConnList2 m_TrnsprtConnCallbackList2;
  219. HANDLE Transport_Transmit_Event;
  220. };
  221. /*
  222. * TransportInterface (
  223. * PTransportInterfaceError transport_interface_error)
  224. *
  225. * Functional Description:
  226. * The constructor initializes the TCP transport code.
  227. *
  228. * The constructor also includes parameters specifying the default
  229. * callback. This callback is used to inform the controller whenever an
  230. * unexpected inbound connection is detected. This gives the controller
  231. * the opportunity to assign responsibility for the new connection to some
  232. * other object in the system.
  233. *
  234. * If anything goes wrong in the constructor, the return value (whose
  235. * address is passed as a constructor parameter) will be set to one of the
  236. * failure codes. If this happens, it is expected that whoever invoked the
  237. * constructor (probably the controller), will immediately delete the
  238. * object without using it. Failure to do this WILL result in unexpected
  239. * behavior.
  240. *
  241. * Formal Parameters:
  242. * default_owner_object (i)
  243. * This is the address of the object that will handle all transport
  244. * events for unregistered transport connections. This includes
  245. * connect indication, dicsonnect indication, and data indication.
  246. * This object will also receive all state and message indications.
  247. * default_owner_message_base (i)
  248. * This is the base value to be used for all owner callback messages.
  249. * transport_interface_error (o)
  250. * This is where the return code will be stored so that the creator of
  251. * this object can make sure that everything is okay before using the
  252. * new object. If this value is set to anything but success, the
  253. * object should be destroyed immediately, without being used.
  254. *
  255. * Return Value:
  256. * Note: the return value is handled as a constructor parameter.
  257. * TRANSPORT_INTERFACE_NO_ERROR
  258. * Everything worked, and the object is ready for use.
  259. * TRANSPORT_INTERFACE_INITIALIZATION_FAILED
  260. * The initialization of the transport interface object failed. It is
  261. * therefore necessary to destroy the object without attempting to
  262. * use it.
  263. *
  264. * Side Effects:
  265. * A DLL will be loaded into memory, for later use.
  266. *
  267. * Caveats:
  268. */
  269. /*
  270. * ~TransportInterface ()
  271. *
  272. * Functional Description:
  273. * The destructor frees up all resources used by the base class. This
  274. * is primarily associated with the callback list (which is maintained by
  275. * this class).
  276. *
  277. * Formal Parameters:
  278. * Destructors have no parameters.
  279. *
  280. * Return Value:
  281. * Destructors have no return value.
  282. *
  283. * Side Effects:
  284. * None.
  285. *
  286. * Caveats:
  287. * None.
  288. */
  289. /*
  290. * TransportInterfaceError RegisterTransportConnection (
  291. * TransportConnection transport_connection,
  292. * PConnection owner_object,
  293. * BOOL bNoNagle)
  294. *
  295. * Functional Description:
  296. * When an inbound connection is detected, an entry is created in the
  297. * callback list for it using the default owner callback information (that
  298. * was specified in the constructor). This means that all events detected
  299. * for the new transport connection will be sent to the default owner
  300. * object until another object explicitly registers itself as the owner
  301. * of the transport connection. That is what this routine is used for.
  302. *
  303. * Once an object has registered itself as the owner of a transport
  304. * connection, it will receive all events related to that connection.
  305. *
  306. * Formal Parameters:
  307. * transport_connection (i)
  308. * This is the transport connection for which the callback information
  309. * is to be associated.
  310. * owner_object (i)
  311. * This is the address of the Connection object that is to receive all transport
  312. * layer events for the specified transport connection.
  313. * bNoNagle (i)
  314. * Should the connection stop using the Nagle algorithm?
  315. *
  316. * Return Value:
  317. * TRANSPORT_INTERFACE_NO_ERROR
  318. * The operation completed successfully.
  319. * TRANSPORT_INTERFACE_NO_SUCH_CONNECTION
  320. * This indicates that the named transport connection does not exist.
  321. *
  322. * Side Effects:
  323. * None.
  324. *
  325. * Caveats:
  326. * None.
  327. */
  328. /*
  329. * TransportError ConnectRequest (
  330. * TransportAddress transport_address,
  331. * BOOL bNoNagle,
  332. * PConnection owner_object,
  333. * PTransportConnection transport_connection)
  334. *
  335. * Functional Description:
  336. * This operation is invoked when the user application wishes to establish
  337. * an outbound connection. Assuming that everything is successful, the
  338. * owner callback information that is passed in to this operation is saved
  339. * for later use. All events for this transport connection will be routed
  340. * to the specified owner rather than the default owner.
  341. *
  342. * Formal Parameters:
  343. * transport_address (i)
  344. * This is the transport address to be passed to the transport stack
  345. * during the connection creation process. The format of this address
  346. * string will vary by transport stack, and cannot be specified here.
  347. * bNoNagle (i)
  348. * Do we need to disable the Nagle algorithm?
  349. * owner_object (i)
  350. * This is the address of the object that is to receive all transport
  351. * layer events for the new transport connection.
  352. * transport_connection (o)
  353. * This is the address of the variable that is to receive the transport
  354. * connection handle that is associated with this connection. Note
  355. * that this handle is assigned before the connection is actually
  356. * established, to allow the application to abort a connection in
  357. * progress.
  358. *
  359. * Return Value:
  360. * TRANSPORT_NO_ERROR
  361. * The operation completed successfully.
  362. * TRANSPORT_NOT_INITIALIZED
  363. * The transport stack is not initialized.
  364. *
  365. * Side Effects:
  366. * An outbound connection establishment process is begun in the background.
  367. *
  368. * Caveats:
  369. * None.
  370. */
  371. /*
  372. * TransportError DisconnectRequest (
  373. * TransportConnection transport_connection)
  374. *
  375. * Functional Description:
  376. * This operation is used to break an existing transport connection. If
  377. * the operation is successful, the transport connection will be removed
  378. * from the callback list.
  379. *
  380. * Formal Parameters:
  381. * transport_connection (i)
  382. * This is the transport connection that is to be broken.
  383. *
  384. * Return Value:
  385. * TRANSPORT_NO_ERROR
  386. * The operation completed successfully.
  387. * TRANSPORT_NOT_INITIALIZED
  388. * The transport stack is not initialized.
  389. * TRANSPORT_NO_SUCH_CONNECTION
  390. * This indicates that the specified transport connection does not
  391. * exist.
  392. *
  393. * Side Effects:
  394. * A transport connection is severed.
  395. *
  396. * Caveats:
  397. * None.
  398. */
  399. /*
  400. * TransportError PollReceiver ()
  401. *
  402. * Functional Description:
  403. * This operation is used to check a transport stack for incoming data (or
  404. * other events, such as connect and disconnect indications). In a single
  405. * threaded environment, this call could also be used to provide a
  406. * time-slice for the processing of inbound data, as well as other events
  407. * (such as the creation of new connections).
  408. *
  409. * Formal Parameters:
  410. * None.
  411. *
  412. * Return Value:
  413. * TRANSPORT_NO_ERROR
  414. * The operation completed successfully.
  415. *
  416. * Side Effects:
  417. * This can result in callbacks from the transport layer back into this
  418. * object.
  419. *
  420. * Caveats:
  421. * None.
  422. */
  423. #endif