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.

342 lines
9.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. service.h
  5. Abstract:
  6. Common top-level definitions for Cluster Service.
  7. Author:
  8. Mike Massa (mikemas) 2-Jan-1996
  9. Revision History:
  10. --*/
  11. #ifndef _SERVICE_INCLUDED
  12. #define _SERVICE_INCLUDED
  13. #define UNICODE 1
  14. //#define CLUSTER_TESTPOINT
  15. #include <nt.h>
  16. #include <ntrtl.h>
  17. #include <nturtl.h>
  18. #include <windows.h>
  19. #include <cluster.h>
  20. #include <resapi.h>
  21. #include <stdlib.h>
  22. #include <wchar.h>
  23. #include <tstpoint.h>
  24. #include <clusverp.h>
  25. //
  26. // RPC protocols and endpoints used by the various RPC servers and clients
  27. //
  28. #define CLUSTER_RPC_PROTSEQ L"ncadg_cluster"
  29. #define CLUSTER_RPC_PORT L"2"
  30. #define CLUSTER_INTRACLUSTER_RPC_COM_TIMEOUT RPC_C_BINDING_DEFAULT_TIMEOUT
  31. #define CLUSTER_EXTROCLUSTER_RPC_COM_TIMEOUT RPC_C_BINDING_DEFAULT_TIMEOUT
  32. #define CLUSTER_JOINVERSION_RPC_COM_TIMEOUT RPC_C_BINDING_DEFAULT_TIMEOUT
  33. //
  34. // Component header files
  35. //
  36. #include "clusrpc.h"
  37. #include "ep.h"
  38. #include "init.h"
  39. #include "nm.h"
  40. #include "config.h"
  41. #include "om.h"
  42. #include "gum.h"
  43. #include "dm.h"
  44. #include "fm.h"
  45. #include "cp.h"
  46. #include "api.h"
  47. #include "logman.h"
  48. #include "mmapi.h"
  49. #include "clmsg.h"
  50. #include "cnetapi.h"
  51. #include "evtlog.h"
  52. //
  53. // Service Message IDs
  54. //
  55. #include "clusvmsg.h"
  56. //
  57. // Global Data
  58. //
  59. extern SERVICE_STATUS CsServiceStatus;
  60. extern PCLRTL_WORK_QUEUE CsDelayedWorkQueue;
  61. extern PCLRTL_WORK_QUEUE CsCriticalWorkQueue;
  62. extern LPWSTR CsClusterName;
  63. extern RPC_BINDING_VECTOR * CsRpcBindingVector;
  64. extern RPC_BINDING_HANDLE CsJoinSponsorBinding;
  65. extern DWORD CsClusterHighestVersion;
  66. extern DWORD CsClusterLowestVersion;
  67. extern DWORD CsClusterNodeLimit;
  68. extern DWORD CsMyHighestVersion;
  69. extern DWORD CsMyLowestVersion;
  70. extern SUITE_TYPE CsMyProductSuite;
  71. extern BOOL CsUseAuthenticatedRPC;
  72. extern LPWSTR CsServiceDomainAccount;
  73. extern DWORD CsRPCSecurityPackage[];
  74. extern LPWSTR CsRPCSecurityPackageName[];
  75. extern LONG CsRPCSecurityPackageIndex;
  76. extern DWORD CsNumberOfRPCSecurityPackages;
  77. //
  78. // Macros
  79. //
  80. #if NO_SHARED_LOCKS
  81. //assume the lock is a critical section
  82. #define INITIALIZE_LOCK(ResLock) \
  83. InitializeCriticalSection(&(ResLock))
  84. #define ACQUIRE_EXCLUSIVE_LOCK(ResLock) \
  85. EnterCriticalSection(&(ResLock))
  86. #define ACQUIRE_SHARED_LOCK(ResLock) \
  87. EnterCriticalSection(&(ResLock))
  88. #define RELEASE_LOCK(ResLock) \
  89. LeaveCriticalSection(&(ResLock))
  90. #define DELETE_LOCK(ResLock) \
  91. DeleteCriticalSection(&(ResLock))
  92. #else // NO_SHARED_LOCKS
  93. //assume the lock is a rtl resource
  94. #define INITIALIZE_LOCK(ResLock) \
  95. RtlInitializeResource(&(ResLock))
  96. #define ACQUIRE_EXCLUSIVE_LOCK(ResLock) \
  97. RtlAcquireResourceExclusive(&(ResLock), TRUE)
  98. #define ACQUIRE_SHARED_LOCK(ResLock) \
  99. RtlAcquireResourceShared(&(ResLock), TRUE)
  100. #define RELEASE_LOCK(ResLock) \
  101. RtlReleaseResource(&(ResLock))
  102. #define DELETE_LOCK(ResLock) \
  103. RtlDeleteResource(&(ResLock))
  104. #endif // NO_SHARED_LOCKS
  105. //
  106. // Cluster initialization
  107. //
  108. //
  109. // Service Control Routines
  110. //
  111. VOID
  112. CsAnnounceServiceStatus(
  113. VOID
  114. );
  115. VOID
  116. CsRunService(
  117. VOID
  118. );
  119. VOID
  120. CsStopService(
  121. VOID
  122. );
  123. DWORD
  124. ClusterRegisterIntraclusterRpcInterface(
  125. VOID
  126. );
  127. VOID
  128. CsInconsistencyHalt(
  129. IN DWORD Status
  130. );
  131. VOID CsGetClusterVersionInfo(
  132. IN PCLUSTERVERSIONINFO pClusterVersionInfo
  133. );
  134. DWORD
  135. WINAPI
  136. CsClusterControl(
  137. IN PNM_NODE HostNode OPTIONAL,
  138. IN DWORD ControlCode,
  139. IN PUCHAR InBuffer,
  140. IN DWORD InBufferSize,
  141. OUT PUCHAR OutBuffer,
  142. IN DWORD OutBufferSize,
  143. OUT LPDWORD BytesReturned,
  144. OUT LPDWORD Required
  145. );
  146. //
  147. // Debugging
  148. //
  149. #if DBG
  150. //
  151. // Global Debug Flags
  152. //
  153. extern ULONG CsDebugFlags;
  154. #define IF_DEBUG(arg) if ( CS_DBG_## arg & CsDebugFlags)
  155. #define CS_DBG_ALL 0xFFFFFFFF
  156. #define CS_DBG_ERROR 0x00000001
  157. #define CS_DBG_INIT 0x00000002
  158. #define CS_DBG_CLEANUP 0x00000004
  159. #else // DBG
  160. #define IF_DEBUG(arg) if (FALSE )
  161. #endif // DBG
  162. //
  163. // Helpful macros for logging cluster service events
  164. //
  165. #define CsLogEvent(_level_, _msgid_) \
  166. ClusterLogEvent0(_level_, \
  167. LOG_CURRENT_MODULE, \
  168. __FILE__, \
  169. __LINE__, \
  170. (_msgid_), \
  171. 0, \
  172. NULL)
  173. #define CsLogEvent1(_level_, _msgid_, _arg1_) \
  174. ClusterLogEvent1(_level_, \
  175. LOG_CURRENT_MODULE, \
  176. __FILE__, \
  177. __LINE__, \
  178. (_msgid_), \
  179. 0, \
  180. NULL, \
  181. (_arg1_))
  182. #define CsLogEvent2(_level_, _msgid_, _arg1_, _arg2_) \
  183. ClusterLogEvent2(_level_, \
  184. LOG_CURRENT_MODULE, \
  185. __FILE__, \
  186. __LINE__, \
  187. (_msgid_), \
  188. 0, \
  189. NULL, \
  190. (_arg1_), \
  191. (_arg2_))
  192. #define CsLogEvent3(_level_, _msgid_, _arg1_, _arg2_, _arg3_) \
  193. ClusterLogEvent3(_level_, \
  194. LOG_CURRENT_MODULE, \
  195. __FILE__, \
  196. __LINE__, \
  197. (_msgid_), \
  198. 0, \
  199. NULL, \
  200. (_arg1_), \
  201. (_arg2_), \
  202. (_arg3_))
  203. #define CsLogEventData(_level_, _msgid_, _dwBytes_, _pData_) \
  204. ClusterLogEvent0(_level_, \
  205. LOG_CURRENT_MODULE, \
  206. __FILE__, \
  207. __LINE__, \
  208. (_msgid_), \
  209. (_dwBytes_), \
  210. (_pData_))
  211. #define CsLogEventData1(_level_, _msgid_, _dwBytes_, _pData_, _arg1_) \
  212. ClusterLogEvent1(_level_, \
  213. LOG_CURRENT_MODULE, \
  214. __FILE__, \
  215. __LINE__, \
  216. (_msgid_), \
  217. (_dwBytes_), \
  218. (_pData_), \
  219. (_arg1_))
  220. #define CsLogEventData2(_level_, _msgid_, _dwBytes_, _pData_, _arg1_, _arg2_) \
  221. ClusterLogEvent2(_level_, \
  222. LOG_CURRENT_MODULE, \
  223. __FILE__, \
  224. __LINE__, \
  225. (_msgid_), \
  226. (_dwBytes_), \
  227. (_pData_), \
  228. (_arg1_), \
  229. (_arg2_))
  230. #define CsLogEventData3(_level_, _msgid_, _dwBytes_, _pData_, _arg1_, _arg2_, _arg3_) \
  231. ClusterLogEvent3(_level_, \
  232. LOG_CURRENT_MODULE, \
  233. __FILE__, \
  234. __LINE__, \
  235. (_msgid_), \
  236. (_dwBytes_), \
  237. (_pData_), \
  238. (_arg1_), \
  239. (_arg2_), \
  240. (_arg3_))
  241. extern BOOL CsDebugResmon;
  242. extern LPWSTR CsResmonDebugCmd;
  243. extern BOOL CsNoVersionCheck;
  244. extern BOOL CsUpgrade;
  245. extern BOOL CsFirstRun;
  246. extern BOOL CsNoQuorumLogging;
  247. extern BOOL CsUserTurnedOffQuorumLogging;
  248. extern BOOL CsNoQuorum;
  249. extern BOOL CsResetQuorumLog;
  250. extern BOOL CsForceQuorum;
  251. extern LPWSTR CsForceQuorumNodes;
  252. extern BOOL CsCommandLineForceQuorum;
  253. extern BOOL CsNoRepEvtLogging;
  254. extern BOOL CsDatabaseRestore;
  255. extern LPWSTR CsDatabaseRestorePath;
  256. extern BOOL CsForceDatabaseRestore;
  257. extern LPWSTR CsQuorumDriveLetter;
  258. extern BOOL CsRunningAsService;
  259. #ifdef CLUSTER_TESTPOINT
  260. //
  261. // Test Points
  262. //
  263. // Codes:
  264. // Init 1-99
  265. // NM 100-199
  266. //
  267. extern DWORD CsTestPoint;
  268. extern DWORD CsTestTrigger;
  269. extern DWORD CsTestAction;
  270. extern BOOL CsPersistentTestPoint;
  271. #define TESTPTMSG \
  272. CsDbgPrint(LOG_NOISE, ("Hit test point %1!u!\n", CsTestPoint));
  273. #define TESTPTCLEAR if (!CsPersistentTestPoint) (CsTestPoint = 0)
  274. #endif // CLUSTER_TESTPOINT
  275. #endif // SERVICE_INCLUDED
  276.