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.

350 lines
9.6 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. #include "qfs.h"
  26. //
  27. // RPC protocols and endpoints used by the various RPC servers and clients
  28. //
  29. #define CLUSTER_RPC_PROTSEQ L"ncadg_cluster"
  30. #define CLUSTER_RPC_PORT L"2"
  31. #define CLUSTER_INTRACLUSTER_RPC_COM_TIMEOUT RPC_C_BINDING_DEFAULT_TIMEOUT
  32. #define CLUSTER_EXTROCLUSTER_RPC_COM_TIMEOUT RPC_C_BINDING_DEFAULT_TIMEOUT
  33. #define CLUSTER_JOINVERSION_RPC_COM_TIMEOUT RPC_C_BINDING_DEFAULT_TIMEOUT
  34. //
  35. // Component header files
  36. //
  37. #include "clusrpc.h"
  38. #include "ep.h"
  39. #include "init.h"
  40. #include "nm.h"
  41. #include "config.h"
  42. #include "om.h"
  43. #include "gum.h"
  44. #include "dm.h"
  45. #include "fm.h"
  46. #include "cp.h"
  47. #include "api.h"
  48. #include "logman.h"
  49. #include "mmapi.h"
  50. #include "clmsg.h"
  51. #include "cnetapi.h"
  52. #include "evtlog.h"
  53. //
  54. // Service Message IDs
  55. //
  56. #include "clusvmsg.h"
  57. //
  58. // Global Data
  59. //
  60. extern SERVICE_STATUS CsServiceStatus;
  61. extern PCLRTL_WORK_QUEUE CsDelayedWorkQueue;
  62. extern PCLRTL_WORK_QUEUE CsCriticalWorkQueue;
  63. extern LPWSTR CsClusterName;
  64. extern RPC_BINDING_VECTOR * CsRpcBindingVector;
  65. extern RPC_BINDING_HANDLE CsJoinSponsorBinding;
  66. extern DWORD CsClusterHighestVersion;
  67. extern DWORD CsClusterLowestVersion;
  68. extern DWORD CsClusterNodeLimit;
  69. extern DWORD CsMyHighestVersion;
  70. extern DWORD CsMyLowestVersion;
  71. extern SUITE_TYPE CsMyProductSuite;
  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. VOID
  147. CsRefreshGlobalsFromRegistry(
  148. VOID
  149. );
  150. //
  151. // Debugging
  152. //
  153. #if DBG
  154. //
  155. // Global Debug Flags
  156. //
  157. extern ULONG CsDebugFlags;
  158. #define IF_DEBUG(arg) if ( CS_DBG_## arg & CsDebugFlags)
  159. #define CS_DBG_ALL 0xFFFFFFFF
  160. #define CS_DBG_ERROR 0x00000001
  161. #define CS_DBG_INIT 0x00000002
  162. #define CS_DBG_CLEANUP 0x00000004
  163. #else // DBG
  164. #define IF_DEBUG(arg) if (FALSE )
  165. #endif // DBG
  166. //
  167. // Helpful macros for logging cluster service events
  168. //
  169. #define CsLogEvent(_level_, _msgid_) \
  170. ClusterLogEvent0(_level_, \
  171. LOG_CURRENT_MODULE, \
  172. __FILE__, \
  173. __LINE__, \
  174. (_msgid_), \
  175. 0, \
  176. NULL)
  177. #define CsLogEvent1(_level_, _msgid_, _arg1_) \
  178. ClusterLogEvent1(_level_, \
  179. LOG_CURRENT_MODULE, \
  180. __FILE__, \
  181. __LINE__, \
  182. (_msgid_), \
  183. 0, \
  184. NULL, \
  185. (_arg1_))
  186. #define CsLogEvent2(_level_, _msgid_, _arg1_, _arg2_) \
  187. ClusterLogEvent2(_level_, \
  188. LOG_CURRENT_MODULE, \
  189. __FILE__, \
  190. __LINE__, \
  191. (_msgid_), \
  192. 0, \
  193. NULL, \
  194. (_arg1_), \
  195. (_arg2_))
  196. #define CsLogEvent3(_level_, _msgid_, _arg1_, _arg2_, _arg3_) \
  197. ClusterLogEvent3(_level_, \
  198. LOG_CURRENT_MODULE, \
  199. __FILE__, \
  200. __LINE__, \
  201. (_msgid_), \
  202. 0, \
  203. NULL, \
  204. (_arg1_), \
  205. (_arg2_), \
  206. (_arg3_))
  207. #define CsLogEventData(_level_, _msgid_, _dwBytes_, _pData_) \
  208. ClusterLogEvent0(_level_, \
  209. LOG_CURRENT_MODULE, \
  210. __FILE__, \
  211. __LINE__, \
  212. (_msgid_), \
  213. (_dwBytes_), \
  214. (_pData_))
  215. #define CsLogEventData1(_level_, _msgid_, _dwBytes_, _pData_, _arg1_) \
  216. ClusterLogEvent1(_level_, \
  217. LOG_CURRENT_MODULE, \
  218. __FILE__, \
  219. __LINE__, \
  220. (_msgid_), \
  221. (_dwBytes_), \
  222. (_pData_), \
  223. (_arg1_))
  224. #define CsLogEventData2(_level_, _msgid_, _dwBytes_, _pData_, _arg1_, _arg2_) \
  225. ClusterLogEvent2(_level_, \
  226. LOG_CURRENT_MODULE, \
  227. __FILE__, \
  228. __LINE__, \
  229. (_msgid_), \
  230. (_dwBytes_), \
  231. (_pData_), \
  232. (_arg1_), \
  233. (_arg2_))
  234. #define CsLogEventData3(_level_, _msgid_, _dwBytes_, _pData_, _arg1_, _arg2_, _arg3_) \
  235. ClusterLogEvent3(_level_, \
  236. LOG_CURRENT_MODULE, \
  237. __FILE__, \
  238. __LINE__, \
  239. (_msgid_), \
  240. (_dwBytes_), \
  241. (_pData_), \
  242. (_arg1_), \
  243. (_arg2_), \
  244. (_arg3_))
  245. extern BOOL CsDebugResmon;
  246. extern LPWSTR CsResmonDebugCmd;
  247. extern BOOL CsNoVersionCheck;
  248. extern BOOL CsUpgrade;
  249. extern BOOL CsFirstRun;
  250. extern BOOL CsNoQuorumLogging;
  251. extern BOOL CsUserTurnedOffQuorumLogging;
  252. extern BOOL CsNoQuorum;
  253. extern BOOL CsResetQuorumLog;
  254. extern BOOL CsForceQuorum;
  255. extern LPWSTR CsForceQuorumNodes;
  256. extern BOOL CsCommandLineForceQuorum;
  257. extern BOOL CsNoRepEvtLogging;
  258. extern BOOL CsDatabaseRestore;
  259. extern LPWSTR CsDatabaseRestorePath;
  260. extern BOOL CsForceDatabaseRestore;
  261. extern LPWSTR CsQuorumDriveLetter;
  262. extern BOOL CsRunningAsService;
  263. extern BOOL CsNoGroupInfoEvtLogging;
  264. #ifdef CLUSTER_TESTPOINT
  265. //
  266. // Test Points
  267. //
  268. // Codes:
  269. // Init 1-99
  270. // NM 100-199
  271. //
  272. extern DWORD CsTestPoint;
  273. extern DWORD CsTestTrigger;
  274. extern DWORD CsTestAction;
  275. extern BOOL CsPersistentTestPoint;
  276. #define TESTPTMSG \
  277. CsDbgPrint(LOG_NOISE, ("Hit test point %1!u!\n", CsTestPoint));
  278. #define TESTPTCLEAR if (!CsPersistentTestPoint) (CsTestPoint = 0)
  279. #endif // CLUSTER_TESTPOINT
  280. #endif // SERVICE_INCLUDED
  281.