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.

412 lines
13 KiB

  1. /* ProtocolLayer.h
  2. *
  3. * Copyright (c) 1994-1995 by DataBeam Corporation, Lexington, KY
  4. *
  5. * Abstract:
  6. * This is the base class and backbone of all of the layers
  7. * in a Transport Stack. This class provides a framework for the basic
  8. * operations expected by a layer in a stack. When all layers inherit
  9. * from this class, they can be linked together and none of the layers
  10. * needs to know who they are connected with.
  11. *
  12. * Caveats:
  13. * None.
  14. *
  15. * Authors:
  16. * James W. Lawwill
  17. */
  18. #ifndef _PROTOCOL_LAYER_H_
  19. #define _PROTOCOL_LAYER_H_
  20. typedef LEGACY_HANDLE LogicalHandle;
  21. typedef PHYSICAL_HANDLE PhysicalHandle; // hCommLink
  22. /*
  23. * TransportPriority is passed in with the TConnectRequest() call.
  24. * The user can set the priority of the logical connection. Valid
  25. * priorities are 0-14.
  26. */
  27. typedef ULONG TransportPriority;
  28. #define DEFAULT_PSTN_CALL_CONTROL PLUGXPRT_PSTN_CALL_CONTROL_PORT_HANDLE
  29. typedef enum
  30. {
  31. PROTOCOL_LAYER_NO_ERROR,
  32. PROTOCOL_LAYER_REGISTRATION_ERROR,
  33. PROTOCOL_LAYER_PACKET_TOO_BIG,
  34. PROTOCOL_LAYER_ERROR
  35. }
  36. ProtocolLayerError;
  37. /*
  38. ** Message structure used by some classes to hold owner callback
  39. ** messages. Sometimes they are processed at later times
  40. */
  41. typedef struct
  42. {
  43. ULONG message;
  44. void *parameter1;
  45. void *parameter2;
  46. void *parameter3;
  47. }
  48. MessageStruct, * PMessageStruct;
  49. /*
  50. ** These values make up the data-to-transmit mask. We need a way to
  51. ** let the layers know what type of data they can transmit. The controller
  52. ** will pass a mask to the layer during the PollTransmitter() call that tells
  53. ** the layer if it can transmit CONTROL data, USER data, or both. The layer
  54. ** will return a mask telling the controller if it needs to send more
  55. ** CONTROL or USER data. It will also tell the controller if it sent any
  56. ** data during the call.
  57. */
  58. #define PROTOCOL_CONTROL_DATA 0x01
  59. #define PROTOCOL_USER_DATA 0x02
  60. #define PROTOCOL_USER_DATA_ONE_PACKET 0x04
  61. #define PROTOCOL_USER_DATA_TRANSMITTED 0x08
  62. #define DEFAULT_PRIORITY 2
  63. /*
  64. ** Messages passed in owner callbacks
  65. */
  66. typedef enum
  67. {
  68. NEW_CONNECTION,
  69. BROKEN_CONNECTION,
  70. REQUEST_TRANSPORT_CONNECTION,
  71. TPRT_CONNECT_INDICATION,
  72. TPRT_CONNECT_CONFIRM,
  73. TPRT_DISCONNECT_REQUEST,
  74. TPRT_DISCONNECT_INDICATION,
  75. NETWORK_CONNECT_INDICATION,
  76. NETWORK_CONNECT_CONFIRM,
  77. NETWORK_DISCONNECT_INDICATION,
  78. DATALINK_ESTABLISH_INDICATION,
  79. DATALINK_ESTABLISH_CONFIRM,
  80. DATALINK_RELEASE_INDICATION,
  81. DATALINK_RELEASE_CONFIRM,
  82. T123_FATAL_ERROR,
  83. T123_STATUS_MESSAGE
  84. }
  85. CallbackMessage;
  86. class IProtocolLayer : public IObject
  87. {
  88. public:
  89. virtual ProtocolLayerError DataRequest (
  90. ULONG_PTR identifier,
  91. LPBYTE buffer_address,
  92. ULONG length,
  93. PULong bytes_accepted) = 0;
  94. virtual ProtocolLayerError DataRequest (
  95. ULONG_PTR identifier,
  96. PMemory memory,
  97. PULong bytes_accepted) = 0;
  98. virtual ProtocolLayerError DataIndication (
  99. LPBYTE buffer_address,
  100. ULONG length,
  101. PULong bytes_accepted) = 0;
  102. virtual ProtocolLayerError RegisterHigherLayer (
  103. ULONG_PTR identifier,
  104. PMemoryManager memory_manager,
  105. IProtocolLayer * higher_layer) = 0;
  106. virtual ProtocolLayerError RemoveHigherLayer (
  107. ULONG_PTR identifier) = 0;
  108. virtual ProtocolLayerError PollTransmitter (
  109. ULONG_PTR identifier,
  110. USHORT data_to_transmit,
  111. USHORT * pending_data,
  112. USHORT * holding_data) = 0;
  113. virtual ProtocolLayerError PollReceiver (void) = 0;
  114. virtual ProtocolLayerError GetParameters (
  115. USHORT * max_packet_size,
  116. USHORT * prepend_bytes,
  117. USHORT * append_bytes) = 0;
  118. virtual BOOL PerformAutomaticDisconnect ()
  119. {
  120. return (TRUE);
  121. };
  122. };
  123. #endif
  124. /*
  125. * Documentation for Public class members
  126. */
  127. /*
  128. * ProtocolLayerError ProtocolLayer::DataRequest (
  129. * USHORT identifier,
  130. * LPBYTE buffer_address,
  131. * USHORT length,
  132. * USHORT * bytes_accepted) = 0;
  133. *
  134. * Functional Description
  135. * This function is called by a higher layer to request data to be
  136. * sent out. The function returns the number of bytes accepted from
  137. * the packet. If the layer expects stream data layer, it can accept
  138. * part of the packet. If it is a packet layer, it MUST accept the
  139. * full packet of none of the packet.
  140. *
  141. * Formal Parameters
  142. * identifier - (i) The identifying value of the higher layer
  143. * buffer_address - (i) Address of the packet.
  144. * length - (i) Length of the packet
  145. * bytes_accepted - (o) Number of bytes accepted by the layer.
  146. *
  147. * Return Value
  148. * PROTOCOL_LAYER_NO_ERROR - No error occured
  149. * PROTOCOL_LAYER_ERROR - Generic error
  150. * PROTOCOL_LAYER_PACKET_TOO_BIG - Packet too big
  151. *
  152. * Side Effects
  153. * None
  154. *
  155. * Caveats
  156. * None
  157. */
  158. /*
  159. * ProtocolLayerError ProtocolLayer::DataRequest (
  160. * USHORT identifier,
  161. * PMemory memory,
  162. * PULong bytes_accepted) = 0;
  163. *
  164. * Functional Description
  165. * This function is called by a higher layer to request data to be
  166. * sent out. The function returns the number of bytes accepted from
  167. * the packet. If the layer expects stream data layer, it can accept
  168. * part of the packet. If it is a packet layer, it MUST accept the
  169. * full packet of none of the packet. This function does not accept a
  170. * buffer address, but it accepts a memory object. This object holds the
  171. * buffer address and the length.
  172. *
  173. * Formal Parameters
  174. * identifier - (i) The identifying value of the higher layer
  175. * memory - (i) Address of memory object
  176. * bytes_accepted - (o) Number of bytes accepted by the layer.
  177. *
  178. * Return Value
  179. * PROTOCOL_LAYER_NO_ERROR - No error occured
  180. * PROTOCOL_LAYER_ERROR - Generic error
  181. * PROTOCOL_LAYER_PACKET_TOO_BIG - Packet too big
  182. *
  183. * Side Effects
  184. * None
  185. *
  186. * Caveats
  187. * None
  188. */
  189. /*
  190. * ProtocolLayerError ProtocolLayer::DataIndication (
  191. * LPBYTE buffer_address,
  192. * USHORT length,
  193. * USHORT * bytes_accepted);
  194. *
  195. * Functional Description
  196. * This function is called by the lower layer when it has data to pass up
  197. *
  198. * Formal Parameters
  199. * buffer_address (i) - Buffer address
  200. * length (i) - Number of bytes available
  201. * bytes_accepted (o) - Number of bytes accepted
  202. *
  203. * Return Value
  204. * PROTOCOL_LAYER_NO_ERROR - No error occured
  205. *
  206. * Side Effects
  207. * None
  208. *
  209. * Caveats
  210. * None
  211. *
  212. */
  213. /*
  214. * ProtocolLayerError ProtocolLayer::RegisterHigherLayer (
  215. * USHORT identifier,
  216. * IProtocolLayer * higher_layer);
  217. *
  218. * Functional Description
  219. * This function is called by the higher layer to register its identifier
  220. * and its address. In some cases, the identifier is the DLCI number in
  221. * the packet.
  222. *
  223. * Formal Parameters
  224. * identifier (i) - Identifier used to identify the higher layer
  225. * higher_layer (i) - Address of higher layer
  226. *
  227. * Return Value
  228. * PROTOCOL_LAYER_NO_ERROR - No error occured
  229. * PROTOCOL_LAYER_REGISTRATION_ERROR - Illegal identifier
  230. *
  231. * Side Effects
  232. * None
  233. *
  234. * Caveats
  235. * None
  236. *
  237. */
  238. /*
  239. * ProtocolLayerError ProtocollLayer::RemoveHigherLayer (
  240. * USHORT identifier);
  241. *
  242. * Functional Description
  243. * This function is called by the higher layer to remove the higher layer.
  244. * If any more data is received with its identifier on it, it will be
  245. * trashed.
  246. *
  247. * Formal Parameters
  248. * identifier (i) - Identifier used to identify the higher layer
  249. *
  250. * Return Value
  251. * PROTOCOL_LAYER_NO_ERROR - No error occured
  252. * PROTOCOL_LAYER_REGISTRATION_ERROR - Illegal identifier
  253. *
  254. * Side Effects
  255. * None
  256. *
  257. * Caveats
  258. * None
  259. *
  260. */
  261. /*
  262. * ProtocolLayerError ProtocolLayer::PollTransmitter (
  263. * USHORT identifier,
  264. * USHORT data_to_transmit,
  265. * USHORT * pending_data);
  266. *
  267. * Functional Description
  268. * This function is called to give the layer a chance transmit data
  269. * in its Data_Request buffer.
  270. *
  271. * Formal Parameters
  272. * identifier (i) - Identifier to poll
  273. * data_to_transmit (i) - This is a mask that tells us to send Control
  274. * data, User data, or both. Since the
  275. * Multiplexer does not differentiate between
  276. * data types it transmits any data it has
  277. * pending_data (o) - Return value to indicat which data is left
  278. * to be transmitted.
  279. *
  280. * Return Value
  281. * PROTOCOL_LAYER_NO_ERROR - No error occured
  282. *
  283. * Side Effects
  284. * None
  285. *
  286. * Caveats
  287. * None
  288. *
  289. */
  290. /*
  291. * ProtocolLayerError ProtocolLayer::PollReceiver (
  292. * USHORT identifier);
  293. *
  294. * Functional Description
  295. * This function is called to give the layer a chance pass packets
  296. * to higher layers
  297. *
  298. * Formal Parameters
  299. * identifier (i) - Not used
  300. *
  301. * Return Value
  302. * PROTOCOL_LAYER_NO_ERROR - No error occured
  303. *
  304. * Side Effects
  305. * None
  306. *
  307. * Caveats
  308. * None
  309. *
  310. */
  311. /*
  312. * ProtocolLayerError ProtocolLayer::GetParameters (
  313. * USHORT identifier,
  314. * USHORT * max_packet_size);
  315. *
  316. * Functional Description
  317. * This function is called to get the maximum packet size
  318. *
  319. * Formal Parameters
  320. * identifier (i) - Not used
  321. * max_packet_size (o) - Returns the maximum packet size
  322. *
  323. * Return Value
  324. * PROTOCOL_LAYER_NO_ERROR - No error occured
  325. *
  326. * Side Effects
  327. * None
  328. *
  329. * Caveats
  330. * None
  331. *
  332. */
  333. /*
  334. * BOOL ProtocolLayer::PerformAutomaticDisconnect (
  335. * void)
  336. *
  337. * Public
  338. *
  339. * Functional Description:
  340. * This function can be used to avoid taking down DLCI0 when the number
  341. * of logical connections handled by a particular stack goes to zero.
  342. * This is a temporary fix that will probably change when the physical
  343. * connection buildup process is handled out of band.
  344. *
  345. * Formal Parameters
  346. * none
  347. *
  348. * Return Value
  349. * TRUE - The base class always returns TRUE. This is the default way
  350. * for a physical connection layer to work.
  351. *
  352. * Side Effects
  353. * None
  354. *
  355. * Caveats
  356. * None
  357. */
  358. /*
  359. * PChar ProtocolLayer::GetIdentifier (
  360. * void)
  361. *
  362. * Public
  363. *
  364. * Functional Description:
  365. * This function returns the identifier for the protocol layer. If the
  366. * layer does not override this call a NULL pointer will be returned.
  367. *
  368. * Formal Parameters
  369. * none
  370. *
  371. * Return Value
  372. * A pointer to the identifier of the protocol layer.
  373. *
  374. * Side Effects
  375. * None
  376. *
  377. * Caveats
  378. * None
  379. */
  380.