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.

595 lines
18 KiB

  1. /* SCF.h
  2. *
  3. * Copyright (c) 1994-1995 by DataBeam Corporation, Lexington, KY
  4. *
  5. * Abstract:
  6. * This class represents the Network layer in the T.123 Transport stack.
  7. * This layer communicates over the DataLink layer (DLCI 0). It sends the
  8. * necessary packets to start a connection. It is also responsible for
  9. * disconnecting the connection.
  10. *
  11. * During arbitration of a connection, SCF arbitrates priority and DataLink
  12. * parameters. SCF instantiates a SCFCall object for each active logical
  13. * connection. Remotely initiated calls are placed in the
  14. * Remote_Call_Reference array while locally initiated calls are kept in
  15. * the Call_Reference array.
  16. *
  17. * This class inherits from ProtocolLayer although it assumes that it does
  18. * not have a higher layer to pass packets to. The T.123 document is clear
  19. * about that during the user data transmission, this layer has no purpose.
  20. *
  21. * Caveats:
  22. * None.
  23. *
  24. * Authors:
  25. * James W. Lawwill
  26. */
  27. #ifndef _SCF_H_
  28. #define _SCF_H_
  29. #include "q922.h"
  30. #include "scfcall.h"
  31. /*
  32. ** SCF Errors
  33. */
  34. typedef enum
  35. {
  36. SCF_NO_ERROR,
  37. SCF_NO_SUCH_DLCI,
  38. SCF_CONNECTION_FULL,
  39. SCF_MEMORY_ALLOCATION_ERROR
  40. }
  41. SCFError;
  42. #define TRANSPORT_HASHING_BUCKETS 3
  43. /*
  44. ** Offsets into packet
  45. */
  46. #define PROTOCOL_DISCRIMINATOR 0
  47. #define LENGTH_CALL_REFERENCE 1
  48. #define CALL_REFERENCE_VALUE 2
  49. /*
  50. ** Supported commands
  51. */
  52. #define NO_PACKET 0x00
  53. #define CONNECT 0x07
  54. #define CONNECT_ACKNOWLEDGE 0x0f
  55. #define SETUP 0x05
  56. #define RELEASE_COMPLETE 0x5a
  57. /*
  58. ** Unsupported commands as stated by T.123
  59. */
  60. #define RELEASE 0x4d
  61. #define ALERTING 0x01
  62. #define CALL_PROCEEDING 0x02
  63. #define PROGRESS 0x03
  64. #define DISCONNECT 0x45
  65. #define SEGMENT 0x40
  66. #define STATUS 0x5d
  67. #define STATUS_ENQUIRY 0x55
  68. /*
  69. ** Packet Elements, not all of these are supported.
  70. */
  71. #define BEARER_CAPABILITY 0x04
  72. #define DLCI_ELEMENT 0x19
  73. #define END_TO_END_DELAY 0x42
  74. #define LINK_LAYER_CORE_PARAMETERS 0x48
  75. #define LINK_LAYER_PROTOCOL_PARAMETERS 0x49
  76. #define X213_PRIORITY 0x50
  77. #define CALLING_PARTY_SUBADDRESS 0x6d
  78. #define CALLED_PARTY_SUBADDRESS 0x71
  79. #define CAUSE 0x08
  80. #define EXTENSION 0x80
  81. /*
  82. ** Remote Call Reference
  83. */
  84. #define REMOTE_CALL_REFERENCE 0x80
  85. /*
  86. ** Bearer Capability definitions
  87. */
  88. #define CODING_STANDARD 0
  89. #define INFORMATION_TRANSFER_CAPABILITY 0x08
  90. #define TRANSFER_MODE 0x20
  91. #define LAYER_2_IDENT 0x40
  92. #define USER_INFORMATION_LAYER_2 0x0e
  93. /*
  94. ** DLCI element
  95. */
  96. #define PREFERRED_EXCLUSIVE 0x40
  97. /*
  98. ** Link Layer Core Parameters
  99. */
  100. #define FMIF_SIZE 0x09
  101. #define THROUGHPUT 0x0a
  102. #define MINIMUM_THROUGHPUT 0x0b
  103. #define COMMITTED_BURST_SIZE 0x0d
  104. #define EXCESS_BURST_SIZE 0x0e
  105. /*
  106. ** Link Layer Protocol Parameters
  107. */
  108. #define TRANSMIT_WINDOW_SIZE_IDENTIFIER 0x07
  109. #define RETRANSMISSION_TIMER_IDENTIFIER 0x09
  110. /*
  111. ** Q.850 Error messages, these are the only 2 errors we currently support
  112. */
  113. #define REQUESTED_CHANNEL_UNAVAILABLE 0x2c
  114. #define NORMAL_USER_DISCONNECT 0x1f
  115. /*
  116. ** Single Octet information elements
  117. */
  118. #define SINGLE_OCTET_ELEMENT_MASK 0x80
  119. #define Q931_PROTOCOL_DISCRIMINATOR 0x08
  120. #define CALL_REFERENCE_ORIGINATOR 0x80
  121. #define CALL_ORIGINATOR_MASK 0x7f
  122. /*
  123. ** T303 is the timeout allowed from the time we send the SETUP until we receive
  124. ** a response
  125. */
  126. #define DEFAULT_T303_TIMEOUT 30000
  127. /*
  128. ** T313 is the timeout allowed from the time we send the CONNECT until we
  129. ** receive a response
  130. */
  131. #define DEFAULT_T313_TIMEOUT 30000
  132. class CLayerSCF : public IProtocolLayer
  133. {
  134. public:
  135. CLayerSCF(
  136. T123 *owner_object,
  137. CLayerQ922 *lower_layer,
  138. USHORT message_base,
  139. USHORT identifier,
  140. BOOL link_originator,
  141. PDataLinkParameters datalink,
  142. PMemoryManager memory_manager,
  143. BOOL * initialized);
  144. virtual ~CLayerSCF(void);
  145. SCFError ConnectRequest (
  146. DLCI dlci,
  147. TransportPriority priority);
  148. SCFError DisconnectRequest (
  149. DLCI dlci);
  150. SCFError ConnectResponse (
  151. CallReference call_reference,
  152. DLCI dlci,
  153. BOOL valid_dlci);
  154. /*
  155. ** Functions overridden from the ProtocolLayer object
  156. */
  157. ProtocolLayerError DataRequest (
  158. ULONG_PTR identifier,
  159. LPBYTE buffer_address,
  160. ULONG length,
  161. PULong bytes_accepted);
  162. ProtocolLayerError DataRequest (
  163. ULONG_PTR identifier,
  164. PMemory memory,
  165. PULong bytes_accepted);
  166. ProtocolLayerError DataIndication (
  167. LPBYTE buffer_address,
  168. ULONG length,
  169. PULong bytes_accepted);
  170. ProtocolLayerError RegisterHigherLayer (
  171. ULONG_PTR identifier,
  172. PMemoryManager dr_memory_manager,
  173. IProtocolLayer * higher_layer);
  174. ProtocolLayerError RemoveHigherLayer (
  175. ULONG_PTR identifier);
  176. ProtocolLayerError PollTransmitter (
  177. ULONG_PTR identifier,
  178. USHORT data_to_transmit,
  179. USHORT * pending_data,
  180. USHORT * holding_data);
  181. ProtocolLayerError PollReceiver(void);
  182. ProtocolLayerError GetParameters (
  183. USHORT * max_packet_size,
  184. USHORT * prepend,
  185. USHORT * append);
  186. ULONG OwnerCallback(ULONG, void *p1 = NULL, void *p2 = NULL, void *p3 = NULL);
  187. private:
  188. CallReference GetNextCallReference (void);
  189. void ProcessMessages (void);
  190. private:
  191. DictionaryClass Remote_Call_Reference;
  192. DictionaryClass Call_Reference;
  193. DictionaryClass DLCI_List;
  194. SListClass Message_List;
  195. T123 *m_pT123; // owner object
  196. CLayerQ922 *m_pQ922; // lower layer
  197. USHORT m_nMsgBase;
  198. USHORT Identifier;
  199. USHORT Link_Originator;
  200. USHORT Maximum_Packet_Size;
  201. DataLinkParameters DataLink_Struct;
  202. PMemoryManager Data_Request_Memory_Manager;
  203. USHORT Lower_Layer_Prepend;
  204. USHORT Lower_Layer_Append;
  205. USHORT Call_Reference_Base;
  206. };
  207. typedef CLayerSCF * PSCF;
  208. #endif
  209. /*
  210. * Documentation for Public class members
  211. */
  212. /*
  213. * CLayerSCF::CLayerSCF (
  214. * PTransportResources transport_resources,
  215. * IObject * owner_object,
  216. * IProtocolLayer * lower_layer,
  217. * USHORT message_base,
  218. * USHORT identifier,
  219. * BOOL link_originator,
  220. * PChar config_file,
  221. * PDataLinkParameters datalink,
  222. * PMemoryManager memory_manager,
  223. * BOOL * initialized);
  224. *
  225. * Functional Description
  226. * This is the constructor for the SCF Network layer. It registers itself
  227. * with the lower so that incoming data will be received properly.
  228. *
  229. * Formal Parameters
  230. * transport_resources (i) - Pointer to TransportResources structure.
  231. * owner_object (i) - Address of the object that owns this object
  232. * lower_layer (i) - Address of the layer below us.
  233. * message_base (i) - Message base used in owner callbacks.
  234. * identifier (i) - This objects identification number. Passed to
  235. * lower layer to identify us (DLCI 0).
  236. * link_originator (i) - BOOL, TRUE if we started the link
  237. * config_file (i) - Address of the configuration path string
  238. * datalink (i) - Address structure holding the DataLink
  239. * arbitratable parameters.
  240. * memory_manager (i) - Address of the memory manager
  241. * initialized (o) - Address of BOOL, we set it to TRUE if it
  242. * worked
  243. *
  244. * Return Value
  245. * None
  246. *
  247. * Side Effects
  248. * None
  249. *
  250. * Caveats
  251. * None
  252. *
  253. */
  254. /*
  255. * CLayerSCF::~CLayerSCF (void);
  256. *
  257. * Functional Description
  258. * This is the destructor for the SCF Network layer. We do our
  259. * cleanup in here
  260. *
  261. * Formal Parameters
  262. * None
  263. *
  264. * Return Value
  265. * None
  266. *
  267. * Side Effects
  268. * None
  269. *
  270. * Caveats
  271. * None
  272. */
  273. /*
  274. * SCFError CLayerSCF::ConnectRequest (
  275. * DLCI dlci,
  276. * USHORT priority)
  277. *
  278. * Functional Description
  279. * This function initiates a connection with the remote site. As a result,
  280. * we will create a SCFCall and tell it to initiate a connection.
  281. *
  282. * Formal Parameters
  283. * dlci (i) - Proposed DLCI for the connection
  284. * priority (i) - Proposed priority for the connection
  285. *
  286. * Return Value
  287. * SCF_NO_ERROR - No erroro occured
  288. *
  289. * Side Effects
  290. * None
  291. *
  292. * Caveats
  293. * None
  294. *
  295. */
  296. /*
  297. * SCFError CLayerSCF::DisconnectRequest (
  298. * DLCI dlci);
  299. *
  300. * Functional Description
  301. * This function starts the disconnect process.
  302. *
  303. * Formal Parameters
  304. * dlci (i) - DLCI to disconnect.
  305. *
  306. * Return Value
  307. * SCF_NO_ERROR - No error occured
  308. * SCF_NO_SUCH_DLCI - Invalid DLCI
  309. *
  310. * Side Effects
  311. * None
  312. *
  313. * Caveats
  314. * None
  315. *
  316. */
  317. /*
  318. * SCFError CLayerSCF::ConnectResponse (
  319. * CallReference call_reference,
  320. * DLCI dlci,
  321. * BOOL valid_dlci);
  322. *
  323. * Functional Description
  324. * This function is called by a higher layer to confirm a connection. If
  325. * the remote site initiates a connection with us, we issue a
  326. * NETWORK_CONNECT_INDICATION to the owner object. It responds with this
  327. * call to confirm or deny the suggested dlci.
  328. *
  329. * Formal Parameters
  330. * call_reference (i) - Call reference ID, passed to owner in
  331. * NETWORK_CONNECT_INDICATION
  332. * dlci (i) - Referenced DLCI
  333. * valid_dlci (i) - TRUE if the requested DLCI is valid
  334. *
  335. * Return Value
  336. * SCF_NO_ERROR - No error occured
  337. *
  338. * Side Effects
  339. * None
  340. *
  341. * Caveats
  342. * None
  343. *
  344. */
  345. /*
  346. * ProtocolLayerError CLayerSCF::DataRequest (
  347. * ULONG identifier,
  348. * LPBYTE buffer_address,
  349. * USHORT length,
  350. * USHORT * bytes_accepted);
  351. *
  352. * Functional Description
  353. * This function is called by a higher layer to request transmission of
  354. * a packet. For the SCF, this functio is not used
  355. *
  356. * Formal Parameters
  357. * identifier (i) - Identifier of the higher layer
  358. * buffer_address (i) - Buffer address
  359. * length (i) - Length of packet to transmit
  360. * bytes_accepted (o) - Number of bytes accepted by the Multiplexer.
  361. * This value will either be 0 or the packet
  362. * length since this layer is a packet to byte
  363. * converter.
  364. *
  365. * Return Value
  366. * PROTOCOL_LAYER_ERROR
  367. *
  368. * Side Effects
  369. * None
  370. *
  371. * Caveats
  372. * None
  373. *
  374. */
  375. /*
  376. * ProtocolLayerError CLayerSCF::DataRequest (
  377. * ULONG,
  378. * PMemory,
  379. * USHORT *)
  380. *
  381. * Functional Description
  382. * This function is not used.
  383. *
  384. * Formal Parameters
  385. * No parameters used
  386. *
  387. * Return Value
  388. * PROTOCOL_LAYER_ERROR
  389. *
  390. * Side Effects
  391. * None
  392. *
  393. * Caveats
  394. * None
  395. *
  396. */
  397. /*
  398. * ProtocolLayerError Multiplexer::DataIndication (
  399. * LPBYTE buffer_address,
  400. * USHORT length,
  401. * USHORT * bytes_accepted);
  402. *
  403. * Functional Description
  404. * This function is called by the lower layer when it has data to pass up
  405. *
  406. * Formal Parameters
  407. * buffer_address (i) - Buffer address
  408. * length (i) - Number of bytes available
  409. * bytes_accepted (o) - Number of bytes accepted
  410. *
  411. * Return Value
  412. * PROTOCOL_LAYER_NO_ERROR - No error occured
  413. *
  414. * Side Effects
  415. * None
  416. *
  417. * Caveats
  418. * None
  419. *
  420. */
  421. /*
  422. * ProtocolLayerError CLayerSCF::RegisterHigherLayer (
  423. * ULONG identifier,
  424. * IProtocolLayer * higher_layer);
  425. *
  426. * Functional Description
  427. * This function is called by the higher layer to register its identifier
  428. * and its address. In some cases, the identifier is the DLCI number in
  429. * the packet. If this multiplexer is being used as a stream to packet
  430. * converter only, the identifer is not used and all data is passed to the
  431. * higher layer. This is a NULL function by SCF
  432. *
  433. * Formal Parameters
  434. * identifier (i) - Identifier used to identify the higher layer
  435. * higher_layer (i) - Address of higher layer
  436. *
  437. * Return Value
  438. * PROTOCOL_LAYER_NO_ERROR - No higher layer allowed
  439. *
  440. * Side Effects
  441. * None
  442. *
  443. * Caveats
  444. * None
  445. *
  446. */
  447. /*
  448. * ProtocolLayerError CLayerSCF::RemoveHigherLayer (
  449. * ULONG identifier);
  450. *
  451. * Functional Description
  452. * This function is called by the higher layer to remove the higher layer.
  453. * If any more data is received with its identifier on it, it will be
  454. * trashed. This is a NULL function for SCF
  455. *
  456. * Formal Parameters
  457. * identifier (i) - Identifier used to identify the higher layer
  458. *
  459. * Return Value
  460. * PROTOCOL_LAYER_REGISTRATION_ERROR - No higher layer allowed
  461. *
  462. * Side Effects
  463. * None
  464. *
  465. * Caveats
  466. * None
  467. *
  468. */
  469. /*
  470. * ProtocolLayerError CLayerSCF::PollTransmitter (
  471. * ULONG identifier,
  472. * USHORT data_to_transmit,
  473. * USHORT * pending_data,
  474. * USHORT * holding_data);
  475. *
  476. * Functional Description
  477. * This function is called to give SCF a chance transmit data
  478. * in its Data_Request buffer.
  479. *
  480. * Formal Parameters
  481. * identifier (i) - Not used
  482. * data_to_transmit (i) - This is a mask that tells us to send Control
  483. * data, User data, or both. Since the
  484. * SCF does not differentiate between
  485. * data types it transmits any data it has
  486. * pending_data (o) - Return value to indicat which data is left
  487. * to be transmitted.
  488. *
  489. * Return Value
  490. * PROTOCOL_LAYER_NO_ERROR - No error occured
  491. *
  492. * Side Effects
  493. * None
  494. *
  495. * Caveats
  496. * None
  497. *
  498. */
  499. /*
  500. * ProtocolLayerError CLayerSCF::PollReceiver (
  501. * ULONG identifier);
  502. *
  503. * Functional Description
  504. * This function is called to give SCF a chance pass packets
  505. * to higher layers. It is not used in SCF.
  506. *
  507. * Formal Parameters
  508. * identifier (i) - Not used
  509. *
  510. * Return Value
  511. * PROTOCOL_LAYER_NO_ERROR - No error occured
  512. *
  513. * Side Effects
  514. * None
  515. *
  516. * Caveats
  517. * None
  518. *
  519. */
  520. /*
  521. * ProtocolLayerError CLayerSCF::GetParameters (
  522. * ULONG identifier,
  523. * USHORT * max_packet_size,
  524. * USHORT * prepend,
  525. * USHORT * append);
  526. *
  527. * Functional Description
  528. * This function is called to get the maximum packet size. This function
  529. * is not used in SCF. It is here because we inherit from ProtocolLayer
  530. * and this is a pure virtual function in that class.
  531. *
  532. * Formal Parameters
  533. * identifier (i) - Not used
  534. * max_packet_size (o) - Returns the maximum packet size
  535. * prepend (o) - Number of bytes prepended to a packet
  536. * append (o) - Number of bytes appended to a packet
  537. *
  538. * Return Value
  539. * PROTOCOL_LAYER_REGISTRATION_ERROR - Function can not be called
  540. *
  541. * Side Effects
  542. * None
  543. *
  544. * Caveats
  545. * None
  546. *
  547. */
  548.