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.

3724 lines
106 KiB

  1. #include "precomp.h"
  2. DEBUG_FILEZONE(ZONE_T120_GCCNC);
  3. /*
  4. * gcontrol.cpp
  5. *
  6. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  7. *
  8. * Abstract:
  9. * This module manages the creation and deletion of various objects
  10. * within GCC. This includes the Control SAP, the Application SAPs, the
  11. * Conference objectis indexed by the Conference ID. Primitives are
  12. * routed to the as and the MCS interface. Conferences are maintained
  13. * in a list that ppropriate conference object based on the Conference ID.
  14. * The controller module is also responsible for routing Connect Provider
  15. * indications to the appropriate destination.
  16. *
  17. * SEE THE INTERFACE FILE FOR A MORE DETAILED EXPLANATION OF THIS CLASS
  18. *
  19. * Portable:
  20. * Not Completely
  21. *
  22. * Protected Instance Variables:
  23. * None.
  24. *
  25. * Private Instance Variables:
  26. * g_pMCSIntf - Pointer to the MCS Interface object.
  27. * All request to MCS and all callbacks
  28. * received from MCS travel through this
  29. * interface.
  30. * m_ConfList2 - This list maintains the active
  31. * conference objects.
  32. * m_ConfPollList - The conference poll list is used when
  33. * polling the conference objects. A
  34. * seperate poll list is needed from the
  35. * conference list to avoid any changes
  36. * to the rogue wave list while it is
  37. * being iterated on.
  38. * m_AppSapList - This list maintains all the registered
  39. * application SAP objects.
  40. * m_PendingCreateConfList2 - This list is used to maintain
  41. * conference information for pending
  42. * conference objects that have not
  43. * yet been created (i.e. CreateRequest
  44. * has been received but not the Create
  45. * Response).
  46. * m_PendingJoinConfList2 - This list is used to maintain the
  47. * join information for pending
  48. * conference joins that have not
  49. * yet been accepted (i.e. JoinRequest
  50. * has been received but not the Join
  51. * Response).
  52. * m_ConfDeleteList - This list contains any conference
  53. * objects that have been marked for
  54. * deletion. Once a conference object is
  55. * put into this list on the next call to
  56. * PollCommDevices it will be deleted.
  57. * m_fConfListChangePending This flag is used to inform when the
  58. * m_ConfList2 changes. This includes
  59. * when items are added as well as deleted.
  60. * m_ConfIDCounter - This instance variable is used to
  61. * generate Conference IDs.
  62. * m_QueryIDCounter - This instance variable is used to
  63. * generate the DomainSelector used in the
  64. * query request.
  65. * m_PendingQueryConfList2 - This list contains the query id (used
  66. * for the domain selector in the query
  67. * request). This query id needs to be
  68. * kept around so that the domain selector
  69. * can be deleted when the query response
  70. * comes back in (or if the controller is
  71. * deleted before the confirm comes back).
  72. *
  73. *
  74. * WIN32 related instance variables:
  75. *
  76. * g_hevGCCOutgoingPDU - This is a Windows handle to an event
  77. * object that signals a GCC PDU being
  78. * queued and ready to send on to MCS.
  79. *
  80. * WIN16 related instance variables:
  81. *
  82. * Timer_Procedure - This is the Process Instance of the
  83. * timer procedure used in the Win16
  84. * environment to get an internal
  85. * heartbeat.
  86. * Timer_ID - This is the timer id of the timer that
  87. * may be allocated in the Win16
  88. * constructor.
  89. *
  90. * Caveats:
  91. * None.
  92. *
  93. * Author:
  94. * blp
  95. */
  96. #include <stdio.h>
  97. #include "gcontrol.h"
  98. #include "ogcccode.h"
  99. #include "translat.h"
  100. #include "appldr.h"
  101. /*
  102. ** These ID ranges are used for conferences and queries. Note that
  103. ** conference ID's and query ID's can never conflict. These ID's are
  104. ** used to create the MCS domains.
  105. */
  106. #define MINIMUM_CONFERENCE_ID_VALUE 0x00000001L
  107. #define MAXIMUM_CONFERENCE_ID_VALUE 0x10000000L
  108. #define MINIMUM_QUERY_ID_VALUE 0x10000001L
  109. #define MAXIMUM_QUERY_ID_VALUE 0xffffffffL
  110. /* ------ local data strctures ------ */
  111. /*
  112. ** The join information structure is used to temporarily store
  113. ** information needed to join a conference after the join response is
  114. ** issued.
  115. */
  116. PENDING_JOIN_CONF::PENDING_JOIN_CONF(void)
  117. :
  118. convener_password(NULL),
  119. password_challenge(NULL),
  120. pwszCallerID(NULL)
  121. {
  122. }
  123. PENDING_JOIN_CONF::~PENDING_JOIN_CONF(void)
  124. {
  125. if (NULL != convener_password)
  126. {
  127. convener_password->Release();
  128. }
  129. if (NULL != password_challenge)
  130. {
  131. password_challenge->Release();
  132. }
  133. delete pwszCallerID;
  134. }
  135. /*
  136. ** The conference information structure is used to temporarily store
  137. ** information needed to create a conference while waiting for a
  138. ** conference create response.
  139. */
  140. PENDING_CREATE_CONF::PENDING_CREATE_CONF(void)
  141. :
  142. pszConfNumericName(NULL),
  143. pwszConfTextName(NULL),
  144. conduct_privilege_list(NULL),
  145. conduct_mode_privilege_list(NULL),
  146. non_conduct_privilege_list(NULL),
  147. pwszConfDescription(NULL)
  148. {
  149. }
  150. PENDING_CREATE_CONF::~PENDING_CREATE_CONF(void)
  151. {
  152. delete pszConfNumericName;
  153. delete pwszConfTextName;
  154. delete conduct_privilege_list;
  155. delete conduct_mode_privilege_list;
  156. delete non_conduct_privilege_list;
  157. delete pwszConfDescription;
  158. }
  159. // The DLL's HINSTANCE.
  160. extern HINSTANCE g_hDllInst;
  161. MCSDLLInterface *g_pMCSIntf;
  162. CRITICAL_SECTION g_csGCCProvider;
  163. DWORD g_dwNCThreadID;
  164. HANDLE g_hevGCCOutgoingPDU;
  165. /*
  166. * This is a global variable that has a pointer to the one GCC coder that
  167. * is instantiated by the GCC Controller. Most objects know in advance
  168. * whether they need to use the MCS or the GCC coder, so, they do not need
  169. * this pointer in their constructors.
  170. */
  171. extern CGCCCoder *g_GCCCoder;
  172. /*
  173. * GCCController::GCCController ()
  174. *
  175. * Public Function Description
  176. * This is the Win32 controller constructor. It is responsible for
  177. * creating the application interface and the mcs interface.
  178. * It also creates up the memory manager, the packet coder etc.
  179. */
  180. GCCController::GCCController(PGCCError pRetCode)
  181. :
  182. CRefCount(MAKE_STAMP_ID('C','t','r','l')),
  183. m_ConfIDCounter(MAXIMUM_CONFERENCE_ID_VALUE),
  184. m_QueryIDCounter(MAXIMUM_QUERY_ID_VALUE),
  185. m_fConfListChangePending(FALSE),
  186. m_PendingQueryConfList2(CLIST_DEFAULT_MAX_ITEMS),
  187. m_PendingCreateConfList2(CLIST_DEFAULT_MAX_ITEMS),
  188. m_PendingJoinConfList2(CLIST_DEFAULT_MAX_ITEMS),
  189. m_AppSapList(DESIRED_MAX_APP_SAP_ITEMS),
  190. m_ConfList2(DESIRED_MAX_CONFS),
  191. m_ConfPollList(DESIRED_MAX_CONFS)
  192. {
  193. GCCError rc = GCC_ALLOCATION_FAILURE;
  194. MCSError mcs_rc;
  195. //WNDCLASS wc;
  196. DebugEntry(GCCController::GCCController);
  197. g_dwNCThreadID = ::GetCurrentThreadId();
  198. g_pMCSIntf = NULL;
  199. g_GCCCoder = NULL;
  200. g_hevGCCOutgoingPDU = NULL;
  201. /*
  202. * The allocation of the critical section succeeded, but we must
  203. * initialize it before we can use it.
  204. */
  205. ::InitializeCriticalSection(&g_csGCCProvider);
  206. DBG_SAVE_FILE_LINE
  207. g_GCCCoder = new CGCCCoder ();
  208. if (g_GCCCoder == NULL)
  209. {
  210. /*
  211. * If the packet coder could not be created then report the error.
  212. * This IS a fatal error, so the faulty controller should be
  213. * destroyed and never used.
  214. */
  215. ERROR_OUT(("GCCController::GCCController: failure creating packet coder"));
  216. // rc = GCC_ALLOCATION_FAILURE;
  217. goto MyExit;
  218. }
  219. /*
  220. * We must allocate an event object that will used to notify the
  221. * controller when messages are ready to be processed within the shared
  222. * memory application interface.
  223. */
  224. g_hevGCCOutgoingPDU = ::CreateEvent(NULL, FALSE, FALSE, NULL);
  225. if (g_hevGCCOutgoingPDU == NULL)
  226. {
  227. /*
  228. * Were unable to allocate an event object for this task, so we
  229. * must fail the creation of this controller.
  230. */
  231. ERROR_OUT(("GCCController::GCCController: failure allocating mcs pdu event object"));
  232. // rc = GCC_ALLOCATION_FAILURE;
  233. goto MyExit;
  234. }
  235. DBG_SAVE_FILE_LINE
  236. g_pMCSIntf = new MCSDLLInterface(&mcs_rc);
  237. if ((NULL == g_pMCSIntf) || (mcs_rc != MCS_NO_ERROR))
  238. {
  239. if (NULL != g_pMCSIntf)
  240. {
  241. ERROR_OUT(("GCCController: Error creating MCS Interface, mcs_rc=%u", (UINT) mcs_rc));
  242. rc = g_pMCSIntf->TranslateMCSIFErrorToGCCError(mcs_rc);
  243. }
  244. else
  245. {
  246. ERROR_OUT(("GCCController: can't create MCSDLLInterface"));
  247. // rc = GCC_ALLOCATION_FAILURE;
  248. }
  249. goto MyExit;
  250. }
  251. rc = GCC_NO_ERROR;
  252. MyExit:
  253. *pRetCode = rc;
  254. DebugExitVOID(GCCController::GCCController);
  255. }
  256. /*
  257. * GCCController::~GCCController ()
  258. *
  259. * Public Function Description
  260. * This is the controller destructor. It takes care of freeing up
  261. * many of the objects this class creates.
  262. */
  263. GCCController::~GCCController(void)
  264. {
  265. GCCConfID query_id;
  266. PENDING_JOIN_CONF *lpJoinInfo;
  267. //PConference lpConf;
  268. //CAppSap *lpAppSap;
  269. PENDING_CREATE_CONF *lpConfInfo;
  270. ConnectionHandle hConn;
  271. DebugEntry(GCCController::~GCCController);
  272. /*
  273. * We need to enter the critical section before attempting to clean out
  274. * all of this stuff (if there is a critical section).
  275. */
  276. ::EnterCriticalSection(&g_csGCCProvider);
  277. //
  278. // No one should use this global pointer any more.
  279. //
  280. ASSERT(this == g_pGCCController);
  281. g_pGCCController = NULL;
  282. // Free up any outstanding join info
  283. while (NULL != (lpJoinInfo = m_PendingJoinConfList2.Get(&hConn)))
  284. {
  285. FailConfJoinIndResponse(lpJoinInfo->nConfID, hConn);
  286. delete lpJoinInfo;
  287. }
  288. // Clean up any outstanding query request
  289. while (GCC_INVALID_CID != (query_id = m_PendingQueryConfList2.Get()))
  290. {
  291. g_pMCSIntf->DeleteDomain(&query_id);
  292. }
  293. // Delete any conferences that are left around
  294. m_ConfList2.DeleteList();
  295. // Delete any application SAPs the are left around
  296. m_AppSapList.DeleteList();
  297. // Delete any outstanding conference information
  298. while (NULL != (lpConfInfo = m_PendingCreateConfList2.Get()))
  299. {
  300. delete lpConfInfo;
  301. }
  302. /*
  303. ** If a conference list change is pending we must delete any outstanding
  304. ** conference.
  305. */
  306. if (m_fConfListChangePending)
  307. {
  308. // Delete any outstanding conference objects
  309. m_ConfDeleteList.DeleteList();
  310. m_fConfListChangePending = FALSE;
  311. }
  312. /*
  313. * We can now leave the critical section.
  314. */
  315. ::LeaveCriticalSection(&g_csGCCProvider);
  316. delete g_pMCSIntf;
  317. g_pMCSIntf = NULL;
  318. ::DeleteCriticalSection(&g_csGCCProvider);
  319. ::My_CloseHandle(g_hevGCCOutgoingPDU);
  320. delete g_GCCCoder;
  321. g_GCCCoder = NULL; // do we really need to set it to NULL?
  322. }
  323. void GCCController::RegisterAppSap(CAppSap *pAppSap)
  324. {
  325. CConf *pConf;
  326. DebugEntry(GCCController::RegisterAppSap);
  327. // Update the application SAP list with the new SAP.
  328. pAppSap->AddRef();
  329. m_AppSapList.Append(pAppSap);
  330. /*
  331. ** Here we are registering the SAP with the conference. A permit
  332. ** to enroll indication is also sent here for all the available
  333. ** conferences.
  334. */
  335. m_ConfList2.Reset();
  336. while (NULL != (pConf = m_ConfList2.Iterate()))
  337. {
  338. /*
  339. ** Only register and send the permit for conferences that are
  340. ** established.
  341. */
  342. if (pConf->IsConfEstablished())
  343. {
  344. // Register the application SAP with the conference.
  345. pConf->RegisterAppSap(pAppSap);
  346. }
  347. }
  348. DebugExitVOID(GCCController::RegisterAppSap);
  349. }
  350. void GCCController::UnRegisterAppSap(CAppSap *pAppSap)
  351. {
  352. DebugEntry(GCCController::UnRegisterAppSap);
  353. if (m_AppSapList.Find(pAppSap))
  354. {
  355. CConf *pConf;
  356. m_ConfPollList.Reset();
  357. while (NULL != (pConf = m_ConfPollList.Iterate()))
  358. {
  359. // This routine takes care of all the necessary unenrollments.
  360. pConf->UnRegisterAppSap(pAppSap);
  361. }
  362. /*
  363. ** Here we remove the application SAP object from the list of valid
  364. ** application SAPs and insert it into the list of Application SAPs
  365. ** to be deleted. On the next call to PollCommDevices this
  366. ** SAP object will be deleted.
  367. */
  368. m_AppSapList.Remove(pAppSap);
  369. pAppSap->Release();
  370. }
  371. else
  372. {
  373. ERROR_OUT(("GCCController::UnRegisterAppSap: bad app sap"));
  374. }
  375. DebugExitVOID(GCCController::UnRegisterAppSap);
  376. }
  377. // Calls received from the Control SAP
  378. /*
  379. * GCCController::ConfCreateRequest()
  380. *
  381. * Private Function Description
  382. * This routine is called when the node controller request that
  383. * a conference is created. The conference object is instantiated in
  384. * this routine.
  385. *
  386. * Formal Parameters:
  387. * conf_create_request_info - (i) Information structure that holds
  388. * all the info necessary to create
  389. * a conference.
  390. *
  391. * Return Value
  392. * GCC_NO_ERROR - No error occured.
  393. * GCC_ALLOCATION_FAILURE - A resource error occured.
  394. * GCC_INVALID_CONFERENCE_NAME - Invalid conference name passed in.
  395. * GCC_FAILURE_CREATING_DOMAIN - Failure creating domain.
  396. * GCC_BAD_NETWORK_ADDRESS - Bad network address passed in.
  397. * GCC_BAD_NETWORK_ADDRESS_TYPE - Bad network address type passed in.
  398. * GCC_CONFERENCE_ALREADY_EXISTS - Conference specified already exists.
  399. * GCC_INVALID_TRANSPORT - Cannot find specified transport.
  400. * GCC_INVALID_ADDRESS_PREFIX - Bad transport address passed in.
  401. * GCC_INVALID_TRANSPORT_ADDRESS - Bad transport address
  402. * GCC_INVALID_PASSWORD - Invalid password passed in.
  403. * GCC_FAILURE_ATTACHING_TO_MCS - Failure creating MCS user attachment
  404. * GCC_BAD_USER_DATA - Invalid user data passed in.
  405. *
  406. * Side Effects
  407. * None
  408. *
  409. * Caveats
  410. * In the Win32 world we pass in a shared memory manager to the
  411. * conference object to use for the message memory manager. This is
  412. * not necessary in the Win16 world since shared memory is not used.
  413. */
  414. GCCError GCCController::
  415. ConfCreateRequest
  416. (
  417. CONF_CREATE_REQUEST *pCCR,
  418. GCCConfID *pnConfID
  419. )
  420. {
  421. GCCError rc;
  422. PConference new_conference;
  423. GCCConfID conference_id;
  424. CONF_SPEC_PARAMS csp;
  425. DebugEntry(GCCController: ConfCreateRequest);
  426. /*
  427. ** We must first check all the existing conferences to make sure that this
  428. ** conference name is not already in use. We will use an empty conference
  429. ** modifier here for our comparision. Note that this returns immediatly
  430. ** if a conference by the same name alreay exists. Conference names
  431. ** must be unique at a node.
  432. */
  433. conference_id = GetConferenceIDFromName(
  434. pCCR->Core.conference_name,
  435. pCCR->Core.conference_modifier);
  436. if (conference_id != 0)
  437. {
  438. ERROR_OUT(("GCCController:ConfCreateRequest: Conference exists."));
  439. return (GCC_CONFERENCE_ALREADY_EXISTS);
  440. }
  441. /*
  442. ** Here we are allocating a conference ID. In most cases this ID
  443. ** will be the same as the conference name. Only if a conference
  444. ** name is passed in that already exists will the name and ID
  445. ** be different. In this case, a modifier will be appended to the
  446. ** conference name to create the conference ID.
  447. */
  448. conference_id = AllocateConferenceID();
  449. // set up conference specification parameters
  450. csp.fClearPassword = pCCR->Core.use_password_in_the_clear;
  451. csp.fConfLocked = pCCR->Core.conference_is_locked;
  452. csp.fConfListed = pCCR->Core.conference_is_listed;
  453. csp.fConfConductable = pCCR->Core.conference_is_conductible;
  454. csp.eTerminationMethod = pCCR->Core.termination_method;
  455. csp.pConductPrivilege = pCCR->Core.conduct_privilege_list;
  456. csp.pConductModePrivilege = pCCR->Core.conduct_mode_privilege_list;
  457. csp.pNonConductPrivilege = pCCR->Core.non_conduct_privilege_list;
  458. csp.pwszConfDescriptor = pCCR->Core.pwszConfDescriptor;
  459. DBG_SAVE_FILE_LINE
  460. new_conference= new CConf(pCCR->Core.conference_name,
  461. pCCR->Core.conference_modifier,
  462. conference_id,
  463. &csp,
  464. pCCR->Core.number_of_network_addresses,
  465. pCCR->Core.network_address_list,
  466. &rc);
  467. if ((new_conference != NULL) && (rc == GCC_NO_ERROR))
  468. {
  469. rc = new_conference->ConfCreateRequest
  470. (
  471. pCCR->Core.calling_address,
  472. pCCR->Core.called_address,
  473. pCCR->fSecure,
  474. pCCR->convener_password,
  475. pCCR->password,
  476. pCCR->Core.pwszCallerID,
  477. pCCR->Core.domain_parameters,
  478. pCCR->user_data_list,
  479. pCCR->Core.connection_handle
  480. );
  481. if (rc == GCC_NO_ERROR)
  482. {
  483. m_fConfListChangePending = TRUE;
  484. if (NULL != pnConfID)
  485. {
  486. *pnConfID = conference_id;
  487. }
  488. m_ConfList2.Append(conference_id, new_conference);
  489. PostMsgToRebuildConfPollList();
  490. }
  491. else
  492. {
  493. new_conference->Release();
  494. }
  495. }
  496. else
  497. {
  498. ERROR_OUT(("GCCController:ConfCreateRequest: Error occured creating conference"));
  499. if (new_conference != NULL)
  500. {
  501. new_conference->Release();
  502. }
  503. else
  504. {
  505. rc = GCC_ALLOCATION_FAILURE;
  506. }
  507. }
  508. DebugExitINT(GCCController: ConfCreateRequest, rc);
  509. return rc;
  510. }
  511. /*
  512. * GCCController::ConfCreateResponse ()
  513. *
  514. * Private Function Description
  515. * This routine is called when the node controller responds to
  516. * a conference create indication. It is responsible for
  517. * creating the conference object.
  518. *
  519. * Formal Parameters:
  520. * conf_create_response_info - (i) Information structure that holds
  521. * all the info necessary to respond to
  522. * a conference create request.
  523. *
  524. * Return Value
  525. * GCC_NO_ERROR - No error occured.
  526. * GCC_ALLOCATION_FAILURE - A resource error occured.
  527. * GCC_INVALID_CONFERENCE - An invalid conference was passed in.
  528. * GCC_INVALID_CONFERENCE_NAME - Invalid conference name passed in.
  529. * GCC_FAILURE_CREATING_DOMAIN - Failure creating domain.
  530. * GCC_CONFERENCE_ALREADY_EXISTS - Conference specified already exists.
  531. * GCC_BAD_USER_DATA - Invalid user data passed in.
  532. * GCC_FAILURE_ATTACHING_TO_MCS - Failure creating MCS user attachment
  533. *
  534. *
  535. * Side Effects
  536. * None
  537. *
  538. * Caveats
  539. * In the Win32 world we pass in a shared memory manager to the
  540. * conference object to use for the message memory manager. This is
  541. * not necessary in the Win16 world since shared memory is not used.
  542. */
  543. GCCError GCCController::
  544. ConfCreateResponse ( PConfCreateResponseInfo conf_create_response_info )
  545. {
  546. GCCConferenceName conference_name;
  547. PENDING_CREATE_CONF *conference_info;
  548. PConference new_conference;
  549. GCCError rc = GCC_NO_ERROR;
  550. GCCConfID conference_id;
  551. ConnectGCCPDU connect_pdu;
  552. LPBYTE encoded_pdu;
  553. UINT encoded_pdu_length;
  554. MCSError mcsif_error;
  555. LPWSTR pwszConfDescription = NULL;
  556. PGCCConferencePrivileges conduct_privilege_list_ptr = NULL;
  557. PGCCConferencePrivileges conduct_mode_privilege_list_ptr = NULL;
  558. PGCCConferencePrivileges non_conduct_privilege_list_ptr = NULL;
  559. CONF_SPEC_PARAMS csp;
  560. DebugEntry(GCCController::ConfCreateResponse);
  561. // Is the conference create info structure in the rogue wave list
  562. if (NULL != (conference_info = m_PendingCreateConfList2.Find(conf_create_response_info->conference_id)))
  563. {
  564. if (conf_create_response_info->result == GCC_RESULT_SUCCESSFUL)
  565. {
  566. // First set up the conference name.
  567. conference_name.numeric_string = (GCCNumericString) conference_info->pszConfNumericName;
  568. conference_name.text_string = conference_info->pwszConfTextName;
  569. /*
  570. ** If the conference name is valid check all the existing
  571. ** conferences to make sure that this conference name is not
  572. * already in use.
  573. */
  574. conference_id = GetConferenceIDFromName(
  575. &conference_name,
  576. conf_create_response_info->conference_modifier);
  577. if (conference_id != 0)
  578. {
  579. WARNING_OUT(("GCCController:ConfCreateResponse: Conference exists"));
  580. rc = GCC_CONFERENCE_ALREADY_EXISTS;
  581. }
  582. else
  583. {
  584. /*
  585. ** Now set up the real conference ID from the conference id
  586. ** that was generated when the create request came in.
  587. */
  588. conference_id = conf_create_response_info->conference_id;
  589. }
  590. /*
  591. ** If everything is OK up to here go ahead and process the
  592. ** create request.
  593. */
  594. if (rc == GCC_NO_ERROR)
  595. {
  596. // Set up the privilege list pointers for the list that exists
  597. if (conference_info->conduct_privilege_list != NULL)
  598. {
  599. conference_info->conduct_privilege_list->
  600. GetPrivilegeListData(&conduct_privilege_list_ptr);
  601. }
  602. if (conference_info->conduct_mode_privilege_list != NULL)
  603. {
  604. conference_info->conduct_mode_privilege_list->
  605. GetPrivilegeListData(&conduct_mode_privilege_list_ptr);
  606. }
  607. if (conference_info->non_conduct_privilege_list != NULL)
  608. {
  609. conference_info->non_conduct_privilege_list->
  610. GetPrivilegeListData(&non_conduct_privilege_list_ptr);
  611. }
  612. // Set up the conference description pointer if one exists
  613. pwszConfDescription = conference_info->pwszConfDescription;
  614. // set up conference specification parameters
  615. csp.fClearPassword = conf_create_response_info->use_password_in_the_clear,
  616. csp.fConfLocked = conference_info->conference_is_locked,
  617. csp.fConfListed = conference_info->conference_is_listed,
  618. csp.fConfConductable = conference_info->conference_is_conductible,
  619. csp.eTerminationMethod = conference_info->termination_method,
  620. csp.pConductPrivilege = conduct_privilege_list_ptr,
  621. csp.pConductModePrivilege = conduct_mode_privilege_list_ptr,
  622. csp.pNonConductPrivilege = non_conduct_privilege_list_ptr,
  623. csp.pwszConfDescriptor = pwszConfDescription,
  624. // Here we instantiate the conference object
  625. DBG_SAVE_FILE_LINE
  626. new_conference = new CConf(&conference_name,
  627. conf_create_response_info->conference_modifier,
  628. conference_id,
  629. &csp,
  630. conf_create_response_info->number_of_network_addresses,
  631. conf_create_response_info->network_address_list,
  632. &rc);
  633. if ((new_conference != NULL) &&
  634. (rc == GCC_NO_ERROR))
  635. {
  636. // Here we actually issue the create response.
  637. rc = new_conference->ConfCreateResponse(
  638. conference_info->connection_handle,
  639. conf_create_response_info->domain_parameters,
  640. conf_create_response_info->user_data_list);
  641. if (rc == GCC_NO_ERROR)
  642. {
  643. // Add the new conference to the Conference List
  644. m_fConfListChangePending = TRUE;
  645. m_ConfList2.Append(conference_id, new_conference);
  646. PostMsgToRebuildConfPollList();
  647. }
  648. else
  649. {
  650. new_conference->Release();
  651. }
  652. }
  653. else
  654. {
  655. if (new_conference != NULL)
  656. {
  657. new_conference->Release();
  658. }
  659. else
  660. {
  661. rc = GCC_ALLOCATION_FAILURE;
  662. }
  663. }
  664. }
  665. }
  666. else
  667. {
  668. /*
  669. ** This section of the code is sending back the failed result.
  670. ** Note that no conference object is instantiated when the
  671. ** result is something other than success.
  672. */
  673. connect_pdu.choice = CONFERENCE_CREATE_RESPONSE_CHOSEN;
  674. connect_pdu.u.conference_create_response.bit_mask = 0;
  675. // This must be set to satisfy ASN.1 restriction
  676. connect_pdu.u.conference_create_response.node_id = 1001;
  677. connect_pdu.u.conference_create_response.tag = 0;
  678. if (conf_create_response_info->user_data_list != NULL)
  679. {
  680. connect_pdu.u.conference_create_response.bit_mask =
  681. CCRS_USER_DATA_PRESENT;
  682. conf_create_response_info->user_data_list->GetUserDataPDU(
  683. &connect_pdu.u.conference_create_response.ccrs_user_data);
  684. }
  685. // We always send a user rejected result here.
  686. connect_pdu.u.conference_create_response.result =
  687. ::TranslateGCCResultToCreateResult(
  688. GCC_RESULT_USER_REJECTED);
  689. if (g_GCCCoder->Encode((LPVOID) &connect_pdu,
  690. CONNECT_GCC_PDU,
  691. PACKED_ENCODING_RULES,
  692. &encoded_pdu,
  693. &encoded_pdu_length))
  694. {
  695. mcsif_error = g_pMCSIntf->ConnectProviderResponse(
  696. conference_info->connection_handle,
  697. NULL,
  698. NULL,
  699. RESULT_USER_REJECTED,
  700. encoded_pdu,
  701. encoded_pdu_length);
  702. rc = g_pMCSIntf->TranslateMCSIFErrorToGCCError(mcsif_error);
  703. g_GCCCoder->FreeEncoded(encoded_pdu);
  704. }
  705. else
  706. {
  707. rc = GCC_ALLOCATION_FAILURE;
  708. }
  709. }
  710. if (rc == GCC_NO_ERROR)
  711. {
  712. /*
  713. ** Remove the conference information structure from the rogue
  714. ** wave list.
  715. */
  716. delete conference_info;
  717. m_PendingCreateConfList2.Remove(conf_create_response_info->conference_id);
  718. }
  719. }
  720. else
  721. rc = GCC_INVALID_CONFERENCE;
  722. DebugExitINT(GCCController::ConfCreateResponse, rc);
  723. return rc;
  724. }
  725. /*
  726. * GCCController::ConfQueryRequest ()
  727. *
  728. * Private Function Description
  729. * This routine is called when the node controller makes a
  730. * conference query request. This routine is responsible for
  731. * creating the MCS domain used to send the request and is also
  732. * responsible for issuing the ConnectProvider request.
  733. *
  734. * Formal Parameters:
  735. * conf_query_request_info - (i) Information structure that holds
  736. * all the info necessary to issue
  737. * a conference query request.
  738. *
  739. * Return Value
  740. * GCC_NO_ERROR - No error occured.
  741. * GCC_ALLOCATION_FAILURE - A resource error occured.
  742. * GCC_INVALID_ADDRESS_PREFIX - Bad transport address passed in.
  743. * GCC_INVALID_TRANSPORT - Bad transport address passed in.
  744. * GCC_BAD_USER_DATA - Invalid user data passed in.
  745. * GCC_INVALID_TRANSPORT_ADDRESS - Bad transport address
  746. *
  747. * Side Effects
  748. * None
  749. *
  750. * Caveats
  751. * None
  752. */
  753. GCCError GCCController::
  754. ConfQueryRequest ( PConfQueryRequestInfo conf_query_request_info )
  755. {
  756. MCSError mcs_error;
  757. GCCError rc = GCC_NO_ERROR;
  758. ConnectGCCPDU connect_pdu;
  759. LPBYTE encoded_pdu;
  760. UINT encoded_pdu_length;
  761. GCCConfID query_id;
  762. DebugEntry(GCCController::ConfQueryRequest);
  763. // Get the query id used to create the query domain
  764. query_id = AllocateQueryID ();
  765. /*
  766. ** Create the MCS domain used by the query. Return an error if the
  767. ** domain already exists.
  768. */
  769. mcs_error = g_pMCSIntf->CreateDomain(&query_id);
  770. if (mcs_error != MCS_NO_ERROR)
  771. {
  772. if (mcs_error == MCS_DOMAIN_ALREADY_EXISTS)
  773. return (GCC_QUERY_REQUEST_OUTSTANDING);
  774. else
  775. return (GCC_ALLOCATION_FAILURE);
  776. }
  777. // Encode the Query Request PDU
  778. connect_pdu.choice = CONFERENCE_QUERY_REQUEST_CHOSEN;
  779. connect_pdu.u.conference_query_request.bit_mask = 0;
  780. // Translate the node type
  781. connect_pdu.u.conference_query_request.node_type =
  782. (NodeType)conf_query_request_info->node_type;
  783. // Set up asymetry indicator if it exists
  784. if (conf_query_request_info->asymmetry_indicator != NULL)
  785. {
  786. connect_pdu.u.conference_query_request.bit_mask |=
  787. CQRQ_ASYMMETRY_INDICATOR_PRESENT;
  788. connect_pdu.u.conference_query_request.cqrq_asymmetry_indicator.choice =
  789. (USHORT)conf_query_request_info->
  790. asymmetry_indicator->asymmetry_type;
  791. connect_pdu.u.conference_query_request.
  792. cqrq_asymmetry_indicator.u.unknown =
  793. conf_query_request_info->asymmetry_indicator->random_number;
  794. }
  795. // Set up the user data if it exists
  796. if (conf_query_request_info->user_data_list != NULL)
  797. {
  798. rc = conf_query_request_info->user_data_list->
  799. GetUserDataPDU (
  800. &connect_pdu.u.conference_query_request.
  801. cqrq_user_data);
  802. if (rc == GCC_NO_ERROR)
  803. {
  804. connect_pdu.u.conference_query_request.bit_mask |=
  805. CQRQ_USER_DATA_PRESENT;
  806. }
  807. }
  808. if (g_GCCCoder->Encode((LPVOID) &connect_pdu,
  809. CONNECT_GCC_PDU,
  810. PACKED_ENCODING_RULES,
  811. &encoded_pdu,
  812. &encoded_pdu_length))
  813. {
  814. // Here we create the logical connection used for the query.
  815. mcs_error = g_pMCSIntf->ConnectProviderRequest (
  816. &query_id, // calling domain selector
  817. &query_id, // called domain selector
  818. conf_query_request_info->calling_address,
  819. conf_query_request_info->called_address,
  820. conf_query_request_info->fSecure,
  821. TRUE, // Upward connection
  822. encoded_pdu,
  823. encoded_pdu_length,
  824. conf_query_request_info->connection_handle,
  825. NULL, // Domain Parameters
  826. NULL);
  827. g_GCCCoder->FreeEncoded(encoded_pdu);
  828. if (mcs_error == MCS_NO_ERROR)
  829. {
  830. /*
  831. ** Add the connection and domain name to the outstanding
  832. ** query request list.
  833. */
  834. m_PendingQueryConfList2.Append(*conf_query_request_info->connection_handle, query_id);
  835. rc = GCC_NO_ERROR;
  836. }
  837. else
  838. {
  839. g_pMCSIntf->DeleteDomain(&query_id);
  840. /*
  841. ** DataBeam's current implementation of MCS returns
  842. ** MCS_INVALID_PARAMETER when something other than
  843. ** the transport prefix is wrong with the specified
  844. ** transport address.
  845. */
  846. if (mcs_error == MCS_INVALID_PARAMETER)
  847. rc = GCC_INVALID_TRANSPORT_ADDRESS;
  848. else
  849. {
  850. rc = g_pMCSIntf->TranslateMCSIFErrorToGCCError(mcs_error);
  851. }
  852. }
  853. }
  854. else
  855. {
  856. rc = GCC_ALLOCATION_FAILURE;
  857. }
  858. DebugExitINT(GCCController::ConfQueryRequest, rc);
  859. return rc;
  860. }
  861. /*
  862. * GCCController::ConfQueryResponse ()
  863. *
  864. * Private Function Description
  865. * This routine is called when the node controller makes a
  866. * conference query response. This routine uses a conference
  867. * descriptor list object to build the PDU associated with the
  868. * query response.
  869. *
  870. * Formal Parameters:
  871. * conf_query_response_info - (i) Information structure that holds
  872. * all the info necessary to issue
  873. * a conference query response.
  874. *
  875. * Return Value
  876. * GCC_NO_ERROR - No error occured.
  877. * GCC_ALLOCATION_FAILURE - A resource error occured.
  878. * GCC_BAD_NETWORK_ADDRESS - Bad network address passed in.
  879. * GCC_BAD_NETWORK_ADDRESS_TYPE - Bad network address type passed in.
  880. * GCC_BAD_USER_DATA - Invalid user data passed in.
  881. *
  882. * Side Effects
  883. * None
  884. *
  885. * Caveats
  886. * None
  887. */
  888. GCCError GCCController::
  889. ConfQueryResponse ( PConfQueryResponseInfo conf_query_response_info )
  890. {
  891. GCCError rc = GCC_NO_ERROR;
  892. ConnectGCCPDU connect_pdu;
  893. LPBYTE encoded_pdu;
  894. UINT encoded_pdu_length;
  895. ConnectionHandle connection_handle;
  896. MCSError mcs_error;
  897. CConfDescriptorListContainer *conference_list = NULL;
  898. DebugEntry(GCCController::ConfQueryResponse);
  899. connection_handle = (ConnectionHandle)conf_query_response_info->
  900. query_response_tag;
  901. // Encode the Query Response PDU
  902. connect_pdu.choice = CONFERENCE_QUERY_RESPONSE_CHOSEN;
  903. connect_pdu.u.conference_query_response.bit_mask = 0;
  904. connect_pdu.u.conference_query_response.node_type =
  905. (NodeType)conf_query_response_info->node_type;
  906. // Set up asymmetry indicator if it exists
  907. if (conf_query_response_info->asymmetry_indicator != NULL)
  908. {
  909. connect_pdu.u.conference_query_response.bit_mask |=
  910. CQRS_ASYMMETRY_INDICATOR_PRESENT;
  911. connect_pdu.u.conference_query_response.
  912. cqrs_asymmetry_indicator.choice =
  913. conf_query_response_info->asymmetry_indicator->asymmetry_type;
  914. connect_pdu.u.conference_query_response.
  915. cqrs_asymmetry_indicator.u.unknown =
  916. conf_query_response_info->asymmetry_indicator->random_number;
  917. }
  918. // Set up the user data if it exists
  919. if (conf_query_response_info->user_data_list != NULL)
  920. {
  921. rc = conf_query_response_info->user_data_list->
  922. GetUserDataPDU (
  923. &connect_pdu.u.conference_query_response.
  924. cqrs_user_data);
  925. if (rc == GCC_NO_ERROR)
  926. {
  927. connect_pdu.u.conference_query_response.bit_mask |=
  928. CQRS_USER_DATA_PRESENT;
  929. }
  930. }
  931. // Translate the result
  932. connect_pdu.u.conference_query_response.result =
  933. ::TranslateGCCResultToQueryResult(
  934. conf_query_response_info->result);
  935. /*
  936. ** We only create a conference descriptor list if the returned result
  937. ** is success.
  938. */
  939. if (conf_query_response_info->result == GCC_RESULT_SUCCESSFUL)
  940. {
  941. // Create a new conference descriptor list and check it for validity.
  942. DBG_SAVE_FILE_LINE
  943. conference_list = new CConfDescriptorListContainer();
  944. if (conference_list != NULL)
  945. {
  946. PConference lpConf;
  947. // Here we build the set of conference descriptor list
  948. m_ConfList2.Reset();
  949. while (NULL != (lpConf = m_ConfList2.Iterate()))
  950. {
  951. // Only show established conferences
  952. if (lpConf->IsConfEstablished())
  953. {
  954. if (lpConf->IsConfListed())
  955. {
  956. conference_list->AddConferenceDescriptorToList (
  957. lpConf->GetNumericConfName(),
  958. lpConf->GetTextConfName(),
  959. lpConf->GetConfModifier(),
  960. lpConf->IsConfLocked(),
  961. lpConf->IsConfPasswordInTheClear(),
  962. lpConf->GetConfDescription(),
  963. lpConf->GetNetworkAddressList());
  964. }
  965. }
  966. }
  967. // Get the pointer to the set of conference descriptors
  968. conference_list->GetConferenceDescriptorListPDU (
  969. &(connect_pdu.u.conference_query_response.conference_list));
  970. }
  971. else
  972. {
  973. rc = GCC_ALLOCATION_FAILURE;
  974. }
  975. }
  976. else
  977. {
  978. // No conference list is sent in this case
  979. connect_pdu.u.conference_query_response.conference_list = NULL;
  980. }
  981. if (rc == GCC_NO_ERROR)
  982. {
  983. if (g_GCCCoder->Encode((LPVOID) &connect_pdu,
  984. CONNECT_GCC_PDU,
  985. PACKED_ENCODING_RULES,
  986. &encoded_pdu,
  987. &encoded_pdu_length))
  988. {
  989. mcs_error = g_pMCSIntf->ConnectProviderResponse(
  990. connection_handle,
  991. NULL,
  992. NULL,
  993. RESULT_USER_REJECTED,
  994. encoded_pdu,
  995. encoded_pdu_length);
  996. g_GCCCoder->FreeEncoded(encoded_pdu);
  997. if (mcs_error == MCS_NO_ERROR)
  998. rc = GCC_NO_ERROR;
  999. else if (mcs_error == MCS_NO_SUCH_CONNECTION)
  1000. rc = GCC_INVALID_QUERY_TAG;
  1001. else
  1002. {
  1003. rc = g_pMCSIntf->TranslateMCSIFErrorToGCCError(mcs_error);
  1004. }
  1005. }
  1006. else
  1007. {
  1008. rc = GCC_ALLOCATION_FAILURE;
  1009. }
  1010. }
  1011. // Free up the conference list allocated above to create the PDU.
  1012. if (NULL != conference_list)
  1013. {
  1014. conference_list->Release();
  1015. }
  1016. DebugExitINT(GCCController::ConfQueryResponse, rc);
  1017. return rc;
  1018. }
  1019. /*
  1020. * GCCController::ConfJoinRequest ()
  1021. *
  1022. * Private Function Description
  1023. * This routine is called when the node controller makes a request
  1024. * to join an existing conference. It is responsible for
  1025. * creating the conference object.
  1026. *
  1027. * Formal Parameters:
  1028. * conf_join_request_info - (i) Information structure that holds
  1029. * all the info necessary to issue
  1030. * a conference join request.
  1031. *
  1032. * Return Value
  1033. * GCC_NO_ERROR - No error occured.
  1034. * GCC_ALLOCATION_FAILURE - A resource error occured.
  1035. * GCC_INVALID_CONFERENCE_NAME - Invalid conference name passed in.
  1036. * GCC_FAILURE_CREATING_DOMAIN - Failure creating domain.
  1037. * GCC_BAD_NETWORK_ADDRESS - Bad network address passed in.
  1038. * GCC_BAD_NETWORK_ADDRESS_TYPE - Bad network address type passed in.
  1039. * GCC_CONFERENCE_ALREADY_EXISTS - Conference specified already exists.
  1040. * GCC_INVALID_ADDRESS_PREFIX - Bad transport address passed in.
  1041. * GCC_INVALID_TRANSPORT - Bad transport address passed in.
  1042. * GCC_INVALID_PASSWORD - Invalid password passed in.
  1043. * GCC_BAD_USER_DATA - Invalid user data passed in.
  1044. * GCC_FAILURE_ATTACHING_TO_MCS - Failure creating MCS user attachment
  1045. *
  1046. * Side Effects
  1047. * None
  1048. *
  1049. * Caveats
  1050. * In the Win32 world we pass in a shared memory manager to the
  1051. * conference object to use for the message memory manager. This is
  1052. * not necessary in the Win16 world since shared memory is not used.
  1053. */
  1054. GCCError GCCController::
  1055. ConfJoinRequest
  1056. (
  1057. PConfJoinRequestInfo conf_join_request_info,
  1058. GCCConfID *pnConfID
  1059. )
  1060. {
  1061. PConference new_conference;
  1062. GCCError rc;
  1063. GCCConfID conference_id;
  1064. DebugEntry(GCCController::ConfJoinRequest);
  1065. /*
  1066. ** We must first check all the existing conferences to make sure that this
  1067. ** conference name is not already in use. Note that this returns immediatly
  1068. ** if a conference by the same name alreay exists. Conference names
  1069. ** must be unique at a node.
  1070. */
  1071. conference_id = GetConferenceIDFromName(
  1072. conf_join_request_info->conference_name,
  1073. conf_join_request_info->calling_node_modifier);
  1074. if (conference_id != 0)
  1075. {
  1076. WARNING_OUT(("GCCController:ConfJoinRequest: Conference exists."));
  1077. return (GCC_CONFERENCE_ALREADY_EXISTS);
  1078. }
  1079. /*
  1080. ** Here we are allocating a conference ID. In most cases this ID
  1081. ** will be the same as the conference name. Only if a conference
  1082. ** name is passed in that already exists will the name and ID
  1083. ** be different. In this case, a modifier will be appended to the
  1084. ** conference name to create the conference ID.
  1085. */
  1086. conference_id = AllocateConferenceID ();
  1087. DBG_SAVE_FILE_LINE
  1088. new_conference = new CConf(conf_join_request_info->conference_name,
  1089. conf_join_request_info->calling_node_modifier,
  1090. conference_id,
  1091. NULL,
  1092. conf_join_request_info->number_of_network_addresses,
  1093. conf_join_request_info->local_network_address_list,
  1094. &rc);
  1095. if ((new_conference != NULL) && (rc == GCC_NO_ERROR))
  1096. {
  1097. rc = new_conference->ConfJoinRequest(
  1098. conf_join_request_info->called_node_modifier,
  1099. conf_join_request_info->convener_password,
  1100. conf_join_request_info->password_challenge,
  1101. conf_join_request_info->pwszCallerID,
  1102. conf_join_request_info->calling_address,
  1103. conf_join_request_info->called_address,
  1104. conf_join_request_info->fSecure,
  1105. conf_join_request_info->domain_parameters,
  1106. conf_join_request_info->user_data_list,
  1107. conf_join_request_info->connection_handle);
  1108. if (rc == GCC_NO_ERROR)
  1109. {
  1110. m_fConfListChangePending = TRUE;
  1111. if (NULL != pnConfID)
  1112. {
  1113. *pnConfID = conference_id;
  1114. }
  1115. m_ConfList2.Append(conference_id, new_conference);
  1116. PostMsgToRebuildConfPollList();
  1117. }
  1118. else
  1119. {
  1120. new_conference->Release();
  1121. }
  1122. }
  1123. else
  1124. {
  1125. if (new_conference != NULL)
  1126. {
  1127. new_conference->Release();
  1128. }
  1129. else
  1130. {
  1131. rc = GCC_ALLOCATION_FAILURE;
  1132. }
  1133. }
  1134. DebugExitINT(GCCController::ConfJoinRequest, rc);
  1135. return rc;
  1136. }
  1137. /*
  1138. * GCCController::ConfJoinIndResponse ()
  1139. *
  1140. * Private Function Description
  1141. * This routine is called when the node controller responds
  1142. * to a join indication. If the result is success, we check to make sure
  1143. * that the conference exist before proceeding. If it is not success, we
  1144. * send back the rejected request.
  1145. *
  1146. * Formal Parameters:
  1147. * conf_join_response_info - (i) Information structure that holds
  1148. * all the info necessary to issue
  1149. * a conference join response.
  1150. *
  1151. * Return Value
  1152. * GCC_NO_ERROR - No error occured.
  1153. * GCC_ALLOCATION_FAILURE - A resource error occured.
  1154. * GCC_INVALID_JOIN_RESPONSE_TAG - No match found for join response tag
  1155. * GCC_INVALID_CONFERENCE_NAME - Invalid conference name passed in.
  1156. * GCC_FAILURE_CREATING_DOMAIN - Failure creating domain.
  1157. * GCC_CONFERENCE_ALREADY_EXISTS - Conference specified already exists.
  1158. * GCC_INVALID_PASSWORD - Invalid password passed in.
  1159. * GCC_BAD_USER_DATA - Invalid user data passed in.
  1160. * GCC_INVALID_CONFERENCE - Invalid conference ID passed in.
  1161. *
  1162. * Side Effects
  1163. * None
  1164. *
  1165. * Caveats
  1166. * If this node is not the Top Provider and the result is success, we
  1167. * go ahead and forward the request on up to the top provider.
  1168. */
  1169. GCCError GCCController::
  1170. ConfJoinIndResponse ( PConfJoinResponseInfo conf_join_response_info )
  1171. {
  1172. PConference joined_conference;
  1173. PENDING_JOIN_CONF *join_info_ptr;
  1174. BOOL convener_is_joining;
  1175. GCCError rc = GCC_NO_ERROR;
  1176. GCCResult gcc_result = GCC_RESULT_SUCCESSFUL;
  1177. BOOL fForwardJoinReq = FALSE;
  1178. DebugEntry(GCCController::ConfJoinIndResponse);
  1179. if (NULL != (join_info_ptr = m_PendingJoinConfList2.Find(conf_join_response_info->connection_handle)))
  1180. {
  1181. /*
  1182. ** If the result is success, we must first check all the existing
  1183. ** conferences to make sure that this conference exist.
  1184. */
  1185. if (conf_join_response_info->result == GCC_RESULT_SUCCESSFUL)
  1186. {
  1187. if (NULL != (joined_conference = m_ConfList2.Find(conf_join_response_info->conference_id)))
  1188. {
  1189. /*
  1190. ** If the node for this conference is not the top provider we
  1191. ** must forward the join request on up to the Top Provider.
  1192. */
  1193. if (! joined_conference->IsConfTopProvider())
  1194. {
  1195. rc = joined_conference->ForwardConfJoinRequest(
  1196. join_info_ptr->convener_password,
  1197. join_info_ptr->password_challenge,
  1198. join_info_ptr->pwszCallerID,
  1199. conf_join_response_info->user_data_list,
  1200. join_info_ptr->numeric_name_present,
  1201. conf_join_response_info->connection_handle);
  1202. if (GCC_NO_ERROR == rc)
  1203. {
  1204. fForwardJoinReq = TRUE;
  1205. }
  1206. }
  1207. else
  1208. {
  1209. /*
  1210. ** If a convener password exists we must inform the conference
  1211. ** object that this is a convener that is trying to rejoin
  1212. ** the conference.
  1213. */
  1214. if (join_info_ptr->convener_password != NULL)
  1215. convener_is_joining = TRUE;
  1216. else
  1217. convener_is_joining = FALSE;
  1218. rc = joined_conference->ConfJoinIndResponse(
  1219. conf_join_response_info->connection_handle,
  1220. conf_join_response_info->password_challenge,
  1221. conf_join_response_info->user_data_list,
  1222. join_info_ptr->numeric_name_present,
  1223. convener_is_joining,
  1224. conf_join_response_info->result);
  1225. }
  1226. if (GCC_NO_ERROR != rc)
  1227. {
  1228. gcc_result = GCC_RESULT_UNSPECIFIED_FAILURE;
  1229. }
  1230. }
  1231. else
  1232. {
  1233. rc = GCC_INVALID_CONFERENCE;
  1234. gcc_result = GCC_RESULT_INVALID_CONFERENCE;
  1235. }
  1236. }
  1237. else
  1238. {
  1239. gcc_result = conf_join_response_info->result;
  1240. }
  1241. }
  1242. else
  1243. {
  1244. rc = GCC_INVALID_JOIN_RESPONSE_TAG;
  1245. gcc_result = GCC_RESULT_INVALID_CONFERENCE;
  1246. }
  1247. if (GCC_RESULT_SUCCESSFUL != gcc_result)
  1248. {
  1249. conf_join_response_info->result = gcc_result;
  1250. FailConfJoinIndResponse(conf_join_response_info);
  1251. }
  1252. /*
  1253. ** Cleanup the join info list if the join was succesful or if the
  1254. ** Domain Parameters were unacceptable. The connection is automatically
  1255. ** rejected by MCS if the domain parameters are found to be unacceptable.
  1256. */
  1257. // if ((rc == GCC_NO_ERROR) ||
  1258. // (rc == GCC_DOMAIN_PARAMETERS_UNACCEPTABLE))
  1259. if (NULL != join_info_ptr && (! fForwardJoinReq))
  1260. {
  1261. RemoveConfJoinInfo(conf_join_response_info->connection_handle);
  1262. }
  1263. DebugExitINT(GCCController::ConfJoinIndResponse, rc);
  1264. return rc;
  1265. }
  1266. GCCError GCCController::
  1267. FailConfJoinIndResponse
  1268. (
  1269. GCCConfID nConfID,
  1270. ConnectionHandle hConn
  1271. )
  1272. {
  1273. ConfJoinResponseInfo cjri;
  1274. cjri.result = GCC_RESULT_RESOURCES_UNAVAILABLE;
  1275. cjri.conference_id = nConfID;
  1276. cjri.password_challenge = NULL;
  1277. cjri.user_data_list = NULL;
  1278. cjri.connection_handle = hConn;
  1279. return FailConfJoinIndResponse(&cjri);
  1280. }
  1281. GCCError GCCController::
  1282. FailConfJoinIndResponse ( PConfJoinResponseInfo conf_join_response_info )
  1283. {
  1284. GCCError rc = GCC_NO_ERROR;
  1285. ConnectGCCPDU connect_pdu;
  1286. LPBYTE encoded_pdu;
  1287. UINT encoded_pdu_length;
  1288. // Send back the failed response with the specified result
  1289. DebugEntry(GCCController::FailConfJoinIndResponse);
  1290. // Encode the Join Response PDU
  1291. connect_pdu.choice = CONNECT_JOIN_RESPONSE_CHOSEN;
  1292. connect_pdu.u.connect_join_response.bit_mask = 0;
  1293. // Get the password challenge if one exists
  1294. if (conf_join_response_info->password_challenge != NULL)
  1295. {
  1296. connect_pdu.u.connect_join_response.bit_mask |= CJRS_PASSWORD_PRESENT;
  1297. rc = conf_join_response_info->password_challenge->GetPasswordChallengeResponsePDU(
  1298. &connect_pdu.u.connect_join_response.cjrs_password);
  1299. }
  1300. // Get the user data
  1301. if ((conf_join_response_info->user_data_list != NULL) && (rc == GCC_NO_ERROR))
  1302. {
  1303. connect_pdu.u.connect_join_response.bit_mask |= CJRS_USER_DATA_PRESENT;
  1304. rc = conf_join_response_info->user_data_list->GetUserDataPDU(
  1305. &connect_pdu.u.connect_join_response.cjrs_user_data);
  1306. }
  1307. if (rc == GCC_NO_ERROR)
  1308. {
  1309. connect_pdu.u.connect_join_response.top_node_id = 1001;
  1310. connect_pdu.u.connect_join_response.tag = 0;
  1311. connect_pdu.u.connect_join_response.conference_is_locked = 0;
  1312. connect_pdu.u.connect_join_response.conference_is_listed = 0;
  1313. connect_pdu.u.connect_join_response.conference_is_conductible = 0;
  1314. connect_pdu.u.connect_join_response.termination_method = AUTOMATIC;
  1315. connect_pdu.u.connect_join_response.clear_password_required = FALSE;
  1316. connect_pdu.u.connect_join_response.result =
  1317. ::TranslateGCCResultToJoinResult(conf_join_response_info->result);
  1318. if (g_GCCCoder->Encode((LPVOID) &connect_pdu,
  1319. CONNECT_GCC_PDU,
  1320. PACKED_ENCODING_RULES,
  1321. &encoded_pdu,
  1322. &encoded_pdu_length))
  1323. {
  1324. g_pMCSIntf->ConnectProviderResponse(
  1325. conf_join_response_info->connection_handle,
  1326. NULL,
  1327. NULL,
  1328. RESULT_USER_REJECTED,
  1329. encoded_pdu,
  1330. encoded_pdu_length);
  1331. g_GCCCoder->FreeEncoded(encoded_pdu);
  1332. }
  1333. else
  1334. {
  1335. ERROR_OUT(("GCCController:FailConfJoinIndResponse: can't encode"));
  1336. rc = GCC_ALLOCATION_FAILURE;
  1337. }
  1338. }
  1339. DebugExitINT(GCCController::FailConfJoinIndResponse, rc);
  1340. return rc;
  1341. }
  1342. /*
  1343. * GCCController::ConfInviteResponse ()
  1344. *
  1345. * Private Function Description
  1346. * This routine is called when the node controller responds to
  1347. * a conference invite indication. It is responsible for
  1348. * creating the conference object.
  1349. *
  1350. * Formal Parameters:
  1351. * conf_invite_response_info - (i) Information structure that holds
  1352. * all the info necessary to issue
  1353. * a conference invite response.
  1354. *
  1355. * Return Value
  1356. * GCC_NO_ERROR - No error occured.
  1357. * GCC_ALLOCATION_FAILURE - A resource error occured.
  1358. * GCC_INVALID_CONFERENCE_NAME - Invalid conference name passed in.
  1359. * GCC_FAILURE_CREATING_DOMAIN - Failure creating domain.
  1360. * GCC_CONFERENCE_ALREADY_EXISTS - Conference specified already exists.
  1361. * GCC_BAD_USER_DATA - Invalid user data passed in.
  1362. * GCC_INVALID_CONFERENCE - Invalid conference ID passed in.
  1363. * GCC_FAILURE_ATTACHING_TO_MCS - Failure creating MCS user attachment
  1364. *
  1365. * Side Effects
  1366. * None
  1367. *
  1368. * Caveats
  1369. * In the Win32 world we pass in a shared memory manager to the
  1370. * conference object to use for the message memory manager. This is
  1371. * not necessary in the Win16 world since shared memory is not used.
  1372. */
  1373. GCCError GCCController::
  1374. ConfInviteResponse ( PConfInviteResponseInfo conf_invite_response_info )
  1375. {
  1376. GCCError rc = GCC_NO_ERROR;
  1377. PENDING_CREATE_CONF *conference_info;
  1378. PConference new_conference;
  1379. GCCConferenceName conference_name;
  1380. LPWSTR pwszConfDescription = NULL;
  1381. PGCCConferencePrivileges conduct_privilege_list_ptr = NULL;
  1382. PGCCConferencePrivileges conduct_mode_privilege_list_ptr = NULL;
  1383. PGCCConferencePrivileges non_conduct_privilege_list_ptr = NULL;
  1384. GCCConfID conference_id;
  1385. ConnectGCCPDU connect_pdu;
  1386. LPBYTE encoded_pdu;
  1387. UINT encoded_pdu_length;
  1388. MCSError mcsif_error;
  1389. CONF_SPEC_PARAMS csp;
  1390. GCCResult gcc_result = GCC_RESULT_SUCCESSFUL;
  1391. DebugEntry(GCCController::ConfInviteResponse);
  1392. if (NULL != (conference_info = m_PendingCreateConfList2.Find(conf_invite_response_info->conference_id)))
  1393. {
  1394. // Is the conference create handle in the rogue wave list
  1395. if (conf_invite_response_info->result == GCC_RESULT_SUCCESSFUL)
  1396. {
  1397. /*
  1398. ** We must first check all the existing conferences to make sure
  1399. ** that this conference name is not already in use. Note that this
  1400. ** returns immediatly if a conference by the same name alreay
  1401. ** exists. Conference names must be unique at a node.
  1402. */
  1403. // Set up the conference name
  1404. conference_name.numeric_string = (GCCNumericString) conference_info->pszConfNumericName;
  1405. conference_name.text_string = conference_info->pwszConfTextName;
  1406. conference_id = GetConferenceIDFromName(
  1407. &conference_name,
  1408. conf_invite_response_info->conference_modifier);
  1409. if (conference_id == 0)
  1410. {
  1411. // Set up the privilege list pointers for the list that exists
  1412. if (conference_info->conduct_privilege_list != NULL)
  1413. {
  1414. conference_info->conduct_privilege_list->
  1415. GetPrivilegeListData(&conduct_privilege_list_ptr);
  1416. }
  1417. if (conference_info->conduct_mode_privilege_list != NULL)
  1418. {
  1419. conference_info->conduct_mode_privilege_list->
  1420. GetPrivilegeListData(&conduct_mode_privilege_list_ptr);
  1421. }
  1422. if (conference_info->non_conduct_privilege_list != NULL)
  1423. {
  1424. conference_info->non_conduct_privilege_list->
  1425. GetPrivilegeListData(&non_conduct_privilege_list_ptr);
  1426. }
  1427. // Set up the conference description pointer if one exists
  1428. pwszConfDescription = conference_info->pwszConfDescription;
  1429. // Now set up the real conference ID
  1430. conference_id = conf_invite_response_info->conference_id;
  1431. // set up conference specification parameters
  1432. csp.fClearPassword = conference_info->password_in_the_clear,
  1433. csp.fConfLocked = conference_info->conference_is_locked,
  1434. csp.fConfListed = conference_info->conference_is_listed,
  1435. csp.fConfConductable = conference_info->conference_is_conductible,
  1436. csp.eTerminationMethod = conference_info->termination_method,
  1437. csp.pConductPrivilege = conduct_privilege_list_ptr,
  1438. csp.pConductModePrivilege = conduct_mode_privilege_list_ptr,
  1439. csp.pNonConductPrivilege = non_conduct_privilege_list_ptr,
  1440. csp.pwszConfDescriptor = pwszConfDescription,
  1441. DBG_SAVE_FILE_LINE
  1442. new_conference = new CConf(&conference_name,
  1443. conf_invite_response_info->conference_modifier,
  1444. conference_id,
  1445. &csp,
  1446. conf_invite_response_info->number_of_network_addresses,
  1447. conf_invite_response_info->local_network_address_list,
  1448. &rc);
  1449. if ((new_conference != NULL) &&
  1450. (rc == GCC_NO_ERROR))
  1451. {
  1452. rc = new_conference->ConfInviteResponse(
  1453. conference_info->parent_node_id,
  1454. conference_info->top_node_id,
  1455. conference_info->tag_number,
  1456. conference_info->connection_handle,
  1457. conf_invite_response_info->fSecure,
  1458. conf_invite_response_info->domain_parameters,
  1459. conf_invite_response_info->user_data_list);
  1460. if (rc == GCC_NO_ERROR)
  1461. {
  1462. // Add the new conference to the Conference List
  1463. m_fConfListChangePending = TRUE;
  1464. m_ConfList2.Append(conference_id, new_conference);
  1465. PostMsgToRebuildConfPollList();
  1466. }
  1467. else
  1468. {
  1469. new_conference->Release();
  1470. gcc_result = GCC_RESULT_UNSPECIFIED_FAILURE;
  1471. }
  1472. }
  1473. else
  1474. {
  1475. if (new_conference != NULL)
  1476. {
  1477. new_conference->Release();
  1478. }
  1479. else
  1480. {
  1481. rc = GCC_ALLOCATION_FAILURE;
  1482. }
  1483. gcc_result = GCC_RESULT_RESOURCES_UNAVAILABLE;
  1484. }
  1485. }
  1486. else
  1487. {
  1488. WARNING_OUT(("GCCController::ConfInviteResponse: Conference exists."));
  1489. rc = GCC_CONFERENCE_ALREADY_EXISTS;
  1490. gcc_result = GCC_RESULT_ENTRY_ALREADY_EXISTS;
  1491. }
  1492. }
  1493. else
  1494. {
  1495. WARNING_OUT(("GCCController: ConfInviteResponse: User Rejected"));
  1496. gcc_result = conf_invite_response_info->result;
  1497. }
  1498. // Let's send a user reject response if any error or reject
  1499. if (GCC_RESULT_SUCCESSFUL != gcc_result)
  1500. {
  1501. GCCError rc2;
  1502. // Encode the Invite Response PDU
  1503. connect_pdu.choice = CONFERENCE_INVITE_RESPONSE_CHOSEN;
  1504. connect_pdu.u.conference_invite_response.bit_mask = 0;
  1505. if (conf_invite_response_info->user_data_list != NULL)
  1506. {
  1507. rc2 = conf_invite_response_info->
  1508. user_data_list->GetUserDataPDU(
  1509. &connect_pdu.u.
  1510. conference_invite_response.cirs_user_data);
  1511. if (rc2 == GCC_NO_ERROR)
  1512. {
  1513. connect_pdu.u.conference_invite_response.bit_mask |=
  1514. CIRS_USER_DATA_PRESENT;
  1515. }
  1516. else
  1517. {
  1518. ERROR_OUT(("GCCController::ConfInviteResponse: GetUserDataPDU failed"));
  1519. }
  1520. }
  1521. // connect_pdu.u.conference_invite_response.result = ::TranslateGCCResultToInviteResult(gcc_result);
  1522. connect_pdu.u.conference_invite_response.result = CIRS_USER_REJECTED;
  1523. if (g_GCCCoder->Encode((LPVOID) &connect_pdu,
  1524. CONNECT_GCC_PDU,
  1525. PACKED_ENCODING_RULES,
  1526. &encoded_pdu,
  1527. &encoded_pdu_length))
  1528. {
  1529. mcsif_error = g_pMCSIntf->ConnectProviderResponse(
  1530. conference_info->connection_handle,
  1531. NULL,
  1532. NULL,
  1533. RESULT_USER_REJECTED,
  1534. encoded_pdu,
  1535. encoded_pdu_length);
  1536. rc2 = g_pMCSIntf->TranslateMCSIFErrorToGCCError(mcsif_error);
  1537. g_GCCCoder->FreeEncoded(encoded_pdu);
  1538. }
  1539. else
  1540. {
  1541. // nothing we can do right now.
  1542. ERROR_OUT(("GCCController::ConfInviteResponse: encode failed"));
  1543. rc2 = GCC_ALLOCATION_FAILURE;
  1544. }
  1545. // Update the error code. If rc is no error, which means the result
  1546. // was passed in by the caller, then we should use the rc2 for
  1547. // the return value.
  1548. if (GCC_NO_ERROR == rc)
  1549. {
  1550. rc = rc2;
  1551. }
  1552. }
  1553. /*
  1554. ** Remove the conference information structure from the rogue
  1555. ** wave list. Also cleanup all the containers needed to store
  1556. ** the conference information.
  1557. */
  1558. delete conference_info;
  1559. m_PendingCreateConfList2.Remove(conf_invite_response_info->conference_id);
  1560. }
  1561. else
  1562. {
  1563. rc = GCC_INVALID_CONFERENCE;
  1564. }
  1565. DebugExitINT(GCCController::ConfInviteResponse, rc);
  1566. return rc;
  1567. }
  1568. // Calls received through the owner callback from a conference.
  1569. /*
  1570. * GCCController::ProcessConfEstablished ()
  1571. *
  1572. * Private Function Description
  1573. * This owner callback is called when the conference has stabalized
  1574. * after creation. This routine takes care of registering all the
  1575. * available application saps with the conference which then kicks off the
  1576. * sending of permission to enrolls to all the applications that have
  1577. * registered a service access point.
  1578. *
  1579. * Formal Parameters:
  1580. * conference_id - (i) The conference ID of the conference
  1581. * object that is now established.
  1582. *
  1583. * Return Value
  1584. * GCC_NO_ERROR - No error occured.
  1585. *
  1586. * Side Effects
  1587. * None
  1588. *
  1589. * Caveats
  1590. * None
  1591. */
  1592. GCCError GCCController::
  1593. ProcessConfEstablished ( GCCConfID nConfID )
  1594. {
  1595. CConf *pConf;
  1596. DebugEntry(GCCController:ProcessConfEstablished);
  1597. /*
  1598. ** Here we make a copy of the SAP list to use in case some kind of
  1599. ** resource error occurs when calling RegisterAppSap that
  1600. ** would cause a SAP to be deleted from the list.
  1601. */
  1602. CAppSapList AppSapList(m_AppSapList);
  1603. /*
  1604. ** Here we register all the available SAPs with the newly available
  1605. ** conference and then we send a permit to enroll indication on to all the
  1606. ** application SAPs.
  1607. */
  1608. if (NULL != (pConf = m_ConfList2.Find(nConfID)))
  1609. {
  1610. CAppSap *pAppSap;
  1611. AppSapList.Reset();
  1612. while (NULL != (pAppSap = AppSapList.Iterate()))
  1613. {
  1614. // Register the Application SAP with the conference
  1615. pConf->RegisterAppSap(pAppSap);
  1616. }
  1617. }
  1618. #if 0 // use it when merging CApplet and CAppSap
  1619. // notify permit-to-enroll callbacks
  1620. CApplet *pApplet;
  1621. m_AppletList.Reset();
  1622. while (NULL != (pApplet = m_AppletList.Iterate()))
  1623. {
  1624. ASSERT(0 != nConfID);
  1625. T120AppletMsg Msg;
  1626. Msg.eMsgType = GCC_PERMIT_TO_ENROLL_INDICATION;
  1627. Msg.PermitToEnrollInd.nConfID = nConfID;
  1628. Msg.PermitToEnrollInd.fPermissionGranted = TRUE;
  1629. pApplet->SendCallbackMessage(&Msg);
  1630. }
  1631. #endif // 0
  1632. DebugExitINT(GCCController:ProcessConfEstablished, GCC_NO_ERROR);
  1633. return (GCC_NO_ERROR);
  1634. }
  1635. void GCCController::RegisterApplet
  1636. (
  1637. CApplet *pApplet
  1638. )
  1639. {
  1640. pApplet->AddRef();
  1641. m_AppletList.Append(pApplet);
  1642. #if 0 // use it when merging CApplet and CAppSap
  1643. // notify of existing conferences
  1644. CConf *pConf;
  1645. GCCConfID nConfID;
  1646. m_ConfList2.Reset();
  1647. while (NULL != (pConf = m_ConfList2.Iterate(&nConfID)))
  1648. {
  1649. ASSERT(0 != nConfID);
  1650. T120AppletMsg Msg;
  1651. Msg.eMsgType = GCC_PERMIT_TO_ENROLL_INDICATION;
  1652. Msg.PermitToEnrollInd.nConfID = nConfID;
  1653. Msg.PermitToEnrollInd.fPermissionGranted = TRUE;
  1654. pApplet->SendCallbackMessage(&Msg);
  1655. }
  1656. #endif // 0
  1657. }
  1658. void GCCController::UnregisterApplet
  1659. (
  1660. CApplet *pApplet
  1661. )
  1662. {
  1663. m_AppletList.Remove(pApplet);
  1664. pApplet->Release();
  1665. }
  1666. /*
  1667. * GCCController::ProcessConfTerminated ()
  1668. *
  1669. * Private Function Description
  1670. * This owner callback is called when the conference has terminated
  1671. * itself. Termination can occur due because of an error or it can
  1672. * terminate for normal reasons.
  1673. *
  1674. * Formal Parameters:
  1675. * conference_id - (i) The conference ID of the conference
  1676. * object that wants to terminate.
  1677. * gcc_reason - (i) Reason the conference was terminated.
  1678. *
  1679. * Return Value
  1680. * GCC_NO_ERROR - No error occured.
  1681. *
  1682. * Side Effects
  1683. * None
  1684. *
  1685. * Caveats
  1686. * None
  1687. */
  1688. GCCError GCCController::
  1689. ProcessConfTerminated
  1690. (
  1691. GCCConfID conference_id,
  1692. GCCReason gcc_reason
  1693. )
  1694. {
  1695. CConf *pConf;
  1696. PENDING_JOIN_CONF *pJoinInfo;
  1697. ConnectionHandle hConn;
  1698. BOOL fMoreToFlush;
  1699. DebugEntry(GCCController::ProcessConfTerminated);
  1700. if (NULL != (pConf = m_ConfList2.Find(conference_id)))
  1701. {
  1702. /*
  1703. ** The conference object will be deleted the next time a
  1704. ** heartbeat occurs.
  1705. */
  1706. m_fConfListChangePending = TRUE;
  1707. m_ConfDeleteList.Append(pConf);
  1708. m_ConfList2.Remove(conference_id);
  1709. PostMsgToRebuildConfPollList();
  1710. // flush any pending join requests from remote
  1711. do
  1712. {
  1713. fMoreToFlush = FALSE;
  1714. m_PendingJoinConfList2.Reset();
  1715. while (NULL != (pJoinInfo = m_PendingJoinConfList2.Iterate(&hConn)))
  1716. {
  1717. if (pJoinInfo->nConfID == conference_id)
  1718. {
  1719. FailConfJoinIndResponse(pJoinInfo->nConfID, hConn);
  1720. m_PendingJoinConfList2.Remove(hConn);
  1721. delete pJoinInfo;
  1722. fMoreToFlush = TRUE;
  1723. break;
  1724. }
  1725. }
  1726. }
  1727. while (fMoreToFlush);
  1728. #ifdef TSTATUS_INDICATION
  1729. /*
  1730. ** Here we inform the node controller of any resource errors that
  1731. ** occured by sending a status message.
  1732. */
  1733. if ((gcc_reason == GCC_REASON_ERROR_LOW_RESOURCES) ||
  1734. (gcc_reason == GCC_REASON_MCS_RESOURCE_FAILURE))
  1735. {
  1736. g_pControlSap->StatusIndication(
  1737. GCC_STATUS_CONF_RESOURCE_ERROR,
  1738. (UINT)conference_id);
  1739. }
  1740. #endif // TSTATUS_INDICATION
  1741. }
  1742. DebugExitINT(GCCController::ProcessConfTerminated, GCC_NO_ERROR);
  1743. return (GCC_NO_ERROR);
  1744. }
  1745. // Calls received from the MCS interface
  1746. void GCCController::RemoveConfJoinInfo(ConnectionHandle hConn)
  1747. {
  1748. PENDING_JOIN_CONF *pJoinInfo = m_PendingJoinConfList2.Remove(hConn);
  1749. delete pJoinInfo;
  1750. }
  1751. /*
  1752. * GCCController::ProcessConnectProviderIndication ()
  1753. *
  1754. * Private Function Description
  1755. * This routine is called when the controller receives a Connect
  1756. * Provider Indication. All connect provider indications are
  1757. * initially directed to the controller. They may then be routed
  1758. * to the Control SAP (for a create, query, join or an invite).
  1759. *
  1760. * Formal Parameters:
  1761. * connect_provider_indication - (i) This is the connect provider
  1762. * indication structure received
  1763. * from MCS.
  1764. *
  1765. * Return Value
  1766. * MCS_NO_ERROR - No error occured.
  1767. *
  1768. * Side Effects
  1769. * None
  1770. *
  1771. * Caveats
  1772. * Note that MCS_NO_ERROR is always returned from this routine.
  1773. * This ensures that the MCS will not resend this message.
  1774. */
  1775. GCCError GCCController::
  1776. ProcessConnectProviderIndication
  1777. (
  1778. PConnectProviderIndication connect_provider_indication
  1779. )
  1780. {
  1781. GCCError error_value = GCC_NO_ERROR;
  1782. PPacket packet;
  1783. PConnectGCCPDU connect_pdu;
  1784. PacketError packet_error;
  1785. Result mcs_result = RESULT_UNSPECIFIED_FAILURE;
  1786. DebugEntry(GCCController::ProcessConnectProviderIndication);
  1787. // Decode the PDU type and switch appropriatly
  1788. DBG_SAVE_FILE_LINE
  1789. packet = new Packet((PPacketCoder) g_GCCCoder,
  1790. PACKED_ENCODING_RULES,
  1791. connect_provider_indication->user_data,
  1792. connect_provider_indication->user_data_length,
  1793. CONNECT_GCC_PDU,
  1794. TRUE,
  1795. &packet_error);
  1796. if ((packet != NULL) && (packet_error == PACKET_NO_ERROR))
  1797. {
  1798. // Only connect PDUs should be processed here
  1799. connect_pdu = (PConnectGCCPDU)packet->GetDecodedData();
  1800. /*
  1801. ** Here we determine what type of GCC connect packet this is and
  1802. ** the request is passed on to the appropriate routine to process
  1803. ** the request.
  1804. */
  1805. switch (connect_pdu->choice)
  1806. {
  1807. case CONFERENCE_CREATE_REQUEST_CHOSEN:
  1808. error_value = ProcessConferenceCreateRequest(
  1809. &(connect_pdu->u.conference_create_request),
  1810. connect_provider_indication);
  1811. break;
  1812. case CONFERENCE_QUERY_REQUEST_CHOSEN:
  1813. error_value = ProcessConferenceQueryRequest(
  1814. &(connect_pdu->u.conference_query_request),
  1815. connect_provider_indication);
  1816. break;
  1817. case CONNECT_JOIN_REQUEST_CHOSEN:
  1818. error_value = ProcessConferenceJoinRequest(
  1819. &(connect_pdu->u.connect_join_request),
  1820. connect_provider_indication);
  1821. break;
  1822. case CONFERENCE_INVITE_REQUEST_CHOSEN:
  1823. error_value = ProcessConferenceInviteRequest(
  1824. &(connect_pdu->u.conference_invite_request),
  1825. connect_provider_indication);
  1826. break;
  1827. default:
  1828. WARNING_OUT(("GCCController::ProcessConnectProviderIndication: connect pdu not supported"));
  1829. error_value = GCC_COMMAND_NOT_SUPPORTED;
  1830. break;
  1831. }
  1832. packet->Unlock();
  1833. }
  1834. else
  1835. {
  1836. if (packet != NULL)
  1837. {
  1838. /*
  1839. ** Here we send a status indication to inform the node controller
  1840. ** that someone attempted to call us with an incompatible protocol.
  1841. */
  1842. if (packet_error == PACKET_INCOMPATIBLE_PROTOCOL)
  1843. {
  1844. #ifdef TSTATUS_INDICATION
  1845. g_pControlSap->StatusIndication(GCC_STATUS_INCOMPATIBLE_PROTOCOL, 0);
  1846. #endif // TSTATUS_INDICATION
  1847. mcs_result = RESULT_PARAMETERS_UNACCEPTABLE;
  1848. }
  1849. packet->Unlock();
  1850. }
  1851. error_value = GCC_ALLOCATION_FAILURE;
  1852. }
  1853. /*
  1854. ** Here, if an error occured, we send back the connect provider response
  1855. ** showing that a failure occured. We use the
  1856. ** RESULT_PARAMETERS_UNACCEPTABLE to indicate that an
  1857. ** incompatible protocol occured. Otherwise, we return a result of
  1858. ** RESULT_UNSPECIFIED_FAILURE.
  1859. */
  1860. if (error_value != GCC_NO_ERROR)
  1861. {
  1862. WARNING_OUT(("GCCController:ProcessConnectProviderIndication: "
  1863. "Error occured processing connect provider: error = %d", error_value));
  1864. g_pMCSIntf->ConnectProviderResponse(
  1865. connect_provider_indication->connection_handle,
  1866. NULL,
  1867. &(connect_provider_indication->domain_parameters),
  1868. mcs_result,
  1869. NULL, 0);
  1870. }
  1871. DebugExitINT(GCCController::ProcessConnectProviderIndication, error_value);
  1872. return error_value;
  1873. }
  1874. /*
  1875. * GCCController::ProcessConferenceCreateRequest ()
  1876. *
  1877. * Private Function Description
  1878. * This routine processes a GCC conference create request "connect"
  1879. * PDU structure. Note that the PDU has already been decoded by
  1880. * the time it reaches this routine.
  1881. *
  1882. * Formal Parameters:
  1883. * create_request - (i) This is a pointer to a structure
  1884. * that holds a GCC conference create
  1885. * request connect PDU.
  1886. * connect_provider_indication - (i) This is the connect provider
  1887. * indication structure received
  1888. * from MCS.
  1889. *
  1890. * Return Value
  1891. * GCC_NO_ERROR - No error occured.
  1892. * GCC_ALLOCATION_FAILURE - A resource error occured.
  1893. * GCC_INVALID_PASSWORD - Invalid password in the PDU.
  1894. * GCC_BAD_USER_DATA - Invalid user data in the PDU.
  1895. *
  1896. * Side Effects
  1897. * None
  1898. *
  1899. * Caveats
  1900. * None
  1901. */
  1902. GCCError GCCController::ProcessConferenceCreateRequest(
  1903. PConferenceCreateRequest create_request,
  1904. PConnectProviderIndication connect_provider_indication)
  1905. {
  1906. GCCError rc = GCC_NO_ERROR;
  1907. PENDING_CREATE_CONF *conference_info;
  1908. GCCConferenceName conference_name;
  1909. GCCConfID conference_id;
  1910. CPassword *convener_password_ptr = NULL;
  1911. CPassword *password_ptr = NULL;
  1912. LPWSTR pwszConfDescription = NULL;
  1913. LPWSTR pwszCallerID = NULL;
  1914. CUserDataListContainer *user_data_list = NULL;
  1915. DebugEntry(GCCController::ProcessConferenceCreateRequest);
  1916. DBG_SAVE_FILE_LINE
  1917. conference_info = new PENDING_CREATE_CONF;
  1918. if (conference_info != NULL)
  1919. {
  1920. /*
  1921. ** This section of the code deals with the conference name
  1922. */
  1923. conference_name.numeric_string = (GCCNumericString)create_request->
  1924. conference_name.numeric;
  1925. // Set up the numeric name portion of the conference info structure.
  1926. conference_info->pszConfNumericName = ::My_strdupA(create_request->conference_name.numeric);
  1927. // Next get the text conference name if one exists
  1928. if (create_request->conference_name.bit_mask &
  1929. CONFERENCE_NAME_TEXT_PRESENT)
  1930. {
  1931. // Save the unicode string object in the conference info structure.
  1932. if (NULL != (conference_info->pwszConfTextName = ::My_strdupW2(
  1933. create_request->conference_name.conference_name_text.length,
  1934. create_request->conference_name.conference_name_text.value)))
  1935. {
  1936. conference_name.text_string = conference_info->pwszConfTextName;
  1937. }
  1938. else
  1939. {
  1940. rc = GCC_ALLOCATION_FAILURE;
  1941. }
  1942. }
  1943. else
  1944. {
  1945. conference_name.text_string = NULL;
  1946. ASSERT(NULL == conference_info->pwszConfTextName);
  1947. }
  1948. // Unpack the convener password
  1949. if ((create_request->bit_mask & CCRQ_CONVENER_PASSWORD_PRESENT) &&
  1950. (rc == GCC_NO_ERROR))
  1951. {
  1952. DBG_SAVE_FILE_LINE
  1953. convener_password_ptr = new CPassword(
  1954. &create_request->ccrq_convener_password,
  1955. &rc);
  1956. if (convener_password_ptr == NULL)
  1957. rc = GCC_ALLOCATION_FAILURE;
  1958. }
  1959. // Unpack the password
  1960. if ((create_request->bit_mask & CCRQ_PASSWORD_PRESENT) &&
  1961. (rc == GCC_NO_ERROR))
  1962. {
  1963. DBG_SAVE_FILE_LINE
  1964. password_ptr = new CPassword(&create_request->ccrq_password, &rc);
  1965. if (password_ptr == NULL)
  1966. rc = GCC_ALLOCATION_FAILURE;
  1967. }
  1968. // Unpack the privilege list that exists
  1969. conference_info->conduct_privilege_list = NULL;
  1970. conference_info->conduct_mode_privilege_list = NULL;
  1971. conference_info->non_conduct_privilege_list = NULL;
  1972. if ((create_request->bit_mask & CCRQ_CONDUCTOR_PRIVS_PRESENT) &&
  1973. (rc == GCC_NO_ERROR))
  1974. {
  1975. DBG_SAVE_FILE_LINE
  1976. conference_info->conduct_privilege_list = new PrivilegeListData (
  1977. create_request->ccrq_conductor_privs);
  1978. if (conference_info->conduct_privilege_list == NULL)
  1979. rc = GCC_ALLOCATION_FAILURE;
  1980. }
  1981. if ((create_request->bit_mask & CCRQ_CONDUCTED_PRIVS_PRESENT) &&
  1982. (rc == GCC_NO_ERROR))
  1983. {
  1984. DBG_SAVE_FILE_LINE
  1985. conference_info->conduct_mode_privilege_list =
  1986. new PrivilegeListData (create_request->ccrq_conducted_privs);
  1987. if (conference_info->conduct_mode_privilege_list == NULL)
  1988. rc = GCC_ALLOCATION_FAILURE;
  1989. }
  1990. if ((create_request->bit_mask & CCRQ_NON_CONDUCTED_PRIVS_PRESENT) &&
  1991. (rc == GCC_NO_ERROR))
  1992. {
  1993. DBG_SAVE_FILE_LINE
  1994. conference_info->non_conduct_privilege_list =
  1995. new PrivilegeListData(create_request->ccrq_non_conducted_privs);
  1996. if (conference_info->non_conduct_privilege_list == NULL)
  1997. rc = GCC_ALLOCATION_FAILURE;
  1998. }
  1999. // Unpack the conference description if one exists
  2000. if ((create_request->bit_mask & CCRQ_DESCRIPTION_PRESENT) &&
  2001. (rc == GCC_NO_ERROR))
  2002. {
  2003. pwszConfDescription = create_request->ccrq_description.value;
  2004. /* Save conference description data in info for later use. This
  2005. ** constructor will automatically append a NULL terminator to the
  2006. ** end of the string.
  2007. */
  2008. if (NULL == (conference_info->pwszConfDescription = ::My_strdupW2(
  2009. create_request->ccrq_description.length,
  2010. create_request->ccrq_description.value)))
  2011. {
  2012. rc = GCC_ALLOCATION_FAILURE;
  2013. }
  2014. }
  2015. else
  2016. {
  2017. ASSERT(NULL == conference_info->pwszConfDescription);
  2018. }
  2019. // Unpack the caller identifier if one exists
  2020. if ((create_request->bit_mask & CCRQ_CALLER_ID_PRESENT) &&
  2021. (rc == GCC_NO_ERROR))
  2022. {
  2023. /*
  2024. * Use a temporary UnicodeString object in order to append a NULL
  2025. * terminator to the end of the string.
  2026. */
  2027. if (NULL == (pwszCallerID = ::My_strdupW2(
  2028. create_request->ccrq_caller_id.length,
  2029. create_request->ccrq_caller_id.value)))
  2030. {
  2031. rc = GCC_ALLOCATION_FAILURE;
  2032. }
  2033. }
  2034. // Unpack the user data list if it exists
  2035. if ((create_request->bit_mask & CCRQ_USER_DATA_PRESENT) &&
  2036. (rc == GCC_NO_ERROR))
  2037. {
  2038. DBG_SAVE_FILE_LINE
  2039. user_data_list = new CUserDataListContainer(create_request->ccrq_user_data, &rc);
  2040. if (user_data_list == NULL)
  2041. {
  2042. rc = GCC_ALLOCATION_FAILURE;
  2043. }
  2044. }
  2045. if (rc == GCC_NO_ERROR)
  2046. {
  2047. // Build the conference information structure
  2048. conference_info->connection_handle =
  2049. connect_provider_indication->connection_handle;
  2050. conference_info->conference_is_locked =
  2051. create_request->conference_is_locked;
  2052. conference_info->conference_is_listed =
  2053. create_request->conference_is_listed;
  2054. conference_info->conference_is_conductible =
  2055. create_request->conference_is_conductible;
  2056. conference_info->termination_method =
  2057. (GCCTerminationMethod)
  2058. create_request->termination_method;
  2059. /*
  2060. ** Add the conference information to the conference
  2061. ** info list. This will be accessed again on a
  2062. ** conference create response.
  2063. */
  2064. conference_id = AllocateConferenceID();
  2065. m_PendingCreateConfList2.Append(conference_id, conference_info);
  2066. g_pControlSap->ConfCreateIndication
  2067. (
  2068. &conference_name,
  2069. conference_id,
  2070. convener_password_ptr,
  2071. password_ptr,
  2072. conference_info->conference_is_locked,
  2073. conference_info->conference_is_listed,
  2074. conference_info->conference_is_conductible,
  2075. conference_info->termination_method,
  2076. conference_info->conduct_privilege_list,
  2077. conference_info->conduct_mode_privilege_list,
  2078. conference_info->non_conduct_privilege_list,
  2079. pwszConfDescription,
  2080. pwszCallerID,
  2081. NULL, // FIX: When supported by MCS
  2082. NULL, // FIX: When supported by MCS
  2083. &(connect_provider_indication->domain_parameters),
  2084. user_data_list,
  2085. connect_provider_indication->connection_handle);
  2086. //
  2087. // LONCHANC: Who is going to delete conference_info?
  2088. //
  2089. }
  2090. else
  2091. {
  2092. delete conference_info;
  2093. }
  2094. // Free up the user data list
  2095. if (user_data_list != NULL)
  2096. {
  2097. user_data_list->Release();
  2098. }
  2099. }
  2100. else
  2101. {
  2102. rc = GCC_ALLOCATION_FAILURE;
  2103. }
  2104. DebugExitINT(GCCController::ProcessConferenceCreateRequest, rc);
  2105. return (rc);
  2106. }
  2107. /*
  2108. * GCCController::ProcessConferenceQueryRequest ()
  2109. *
  2110. * Private Function Description
  2111. * This routine processes a GCC conference query request "connect"
  2112. * PDU structure. Note that the PDU has already been decoded by
  2113. * the time it reaches this routine.
  2114. *
  2115. * Formal Parameters:
  2116. * query_request - (i) This is a pointer to a structure
  2117. * that holds a GCC conference query
  2118. * request connect PDU.
  2119. * connect_provider_indication - (i) This is the connect provider
  2120. * indication structure received
  2121. * from MCS.
  2122. *
  2123. * Return Value
  2124. * GCC_NO_ERROR - No error occured.
  2125. * GCC_ALLOCATION_FAILURE - A resource error occured.
  2126. * GCC_BAD_USER_DATA - Invalid user data in the PDU.
  2127. *
  2128. * Side Effects
  2129. * None
  2130. *
  2131. * Caveats
  2132. * None
  2133. */
  2134. GCCError GCCController::ProcessConferenceQueryRequest (
  2135. PConferenceQueryRequest query_request,
  2136. PConnectProviderIndication connect_provider_indication)
  2137. {
  2138. GCCError rc = GCC_NO_ERROR;
  2139. GCCNodeType node_type;
  2140. GCCAsymmetryIndicator asymmetry_indicator;
  2141. PGCCAsymmetryIndicator asymmetry_indicator_ptr = NULL;
  2142. CUserDataListContainer *user_data_list = NULL;
  2143. DebugEntry(GCCController::ProcessConferenceQueryRequest);
  2144. node_type = (GCCNodeType)query_request->node_type;
  2145. // First get the asymmetry indicator if it exists
  2146. if (query_request->bit_mask & CQRQ_ASYMMETRY_INDICATOR_PRESENT)
  2147. {
  2148. asymmetry_indicator.asymmetry_type =
  2149. (GCCAsymmetryType)query_request->cqrq_asymmetry_indicator.choice;
  2150. asymmetry_indicator.random_number =
  2151. query_request->cqrq_asymmetry_indicator.u.unknown;
  2152. asymmetry_indicator_ptr = &asymmetry_indicator;
  2153. }
  2154. // Next get the user data if it exists
  2155. if (query_request->bit_mask & CQRQ_USER_DATA_PRESENT)
  2156. {
  2157. DBG_SAVE_FILE_LINE
  2158. user_data_list = new CUserDataListContainer(query_request->cqrq_user_data, &rc);
  2159. if (user_data_list == NULL)
  2160. {
  2161. rc = GCC_ALLOCATION_FAILURE;
  2162. }
  2163. }
  2164. if (rc == GCC_NO_ERROR)
  2165. {
  2166. g_pControlSap->ConfQueryIndication(
  2167. (GCCResponseTag)connect_provider_indication->
  2168. connection_handle,
  2169. node_type,
  2170. asymmetry_indicator_ptr,
  2171. NULL, // FIX: When transport address supported by MCS
  2172. NULL, // FIX: When transport address supported by MCS
  2173. user_data_list,
  2174. connect_provider_indication->connection_handle);
  2175. }
  2176. // Free the user data list container
  2177. if (user_data_list != NULL)
  2178. {
  2179. user_data_list->Release();
  2180. }
  2181. DebugExitINT(GCCController::ProcessConferenceQueryRequest, rc);
  2182. return (rc);
  2183. }
  2184. /*
  2185. * GCCController::ProcessConferenceJoinRequest ()
  2186. *
  2187. * Private Function Description
  2188. * This routine processes a GCC conference join request "connect"
  2189. * PDU structure. Note that the PDU has already been decoded by
  2190. * the time it reaches this routine.
  2191. *
  2192. * If the conference conference exist and this node is the Top
  2193. * Provider for the conference we allow the join request to propogate
  2194. * up to the node controller so that the decision about how to proceed is
  2195. * made there.
  2196. *
  2197. * If the conference exist and this is not the Top Provider we
  2198. * still send the join indication to the intermediate node controller
  2199. * so that this node has a chance to reject it before the join request is
  2200. * passed on up to the top provider.
  2201. *
  2202. * If the conference does not currently exist at this node
  2203. * we immediately reject the request and send a status indication to
  2204. * the local node controller to inform it of the failed join attempt.
  2205. *
  2206. * Formal Parameters:
  2207. * join_request - (i) This is a pointer to a structure
  2208. * that holds a GCC conference join
  2209. * request connect PDU.
  2210. * connect_provider_indication - (i) This is the connect provider
  2211. * indication structure received
  2212. * from MCS.
  2213. *
  2214. * Return Value
  2215. * GCC_NO_ERROR - No error occured.
  2216. * GCC_ALLOCATION_FAILURE - A resource error occured.
  2217. * GCC_BAD_USER_DATA - Invalid user data in the PDU.
  2218. * GCC_INVALID_PASSWORD - Invalid password in the PDU.
  2219. * GCC_INVALID_CONFERENCE_NAME - Invalid conference name in PDU.
  2220. *
  2221. * Side Effects
  2222. * None
  2223. *
  2224. * Caveats
  2225. * None
  2226. */
  2227. GCCError GCCController::ProcessConferenceJoinRequest(
  2228. PConferenceJoinRequest join_request,
  2229. PConnectProviderIndication connect_provider_indication)
  2230. {
  2231. GCCError rc = GCC_NO_ERROR;
  2232. GCCConfID conference_id = 0;
  2233. GCCConferenceName conference_name;
  2234. GCCNumericString conference_modifier = NULL;
  2235. PConference conference_ptr = NULL;
  2236. CUserDataListContainer *user_data_list;
  2237. BOOL intermediate_node = FALSE;
  2238. PENDING_JOIN_CONF *join_info_ptr;
  2239. BOOL convener_exists = FALSE;
  2240. BOOL conference_is_locked = FALSE;
  2241. GCCStatusMessageType status_message_type;
  2242. CPassword *convener_password = NULL;
  2243. CPassword *password_challenge = NULL;
  2244. PConference lpConf;
  2245. GCCResult gcc_result = GCC_RESULT_SUCCESSFUL;
  2246. DebugEntry(GCCController::ProcessConferenceJoinRequest);
  2247. DBG_SAVE_FILE_LINE
  2248. join_info_ptr = new PENDING_JOIN_CONF;
  2249. if (join_info_ptr != NULL)
  2250. {
  2251. // Get the conference name
  2252. if (join_request->bit_mask & CONFERENCE_NAME_PRESENT)
  2253. {
  2254. if (join_request->conference_name.choice == NAME_SELECTOR_NUMERIC_CHOSEN)
  2255. {
  2256. conference_name.numeric_string =
  2257. (GCCNumericString)join_request->conference_name.u.name_selector_numeric;
  2258. conference_name.text_string = NULL;
  2259. join_info_ptr->numeric_name_present = TRUE;
  2260. }
  2261. else
  2262. {
  2263. conference_name.numeric_string = NULL;
  2264. /*
  2265. * Use a temporary UnicodeString object in order to append a
  2266. * NULL terminator to the end of the string.
  2267. */
  2268. if (NULL == (conference_name.text_string = ::My_strdupW2(
  2269. join_request->conference_name.u.name_selector_text.length,
  2270. join_request->conference_name.u.name_selector_text.value)))
  2271. {
  2272. rc = GCC_ALLOCATION_FAILURE;
  2273. }
  2274. join_info_ptr->numeric_name_present = FALSE;
  2275. }
  2276. }
  2277. else
  2278. rc = GCC_INVALID_CONFERENCE_NAME;
  2279. // Get the conference modifier
  2280. if (join_request->bit_mask & CJRQ_CONFERENCE_MODIFIER_PRESENT)
  2281. conference_modifier = (GCCNumericString)join_request->cjrq_conference_modifier;
  2282. // Get the convener password if one exist
  2283. if ((join_request->bit_mask & CJRQ_CONVENER_PASSWORD_PRESENT) &&
  2284. (rc == GCC_NO_ERROR))
  2285. {
  2286. // First allocate the convener password for the join info structure
  2287. DBG_SAVE_FILE_LINE
  2288. join_info_ptr->convener_password = new CPassword(
  2289. &join_request->cjrq_convener_password,
  2290. &rc);
  2291. if (join_info_ptr->convener_password == NULL)
  2292. rc = GCC_ALLOCATION_FAILURE;
  2293. else if (rc == GCC_NO_ERROR)
  2294. {
  2295. // Now allocate the convener password to send in the indication
  2296. DBG_SAVE_FILE_LINE
  2297. convener_password = new CPassword(
  2298. &join_request->cjrq_convener_password,
  2299. &rc);
  2300. if (convener_password == NULL)
  2301. rc = GCC_ALLOCATION_FAILURE;
  2302. }
  2303. }
  2304. else
  2305. {
  2306. ASSERT(NULL == join_info_ptr->convener_password);
  2307. }
  2308. // Get the password challange if one exist
  2309. if ((join_request->bit_mask & CJRQ_PASSWORD_PRESENT) &&
  2310. (rc == GCC_NO_ERROR))
  2311. {
  2312. // First allocate the password for the join info structure
  2313. DBG_SAVE_FILE_LINE
  2314. join_info_ptr->password_challenge = new CPassword(
  2315. &join_request->cjrq_password,
  2316. &rc);
  2317. if (join_info_ptr->password_challenge == NULL)
  2318. rc = GCC_ALLOCATION_FAILURE;
  2319. else if (rc == GCC_NO_ERROR)
  2320. {
  2321. // Now allocate the password to send in the indication
  2322. DBG_SAVE_FILE_LINE
  2323. password_challenge = new CPassword(
  2324. &join_request->cjrq_password,
  2325. &rc);
  2326. if (password_challenge == NULL)
  2327. rc = GCC_ALLOCATION_FAILURE;
  2328. }
  2329. }
  2330. else
  2331. {
  2332. ASSERT(NULL == join_info_ptr->password_challenge);
  2333. }
  2334. // Get the caller identifier
  2335. if ((join_request->bit_mask & CJRQ_CALLER_ID_PRESENT) &&
  2336. (rc == GCC_NO_ERROR))
  2337. {
  2338. /*
  2339. * Use a temporary UnicodeString object in order to append a
  2340. * NULL terminator to the end of the string.
  2341. */
  2342. if (NULL == (join_info_ptr->pwszCallerID = ::My_strdupW2(
  2343. join_request->cjrq_caller_id.length,
  2344. join_request->cjrq_caller_id.value)))
  2345. {
  2346. rc = GCC_ALLOCATION_FAILURE;
  2347. }
  2348. }
  2349. // Get the user data if it exists
  2350. if ((join_request->bit_mask & CJRQ_USER_DATA_PRESENT) &&
  2351. (rc == GCC_NO_ERROR))
  2352. {
  2353. DBG_SAVE_FILE_LINE
  2354. user_data_list = new CUserDataListContainer(join_request->cjrq_user_data, &rc);
  2355. if (user_data_list == NULL)
  2356. {
  2357. rc = GCC_ALLOCATION_FAILURE;
  2358. }
  2359. }
  2360. else
  2361. {
  2362. user_data_list = NULL;
  2363. }
  2364. if (rc == GCC_NO_ERROR)
  2365. {
  2366. /*
  2367. ** We must query each conference to determine if the name
  2368. ** matches the name recevied from the joining node.
  2369. */
  2370. conference_id = GetConferenceIDFromName(&conference_name,
  2371. conference_modifier);
  2372. // Determine if this is an intermediate node
  2373. if (conference_id == 0)
  2374. {
  2375. /*
  2376. ** If the conference_id equals zero then the conference
  2377. ** specified in the join request does not exists and the
  2378. ** request is automatically rejected. We send a GCC status
  2379. ** indication to the control sap to indicate that someone
  2380. ** tried to join with a bad conference name.
  2381. */
  2382. gcc_result = GCC_RESULT_INVALID_CONFERENCE;
  2383. // Set up the status message
  2384. status_message_type = GCC_STATUS_JOIN_FAILED_BAD_CONF_NAME;
  2385. }
  2386. else if (NULL != (lpConf = m_ConfList2.Find(conference_id)) &&
  2387. lpConf->IsConfEstablished() == FALSE)
  2388. {
  2389. /*
  2390. ** If the conference is not established then the conference
  2391. ** specified in the join request does not exists and the
  2392. ** request is automatically rejected. We send a GCC status
  2393. ** indication to the control sap to indicate that someone
  2394. ** tried to join with a bad conference name.
  2395. */
  2396. gcc_result = GCC_RESULT_INVALID_CONFERENCE;
  2397. // Set up the status message
  2398. status_message_type = GCC_STATUS_JOIN_FAILED_BAD_CONF_NAME;
  2399. }
  2400. else if (NULL != (lpConf = m_ConfList2.Find(conference_id)) &&
  2401. lpConf->IsConfSecure() != connect_provider_indication->fSecure )
  2402. {
  2403. /*
  2404. ** If the conference security does not match the security
  2405. ** setting of the connection underlying the join then the
  2406. ** join is rejected
  2407. */
  2408. WARNING_OUT(("JOIN REJECTED: %d joins %d",
  2409. connect_provider_indication->fSecure,
  2410. lpConf->IsConfSecure() ));
  2411. //
  2412. // Make sure that we really compared 2 booleans
  2413. //
  2414. ASSERT(FALSE == lpConf->IsConfSecure() ||
  2415. TRUE == lpConf->IsConfSecure() );
  2416. ASSERT(FALSE == connect_provider_indication->fSecure ||
  2417. TRUE == connect_provider_indication->fSecure );
  2418. // BUGBUG - these don't map to good UI errors
  2419. gcc_result = lpConf->IsConfSecure() ?
  2420. GCC_RESULT_CONNECT_PROVIDER_REMOTE_REQUIRE_SECURITY :
  2421. GCC_RESULT_CONNECT_PROVIDER_REMOTE_NO_SECURITY ;
  2422. // Set up the status message
  2423. status_message_type = GCC_STATUS_INCOMPATIBLE_PROTOCOL;
  2424. }
  2425. else
  2426. {
  2427. conference_ptr = m_ConfList2.Find(conference_id);
  2428. if (! conference_ptr->IsConfTopProvider())
  2429. intermediate_node = TRUE;
  2430. convener_exists = conference_ptr->DoesConvenerExists();
  2431. conference_is_locked = conference_ptr->IsConfLocked();
  2432. /*
  2433. ** This logic takes care of the convener password. If the
  2434. ** convener password exists we must make sure that the
  2435. ** conference does not already have a convener, that this is
  2436. ** not an intermediate node within the conference.
  2437. */
  2438. if (((join_info_ptr->convener_password == NULL) &&
  2439. (conference_is_locked == FALSE)) ||
  2440. ((join_info_ptr->convener_password != NULL) &&
  2441. (convener_exists == FALSE) &&
  2442. (intermediate_node == FALSE)))
  2443. {
  2444. gcc_result = GCC_RESULT_SUCCESSFUL;
  2445. }
  2446. else
  2447. {
  2448. if (join_info_ptr->convener_password != NULL)
  2449. {
  2450. /*
  2451. ** We must send a rejection here informing the
  2452. ** requester that this was an illegal join attempt due
  2453. ** to the presence of a convener password.
  2454. */
  2455. gcc_result = GCC_RESULT_INVALID_CONVENER_PASSWORD;
  2456. // Set up the status message
  2457. status_message_type = GCC_STATUS_JOIN_FAILED_BAD_CONVENER;
  2458. }
  2459. else
  2460. {
  2461. /*
  2462. ** We must send a rejection here informing the
  2463. ** requester that the conference was locked.
  2464. */
  2465. gcc_result = GCC_RESULT_INVALID_CONFERENCE;
  2466. // Set up the status message
  2467. status_message_type = GCC_STATUS_JOIN_FAILED_LOCKED;
  2468. }
  2469. }
  2470. }
  2471. /*
  2472. ** Here we either send the conference join indication to the
  2473. ** control sap or send back a response specifying a failed
  2474. ** join attempt with the result code. If the response is sent
  2475. ** here we send a status indication to the control sap informing
  2476. ** of the failed join attempt.
  2477. */
  2478. if (gcc_result == GCC_RESULT_SUCCESSFUL)
  2479. {
  2480. /*
  2481. ** Add the join info structure to the list of outstanding
  2482. ** join request.
  2483. */
  2484. join_info_ptr->nConfID = conference_id;
  2485. m_PendingJoinConfList2.Append(connect_provider_indication->connection_handle, join_info_ptr);
  2486. // All join request are passed to the Node Controller.
  2487. g_pControlSap->ConfJoinIndication(
  2488. conference_id,
  2489. convener_password,
  2490. password_challenge,
  2491. join_info_ptr->pwszCallerID,
  2492. NULL, // FIX: Support when added to MCS
  2493. NULL, // FIX: Support when added to MCS
  2494. user_data_list,
  2495. intermediate_node,
  2496. connect_provider_indication->connection_handle);
  2497. }
  2498. else
  2499. {
  2500. ConfJoinResponseInfo cjri;
  2501. #ifdef TSTATUS_INDICATION
  2502. /*
  2503. ** This status message is used to inform the node controller
  2504. ** of the failed join.
  2505. */
  2506. g_pControlSap->StatusIndication(
  2507. status_message_type, conference_id);
  2508. #endif // TSTATUS_INDICATION
  2509. // Send back the failed response with the result
  2510. cjri.result = gcc_result;
  2511. cjri.conference_id = conference_id;
  2512. cjri.password_challenge = NULL;
  2513. cjri.user_data_list = NULL;
  2514. cjri.connection_handle = connect_provider_indication->connection_handle;
  2515. /*
  2516. ** The join response takes care of freeing up the join
  2517. ** info structure.
  2518. */
  2519. ConfJoinIndResponse(&cjri);
  2520. delete join_info_ptr;
  2521. }
  2522. }
  2523. else
  2524. {
  2525. // Clean up the join info data when an error occurs.
  2526. delete join_info_ptr;
  2527. }
  2528. // Free up any containers that are no longer needed
  2529. if (user_data_list != NULL)
  2530. {
  2531. user_data_list->Release();
  2532. }
  2533. if (convener_password != NULL)
  2534. {
  2535. convener_password->Release();
  2536. }
  2537. if (password_challenge != NULL)
  2538. {
  2539. password_challenge->Release();
  2540. }
  2541. delete conference_name.text_string;
  2542. }
  2543. else
  2544. {
  2545. rc = GCC_ALLOCATION_FAILURE;
  2546. }
  2547. // in case of error, we have to flush response PDU in order to unblock the remote node
  2548. if (GCC_NO_ERROR != rc)
  2549. {
  2550. FailConfJoinIndResponse(conference_id, connect_provider_indication->connection_handle);
  2551. }
  2552. DebugExitINT(GCCController::ProcessConferenceJoinRequest, rc);
  2553. return (rc);
  2554. }
  2555. /*
  2556. * GCCController::ProcessConferenceInviteRequest ()
  2557. *
  2558. * Private Function Description
  2559. * This routine processes a GCC conference invite request "connect"
  2560. * PDU structure. Note that the PDU has already been decoded by
  2561. * the time it reaches this routine.
  2562. *
  2563. * Formal Parameters:
  2564. * invite_request - (i) This is a pointer to a structure
  2565. * that holds a GCC conference invite
  2566. * request connect PDU.
  2567. * connect_provider_indication - (i) This is the connect provider
  2568. * indication structure received
  2569. * from MCS.
  2570. *
  2571. * Return Value
  2572. * GCC_NO_ERROR - No error occured.
  2573. * GCC_ALLOCATION_FAILURE - A resource error occured.
  2574. * GCC_BAD_USER_DATA - Invalid user data in the PDU.
  2575. *
  2576. * Side Effects
  2577. * None
  2578. *
  2579. * Caveats
  2580. * None
  2581. */
  2582. GCCError GCCController::ProcessConferenceInviteRequest(
  2583. PConferenceInviteRequest invite_request,
  2584. PConnectProviderIndication connect_provider_indication)
  2585. {
  2586. GCCError rc = GCC_NO_ERROR;
  2587. PENDING_CREATE_CONF *conference_info;
  2588. GCCConfID conference_id;
  2589. LPWSTR pwszCallerID = NULL;
  2590. CUserDataListContainer *user_data_list = NULL;
  2591. GCCConferenceName conference_name;
  2592. LPWSTR pwszConfDescription = NULL;
  2593. DBG_SAVE_FILE_LINE
  2594. conference_info = new PENDING_CREATE_CONF;
  2595. if (conference_info != NULL)
  2596. {
  2597. // First make copies of the conference name
  2598. conference_info->pszConfNumericName = ::My_strdupA(invite_request->conference_name.numeric);
  2599. if (invite_request->conference_name.bit_mask & CONFERENCE_NAME_TEXT_PRESENT)
  2600. {
  2601. if (NULL == (conference_info->pwszConfTextName = ::My_strdupW2(
  2602. invite_request->conference_name.conference_name_text.length,
  2603. invite_request->conference_name.conference_name_text.value)))
  2604. {
  2605. rc = GCC_ALLOCATION_FAILURE;
  2606. }
  2607. }
  2608. else
  2609. {
  2610. ASSERT(NULL == conference_info->pwszConfTextName);
  2611. }
  2612. // Fill in the GCC Conference Name
  2613. conference_name.numeric_string = (GCCNumericString) conference_info->pszConfNumericName;
  2614. conference_name.text_string = conference_info->pwszConfTextName;
  2615. // Now get the privilege lists
  2616. if (invite_request->bit_mask & CIRQ_CONDUCTOR_PRIVS_PRESENT)
  2617. {
  2618. DBG_SAVE_FILE_LINE
  2619. conference_info->conduct_privilege_list = new PrivilegeListData (
  2620. invite_request->cirq_conductor_privs);
  2621. if (conference_info->conduct_privilege_list == NULL)
  2622. rc = GCC_ALLOCATION_FAILURE;
  2623. }
  2624. else
  2625. {
  2626. ASSERT(NULL == conference_info->conduct_privilege_list);
  2627. }
  2628. if (invite_request->bit_mask & CIRQ_CONDUCTED_PRIVS_PRESENT)
  2629. {
  2630. DBG_SAVE_FILE_LINE
  2631. conference_info->conduct_mode_privilege_list =
  2632. new PrivilegeListData(invite_request->cirq_conducted_privs);
  2633. if (conference_info->conduct_mode_privilege_list == NULL)
  2634. rc = GCC_ALLOCATION_FAILURE;
  2635. }
  2636. else
  2637. {
  2638. ASSERT(NULL == conference_info->conduct_mode_privilege_list);
  2639. }
  2640. if (invite_request->bit_mask & CIRQ_NON_CONDUCTED_PRIVS_PRESENT)
  2641. {
  2642. DBG_SAVE_FILE_LINE
  2643. conference_info->non_conduct_privilege_list =
  2644. new PrivilegeListData(invite_request->cirq_non_conducted_privs);
  2645. if (conference_info->non_conduct_privilege_list == NULL)
  2646. rc = GCC_ALLOCATION_FAILURE;
  2647. }
  2648. else
  2649. {
  2650. ASSERT(NULL == conference_info->non_conduct_privilege_list);
  2651. }
  2652. // Get the conference description of one exists
  2653. if (invite_request->bit_mask & CIRQ_DESCRIPTION_PRESENT)
  2654. {
  2655. if (NULL == (conference_info->pwszConfDescription = ::My_strdupW2(
  2656. invite_request->cirq_description.length,
  2657. invite_request->cirq_description.value)))
  2658. {
  2659. rc = GCC_ALLOCATION_FAILURE;
  2660. }
  2661. else
  2662. {
  2663. pwszConfDescription = conference_info->pwszConfDescription;
  2664. }
  2665. }
  2666. else
  2667. {
  2668. ASSERT(NULL == conference_info->pwszConfDescription);
  2669. }
  2670. // Get the caller identifier
  2671. if (invite_request->bit_mask & CIRQ_CALLER_ID_PRESENT)
  2672. {
  2673. /*
  2674. * Use a temporary UnicodeString object in order to append a
  2675. * NULL terminator to the end of the string.
  2676. */
  2677. if (NULL == (pwszCallerID = ::My_strdupW2(
  2678. invite_request->cirq_caller_id.length,
  2679. invite_request->cirq_caller_id.value)))
  2680. {
  2681. rc = GCC_ALLOCATION_FAILURE;
  2682. }
  2683. }
  2684. // Get the user data if any exists
  2685. if ((invite_request->bit_mask & CIRQ_USER_DATA_PRESENT) &&
  2686. (rc == GCC_NO_ERROR))
  2687. {
  2688. DBG_SAVE_FILE_LINE
  2689. user_data_list = new CUserDataListContainer(invite_request->cirq_user_data, &rc);
  2690. if (user_data_list == NULL)
  2691. {
  2692. rc = GCC_ALLOCATION_FAILURE;
  2693. }
  2694. }
  2695. if (rc == GCC_NO_ERROR)
  2696. {
  2697. // Build the conference information structure
  2698. conference_info->connection_handle =
  2699. connect_provider_indication->connection_handle;
  2700. conference_info->password_in_the_clear =
  2701. invite_request->clear_password_required;
  2702. conference_info->conference_is_listed =
  2703. invite_request->conference_is_listed;
  2704. conference_info->conference_is_locked =
  2705. invite_request->conference_is_locked;
  2706. conference_info->conference_is_conductible =
  2707. invite_request->conference_is_conductible;
  2708. conference_info->termination_method =
  2709. (GCCTerminationMethod)invite_request->termination_method;
  2710. conference_info->top_node_id = (UserID)invite_request->top_node_id;
  2711. conference_info->parent_node_id = (UserID)invite_request->node_id;
  2712. conference_info->tag_number = invite_request->tag;
  2713. /*
  2714. ** Add the conference information to the conference
  2715. ** info list. This will be accessed again on a
  2716. ** conference create response.
  2717. */
  2718. conference_id = AllocateConferenceID();
  2719. m_PendingCreateConfList2.Append(conference_id, conference_info);
  2720. g_pControlSap->ConfInviteIndication(
  2721. conference_id,
  2722. &conference_name,
  2723. pwszCallerID,
  2724. NULL, // FIX : When supported by MCS
  2725. NULL, // FIX : When supported by MCS
  2726. connect_provider_indication->fSecure,
  2727. &(connect_provider_indication->domain_parameters),
  2728. conference_info->password_in_the_clear,
  2729. conference_info->conference_is_locked,
  2730. conference_info->conference_is_listed,
  2731. conference_info->conference_is_conductible,
  2732. conference_info->termination_method,
  2733. conference_info->conduct_privilege_list,
  2734. conference_info->conduct_mode_privilege_list,
  2735. conference_info->non_conduct_privilege_list,
  2736. pwszConfDescription,
  2737. user_data_list,
  2738. connect_provider_indication->connection_handle);
  2739. //
  2740. // LONCHANC: Who will free conference_info?
  2741. //
  2742. }
  2743. else
  2744. {
  2745. delete conference_info;
  2746. }
  2747. // Free up the user data list
  2748. if (user_data_list != NULL)
  2749. {
  2750. user_data_list->Release();
  2751. }
  2752. delete pwszCallerID;
  2753. }
  2754. else
  2755. {
  2756. rc = GCC_ALLOCATION_FAILURE;
  2757. }
  2758. return (rc);
  2759. }
  2760. /*
  2761. * GCCController::ProcessConnectProviderConfirm ()
  2762. *
  2763. * Private Function Description
  2764. * This routine is called when the controller receives a Connect Provider
  2765. * confirm from the MCS interface. This will occur after a conference
  2766. * query request is issued. All other connect provider confirms should
  2767. * be directly handled by the conference object.
  2768. *
  2769. * Formal Parameters:
  2770. * connect_provider_confirm - (i) This is the connect provider
  2771. * confirm structure received
  2772. * from MCS.
  2773. *
  2774. * Return Value
  2775. * GCC_NO_ERROR - No error occured.
  2776. * GCC_ALLOCATION_FAILURE - A resource error occured.
  2777. *
  2778. * Side Effects
  2779. * None
  2780. *
  2781. * Caveats
  2782. * None
  2783. */
  2784. GCCError GCCController::
  2785. ProcessConnectProviderConfirm
  2786. (
  2787. PConnectProviderConfirm connect_provider_confirm
  2788. )
  2789. {
  2790. GCCError error_value = GCC_NO_ERROR;
  2791. PPacket packet;
  2792. PConnectGCCPDU connect_pdu;
  2793. PacketError packet_error;
  2794. /*
  2795. ** If the user data length is zero then the GCC request to MCS to
  2796. ** connect provider failed (probably do to a bad address). If this
  2797. ** happens we will check the connection handle to determine what
  2798. ** request to match the failed confirm with.
  2799. */
  2800. if (connect_provider_confirm->user_data_length != 0)
  2801. {
  2802. // Decode the PDU type and switch appropriatly
  2803. DBG_SAVE_FILE_LINE
  2804. packet = new Packet((PPacketCoder) g_GCCCoder,
  2805. PACKED_ENCODING_RULES,
  2806. connect_provider_confirm->user_data,
  2807. connect_provider_confirm->user_data_length,
  2808. CONNECT_GCC_PDU,
  2809. TRUE,
  2810. &packet_error);
  2811. if ((packet != NULL) && (packet_error == PACKET_NO_ERROR))
  2812. {
  2813. // Only connect PDUs should be processed here
  2814. connect_pdu = (PConnectGCCPDU)packet->GetDecodedData();
  2815. switch (connect_pdu->choice)
  2816. {
  2817. case CONFERENCE_QUERY_RESPONSE_CHOSEN:
  2818. ProcessConferenceQueryResponse(
  2819. &(connect_pdu->u.conference_query_response),
  2820. connect_provider_confirm);
  2821. break;
  2822. default:
  2823. error_value = GCC_COMMAND_NOT_SUPPORTED;
  2824. break;
  2825. }
  2826. packet->Unlock();
  2827. }
  2828. else
  2829. {
  2830. if (packet != NULL)
  2831. packet->Unlock();
  2832. error_value = GCC_ALLOCATION_FAILURE;
  2833. }
  2834. }
  2835. else
  2836. error_value = GCC_ALLOCATION_FAILURE;
  2837. if (error_value != GCC_NO_ERROR)
  2838. {
  2839. /*
  2840. ** Since we are only processing conference query responses here
  2841. ** we know that any failure must be associated with one of these
  2842. ** request.
  2843. */
  2844. ProcessConferenceQueryResponse( NULL,
  2845. connect_provider_confirm);
  2846. }
  2847. return error_value;
  2848. }
  2849. /*
  2850. * GCCController::ProcessConferenceQueryResponse ()
  2851. *
  2852. * Private Function Description
  2853. * This routine processes a GCC conference query response "connect"
  2854. * PDU structure. Note that the PDU has already been decoded by
  2855. * the time it reaches this routine.
  2856. *
  2857. * Formal Parameters:
  2858. * query_response - (i) This is a pointer to a structure
  2859. * that holds a GCC conference query
  2860. * response connect PDU.
  2861. * connect_provider_confirm - (i) This is the connect provider
  2862. * confirm structure received
  2863. * from MCS.
  2864. *
  2865. * Return Value
  2866. * None
  2867. *
  2868. * Side Effects
  2869. * None
  2870. *
  2871. * Caveats
  2872. * None
  2873. */
  2874. GCCError GCCController::
  2875. ProcessConferenceQueryResponse
  2876. (
  2877. PConferenceQueryResponse query_response,
  2878. PConnectProviderConfirm connect_provider_confirm
  2879. )
  2880. {
  2881. CConfDescriptorListContainer *conference_list;
  2882. GCCError error_value = GCC_NO_ERROR;
  2883. GCCResult result;
  2884. GCCConfID query_id;
  2885. GCCNodeType node_type;
  2886. GCCAsymmetryIndicator asymmetry_indicator;
  2887. PGCCAsymmetryIndicator asymmetry_indicator_ptr = NULL;
  2888. CUserDataListContainer *user_data_list = NULL;
  2889. if (GCC_INVALID_CID != (query_id = m_PendingQueryConfList2.Remove(connect_provider_confirm->connection_handle)))
  2890. {
  2891. // Clean up the query connection and domain used to perform query
  2892. g_pMCSIntf->DeleteDomain(&query_id);
  2893. if (query_response != NULL)
  2894. {
  2895. // Create a new conference list
  2896. DBG_SAVE_FILE_LINE
  2897. conference_list = new CConfDescriptorListContainer(query_response->conference_list, &error_value);
  2898. if ((conference_list != NULL) && (error_value == GCC_NO_ERROR))
  2899. {
  2900. node_type = (GCCNodeType)query_response->node_type;
  2901. // First get the asymmetry indicator if it exists
  2902. if (query_response->bit_mask & CQRS_ASYMMETRY_INDICATOR_PRESENT)
  2903. {
  2904. asymmetry_indicator.asymmetry_type =
  2905. (GCCAsymmetryType)query_response->
  2906. cqrs_asymmetry_indicator.choice;
  2907. asymmetry_indicator.random_number =
  2908. query_response->cqrs_asymmetry_indicator.u.unknown;
  2909. asymmetry_indicator_ptr = &asymmetry_indicator;
  2910. }
  2911. // Next get the user data if it exists
  2912. if (query_response->bit_mask & CQRS_USER_DATA_PRESENT)
  2913. {
  2914. DBG_SAVE_FILE_LINE
  2915. user_data_list = new CUserDataListContainer(query_response->cqrs_user_data, &error_value);
  2916. if (user_data_list == NULL)
  2917. {
  2918. error_value = GCC_ALLOCATION_FAILURE;
  2919. }
  2920. }
  2921. result = ::TranslateQueryResultToGCCResult(query_response->result);
  2922. if (error_value == GCC_NO_ERROR)
  2923. {
  2924. g_pControlSap->ConfQueryConfirm(
  2925. node_type,
  2926. asymmetry_indicator_ptr,
  2927. conference_list,
  2928. user_data_list,
  2929. result,
  2930. connect_provider_confirm->connection_handle);
  2931. }
  2932. /*
  2933. ** Here we call free so that the conference list container
  2934. ** object will be freed up when its lock count goes to zero.
  2935. */
  2936. conference_list->Release();
  2937. }
  2938. else
  2939. {
  2940. if (NULL != conference_list)
  2941. {
  2942. conference_list->Release();
  2943. }
  2944. else
  2945. {
  2946. error_value = GCC_ALLOCATION_FAILURE;
  2947. }
  2948. }
  2949. }
  2950. else
  2951. {
  2952. switch (connect_provider_confirm->result)
  2953. {
  2954. case RESULT_PARAMETERS_UNACCEPTABLE :
  2955. result = GCC_RESULT_INCOMPATIBLE_PROTOCOL;
  2956. break;
  2957. case RESULT_REMOTE_NO_SECURITY :
  2958. result = GCC_RESULT_CONNECT_PROVIDER_REMOTE_NO_SECURITY;
  2959. break;
  2960. case RESULT_REMOTE_DOWNLEVEL_SECURITY :
  2961. result = GCC_RESULT_CONNECT_PROVIDER_REMOTE_DOWNLEVEL_SECURITY;
  2962. break;
  2963. case RESULT_REMOTE_REQUIRE_SECURITY :
  2964. result = GCC_RESULT_CONNECT_PROVIDER_REMOTE_REQUIRE_SECURITY;
  2965. break;
  2966. case RESULT_AUTHENTICATION_FAILED :
  2967. result = GCC_RESULT_CONNECT_PROVIDER_AUTHENTICATION_FAILED;
  2968. break;
  2969. default:
  2970. result = GCC_RESULT_CONNECT_PROVIDER_FAILED;
  2971. break;
  2972. }
  2973. // Send back a failed result
  2974. g_pControlSap->ConfQueryConfirm(
  2975. GCC_TERMINAL,
  2976. NULL,
  2977. NULL,
  2978. NULL,
  2979. result,
  2980. connect_provider_confirm->connection_handle);
  2981. }
  2982. }
  2983. else
  2984. {
  2985. WARNING_OUT(("GCCController:ProcessConferenceQueryResponse: invalid conference"));
  2986. }
  2987. if (NULL != user_data_list)
  2988. {
  2989. user_data_list->Release();
  2990. }
  2991. return error_value;
  2992. }
  2993. void GCCController::
  2994. CancelConfQueryRequest ( ConnectionHandle hQueryReqConn )
  2995. {
  2996. GCCConfID nQueryID;
  2997. if (GCC_INVALID_CID != (nQueryID = m_PendingQueryConfList2.Remove(hQueryReqConn)))
  2998. {
  2999. // Clean up the query connection and domain used to perform query
  3000. g_pMCSIntf->DeleteDomain(&nQueryID);
  3001. // Send back a failed result
  3002. g_pControlSap->ConfQueryConfirm(GCC_TERMINAL, NULL, NULL, NULL,
  3003. GCC_RESULT_CANCELED,
  3004. hQueryReqConn);
  3005. }
  3006. }
  3007. /*
  3008. * GCCController::ProcessDisconnectProviderIndication ()
  3009. *
  3010. * Private Function Description
  3011. * This routine is called when the controller receives a Disconnect
  3012. * Provider Indication. All disconnect provider indications are
  3013. * initially directed to the controller. They may then be routed
  3014. * to a conference.
  3015. *
  3016. * Formal Parameters:
  3017. * connection_handle - (i) Logical connection that has been
  3018. * disconnected.
  3019. *
  3020. * Return Value
  3021. * MCS_NO_ERROR - Always return MCS no error so that the
  3022. * message wont be delivered again.
  3023. *
  3024. * Side Effects
  3025. * None
  3026. *
  3027. * Caveats
  3028. * None
  3029. */
  3030. GCCError GCCController::
  3031. ProcessDisconnectProviderIndication
  3032. (
  3033. ConnectionHandle connection_handle
  3034. )
  3035. {
  3036. GCCError error_value = GCC_NO_ERROR;
  3037. PConference lpConf;
  3038. m_ConfPollList.Reset();
  3039. while (NULL != (lpConf = m_ConfPollList.Iterate()))
  3040. {
  3041. error_value = lpConf->DisconnectProviderIndication (connection_handle);
  3042. /*
  3043. ** Once a conference deletes a connection handle there is no
  3044. ** need to continue in the iterator. Connection Handles
  3045. ** are specific to only one conference. We decided not to
  3046. ** keep a connection handle list in both the controller and
  3047. ** conference for resource reasons.
  3048. */
  3049. if (error_value == GCC_NO_ERROR)
  3050. break;
  3051. }
  3052. TRACE_OUT(("Controller::ProcessDisconnectProviderIndication: "
  3053. "Sending ConnectionBrokenIndication"));
  3054. g_pControlSap->ConnectionBrokenIndication(connection_handle);
  3055. return error_value;
  3056. }
  3057. // Utility functions used by the controller class
  3058. /*
  3059. * GCCController::AllocateConferenceID()
  3060. *
  3061. * Private Function Description
  3062. * This routine is used to generate a unique Conference ID.
  3063. *
  3064. * Formal Parameters:
  3065. * None
  3066. *
  3067. * Return Value
  3068. * The generated unique conference ID.
  3069. *
  3070. * Side Effects
  3071. * None
  3072. *
  3073. * Caveats
  3074. * None
  3075. */
  3076. GCCConfID GCCController::AllocateConferenceID(void)
  3077. {
  3078. /*
  3079. * This loop simply increments a rolling number, looking for the next
  3080. * one that is not already in use.
  3081. */
  3082. do
  3083. {
  3084. m_ConfIDCounter = ((m_ConfIDCounter + 1) % MAXIMUM_CONFERENCE_ID_VALUE) + MINIMUM_CONFERENCE_ID_VALUE;
  3085. }
  3086. while (NULL != m_ConfList2.Find(m_ConfIDCounter));
  3087. return m_ConfIDCounter;
  3088. }
  3089. /*
  3090. * GCCController::AllocateQueryID()
  3091. *
  3092. * Private Function Description
  3093. * This routine is used to generate a unique Query ID
  3094. *
  3095. * Formal Parameters:
  3096. * None
  3097. *
  3098. * Return Value
  3099. * The generated unique query ID.
  3100. *
  3101. * Side Effects
  3102. * None
  3103. *
  3104. * Caveats
  3105. * None
  3106. */
  3107. GCCConfID GCCController::AllocateQueryID()
  3108. {
  3109. GCCConfID test_query_id, nConfID;
  3110. /*
  3111. * This loop simply increments a rolling number, looking for the next
  3112. * one that is not already in use.
  3113. */
  3114. while (1)
  3115. {
  3116. m_QueryIDCounter = ((m_QueryIDCounter + 1) % MAXIMUM_QUERY_ID_VALUE) + MINIMUM_QUERY_ID_VALUE;
  3117. // If this handle is not in use, break from the loop and use it.
  3118. m_PendingQueryConfList2.Reset();
  3119. /*
  3120. ** Check the outstanding query request list to make sure that no
  3121. ** queries are using this ID.
  3122. */
  3123. test_query_id = 0;
  3124. while (GCC_INVALID_CID != (nConfID = m_PendingQueryConfList2.Iterate()))
  3125. {
  3126. if (nConfID == m_QueryIDCounter)
  3127. {
  3128. test_query_id = nConfID;
  3129. break;
  3130. }
  3131. }
  3132. // Break if the ID is not in use.
  3133. if (test_query_id == 0)
  3134. break;
  3135. }
  3136. return m_QueryIDCounter;
  3137. }
  3138. /*
  3139. * GCCController::GetConferenceIDFromName()
  3140. *
  3141. * Private Function Description
  3142. * This call returns the conference Id associated with a conference
  3143. * name and modifier.
  3144. *
  3145. * Formal Parameters:
  3146. * conference_name - (i) Pointer to conference name structure to
  3147. * search on.
  3148. * conference_modifier - (i) The conference name modifier to search on.
  3149. *
  3150. * Return Value
  3151. * The conference ID associated with the specified name.
  3152. * 0 if the name does not exists.
  3153. *
  3154. * Side Effects
  3155. * None
  3156. *
  3157. * Caveats
  3158. * We must iterate on the m_ConfList2 instead of the
  3159. * m_ConfPollList here to insure that the list is accurate. It
  3160. * is possible for the m_ConfList2 to change while the
  3161. * m_ConfPollList is being iterated on followed by something like
  3162. * a join request. If you don't use the m_ConfList2 here the name
  3163. * would still show up even after it had been terminated.
  3164. */
  3165. GCCConfID GCCController::GetConferenceIDFromName(
  3166. PGCCConferenceName conference_name,
  3167. GCCNumericString conference_modifier)
  3168. {
  3169. GCCConfID conference_id = 0;
  3170. LPSTR pszNumericName;
  3171. LPWSTR text_name_ptr;
  3172. LPSTR pszConfModifier;
  3173. PConference lpConf;
  3174. m_ConfList2.Reset();
  3175. while (NULL != (lpConf = m_ConfList2.Iterate()))
  3176. {
  3177. pszNumericName = lpConf->GetNumericConfName();
  3178. text_name_ptr = lpConf->GetTextConfName();
  3179. pszConfModifier = lpConf->GetConfModifier();
  3180. /*
  3181. ** First check the conference name. If both names are used we must
  3182. ** determine if there is a match on either name. If so the
  3183. ** conference is a match. We do this because having either correct
  3184. ** name will be interpreted as a match in a join request.
  3185. **
  3186. */
  3187. if ((conference_name->numeric_string != NULL) &&
  3188. (conference_name->text_string != NULL))
  3189. {
  3190. if (text_name_ptr != NULL)
  3191. {
  3192. if ((0 != lstrcmpA(pszNumericName, conference_name->numeric_string)) &&
  3193. (0 != My_strcmpW(text_name_ptr, conference_name->text_string)))
  3194. continue;
  3195. }
  3196. else
  3197. continue;
  3198. }
  3199. else if (conference_name->numeric_string != NULL)
  3200. {
  3201. if (0 != lstrcmpA(pszNumericName, conference_name->numeric_string))
  3202. continue;
  3203. }
  3204. else
  3205. {
  3206. if (text_name_ptr != NULL)
  3207. {
  3208. if (0 != My_strcmpW(text_name_ptr, conference_name->text_string))
  3209. continue;
  3210. }
  3211. else
  3212. {
  3213. TRACE_OUT(("GCCController: GetConferenceIDFromName: Text Conference Name is NULL: No Match"));
  3214. continue;
  3215. }
  3216. }
  3217. // Next check the conference modifier
  3218. TRACE_OUT(("GCCController: GetConferenceIDFromName: Before Modifier Check"));
  3219. if (conference_modifier != NULL)
  3220. {
  3221. if (pszConfModifier != NULL)
  3222. {
  3223. if (0 != lstrcmpA(pszConfModifier, conference_modifier))
  3224. {
  3225. TRACE_OUT(("GCCController: GetConferenceIDFromName: After Modifier Check"));
  3226. continue;
  3227. }
  3228. else
  3229. {
  3230. TRACE_OUT(("GCCController: GetConferenceIDFromName: Name match was found"));
  3231. }
  3232. }
  3233. else
  3234. {
  3235. TRACE_OUT(("GCCController: GetConferenceIDFromName: Conference Modifier is NULL: No Match"));
  3236. continue;
  3237. }
  3238. }
  3239. else if (pszConfModifier != NULL)
  3240. continue;
  3241. /*
  3242. ** If we get this far then we have found the correct conference.
  3243. ** Go ahead and get the conference id and then break out of the
  3244. ** search loop.
  3245. */
  3246. conference_id = lpConf->GetConfID();
  3247. break;
  3248. }
  3249. return (conference_id);
  3250. }
  3251. //
  3252. // Called from the SAP window procedure.
  3253. //
  3254. void GCCController::
  3255. WndMsgHandler ( UINT uMsg )
  3256. {
  3257. if (GCTRL_REBUILD_CONF_POLL_LIST == uMsg)
  3258. {
  3259. if (m_fConfListChangePending)
  3260. {
  3261. CConf *pConf;
  3262. m_fConfListChangePending = FALSE;
  3263. m_ConfPollList.Clear();
  3264. // Delete any outstanding conference objects
  3265. m_ConfDeleteList.DeleteList();
  3266. // Create a new conference poll list
  3267. m_ConfList2.Reset();
  3268. while (NULL != (pConf = m_ConfList2.Iterate()))
  3269. {
  3270. m_ConfPollList.Append(pConf);
  3271. }
  3272. }
  3273. //
  3274. // Flush any pending PDU.
  3275. //
  3276. FlushOutgoingPDU();
  3277. }
  3278. else
  3279. {
  3280. ERROR_OUT(("GCCController::WndMsgHandler: invalid msg=%u", uMsg));
  3281. }
  3282. }
  3283. //
  3284. // Rebuild the conf poll list in the next tick.
  3285. //
  3286. void GCCController::
  3287. PostMsgToRebuildConfPollList ( void )
  3288. {
  3289. if (NULL != g_pControlSap)
  3290. {
  3291. ::PostMessage(g_pControlSap->GetHwnd(), GCTRL_REBUILD_CONF_POLL_LIST, 0, (LPARAM) this);
  3292. }
  3293. else
  3294. {
  3295. ERROR_OUT(("GCCController::PostMsgToRebuildConfPollList: invalid control sap"));
  3296. }
  3297. }
  3298. //
  3299. // Enumerate all conferences and flush their pending outgoing PDUs to MCS.
  3300. //
  3301. BOOL GCCController::
  3302. FlushOutgoingPDU ( void )
  3303. {
  3304. BOOL fFlushMoreData = FALSE;
  3305. CConf *pConf;
  3306. m_ConfPollList.Reset();
  3307. while (NULL != (pConf = m_ConfPollList.Iterate()))
  3308. {
  3309. fFlushMoreData |= pConf->FlushOutgoingPDU();
  3310. }
  3311. return fFlushMoreData;
  3312. }
  3313. //
  3314. // Called from MCS work thread.
  3315. //
  3316. BOOL GCCRetryFlushOutgoingPDU ( void )
  3317. {
  3318. BOOL fFlushMoreData = FALSE;
  3319. //
  3320. // Normally, we should get to here because it is very rarely
  3321. // that there is a backlog in MCS SendData. We are using local memory.
  3322. // It will be interesting to note that we are having a backlog here.
  3323. //
  3324. TRACE_OUT(("GCCRetryFlushOutgoingPDU: ============"));
  3325. //
  3326. // We have to enter GCC critical section because
  3327. // we are called from MCS work thread.
  3328. //
  3329. ::EnterCriticalSection(&g_csGCCProvider);
  3330. if (NULL != g_pGCCController)
  3331. {
  3332. fFlushMoreData = g_pGCCController->FlushOutgoingPDU();
  3333. }
  3334. ::LeaveCriticalSection(&g_csGCCProvider);
  3335. return fFlushMoreData;
  3336. }