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.

446 lines
15 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. TransportInterfaceError CreateConnectionCallback (
  203. TransportConnection transport_connection,
  204. PConnection owner_object);
  205. void ConnectIndication (
  206. TransportConnection transport_connection);
  207. void ConnectConfirm (
  208. TransportConnection transport_connection);
  209. void DisconnectIndication (
  210. TransportConnection transport_connection,
  211. ULONG ulReason);
  212. TransportError DataIndication (
  213. PTransportData transport_data);
  214. void BufferEmptyIndication (
  215. TransportConnection transport_connection);
  216. private:
  217. CTransportConnList2 m_TrnsprtConnCallbackList2;
  218. HANDLE Transport_Transmit_Event;
  219. };
  220. /*
  221. * TransportInterface (
  222. * PTransportInterfaceError transport_interface_error)
  223. *
  224. * Functional Description:
  225. * The constructor initializes the TCP transport code.
  226. *
  227. * The constructor also includes parameters specifying the default
  228. * callback. This callback is used to inform the controller whenever an
  229. * unexpected inbound connection is detected. This gives the controller
  230. * the opportunity to assign responsibility for the new connection to some
  231. * other object in the system.
  232. *
  233. * If anything goes wrong in the constructor, the return value (whose
  234. * address is passed as a constructor parameter) will be set to one of the
  235. * failure codes. If this happens, it is expected that whoever invoked the
  236. * constructor (probably the controller), will immediately delete the
  237. * object without using it. Failure to do this WILL result in unexpected
  238. * behavior.
  239. *
  240. * Formal Parameters:
  241. * default_owner_object (i)
  242. * This is the address of the object that will handle all transport
  243. * events for unregistered transport connections. This includes
  244. * connect indication, dicsonnect indication, and data indication.
  245. * This object will also receive all state and message indications.
  246. * default_owner_message_base (i)
  247. * This is the base value to be used for all owner callback messages.
  248. * transport_interface_error (o)
  249. * This is where the return code will be stored so that the creator of
  250. * this object can make sure that everything is okay before using the
  251. * new object. If this value is set to anything but success, the
  252. * object should be destroyed immediately, without being used.
  253. *
  254. * Return Value:
  255. * Note: the return value is handled as a constructor parameter.
  256. * TRANSPORT_INTERFACE_NO_ERROR
  257. * Everything worked, and the object is ready for use.
  258. * TRANSPORT_INTERFACE_INITIALIZATION_FAILED
  259. * The initialization of the transport interface object failed. It is
  260. * therefore necessary to destroy the object without attempting to
  261. * use it.
  262. *
  263. * Side Effects:
  264. * A DLL will be loaded into memory, for later use.
  265. *
  266. * Caveats:
  267. */
  268. /*
  269. * ~TransportInterface ()
  270. *
  271. * Functional Description:
  272. * The destructor frees up all resources used by the base class. This
  273. * is primarily associated with the callback list (which is maintained by
  274. * this class).
  275. *
  276. * Formal Parameters:
  277. * Destructors have no parameters.
  278. *
  279. * Return Value:
  280. * Destructors have no return value.
  281. *
  282. * Side Effects:
  283. * None.
  284. *
  285. * Caveats:
  286. * None.
  287. */
  288. /*
  289. * TransportInterfaceError RegisterTransportConnection (
  290. * TransportConnection transport_connection,
  291. * PConnection owner_object,
  292. * BOOL bNoNagle)
  293. *
  294. * Functional Description:
  295. * When an inbound connection is detected, an entry is created in the
  296. * callback list for it using the default owner callback information (that
  297. * was specified in the constructor). This means that all events detected
  298. * for the new transport connection will be sent to the default owner
  299. * object until another object explicitly registers itself as the owner
  300. * of the transport connection. That is what this routine is used for.
  301. *
  302. * Once an object has registered itself as the owner of a transport
  303. * connection, it will receive all events related to that connection.
  304. *
  305. * Formal Parameters:
  306. * transport_connection (i)
  307. * This is the transport connection for which the callback information
  308. * is to be associated.
  309. * owner_object (i)
  310. * This is the address of the Connection object that is to receive all transport
  311. * layer events for the specified transport connection.
  312. * bNoNagle (i)
  313. * Should the connection stop using the Nagle algorithm?
  314. *
  315. * Return Value:
  316. * TRANSPORT_INTERFACE_NO_ERROR
  317. * The operation completed successfully.
  318. * TRANSPORT_INTERFACE_NO_SUCH_CONNECTION
  319. * This indicates that the named transport connection does not exist.
  320. *
  321. * Side Effects:
  322. * None.
  323. *
  324. * Caveats:
  325. * None.
  326. */
  327. /*
  328. * TransportError ConnectRequest (
  329. * TransportAddress transport_address,
  330. * BOOL bNoNagle,
  331. * PConnection owner_object,
  332. * PTransportConnection transport_connection)
  333. *
  334. * Functional Description:
  335. * This operation is invoked when the user application wishes to establish
  336. * an outbound connection. Assuming that everything is successful, the
  337. * owner callback information that is passed in to this operation is saved
  338. * for later use. All events for this transport connection will be routed
  339. * to the specified owner rather than the default owner.
  340. *
  341. * Formal Parameters:
  342. * transport_address (i)
  343. * This is the transport address to be passed to the transport stack
  344. * during the connection creation process. The format of this address
  345. * string will vary by transport stack, and cannot be specified here.
  346. * bNoNagle (i)
  347. * Do we need to disable the Nagle algorithm?
  348. * owner_object (i)
  349. * This is the address of the object that is to receive all transport
  350. * layer events for the new transport connection.
  351. * transport_connection (o)
  352. * This is the address of the variable that is to receive the transport
  353. * connection handle that is associated with this connection. Note
  354. * that this handle is assigned before the connection is actually
  355. * established, to allow the application to abort a connection in
  356. * progress.
  357. *
  358. * Return Value:
  359. * TRANSPORT_NO_ERROR
  360. * The operation completed successfully.
  361. * TRANSPORT_NOT_INITIALIZED
  362. * The transport stack is not initialized.
  363. *
  364. * Side Effects:
  365. * An outbound connection establishment process is begun in the background.
  366. *
  367. * Caveats:
  368. * None.
  369. */
  370. /*
  371. * TransportError DisconnectRequest (
  372. * TransportConnection transport_connection)
  373. *
  374. * Functional Description:
  375. * This operation is used to break an existing transport connection. If
  376. * the operation is successful, the transport connection will be removed
  377. * from the callback list.
  378. *
  379. * Formal Parameters:
  380. * transport_connection (i)
  381. * This is the transport connection that is to be broken.
  382. *
  383. * Return Value:
  384. * TRANSPORT_NO_ERROR
  385. * The operation completed successfully.
  386. * TRANSPORT_NOT_INITIALIZED
  387. * The transport stack is not initialized.
  388. * TRANSPORT_NO_SUCH_CONNECTION
  389. * This indicates that the specified transport connection does not
  390. * exist.
  391. *
  392. * Side Effects:
  393. * A transport connection is severed.
  394. *
  395. * Caveats:
  396. * None.
  397. */
  398. /*
  399. * TransportError PollReceiver ()
  400. *
  401. * Functional Description:
  402. * This operation is used to check a transport stack for incoming data (or
  403. * other events, such as connect and disconnect indications). In a single
  404. * threaded environment, this call could also be used to provide a
  405. * time-slice for the processing of inbound data, as well as other events
  406. * (such as the creation of new connections).
  407. *
  408. * Formal Parameters:
  409. * None.
  410. *
  411. * Return Value:
  412. * TRANSPORT_NO_ERROR
  413. * The operation completed successfully.
  414. *
  415. * Side Effects:
  416. * This can result in callbacks from the transport layer back into this
  417. * object.
  418. *
  419. * Caveats:
  420. * None.
  421. */
  422. #endif