Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

505 lines
13 KiB

  1. //*************************************************************
  2. //
  3. // File name: TGcc.c
  4. //
  5. // Description: Contains routines to provide
  6. // Tiny GCC support
  7. //
  8. // Microsoft Confidential
  9. // Copyright (c) Microsoft Corporation 1991-1997
  10. // All rights reserved
  11. //
  12. //*************************************************************
  13. #define _TGCC_ALLOC_DATA_
  14. #include <_tgcc.h>
  15. #include <stdio.h>
  16. #include <mcs.h>
  17. //*************************************************************
  18. //
  19. // gccMapMcsError()
  20. //
  21. // Purpose: Provides MCSError to GCCError mapping
  22. //
  23. // Parameters: IN [mcsError] -- MCSError
  24. //
  25. // Return: GCCError
  26. //
  27. // History: 08-10-97 BrianTa Created
  28. //
  29. //*************************************************************
  30. GCCError
  31. gccMapMcsError(IN MCSError mcsError)
  32. {
  33. int i;
  34. GCCError gccError;
  35. gccError = GCC_UNSUPPORTED_ERROR;
  36. for (i=0; i<sizeof(GccMcsErrorTBL) / sizeof(GccMcsErrorTBL[0]); i++)
  37. {
  38. if (GccMcsErrorTBL[i].mcsError == mcsError)
  39. {
  40. gccError = GccMcsErrorTBL[i].gccError;
  41. break;
  42. }
  43. }
  44. #if DBG
  45. if (i < sizeof(GccMcsErrorTBL) / sizeof(GccMcsErrorTBL[0]))
  46. {
  47. TRACE((DEBUG_GCC_DBDEBUG,
  48. "GCC: gccMapMcsError: mcsError 0x%x (%s), gbbError 0x%x (%s)\n",
  49. mcsError, GccMcsErrorTBL[i].pszMcsMessageText,
  50. gccError, GccMcsErrorTBL[i].pszGccMessageText));
  51. }
  52. else
  53. {
  54. TRACE((DEBUG_GCC_DBDEBUG,
  55. "GCC: gccMapMcsError: mcsError 0x%x (UNKNOWN)\n",
  56. mcsError));
  57. }
  58. #endif
  59. return (gccError);
  60. }
  61. //*************************************************************
  62. //
  63. // gccInitialized()
  64. //
  65. // Purpose: Sets GCC initialized state
  66. //
  67. // Parameters: IN [fInitialized] -- State (T/F)
  68. //
  69. // Return: void
  70. //
  71. // History: 08-10-97 BrianTa Created
  72. //
  73. //*************************************************************
  74. void
  75. gccInitialized(IN BOOL fInitialized)
  76. {
  77. g_fInitialized = fInitialized;
  78. }
  79. //*************************************************************
  80. //
  81. // gccIsInitialized()
  82. //
  83. // Purpose: Returns GCC initialized state
  84. //
  85. // Parameters: OUT [gccError] -- Ptr to return error to
  86. //
  87. // Return: TRUE - if initialized
  88. // FALSE - if not initialized
  89. //
  90. // History: 08-10-97 BrianTa Created
  91. //
  92. //*************************************************************
  93. BOOL
  94. gccIsInitialized(OUT GCCError *pgccError)
  95. {
  96. *pgccError = (g_fInitialized ? GCC_ALREADY_INITIALIZED
  97. : GCC_NOT_INITIALIZED);
  98. return (g_fInitialized);
  99. }
  100. //*************************************************************
  101. //
  102. // GCCRegisterNodeControllerApplication()
  103. //
  104. // Purpose: Performs GCC NC registration
  105. //
  106. // Parameters: Too many - read the code <g>
  107. //
  108. // Return: GCCError
  109. //
  110. // History: 08-10-97 BrianTa Created
  111. //
  112. //*************************************************************
  113. GCCError
  114. APIENTRY
  115. GCCRegisterNodeControllerApplication(
  116. GCCCallBack control_sap_callback,
  117. void FAR * user_defined,
  118. GCCVersion gcc_version_requested,
  119. unsigned short FAR * initialization_flags,
  120. unsigned long FAR * application_id,
  121. unsigned short FAR * capabilities_mask,
  122. GCCVersion FAR * gcc_high_version,
  123. GCCVersion FAR * gcc_version)
  124. {
  125. MCSError mcsError;
  126. GCCError gccError;
  127. TRACE((DEBUG_GCC_DBFLOW,
  128. "GCC: GCCRegisterNodeControllerApplication entry\n"));
  129. if (!gccIsInitialized(&gccError))
  130. {
  131. if (gcc_version_requested.major_version == GCC_MAJOR_VERSION &&
  132. gcc_version_requested.minor_version == GCC_MINOR_VERSION)
  133. {
  134. TS_ASSERT(application_id);
  135. gcc_version->major_version = GCC_MAJOR_VERSION;
  136. gcc_version->minor_version = GCC_MINOR_VERSION;
  137. gcc_high_version->major_version = GCC_MAJOR_VERSION;
  138. gcc_high_version->minor_version = GCC_MINOR_VERSION;
  139. gccSetCallback(control_sap_callback);
  140. TRACE((DEBUG_GCC_DBDEBUG,
  141. "GCC: Calling MCSInitialize - callback 0x%x\n",
  142. mcsCallback));
  143. mcsError = MCSInitialize(mcsCallback);
  144. gccDumpMCSErrorDetails(mcsError,
  145. "MCSInitialize");
  146. gccError = gccMapMcsError(mcsError);
  147. if (gccError == GCC_NO_ERROR)
  148. gccInitialized(TRUE);
  149. *application_id = (g_fInitialized ? 1 : 0);
  150. }
  151. else
  152. {
  153. TRACE((DEBUG_GCC_DBERROR,
  154. "GCC: Invalid GCC version requested\n"));
  155. gccError = GCC_INVALID_PARAMETER;
  156. }
  157. }
  158. TRACE((DEBUG_GCC_DBFLOW,
  159. "GCC: GCCRegisterNodeControllerApplication exit - 0x%x\n",
  160. gccError));
  161. return (gccError);
  162. }
  163. //*************************************************************
  164. //
  165. // GCCCleanup()
  166. //
  167. // Purpose: Performs GCC cleanup processing
  168. //
  169. // Parameters: application_id
  170. //
  171. // Return: GCCError
  172. //
  173. // History: 08-10-97 BrianTa Created
  174. //
  175. //*************************************************************
  176. GCCError
  177. APIENTRY
  178. GCCCleanup(ULONG application_id)
  179. {
  180. MCSError mcsError;
  181. GCCError gccError;
  182. TRACE((DEBUG_GCC_DBFLOW,
  183. "GCC: GCCCleanup entry\n"));
  184. if (gccIsInitialized(&gccError))
  185. {
  186. TS_ASSERT(application_id > 0);
  187. TRACE((DEBUG_GCC_DBDEBUG,
  188. "GCC: Calling MCSCleanup - no args\n"));
  189. mcsError = MCSCleanup();
  190. gccDumpMCSErrorDetails(mcsError,
  191. "MCSCleanup");
  192. gccError = gccMapMcsError(mcsError);
  193. }
  194. TRACE((DEBUG_GCC_DBFLOW,
  195. "GCC: GCCCleanup exit - 0x%x\n",
  196. gccError));
  197. return (gccError);
  198. }
  199. //*************************************************************
  200. //
  201. // GCCConferenceInit()
  202. //
  203. // Purpose: Initializes the conference
  204. //
  205. // Parameters: application_id
  206. //
  207. // Return: GCCError
  208. //
  209. // History: 08-10-97 BrianTa Created
  210. //
  211. //*************************************************************
  212. GCCError
  213. APIENTRY
  214. GCCConferenceInit(HANDLE hIca,
  215. HANDLE hStack,
  216. PVOID pvContext,
  217. DomainHandle *phDomain)
  218. {
  219. MCSError mcsError;
  220. GCCError gccError;
  221. TRACE((DEBUG_GCC_DBFLOW,
  222. "GCC: GCCConferenceInit entry\n"));
  223. if (gccIsInitialized(&gccError))
  224. {
  225. TS_ASSERT(hIca);
  226. TS_ASSERT(hStack);
  227. TS_ASSERT(pvContext);
  228. TS_ASSERT(phDomain);
  229. TRACE((DEBUG_GCC_DBDEBUG,
  230. "GCC: Calling MCSCreateDomain - hIca 0x%x, hStack 0x%x, "
  231. "pvContext 0x%x, phDomain 0x%x\n",
  232. hIca, hStack, pvContext, phDomain));
  233. mcsError = MCSCreateDomain(hIca, hStack, pvContext, phDomain);
  234. gccDumpMCSErrorDetails(mcsError,
  235. "MCSCreateDomain");
  236. TRACE((DEBUG_GCC_DBDEBUG,
  237. "GCC: MCSCreateDomain: domain 0x%x\n",
  238. *phDomain));
  239. gccError = gccMapMcsError(mcsError);
  240. }
  241. TRACE((DEBUG_GCC_DBFLOW,
  242. "GCC: GCCConferenceInit exit - 0x%x\n",
  243. gccError));
  244. return (gccError);
  245. }
  246. //*************************************************************
  247. //
  248. // GCCConferenceCreateResponse()
  249. //
  250. // Purpose: Performs conference creation
  251. //
  252. // Parameters: application_id
  253. //
  254. // Return: GCCError
  255. //
  256. // History: 08-10-97 BrianTa Created
  257. //
  258. //*************************************************************
  259. GCCError
  260. APIENTRY
  261. GCCConferenceCreateResponse(GCCNumericString conference_modifier,
  262. DomainHandle hDomain,
  263. T120Boolean use_password_in_the_clear,
  264. DomainParameters *domain_parameters,
  265. USHORT number_of_network_addresses,
  266. GCCNetworkAddress **local_network_address_list,
  267. USHORT number_of_user_data_members,
  268. GCCUserData **user_data_list,
  269. GCCResult result)
  270. {
  271. MCSError mcsError;
  272. GCCError gccError;
  273. PBYTE pUserData;
  274. UINT UserDataLength;
  275. TRACE((DEBUG_GCC_DBFLOW,
  276. "GCC: GCCConferenceCreateResponse entry\n"));
  277. if (gccIsInitialized(&gccError))
  278. {
  279. mcsError = gccEncodeUserData(number_of_user_data_members,
  280. user_data_list,
  281. &pUserData,
  282. &UserDataLength);
  283. if (mcsError == MCS_NO_ERROR)
  284. {
  285. TRACE((DEBUG_GCC_DBDEBUG,
  286. "GCC: Calling MCSConnectProviderResponse - hDomain 0x%x, result 0x%x, "
  287. "pUserData 0x%x, UserDataLength 0x%x\n",
  288. hDomain, result, pUserData, UserDataLength));
  289. TS_ASSERT(hDomain);
  290. mcsError = MCSConnectProviderResponse(hDomain, result, pUserData, UserDataLength);
  291. gccDumpMCSErrorDetails(mcsError,
  292. "MCSConnectProviderResponse");
  293. if (pUserData)
  294. TShareFree(pUserData);
  295. }
  296. gccError = gccMapMcsError(mcsError);
  297. }
  298. TRACE((DEBUG_GCC_DBFLOW,
  299. "GCC: GCCConferenceCreateResponse exit - 0x%x\n",
  300. gccError));
  301. return (gccError);
  302. }
  303. //*************************************************************
  304. //
  305. // GCCConferenceTerminateRequest()
  306. //
  307. // Purpose: Performs conference termination
  308. //
  309. // Parameters: application_id
  310. //
  311. // Return: GCCError
  312. //
  313. // History: 08-10-97 BrianTa Created
  314. //
  315. //*************************************************************
  316. GCCError
  317. APIENTRY
  318. GCCConferenceTerminateRequest(HANDLE hIca,
  319. DomainHandle hDomain,
  320. ConnectionHandle hConnection,
  321. GCCReason reason)
  322. {
  323. MCSError mcsError;
  324. GCCError gccError;
  325. MCSReason mcsReason;
  326. TRACE((DEBUG_GCC_DBFLOW,
  327. "GCC: GCCConferenceTerminateRequest entry\n"));
  328. if (gccIsInitialized(&gccError))
  329. {
  330. switch (reason)
  331. {
  332. case GCC_REASON_SERVER_INITIATED:
  333. mcsReason = REASON_PROVIDER_INITIATED;
  334. break;
  335. case GCC_REASON_USER_INITIATED:
  336. mcsReason = REASON_USER_REQUESTED;
  337. break;
  338. case GCC_REASON_UNKNOWN:
  339. mcsReason = REASON_PROVIDER_INITIATED;
  340. break;
  341. case GCC_REASON_ERROR_TERMINATION:
  342. mcsReason = REASON_PROVIDER_INITIATED;
  343. break;
  344. default:
  345. ASSERT(0);
  346. mcsReason = REASON_PROVIDER_INITIATED;
  347. break;
  348. }
  349. mcsError = MCS_NO_ERROR;
  350. if (hConnection)
  351. {
  352. TRACE((DEBUG_GCC_DBDEBUG,
  353. "GCC: Calling MCSDisconnectProviderRequest - "
  354. "hConnection 0x%x, mcsReason 0x%x\n",
  355. hConnection, mcsReason));
  356. mcsError = MCSDisconnectProviderRequest(hIca, hConnection, mcsReason);
  357. gccDumpMCSErrorDetails(mcsError,
  358. "GCCConferenceTerminateRequest");
  359. }
  360. if (hDomain)
  361. {
  362. mcsError = MCSDeleteDomain(hIca, hDomain, reason);
  363. gccDumpMCSErrorDetails(mcsError,
  364. "MCSDeleteDomain");
  365. }
  366. gccError = gccMapMcsError(mcsError);
  367. }
  368. TRACE((DEBUG_GCC_DBFLOW,
  369. "GCC: GCCConferenceTerminateRequest exit - 0x%x\n",
  370. gccError));
  371. return (gccError);
  372. }
  373. #if DBG
  374. //*************************************************************
  375. //
  376. // gccDumpMCSErrorDetails()
  377. //
  378. // Purpose: Dumps out MCSError details
  379. //
  380. // Parameters: IN [mcsError] - MCS return code
  381. // IN [PrintLevel] - Print level
  382. // IN [pszText] - var text
  383. //
  384. // Return: void
  385. //
  386. // History: 07-17-97 BrianTa Created
  387. //
  388. //*************************************************************
  389. void
  390. gccDumpMCSErrorDetails(IN MCSError mcsError,
  391. IN PCHAR pszText)
  392. {
  393. int i;
  394. PCHAR pszMessageText;
  395. pszMessageText = "UNKNOWN_MCS_ERROR";
  396. for (i=0; i<sizeof(GccMcsErrorTBL) / sizeof(GccMcsErrorTBL[0]); i++)
  397. {
  398. if (GccMcsErrorTBL[i].mcsError == mcsError)
  399. {
  400. pszMessageText = GccMcsErrorTBL[i].pszMcsMessageText;
  401. break;
  402. }
  403. }
  404. TRACE((DEBUG_GCC_DBDEBUG,
  405. "GCC: %s - MCSError 0x%x (%s)\n",
  406. pszText, mcsError, pszMessageText));
  407. }
  408. #endif