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.

470 lines
16 KiB

  1. /* T123.h
  2. *
  3. * Copyright (c) 1993-1995 by DataBeam Corporation, Lexington, KY
  4. *
  5. * Abstract:
  6. * This class controlls the T123 stack associated with a particular
  7. * physical connection.
  8. *
  9. * This class builds a T123 PSTN stack. The physical layer is passed in via
  10. * the constructor. During the constructor, we instantiate a multiplexer.
  11. * This multiplexer will allow us to mux multiple DataLink layers to the
  12. * same physical address. For this particular physical connection (PSTN)
  13. * the Multiplexer adds a CRC to the packet and frames it before passing
  14. * it to the physical layer. On the receive side, it frames the incoming
  15. * stream data and packetizes it. It also checks the CRC for validity.
  16. * The Multiplexer receives data from its higher layer
  17. * (DataLink) in packet form. When the Multiplexer passes data to its
  18. * lower layer, it passes it in stream form. The Multiplexer is
  19. * configured to be a multi-DataLink entity. Since it does handle multiple
  20. * DataLinks, it can NOT buffer data on the receive side. If one
  21. * particular DataLink is backed up, it can NOT hold the other DataLinks
  22. * up. If it can not pass a packet up immediately, it will trash it.
  23. *
  24. * After the Multiplexer issues a callback to us to us it is ready, we
  25. * will create a DataLink Layer to service the Network layer. The DataLink
  26. * Layer is based on the Q.922 standard. The DLCI associated with this
  27. * DataLink is 0. Its Lower Layer is the Multiplexer. Its Higher Layer is
  28. * the SCF Layer.
  29. *
  30. * The SCF Layer is the Network Layer. It is responsible for
  31. * arbitrating the DLCI and parameters used in other transport
  32. * connections. It has no responsibilities once the connection is up. If
  33. * this class receives a ConnectRequest() from the user, it issues a
  34. * ConnectRequest() to the SCF Layer. SCF will notify us when the
  35. * connection is up.
  36. *
  37. * When the SCF notifies us that a new connection exists, we create a
  38. * DataLink Layer that services the new Transport Connection. This
  39. * DataLink Layer uses our Multiplexer as its Lower Layer.
  40. *
  41. * When the DataLink Layer is up and operational, it notifies us. At this
  42. * point, we create an X224 Layer to interface with the user. The X224
  43. * Layer interfaces with the DataLink Layer to send data. It also
  44. * interfaces with the user to pass data on up.
  45. *
  46. * Caveats:
  47. * None.
  48. *
  49. * Author:
  50. * James W. Lawwill
  51. */
  52. #ifndef _T123_H_
  53. #define _T123_H_
  54. #include "scf.h"
  55. #include "q922.h"
  56. #include "mplex.h"
  57. #include "x224.h"
  58. /*
  59. ** Layer Numbers
  60. */
  61. #define PHYSICAL_LAYER 1
  62. #define MULTIPLEXER_LAYER 2 // This is a DataBeam-specific layer
  63. #define DATALINK_LAYER 3
  64. #define NETWORK_LAYER 4
  65. #define TRANSPORT_LAYER 5
  66. /*
  67. ** Layer Message Bases
  68. */
  69. #define PHYSICAL_LAYER_MESSAGE_BASE 0x0000
  70. #define MULTIPLEXER_LAYER_MESSAGE_BASE 0x1000
  71. #define DATALINK_LAYER_MESSAGE_BASE 0x2000
  72. #define NETWORK_LAYER_MESSAGE_BASE 0x3000
  73. #define TRANSPORT_LAYER_MESSAGE_BASE 0x4000
  74. #define LAYER_MASK 0x7000
  75. #define MESSAGE_MASK 0x0fff
  76. /*
  77. ** Maximum number of priorities
  78. */
  79. // #define NUMBER_OF_PRIORITIES 15
  80. #define NUMBER_OF_PRIORITIES 4
  81. #define LOWEST_DLCI_VALUE 16
  82. #define HIGHEST_DLCI_VALUE 991
  83. #define INVALID_LOGICAL_HANDLE 0
  84. /*
  85. ** Each DLCI has this structure associated with it.
  86. */
  87. typedef struct
  88. {
  89. BOOL link_originator;
  90. CLayerX224 *x224; // transport_layer
  91. CLayerQ922 *q922; // datalink_layer
  92. TransportPriority priority;
  93. BOOL disconnect_requested;
  94. BOOL connect_requested;
  95. PMemoryManager data_request_memory_manager;
  96. USHORT network_retries;
  97. }
  98. DLCIStruct, *PDLCIStruct;
  99. class T123
  100. {
  101. public:
  102. T123(TransportController *owner_object,
  103. USHORT message_base,
  104. BOOL link_originator,
  105. ComPort *physical_layer,
  106. PhysicalHandle physical_handle,
  107. PLUGXPRT_PARAMETERS *pParams,
  108. BOOL * t123_initialized);
  109. virtual ~T123(void);
  110. /*
  111. ** Functions related to making and breaking a linkg
  112. */
  113. TransportError ConnectRequest (
  114. LogicalHandle logical_handle,
  115. TransportPriority priority);
  116. TransportError ConnectResponse (
  117. LogicalHandle logical_handle);
  118. TransportError DisconnectRequest (
  119. LogicalHandle logical_handle,
  120. UINT_PTR trash_packets);
  121. TransportError DataRequest (
  122. LogicalHandle logical_handle,
  123. LPBYTE user_data,
  124. ULONG user_data_length);
  125. TransportError PurgeRequest (
  126. LogicalHandle logical_handle);
  127. void EnableReceiver (void);
  128. ULONG PollReceiver (void);
  129. void PollTransmitter (void);
  130. ULONG OwnerCallback(ULONG, void *p1 = NULL, void *p2 = NULL, void *p3 = NULL);
  131. private:
  132. void Reset (void);
  133. DLCI GetNextDLCI (void);
  134. void ProcessMessages (void);
  135. void NetworkDisconnectIndication (
  136. DLCI dlci,
  137. BOOL link_originator,
  138. BOOL retry);
  139. void DataLinkRelease (
  140. DLCI dlci,
  141. DataLinkDisconnectType error);
  142. void NewConnection (void);
  143. void NetworkConnectIndication (
  144. PNetworkConnectStruct connect_struct);
  145. void NetworkConnectConfirm (
  146. PNetworkConnectStruct connect_struct);
  147. void DataLinkEstablish (
  148. DLCI dlci);
  149. private:
  150. BOOL m_fValidSDKParams;
  151. PLUGXPRT_PARAMETERS m_SDKParams;
  152. DictionaryClass Logical_Connection_List;
  153. DictionaryClass DLCI_List;
  154. SListClass Message_List;
  155. SListClass DataLink_List;
  156. SListClass *Logical_Connection_Priority_List[NUMBER_OF_PRIORITIES];
  157. TransportController *m_pController;
  158. BOOL Link_Originator;
  159. USHORT m_nMsgBase;
  160. CLayerSCF *m_pSCF; // network layer
  161. CLayerQ922 *m_pQ922; // data link layer
  162. Multiplexer *m_pMultiplexer; // multiplexer layer
  163. ComPort *m_pComPort; // physical layer
  164. PhysicalHandle m_hCommLink;
  165. DataLinkParameters DataLink_Struct;
  166. PMemoryManager Data_Request_Memory_Manager;
  167. #ifdef USE_RANDOM_CLASS
  168. PRandomNumberGenerator Random;
  169. #endif
  170. BOOL Disconnect_Requested;
  171. };
  172. typedef T123 * PT123;
  173. #endif
  174. /*
  175. * Documentation for Public class members
  176. */
  177. /*
  178. * T123::T123 (
  179. * PTransportResources transport_resources,
  180. * IObject * owner_object,
  181. * USHORT message_base,
  182. * BOOL link_originator,
  183. * IProtocolLayer * physical_layer,
  184. * PhysicalHandle physical_handle,
  185. * BOOL * initialized);
  186. *
  187. * Functional Description
  188. * This is the constructor for the T123 class. It prepares for new
  189. * connections.
  190. *
  191. * Formal Parameters
  192. * transport_resources (i) - Address of resources structure.
  193. * owner_object (i) - Address of owner object. Used for owner
  194. * callbacks.
  195. * message_base (i) - Message base used with owner callbacks.
  196. * link_originator (i) - TRUE if we actually originated the
  197. * connection
  198. * physical_layer (i) - Pointer to physical layer
  199. * physical_handle (i) - Identifier that needs to be passed to the
  200. * physical layer to identify the connection
  201. * initialized (o) - TRUE if the object initialized OK.
  202. *
  203. * Return Value
  204. * None
  205. *
  206. * Side Effects
  207. * None
  208. *
  209. * Caveats
  210. * None
  211. */
  212. /*
  213. * T123::~T123 (void)
  214. *
  215. * Functional Description
  216. * This is the T123 destructor. It removes all active connections
  217. *
  218. * Formal Parameters
  219. * None
  220. *
  221. * Return Value
  222. * None
  223. *
  224. * Side Effects
  225. * None
  226. *
  227. * Caveats
  228. * None
  229. *
  230. */
  231. /*
  232. * TransportError T123::ConnectRequest (
  233. * LogicalHandle logical_handle
  234. * TransportPriority priority);
  235. *
  236. * Functional Description
  237. * This function initiates a logical connection.
  238. *
  239. * Formal Parameters
  240. * logical_handle (i) - Handle assocaiated with the
  241. * logical connection
  242. * priority (i) - Requested priority of the connection.
  243. *
  244. * Return Value
  245. * TRANSPORT_NO_ERROR - No Error
  246. *
  247. * Side Effects
  248. * None
  249. *
  250. * Caveats
  251. * None
  252. */
  253. /*
  254. * TransportError T123::ConnectResponse (
  255. * LogicalHandle logical_handle)
  256. *
  257. * Functional Description
  258. * This function is called in response to TRANSPORT_CONNECT_INDICATION
  259. * message that was sent the owner. By making this call, the owner is
  260. * accepting the connection.
  261. *
  262. * Formal Parameters
  263. * logical_handle (i) - Logical connection handle
  264. *
  265. * Return Value
  266. * TRANSPORT_NO_ERROR - No Error
  267. * TRANSPORT_CONNECT_RESPONSE_FAILURE - Function not valid
  268. *
  269. * Side Effects
  270. * None
  271. *
  272. * Caveats
  273. * None
  274. */
  275. /*
  276. * TransportError T123::DisconnectRequest (
  277. * LogicalHandle logical_handle,
  278. * BOOL trash_packets);
  279. *
  280. * Functional Description
  281. * This function terminates the transport connection. The user will
  282. * receive a TRANSPORT_DISCONNECT_INDICATION message when the connection
  283. * is terminated
  284. *
  285. * If the logical_handle equals INVALID_LOGICAL_HANDLE, the user is
  286. * telling us to take down all logical connections and ultimately the
  287. * physical connection.
  288. *
  289. * Formal Parameters
  290. * logical_handle - (i) Logical connection number to terminate
  291. * trash_packets - (i) BOOL , set to TRUE if we are to trash
  292. * the packets in the output buffer.
  293. *
  294. * Return Value
  295. * TRANSPORT_NO_ERROR - No Error
  296. * TRANSPORT_NO_SUCH_CONNECTION - Transport connection does not exist
  297. *
  298. * Side Effects
  299. * None
  300. *
  301. * Caveats
  302. * None
  303. */
  304. /*
  305. * TransportError T123::DataRequest (
  306. * LogicalHandle logical_handle,
  307. * LPBYTE user_data,
  308. * ULONG user_data_length);
  309. *
  310. * Functional Description
  311. * This function is used to send a data packet to the remote location.
  312. * We simply pass this packet to the X224 object associated with the
  313. * transport connection.
  314. *
  315. * Formal Parameters
  316. * logical_handle - (i) Transport connection number
  317. * user_data - (i) Address of data to send
  318. * user_data_length - (i) Length of data to send
  319. *
  320. * Return Value
  321. * TRANSPORT_NO_ERROR - No Error
  322. * TRANSPORT_NO_SUCH_CONNECTION - Logical connection does not exist
  323. * TRANSPORT_WRITE_QUEUE_FULL - Transport write queues are already
  324. * full.
  325. * TRANSPORT_NOT_READY_TO_TRANSMIT - The transport layer is in the
  326. * process of building or breaking
  327. * down the transport stack and is
  328. * not ready for user data.
  329. *
  330. * Side Effects
  331. * None
  332. *
  333. * Caveats
  334. * None
  335. */
  336. /*
  337. * TransportError T123::PurgeRequest (
  338. * LogicalHandle logical_handle)
  339. *
  340. * Functional Description
  341. * This function purges the outbound packets for the logical connection.
  342. *
  343. * Formal Parameters
  344. * logical_handle - (i) Transport connection number
  345. *
  346. * Return Value
  347. * TRANSPORT_NO_ERROR - No Error
  348. * TRANSPORT_NO_SUCH_CONNECTION - Logical connection does not exist
  349. *
  350. * Side Effects
  351. * None
  352. */
  353. /*
  354. * TransportError T123::EnableReceiver (void);
  355. *
  356. * Functional Description
  357. * This function is called to enable TRANSPORT_DATA_INDICATION callbacks
  358. * to the user application.
  359. *
  360. * Formal Parameters
  361. * None.
  362. *
  363. * Return Value
  364. * TRANSPORT_NO_ERROR - No Error
  365. *
  366. * Side Effects
  367. * None
  368. */
  369. /*
  370. * void T123::PollReceiver (void);
  371. *
  372. * Functional Description
  373. * This function gives the T123 stack a chance to receive packets from
  374. * the remote site. During this call, we may be making user callbacks to
  375. * pass the data on up.
  376. *
  377. * Formal Parameters
  378. * None.
  379. *
  380. * Return Value
  381. * None.
  382. *
  383. * Side Effects
  384. * None
  385. *
  386. * Caveats
  387. * None
  388. */
  389. /*
  390. * void T123::PollTransmitter (void);
  391. *
  392. * Functional Description
  393. * This function gives the T123 stack a chance to transmit data to the
  394. * remote site.
  395. *
  396. * Formal Parameters
  397. * None.
  398. *
  399. * Return Value
  400. * None.
  401. *
  402. * Side Effects
  403. * None
  404. *
  405. * Caveats
  406. * None
  407. */
  408. /*
  409. * ULONG T123::OwnerCallback (
  410. * USHORT layer_message,
  411. * ULONG parameter1,
  412. * ULONG parameter2,
  413. * PVoid parameter3);
  414. *
  415. * Functional Description
  416. * This function is the owner callback function. If any of the layers
  417. * owned by this object want to send us a message, they make an owner
  418. * callback. During instantiation of these lower layers, we pass them our
  419. * address. They can call us with significant messages.
  420. *
  421. * Formal Parameters
  422. * layer_message (i) - Layer-specific message
  423. * parameter1 (i) - Message-specific parameter
  424. * parameter2 (i) - Message-specific parameter
  425. * parameter3 (i) - Message-specific parameter
  426. *
  427. * Return Value
  428. * Message specific
  429. *
  430. * Side Effects
  431. * None
  432. *
  433. * Caveats
  434. * None
  435. */