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.

250 lines
6.8 KiB

  1. //*************************************************************
  2. //
  3. // File name: TGccCB.c
  4. //
  5. // Description: Contains routines to support GCC
  6. // mcs callback processing
  7. //
  8. // Microsoft Confidential
  9. // Copyright (c) Microsoft Corporation 1991-1997
  10. // All rights reserved
  11. //
  12. //*************************************************************
  13. #include <_tgcc.h>
  14. #include <stdio.h>
  15. // Data declarations
  16. GCCCallBack g_GCCCallBack = NULL;
  17. //*************************************************************
  18. //
  19. // gccSetCallback()
  20. //
  21. // Purpose: Sets GCC callback address
  22. //
  23. // Parameters: IN [control_sap_callback]
  24. //
  25. // Return: void
  26. //
  27. // History: 08-10-97 BrianTa Created
  28. //
  29. //*************************************************************
  30. void
  31. gccSetCallback(IN GCCCallBack control_sap_callback)
  32. {
  33. TS_ASSERT(control_sap_callback);
  34. g_GCCCallBack = control_sap_callback;
  35. }
  36. //*************************************************************
  37. //
  38. // gccConnectProviderIndication()
  39. //
  40. // Purpose: GCC_CREATE_INDICATION processing
  41. //
  42. // Parameters: IN [pcpi] -- ConnectProviderIndication
  43. // IN [pvContext] -- Context
  44. //
  45. // Return: void
  46. //
  47. // History: 08-10-97 BrianTa Created
  48. //
  49. //*************************************************************
  50. MCSError
  51. gccConnectProviderIndication(IN PConnectProviderIndication pcpi,
  52. IN PVOID pvContext)
  53. {
  54. MCSError mcsError;
  55. GCCMessage gccMessage;
  56. CreateIndicationMessage *pCreateInd;
  57. GCCUserData *pUserData;
  58. GCCUserData UserData;
  59. USHORT usMembers;
  60. TRACE((DEBUG_GCC_DBFLOW,
  61. "GCC: gccConnectProviderIndication entry "
  62. "(MCS userDataLength = 0x%x)\n",
  63. pcpi->UserDataLength));
  64. pUserData = &UserData;
  65. mcsError = gccDecodeUserData(pcpi->pUserData, pcpi->UserDataLength, pUserData);
  66. if (mcsError == MCS_NO_ERROR)
  67. {
  68. ZeroMemory(&gccMessage, sizeof(gccMessage));
  69. gccMessage.message_type = GCC_CREATE_INDICATION;
  70. gccMessage.user_defined = pvContext;
  71. pCreateInd = &gccMessage.u.create_indication;
  72. pCreateInd->domain_parameters = &pcpi->DomainParams;
  73. pCreateInd->connection_handle = pcpi->hConnection;
  74. pCreateInd->number_of_user_data_members = 1;
  75. pCreateInd->user_data_list = &pUserData;
  76. TRACE((DEBUG_GCC_DBNORMAL,
  77. "GCC: Performing GCC_CREATE_INDICATION callout\n"));
  78. g_GCCCallBack(&gccMessage);
  79. TRACE((DEBUG_GCC_DBNORMAL,
  80. "GCC: Returned from GCC_CREATE_INDICATION callout\n"));
  81. gccFreeUserData(pUserData);
  82. }
  83. TRACE((DEBUG_GCC_DBFLOW,
  84. "GCC: gccConnectProviderIndication exit - 0x%x\n",
  85. mcsError));
  86. return (mcsError);
  87. }
  88. //*************************************************************
  89. //
  90. // gccDisconnectProviderIndication()
  91. //
  92. // Purpose: GCC_DISCONNECT_INDICATION processing
  93. //
  94. // Parameters: IN [pcpi] -- DisconnectProviderIndication
  95. // IN [pvContext] -- Context
  96. //
  97. // Return: void
  98. //
  99. // History: 08-10-97 BrianTa Created
  100. //
  101. //*************************************************************
  102. MCSError
  103. gccDisconnectProviderIndication(IN PDisconnectProviderIndication pdpi,
  104. IN PVOID pvContext)
  105. {
  106. GCCMessage gccMessage;
  107. DisconnectIndicationMessage *pDiscInd;
  108. TerminateIndicationMessage *pTermInd;
  109. TRACE((DEBUG_GCC_DBFLOW,
  110. "GCC: gccDisconnectProviderIndication entry\n"));
  111. // Handle GCC_DISCONNECT_INDICATION
  112. ZeroMemory(&gccMessage, sizeof(gccMessage));
  113. gccMessage.message_type = GCC_DISCONNECT_INDICATION;
  114. gccMessage.user_defined = pvContext;
  115. pDiscInd = &gccMessage.u.disconnect_indication;
  116. pDiscInd->reason = pdpi->Reason;
  117. TRACE((DEBUG_GCC_DBNORMAL,
  118. "GCC: Performing GCC_DISCONNECT_INDICATION callout\n"));
  119. g_GCCCallBack(&gccMessage);
  120. TRACE((DEBUG_GCC_DBNORMAL,
  121. "GCC: Returned from GCC_DISCONNECT_INDICATION callout\n"));
  122. // Handle GCC_TERMINATE_INDICATION
  123. ZeroMemory(&gccMessage, sizeof(gccMessage));
  124. gccMessage.message_type = GCC_TERMINATE_INDICATION;
  125. gccMessage.user_defined = pvContext;
  126. pTermInd = &gccMessage.u.terminate_indication;
  127. pTermInd->reason = pdpi->Reason;
  128. TRACE((DEBUG_GCC_DBNORMAL,
  129. "GCC: Performing GCC_TERMINATE_INDICATION callout\n"));
  130. g_GCCCallBack(&gccMessage);
  131. TRACE((DEBUG_GCC_DBNORMAL,
  132. "GCC: Returned from GCC_TERMINATE_INDICATION callout\n"));
  133. TRACE((DEBUG_GCC_DBFLOW,
  134. "GCC: gccDisconnectProviderIndication exit - 0x%x\n",
  135. MCS_NO_ERROR));
  136. return (MCS_NO_ERROR);
  137. }
  138. //*************************************************************
  139. //
  140. // mcsCallback()
  141. //
  142. // Purpose: MCS node controller callback dispatch processing
  143. //
  144. // Parameters: IN [hDomain] -- Domain handle for the callback
  145. // IN [Message] -- Callback message
  146. // IN [pvParam] -- Param
  147. // IN [pvContext] -- Context
  148. //
  149. // Return: MCSError
  150. //
  151. // History: 08-10-97 BrianTa Created
  152. //
  153. //*************************************************************
  154. MCSError
  155. mcsCallback(DomainHandle hDomain,
  156. UINT Message,
  157. PVOID pvParam,
  158. PVOID pvContext)
  159. {
  160. MCSError mcsError;
  161. TRACE((DEBUG_GCC_DBFLOW,
  162. "GCC: mcsCallback entry\n"));
  163. TRACE((DEBUG_GCC_DBDEBUG,
  164. "GCC: Message 0x%x, pvParam 0x%x, pvContext 0x%x\n",
  165. Message, pvParam, pvContext));
  166. switch (Message)
  167. {
  168. case MCS_CONNECT_PROVIDER_INDICATION:
  169. mcsError = gccConnectProviderIndication(
  170. (PConnectProviderIndication) pvParam,
  171. pvContext);
  172. break;
  173. case MCS_DISCONNECT_PROVIDER_INDICATION:
  174. mcsError = gccDisconnectProviderIndication(
  175. (PDisconnectProviderIndication) pvParam,
  176. pvContext);
  177. break;
  178. default:
  179. mcsError = MCS_COMMAND_NOT_SUPPORTED;
  180. TRACE((DEBUG_GCC_DBWARN,
  181. "GCC: mcsCallback: Unknown Message 0x%x\n",
  182. Message));
  183. break;
  184. }
  185. TRACE((DEBUG_GCC_DBFLOW,
  186. "GCC: mcsCallback exit - 0x%x\n",
  187. mcsError));
  188. return (mcsError);
  189. }