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.

4948 lines
149 KiB

  1. #include "precomp.h"
  2. DEBUG_FILEZONE(ZONE_T120_MCSNC);
  3. /*
  4. * connect.cpp
  5. *
  6. * Copyright (c) 1993 - 1995 by DataBeam Corporation, Lexington, KY
  7. *
  8. * Abstract:
  9. * This is the implementation file for class Connection. It contains
  10. * all code necessary to encode MCS commands as T.125 PDUs, and to
  11. * decode T.125 back into MCS commands.
  12. *
  13. * The primary responsibility of this class is to act as a Remote
  14. * Procedure Call facility for MCS commands. A CommandTarget object
  15. * uses a Connection object to encode an MCS command as a PDU, and send it
  16. * across to a remote Connection object. That Connection object will
  17. * decode the PDU back into an MCS command, at which time it will send
  18. * it to the attached CommandTarget object on that side. The intervening
  19. * transport layer is transparent to the CommandTargets utilizing
  20. * Connection class services.
  21. *
  22. * A secondary responsibility of this class is to provide a layer of
  23. * flow control between the attached CommandTarget object and the
  24. * transport layer. PDUs are queued until the transport layer can take
  25. * them.
  26. *
  27. * Private Instance Variables:
  28. * Encoding_Rules
  29. * This is a variable which holds a value indicating what type of
  30. * rules (Basic or Packed) are used for encoding and decoding the PDUs.
  31. * m_pDomain
  32. * This is a pointer to the domain to which this connection is bound.
  33. * m_pPendingDomain
  34. * This is a pointer to the domain to which this connection will be
  35. * bound upon successful completion of the connection process.
  36. * Connection_Handle
  37. * This is the handle for the current transport connection. It allows
  38. * callback functions to be associated with the current transport
  39. * connection so that any events which occur on this transport
  40. * connection will be routed to any object that has registered its
  41. * callbacks.
  42. * m_pszCalledAddress
  43. * The transport address of the party being called.
  44. * Upward_Connection
  45. * This is a boolean flag which indicates whether or not this is
  46. * an upward connection.
  47. * Domain_Parameters
  48. * This is a structure which holds the set of domain parameters
  49. * associated with this connection.
  50. * Connect_Response_Memory
  51. * This is a pointer to a memory object which is used to hold any
  52. * user data contained within a ConnectResponse PDU.
  53. * Merge_In_Progress
  54. * This is a boolean flag that indicates whether or not the attached
  55. * Domain object is in the merge state. When in the merge state it
  56. * is invalid to send it any MCS commands.
  57. * Domain_Traffic_Allowed
  58. * This is a boolean flag used to indicate when this connection object
  59. * has been successfully created and bound to the domain, thus allowing
  60. * PDU traffic to commence.
  61. * Connect_Provider_Confirm_Pending
  62. * This is a boolean flag used to dictate the behavior if this
  63. * connection becomes invalid. If a connect provider confirm is
  64. * pending when the connection becomes invalid, then a failed confirm
  65. * is issued to the controller. If there is not a confirm pending,
  66. * then we simply issue a delete connection to the controller.
  67. * Transport_Connection
  68. * This is an array used to hold handles for the transport connections
  69. * available for use by this connection object. There is a transport
  70. * connection associated with each of the four data priorities.
  71. * Transport_Connection_PDU_Type
  72. * This is an array which holds values indicating what type of PDU
  73. * (Connect or Domain) is expected for each priority level.
  74. * Transport_Connection_State
  75. * This is an array which holds values indicating the state of the
  76. * transport connection associated with each prioriy level.
  77. * Transport_Connection_Count
  78. * This is a counter which keeps track of the number of transport
  79. * connections.
  80. * m_OutPktQueue
  81. * This is a queue used to hold data units to be transmitted.
  82. *
  83. * Private Member Functions:
  84. * ConnectInitial
  85. * This routine is called by the domain when a connection is being
  86. * created. It places the necessary domain information into a data
  87. * packet and queues the data to be transmitted through the transport
  88. * interface.
  89. * ConnectResponse
  90. * This routine is called when issuing a response to a
  91. * "ConnectInitial" PDU. The result of the attempted connection, the
  92. * connection ID, the domain parameters, and any user data are all put
  93. * into the packet and queued for transmission through the transport
  94. * interface. If the result of the attempted connection is negative,
  95. * the controller and transport interface are notified.
  96. * ConnectAdditional
  97. * This routine is called after successfully processing a
  98. * "ConnectResponse" PDU in order to create any addition necessary
  99. * transport connections.
  100. * ConnectResult
  101. * This routine is called indirectly when issuing a positive response
  102. * to a "ConnectAdditional" PDU. The "ConnectAdditional" PDUs are
  103. * processed by the controller and therefore any negative
  104. * "ConnectResult" PDU will be issued by the controller.
  105. * ProcessConnectResponse
  106. * This routine processes "Connect Response" PDU's coming from the
  107. * transport interface. Domain parameters are retrieved and the
  108. * PDU sent on to the proper domain.
  109. * ProcessConnectResult
  110. * This routine processes "Connect Result" PDU's coming from the
  111. * transport interface. For successful "Connect Result" PDU's this
  112. * connection is bound to the domain and a positive Connect Provider
  113. * Confirm issued to the controller. If unsuccessful, a negative
  114. * Connect Provider Confirm is issued to the controller.
  115. * IssueConnectProviderConfirm
  116. * This routine is called in order to send a "Connect Provider Confirm"
  117. * to the controller through a callback.
  118. * DestroyConnection
  119. * This routine is called in order to delete this connection because it
  120. * has become invalid. This is done by issuing a failed confirm to the
  121. * controller or, if no confirm is pending, by issuing a delete
  122. * connection to the controller.
  123. * AssignRemainingTransportConnections
  124. * This routine is called when there are no more transport connections
  125. * to create in order to copy the lowest priority transport connection
  126. * into all unassigned priorities.
  127. * CreateTransportConnection
  128. * This routine is called in order to create new transport connections.
  129. * AcceptTransportConnection
  130. * This routine is called in order to register this connection object
  131. * with the transport interface.
  132. * AdjustDomainParameters
  133. * This routine is called in order to adjust the domain parameters so
  134. * that they fall within the allowable range.
  135. * MergeDomainParameters
  136. * This routine is called in order to calculate the optimum overlap
  137. * between the local and remote domain parameters. If there is no
  138. * overlap, this routine will return a value causing this connection
  139. * to be destroyed.
  140. * PrintDomainParameters
  141. * This routine is used for debug purposes in order to print out the
  142. * current set of domain parameters.
  143. * SendPacket
  144. * This routine is called in order to create a packet which will hold
  145. * the PDU to be sent to the remote provider. The packet will be
  146. * queued up for transmission through the transport interface.
  147. * QueueForTransmission
  148. * This routine places data units into the transmission queue so
  149. * they can be transmitted through the transport interface when
  150. * possible.
  151. * ProcessMergeChannelsRequest
  152. * This routine processes "Merge Channel Request" PDU's coming from the
  153. * transport interface by retrieving any necessary information from the
  154. * packet and sending the PDU on to the proper domain.
  155. * ProcessMergeChannelsConfirm
  156. * This routine processes "Merge Channel Confirm" PDU's coming from the
  157. * transport interface by retrieving any necessary information from the
  158. * packet and sending the PDU on to the proper domain.
  159. * ProcessPurgeChannelsIndication
  160. * This routine processes "Purge Channel Indication" PDU's coming from
  161. * the transport interface by retrieving any necessary information from
  162. * the packet and sending the PDU on to the proper domain.
  163. * ProcessMergeTokenRequest
  164. * This routine processes "Merge Token Request" PDU's coming from the
  165. * transport interface by retrieving any necessary information from the
  166. * packet and sending the PDU on to the proper domain.
  167. * ProcessMergeTokenConfirm
  168. * This routine processes "Merge Token Confirm" PDU's coming from the
  169. * transport interface by retrieving any necessary information from the
  170. * packet and sending the PDU on to the proper domain.
  171. * ProcessPurgeTokenIndication
  172. * This routine processes "Purge Token Indication" PDU's coming from
  173. * the transport interface by retrieving any necessary information from
  174. * the packet and sending the PDU on to the proper domain.
  175. * ProcessDisconnectProviderUltimatum
  176. * This routine processes "Disconnect Provider Ultimatum" PDU's coming
  177. * from the transport interface by retrieving any necessary information
  178. * from the packet and sending the PDU on to the proper domain.
  179. * ProcessAttachUserRequest
  180. * This routine processes "Attach User Request" PDU's coming from the
  181. * transport interface by sending the PDU on to the proper domain.
  182. * ProcessAttachUserConfirm
  183. * This routine processes "Attach User Confirm" PDU's coming from the
  184. * transport interface by retrieving any necessary information from the
  185. * packet and sending the PDU on to the proper domain.
  186. * ProcessDetachUserRequest
  187. * This routine processes "Detach User Request" PDU's coming from the
  188. * transport interface by retrieving any necessary information from the
  189. * packet and sending the PDU on to the proper domain.
  190. * ProcessDetachUserIndication
  191. * This routine processes "Detach User Request" PDU's coming from the
  192. * transport interface by retrieving any necessary information from the
  193. * packet and sending the PDU on to the proper domain.
  194. * ProcessChannelJoinRequest
  195. * This routine processes "Channel Join Request" PDU's coming from the
  196. * transport interface by retrieving any necessary information from the
  197. * packet and sending the PDU on to the proper domain.
  198. * ProcessChannelJoinConfirm
  199. * This routine processes "Channel Join Confirm" PDU's coming from the
  200. * transport interface by retrieving any necessary information from the
  201. * packet and sending the PDU on to the proper domain.
  202. * ProcessChannelLeaveRequest
  203. * This routine processes "Channel Leave Request" PDU's coming from the
  204. * transport interface by retrieving any necessary information from the
  205. * packet and sending the PDU on to the proper domain.
  206. * ProcessChannelConveneRequest
  207. * This routine processes the "ChannelConveneRequest" PDU's being
  208. * received through the transport interface. The pertinent data is
  209. * read from the incoming packet and passed on to the domain.
  210. * ProcessChannelConveneConfirm
  211. * This routine processes the "ChannelConveneConfirm" PDU's being
  212. * received through the transport interface. The pertinent data is
  213. * read from the incoming packet and passed on to the domain.
  214. * ProcessChannelDisbandRequest
  215. * This routine processes the "ChannelDisbandRequest" PDU's being
  216. * received through the transport interface. The pertinent data is
  217. * read from the incoming packet and passed on to the domain.
  218. * ProcessChannelDisbandIndication
  219. * This routine processes the "ChannelDisbandIndication" PDU's being
  220. * received through the transport interface. The pertinent data is
  221. * read from the incoming packet and passed on to the domain.
  222. * ProcessChannelAdmitRequest
  223. * This routine processes the "ChannelAdmitRequest" PDU's being
  224. * received through the transport interface. The pertinent data is
  225. * read from the incoming packet and passed on to the domain.
  226. * ProcessChannelAdmitIndication
  227. * This routine processes the "ChannelAdmitIndication" PDU's being
  228. * received through the transport interface. The pertinent data is
  229. * read from the incoming packet and passed on to the domain.
  230. * ProcessChannelExpelRequest
  231. * This routine processes the "ChannelExpelRequest" PDU's being
  232. * received through the transport interface. The pertinent data is
  233. * read from the incoming packet and passed on to the domain.
  234. * ProcessChannelExpelIndication
  235. * This routine processes the "ChannelExpelIndication" PDU's being
  236. * received through the transport interface. The pertinent data is
  237. * read from the incoming packet and passed on to the domain.
  238. * ProcessSendDataRequest
  239. * This routine processes "Send Data Request" PDU's coming from the
  240. * transport interface by retrieving any necessary information from the
  241. * packet, allocating any memory needed, and sending the PDU on to the
  242. * proper domain.
  243. * ProcessSendDataIndication
  244. * This routine processes "Send Data Indication" PDU's coming from the
  245. * transport interface by retrieving any necessary information from the
  246. * packet, allocating any memory needed, and sending the PDU on to the
  247. * proper domain.
  248. * ProcessUniformSendDataRequest
  249. * This routine processes "Uniform Send Data Indication" PDU's coming
  250. * from the transport interface by retrieving any necessary information
  251. * from the packet, allocating any memory needed, and sending the PDU
  252. * on to the proper domain.
  253. * ProcessUniformSendDataIndication
  254. * This routine processes "Uniform Send Data Indication" PDU's coming
  255. * from the transport interface by retrieving any necessary information
  256. * from the packet, allocating any memory needed, and sending the PDU
  257. * on to the proper domain.
  258. * ProcessTokenGrabRequest
  259. * This routine processes "Token Grab Request" PDU's coming from the
  260. * transport interface by retrieving any necessary information from the
  261. * packet and sending the PDU on to the proper domain.
  262. * ProcessTokenGrabConfirm
  263. * This routine processes "Token Grab Confirm" PDU's coming from the
  264. * transport interface by retrieving any necessary information from the
  265. * packet and sending the PDU on to the proper domain.
  266. * ProcessTokenInhibitRequest
  267. * This routine processes "Token Inhibit Request" PDU's coming from the
  268. * transport interface by retrieving any necessary information from the
  269. * packet and sending the PDU on to the proper domain.
  270. * ProcessTokenInhibitConfirm
  271. * This routine processes "Token Inhibit Confirm" PDU's coming from the
  272. * transport interface by retrieving any necessary information from the
  273. * packet and sending the PDU on to the proper domain.
  274. * ProcessTokenReleaseRequest
  275. * This routine processes "Token Release Request" PDU's coming from the
  276. * transport interface by retrieving any necessary information from the
  277. * packet and sending the PDU on to the proper domain.
  278. * ProcessTokenReleaseConfirm
  279. * This routine processes "Token Release Confirm" PDU's coming from the
  280. * transport interface by retrieving any necessary information from the
  281. * packet and sending the PDU on to the proper domain.
  282. * ProcessTokenTestRequest
  283. * This routine processes "Token Test Request" PDU's coming from the
  284. * transport interface by retrieving any necessary information from the
  285. * packet and sending the PDU on to the proper domain.
  286. * ProcessTokenTestConfirm
  287. * This routine processes "Token Test Confirm" PDU's coming from the
  288. * transport interface by retrieving any necessary information from the
  289. * packet and sending the PDU on to the proper domain.
  290. * ProcessRejectUltimatum
  291. * This routine processes "RejectUltimatum" PDU's coming from the
  292. * transport interface by retrieving any necessary information from the
  293. * packet and sending the PDU on to the proper domain.
  294. * ProcessTokenGiveRequest
  295. * This routine processes "TokenGiveRequest" PDU's coming from the
  296. * transport interface by retrieving any necessary information from the
  297. * packet and sending the PDU on to the proper domain.
  298. * ProcessTokenGiveIndication
  299. * This routine processes "TokenGiveIndication" PDU's coming from the
  300. * transport interface by retrieving any necessary information from the
  301. * packet and sending the PDU on to the proper domain.
  302. * ProcessTokenGiveResponse
  303. * This routine processes "TokenGiveResponse" PDU's coming from the
  304. * transport interface by retrieving any necessary information from the
  305. * packet and sending the PDU on to the proper domain.
  306. * ProcessTokenGiveConfirm
  307. * This routine processes "TokenGiveConfirm" PDU's coming from the
  308. * transport interface by retrieving any necessary information from the
  309. * packet and sending the PDU on to the proper domain.
  310. * ProcessTokenPleaseRequest
  311. * This routine processes "TokenPleaseRequest" PDU's coming from the
  312. * transport interface by retrieving any necessary information from the
  313. * packet and sending the PDU on to the proper domain.
  314. * ProcessTokenPleaseIndication
  315. * This routine processes "TokenPleaseIndication" PDU's coming from the
  316. * transport interface by retrieving any necessary information from the
  317. * packet and sending the PDU on to the proper domain.
  318. * ProcessPlumbDomainIndication
  319. * This routine processes "PlumbDomainIndication" PDU's coming from the
  320. * transport interface by retrieving any necessary information from the
  321. * packet and sending the PDU on to the proper domain.
  322. * ProcessErectDomainRequest
  323. * This routine processes "ErectDomainRequest" PDU's coming from the
  324. * transport interface by retrieving any necessary information from the
  325. * packet and sending the PDU on to the proper domain.
  326. * ValidateConnectionRequest
  327. * This function is used to determine if it is valid to process an
  328. * incoming request at the current time.
  329. *
  330. * Caveats:
  331. * None.
  332. *
  333. * Author:
  334. * James P. Galvin, Jr.
  335. * John B. O'Nan
  336. */
  337. /*
  338. * External Interfaces
  339. */
  340. #include "omcscode.h"
  341. #include "tprtntfy.h"
  342. #include "plgxprt.h"
  343. /*
  344. * This is a global variable that has a pointer to the one MCS coder that
  345. * is instantiated by the MCS Controller. Most objects know in advance
  346. * whether they need to use the MCS or the GCC coder, so, they do not need
  347. * this pointer in their constructors.
  348. */
  349. extern CMCSCoder *g_MCSCoder;
  350. // The external MCS Controller object
  351. extern PController g_pMCSController;
  352. // The global TransportInterface pointer (for transport access)
  353. extern PTransportInterface g_Transport;
  354. /*
  355. * Connection ()
  356. *
  357. * Public
  358. *
  359. * Functional Description:
  360. * This is a constructor for the Connection class. This constructor
  361. * is used for creating outbound connections. It initializes private
  362. * instance variables and calls the transport interface to set up a
  363. * transport connection and register this connection object (through a
  364. * callback structure) with the transport object.
  365. *
  366. * Caveats:
  367. * None.
  368. */
  369. Connection::Connection
  370. (
  371. PDomain attachment,
  372. ConnectionHandle connection_handle,
  373. GCCConfID *calling_domain,
  374. GCCConfID *called_domain,
  375. PChar called_address,
  376. BOOL fSecure,
  377. BOOL upward_connection,
  378. PDomainParameters domain_parameters,
  379. PUChar user_data,
  380. ULong user_data_length,
  381. PMCSError connection_error
  382. )
  383. :
  384. CAttachment(CONNECT_ATTACHMENT),
  385. Encoding_Rules (BASIC_ENCODING_RULES),
  386. m_pDomain(NULL),
  387. m_pPendingDomain(attachment),
  388. Connection_Handle (connection_handle),
  389. Upward_Connection (upward_connection),
  390. Deletion_Reason (REASON_USER_REQUESTED),
  391. Connect_Response_Memory (NULL),
  392. Merge_In_Progress (FALSE),
  393. Domain_Traffic_Allowed (FALSE),
  394. Connect_Provider_Confirm_Pending (TRUE),
  395. m_fSecure(fSecure)
  396. {
  397. UINT priority;
  398. TransportError transport_error;
  399. DomainParameters min_domain_parameters;
  400. DomainParameters max_domain_parameters;
  401. BOOL fPluggableTransport = ::GetPluggableTransportConnID((LPCSTR) called_address);
  402. /*
  403. * If the passed in pointer is valid, then set the local domain
  404. * parameters to the values contained therein. Otherwise, use
  405. * defaults for everything.
  406. */
  407. if (domain_parameters != NULL)
  408. Domain_Parameters = *domain_parameters;
  409. else
  410. {
  411. /*
  412. * Use default values for all domain parameters.
  413. */
  414. Domain_Parameters.max_channel_ids = DEFAULT_MAXIMUM_CHANNELS;
  415. Domain_Parameters.max_user_ids = DEFAULT_MAXIMUM_USERS;
  416. Domain_Parameters.max_token_ids = DEFAULT_MAXIMUM_TOKENS;
  417. Domain_Parameters.number_priorities = DEFAULT_NUMBER_OF_PRIORITIES;
  418. Domain_Parameters.min_throughput = DEFAULT_MINIMUM_THROUGHPUT;
  419. Domain_Parameters.max_height = DEFAULT_MAXIMUM_DOMAIN_HEIGHT;
  420. Domain_Parameters.max_mcspdu_size = DEFAULT_MAXIMUM_PDU_SIZE;
  421. Domain_Parameters.protocol_version = DEFAULT_PROTOCOL_VERSION;
  422. if (fPluggableTransport || g_fWinsockDisabled)
  423. {
  424. Domain_Parameters.number_priorities = DEFAULT_NUM_PLUGXPRT_PRIORITIES;
  425. }
  426. }
  427. /*
  428. * Initialize the arrays indicating that the transport connections
  429. * are not yet valid, and that none of the queues have data in them
  430. * yet.
  431. */
  432. for (priority = 0; priority < MAXIMUM_PRIORITIES; priority++)
  433. {
  434. Transport_Connection_State[priority] = TRANSPORT_CONNECTION_UNASSIGNED;
  435. }
  436. Transport_Connection_Count = 0;
  437. if (NULL == (m_pszCalledAddress = ::My_strdupA(called_address)))
  438. {
  439. ERROR_OUT(("Connection::Connection: can't create called address"));
  440. *connection_error = MCS_ALLOCATION_FAILURE;
  441. return;
  442. }
  443. /*
  444. * Send a connect request to the transport layer to create the Top
  445. * Priority transport connection.
  446. */
  447. transport_error = CreateTransportConnection (m_pszCalledAddress, m_fSecure, TOP_PRIORITY);
  448. if (transport_error == TRANSPORT_NO_ERROR)
  449. {
  450. /*
  451. * Call upon the domain to find out the appropriate minimum and
  452. * maximum domain parameter values. Then call a private member
  453. * function to adjust the target parameters to fit into that range.
  454. */
  455. m_pPendingDomain->GetDomainParameters(NULL, &min_domain_parameters,
  456. &max_domain_parameters);
  457. AdjustDomainParameters (&min_domain_parameters, &max_domain_parameters,
  458. &Domain_Parameters);
  459. #ifdef DEBUG
  460. TRACE_OUT (("Connection::Connection: CONNECT_INITIAL target parameters"));
  461. PrintDomainParameters (&Domain_Parameters);
  462. TRACE_OUT (("Connection::Connection: CONNECT_INITIAL minimum parameters"));
  463. PrintDomainParameters (&min_domain_parameters);
  464. TRACE_OUT (("Connection::Connection: CONNECT_INITIAL maximum parameters"));
  465. PrintDomainParameters (&max_domain_parameters);
  466. #endif // DEBUG
  467. /*
  468. * Issue the ConnectInitial on the newly created transport
  469. * connection. Note that the queue will not actually try to
  470. * send the data until the confirm is received from the
  471. * transport layer.
  472. */
  473. ConnectInitial (calling_domain, called_domain, Upward_Connection,
  474. &Domain_Parameters, &min_domain_parameters,
  475. &max_domain_parameters, user_data, user_data_length);
  476. *connection_error = MCS_NO_ERROR;
  477. }
  478. else
  479. {
  480. WARNING_OUT (("Connection::Connection: transport ConnectRequest failed"));
  481. /*
  482. * Set the return code according to the nature of the failure.
  483. */
  484. switch (transport_error)
  485. {
  486. case TRANSPORT_MEMORY_FAILURE:
  487. *connection_error = MCS_ALLOCATION_FAILURE;
  488. break;
  489. case TRANSPORT_SECURITY_FAILED:
  490. *connection_error = MCS_SECURITY_FAILED;
  491. break;
  492. default:
  493. *connection_error = MCS_TRANSPORT_NOT_READY;
  494. break;
  495. }
  496. }
  497. }
  498. /*
  499. * Connection ()
  500. *
  501. * Public
  502. *
  503. * Functional Description:
  504. * This is a constructor for the Connection class. This constructor is
  505. * used for creating inbound connections and is called when a transport
  506. * connection already exists. It initializes private instance variables
  507. * and calls the transport interface to register this connection object
  508. * (through a callback structure) with the transport object.
  509. *
  510. * Caveats:
  511. * None.
  512. */
  513. Connection::Connection (
  514. PDomain attachment,
  515. ConnectionHandle connection_handle,
  516. TransportConnection transport_connection,
  517. BOOL upward_connection,
  518. PDomainParameters domain_parameters,
  519. PDomainParameters min_domain_parameters,
  520. PDomainParameters max_domain_parameters,
  521. PUChar user_data,
  522. ULong user_data_length,
  523. PMCSError connection_error)
  524. :
  525. CAttachment(CONNECT_ATTACHMENT),
  526. m_pszCalledAddress(NULL),
  527. Encoding_Rules (BASIC_ENCODING_RULES),
  528. m_pDomain(NULL),
  529. m_pPendingDomain(attachment),
  530. Connection_Handle (connection_handle),
  531. Upward_Connection (upward_connection),
  532. Deletion_Reason (REASON_USER_REQUESTED),
  533. Connect_Response_Memory (NULL),
  534. Merge_In_Progress (FALSE),
  535. Domain_Traffic_Allowed (FALSE),
  536. Connect_Provider_Confirm_Pending (FALSE)
  537. {
  538. UINT priority;
  539. TransportError transport_error;
  540. DomainParameters local_min_domain_parameters;
  541. DomainParameters local_max_domain_parameters;
  542. //
  543. // BUGBUG: set m_fSecure from transport connection?
  544. //
  545. /*
  546. * If the passed in pointer is valid, then set the local domain
  547. * parameters to the values contained therein. Otherwise, use
  548. * defaults for everything.
  549. */
  550. if (domain_parameters != NULL)
  551. Domain_Parameters = *domain_parameters;
  552. else
  553. {
  554. /*
  555. * Use default values for all domain parameters.
  556. */
  557. Domain_Parameters.max_channel_ids = DEFAULT_MAXIMUM_CHANNELS;
  558. Domain_Parameters.max_user_ids = DEFAULT_MAXIMUM_USERS;
  559. Domain_Parameters.max_token_ids = DEFAULT_MAXIMUM_TOKENS;
  560. Domain_Parameters.number_priorities = DEFAULT_NUMBER_OF_PRIORITIES;
  561. Domain_Parameters.min_throughput = DEFAULT_MINIMUM_THROUGHPUT;
  562. Domain_Parameters.max_height = DEFAULT_MAXIMUM_DOMAIN_HEIGHT;
  563. Domain_Parameters.max_mcspdu_size = DEFAULT_MAXIMUM_PDU_SIZE;
  564. Domain_Parameters.protocol_version = DEFAULT_PROTOCOL_VERSION;
  565. if (IS_PLUGGABLE(transport_connection) || g_fWinsockDisabled)
  566. {
  567. Domain_Parameters.number_priorities = DEFAULT_NUM_PLUGXPRT_PRIORITIES;
  568. }
  569. }
  570. /*
  571. * Initialize the arrays indicating that the transport connections
  572. * are not yet valid, and that none of the queues have data in them
  573. * yet.
  574. */
  575. for (priority=0; priority < MAXIMUM_PRIORITIES; priority++)
  576. {
  577. Transport_Connection_State[priority] = TRANSPORT_CONNECTION_UNASSIGNED;
  578. }
  579. Transport_Connection_Count = 0;
  580. transport_error = AcceptTransportConnection (transport_connection,
  581. TOP_PRIORITY);
  582. if (transport_error == TRANSPORT_NO_ERROR)
  583. {
  584. /*
  585. * Call the domain object to find out the local minimum and maximum
  586. * permissible values for the domain parameters.
  587. */
  588. m_pPendingDomain->GetDomainParameters (NULL, &local_min_domain_parameters,
  589. &local_max_domain_parameters);
  590. /*
  591. * Now call a private member function to calculate the optimum overlap
  592. * between the local and remote domain parameters. Note that if there
  593. * is no overlap, this connection will be destroyed.
  594. */
  595. if (MergeDomainParameters (min_domain_parameters, max_domain_parameters,
  596. &local_min_domain_parameters, &local_max_domain_parameters))
  597. {
  598. /*
  599. * The merge of the domain parameters was acceptable, so now we
  600. * must adjust the target parameters to fit within the agreed
  601. * upon range.
  602. */
  603. AdjustDomainParameters (&local_min_domain_parameters,
  604. &local_max_domain_parameters, &Domain_Parameters);
  605. #ifdef DEBUG
  606. TRACE_OUT (("Connection::Connection: CONNECT_RESPONSE parameters"));
  607. PrintDomainParameters (&Domain_Parameters);
  608. #endif // DEBUG
  609. /*
  610. * Issue the ConnectResponse on the new transport connection.
  611. */
  612. ConnectResponse (RESULT_SUCCESSFUL, &Domain_Parameters,
  613. Connection_Handle, user_data, user_data_length);
  614. /*
  615. * Check to see if this completes the list of transport
  616. * connections that will be used in this MCS connection.
  617. */
  618. if (Transport_Connection_Count == Domain_Parameters.number_priorities)
  619. {
  620. /*
  621. * There are no more transport connections to accept. We must
  622. * now assign the lowest priority TC to all unassigned
  623. * priorities.
  624. */
  625. AssignRemainingTransportConnections ();
  626. }
  627. else
  628. {
  629. /*
  630. * Issue a ConnectResult for each remaining priority. Note
  631. * that these TCs have not been created yet, so the PDUs will
  632. * remain in the queue until they are created. They are put in
  633. * the queue here to assure that they are the first PDUs
  634. * transmitted over a given TC.
  635. */
  636. for (priority = Transport_Connection_Count;
  637. priority < Domain_Parameters.number_priorities;
  638. priority++)
  639. ConnectResult (RESULT_SUCCESSFUL, (Priority) priority);
  640. }
  641. /*
  642. * Now that we know what the domain parameters will be for this
  643. * connection, we can determine what type of encoding rules will
  644. * be used for domain PDUs (basic or packed).
  645. */
  646. #if 0
  647. if (Domain_Parameters.protocol_version == PROTOCOL_VERSION_BASIC)
  648. {
  649. TRACE_OUT(("Connection::Connection: using basic encoding rules"));
  650. Encoding_Rules = BASIC_ENCODING_RULES;
  651. }
  652. else
  653. #endif // 0
  654. {
  655. TRACE_OUT (("Connection::Connection: using packed encoding rules"));
  656. Encoding_Rules = PACKED_ENCODING_RULES;
  657. }
  658. /*
  659. * Bind the pending attachment to the domain. Note that this
  660. * is necessary on the called provider in order to allow access
  661. * to domain services immediately after the return from
  662. * MCSConnectProviderResponse (which is what got us here).
  663. */
  664. TRACE_OUT (("Connection::Connection: binding MCS connection to domain"));
  665. m_pDomain = m_pPendingDomain;
  666. m_pDomain->BindConnAttmnt(this, Upward_Connection, &Domain_Parameters);
  667. *connection_error = MCS_NO_ERROR;
  668. }
  669. else
  670. {
  671. /*
  672. * Issue the ConnectResponse informing the remote side that the
  673. * domain parameters are unacceptable. We must flush the message
  674. * queue from here to force the response packet to be transmitted.
  675. * This is because this object will be deleted by the controller
  676. * as soon as this call returns.
  677. */
  678. WARNING_OUT (("Connection::Connection: "
  679. "unacceptable domain parameters"));
  680. ConnectResponse (RESULT_PARAMETERS_UNACCEPTABLE, &Domain_Parameters,
  681. Connection_Handle, user_data, user_data_length);
  682. FlushMessageQueue ();
  683. *connection_error = MCS_DOMAIN_PARAMETERS_UNACCEPTABLE;
  684. }
  685. }
  686. else
  687. {
  688. WARNING_OUT (("Connection::Connection: "
  689. "register transport connection failed"));
  690. *connection_error = MCS_NO_SUCH_CONNECTION;
  691. }
  692. }
  693. /*
  694. * ~Connection ()
  695. *
  696. * Public
  697. *
  698. * Functional Description:
  699. * This is the destructor for the Connection class. If no connection
  700. * deletion is pending, it terminates the current connection by issuing
  701. * a DisconnectProviderUltimatum to the domain, transmitting a
  702. * "DISCONNECT_PROVIDER_ULTIMATUM" PDU, and issuing a DisconnectRequest
  703. * to the transport interface. The destructor also clears the transmission
  704. * queue and frees any allocated memory.
  705. *
  706. * Caveats:
  707. * None.
  708. */
  709. Connection::~Connection ()
  710. {
  711. DomainMCSPDU disconnect_provider_ultimatum_pdu;
  712. PSimplePacket packet;
  713. PacketError packet_error;
  714. UShort priority;
  715. /*
  716. * If we still have an upward attachment, then issue a disconnect
  717. * provider ultimatum to terminate it.
  718. */
  719. if (m_pDomain != NULL)
  720. m_pDomain->DisconnectProviderUltimatum(this, Deletion_Reason);
  721. /*
  722. * Check to see if the Top Priority transport connection is still valid.
  723. * If so, we need to try and send a disconnect ultimatum PDU through it
  724. * before hanging up.
  725. */
  726. if (Transport_Connection_State[TOP_PRIORITY] == TRANSPORT_CONNECTION_READY)
  727. {
  728. /*
  729. * We must first purge all packets that are waiting in the transport
  730. * queue, to expediate the disconnect process.
  731. */
  732. ::PurgeRequest (Transport_Connection[TOP_PRIORITY]);
  733. /*
  734. * If there are any remaining data units in the queue for this
  735. * priority, walk through the list releasing all memory associated
  736. * with them.
  737. */
  738. while (NULL != (packet = m_OutPktQueue[TOP_PRIORITY].Get()))
  739. {
  740. packet->Unlock();
  741. }
  742. if (Domain_Traffic_Allowed)
  743. {
  744. PPacket disconnect_packet;
  745. /*
  746. * Fill in the PDU structure to be encoded.
  747. */
  748. disconnect_provider_ultimatum_pdu.choice =
  749. DISCONNECT_PROVIDER_ULTIMATUM_CHOSEN;
  750. disconnect_provider_ultimatum_pdu.u.
  751. disconnect_provider_ultimatum.reason =
  752. (PDUReason)Deletion_Reason;
  753. /*
  754. * Create a packet which will be used to hold the data to be sent
  755. * through the transport interface. If the packet creation fails it
  756. * doesn't matter since this connection is being deleted anyway.
  757. */
  758. DBG_SAVE_FILE_LINE
  759. disconnect_packet = new Packet (
  760. (PPacketCoder) g_MCSCoder,
  761. Encoding_Rules,
  762. (PVoid) &disconnect_provider_ultimatum_pdu,
  763. DOMAIN_MCS_PDU,
  764. Upward_Connection,
  765. &packet_error);
  766. if (disconnect_packet != NULL)
  767. {
  768. if (packet_error == PACKET_NO_ERROR)
  769. {
  770. /*
  771. * Lock the encoded PDU data and queue the packet up for
  772. * transmission through the transport interface.
  773. */
  774. QueueForTransmission ((PSimplePacket) disconnect_packet,
  775. TOP_PRIORITY);
  776. /*
  777. * Attempt to flush the message queue. Since this is the
  778. * object destructor, this is the last chance we will get to
  779. * send queued up PDUs (including the disconnect PDU that we
  780. * just put there).
  781. */
  782. FlushMessageQueue ();
  783. }
  784. disconnect_packet->Unlock ();
  785. }
  786. } // Domain_Traffic_Allowed == TRUE
  787. /*
  788. * Issue a disconnect request to the top priority transport connection,
  789. * telling it to wait until the disconnect provider ultimatum has
  790. * cleared the transmitter.
  791. */
  792. ASSERT(g_Transport != NULL);
  793. g_Transport->DisconnectRequest (Transport_Connection[TOP_PRIORITY]);
  794. Transport_Connection_State[TOP_PRIORITY] =
  795. TRANSPORT_CONNECTION_UNASSIGNED;
  796. }
  797. /*
  798. * Clear the transmission queue and free any allocated memory.
  799. */
  800. for (priority = 0; priority < MAXIMUM_PRIORITIES; priority++)
  801. {
  802. /*
  803. * If we are holding a valid connection handle for this priority, then
  804. * it is necessary to issue a disconnect.
  805. */
  806. if (Transport_Connection_State[priority] !=
  807. TRANSPORT_CONNECTION_UNASSIGNED)
  808. {
  809. ASSERT(g_Transport != NULL);
  810. g_Transport->DisconnectRequest (
  811. Transport_Connection[priority]);
  812. }
  813. /*
  814. * If there are any remaining data units in the queue for this
  815. * priority, walk through the list releasing all memory associated
  816. * with them.
  817. */
  818. while (NULL != (packet = m_OutPktQueue[priority].Get()))
  819. {
  820. packet->Unlock();
  821. }
  822. }
  823. /*
  824. * If there is a memory block holding the user data field of a pending
  825. * connect provider confirm, then free it.
  826. */
  827. FreeMemory (Connect_Response_Memory);
  828. delete m_pszCalledAddress;
  829. }
  830. /*
  831. * void RegisterTransportConnection ()
  832. *
  833. * Public
  834. *
  835. * Functional Description:
  836. * This routine is called in order to register the transport connection
  837. * with the connection object.
  838. */
  839. void Connection::RegisterTransportConnection (
  840. TransportConnection transport_connection,
  841. Priority priority)
  842. {
  843. TransportError transport_error;
  844. /*
  845. * Make sure that the specified priority is one of those outstanding.
  846. */
  847. if (Transport_Connection_State[priority] != TRANSPORT_CONNECTION_READY)
  848. {
  849. /*
  850. * Register this connection object as the owner of the new
  851. * transport connection.
  852. */
  853. transport_error = AcceptTransportConnection (transport_connection,
  854. priority);
  855. if (transport_error == TRANSPORT_NO_ERROR)
  856. {
  857. TRACE_OUT (("Connection::RegisterTransportConnection: "
  858. "transport connection accepted"));
  859. /*
  860. * Check to see if this completes the list of transport
  861. * connections that will be used in this MCS connection.
  862. */
  863. if (Transport_Connection_Count == Domain_Parameters.number_priorities)
  864. {
  865. /*
  866. * There are no more transport connections to accept. We must
  867. * now assign the lowest priority TC to all unassigned
  868. * priorities.
  869. */
  870. AssignRemainingTransportConnections ();
  871. }
  872. }
  873. else
  874. {
  875. /*
  876. * The transport connection must be invalid or already assigned
  877. * to another connection object. We therefore cannot use it.
  878. */
  879. ERROR_OUT (("Connection::RegisterTransportConnection: "
  880. "register transport connection failed"));
  881. }
  882. }
  883. else
  884. {
  885. /*
  886. * A transport connection is not pending for this priority level.
  887. * Reject the registration.
  888. */
  889. ERROR_OUT (("Connection::RegisterTransportConnection: "
  890. "priority already assigned"));
  891. }
  892. }
  893. /*
  894. * Void ConnectInitial ()
  895. *
  896. * Private
  897. *
  898. * Functional Description:
  899. * This routine is called by the domain when a connection is being created.
  900. * It places the necessary domain information into a data packet and
  901. * queues the data to be transmitted through the transport interface.
  902. *
  903. * Caveats:
  904. * None.
  905. */
  906. // LONCHANC: we send out calling and called domain selectors but
  907. // at the receiver side, we ignore them completely.
  908. Void Connection::ConnectInitial (
  909. GCCConfID *calling_domain,
  910. GCCConfID *called_domain,
  911. BOOL upward_connection,
  912. PDomainParameters domain_parameters,
  913. PDomainParameters min_domain_parameters,
  914. PDomainParameters max_domain_parameters,
  915. PUChar user_data,
  916. ULong user_data_length)
  917. {
  918. ConnectMCSPDU connect_initial_pdu;
  919. /*
  920. * Fill in the PDU structure to be encoded.
  921. */
  922. connect_initial_pdu.choice = CONNECT_INITIAL_CHOSEN;
  923. connect_initial_pdu.u.connect_initial.calling_domain_selector.length = sizeof(GCCConfID);
  924. connect_initial_pdu.u.connect_initial.calling_domain_selector.value = (LPBYTE) calling_domain;
  925. connect_initial_pdu.u.connect_initial.called_domain_selector.length = sizeof(GCCConfID);
  926. connect_initial_pdu.u.connect_initial.called_domain_selector.value = (LPBYTE) called_domain;
  927. connect_initial_pdu.u.connect_initial.upward_flag = (ASN1bool_t)upward_connection;
  928. memcpy (&(connect_initial_pdu.u.connect_initial.target_parameters),
  929. domain_parameters, sizeof (PDUDomainParameters));
  930. memcpy (&(connect_initial_pdu.u.connect_initial.minimum_parameters),
  931. min_domain_parameters, sizeof(PDUDomainParameters));
  932. memcpy (&(connect_initial_pdu.u.connect_initial.maximum_parameters),
  933. max_domain_parameters, sizeof(PDUDomainParameters));
  934. connect_initial_pdu.u.connect_initial.user_data.length = user_data_length;
  935. connect_initial_pdu.u.connect_initial.user_data.value = user_data;
  936. /*
  937. * Send the packet to the remote provider.
  938. */
  939. SendPacket ((PVoid) &connect_initial_pdu, CONNECT_MCS_PDU, TOP_PRIORITY);
  940. }
  941. /*
  942. * Void ConnectResponse ()
  943. *
  944. * Private
  945. *
  946. * Functional Description:
  947. * This routine is called when issuing a response to a "ConnectInitial"
  948. * PDU. The result of the attempted connection, the connection ID, the
  949. * domain parameters, and any user data are all put into the packet and
  950. * queued for transmission through the transport interface. If the result
  951. * of the attempted connection is negative, the controller and transport
  952. * interface are notified.
  953. *
  954. * Caveats:
  955. * None.
  956. */
  957. Void Connection::ConnectResponse (
  958. Result result,
  959. PDomainParameters domain_parameters,
  960. ConnectID connect_id,
  961. PUChar user_data,
  962. ULong user_data_length)
  963. {
  964. ConnectMCSPDU connect_response_pdu;
  965. /*
  966. * Fill in the PDU structure to be encoded.
  967. */
  968. connect_response_pdu.choice = CONNECT_RESPONSE_CHOSEN;
  969. connect_response_pdu.u.connect_response.result = (PDUResult)result;
  970. connect_response_pdu.u.connect_response.called_connect_id = connect_id;
  971. memcpy (&(connect_response_pdu.u.connect_response.domain_parameters),
  972. domain_parameters, sizeof(PDUDomainParameters));
  973. connect_response_pdu.u.connect_response.user_data.length = user_data_length;
  974. connect_response_pdu.u.connect_response.user_data.value = user_data;
  975. /*
  976. * Send the packet to the remote provider.
  977. */
  978. SendPacket ((PVoid) &connect_response_pdu, CONNECT_MCS_PDU, TOP_PRIORITY);
  979. }
  980. /*
  981. * Void ConnectAdditional ()
  982. *
  983. * Private
  984. *
  985. * Functional Description:
  986. * This routine is called after successfully processing a"ConnectResponse"
  987. * PDU in order to create any addition necessary transport connections.
  988. *
  989. * Caveats:
  990. * None.
  991. */
  992. Void Connection::ConnectAdditional (
  993. ConnectID connect_id,
  994. Priority priority)
  995. {
  996. ConnectMCSPDU connect_additional_pdu;
  997. /*
  998. * Fill in the PDU structure to be encoded.
  999. */
  1000. connect_additional_pdu.choice = CONNECT_ADDITIONAL_CHOSEN;
  1001. connect_additional_pdu.u.connect_additional.called_connect_id = connect_id;
  1002. connect_additional_pdu.u.connect_additional.data_priority =
  1003. (PDUPriority)priority;
  1004. /*
  1005. * Send the packet to the remote provider.
  1006. */
  1007. SendPacket ((PVoid) &connect_additional_pdu, CONNECT_MCS_PDU, priority);
  1008. }
  1009. /*
  1010. * Void ConnectResult ()
  1011. *
  1012. * Private
  1013. *
  1014. * Functional Description:
  1015. * This routine is called indirectly when issuing a positive response
  1016. * to a "ConnectAdditional" PDU. The "ConnectAdditional" PDUs are
  1017. * processed by the controller and therefore any negative
  1018. * "ConnectResult" PDU will be issued by the controller.
  1019. *
  1020. * Caveats:
  1021. * None.
  1022. */
  1023. Void Connection::ConnectResult (
  1024. Result result,
  1025. Priority priority)
  1026. {
  1027. ConnectMCSPDU connect_result_pdu;
  1028. /*
  1029. * Fill in the PDU structure to be encoded.
  1030. */
  1031. connect_result_pdu.choice = CONNECT_RESULT_CHOSEN;
  1032. connect_result_pdu.u.connect_result.result = (PDUResult)result;
  1033. /*
  1034. * Send the packet to the remote provider.
  1035. */
  1036. SendPacket ((PVoid) &connect_result_pdu, CONNECT_MCS_PDU, priority);
  1037. }
  1038. /*
  1039. * ULong ProcessConnectResponse()
  1040. *
  1041. * Private
  1042. *
  1043. * Functional Description:
  1044. * This routine processes the "ConnectResponse" PDU's being received
  1045. * through the transport interface. The result of the connection attempt,
  1046. * the connection ID, and the domain parameters are read from the packet
  1047. * and the domain notified of the connection response.
  1048. *
  1049. * Caveats:
  1050. * None.
  1051. */
  1052. ULong Connection::ProcessConnectResponse (PConnectResponsePDU pdu_structure)
  1053. {
  1054. TransportError return_value=TRANSPORT_NO_ERROR;
  1055. UINT priority;
  1056. TransportError transport_error;
  1057. /*
  1058. * Allocate any memory needed to pass user data on to the domain.
  1059. */
  1060. if (pdu_structure->user_data.length != 0)
  1061. {
  1062. DBG_SAVE_FILE_LINE
  1063. Connect_Response_Memory = AllocateMemory (
  1064. pdu_structure->user_data.value,
  1065. pdu_structure->user_data.length);
  1066. if (Connect_Response_Memory == NULL)
  1067. {
  1068. ("Connection::ProcessConnectResponse: "
  1069. "memory allocation failed");
  1070. return_value = TRANSPORT_READ_QUEUE_FULL;
  1071. }
  1072. }
  1073. else
  1074. Connect_Response_Memory = NULL;
  1075. /*
  1076. * If everything is okay, then process the PDU. Note that the only way
  1077. * for there to be a problem at this point, is if the memory allocation
  1078. * above has failed. If this is the case, returning an error without
  1079. * processing the PDU will cause the transport layer to retry the PDU
  1080. * at a future time.
  1081. */
  1082. if (return_value == TRANSPORT_NO_ERROR)
  1083. {
  1084. /*
  1085. * Was the connection accepted by the remote side? If so, then begin
  1086. * the process of creating additional TCs (if necessary).
  1087. */
  1088. if (pdu_structure->result == RESULT_SUCCESSFUL)
  1089. {
  1090. /*
  1091. * Get the domain parameters that are to be used for this MCS
  1092. * connection.
  1093. */
  1094. memcpy (&Domain_Parameters, &(pdu_structure->domain_parameters),
  1095. sizeof(PDUDomainParameters));
  1096. /*
  1097. * Now that we know what the domain parameters will be for this
  1098. * connection, we can determine what type of encoding rules will
  1099. * be used for domain PDUs (basic or packed).
  1100. * NOTE: The Teles ASN.1 coder assumes the use of packed encoding rules.
  1101. */
  1102. ASSERT (Domain_Parameters.protocol_version != PROTOCOL_VERSION_BASIC);
  1103. TRACE_OUT (("Connection::ProcessConnectResponse: "
  1104. "using packed encoding rules"));
  1105. Encoding_Rules = PACKED_ENCODING_RULES;
  1106. /*
  1107. * Increment the number of transport connections that are now ready
  1108. * for domain MCSPDU traffic.
  1109. */
  1110. Transport_Connection_Count++;
  1111. /*
  1112. * If there is at least one additional TC required, then it is
  1113. * necessary to create it before this connection can be bound to
  1114. * the local domain.
  1115. */
  1116. if (Transport_Connection_Count < Domain_Parameters.number_priorities)
  1117. {
  1118. /*
  1119. * Loop through, creating the proper number of additional
  1120. * transport connections.
  1121. */
  1122. for (priority = Transport_Connection_Count;
  1123. priority < Domain_Parameters.number_priorities;
  1124. priority++)
  1125. {
  1126. /*
  1127. * Attempt to create an outbound transport connection.
  1128. */
  1129. transport_error = CreateTransportConnection (m_pszCalledAddress,
  1130. m_fSecure,
  1131. (Priority) priority);
  1132. if (transport_error == TRANSPORT_NO_ERROR)
  1133. {
  1134. /*
  1135. * If we were able to successfully request a new TC,
  1136. * then queue up a connect additional, which will
  1137. * automatically be sent when the TC becomes valid.
  1138. */
  1139. ConnectAdditional (
  1140. (UShort) pdu_structure->called_connect_id,
  1141. (Priority) priority);
  1142. }
  1143. else
  1144. {
  1145. /*
  1146. * If we were not able to create one of the required
  1147. * TCs, then this MCS connection is invalid. Issue
  1148. * a failed connect provider confirm.
  1149. */
  1150. IssueConnectProviderConfirm (
  1151. RESULT_UNSPECIFIED_FAILURE);
  1152. /*
  1153. * Its pointless to try and create any more TCs, so
  1154. * break out of this loop.
  1155. */
  1156. break;
  1157. }
  1158. }
  1159. }
  1160. else
  1161. {
  1162. /*
  1163. * If there are no more TCs to create, then copy the lowest
  1164. * priority TC into all unassigned priorities.
  1165. */
  1166. AssignRemainingTransportConnections ();
  1167. /*
  1168. * Bind this MCS connection to the domain, now that it is
  1169. * ready for use.
  1170. */
  1171. TRACE_OUT (("Connection::ProcessConnectResponse: "
  1172. "binding MCS connection to domain"));
  1173. m_pDomain = m_pPendingDomain;
  1174. m_pDomain->BindConnAttmnt(this, Upward_Connection, &Domain_Parameters);
  1175. /*
  1176. * Issue a successful connect provider confirm to the node
  1177. * controller.
  1178. */
  1179. IssueConnectProviderConfirm (RESULT_SUCCESSFUL);
  1180. }
  1181. }
  1182. else
  1183. {
  1184. /*
  1185. * This connection was rejected by the remote side. It is
  1186. * therefore necessary to issue a failed connect provider confirm.
  1187. */
  1188. IssueConnectProviderConfirm ((Result)pdu_structure->result);
  1189. }
  1190. }
  1191. return ((ULong) return_value);
  1192. }
  1193. /*
  1194. * Void ProcessConnectResult ()
  1195. *
  1196. * Private
  1197. *
  1198. * Functional Description:
  1199. * This routine processes "Connect Result" PDU's coming from the
  1200. * transport interface. For successful "Connect Result" PDU's this
  1201. * connection is bound to the domain and a positive Connect Provider
  1202. * Confirm issued to the controller. If unsuccessful, a negative
  1203. * Connect Provider Confirm is issued to the controller.
  1204. *
  1205. * Caveats:
  1206. * None.
  1207. */
  1208. Void Connection::ProcessConnectResult (PConnectResultPDU pdu_structure)
  1209. {
  1210. Result result;
  1211. result = (Result)pdu_structure->result;
  1212. /*
  1213. * Was the transport connection accepted by the remote system?
  1214. */
  1215. if (result == RESULT_SUCCESSFUL)
  1216. {
  1217. /*
  1218. * Increment the number of transport connections that are now ready
  1219. * for domain MCSPDU traffic.
  1220. */
  1221. Transport_Connection_Count++;
  1222. /*
  1223. * Do we now have all transport connections accounted for?
  1224. */
  1225. if (Transport_Connection_Count == Domain_Parameters.number_priorities)
  1226. {
  1227. /*
  1228. * If there are no more TCs to create, then copy the lowest
  1229. * priority TC into all unassigned priorities.
  1230. */
  1231. AssignRemainingTransportConnections ();
  1232. /*
  1233. * Bind this MCS connection to the domain, now that it is
  1234. * ready for use.
  1235. */
  1236. TRACE_OUT (("Connection::ProcessConnectResult: "
  1237. "binding MCS connection to domain"));
  1238. m_pDomain = m_pPendingDomain;
  1239. m_pDomain->BindConnAttmnt(this, Upward_Connection, &Domain_Parameters);
  1240. /*
  1241. * Issue a successful connect provider confirm to the node
  1242. * controller.
  1243. */
  1244. IssueConnectProviderConfirm (RESULT_SUCCESSFUL);
  1245. }
  1246. }
  1247. else
  1248. {
  1249. /*
  1250. * This connection was rejected by the remote side. It is
  1251. * therefore necessary to issue a failed connect provider confirm.
  1252. */
  1253. IssueConnectProviderConfirm (result);
  1254. }
  1255. }
  1256. /*
  1257. * Void IssueConnectProviderConfirm ()
  1258. *
  1259. * Private
  1260. *
  1261. * Functional Description:
  1262. * This routine is called in order to send a "Connect Provider Confirm"
  1263. * to the controller through a callback.
  1264. *
  1265. * Caveats:
  1266. * None.
  1267. */
  1268. Void Connection::IssueConnectProviderConfirm (
  1269. Result result)
  1270. {
  1271. ConnectConfirmInfo connect_confirm_info;
  1272. /*
  1273. * Make sure there is a confirm pending before issuing one to the
  1274. * controller.
  1275. */
  1276. if (Connect_Provider_Confirm_Pending)
  1277. {
  1278. /*
  1279. * Pack the information into the structure for passing in the owner
  1280. * callback.
  1281. */
  1282. ASSERT (g_Transport != NULL);
  1283. connect_confirm_info.domain_parameters = &Domain_Parameters;
  1284. connect_confirm_info.result = result;
  1285. connect_confirm_info.memory = Connect_Response_Memory;
  1286. /*
  1287. * Issue the callback to the controller.
  1288. */
  1289. TRACE_OUT (("Connection::IssueConnectProviderConfirm: "
  1290. "sending CONNECT_PROVIDER_CONFIRM"));
  1291. g_pMCSController->HandleConnConnectProviderConfirm(&connect_confirm_info, Connection_Handle);
  1292. /*
  1293. * If there was user data associated with this confirm, free the memory
  1294. * block that contained it.
  1295. */
  1296. if (Connect_Response_Memory != NULL)
  1297. {
  1298. FreeMemory (Connect_Response_Memory);
  1299. Connect_Response_Memory = NULL;
  1300. }
  1301. /*
  1302. * Reset the confirm pending flag, to prevent this object from sending
  1303. * a second confirm to the controller.
  1304. */
  1305. Connect_Provider_Confirm_Pending = FALSE;
  1306. }
  1307. }
  1308. /*
  1309. * Void DestroyConnection ()
  1310. *
  1311. * Private
  1312. *
  1313. * Functional Description:
  1314. * This routine is called in order to delete this connection because it has
  1315. * become invalid. This is done by issuing a failed confirm to the
  1316. * controller or, if no confirm is pending, by issuing a delete connection
  1317. * to the controller.
  1318. *
  1319. * Caveats:
  1320. * None.
  1321. */
  1322. Void Connection::DestroyConnection (
  1323. Reason reason)
  1324. {
  1325. Result result = RESULT_UNSPECIFIED_FAILURE;
  1326. /*
  1327. * Modify the Deletion_Reason to reflect why this connection is being
  1328. * destroyed.
  1329. */
  1330. Deletion_Reason = reason;
  1331. /*
  1332. * Something catastrophic has occurred, so we must ask the controller to
  1333. * delete this object. There are two possible ways of doing this
  1334. * (depending on circumstances). If a connect provider confirm is still
  1335. * pending, then we issue a failed confirm to the controller (who will
  1336. * forward it to the node controller and destroy this object). If there
  1337. * is not a confirm pending, then we simply issue a delete connection to
  1338. * the controller (who will issue a disconnect provider indication to the
  1339. * node controller and destroy this object).
  1340. */
  1341. if (Connect_Provider_Confirm_Pending)
  1342. {
  1343. /*
  1344. * Send the failed confirm to the controller.
  1345. */
  1346. switch (reason)
  1347. {
  1348. case REASON_REMOTE_NO_SECURITY :
  1349. result = RESULT_REMOTE_NO_SECURITY;
  1350. break;
  1351. case REASON_REMOTE_DOWNLEVEL_SECURITY :
  1352. result = RESULT_REMOTE_DOWNLEVEL_SECURITY;
  1353. break;
  1354. case REASON_REMOTE_REQUIRE_SECURITY :
  1355. result = RESULT_REMOTE_REQUIRE_SECURITY;
  1356. break;
  1357. case REASON_AUTHENTICATION_FAILED :
  1358. result = RESULT_AUTHENTICATION_FAILED;
  1359. break;
  1360. default :
  1361. result = RESULT_UNSPECIFIED_FAILURE;
  1362. break;
  1363. }
  1364. IssueConnectProviderConfirm (result);
  1365. }
  1366. else
  1367. {
  1368. ASSERT (g_Transport != NULL);
  1369. /*
  1370. * Issue a delete connection callback to the controller. When the
  1371. * controller deletes this object, it will correctly disconnect itself
  1372. * from the layers above and below, and clean up all outstanding
  1373. * resources.
  1374. */
  1375. TRACE_OUT (("Connection::DestroyConnection: sending DELETE_CONNECTION"));
  1376. g_pMCSController->HandleConnDeleteConnection(Connection_Handle);
  1377. }
  1378. }
  1379. /*
  1380. * Void AssignRemainingTransportConnections ()
  1381. *
  1382. * Private
  1383. *
  1384. * Functional Description:
  1385. * This routine is called when there are no more transport connections to
  1386. * create in order to copy the lowest priority transport connection into
  1387. * all unassigned priorities.
  1388. *
  1389. * Caveats:
  1390. * None.
  1391. */
  1392. Void Connection::AssignRemainingTransportConnections ()
  1393. {
  1394. unsigned int priority;
  1395. TransportConnection transport_connection;
  1396. /*
  1397. * Verify that this MCS connection is in the initializing state before
  1398. * proceeding with this request.
  1399. */
  1400. if (Transport_Connection_State[TOP_PRIORITY] == TRANSPORT_CONNECTION_READY)
  1401. {
  1402. /*
  1403. * Loop through for each priority, copying transport connections from
  1404. * higher priorities into lower priorities that do not have a
  1405. * transport connection assigned.
  1406. */
  1407. for (priority=0; priority < MAXIMUM_PRIORITIES; priority++)
  1408. {
  1409. if (Transport_Connection_State[priority] ==
  1410. TRANSPORT_CONNECTION_READY)
  1411. transport_connection = Transport_Connection[priority];
  1412. else
  1413. {
  1414. Transport_Connection[priority] = transport_connection;
  1415. Transport_Connection_PDU_Type[priority] = DOMAIN_MCS_PDU;
  1416. Transport_Connection_State[priority] =
  1417. TRANSPORT_CONNECTION_READY;
  1418. }
  1419. }
  1420. /*
  1421. * Set the flag indicating that the transmission of domain PDUs is
  1422. * now permitted on this MCS connection. Also, flush any queued msgs
  1423. * in case they were prevented earlier.
  1424. * bugbug: the FlushMessageQueue may fail.
  1425. */
  1426. Domain_Traffic_Allowed = TRUE;
  1427. FlushMessageQueue ();
  1428. }
  1429. else
  1430. {
  1431. /*
  1432. * We have no valid transport connections. It is therefore not
  1433. * possible to bind to the domain.
  1434. */
  1435. WARNING_OUT (("Connection::AssignRemainingTransportConnections: "
  1436. "no valid transport connections"));
  1437. }
  1438. }
  1439. /*
  1440. * TransportError CreateTransportConnection ()
  1441. *
  1442. * Private
  1443. *
  1444. * Functional Description:
  1445. * This routine is called in order to create new transport connections.
  1446. *
  1447. * Caveats:
  1448. * None.
  1449. */
  1450. TransportError Connection::CreateTransportConnection (
  1451. LPCTSTR called_address,
  1452. BOOL fSecure,
  1453. Priority priority)
  1454. {
  1455. TransportConnection transport_connection;
  1456. TransportError transport_error;
  1457. /*
  1458. * Send a connect request to the transport layer to create the transport
  1459. * connection.
  1460. */
  1461. ASSERT(g_Transport != NULL);
  1462. transport_error = g_Transport->ConnectRequest (
  1463. (PChar) called_address, fSecure, priority < MEDIUM_PRIORITY, this,
  1464. &transport_connection);
  1465. if (transport_error == TRANSPORT_NO_ERROR)
  1466. {
  1467. /*
  1468. * Mark the transport connection as pending, which indicates that
  1469. * it has been assigned, but is not yet ready for use. This will
  1470. * be set to ready when a successsful confirm is received from the
  1471. * transport layer.
  1472. */
  1473. Transport_Connection[priority] = transport_connection;
  1474. Transport_Connection_PDU_Type[priority] = CONNECT_MCS_PDU;
  1475. Transport_Connection_State[priority] = TRANSPORT_CONNECTION_PENDING;
  1476. }
  1477. else
  1478. {
  1479. /*
  1480. * The call to the transport layer failed. Report the error to the
  1481. * diagnostic window, and let the error fall through.
  1482. */
  1483. WARNING_OUT (("Connection::CreateTransportConnection: "
  1484. "connect request failed"));
  1485. }
  1486. return (transport_error);
  1487. }
  1488. /*
  1489. * TransportError AcceptTransportConnection ()
  1490. *
  1491. * Private
  1492. *
  1493. * Functional Description:
  1494. * This routine is called in order to register this connection object
  1495. * with the transport interface.
  1496. *
  1497. * Caveats:
  1498. * None.
  1499. */
  1500. TransportError Connection::AcceptTransportConnection (
  1501. TransportConnection transport_connection,
  1502. Priority priority)
  1503. {
  1504. TransportError transport_error;
  1505. /*
  1506. * Attempt to register this object with the transport interface. If
  1507. * successful, all indications associated with this transport connection
  1508. * will be sent directly to this object.
  1509. */
  1510. ASSERT(g_Transport != NULL);
  1511. transport_error = g_Transport->RegisterTransportConnection (
  1512. transport_connection, this, priority < MEDIUM_PRIORITY);
  1513. if (transport_error == TRANSPORT_NO_ERROR)
  1514. {
  1515. /*
  1516. * Save the transport connection handle that we are supposed to use
  1517. * for top priority data transfer. Also, since this is an inbound
  1518. * request, the top priority transport connection IS valid. Mark
  1519. * it as such, allowing data transfer to occur immediately.
  1520. */
  1521. Transport_Connection[priority] = transport_connection;
  1522. Transport_Connection_PDU_Type[priority] = DOMAIN_MCS_PDU;
  1523. Transport_Connection_State[priority] = TRANSPORT_CONNECTION_READY;
  1524. Transport_Connection_Count++;
  1525. }
  1526. else
  1527. {
  1528. /*
  1529. * The call to the transport layer failed. Report the error to the
  1530. * diagnostic window, and let the error fall through.
  1531. */
  1532. WARNING_OUT (("Connection::AcceptTransportConnection: "
  1533. "invalid transport connection"));
  1534. }
  1535. return (transport_error);
  1536. }
  1537. /*
  1538. * Void AdjustDomainParameters ()
  1539. *
  1540. * Private
  1541. *
  1542. * Functional Description:
  1543. * This routine is called in order to adjust the domain parameters so that
  1544. * they fall within the allowable range.
  1545. *
  1546. * Caveats:
  1547. * None.
  1548. */
  1549. Void Connection::AdjustDomainParameters (
  1550. PDomainParameters min_domain_parameters,
  1551. PDomainParameters max_domain_parameters,
  1552. PDomainParameters domain_parameters)
  1553. {
  1554. /*
  1555. * Adjust the maximum number of channels to fall within the range.
  1556. */
  1557. if (domain_parameters->max_channel_ids <
  1558. min_domain_parameters->max_channel_ids)
  1559. domain_parameters->max_channel_ids =
  1560. min_domain_parameters->max_channel_ids;
  1561. else if (domain_parameters->max_channel_ids >
  1562. max_domain_parameters->max_channel_ids)
  1563. domain_parameters->max_channel_ids =
  1564. max_domain_parameters->max_channel_ids;
  1565. /*
  1566. * Adjust the maximum number of users to fall within the range.
  1567. */
  1568. if (domain_parameters->max_user_ids <
  1569. min_domain_parameters->max_user_ids)
  1570. domain_parameters->max_user_ids =
  1571. min_domain_parameters->max_user_ids;
  1572. else if (domain_parameters->max_user_ids >
  1573. max_domain_parameters->max_user_ids)
  1574. domain_parameters->max_user_ids =
  1575. max_domain_parameters->max_user_ids;
  1576. /*
  1577. * Adjust the maximum number of tokens to fall within the range.
  1578. */
  1579. if (domain_parameters->max_token_ids <
  1580. min_domain_parameters->max_token_ids)
  1581. domain_parameters->max_token_ids =
  1582. min_domain_parameters->max_token_ids;
  1583. else if (domain_parameters->max_token_ids >
  1584. max_domain_parameters->max_token_ids)
  1585. domain_parameters->max_token_ids =
  1586. max_domain_parameters->max_token_ids;
  1587. /*
  1588. * Adjust the number of priorities to fall within the range.
  1589. */
  1590. if (domain_parameters->number_priorities <
  1591. min_domain_parameters->number_priorities)
  1592. domain_parameters->number_priorities =
  1593. min_domain_parameters->number_priorities;
  1594. else if (domain_parameters->number_priorities >
  1595. max_domain_parameters->number_priorities)
  1596. domain_parameters->number_priorities =
  1597. max_domain_parameters->number_priorities;
  1598. /*
  1599. * Adjust the minimum throughput to fall within the range.
  1600. */
  1601. if (domain_parameters->min_throughput <
  1602. min_domain_parameters->min_throughput)
  1603. domain_parameters->min_throughput =
  1604. min_domain_parameters->min_throughput;
  1605. else if (domain_parameters->min_throughput >
  1606. max_domain_parameters->min_throughput)
  1607. domain_parameters->min_throughput =
  1608. max_domain_parameters->min_throughput;
  1609. /*
  1610. * Adjust the maximum domain height to fall within the range.
  1611. */
  1612. if (domain_parameters->max_height <
  1613. min_domain_parameters->max_height)
  1614. domain_parameters->max_height =
  1615. min_domain_parameters->max_height;
  1616. else if (domain_parameters->max_height >
  1617. max_domain_parameters->max_height)
  1618. domain_parameters->max_height =
  1619. max_domain_parameters->max_height;
  1620. /*
  1621. * Adjust the maximum PDU size to fall within the range.
  1622. */
  1623. if (domain_parameters->max_mcspdu_size <
  1624. min_domain_parameters->max_mcspdu_size)
  1625. domain_parameters->max_mcspdu_size =
  1626. min_domain_parameters->max_mcspdu_size;
  1627. else if (domain_parameters->max_mcspdu_size >
  1628. max_domain_parameters->max_mcspdu_size)
  1629. domain_parameters->max_mcspdu_size =
  1630. max_domain_parameters->max_mcspdu_size;
  1631. /*
  1632. * Adjust the protocol version to fall within the range.
  1633. */
  1634. if (domain_parameters->protocol_version <
  1635. min_domain_parameters->protocol_version)
  1636. domain_parameters->protocol_version =
  1637. min_domain_parameters->protocol_version;
  1638. else if (domain_parameters->protocol_version >
  1639. max_domain_parameters->protocol_version)
  1640. domain_parameters->protocol_version =
  1641. max_domain_parameters->protocol_version;
  1642. }
  1643. /*
  1644. * BOOL MergeDomainParameters ()
  1645. *
  1646. * Private
  1647. *
  1648. * Functional Description:
  1649. * This routine is called in order to calculate the optimum overlap
  1650. * between the local and remote domain parameters. If there is no overlap,
  1651. * this routine will return a value causing this connection to be
  1652. * destroyed.
  1653. *
  1654. * Caveats:
  1655. * None.
  1656. */
  1657. BOOL Connection::MergeDomainParameters (
  1658. PDomainParameters min_domain_parameters1,
  1659. PDomainParameters max_domain_parameters1,
  1660. PDomainParameters min_domain_parameters2,
  1661. PDomainParameters max_domain_parameters2)
  1662. {
  1663. BOOL valid=TRUE;
  1664. /*
  1665. * Determine the overlap for maximum number of channels. If there is no
  1666. * overlap, set the valid flag to FALSE.
  1667. */
  1668. if (min_domain_parameters2->max_channel_ids <
  1669. min_domain_parameters1->max_channel_ids)
  1670. min_domain_parameters2->max_channel_ids =
  1671. min_domain_parameters1->max_channel_ids;
  1672. if (max_domain_parameters2->max_channel_ids >
  1673. max_domain_parameters1->max_channel_ids)
  1674. max_domain_parameters2->max_channel_ids =
  1675. max_domain_parameters1->max_channel_ids;
  1676. if (min_domain_parameters2->max_channel_ids >
  1677. max_domain_parameters2->max_channel_ids)
  1678. valid = FALSE;
  1679. /*
  1680. * Determine the overlap for maximum number of users. If there is no
  1681. * overlap, set the valid flag to FALSE.
  1682. */
  1683. if (min_domain_parameters2->max_user_ids <
  1684. min_domain_parameters1->max_user_ids)
  1685. min_domain_parameters2->max_user_ids =
  1686. min_domain_parameters1->max_user_ids;
  1687. if (max_domain_parameters2->max_user_ids >
  1688. max_domain_parameters1->max_user_ids)
  1689. max_domain_parameters2->max_user_ids =
  1690. max_domain_parameters1->max_user_ids;
  1691. if (min_domain_parameters2->max_user_ids >
  1692. max_domain_parameters2->max_user_ids)
  1693. valid = FALSE;
  1694. /*
  1695. * Determine the overlap for maximum number of tokens. If there is no
  1696. * overlap, set the valid flag to FALSE.
  1697. */
  1698. if (min_domain_parameters2->max_token_ids <
  1699. min_domain_parameters1->max_token_ids)
  1700. min_domain_parameters2->max_token_ids =
  1701. min_domain_parameters1->max_token_ids;
  1702. if (max_domain_parameters2->max_token_ids >
  1703. max_domain_parameters1->max_token_ids)
  1704. max_domain_parameters2->max_token_ids =
  1705. max_domain_parameters1->max_token_ids;
  1706. if (min_domain_parameters2->max_token_ids >
  1707. max_domain_parameters2->max_token_ids)
  1708. valid = FALSE;
  1709. /*
  1710. * Determine the overlap for number of priorities. If there is no
  1711. * overlap, set the valid flag to FALSE.
  1712. */
  1713. if (min_domain_parameters2->number_priorities <
  1714. min_domain_parameters1->number_priorities)
  1715. min_domain_parameters2->number_priorities =
  1716. min_domain_parameters1->number_priorities;
  1717. if (max_domain_parameters2->number_priorities >
  1718. max_domain_parameters1->number_priorities)
  1719. max_domain_parameters2->number_priorities =
  1720. max_domain_parameters1->number_priorities;
  1721. if (min_domain_parameters2->number_priorities >
  1722. max_domain_parameters2->number_priorities)
  1723. valid = FALSE;
  1724. /*
  1725. * Determine the overlap for minimum throughput. If there is no
  1726. * overlap, set the valid flag to FALSE.
  1727. */
  1728. if (min_domain_parameters2->min_throughput <
  1729. min_domain_parameters1->min_throughput)
  1730. min_domain_parameters2->min_throughput =
  1731. min_domain_parameters1->min_throughput;
  1732. if (max_domain_parameters2->min_throughput >
  1733. max_domain_parameters1->min_throughput)
  1734. max_domain_parameters2->min_throughput =
  1735. max_domain_parameters1->min_throughput;
  1736. if (min_domain_parameters2->min_throughput >
  1737. max_domain_parameters2->min_throughput)
  1738. valid = FALSE;
  1739. /*
  1740. * Determine the overlap for maximum domain height. If there is no
  1741. * overlap, set the valid flag to FALSE.
  1742. */
  1743. if (min_domain_parameters2->max_height <
  1744. min_domain_parameters1->max_height)
  1745. min_domain_parameters2->max_height =
  1746. min_domain_parameters1->max_height;
  1747. if (max_domain_parameters2->max_height >
  1748. max_domain_parameters1->max_height)
  1749. max_domain_parameters2->max_height =
  1750. max_domain_parameters1->max_height;
  1751. if (min_domain_parameters2->max_height >
  1752. max_domain_parameters2->max_height)
  1753. valid = FALSE;
  1754. /*
  1755. * Determine the overlap for maximum PDU size. If there is no
  1756. * overlap, set the valid flag to FALSE.
  1757. */
  1758. if (min_domain_parameters2->max_mcspdu_size <
  1759. min_domain_parameters1->max_mcspdu_size)
  1760. min_domain_parameters2->max_mcspdu_size =
  1761. min_domain_parameters1->max_mcspdu_size;
  1762. if (max_domain_parameters2->max_mcspdu_size >
  1763. max_domain_parameters1->max_mcspdu_size)
  1764. max_domain_parameters2->max_mcspdu_size =
  1765. max_domain_parameters1->max_mcspdu_size;
  1766. if (min_domain_parameters2->max_mcspdu_size >
  1767. max_domain_parameters2->max_mcspdu_size)
  1768. valid = FALSE;
  1769. /*
  1770. * Determine the overlap for protocol version. If there is no
  1771. * overlap, set the valid flag to FALSE.
  1772. */
  1773. if (min_domain_parameters2->protocol_version <
  1774. min_domain_parameters1->protocol_version)
  1775. min_domain_parameters2->protocol_version =
  1776. min_domain_parameters1->protocol_version;
  1777. if (max_domain_parameters2->protocol_version >
  1778. max_domain_parameters1->protocol_version)
  1779. max_domain_parameters2->protocol_version =
  1780. max_domain_parameters1->protocol_version;
  1781. if (min_domain_parameters2->protocol_version >
  1782. max_domain_parameters2->protocol_version)
  1783. valid = FALSE;
  1784. return (valid);
  1785. }
  1786. /*
  1787. * Void PrintDomainParameters ()
  1788. *
  1789. * Private
  1790. *
  1791. * Functional Description:
  1792. * This routine is used for debug purposes in order to print out the
  1793. * current set of domain parameters.
  1794. *
  1795. * Caveats:
  1796. * None.
  1797. */
  1798. #ifdef DEBUG
  1799. Void Connection::PrintDomainParameters (
  1800. PDomainParameters domain_parameters)
  1801. {
  1802. TRACE_OUT ((" Maximum Channels = %ld",
  1803. (ULong) domain_parameters->max_channel_ids));
  1804. TRACE_OUT ((" Maximum Users = %ld",
  1805. (ULong) domain_parameters->max_user_ids));
  1806. TRACE_OUT ((" Maximum Tokens = %ld",
  1807. (ULong) domain_parameters->max_token_ids));
  1808. TRACE_OUT ((" Number of Priorities = %ld",
  1809. (ULong) domain_parameters->number_priorities));
  1810. TRACE_OUT ((" Minimum Throughput = %ld",
  1811. (ULong) domain_parameters->min_throughput));
  1812. TRACE_OUT ((" Maximum Domain Height = %ld",
  1813. (ULong) domain_parameters->max_height));
  1814. TRACE_OUT ((" Maximum PDU Size = %ld",
  1815. (ULong) domain_parameters->max_mcspdu_size));
  1816. TRACE_OUT ((" Protocol Version = %ld",
  1817. (ULong) domain_parameters->protocol_version));
  1818. }
  1819. #endif // DEBUG
  1820. /*
  1821. * Void PlumbDomainIndication ()
  1822. *
  1823. * Public
  1824. *
  1825. * Functional Description:
  1826. * This routine is called by the domain in order to send a
  1827. * "PlumbDomainIndication" PDU through the transport interface.
  1828. *
  1829. * Caveats:
  1830. * None.
  1831. */
  1832. Void Connection::PlumbDomainIndication (
  1833. ULong height_limit)
  1834. {
  1835. DomainMCSPDU plumb_domain_indication_pdu;
  1836. /*
  1837. * Fill in the PDU structure to be encoded.
  1838. */
  1839. plumb_domain_indication_pdu.choice = PLUMB_DOMAIN_INDICATION_CHOSEN;
  1840. plumb_domain_indication_pdu.u.plumb_domain_indication.height_limit =
  1841. height_limit;
  1842. /*
  1843. * Send the packet to the remote provider.
  1844. */
  1845. SendPacket ((PVoid) &plumb_domain_indication_pdu, DOMAIN_MCS_PDU,
  1846. TOP_PRIORITY);
  1847. }
  1848. /*
  1849. * Void ErectDomainRequest ()
  1850. *
  1851. * Public
  1852. *
  1853. * Functional Description:
  1854. * This routine is called by the domain in order to send a
  1855. * "ErectDomainRequest" PDU through the transport interface.
  1856. *
  1857. * Caveats:
  1858. * None.
  1859. */
  1860. Void Connection::ErectDomainRequest (
  1861. ULong height_in_domain,
  1862. ULong throughput_interval)
  1863. {
  1864. DomainMCSPDU erect_domain_request_pdu;
  1865. /*
  1866. * Fill in the PDU structure to be encoded.
  1867. */
  1868. erect_domain_request_pdu.choice = ERECT_DOMAIN_REQUEST_CHOSEN;
  1869. erect_domain_request_pdu.u.erect_domain_request.sub_height =
  1870. height_in_domain;
  1871. erect_domain_request_pdu.u.erect_domain_request.sub_interval =
  1872. throughput_interval;
  1873. /*
  1874. * Send the packet to the remote provider.
  1875. */
  1876. SendPacket ((PVoid) &erect_domain_request_pdu, DOMAIN_MCS_PDU,
  1877. TOP_PRIORITY);
  1878. }
  1879. /*
  1880. * Void RejectUltimatum ()
  1881. *
  1882. * Public
  1883. *
  1884. * Functional Description:
  1885. * This routine is called by the domain in order to send a
  1886. * "RejectUltimatum" PDU through the transport interface.
  1887. *
  1888. * Caveats:
  1889. * None.
  1890. */
  1891. Void Connection::RejectUltimatum (
  1892. Diagnostic diagnostic,
  1893. PUChar octet_string_address,
  1894. ULong octet_string_length)
  1895. {
  1896. DomainMCSPDU reject_ultimatum_pdu;
  1897. /*
  1898. * Fill in the PDU structure to be encoded.
  1899. */
  1900. reject_ultimatum_pdu.choice = REJECT_ULTIMATUM_CHOSEN;
  1901. reject_ultimatum_pdu.u.reject_user_ultimatum.diagnostic = diagnostic;
  1902. reject_ultimatum_pdu.u.reject_user_ultimatum.initial_octets.length =
  1903. (UShort) octet_string_length;
  1904. reject_ultimatum_pdu.u.reject_user_ultimatum.initial_octets.value =
  1905. octet_string_address;
  1906. /*
  1907. * Send the packet to the remote provider.
  1908. */
  1909. SendPacket ((PVoid) &reject_ultimatum_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  1910. }
  1911. /*
  1912. * Void MergeChannelsRequest ()
  1913. *
  1914. * Public
  1915. *
  1916. * Functional Description:
  1917. * This routine is called by the domain in order to send a
  1918. * "MergeChannelsRequest" PDU through the transport interface.
  1919. *
  1920. * Caveats:
  1921. * None.
  1922. */
  1923. Void Connection::MergeChannelsRequest (
  1924. CChannelAttributesList *merge_channel_list,
  1925. CChannelIDList *purge_channel_list)
  1926. {
  1927. MergeChannelsRC (MERGE_CHANNELS_REQUEST_CHOSEN, merge_channel_list, purge_channel_list);
  1928. }
  1929. /*
  1930. * Void MergeChannelsConfirm ()
  1931. *
  1932. * Public
  1933. *
  1934. * Functional Description:
  1935. * This routine is called by the domain in order to send a
  1936. * "MergeChannelsConfirm" PDU through the transport interface.
  1937. *
  1938. * Caveats:
  1939. * None.
  1940. */
  1941. Void Connection::MergeChannelsConfirm (
  1942. CChannelAttributesList *merge_channel_list,
  1943. CChannelIDList *purge_channel_list)
  1944. {
  1945. MergeChannelsRC (MERGE_CHANNELS_CONFIRM_CHOSEN, merge_channel_list, purge_channel_list);
  1946. }
  1947. /*
  1948. * Void MergeChannelsRC ()
  1949. *
  1950. * Public
  1951. *
  1952. * Functional Description:
  1953. * This routine is called by the domain in order to send a
  1954. * "MergeChannelsRequest" or a "MergeChannelsConfirm" PDU
  1955. * through the transport interface.
  1956. *
  1957. * IMPORTANT:
  1958. * Since the code is used for both PDUs the DomainMCSPDU's
  1959. * merge_channels_request and merge_channels_confirm fields should
  1960. * be identical structures.
  1961. *
  1962. * Caveats:
  1963. * None.
  1964. */
  1965. Void Connection::MergeChannelsRC (
  1966. ASN1choice_t choice,
  1967. CChannelAttributesList *merge_channel_list,
  1968. CChannelIDList *purge_channel_list)
  1969. {
  1970. BOOL memory_error = FALSE;
  1971. DomainMCSPDU merge_channels_pdu;
  1972. DWORD channel_attributes_count;
  1973. PSetOfPDUChannelAttributes setof_channel_attributes;
  1974. PChannelAttributes channel_attributes;
  1975. PSetOfUserIDs user_ids_pointer;
  1976. DWORD purge_channel_count;
  1977. PSetOfChannelIDs channel_ids_pointer;
  1978. DWORD dwMemoryToAlloc;
  1979. CUidList *user_admit_list;
  1980. /*
  1981. * Set the type of PDU to be encoded.
  1982. */
  1983. merge_channels_pdu.choice = choice;
  1984. /*
  1985. * Determine how many channel attributes entries there are in the lists.
  1986. * If there are any entries, allocate memory to hold the associated
  1987. * structures.
  1988. */
  1989. channel_attributes_count = merge_channel_list->GetCount();
  1990. purge_channel_count = purge_channel_list->GetCount();
  1991. if ((channel_attributes_count != 0) || (purge_channel_count != 0)) {
  1992. // Determine how much memory we need to allocate
  1993. dwMemoryToAlloc = channel_attributes_count * sizeof (SetOfPDUChannelAttributes) +
  1994. purge_channel_count * sizeof (SetOfChannelIDs);
  1995. merge_channel_list->Reset();
  1996. while (NULL != (channel_attributes = merge_channel_list->Iterate()))
  1997. {
  1998. if (PRIVATE_CHANNEL == channel_attributes->channel_type) {
  1999. dwMemoryToAlloc += sizeof (SetOfUserIDs) *
  2000. (channel_attributes->u.
  2001. private_channel_attributes.admitted_list)->GetCount();
  2002. }
  2003. }
  2004. // Allocate the needed amount of memory.
  2005. DBG_SAVE_FILE_LINE
  2006. setof_channel_attributes = (PSetOfPDUChannelAttributes) Allocate (dwMemoryToAlloc);
  2007. if (setof_channel_attributes == NULL) {
  2008. memory_error = TRUE;
  2009. }
  2010. }
  2011. else {
  2012. setof_channel_attributes = NULL;
  2013. }
  2014. if (setof_channel_attributes == NULL) {
  2015. merge_channels_pdu.u.merge_channels_request.purge_channel_ids = NULL;
  2016. merge_channels_pdu.u.merge_channels_request.merge_channels = NULL;
  2017. }
  2018. else {
  2019. /*
  2020. * Get the base address of the array of SetOfChannelIDs structures.
  2021. */
  2022. channel_ids_pointer = (PSetOfChannelIDs) (((PUChar) setof_channel_attributes) +
  2023. channel_attributes_count * sizeof (SetOfPDUChannelAttributes));
  2024. if (channel_attributes_count != 0) {
  2025. /*
  2026. * Get the base address of the array of SetOfPDUChannelAttributes
  2027. * structures. Put it into the PDU structure.
  2028. */
  2029. merge_channels_pdu.u.merge_channels_request.merge_channels =
  2030. setof_channel_attributes;
  2031. /*
  2032. * Get the base address of the array of SetOfUserIDs structures.
  2033. */
  2034. user_ids_pointer = (PSetOfUserIDs) (((PUChar) channel_ids_pointer) +
  2035. purge_channel_count * sizeof (SetOfChannelIDs));
  2036. /*
  2037. * Set up an iterator for the list of channel attributes. Retrieve
  2038. * the channel attributes structures from the list and construct the
  2039. * PDU structure.
  2040. */
  2041. merge_channel_list->Reset();
  2042. while (NULL != (channel_attributes = merge_channel_list->Iterate()))
  2043. {
  2044. /*
  2045. * Use the channel type to determine what information to include in
  2046. * the PDU structure.
  2047. */
  2048. switch (channel_attributes->channel_type)
  2049. {
  2050. case STATIC_CHANNEL:
  2051. setof_channel_attributes->value.choice =
  2052. CHANNEL_ATTRIBUTES_STATIC_CHOSEN;
  2053. setof_channel_attributes->value.u.
  2054. channel_attributes_static.channel_id =
  2055. channel_attributes->u.
  2056. static_channel_attributes.channel_id;
  2057. break;
  2058. case USER_CHANNEL:
  2059. setof_channel_attributes->value.choice =
  2060. CHANNEL_ATTRIBUTES_USER_ID_CHOSEN;
  2061. setof_channel_attributes->value.u.
  2062. channel_attributes_user_id.joined =
  2063. (ASN1bool_t)channel_attributes->u.
  2064. user_channel_attributes.joined;
  2065. setof_channel_attributes->value.u.
  2066. channel_attributes_user_id.user_id =
  2067. channel_attributes->u.
  2068. user_channel_attributes.user_id;
  2069. break;
  2070. case PRIVATE_CHANNEL:
  2071. setof_channel_attributes->value.choice =
  2072. CHANNEL_ATTRIBUTES_PRIVATE_CHOSEN;
  2073. setof_channel_attributes->value.u.
  2074. channel_attributes_private.joined =
  2075. (ASN1bool_t)channel_attributes->u.
  2076. private_channel_attributes.joined;
  2077. setof_channel_attributes->value.u.
  2078. channel_attributes_private.channel_id =
  2079. channel_attributes->u.
  2080. private_channel_attributes.channel_id;
  2081. setof_channel_attributes->value.u.
  2082. channel_attributes_private.manager =
  2083. channel_attributes->u.
  2084. private_channel_attributes.channel_manager;
  2085. /*
  2086. * Get the number of the User IDs in the list of user ID's
  2087. */
  2088. if ((channel_attributes->u.private_channel_attributes.
  2089. admitted_list)->GetCount() > 0)
  2090. {
  2091. /*
  2092. * Get the base address of the array of SetOfUserIDs
  2093. * structures. Put it into the channel attributes
  2094. * structure.
  2095. */
  2096. setof_channel_attributes->value.u.channel_attributes_private.admitted =
  2097. user_ids_pointer;
  2098. /*
  2099. * Iterate through the set of user ids, filling in the
  2100. * PDU structure.
  2101. */
  2102. user_admit_list = channel_attributes->u.private_channel_attributes.admitted_list;
  2103. user_admit_list->BuildExternalList(&user_ids_pointer);
  2104. }
  2105. else
  2106. {
  2107. /*
  2108. * There are either no users admitted to this channel,
  2109. * or a memory allocation error occurred above.
  2110. * Either way, we need to set the admitted array
  2111. * address to NULL.
  2112. */
  2113. setof_channel_attributes->value.u.
  2114. channel_attributes_private.admitted = NULL;
  2115. }
  2116. break;
  2117. case ASSIGNED_CHANNEL:
  2118. setof_channel_attributes->value.choice =
  2119. CHANNEL_ATTRIBUTES_ASSIGNED_CHOSEN;
  2120. setof_channel_attributes->value.u.
  2121. channel_attributes_assigned.channel_id =
  2122. channel_attributes->u.
  2123. assigned_channel_attributes.channel_id;
  2124. break;
  2125. default:
  2126. WARNING_OUT(("Connection::MergeChannelsRC: "
  2127. "ERROR - bad channel type"));
  2128. break;
  2129. }
  2130. /*
  2131. * Set the next pointer to point to the next element of the
  2132. * PDU channel attributes structure array. Then increment the
  2133. * pointer.
  2134. */
  2135. setof_channel_attributes->next = setof_channel_attributes + 1;
  2136. setof_channel_attributes++;
  2137. }
  2138. /*
  2139. * Decrement the pointer in order to set the last "next" pointer to
  2140. * NULL.
  2141. */
  2142. (setof_channel_attributes - 1)->next = NULL;
  2143. }
  2144. else {
  2145. /* There are no channels to merge. We need to set the structure
  2146. * array address to NULL.
  2147. */
  2148. merge_channels_pdu.u.merge_channels_request.merge_channels = NULL;
  2149. }
  2150. // Work on the purged channels.
  2151. if (purge_channel_count != 0) {
  2152. /*
  2153. * Get the base address of the array of SetOfChannelIDs structures.
  2154. * Put it into the PDU structure.
  2155. */
  2156. merge_channels_pdu.u.merge_channels_request.purge_channel_ids = channel_ids_pointer;
  2157. purge_channel_list->BuildExternalList(&channel_ids_pointer);
  2158. }
  2159. else
  2160. {
  2161. /*
  2162. * There are either no channels to purge or a memory allocation
  2163. * failure occurred above. Either way, we need to set the structure
  2164. * array address to NULL.
  2165. */
  2166. merge_channels_pdu.u.merge_channels_request.purge_channel_ids = NULL;
  2167. }
  2168. }
  2169. /*
  2170. * Send the packet to the remote provider.
  2171. */
  2172. if (memory_error == FALSE)
  2173. SendPacket ((PVoid) &merge_channels_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  2174. else
  2175. {
  2176. /*
  2177. * A memory allocation failure occurred somewhere above. Report the
  2178. * error and destroy this faulty connection.
  2179. */
  2180. ERROR_OUT (("Connection::MergeChannelsRC: memory allocation failure"));
  2181. DestroyConnection (REASON_PROVIDER_INITIATED);
  2182. }
  2183. /*
  2184. * Free up the memory block that was allocated to build this PDU
  2185. * structure.
  2186. */
  2187. Free(setof_channel_attributes - channel_attributes_count);
  2188. }
  2189. /*
  2190. * Void PurgeChannelsIndication ()
  2191. *
  2192. * Public
  2193. *
  2194. * Functional Description:
  2195. * This routine is called by the domain in order to send a
  2196. * "PurgeChannelsIndication" PDU through the transport interface.
  2197. *
  2198. * Caveats:
  2199. * None.
  2200. */
  2201. Void Connection::PurgeChannelsIndication (
  2202. CUidList *purge_user_list,
  2203. CChannelIDList *purge_channel_list)
  2204. {
  2205. BOOL memory_error = FALSE;
  2206. DomainMCSPDU purge_channel_indication_pdu;
  2207. ULong user_id_count;
  2208. PSetOfUserIDs user_ids_pointer;
  2209. DWORD purge_channel_count;
  2210. PSetOfChannelIDs channel_ids_pointer;
  2211. /*
  2212. * Fill in the PDU structure to be encoded.
  2213. */
  2214. purge_channel_indication_pdu.choice = PURGE_CHANNEL_INDICATION_CHOSEN;
  2215. /*
  2216. * Allocate memory to hold the list of user ID's and the list
  2217. * of purged channels. If the allocation
  2218. * fails, set the flag which will result in a callback to the
  2219. * controller requesting that this connection be deleted.
  2220. */
  2221. user_id_count = purge_user_list->GetCount();
  2222. purge_channel_count = purge_channel_list->GetCount();
  2223. if (user_id_count != 0 || purge_channel_count != 0)
  2224. {
  2225. DBG_SAVE_FILE_LINE
  2226. user_ids_pointer = (PSetOfUserIDs) Allocate (user_id_count * sizeof (SetOfUserIDs) +
  2227. purge_channel_count * sizeof (SetOfChannelIDs));
  2228. if (user_ids_pointer == NULL) {
  2229. memory_error = TRUE;
  2230. }
  2231. }
  2232. else
  2233. user_ids_pointer = NULL;
  2234. if (user_ids_pointer == NULL) {
  2235. purge_channel_indication_pdu.u.purge_channel_indication.detach_user_ids = NULL;
  2236. purge_channel_indication_pdu.u.purge_channel_indication.purge_channel_ids = NULL;
  2237. }
  2238. else {
  2239. if (user_id_count != 0) {
  2240. /*
  2241. * Fill in the structure's pointer to the set of user ID's.
  2242. */
  2243. purge_channel_indication_pdu.u.purge_channel_indication.detach_user_ids = user_ids_pointer;
  2244. purge_user_list->BuildExternalList(&user_ids_pointer);
  2245. }
  2246. else
  2247. {
  2248. /*
  2249. * Either there are no user IDs to purge or a memory allocation
  2250. * failed above. Either way, put NULL into the PDU structure to
  2251. * indicate that there is no list of IDs.
  2252. */
  2253. purge_channel_indication_pdu.u.purge_channel_indication.
  2254. detach_user_ids = NULL;
  2255. }
  2256. if (purge_channel_count != 0) {
  2257. /*
  2258. * Fill in the structure's pointer to the set of purge channel ID's.
  2259. */
  2260. channel_ids_pointer = (PSetOfChannelIDs) user_ids_pointer;
  2261. purge_channel_indication_pdu.u.purge_channel_indication.purge_channel_ids = channel_ids_pointer;
  2262. purge_channel_list->BuildExternalList(&channel_ids_pointer);
  2263. }
  2264. else
  2265. {
  2266. /*
  2267. * Either there are no channel IDs to purge or a memory allocation
  2268. * failed above. Either way, put NULL into the PDU structure to
  2269. * indicate that there is no list of IDs.
  2270. */
  2271. purge_channel_indication_pdu.u.purge_channel_indication.purge_channel_ids = NULL;
  2272. }
  2273. }
  2274. /*
  2275. * Send the packet to the remote provider.
  2276. */
  2277. if (memory_error == FALSE)
  2278. SendPacket ((PVoid) &purge_channel_indication_pdu, DOMAIN_MCS_PDU,
  2279. TOP_PRIORITY);
  2280. else
  2281. {
  2282. /*
  2283. * A memory allocation failure occurred somewhere above. Report the
  2284. * error and destroy this faulty connection.
  2285. */
  2286. ERROR_OUT (("Connection::PurgeChannelsIndication: "
  2287. "memory allocation failure"));
  2288. DestroyConnection (REASON_PROVIDER_INITIATED);
  2289. }
  2290. /*
  2291. * Free all memory allocated above.
  2292. */
  2293. Free(user_ids_pointer - user_id_count);
  2294. }
  2295. /*
  2296. * Void MergeTokenRequest ()
  2297. *
  2298. * Public
  2299. *
  2300. * Functional Description:
  2301. * This routine is called by the domain in order to send a
  2302. * "MergeTokensRequest" PDU through the transport interface.
  2303. *
  2304. * Caveats:
  2305. * None.
  2306. */
  2307. Void Connection::MergeTokensRequest (
  2308. CTokenAttributesList *merge_token_list,
  2309. CTokenIDList *purge_token_list)
  2310. {
  2311. MergeTokensRC (MERGE_TOKENS_REQUEST_CHOSEN, merge_token_list, purge_token_list);
  2312. }
  2313. /*
  2314. * Void MergeTokenConfirm ()
  2315. *
  2316. * Public
  2317. *
  2318. * Functional Description:
  2319. * This routine is called by the domain in order to send a
  2320. * "MergeTokenConfirm" PDU through the transport interface.
  2321. *
  2322. * Caveats:
  2323. * None.
  2324. */
  2325. Void Connection::MergeTokensConfirm (
  2326. CTokenAttributesList *merge_token_list,
  2327. CTokenIDList *purge_token_list)
  2328. {
  2329. MergeTokensRC (MERGE_TOKENS_CONFIRM_CHOSEN, merge_token_list, purge_token_list);
  2330. }
  2331. /*
  2332. * Void MergeTokenRC ()
  2333. *
  2334. * Private
  2335. *
  2336. * Functional Description:
  2337. * This routine is called by the domain in order to send a
  2338. * "MergeTokenConfirm" PDU or a "MergeTokenRequest" PDU through
  2339. * the transport interface.
  2340. *
  2341. * IMPORTANT:
  2342. * Since the code is used for both PDUs the DomainMCSPDU's
  2343. * merge_tokens_request and merge_tokens_confirm fields should
  2344. * be identical structures.
  2345. *
  2346. * Caveats:
  2347. * None.
  2348. */
  2349. Void Connection::MergeTokensRC (
  2350. ASN1choice_t choice,
  2351. CTokenAttributesList *merge_token_list,
  2352. CTokenIDList *purge_token_list)
  2353. {
  2354. BOOL memory_error = FALSE;
  2355. DomainMCSPDU merge_tokens_pdu;
  2356. DWORD token_attributes_count;
  2357. PSetOfPDUTokenAttributes setof_token_attributes;
  2358. PTokenAttributes token_attributes;
  2359. PSetOfUserIDs user_ids_pointer;
  2360. DWORD purge_token_count;
  2361. PSetOfTokenIDs token_ids_pointer;
  2362. DWORD dwMemoryToAlloc;
  2363. CUidList *user_inhibit_list;
  2364. merge_tokens_pdu.choice = choice;
  2365. /*
  2366. * Determine how many tokens are being merged with this PDU. This is
  2367. * used to allocate a buffer for big enough for all of the needed token
  2368. * attributes structures.
  2369. */
  2370. token_attributes_count = merge_token_list->GetCount();
  2371. purge_token_count = purge_token_list->GetCount();
  2372. if ((token_attributes_count != 0) || (purge_token_count != 0)) {
  2373. // Determine how much memory we need to allocate
  2374. dwMemoryToAlloc = token_attributes_count * sizeof (SetOfPDUTokenAttributes) +
  2375. purge_token_count * sizeof (SetOfTokenIDs);
  2376. merge_token_list->Reset();
  2377. while (NULL != (token_attributes = merge_token_list->Iterate()))
  2378. {
  2379. if (TOKEN_INHIBITED == token_attributes->token_state) {
  2380. dwMemoryToAlloc += sizeof (SetOfUserIDs) *
  2381. token_attributes->u.inhibited_token_attributes.
  2382. inhibitors->GetCount();
  2383. }
  2384. }
  2385. // Allocate the needed amount of memory.
  2386. DBG_SAVE_FILE_LINE
  2387. setof_token_attributes = (PSetOfPDUTokenAttributes) Allocate (dwMemoryToAlloc);
  2388. if (setof_token_attributes == NULL) {
  2389. memory_error = TRUE;
  2390. }
  2391. }
  2392. else {
  2393. setof_token_attributes = NULL;
  2394. }
  2395. if (setof_token_attributes == NULL) {
  2396. merge_tokens_pdu.u.merge_tokens_confirm.merge_tokens = NULL;
  2397. merge_tokens_pdu.u.merge_tokens_confirm.purge_token_ids = NULL;
  2398. }
  2399. else {
  2400. /*
  2401. * Compute where the set of purged token IDs will start from in the
  2402. * memory previously allocated.
  2403. */
  2404. token_ids_pointer = (PSetOfTokenIDs) ((PUChar) setof_token_attributes +
  2405. token_attributes_count * sizeof (SetOfPDUTokenAttributes));
  2406. if (token_attributes_count != 0) {
  2407. /*
  2408. * Get the base address of the array of SetOfPDUTokenAttributes
  2409. * structures. Put it into the PDU structure.
  2410. */
  2411. merge_tokens_pdu.u.merge_tokens_confirm.merge_tokens =
  2412. setof_token_attributes;
  2413. /*
  2414. * Compute the base address of the arrays of SetOfUserIDs structures.
  2415. */
  2416. user_ids_pointer = (PSetOfUserIDs) ((PUChar) token_ids_pointer +
  2417. purge_token_count * sizeof (SetOfTokenIDs));
  2418. /*
  2419. * Set up an iterator for the list of token attributes. Retrieve
  2420. * the token attributes structures from the list and construct the
  2421. * PDU structure.
  2422. */
  2423. merge_token_list->Reset();
  2424. while (NULL != (token_attributes = merge_token_list->Iterate()))
  2425. {
  2426. /*
  2427. * Use the token state to determine what information to include in
  2428. * the PDU structure.
  2429. */
  2430. switch (token_attributes->token_state)
  2431. {
  2432. case TOKEN_GRABBED:
  2433. setof_token_attributes->value.choice = GRABBED_CHOSEN;
  2434. setof_token_attributes->value.u.grabbed.token_id =
  2435. token_attributes->u.
  2436. grabbed_token_attributes.token_id;
  2437. setof_token_attributes->value.u.grabbed.grabber =
  2438. token_attributes->u.
  2439. grabbed_token_attributes.grabber;
  2440. break;
  2441. case TOKEN_INHIBITED:
  2442. setof_token_attributes->value.choice = INHIBITED_CHOSEN;
  2443. setof_token_attributes->value.u.inhibited.token_id =
  2444. token_attributes->u.
  2445. inhibited_token_attributes.token_id;
  2446. if ((token_attributes->u.inhibited_token_attributes.
  2447. inhibitors)->GetCount() > 0)
  2448. {
  2449. /*
  2450. * Get the base address of the array of SetOfUserIDs
  2451. * structures. Put it into the channel attributes
  2452. * structure.
  2453. */
  2454. setof_token_attributes->value.u.inhibited.inhibitors =
  2455. user_ids_pointer;
  2456. /*
  2457. * Iterate through the User ID list, adding each user
  2458. * to the PDU.
  2459. */
  2460. user_inhibit_list = token_attributes->u.inhibited_token_attributes.inhibitors;
  2461. user_inhibit_list->BuildExternalList(&user_ids_pointer);
  2462. }
  2463. else
  2464. {
  2465. /*
  2466. * Either there were no inhibitors of this token, or
  2467. * a memory allocation failure occurred above. Either
  2468. * way, put a NULL into the PDU structure to indicate
  2469. * that this field is unused.
  2470. */
  2471. setof_token_attributes->value.u.inhibited.inhibitors =
  2472. NULL;
  2473. }
  2474. break;
  2475. case TOKEN_GIVING:
  2476. setof_token_attributes->value.choice = GIVING_CHOSEN;
  2477. /*
  2478. * IMPORTANT:
  2479. * The two structs involved in this memcpy should have
  2480. * same-type fields.
  2481. * Original code is included below.
  2482. */
  2483. memcpy (&(setof_token_attributes->value.u.giving),
  2484. &(token_attributes->u.giving_token_attributes),
  2485. sizeof (Giving));
  2486. /*
  2487. setof_token_attributes->value.u.giving.token_id =
  2488. token_attributes->u.
  2489. giving_token_attributes.token_id;
  2490. setof_token_attributes->value.u.giving.grabber =
  2491. token_attributes->u.
  2492. giving_token_attributes.grabber;
  2493. setof_token_attributes->value.u.giving.recipient =
  2494. token_attributes->u.
  2495. giving_token_attributes.recipient;
  2496. */
  2497. break;
  2498. case TOKEN_GIVEN:
  2499. setof_token_attributes->value.choice = GIVEN_CHOSEN;
  2500. setof_token_attributes->value.u.given.token_id =
  2501. token_attributes->u.
  2502. given_token_attributes.token_id;
  2503. setof_token_attributes->value.u.given.recipient =
  2504. token_attributes->u.
  2505. given_token_attributes.recipient;
  2506. break;
  2507. default:
  2508. WARNING_OUT(("Connection::MergeTokensRC: bad channel type"));
  2509. break;
  2510. }
  2511. /*
  2512. * Set the next pointer to point to the next element of the
  2513. * PDU token attributes structure array. Then increment the
  2514. * pointer.
  2515. */
  2516. setof_token_attributes->next = setof_token_attributes + 1;
  2517. setof_token_attributes++;
  2518. }
  2519. /*
  2520. * Decrement the pointer in order to set the last "next" pointer to
  2521. * NULL.
  2522. */
  2523. (setof_token_attributes - 1)->next = NULL;
  2524. }
  2525. else
  2526. {
  2527. /*
  2528. * Either there are no tokens to merge, or a memory allocation failure
  2529. * occurred above. Either way put a NULL into the PDU structure to
  2530. * indicate that this field is unused.
  2531. */
  2532. merge_tokens_pdu.u.merge_tokens_confirm.merge_tokens = NULL;
  2533. }
  2534. if (purge_token_count != 0)
  2535. {
  2536. /*
  2537. * Fill in the MergeTokensRequest structure's pointer to the set of
  2538. * purge token ID's.
  2539. */
  2540. merge_tokens_pdu.u.merge_tokens_confirm.purge_token_ids = token_ids_pointer;
  2541. purge_token_list->BuildExternalList(&token_ids_pointer);
  2542. }
  2543. else
  2544. {
  2545. /*
  2546. * Either there are no tokens to be purged, or a memory allocation
  2547. * failure occurred above. Either way, put a NULL into the PDU
  2548. * structure to indicate that this field is unused.
  2549. */
  2550. merge_tokens_pdu.u.merge_tokens_confirm.purge_token_ids = NULL;
  2551. }
  2552. }
  2553. /*
  2554. * Send the packet to the remote provider.
  2555. */
  2556. if (memory_error == FALSE)
  2557. SendPacket ((PVoid) &merge_tokens_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  2558. else
  2559. {
  2560. /*
  2561. * A memory allocation failure occurred somewhere above. Report the
  2562. * error and destroy this faulty connection.
  2563. */
  2564. ERROR_OUT (("Connection::MergeTokensRC: memory allocation failure"));
  2565. DestroyConnection (REASON_PROVIDER_INITIATED);
  2566. }
  2567. /*
  2568. * Release all memory allocated above.
  2569. */
  2570. Free(setof_token_attributes - token_attributes_count);
  2571. }
  2572. /*
  2573. * Void PurgeTokensIndication ()
  2574. *
  2575. * Public
  2576. *
  2577. * Functional Description:
  2578. * This routine is called by the domain in order to send a
  2579. * "PurgeTokenIndication" PDU through the transport interface.
  2580. *
  2581. * Caveats:
  2582. * None.
  2583. */
  2584. Void Connection::PurgeTokensIndication (
  2585. PDomain,
  2586. CTokenIDList *purge_token_list)
  2587. {
  2588. BOOL memory_error=FALSE;
  2589. DomainMCSPDU purge_token_indication_pdu;
  2590. DWORD purge_token_count;
  2591. PSetOfTokenIDs token_ids_pointer;
  2592. //TokenID tid;
  2593. /*
  2594. * Fill in the PDU structure to be encoded.
  2595. */
  2596. purge_token_indication_pdu.choice = PURGE_TOKEN_INDICATION_CHOSEN;
  2597. /*
  2598. * Allocate memory to hold the list of purge tokens. If the allocation
  2599. * fails, set the flag which will result in a callback to the
  2600. * controller requesting that this connection be deleted.
  2601. */
  2602. purge_token_count = purge_token_list->GetCount();
  2603. if (purge_token_count != 0)
  2604. {
  2605. DBG_SAVE_FILE_LINE
  2606. token_ids_pointer = (PSetOfTokenIDs) Allocate (purge_token_count *
  2607. sizeof (SetOfTokenIDs));
  2608. if (token_ids_pointer == NULL)
  2609. memory_error = TRUE;
  2610. }
  2611. else
  2612. token_ids_pointer = NULL;
  2613. if (token_ids_pointer!= NULL)
  2614. {
  2615. /*
  2616. * Fill in the structure's pointer to the set of purge token ID's.
  2617. */
  2618. purge_token_indication_pdu.u.purge_token_indication.purge_token_ids = token_ids_pointer;
  2619. purge_token_list->BuildExternalList(&token_ids_pointer);
  2620. }
  2621. else
  2622. {
  2623. /*
  2624. * Either there are no tokens to purge or a memory allocation failure
  2625. * occurred above. Either way, put a NULL into the PDU structure to
  2626. * indicate that this field is unused.
  2627. */
  2628. purge_token_indication_pdu.u.purge_token_indication.purge_token_ids = NULL;
  2629. }
  2630. /*
  2631. * Send the packet to the remote provider.
  2632. */
  2633. if (memory_error == FALSE)
  2634. SendPacket ((PVoid) &purge_token_indication_pdu, DOMAIN_MCS_PDU,
  2635. TOP_PRIORITY);
  2636. else
  2637. {
  2638. /*
  2639. * A memory allocation failure occurred somewhere above. Report the
  2640. * error and destroy this faulty connection.
  2641. */
  2642. ERROR_OUT (("Connection::PurgeTokensIndication: memory allocation failure"));
  2643. DestroyConnection (REASON_PROVIDER_INITIATED);
  2644. }
  2645. /*
  2646. * If memory was successfully allocated to hold the set of token ID's,
  2647. * then free it here.
  2648. */
  2649. Free(token_ids_pointer - purge_token_count);
  2650. }
  2651. /*
  2652. * Void DisconnectProviderUltimatum ()
  2653. *
  2654. * Public
  2655. *
  2656. * Functional Description:
  2657. * This routine is called by the domain in order to send a
  2658. * "DisconnectProviderUltimatum" PDU through the transport interface.
  2659. *
  2660. * Caveats:
  2661. * None.
  2662. */
  2663. Void Connection::DisconnectProviderUltimatum (
  2664. Reason reason)
  2665. {
  2666. /*
  2667. * Set attachment to NULL to prevent any attempt to send a command to
  2668. * the attachment that just disconnected us.
  2669. */
  2670. m_pDomain = NULL;
  2671. /*
  2672. * Issue an owner callback to ask for deletion. An attempt will be made
  2673. * to send a DisconnectProviderUltimatum PDU through the transport
  2674. * interface from the Connection's destructor.
  2675. */
  2676. DestroyConnection (reason);
  2677. }
  2678. /*
  2679. * Void AttachUserRequest ()
  2680. *
  2681. * Public
  2682. *
  2683. * Functional Description:
  2684. * This routine is called by the domain in order to send a
  2685. * "AttachUserRequest" PDU through the transport interface.
  2686. *
  2687. * Caveats:
  2688. * None.
  2689. */
  2690. Void Connection::AttachUserRequest ( void )
  2691. {
  2692. DomainMCSPDU attach_user_request_pdu;
  2693. /*
  2694. * Fill in the PDU structure to be encoded.
  2695. */
  2696. attach_user_request_pdu.choice = ATTACH_USER_REQUEST_CHOSEN;
  2697. /*
  2698. * Send the packet to the remote provider.
  2699. */
  2700. SendPacket ((PVoid) &attach_user_request_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  2701. }
  2702. /*
  2703. * Void AttachUserConfirm ()
  2704. *
  2705. * Public
  2706. *
  2707. * Functional Description:
  2708. * This routine is called by the domain in order to send a
  2709. * "AttachUserConfirm" PDU through the transport interface.
  2710. *
  2711. * Caveats:
  2712. * None.
  2713. */
  2714. Void Connection::AttachUserConfirm (
  2715. Result result,
  2716. UserID uidInitiator)
  2717. {
  2718. DomainMCSPDU attach_user_confirm_pdu;
  2719. /*
  2720. * Fill in the PDU structure to be encoded.
  2721. */
  2722. attach_user_confirm_pdu.choice = ATTACH_USER_CONFIRM_CHOSEN;
  2723. if (result == RESULT_SUCCESSFUL)
  2724. attach_user_confirm_pdu.u.attach_user_confirm.bit_mask =
  2725. INITIATOR_PRESENT;
  2726. else
  2727. attach_user_confirm_pdu.u.attach_user_confirm.bit_mask = 0x00;
  2728. attach_user_confirm_pdu.u.attach_user_confirm.result = (PDUResult)result;
  2729. attach_user_confirm_pdu.u.attach_user_confirm.initiator = uidInitiator;
  2730. /*
  2731. * Send the packet to the remote provider.
  2732. */
  2733. SendPacket ((PVoid) &attach_user_confirm_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  2734. }
  2735. /*
  2736. * Void DetachUserRequest ()
  2737. *
  2738. * Public
  2739. *
  2740. * Functional Description:
  2741. * This routine is called by the domain in order to send a
  2742. * "DetachUserRequest" PDU through the transport interface.
  2743. *
  2744. * Caveats:
  2745. * None.
  2746. */
  2747. Void Connection::DetachUserRequest (
  2748. Reason reason,
  2749. CUidList *user_id_list)
  2750. {
  2751. UserChannelRI (DETACH_USER_REQUEST_CHOSEN, (UINT) reason, 0, user_id_list);
  2752. }
  2753. /*
  2754. * Void UserChannelRI ()
  2755. *
  2756. * Public
  2757. *
  2758. * Functional Description:
  2759. * This routine is called by the domain in order to send a
  2760. * "DetachUserRequest", "DetachUserIndication", "ChannelAdmitRequest",
  2761. * "ChannelAdmitIndication", "ChannelExpelRequest" or
  2762. * "ChannelExpelIndication" PDU through the transport interface.
  2763. *
  2764. * Caveats:
  2765. * None.
  2766. */
  2767. Void Connection::UserChannelRI (
  2768. ASN1choice_t choice,
  2769. UINT reason_userID,
  2770. ChannelID channel_id,
  2771. CUidList *user_id_list)
  2772. {
  2773. BOOL memory_error = FALSE;
  2774. DomainMCSPDU domain_pdu;
  2775. DWORD user_ids_count;
  2776. PSetOfUserIDs user_ids_pointer;
  2777. //UserID uid;
  2778. /*
  2779. * Allocate memory to hold the list of users. If the allocation
  2780. * fails, set the flag which will result in a callback to the
  2781. * controller requesting that this connection be deleted.
  2782. */
  2783. user_ids_count = user_id_list->GetCount();
  2784. if (user_ids_count != 0)
  2785. {
  2786. DBG_SAVE_FILE_LINE
  2787. user_ids_pointer = (PSetOfUserIDs) Allocate (user_ids_count *
  2788. sizeof (SetOfUserIDs));
  2789. if (user_ids_pointer == NULL)
  2790. memory_error = TRUE;
  2791. }
  2792. else
  2793. user_ids_pointer = NULL;
  2794. /*
  2795. * Fill in the PDU structure to be encoded. Also,
  2796. * get the base address of the SetOfUserIDs structure and put it into
  2797. * the PDU structure.
  2798. */
  2799. domain_pdu.choice = choice;
  2800. switch (choice) {
  2801. case DETACH_USER_REQUEST_CHOSEN:
  2802. case DETACH_USER_INDICATION_CHOSEN:
  2803. /*
  2804. * IMPORTANT:
  2805. * The detach_user_request and detach_user_indication structs
  2806. * in DomainMCSPDU must be identical.
  2807. */
  2808. domain_pdu.u.detach_user_request.reason = (PDUReason) reason_userID;
  2809. domain_pdu.u.detach_user_request.user_ids = user_ids_pointer;
  2810. break;
  2811. case CHANNEL_ADMIT_REQUEST_CHOSEN:
  2812. case CHANNEL_ADMIT_INDICATION_CHOSEN:
  2813. case CHANNEL_EXPEL_REQUEST_CHOSEN:
  2814. /*
  2815. * IMPORTANT:
  2816. * The channel_admit_request, channel_admit_indication
  2817. * and channel_expel_request structs
  2818. * in DomainMCSPDU must be identical.
  2819. */
  2820. domain_pdu.u.channel_admit_request.initiator = (UserID) reason_userID;
  2821. domain_pdu.u.channel_admit_request.channel_id = channel_id;
  2822. domain_pdu.u.channel_admit_request.user_ids = user_ids_pointer;
  2823. break;
  2824. case CHANNEL_EXPEL_INDICATION_CHOSEN:
  2825. domain_pdu.u.channel_expel_indication.channel_id = channel_id;
  2826. domain_pdu.u.channel_expel_indication.user_ids = user_ids_pointer;
  2827. break;
  2828. default:
  2829. ASSERT(FALSE);
  2830. ERROR_OUT (("Connection::UserChannelRI: PDU should not be formed by this method."));
  2831. break;
  2832. }
  2833. user_id_list->BuildExternalList(&user_ids_pointer);
  2834. /*
  2835. * Send the packet to the remote provider.
  2836. */
  2837. if (memory_error == FALSE)
  2838. SendPacket ((PVoid) &domain_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  2839. else
  2840. {
  2841. /*
  2842. * A memory allocation failure occurred somewhere above. Report the
  2843. * error and destroy this faulty connection.
  2844. */
  2845. ERROR_OUT (("Connection::UserChannelRI: memory allocation failure"));
  2846. DestroyConnection (REASON_PROVIDER_INITIATED);
  2847. }
  2848. /*
  2849. * If memory was successfully allocated to hold the set of user ID's,
  2850. * then free it here.
  2851. */
  2852. Free(user_ids_pointer - user_ids_count);
  2853. }
  2854. /*
  2855. * Void DetachUserIndication ()
  2856. *
  2857. * Public
  2858. *
  2859. * Functional Description:
  2860. * This routine is called by the domain in order to send a
  2861. * "DetachUserIndication" PDU through the transport interface.
  2862. *
  2863. * Caveats:
  2864. * None.
  2865. */
  2866. Void Connection::DetachUserIndication (
  2867. Reason reason,
  2868. CUidList *user_id_list)
  2869. {
  2870. UserChannelRI (DETACH_USER_INDICATION_CHOSEN, (UINT) reason, 0, user_id_list);
  2871. }
  2872. /*
  2873. * Void ChannelJoinRequest ()
  2874. *
  2875. * Public
  2876. *
  2877. * Functional Description:
  2878. * This routine is called by the domain in order to send a
  2879. * "ChannelJoinRequest" PDU through the transport interface.
  2880. *
  2881. * Caveats:
  2882. * None.
  2883. */
  2884. Void Connection::ChannelJoinRequest (
  2885. UserID uidInitiator,
  2886. ChannelID channel_id)
  2887. {
  2888. DomainMCSPDU channel_join_request_pdu;
  2889. /*
  2890. * Fill in the PDU structure to be encoded.
  2891. */
  2892. channel_join_request_pdu.choice = CHANNEL_JOIN_REQUEST_CHOSEN;
  2893. channel_join_request_pdu.u.channel_join_request.initiator = uidInitiator;
  2894. channel_join_request_pdu.u.channel_join_request.channel_id = channel_id;
  2895. /*
  2896. * Send the packet to the remote provider.
  2897. */
  2898. SendPacket ((PVoid) &channel_join_request_pdu, DOMAIN_MCS_PDU,
  2899. TOP_PRIORITY);
  2900. }
  2901. /*
  2902. * Void ChannelJoinConfirm ()
  2903. *
  2904. * Public
  2905. *
  2906. * Functional Description:
  2907. * This routine is called by the domain in order to send a
  2908. * "ChannelJoinConfirm" PDU through the transport interface.
  2909. *
  2910. * Caveats:
  2911. * None.
  2912. */
  2913. Void Connection::ChannelJoinConfirm (
  2914. Result result,
  2915. UserID uidInitiator,
  2916. ChannelID requested_id,
  2917. ChannelID channel_id)
  2918. {
  2919. DomainMCSPDU channel_join_confirm_pdu;
  2920. /*
  2921. * Fill in the PDU structure to be encoded.
  2922. */
  2923. channel_join_confirm_pdu.choice = CHANNEL_JOIN_CONFIRM_CHOSEN;
  2924. if (result == RESULT_SUCCESSFUL)
  2925. channel_join_confirm_pdu.u.channel_join_confirm.bit_mask =
  2926. JOIN_CHANNEL_ID_PRESENT;
  2927. else
  2928. channel_join_confirm_pdu.u.channel_join_confirm.bit_mask = 0x00;
  2929. channel_join_confirm_pdu.u.channel_join_confirm.result = (PDUResult)result;
  2930. channel_join_confirm_pdu.u.channel_join_confirm.initiator = uidInitiator;
  2931. channel_join_confirm_pdu.u.channel_join_confirm.requested = requested_id;
  2932. channel_join_confirm_pdu.u.channel_join_confirm.join_channel_id =
  2933. channel_id;
  2934. /*
  2935. * Send the packet to the remote provider.
  2936. */
  2937. SendPacket ((PVoid) &channel_join_confirm_pdu, DOMAIN_MCS_PDU,
  2938. TOP_PRIORITY);
  2939. }
  2940. /*
  2941. * Void ChannelLeaveRequest ()
  2942. *
  2943. * Public
  2944. *
  2945. * Functional Description:
  2946. * This routine is called by the domain in order to send a
  2947. * "ChannelLeaveRequest" PDU through the transport interface.
  2948. *
  2949. * Caveats:
  2950. * None.
  2951. */
  2952. Void Connection::ChannelLeaveRequest (
  2953. CChannelIDList *channel_id_list)
  2954. {
  2955. BOOL memory_error=FALSE;
  2956. DomainMCSPDU channel_leave_request_pdu;
  2957. DWORD channel_ids_count;
  2958. PSetOfChannelIDs channel_ids_pointer;
  2959. PSetOfChannelIDs pToFree;
  2960. //ChannelID chid;
  2961. /*
  2962. * Fill in the elements of the PDU structure.
  2963. */
  2964. channel_leave_request_pdu.choice = CHANNEL_LEAVE_REQUEST_CHOSEN;
  2965. /*
  2966. * Allocate memory to hold the list of channels. If the allocation
  2967. * fails, set the flag which will result in a callback to the
  2968. * controller requesting that this connection be deleted.
  2969. */
  2970. channel_ids_count = channel_id_list->GetCount();
  2971. if (channel_ids_count != 0)
  2972. {
  2973. DBG_SAVE_FILE_LINE
  2974. channel_ids_pointer = (PSetOfChannelIDs) Allocate (channel_ids_count *
  2975. sizeof (SetOfChannelIDs));
  2976. if (channel_ids_pointer == NULL)
  2977. memory_error = TRUE;
  2978. }
  2979. else
  2980. channel_ids_pointer = NULL;
  2981. pToFree = channel_ids_pointer;
  2982. /*
  2983. * Get the base address of the array fo SetOfChannelIDs structure and
  2984. * put it into the PDU structure.
  2985. */
  2986. channel_leave_request_pdu.u.channel_leave_request.channel_ids = channel_ids_pointer;
  2987. channel_id_list->BuildExternalList(&channel_ids_pointer);
  2988. /*
  2989. * Send the packet to the remote provider.
  2990. */
  2991. if (memory_error == FALSE)
  2992. SendPacket ((PVoid) &channel_leave_request_pdu, DOMAIN_MCS_PDU,
  2993. TOP_PRIORITY);
  2994. else
  2995. {
  2996. /*
  2997. * A memory allocation failure occurred somewhere above. Report the
  2998. * error and destroy this faulty connection.
  2999. */
  3000. ERROR_OUT (("Connection::ChannelLeaveRequest: memory allocation failure"));
  3001. DestroyConnection (REASON_PROVIDER_INITIATED);
  3002. }
  3003. /*
  3004. * If memory was successfully allocated to hold the set of channel ID's,
  3005. * then free it here.
  3006. */
  3007. Free(pToFree);
  3008. }
  3009. /*
  3010. * Void ChannelConveneRequest ()
  3011. *
  3012. * Public
  3013. *
  3014. * Functional Description:
  3015. * This routine is called by the domain in order to send a
  3016. * "ChannelConveneRequest" PDU through the transport interface.
  3017. *
  3018. * Caveats:
  3019. * None.
  3020. */
  3021. Void Connection::ChannelConveneRequest (
  3022. UserID uidInitiator)
  3023. {
  3024. DomainMCSPDU channel_convene_request_pdu;
  3025. /*
  3026. * Fill in the PDU structure to be encoded.
  3027. */
  3028. channel_convene_request_pdu.choice = CHANNEL_CONVENE_REQUEST_CHOSEN;
  3029. channel_convene_request_pdu.u.channel_convene_request.initiator =
  3030. uidInitiator;
  3031. /*
  3032. * Send the packet to the remote provider.
  3033. */
  3034. SendPacket ((PVoid) &channel_convene_request_pdu, DOMAIN_MCS_PDU,
  3035. TOP_PRIORITY);
  3036. }
  3037. /*
  3038. * Void ChannelConveneConfirm ()
  3039. *
  3040. * Public
  3041. *
  3042. * Functional Description:
  3043. * This routine is called by the domain in order to send a
  3044. * "ChannelConveneConfirm" PDU through the transport interface.
  3045. *
  3046. * Caveats:
  3047. * None.
  3048. */
  3049. Void Connection::ChannelConveneConfirm (
  3050. Result result,
  3051. UserID uidInitiator,
  3052. ChannelID channel_id)
  3053. {
  3054. DomainMCSPDU channel_convene_confirm_pdu;
  3055. /*
  3056. * Fill in the PDU structure to be encoded.
  3057. */
  3058. channel_convene_confirm_pdu.choice = CHANNEL_CONVENE_CONFIRM_CHOSEN;
  3059. if (result == RESULT_SUCCESSFUL)
  3060. channel_convene_confirm_pdu.u.channel_convene_confirm.bit_mask =
  3061. CONVENE_CHANNEL_ID_PRESENT;
  3062. else
  3063. channel_convene_confirm_pdu.u.channel_convene_confirm.bit_mask = 0x00;
  3064. channel_convene_confirm_pdu.u.channel_convene_confirm.result =
  3065. (PDUResult)result;
  3066. channel_convene_confirm_pdu.u.channel_convene_confirm.initiator =
  3067. uidInitiator;
  3068. channel_convene_confirm_pdu.u.channel_convene_confirm.convene_channel_id =
  3069. channel_id;
  3070. /*
  3071. * Send the packet to the remote provider.
  3072. */
  3073. SendPacket ((PVoid) &channel_convene_confirm_pdu, DOMAIN_MCS_PDU,
  3074. TOP_PRIORITY);
  3075. }
  3076. /*
  3077. * Void ChannelDisbandRequest ()
  3078. *
  3079. * Public
  3080. *
  3081. * Functional Description:
  3082. * This routine is called by the domain in order to send a
  3083. * "ChannelDisbandRequest" PDU through the transport interface.
  3084. *
  3085. * Caveats:
  3086. * None.
  3087. */
  3088. Void Connection::ChannelDisbandRequest (
  3089. UserID uidInitiator,
  3090. ChannelID channel_id)
  3091. {
  3092. DomainMCSPDU channel_disband_request_pdu;
  3093. /*
  3094. * Fill in the PDU structure to be encoded.
  3095. */
  3096. channel_disband_request_pdu.choice = CHANNEL_DISBAND_REQUEST_CHOSEN;
  3097. channel_disband_request_pdu.u.channel_disband_request.initiator =
  3098. uidInitiator;
  3099. channel_disband_request_pdu.u.channel_disband_request.channel_id =
  3100. channel_id;
  3101. /*
  3102. * Send the packet to the remote provider.
  3103. */
  3104. SendPacket ((PVoid) &channel_disband_request_pdu, DOMAIN_MCS_PDU,
  3105. TOP_PRIORITY);
  3106. }
  3107. /*
  3108. * Void ChannelDisbandIndication ()
  3109. *
  3110. * Public
  3111. *
  3112. * Functional Description:
  3113. * This routine is called by the domain in order to send a
  3114. * "ChannelDisbandIndication" PDU through the transport interface.
  3115. *
  3116. * Caveats:
  3117. * None.
  3118. */
  3119. Void Connection::ChannelDisbandIndication (
  3120. ChannelID channel_id)
  3121. {
  3122. DomainMCSPDU channel_disband_indication_pdu;
  3123. /*
  3124. * Fill in the PDU structure to be encoded.
  3125. */
  3126. channel_disband_indication_pdu.choice = CHANNEL_DISBAND_INDICATION_CHOSEN;
  3127. channel_disband_indication_pdu.u.channel_disband_indication.channel_id =
  3128. channel_id;
  3129. /*
  3130. * Send the packet to the remote provider.
  3131. */
  3132. SendPacket ((PVoid) &channel_disband_indication_pdu, DOMAIN_MCS_PDU,
  3133. TOP_PRIORITY);
  3134. }
  3135. /*
  3136. * Void ChannelAdmitRequest ()
  3137. *
  3138. * Public
  3139. *
  3140. * Functional Description:
  3141. * This routine is called by the domain in order to send a
  3142. * "ChannelAdmitRequest" PDU through the transport interface.
  3143. *
  3144. * Caveats:
  3145. * None.
  3146. */
  3147. Void Connection::ChannelAdmitRequest (
  3148. UserID uidInitiator,
  3149. ChannelID channel_id,
  3150. CUidList *user_id_list)
  3151. {
  3152. UserChannelRI (CHANNEL_ADMIT_REQUEST_CHOSEN, (UINT) uidInitiator, channel_id,
  3153. user_id_list);
  3154. }
  3155. /*
  3156. * Void ChannelAdmitIndication ()
  3157. *
  3158. * Public
  3159. *
  3160. * Functional Description:
  3161. * This routine is called by the domain in order to send a
  3162. * "ChannelAdmitIndication" PDU through the transport interface.
  3163. *
  3164. * Caveats:
  3165. * None.
  3166. */
  3167. Void Connection::ChannelAdmitIndication (
  3168. UserID uidInitiator,
  3169. ChannelID channel_id,
  3170. CUidList *user_id_list)
  3171. {
  3172. UserChannelRI (CHANNEL_ADMIT_INDICATION_CHOSEN, (UINT) uidInitiator, channel_id,
  3173. user_id_list);
  3174. }
  3175. /*
  3176. * Void ChannelExpelRequest ()
  3177. *
  3178. * Public
  3179. *
  3180. * Functional Description:
  3181. * This routine is called by the domain in order to send a
  3182. * "ChannelExpelRequest" PDU through the transport interface.
  3183. *
  3184. * Caveats:
  3185. * None.
  3186. */
  3187. Void Connection::ChannelExpelRequest (
  3188. UserID uidInitiator,
  3189. ChannelID channel_id,
  3190. CUidList *user_id_list)
  3191. {
  3192. UserChannelRI (CHANNEL_EXPEL_REQUEST_CHOSEN, (UINT) uidInitiator, channel_id,
  3193. user_id_list);
  3194. }
  3195. /*
  3196. * Void ChannelExpelIndication ()
  3197. *
  3198. * Public
  3199. *
  3200. * Functional Description:
  3201. * This routine is called by the domain in order to send a
  3202. * "ChannelExpelIndication" PDU through the transport interface.
  3203. *
  3204. * Caveats:
  3205. * None.
  3206. */
  3207. Void Connection::ChannelExpelIndication (
  3208. ChannelID channel_id,
  3209. CUidList *user_id_list)
  3210. {
  3211. UserChannelRI (CHANNEL_EXPEL_INDICATION_CHOSEN, 0, channel_id,
  3212. user_id_list);
  3213. }
  3214. /*
  3215. * Void TokenGrabRequest ()
  3216. *
  3217. * Public
  3218. *
  3219. * Functional Description:
  3220. * This routine is called by the domain in order to send a
  3221. * "TokenGrabRequest" PDU through the transport interface.
  3222. *
  3223. * Caveats:
  3224. * None.
  3225. */
  3226. Void Connection::TokenGrabRequest (
  3227. UserID uidInitiator,
  3228. TokenID token_id)
  3229. {
  3230. DomainMCSPDU token_grab_request_pdu;
  3231. /*
  3232. * Fill in the PDU structure to be encoded.
  3233. */
  3234. token_grab_request_pdu.choice = TOKEN_GRAB_REQUEST_CHOSEN;
  3235. token_grab_request_pdu.u.token_grab_request.initiator = uidInitiator;
  3236. token_grab_request_pdu.u.token_grab_request.token_id = token_id;
  3237. /*
  3238. * Send the packet to the remote provider.
  3239. */
  3240. SendPacket ((PVoid) &token_grab_request_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  3241. }
  3242. /*
  3243. * Void TokenGrabConfirm ()
  3244. *
  3245. * Public
  3246. *
  3247. * Functional Description:
  3248. * This routine is called by the domain in order to send a
  3249. * "TokenGrabConfirm" PDU through the transport interface.
  3250. *
  3251. * Caveats:
  3252. * None.
  3253. */
  3254. Void Connection::TokenGrabConfirm (
  3255. Result result,
  3256. UserID uidInitiator,
  3257. TokenID token_id,
  3258. TokenStatus token_status)
  3259. {
  3260. DomainMCSPDU token_grab_confirm_pdu;
  3261. /*
  3262. * Fill in the PDU structure to be encoded.
  3263. */
  3264. token_grab_confirm_pdu.choice = TOKEN_GRAB_CONFIRM_CHOSEN;
  3265. token_grab_confirm_pdu.u.token_grab_confirm.result = (PDUResult)result;
  3266. token_grab_confirm_pdu.u.token_grab_confirm.initiator = uidInitiator;
  3267. token_grab_confirm_pdu.u.token_grab_confirm.token_id = token_id;
  3268. token_grab_confirm_pdu.u.token_grab_confirm.token_status =
  3269. (PDUTokenStatus)token_status;
  3270. /*
  3271. * Send the packet to the remote provider.
  3272. */
  3273. SendPacket ((PVoid) &token_grab_confirm_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  3274. }
  3275. /*
  3276. * Void TokenInhibitRequest ()
  3277. *
  3278. * Public
  3279. *
  3280. * Functional Description:
  3281. * This routine is called by the domain in order to send a
  3282. * "TokenInhibitRequest" PDU through the transport interface.
  3283. *
  3284. * Caveats:
  3285. * None.
  3286. */
  3287. Void Connection::TokenInhibitRequest (
  3288. UserID uidInitiator,
  3289. TokenID token_id)
  3290. {
  3291. DomainMCSPDU token_inhibit_request_pdu;
  3292. /*
  3293. * Fill in the PDU structure to be encoded.
  3294. */
  3295. token_inhibit_request_pdu.choice = TOKEN_INHIBIT_REQUEST_CHOSEN;
  3296. token_inhibit_request_pdu.u.token_inhibit_request.initiator = uidInitiator;
  3297. token_inhibit_request_pdu.u.token_inhibit_request.token_id = token_id;
  3298. /*
  3299. * Send the packet to the remote provider.
  3300. */
  3301. SendPacket ((PVoid) &token_inhibit_request_pdu, DOMAIN_MCS_PDU,
  3302. TOP_PRIORITY);
  3303. }
  3304. /*
  3305. * Void TokenInhibitConfirm ()
  3306. *
  3307. * Public
  3308. *
  3309. * Functional Description:
  3310. * This routine is called by the domain in order to send a
  3311. * "TokenInhibitConfirm" PDU through the transport interface.
  3312. *
  3313. * Caveats:
  3314. * None.
  3315. */
  3316. Void Connection::TokenInhibitConfirm (
  3317. Result result,
  3318. UserID uidInitiator,
  3319. TokenID token_id,
  3320. TokenStatus token_status)
  3321. {
  3322. DomainMCSPDU token_inhibit_confirm_pdu;
  3323. /*
  3324. * Fill in the PDU structure to be encoded.
  3325. */
  3326. token_inhibit_confirm_pdu.choice = TOKEN_INHIBIT_CONFIRM_CHOSEN;
  3327. token_inhibit_confirm_pdu.u.token_inhibit_confirm.result =
  3328. (PDUResult)result;
  3329. token_inhibit_confirm_pdu.u.token_inhibit_confirm.initiator = uidInitiator;
  3330. token_inhibit_confirm_pdu.u.token_inhibit_confirm.token_id = token_id;
  3331. token_inhibit_confirm_pdu.u.token_inhibit_confirm.token_status =
  3332. (PDUTokenStatus)token_status;
  3333. /*
  3334. * Send the packet to the remote provider.
  3335. */
  3336. SendPacket ((PVoid) &token_inhibit_confirm_pdu, DOMAIN_MCS_PDU,
  3337. TOP_PRIORITY);
  3338. }
  3339. /*
  3340. * Void TokenGiveRequest ()
  3341. *
  3342. * Public
  3343. *
  3344. * Functional Description:
  3345. * This routine is called by the domain in order to send a
  3346. * "TokenGiveRequest" PDU through the transport interface.
  3347. *
  3348. * Caveats:
  3349. * None.
  3350. */
  3351. Void Connection::TokenGiveRequest (
  3352. PTokenGiveRecord pTokenGiveRec)
  3353. {
  3354. DomainMCSPDU token_give_request_pdu;
  3355. /*
  3356. * Fill in the PDU structure to be encoded.
  3357. */
  3358. token_give_request_pdu.choice = TOKEN_GIVE_REQUEST_CHOSEN;
  3359. token_give_request_pdu.u.token_give_request.initiator = pTokenGiveRec->uidInitiator;
  3360. token_give_request_pdu.u.token_give_request.token_id = pTokenGiveRec->token_id;
  3361. token_give_request_pdu.u.token_give_request.recipient = pTokenGiveRec->receiver_id;
  3362. /*
  3363. * Send the packet to the remote provider.
  3364. */
  3365. SendPacket ((PVoid) &token_give_request_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  3366. }
  3367. /*
  3368. * Void TokenGiveIndication ()
  3369. *
  3370. * Public
  3371. *
  3372. * Functional Description:
  3373. * This routine is called by the domain in order to send a
  3374. * "TokenGiveIndication" PDU through the transport interface.
  3375. *
  3376. * Caveats:
  3377. * None.
  3378. */
  3379. Void Connection::TokenGiveIndication (
  3380. PTokenGiveRecord pTokenGiveRec)
  3381. {
  3382. DomainMCSPDU token_give_indication_pdu;
  3383. /*
  3384. * Fill in the PDU structure to be encoded.
  3385. */
  3386. token_give_indication_pdu.choice = TOKEN_GIVE_INDICATION_CHOSEN;
  3387. token_give_indication_pdu.u.token_give_indication.initiator = pTokenGiveRec->uidInitiator;
  3388. token_give_indication_pdu.u.token_give_indication.token_id = pTokenGiveRec->token_id;
  3389. token_give_indication_pdu.u.token_give_indication.recipient = pTokenGiveRec->receiver_id;
  3390. /*
  3391. * Send the packet to the remote provider.
  3392. */
  3393. SendPacket ((PVoid) &token_give_indication_pdu, DOMAIN_MCS_PDU,
  3394. TOP_PRIORITY);
  3395. }
  3396. /*
  3397. * Void TokenGiveResponse ()
  3398. *
  3399. * Public
  3400. *
  3401. * Functional Description:
  3402. * This routine is called by the domain in order to send a
  3403. * "TokenGiveResponse" PDU through the transport interface.
  3404. *
  3405. * Caveats:
  3406. * None.
  3407. */
  3408. Void Connection::TokenGiveResponse (
  3409. Result result,
  3410. UserID receiver_id,
  3411. TokenID token_id)
  3412. {
  3413. DomainMCSPDU token_give_response_pdu;
  3414. /*
  3415. * Fill in the PDU structure to be encoded.
  3416. */
  3417. token_give_response_pdu.choice = TOKEN_GIVE_RESPONSE_CHOSEN;
  3418. token_give_response_pdu.u.token_give_response.result =
  3419. (PDUResult)result;
  3420. token_give_response_pdu.u.token_give_response.recipient = receiver_id;
  3421. token_give_response_pdu.u.token_give_response.token_id = token_id;
  3422. /*
  3423. * Send the packet to the remote provider.
  3424. */
  3425. SendPacket ((PVoid) &token_give_response_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  3426. }
  3427. /*
  3428. * Void TokenGiveConfirm ()
  3429. *
  3430. * Public
  3431. *
  3432. * Functional Description:
  3433. * This routine is called by the domain in order to send a
  3434. * "TokenGiveConfirm" PDU through the transport interface.
  3435. *
  3436. * Caveats:
  3437. * None.
  3438. */
  3439. Void Connection::TokenGiveConfirm (
  3440. Result result,
  3441. UserID uidInitiator,
  3442. TokenID token_id,
  3443. TokenStatus token_status)
  3444. {
  3445. DomainMCSPDU token_give_confirm_pdu;
  3446. /*
  3447. * Fill in the PDU structure to be encoded.
  3448. */
  3449. token_give_confirm_pdu.choice = TOKEN_GIVE_CONFIRM_CHOSEN;
  3450. token_give_confirm_pdu.u.token_give_confirm.result =
  3451. (PDUResult)result;
  3452. token_give_confirm_pdu.u.token_give_confirm.initiator = uidInitiator;
  3453. token_give_confirm_pdu.u.token_give_confirm.token_id = token_id;
  3454. token_give_confirm_pdu.u.token_give_confirm.token_status =
  3455. (PDUTokenStatus)token_status;
  3456. /*
  3457. * Send the packet to the remote provider.
  3458. */
  3459. SendPacket ((PVoid) &token_give_confirm_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  3460. }
  3461. /*
  3462. * Void TokenPleaseRequest ()
  3463. *
  3464. * Public
  3465. *
  3466. * Functional Description:
  3467. * This routine is called by the domain in order to send a
  3468. * "TokenPleaseRequest" PDU through the transport interface.
  3469. *
  3470. * Caveats:
  3471. * None.
  3472. */
  3473. Void Connection::TokenPleaseRequest (
  3474. UserID uidInitiator,
  3475. TokenID token_id)
  3476. {
  3477. DomainMCSPDU token_please_request_pdu;
  3478. /*
  3479. * Fill in the PDU structure to be encoded.
  3480. */
  3481. token_please_request_pdu.choice = TOKEN_PLEASE_REQUEST_CHOSEN;
  3482. token_please_request_pdu.u.token_please_request.initiator = uidInitiator;
  3483. token_please_request_pdu.u.token_please_request.token_id = token_id;
  3484. /*
  3485. * Send the packet to the remote provider.
  3486. */
  3487. SendPacket ((PVoid) &token_please_request_pdu, DOMAIN_MCS_PDU,
  3488. TOP_PRIORITY);
  3489. }
  3490. /*
  3491. * Void TokenPleaseIndication ()
  3492. *
  3493. * Public
  3494. *
  3495. * Functional Description:
  3496. * This routine is called by the domain in order to send a
  3497. * "TokenPleaseIndication" PDU through the transport interface.
  3498. *
  3499. * Caveats:
  3500. * None.
  3501. */
  3502. Void Connection::TokenPleaseIndication (
  3503. UserID uidInitiator,
  3504. TokenID token_id)
  3505. {
  3506. DomainMCSPDU token_please_indication_pdu;
  3507. /*
  3508. * Fill in the PDU structure to be encoded.
  3509. */
  3510. token_please_indication_pdu.choice = TOKEN_PLEASE_INDICATION_CHOSEN;
  3511. token_please_indication_pdu.u.token_please_request.initiator = uidInitiator;
  3512. token_please_indication_pdu.u.token_please_request.token_id = token_id;
  3513. /*
  3514. * Send the packet to the remote provider.
  3515. */
  3516. SendPacket ((PVoid) &token_please_indication_pdu, DOMAIN_MCS_PDU,
  3517. TOP_PRIORITY);
  3518. }
  3519. /*
  3520. * Void TokenReleaseRequest ()
  3521. *
  3522. * Public
  3523. *
  3524. * Functional Description:
  3525. * This routine is called by the domain in order to send a
  3526. * "TokenReleaseRequest" PDU through the transport interface.
  3527. *
  3528. * Caveats:
  3529. * None.
  3530. */
  3531. Void Connection::TokenReleaseRequest (
  3532. UserID uidInitiator,
  3533. TokenID token_id)
  3534. {
  3535. DomainMCSPDU token_release_request_pdu;
  3536. /*
  3537. * Fill in the PDU structure to be encoded.
  3538. */
  3539. token_release_request_pdu.choice = TOKEN_RELEASE_REQUEST_CHOSEN;
  3540. token_release_request_pdu.u.token_release_request.initiator = uidInitiator;
  3541. token_release_request_pdu.u.token_release_request.token_id = token_id;
  3542. /*
  3543. * Send the packet to the remote provider.
  3544. */
  3545. SendPacket ((PVoid) &token_release_request_pdu, DOMAIN_MCS_PDU,
  3546. TOP_PRIORITY);
  3547. }
  3548. /*
  3549. * Void TokenReleaseConfirm ()
  3550. *
  3551. * Public
  3552. *
  3553. * Functional Description:
  3554. * This routine is called by the domain in order to send a
  3555. * "TokenReleaseConfirm" PDU through the transport interface.
  3556. *
  3557. * Caveats:
  3558. * None.
  3559. */
  3560. Void Connection::TokenReleaseConfirm (
  3561. Result result,
  3562. UserID uidInitiator,
  3563. TokenID token_id,
  3564. TokenStatus token_status)
  3565. {
  3566. DomainMCSPDU token_release_confirm_pdu;
  3567. /*
  3568. * Fill in the PDU structure to be encoded.
  3569. */
  3570. token_release_confirm_pdu.choice = TOKEN_RELEASE_CONFIRM_CHOSEN;
  3571. token_release_confirm_pdu.u.token_release_confirm.result =
  3572. (PDUResult)result;
  3573. token_release_confirm_pdu.u.token_release_confirm.initiator = uidInitiator;
  3574. token_release_confirm_pdu.u.token_release_confirm.token_id = token_id;
  3575. token_release_confirm_pdu.u.token_release_confirm.token_status =
  3576. (PDUTokenStatus)token_status;
  3577. /*
  3578. * Send the packet to the remote provider.
  3579. */
  3580. SendPacket ((PVoid) &token_release_confirm_pdu, DOMAIN_MCS_PDU,
  3581. TOP_PRIORITY);
  3582. }
  3583. /*
  3584. * Void TokenTestRequest ()
  3585. *
  3586. * Public
  3587. *
  3588. * Functional Description:
  3589. * This routine is called by the domain in order to send a
  3590. * "TokenTestRequest" PDU through the transport interface.
  3591. *
  3592. * Caveats:
  3593. * None.
  3594. */
  3595. Void Connection::TokenTestRequest (
  3596. UserID uidInitiator,
  3597. TokenID token_id)
  3598. {
  3599. DomainMCSPDU token_test_request_pdu;
  3600. /*
  3601. * Fill in the PDU structure to be encoded.
  3602. */
  3603. token_test_request_pdu.choice = TOKEN_TEST_REQUEST_CHOSEN;
  3604. token_test_request_pdu.u.token_test_request.initiator = uidInitiator;
  3605. token_test_request_pdu.u.token_test_request.token_id = token_id;
  3606. /*
  3607. * Send the packet to the remote provider.
  3608. */
  3609. SendPacket ((PVoid) &token_test_request_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  3610. }
  3611. /*
  3612. * Void TokenTestConfirm ()
  3613. *
  3614. * Public
  3615. *
  3616. * Functional Description:
  3617. * This routine is called by the domain in order to send a
  3618. * "TokenTestConfirm" PDU through the transport interface.
  3619. *
  3620. * Caveats:
  3621. * None.
  3622. */
  3623. Void Connection::TokenTestConfirm (
  3624. UserID uidInitiator,
  3625. TokenID token_id,
  3626. TokenStatus token_status)
  3627. {
  3628. DomainMCSPDU token_test_confirm_pdu;
  3629. /*
  3630. * Fill in the PDU structure to be encoded.
  3631. */
  3632. token_test_confirm_pdu.choice = TOKEN_TEST_CONFIRM_CHOSEN;
  3633. token_test_confirm_pdu.u.token_test_confirm.initiator = uidInitiator;
  3634. token_test_confirm_pdu.u.token_test_confirm.token_id = token_id;
  3635. token_test_confirm_pdu.u.token_test_confirm.token_status =
  3636. (PDUTokenStatus)token_status;
  3637. /*
  3638. * Send the packet to the remote provider.
  3639. */
  3640. SendPacket ((PVoid) &token_test_confirm_pdu, DOMAIN_MCS_PDU, TOP_PRIORITY);
  3641. }
  3642. /*
  3643. * Void MergeDomainIndication ()
  3644. *
  3645. * Public
  3646. *
  3647. * Functional Description:
  3648. * This function is called when the attached domain enters or leaves the
  3649. * merge state.
  3650. */
  3651. Void Connection::MergeDomainIndication (
  3652. MergeStatus merge_status)
  3653. {
  3654. /*
  3655. * If this indication shows that a domain merger is in progress, set the
  3656. * boolean flag that prevents the sending of MCS commands to the domain.
  3657. * Otherwise, reset it.
  3658. */
  3659. if (merge_status == MERGE_DOMAIN_IN_PROGRESS)
  3660. {
  3661. TRACE_OUT (("Connection::MergeDomainIndication: entering merge state"));
  3662. Merge_In_Progress = TRUE;
  3663. }
  3664. else
  3665. {
  3666. TRACE_OUT (("Connection::MergeDomainIndication: leaving merge state"));
  3667. Merge_In_Progress = FALSE;
  3668. }
  3669. }
  3670. /*
  3671. * Void SendPacket ()
  3672. *
  3673. * Private
  3674. *
  3675. * Functional Description:
  3676. * This routine is called in order to create a packet which will hold
  3677. * the PDU to be sent to the remote provider. The packet will be queued
  3678. * up for transmission through the transport interface.
  3679. *
  3680. * Caveats:
  3681. * None.
  3682. */
  3683. Void Connection::SendPacket (
  3684. PVoid pdu_structure,
  3685. int pdu_type,
  3686. Priority priority)
  3687. {
  3688. unsigned int encoding_rules;
  3689. PPacket packet;
  3690. PacketError packet_error;
  3691. BOOL bFlush;
  3692. /*
  3693. * Set the appropriate encoding rules for this PDU according to what type
  3694. * it is.
  3695. */
  3696. if (pdu_type == CONNECT_MCS_PDU) {
  3697. encoding_rules = BASIC_ENCODING_RULES;
  3698. bFlush = FALSE;
  3699. // TRACE_OUT(("Connect SendPacket: PDU type: %d", (UINT) ((ConnectMCSPDU *) pdu_structure)->choice));
  3700. }
  3701. else {
  3702. encoding_rules = Encoding_Rules;
  3703. bFlush = TRUE;
  3704. // TRACE_OUT(("Domain SendPacket: PDU type: %d", (UINT) ((DomainMCSPDU *) pdu_structure)->choice));
  3705. }
  3706. /*
  3707. * Create a packet which will be used to hold the data to be sent
  3708. * through the transport interface. Check to make sure the packet is
  3709. * successfully created. Issue a callback to the controller requesting
  3710. * deletion of this connection if the packet is not successfully created.
  3711. */
  3712. DBG_SAVE_FILE_LINE
  3713. packet = new Packet (
  3714. (PPacketCoder) g_MCSCoder,
  3715. encoding_rules,
  3716. pdu_structure,
  3717. (int) pdu_type,
  3718. Upward_Connection,
  3719. &packet_error);
  3720. if (packet != NULL)
  3721. {
  3722. if (packet_error == PACKET_NO_ERROR)
  3723. {
  3724. /*
  3725. * Lock the encoded PDU data and queue the packet up for
  3726. * transmission through the transport interface.
  3727. */
  3728. QueueForTransmission ((PSimplePacket) packet, priority, bFlush);
  3729. }
  3730. else
  3731. {
  3732. /*
  3733. * The packet creation has failed due to an internal error so
  3734. * issue an owner callback to ask for deletion.
  3735. */
  3736. DestroyConnection (REASON_PROVIDER_INITIATED);
  3737. }
  3738. /*
  3739. * The packet is freed here so that it will be deleted when it's lock
  3740. * count reaches zero.
  3741. */
  3742. packet->Unlock ();
  3743. }
  3744. else
  3745. {
  3746. /*
  3747. * The packet creation has failed so issue an owner callback
  3748. * to ask for deletion.
  3749. */
  3750. DestroyConnection (REASON_PROVIDER_INITIATED);
  3751. }
  3752. }
  3753. /*
  3754. * Void QueueForTransmission()
  3755. *
  3756. * Private
  3757. *
  3758. * Functional Description:
  3759. * This routine encodes a PDU and places data units into the transmission queue so
  3760. * they can be transmitted through the transport interface when possible.
  3761. * An attempt is made to flush the queue and the transmitter is polled
  3762. * in order to go ahead and send the data immediately, if possible, instead
  3763. * of waiting for a timer event to occur.
  3764. *
  3765. * Caveats:
  3766. * None.
  3767. */
  3768. Void Connection::QueueForTransmission (
  3769. PSimplePacket packet,
  3770. Priority priority,
  3771. BOOL bFlush)
  3772. {
  3773. int p;
  3774. ASSERT (g_Transport != NULL);
  3775. packet->Lock();
  3776. /*
  3777. * Attempt to set the packet directly to the transport without queueing it.
  3778. * If this is done, it can eliminate queueing time and a thread switch.
  3779. * For this to be possible, all higher priorities must have no pending
  3780. * packets and the bFlush parameter should be TRUE.
  3781. */
  3782. if (bFlush) {
  3783. for (p = (int) TOP_PRIORITY; p <= (int) priority; p++) {
  3784. if (m_OutPktQueue[p].GetCount() > 0)
  3785. break;
  3786. }
  3787. if (p > priority) {
  3788. /*
  3789. * There are no packets queued up for higher priorities. We can attempt
  3790. * to send the packet directly, by-passing the queue.
  3791. */
  3792. if (FlushAMessage (packet, priority)) {
  3793. return;
  3794. }
  3795. }
  3796. }
  3797. /*
  3798. * Place the data unit in the proper queue. Increment the counter for that
  3799. * queue and increment the transmission counter.
  3800. */
  3801. m_OutPktQueue[priority].Append(packet);
  3802. /*
  3803. * If this is the first packet queued up for the specified priority,
  3804. * then we must send a DataRequestReady to the transport interface
  3805. * object. Note that if other packets are already queued up, then it
  3806. * is not necessary to inform the transport interface object, since it
  3807. * already knows it has at least one).
  3808. */
  3809. if (m_OutPktQueue[priority].GetCount() == 1)
  3810. g_Transport->DataRequestReady ();
  3811. }
  3812. /*
  3813. * BOOL FlushAMessage()
  3814. *
  3815. * Private
  3816. *
  3817. * Functional Description:
  3818. * This routine will only flush one MCS PDU to the transport layer.
  3819. *
  3820. * Parameters:
  3821. * packet: the packet to send.
  3822. * priority: the packet's priority
  3823. *
  3824. * Return value:
  3825. * TRUE, if the message was successfully sent. FALSE, otherwise.
  3826. *
  3827. */
  3828. BOOL Connection::FlushAMessage (PSimplePacket packet, Priority priority)
  3829. {
  3830. if (Domain_Traffic_Allowed == FALSE && packet->GetPDUType () == DOMAIN_MCS_PDU) {
  3831. return FALSE;
  3832. }
  3833. if (packet->IsDataPacket())
  3834. ((PDataPacket) packet)->SetDirection (Upward_Connection);
  3835. /*
  3836. * Send the PDU to the transport interface.
  3837. */
  3838. if (DataRequest (Transport_Connection[priority], packet) != TRANSPORT_WRITE_QUEUE_FULL) {
  3839. packet->Unlock();
  3840. return TRUE;
  3841. }
  3842. return FALSE;
  3843. }
  3844. /*
  3845. * Void FlushMessageQueue()
  3846. *
  3847. * Private
  3848. *
  3849. * Functional Description:
  3850. * This routine flushes the transmit queue by copying the data unit
  3851. * into the output buffer and calling into the transport interface to
  3852. * give it a chance to accept the data.
  3853. *
  3854. * Return value:
  3855. * TRUE, if there remain un-processed msgs in the connection message queue
  3856. * FALSE, if all the msgs in the connection msg queue were processed.
  3857. *
  3858. * Caveats:
  3859. * None.
  3860. */
  3861. BOOL Connection::FlushMessageQueue()
  3862. {
  3863. int priority;
  3864. BOOL return_value = FALSE;
  3865. ASSERT (g_Transport != NULL);
  3866. /*
  3867. * Loop through all four priority levels of transmission queues.
  3868. */
  3869. for (priority = 0; priority < MAXIMUM_PRIORITIES; priority++) {
  3870. if (m_OutPktQueue[priority].GetCount() > 0) {
  3871. return_value |= FlushPriority ((Priority) priority);
  3872. }
  3873. }
  3874. return (return_value);
  3875. }
  3876. /*
  3877. * BOOL FlushPriority ()
  3878. *
  3879. * Private
  3880. *
  3881. * Functional Description:
  3882. *
  3883. * Return value:
  3884. * TRUE, if there remain un-processed msgs in the connection message queue
  3885. * FALSE, if all the msgs in the connection msg queue were processed.
  3886. *
  3887. * Caveats:
  3888. * None.
  3889. */
  3890. BOOL Connection::FlushPriority (
  3891. Priority priority)
  3892. {
  3893. PSimplePacket packet;
  3894. BOOL return_value = FALSE;
  3895. /*
  3896. * Check to see if the transport connection for this priority is
  3897. * ready. If not, skip it for now.
  3898. */
  3899. if (Transport_Connection_State[priority] == TRANSPORT_CONNECTION_READY)
  3900. {
  3901. /*
  3902. * If there is no packet in the queue, we may be here to send the
  3903. * remainder of a packet that has been accepted by transport earlier.
  3904. * We need to flush this remainder of the packet.
  3905. */
  3906. if (m_OutPktQueue[priority].IsEmpty()) {
  3907. if (DataRequest (Transport_Connection[priority], NULL) == TRANSPORT_WRITE_QUEUE_FULL) {
  3908. return_value = TRUE;
  3909. }
  3910. }
  3911. else {
  3912. /*
  3913. * While data exists in this queue and the transport interface is
  3914. * able to accept it, retrieve the next packet from the queue and
  3915. * send the data to the transport interface.
  3916. */
  3917. while (NULL != (packet = m_OutPktQueue[priority].Get()))
  3918. {
  3919. if (! FlushAMessage (packet, priority))
  3920. {
  3921. /*
  3922. * If the transport layer has rejected the PDU, then it is
  3923. * necessary to leave it in the queue (at the front).
  3924. * Then break out of the loop to prevent additional
  3925. * attempts to transmit data at this priority.
  3926. */
  3927. return_value = TRUE;
  3928. if (packet != NULL) {
  3929. m_OutPktQueue[priority].Prepend(packet);
  3930. }
  3931. break;
  3932. }
  3933. }
  3934. }
  3935. }
  3936. else
  3937. return_value = TRUE;
  3938. return (return_value);
  3939. }
  3940. /*
  3941. * ULong OwnerCallback()
  3942. *
  3943. * Private
  3944. *
  3945. * Functional Description:
  3946. * This routine allows the transport interface to call into the connection
  3947. * in order to notify the connection of data reception. This routine
  3948. * decodes the incoming data, notifies the controller if necessary and/or
  3949. * makes the necessary calls into the domain.
  3950. *
  3951. * Caveats:
  3952. * None.
  3953. */
  3954. TransportError Connection::HandleDataIndication
  3955. (
  3956. PTransportData pTransport_data,
  3957. TransportConnection transport_connection
  3958. )
  3959. {
  3960. int priority;
  3961. TransportError rc = TRANSPORT_NO_ERROR;
  3962. /*
  3963. * Data is being received through the transport interface. Determine
  3964. * what priority this data is arriving at. This will be used to see
  3965. * what type of PDU this is supposed to be (CONNECT or DOMAIN).
  3966. */
  3967. for (priority = 0; priority < MAXIMUM_PRIORITIES; priority++)
  3968. {
  3969. if (IS_SAME_TRANSPORT_CONNECTION(Transport_Connection[priority], transport_connection))
  3970. {
  3971. break;
  3972. }
  3973. }
  3974. /*
  3975. * Make sure that this transport connection was somewhere in the the
  3976. * transport connection list before processing the PDU. If it was not,
  3977. * then report an error and ignore the PDU.
  3978. */
  3979. if (priority < MAXIMUM_PRIORITIES)
  3980. {
  3981. int pdu_type;
  3982. unsigned int encoding_rules;
  3983. PSimplePacket packet;
  3984. PacketError packet_error;
  3985. PVoid pdu_structure;
  3986. /*
  3987. * Determine what type of PDU this should be.
  3988. */
  3989. pdu_type = Transport_Connection_PDU_Type[priority];
  3990. /*
  3991. * Set the appropriate encoding rules for this PDU according to
  3992. * what type it is.
  3993. */
  3994. encoding_rules = (pdu_type == CONNECT_MCS_PDU) ? BASIC_ENCODING_RULES :
  3995. Encoding_Rules;
  3996. /*
  3997. * Get the pointer to the data indication structure from the the
  3998. * parameter list. Then construct a packet object to represent
  3999. * this inbound data.
  4000. */
  4001. /*
  4002. * Crete a Packet or a DataPacket, depending on whether this
  4003. * is an MCS data packet.
  4004. */
  4005. if (g_MCSCoder->IsMCSDataPacket (
  4006. pTransport_data->user_data + PROTOCOL_OVERHEAD_X224,
  4007. encoding_rules))
  4008. {
  4009. ASSERT (encoding_rules == PACKED_ENCODING_RULES);
  4010. DBG_SAVE_FILE_LINE
  4011. packet = (PSimplePacket) new DataPacket (pTransport_data,
  4012. ! Upward_Connection);
  4013. packet_error = PACKET_NO_ERROR;
  4014. }
  4015. else
  4016. {
  4017. DBG_SAVE_FILE_LINE
  4018. packet = (PSimplePacket) new Packet (
  4019. (PPacketCoder) g_MCSCoder,
  4020. encoding_rules,
  4021. pTransport_data->user_data + PROTOCOL_OVERHEAD_X224,
  4022. pTransport_data->user_data_length - PROTOCOL_OVERHEAD_X224,
  4023. pdu_type, ! Upward_Connection,
  4024. &packet_error);
  4025. }
  4026. if (packet != NULL)
  4027. {
  4028. if (packet_error == PACKET_NO_ERROR)
  4029. {
  4030. /*
  4031. * Retrieve a pointer to the decoded data
  4032. */
  4033. pdu_structure = packet->GetDecodedData ();
  4034. /*
  4035. * Process the PDU according to what type it is.
  4036. */
  4037. if (pdu_type == CONNECT_MCS_PDU)
  4038. {
  4039. switch (((PConnectMCSPDU) pdu_structure)->choice)
  4040. {
  4041. case CONNECT_RESPONSE_CHOSEN:
  4042. rc = ProcessConnectResponse (
  4043. &((PConnectMCSPDU) pdu_structure)->
  4044. u.connect_response);
  4045. /*
  4046. * Now that we have received and processed a
  4047. * connect PDU over this transport connection,
  4048. * we must indicate that the next PDU received
  4049. * must be a domain PDU.
  4050. */
  4051. Transport_Connection_PDU_Type[priority] =
  4052. DOMAIN_MCS_PDU;
  4053. break;
  4054. case CONNECT_RESULT_CHOSEN:
  4055. ProcessConnectResult (
  4056. &((PConnectMCSPDU) pdu_structure)->
  4057. u.connect_result);
  4058. /*
  4059. * Now that we have received and processed a
  4060. * connect PDU over this transport connection,
  4061. * we must indicate that the next PDU received
  4062. * must be a domain PDU.
  4063. */
  4064. Transport_Connection_PDU_Type[priority] =
  4065. DOMAIN_MCS_PDU;
  4066. break;
  4067. default:
  4068. /*
  4069. * We have received a PDU that should not have
  4070. * been received. Ignore it.
  4071. */
  4072. ERROR_OUT (("Connection::HandleDataIndication: Unknown ConnectMCSPDU Rxd"));
  4073. break;
  4074. }
  4075. }
  4076. else
  4077. {
  4078. /*
  4079. * Verify that current conditions are appropriate for a request to be
  4080. * accepted from a transport connection.
  4081. */
  4082. rc = ValidateConnectionRequest ();
  4083. if (rc == TRANSPORT_NO_ERROR)
  4084. {
  4085. switch (((PDomainMCSPDU) pdu_structure)->choice)
  4086. {
  4087. case SEND_DATA_REQUEST_CHOSEN:
  4088. ProcessSendDataRequest (
  4089. &((PDomainMCSPDU) pdu_structure)->u.
  4090. send_data_request, (PDataPacket) packet);
  4091. break;
  4092. case SEND_DATA_INDICATION_CHOSEN:
  4093. ProcessSendDataIndication (
  4094. &((PDomainMCSPDU) pdu_structure)->u.
  4095. send_data_indication, (PDataPacket) packet);
  4096. break;
  4097. case UNIFORM_SEND_DATA_REQUEST_CHOSEN:
  4098. ProcessUniformSendDataRequest (
  4099. &((PDomainMCSPDU) pdu_structure)->u.
  4100. uniform_send_data_request, (PDataPacket) packet);
  4101. break;
  4102. case UNIFORM_SEND_DATA_INDICATION_CHOSEN:
  4103. ProcessUniformSendDataIndication (
  4104. &((PDomainMCSPDU) pdu_structure)->u.
  4105. uniform_send_data_indication, (PDataPacket) packet);
  4106. break;
  4107. case PLUMB_DOMAIN_INDICATION_CHOSEN:
  4108. ProcessPlumbDomainIndication (
  4109. &((PDomainMCSPDU) pdu_structure)->u.
  4110. plumb_domain_indication);
  4111. break;
  4112. case ERECT_DOMAIN_REQUEST_CHOSEN:
  4113. ProcessErectDomainRequest (
  4114. &((PDomainMCSPDU) pdu_structure)->u.
  4115. erect_domain_request);
  4116. break;
  4117. case MERGE_CHANNELS_REQUEST_CHOSEN:
  4118. rc = ProcessMergeChannelsRequest (
  4119. &((PDomainMCSPDU) pdu_structure)->u.
  4120. merge_channels_request);
  4121. break;
  4122. case MERGE_CHANNELS_CONFIRM_CHOSEN:
  4123. rc = ProcessMergeChannelsConfirm (
  4124. &((PDomainMCSPDU) pdu_structure)->u.
  4125. merge_channels_confirm);
  4126. break;
  4127. case PURGE_CHANNEL_INDICATION_CHOSEN:
  4128. ProcessPurgeChannelIndication (
  4129. &((PDomainMCSPDU) pdu_structure)->u.
  4130. purge_channel_indication);
  4131. break;
  4132. case MERGE_TOKENS_REQUEST_CHOSEN:
  4133. rc = ProcessMergeTokensRequest (
  4134. &((PDomainMCSPDU) pdu_structure)->u.
  4135. merge_tokens_request);
  4136. break;
  4137. case MERGE_TOKENS_CONFIRM_CHOSEN:
  4138. rc = ProcessMergeTokensConfirm (
  4139. &((PDomainMCSPDU) pdu_structure)->u.
  4140. merge_tokens_confirm);
  4141. break;
  4142. case PURGE_TOKEN_INDICATION_CHOSEN:
  4143. ProcessPurgeTokenIndication (
  4144. &((PDomainMCSPDU) pdu_structure)->u.
  4145. purge_token_indication);
  4146. break;
  4147. case DISCONNECT_PROVIDER_ULTIMATUM_CHOSEN:
  4148. ProcessDisconnectProviderUltimatum (
  4149. &((PDomainMCSPDU) pdu_structure)->u.
  4150. disconnect_provider_ultimatum);
  4151. break;
  4152. case REJECT_ULTIMATUM_CHOSEN:
  4153. ProcessRejectUltimatum (
  4154. &((PDomainMCSPDU) pdu_structure)->u.
  4155. reject_user_ultimatum);
  4156. break;
  4157. case ATTACH_USER_REQUEST_CHOSEN:
  4158. ProcessAttachUserRequest (
  4159. &((PDomainMCSPDU) pdu_structure)->u.
  4160. attach_user_request);
  4161. break;
  4162. case ATTACH_USER_CONFIRM_CHOSEN:
  4163. ProcessAttachUserConfirm (
  4164. &((PDomainMCSPDU) pdu_structure)->u.
  4165. attach_user_confirm);
  4166. break;
  4167. case DETACH_USER_REQUEST_CHOSEN:
  4168. ProcessDetachUserRequest (
  4169. &((PDomainMCSPDU) pdu_structure)->u.
  4170. detach_user_request);
  4171. break;
  4172. case DETACH_USER_INDICATION_CHOSEN:
  4173. ProcessDetachUserIndication (
  4174. &((PDomainMCSPDU) pdu_structure)->u.
  4175. detach_user_indication);
  4176. break;
  4177. case CHANNEL_JOIN_REQUEST_CHOSEN:
  4178. ProcessChannelJoinRequest (
  4179. &((PDomainMCSPDU) pdu_structure)->u.
  4180. channel_join_request);
  4181. break;
  4182. case CHANNEL_JOIN_CONFIRM_CHOSEN:
  4183. ProcessChannelJoinConfirm (
  4184. &((PDomainMCSPDU) pdu_structure)->u.
  4185. channel_join_confirm);
  4186. break;
  4187. case CHANNEL_LEAVE_REQUEST_CHOSEN:
  4188. ProcessChannelLeaveRequest (
  4189. &((PDomainMCSPDU) pdu_structure)->u.
  4190. channel_leave_request);
  4191. break;
  4192. case CHANNEL_CONVENE_REQUEST_CHOSEN:
  4193. ProcessChannelConveneRequest (
  4194. &((PDomainMCSPDU) pdu_structure)->u.
  4195. channel_convene_request);
  4196. break;
  4197. case CHANNEL_CONVENE_CONFIRM_CHOSEN:
  4198. ProcessChannelConveneConfirm (
  4199. &((PDomainMCSPDU) pdu_structure)->u.
  4200. channel_convene_confirm);
  4201. break;
  4202. case CHANNEL_DISBAND_REQUEST_CHOSEN:
  4203. ProcessChannelDisbandRequest (
  4204. &((PDomainMCSPDU) pdu_structure)->u.
  4205. channel_disband_request);
  4206. break;
  4207. case CHANNEL_DISBAND_INDICATION_CHOSEN:
  4208. ProcessChannelDisbandIndication (
  4209. &((PDomainMCSPDU) pdu_structure)->u.
  4210. channel_disband_indication);
  4211. break;
  4212. case CHANNEL_ADMIT_REQUEST_CHOSEN:
  4213. ProcessChannelAdmitRequest (
  4214. &((PDomainMCSPDU) pdu_structure)->u.
  4215. channel_admit_request);
  4216. break;
  4217. case CHANNEL_ADMIT_INDICATION_CHOSEN:
  4218. ProcessChannelAdmitIndication (
  4219. &((PDomainMCSPDU) pdu_structure)->u.
  4220. channel_admit_indication);
  4221. break;
  4222. case CHANNEL_EXPEL_REQUEST_CHOSEN:
  4223. ProcessChannelExpelRequest (
  4224. &((PDomainMCSPDU) pdu_structure)->u.
  4225. channel_expel_request);
  4226. break;
  4227. case CHANNEL_EXPEL_INDICATION_CHOSEN:
  4228. ProcessChannelExpelIndication (
  4229. &((PDomainMCSPDU) pdu_structure)->u.
  4230. channel_expel_indication);
  4231. break;
  4232. case TOKEN_GRAB_REQUEST_CHOSEN:
  4233. ProcessTokenGrabRequest (
  4234. &((PDomainMCSPDU) pdu_structure)->u.
  4235. token_grab_request);
  4236. break;
  4237. case TOKEN_GRAB_CONFIRM_CHOSEN:
  4238. ProcessTokenGrabConfirm (
  4239. &((PDomainMCSPDU) pdu_structure)->u.
  4240. token_grab_confirm);
  4241. break;
  4242. case TOKEN_INHIBIT_REQUEST_CHOSEN:
  4243. ProcessTokenInhibitRequest (
  4244. &((PDomainMCSPDU) pdu_structure)->u.
  4245. token_inhibit_request);
  4246. break;
  4247. case TOKEN_INHIBIT_CONFIRM_CHOSEN:
  4248. ProcessTokenInhibitConfirm (
  4249. &((PDomainMCSPDU) pdu_structure)->u.
  4250. token_inhibit_confirm);
  4251. break;
  4252. case TOKEN_GIVE_REQUEST_CHOSEN:
  4253. ProcessTokenGiveRequest (
  4254. &((PDomainMCSPDU) pdu_structure)->u.
  4255. token_give_request);
  4256. break;
  4257. case TOKEN_GIVE_INDICATION_CHOSEN:
  4258. ProcessTokenGiveIndication (
  4259. &((PDomainMCSPDU) pdu_structure)->u.
  4260. token_give_indication);
  4261. break;
  4262. case TOKEN_GIVE_RESPONSE_CHOSEN:
  4263. ProcessTokenGiveResponse (
  4264. &((PDomainMCSPDU) pdu_structure)->u.
  4265. token_give_response);
  4266. break;
  4267. case TOKEN_GIVE_CONFIRM_CHOSEN:
  4268. ProcessTokenGiveConfirm (
  4269. &((PDomainMCSPDU) pdu_structure)->u.
  4270. token_give_confirm);
  4271. break;
  4272. case TOKEN_PLEASE_REQUEST_CHOSEN:
  4273. ProcessTokenPleaseRequest (
  4274. &((PDomainMCSPDU) pdu_structure)->u.
  4275. token_please_request);
  4276. break;
  4277. case TOKEN_PLEASE_INDICATION_CHOSEN:
  4278. ProcessTokenPleaseIndication (
  4279. &((PDomainMCSPDU) pdu_structure)->u.
  4280. token_please_indication);
  4281. break;
  4282. case TOKEN_RELEASE_REQUEST_CHOSEN:
  4283. ProcessTokenReleaseRequest (
  4284. &((PDomainMCSPDU) pdu_structure)->u.
  4285. token_release_request);
  4286. break;
  4287. case TOKEN_RELEASE_CONFIRM_CHOSEN:
  4288. ProcessTokenReleaseConfirm (
  4289. &((PDomainMCSPDU) pdu_structure)->u.
  4290. token_release_confirm);
  4291. break;
  4292. case TOKEN_TEST_REQUEST_CHOSEN:
  4293. ProcessTokenTestRequest (
  4294. &((PDomainMCSPDU) pdu_structure)->u.
  4295. token_test_request);
  4296. break;
  4297. case TOKEN_TEST_CONFIRM_CHOSEN:
  4298. ProcessTokenTestConfirm (
  4299. &((PDomainMCSPDU) pdu_structure)->u.
  4300. token_test_confirm);
  4301. break;
  4302. default:
  4303. ERROR_OUT (("Connection::HandleDataIndication: Unknown DomainMCSPDU Rxd"));
  4304. break;
  4305. }
  4306. }
  4307. else
  4308. {
  4309. ASSERT (TRANSPORT_READ_QUEUE_FULL == rc);
  4310. if (packet->IsDataPacket())
  4311. {
  4312. /*
  4313. * We are returning TRANSPORT_READ_QUEUE_FULL to the transport.
  4314. * The transport will attempt to deliver the data again later.
  4315. * However, we have to delete the DataPacket we created here, which
  4316. * will attempt to free the buffer that will be delivered again
  4317. * later. So, let's lock it now.
  4318. */
  4319. LockMemory (pTransport_data->memory);
  4320. }
  4321. }
  4322. }
  4323. /* If this was a non-data PDU, we need to free up the transport
  4324. * buffer with the original data.
  4325. */
  4326. if ((! packet->IsDataPacket()) && (rc == TRANSPORT_NO_ERROR))
  4327. FreeMemory (pTransport_data->memory);
  4328. /*
  4329. * Free the packet. This will result in the destruction of the
  4330. * packet unless it is a "Send Data" packet which has been
  4331. * locked by someone else.
  4332. */
  4333. packet->Unlock ();
  4334. }
  4335. else
  4336. {
  4337. /*
  4338. * Although the construction of the packet object itself
  4339. * was successful, an error was generated in its
  4340. * constructor. We must therefore reject the packet.
  4341. */
  4342. WARNING_OUT (("Connection::HandleDataIndication: packet constructor failure"));
  4343. delete packet;
  4344. rc = TRANSPORT_READ_QUEUE_FULL;
  4345. }
  4346. }
  4347. else
  4348. {
  4349. /*
  4350. * We were not able to construct a packet object to represent
  4351. * the inbound data. It is therefore necessary to reject the
  4352. * data from the transport layer, so that it can be retried
  4353. * later.
  4354. */
  4355. WARNING_OUT (("Connection::HandleDataIndication: packet allocation failure"));
  4356. rc = TRANSPORT_READ_QUEUE_FULL;
  4357. }
  4358. }
  4359. else
  4360. {
  4361. /*
  4362. * This transport connection is not listed as one of the ones being
  4363. * used by this MCS connection. It is therefore necessary to
  4364. * ignore the PDU.
  4365. */
  4366. WARNING_OUT (("Connection::HandleDataIndication: unknown transport connection"));
  4367. }
  4368. return rc;
  4369. }
  4370. void Connection::HandleBufferEmptyIndication
  4371. (
  4372. TransportConnection transport_connection
  4373. )
  4374. {
  4375. /*
  4376. * Determine what priority this indication is associated with.
  4377. */
  4378. for (int priority = 0; priority < MAXIMUM_PRIORITIES; priority++)
  4379. {
  4380. if (IS_SAME_TRANSPORT_CONNECTION(Transport_Connection[priority], transport_connection))
  4381. /*
  4382. * Try to flush existing data downward.
  4383. */
  4384. FlushPriority ((Priority) priority);
  4385. }
  4386. }
  4387. void Connection::HandleConnectConfirm
  4388. (
  4389. TransportConnection transport_connection
  4390. )
  4391. {
  4392. /*
  4393. * A confirm has been received as the result of an outbound connect
  4394. * request. This tells us that the request was successful.
  4395. */
  4396. TRACE_OUT (("Connection::HandleConnectConfirm: received CONNECT_CONFIRM"));
  4397. for (int priority = 0; priority < MAXIMUM_PRIORITIES; priority++)
  4398. {
  4399. if (IS_SAME_TRANSPORT_CONNECTION(Transport_Connection[priority], transport_connection) &&
  4400. (Transport_Connection_State[priority] == TRANSPORT_CONNECTION_PENDING))
  4401. {
  4402. Transport_Connection_State[priority] = TRANSPORT_CONNECTION_READY;
  4403. }
  4404. }
  4405. }
  4406. void Connection::HandleDisconnectIndication
  4407. (
  4408. TransportConnection transport_connection,
  4409. ULONG *pnNotify
  4410. )
  4411. {
  4412. Reason reason;
  4413. /*
  4414. * A disconnection indication has been received through the transport
  4415. * interface. Notify the controller and the domain and set the flag
  4416. * indicating a connection deletion is pending.
  4417. */
  4418. TRACE_OUT (("Connection::HandleDisconnectIndication: received DISCONNECT_INDICATION"));
  4419. /*
  4420. * For each priority level that is using that disconnected
  4421. * transport connection, mark it as unassigned. This serves two
  4422. * purposes. First, it prevents any attempt to send data on the
  4423. * transport connection that is no longer valid. Second, it
  4424. * prevents the destructor of this object from sending a
  4425. * disconnect request.
  4426. */
  4427. for (int priority = 0; priority < MAXIMUM_PRIORITIES; priority++)
  4428. {
  4429. if (IS_SAME_TRANSPORT_CONNECTION(Transport_Connection[priority], transport_connection))
  4430. {
  4431. Transport_Connection_State[priority] = TRANSPORT_CONNECTION_UNASSIGNED;
  4432. }
  4433. }
  4434. /*
  4435. * Losing ANY of its transport connections is fatal to an MCS
  4436. * connection. Therefore, this connection object must delete
  4437. * itself.
  4438. */
  4439. ASSERT(pnNotify);
  4440. switch (*pnNotify)
  4441. {
  4442. case TPRT_NOTIFY_REMOTE_NO_SECURITY :
  4443. reason = REASON_REMOTE_NO_SECURITY;
  4444. break;
  4445. case TPRT_NOTIFY_REMOTE_DOWNLEVEL_SECURITY :
  4446. reason = REASON_REMOTE_DOWNLEVEL_SECURITY;
  4447. break;
  4448. case TPRT_NOTIFY_REMOTE_REQUIRE_SECURITY :
  4449. reason = REASON_REMOTE_REQUIRE_SECURITY;
  4450. break;
  4451. case TPRT_NOTIFY_AUTHENTICATION_FAILED:
  4452. reason = REASON_AUTHENTICATION_FAILED;
  4453. break;
  4454. default :
  4455. reason = REASON_DOMAIN_DISCONNECTED;
  4456. break;
  4457. }
  4458. DestroyConnection (reason);
  4459. }
  4460. void CChannelIDList::BuildExternalList(PSetOfChannelIDs *ppChannelIDs)
  4461. {
  4462. PSetOfChannelIDs p = *ppChannelIDs;
  4463. ChannelID chid;
  4464. if (p != NULL)
  4465. {
  4466. /*
  4467. * Iterate through the set of channel ids, filling in the PDU
  4468. * structure.
  4469. */
  4470. for (Reset(); NULL != (chid = Iterate()); p++)
  4471. {
  4472. p->value = chid;
  4473. p->next = p + 1;
  4474. }
  4475. /*
  4476. * Decrement the pointer in order to set the last "next"
  4477. * pointer to NULL.
  4478. */
  4479. (p - 1)->next = NULL;
  4480. *ppChannelIDs = p;
  4481. }
  4482. }
  4483. void CTokenIDList::BuildExternalList(PSetOfTokenIDs *ppTokenIDs)
  4484. {
  4485. PSetOfTokenIDs p = *ppTokenIDs;
  4486. TokenID tid;
  4487. if (p != NULL)
  4488. {
  4489. /*
  4490. * Iterate through the set of token ids, filling in the PDU
  4491. * structure.
  4492. */
  4493. for (Reset(); NULL != (tid = Iterate()); p++)
  4494. {
  4495. p->value = tid;
  4496. p->next = p + 1;
  4497. }
  4498. /*
  4499. * Decrement the pointer in order to set the last "next"
  4500. * pointer to NULL.
  4501. */
  4502. (p - 1)->next = NULL;
  4503. *ppTokenIDs = p;
  4504. }
  4505. }
  4506. void CUidList::BuildExternalList(PSetOfUserIDs *ppUserIDs)
  4507. {
  4508. PSetOfUserIDs p = *ppUserIDs;
  4509. UserID uid;
  4510. if (p != NULL)
  4511. {
  4512. /*
  4513. * Iterate through the set of user ids, filling in the PDU
  4514. * structure.
  4515. */
  4516. for (Reset(); NULL != (uid = Iterate()); p++)
  4517. {
  4518. p->value = uid;
  4519. p->next = p + 1;
  4520. }
  4521. /*
  4522. * Decrement the pointer in order to set the last "next"
  4523. * pointer to NULL.
  4524. */
  4525. (p - 1)->next = NULL;
  4526. *ppUserIDs = p;
  4527. }
  4528. }
  4529.