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.

211 lines
6.5 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. DWORD WlbsQuery(CWlbsCluster* pCluster,
  25. DWORD host,
  26. PWLBS_RESPONSE response,
  27. PDWORD num_hosts,
  28. PDWORD host_map,
  29. PVOID reserved);
  30. DWORD WlbsQuery(DWORD cluster,
  31. DWORD host,
  32. PWLBS_RESPONSE response,
  33. PDWORD num_hosts,
  34. PDWORD host_map,
  35. PVOID reserved);
  36. DWORD WlbsSuspend(DWORD cluster,
  37. DWORD host,
  38. PWLBS_RESPONSE response,
  39. PDWORD num_hosts);
  40. DWORD WlbsResume(DWORD cluster,
  41. DWORD host,
  42. PWLBS_RESPONSE response,
  43. PDWORD num_hosts);
  44. DWORD WlbsStart(DWORD cluster,
  45. DWORD host,
  46. PWLBS_RESPONSE response,
  47. PDWORD num_hosts);
  48. DWORD WlbsStop(DWORD cluster,
  49. DWORD host,
  50. PWLBS_RESPONSE response,
  51. PDWORD num_hosts);
  52. DWORD WlbsDrainStop(DWORD cluster,
  53. DWORD host,
  54. PWLBS_RESPONSE response,
  55. PDWORD num_hosts);
  56. DWORD WlbsEnable(DWORD cluster,
  57. DWORD host,
  58. PWLBS_RESPONSE response,
  59. PDWORD num_hosts,
  60. DWORD vip,
  61. DWORD port);
  62. DWORD WlbsDisable(DWORD cluster,
  63. DWORD host,
  64. PWLBS_RESPONSE response,
  65. PDWORD num_hosts,
  66. DWORD vip,
  67. DWORD port);
  68. DWORD WlbsDrain(DWORD cluster,
  69. DWORD host,
  70. PWLBS_RESPONSE response,
  71. PDWORD num_hosts,
  72. DWORD vip,
  73. DWORD port);
  74. DWORD WlbsAdjust(DWORD cluster,
  75. DWORD host,
  76. PWLBS_RESPONSE response,
  77. PDWORD num_hosts,
  78. DWORD port,
  79. DWORD value);
  80. //
  81. // Set remote control parameters
  82. //
  83. void WlbsPortSet(DWORD cluster, WORD port);
  84. void WlbsPasswordSet(DWORD cluster, const WCHAR* password);
  85. void WlbsCodeSet(DWORD cluster, DWORD passw);
  86. void WlbsDestinationSet(DWORD cluster, DWORD dest);
  87. void WlbsTimeoutSet(DWORD cluster, DWORD milliseconds);
  88. DWORD EnumClusters(OUT DWORD* pdwAddresses, IN OUT DWORD* pdwNum); // for API wrapper
  89. DWORD GetClusterNum() { return m_dwNumCluster;}
  90. DWORD EnumClusterObjects(OUT CWlbsCluster** &ppClusters, OUT DWORD* pdwNum);
  91. CWlbsCluster* GetClusterFromIp(DWORD dwClusterIp);
  92. CWlbsCluster* GetClusterFromIpOrIndex(DWORD dwClusterIpOrIndex);
  93. HANDLE GetDriverHandle() {return m_hdl;}
  94. //
  95. // GetClusterFromAdapter looks up an adapter based on its GUID.
  96. //
  97. CWlbsCluster*
  98. GetClusterFromAdapter(
  99. IN const GUID &AdapterGuid
  100. );
  101. //
  102. // ValidateParam validates and fixes up the specified parameters structure. It has no side effects other than changing some
  103. // fields within paramp, such as IP addresses which may be reformatted into canonical form.
  104. //
  105. BOOL
  106. ValidateParam(
  107. IN OUT PWLBS_REG_PARAMS paramp
  108. );
  109. //
  110. // Performs local cluster-wide control operations on the specified GUID.
  111. //
  112. DWORD LocalClusterControl(
  113. IN const GUID& AdapterGuid,
  114. IN LONG ioctl
  115. );
  116. BOOLEAN IsClusterMember (DWORD dwClusterIp);
  117. protected:
  118. struct WLBS_CLUSTER_PARAMS
  119. {
  120. DWORD cluster;
  121. DWORD passw;
  122. DWORD timeout;
  123. DWORD dest;
  124. WORD port;
  125. WORD valid;
  126. };
  127. enum { WLBS_MAX_CLUSTERS = 128};
  128. WLBS_CLUSTER_PARAMS m_cluster_params [WLBS_MAX_CLUSTERS]; // Cluster settings for remote control
  129. BOOL m_init_once; // whether WlbsInit is called
  130. BOOL m_remote_ctrl; // Whether remote operation can be performed on this machine
  131. BOOL m_local_ctrl; // Whether local operation can be performed on this machine
  132. HANDLE m_hdl; // handle to the device object
  133. // HANDLE lock; // An mutex
  134. DWORD m_def_dst_addr; // Default destination address for all clusters, set by WlbsDestinationSet
  135. DWORD m_def_timeout;// Time out value for remote control
  136. WORD m_def_port; // UDP port for remote control
  137. DWORD m_def_passw; // Default password for remote control
  138. HANDLE m_registry_lock; // used for mutually exclusive access to the registry, should use named lock
  139. DWORD m_dwSrcAddress; // address of this machine, used by remote control packet
  140. DWORD m_dwNumCluster; // number of clusters on this host
  141. CWlbsCluster* m_pClusterArray[WLBS_MAX_CLUSTERS]; // an array of all clusters
  142. DWORD GetInitResult()
  143. {
  144. if (m_local_ctrl && m_remote_ctrl)
  145. return WLBS_PRESENT;
  146. if (m_local_ctrl)
  147. return WLBS_LOCAL_ONLY;
  148. else if (m_remote_ctrl)
  149. return WLBS_REMOTE_ONLY;
  150. else
  151. return WLBS_INIT_ERROR;
  152. };
  153. bool IsInitialized() const {return m_hdl != INVALID_HANDLE_VALUE;}
  154. DWORD RemoteQuery(DWORD cluster,
  155. DWORD host,
  156. PWLBS_RESPONSE response,
  157. PDWORD num_hosts,
  158. PDWORD host_map);
  159. DWORD WlbsRemoteControl(LONG ioctl,
  160. PIOCTL_CVY_BUF pin_bufp,
  161. PIOCTL_CVY_BUF pout_bufp,
  162. PWLBS_RESPONSE pcvy_resp,
  163. PDWORD nump,
  164. DWORD trg_addr,
  165. DWORD hst_addr,
  166. DWORD vip);
  167. };
  168. DWORD WlbsLocalControl(HANDLE hDevice, const GUID& AdapterGuid,
  169. LONG ioctl, PIOCTL_CVY_BUF in_bufp,
  170. PIOCTL_CVY_BUF out_bufp, DWORD vip);
  171. #endif