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.

244 lines
7.9 KiB

  1. #ifndef WLBSCONTROL_H
  2. #define WLBSCONTROL_H
  3. #include "cluster.h"
  4. class CWlbsCluster;
  5. //+----------------------------------------------------------------------------
  6. //
  7. // class CWlbsControl
  8. //
  9. // Description: This class is exported to perform cluster control operation,
  10. // as well as get Cluster objects
  11. //
  12. //
  13. // History: fengsun Created Header 3/2/00
  14. //
  15. //+----------------------------------------------------------------------------
  16. class __declspec(dllexport) CWlbsControl
  17. {
  18. friend DWORD WINAPI WlbsCommitChanges(DWORD cluster);
  19. public:
  20. CWlbsControl();
  21. ~CWlbsControl();
  22. DWORD Initialize();
  23. bool ReInitialize();
  24. //
  25. // ChrisDar 2002-01-10
  26. //
  27. // Though this is a public method it is intended to be called internally.
  28. // External use of query should go through the WlbsQuery method that
  29. // takes a DWORD for the cluster argument.
  30. //
  31. DWORD WlbsQuery(CWlbsCluster* pCluster,
  32. DWORD host,
  33. PWLBS_RESPONSE response,
  34. PDWORD num_hosts,
  35. PDWORD host_map,
  36. PFN_QUERY_CALLBACK pfnQueryCallBack);
  37. DWORD WlbsQuery(DWORD cluster,
  38. DWORD host,
  39. PWLBS_RESPONSE response,
  40. PDWORD num_hosts,
  41. PDWORD host_map,
  42. PFN_QUERY_CALLBACK pfnQueryCallBack);
  43. DWORD WlbsQueryState
  44. (
  45. DWORD cluster,
  46. DWORD host,
  47. DWORD operation,
  48. PNLB_OPTIONS pOptions,
  49. PWLBS_RESPONSE pResponse,
  50. PDWORD pcResponses
  51. );
  52. DWORD WlbsSuspend(DWORD cluster,
  53. DWORD host,
  54. PWLBS_RESPONSE response,
  55. PDWORD num_hosts);
  56. DWORD WlbsResume(DWORD cluster,
  57. DWORD host,
  58. PWLBS_RESPONSE response,
  59. PDWORD num_hosts);
  60. DWORD WlbsStart(DWORD cluster,
  61. DWORD host,
  62. PWLBS_RESPONSE response,
  63. PDWORD num_hosts);
  64. DWORD WlbsStop(DWORD cluster,
  65. DWORD host,
  66. PWLBS_RESPONSE response,
  67. PDWORD num_hosts);
  68. DWORD WlbsDrainStop(DWORD cluster,
  69. DWORD host,
  70. PWLBS_RESPONSE response,
  71. PDWORD num_hosts);
  72. DWORD WlbsEnable(DWORD cluster,
  73. DWORD host,
  74. PWLBS_RESPONSE response,
  75. PDWORD num_hosts,
  76. DWORD vip,
  77. DWORD port);
  78. DWORD WlbsDisable(DWORD cluster,
  79. DWORD host,
  80. PWLBS_RESPONSE response,
  81. PDWORD num_hosts,
  82. DWORD vip,
  83. DWORD port);
  84. DWORD WlbsDrain(DWORD cluster,
  85. DWORD host,
  86. PWLBS_RESPONSE response,
  87. PDWORD num_hosts,
  88. DWORD vip,
  89. DWORD port);
  90. //
  91. // Set remote control parameters
  92. //
  93. void WlbsPortSet(DWORD cluster, WORD port);
  94. void WlbsPasswordSet(DWORD cluster, const WCHAR* password);
  95. void WlbsCodeSet(DWORD cluster, DWORD passw);
  96. void WlbsDestinationSet(DWORD cluster, DWORD dest);
  97. void WlbsTimeoutSet(DWORD cluster, DWORD milliseconds);
  98. DWORD EnumClusters(OUT DWORD* pdwAddresses, IN OUT DWORD* pdwNum); // for API wrapper
  99. DWORD GetClusterNum() { return m_dwNumCluster;}
  100. DWORD EnumClusterObjects(OUT CWlbsCluster** &ppClusters, OUT DWORD* pdwNum);
  101. CWlbsCluster* GetClusterFromIp(DWORD dwClusterIp);
  102. CWlbsCluster* GetClusterFromIpOrIndex(DWORD dwClusterIpOrIndex);
  103. HANDLE GetDriverHandle() {return m_hdl;}
  104. //
  105. // GetClusterFromAdapter looks up an adapter based on its GUID.
  106. //
  107. CWlbsCluster*
  108. GetClusterFromAdapter(
  109. IN const GUID &AdapterGuid
  110. );
  111. //
  112. // ValidateParam validates and fixes up the specified parameters structure. It has no side effects other than changing some
  113. // fields within paramp, such as IP addresses which may be reformatted into canonical form.
  114. //
  115. BOOL
  116. ValidateParam(
  117. IN OUT PWLBS_REG_PARAMS paramp
  118. );
  119. //
  120. // Performs local cluster-wide control operations on the specified GUID.
  121. //
  122. /* OBSOLETE
  123. DWORD LocalClusterControl(
  124. IN const GUID& AdapterGuid,
  125. IN LONG ioctl
  126. );
  127. */
  128. BOOLEAN IsClusterMember (DWORD dwClusterIp);
  129. protected:
  130. struct WLBS_CLUSTER_PARAMS
  131. {
  132. DWORD cluster;
  133. DWORD passw;
  134. DWORD timeout;
  135. DWORD dest;
  136. WORD port;
  137. WORD valid;
  138. };
  139. enum { WLBS_MAX_CLUSTERS = 128};
  140. WLBS_CLUSTER_PARAMS m_cluster_params [WLBS_MAX_CLUSTERS]; // Cluster settings for remote control
  141. BOOL m_init_once; // whether WlbsInit is called
  142. BOOL m_remote_ctrl; // Whether remote operation can be performed on this machine
  143. BOOL m_local_ctrl; // Whether local operation can be performed on this machine
  144. HANDLE m_hdl; // handle to the device object
  145. // HANDLE lock; // An mutex
  146. DWORD m_def_dst_addr; // Default destination address for all clusters, set by WlbsDestinationSet
  147. DWORD m_def_timeout;// Time out value for remote control
  148. WORD m_def_port; // UDP port for remote control
  149. DWORD m_def_passw; // Default password for remote control
  150. HANDLE m_registry_lock; // used for mutually exclusive access to the registry, should use named lock
  151. DWORD m_dwNumCluster; // number of clusters on this host
  152. CWlbsCluster* m_pClusterArray[WLBS_MAX_CLUSTERS]; // an array of all clusters
  153. DWORD GetInitResult()
  154. {
  155. if (m_local_ctrl && m_remote_ctrl)
  156. return WLBS_PRESENT;
  157. if (m_local_ctrl)
  158. return WLBS_LOCAL_ONLY;
  159. else if (m_remote_ctrl)
  160. return WLBS_REMOTE_ONLY;
  161. else
  162. return WLBS_INIT_ERROR;
  163. };
  164. bool IsInitialized() const {return m_hdl != INVALID_HANDLE_VALUE;}
  165. DWORD RemoteQuery(DWORD cluster,
  166. DWORD host,
  167. PWLBS_RESPONSE response,
  168. PDWORD num_hosts,
  169. PDWORD host_map,
  170. PFN_QUERY_CALLBACK pfnQueryCallBack);
  171. DWORD WlbsRemoteControl(LONG ioctl,
  172. PIOCTL_CVY_BUF pin_bufp,
  173. PIOCTL_CVY_BUF pout_bufp,
  174. PWLBS_RESPONSE pcvy_resp,
  175. PDWORD nump,
  176. DWORD trg_addr,
  177. DWORD hst_addr,
  178. PIOCTL_REMOTE_OPTIONS optionsp,
  179. PFN_QUERY_CALLBACK pfnQueryCallBack);
  180. DWORD WlbsQueryLocalState
  181. (
  182. CWlbsCluster * pCluster,
  183. DWORD operation,
  184. PNLB_OPTIONS pOptions,
  185. PWLBS_RESPONSE pResponse,
  186. PDWORD pcResponses
  187. );
  188. DWORD WlbsQueryRemoteState
  189. (
  190. DWORD cluster,
  191. DWORD host,
  192. DWORD operation,
  193. PNLB_OPTIONS pOptions,
  194. PWLBS_RESPONSE pResponse,
  195. PDWORD pcResponses
  196. );
  197. };
  198. DWORD WlbsLocalControl(HANDLE hDevice, const GUID& AdapterGuid,
  199. LONG ioctl, PIOCTL_CVY_BUF in_bufp,
  200. PIOCTL_CVY_BUF out_bufp, PIOCTL_LOCAL_OPTIONS optionsp);
  201. DWORD WINAPI WlbsLocalControlWrapper(HANDLE hdl,
  202. const GUID& AdapterGuid,
  203. LONG ioctl);
  204. #endif