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.

439 lines
8.4 KiB

  1. #ifndef _MNLBHOST_H
  2. #define _MNLBHOST_H
  3. //
  4. // Copyright (c) Microsoft. All Rights Reserved
  5. //
  6. // THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Microsoft.
  7. // The copyright notice above does not evidence any
  8. // actual or intended publication of such source code.
  9. //
  10. // OneLiner : MNLBHost interface.
  11. // DevUnit : wlbstest
  12. // Author : Murtaza Hakim
  13. //
  14. // Description:
  15. // -----------
  16. // Include Files
  17. #include <vector>
  18. #include <wbemidl.h>
  19. #include <comdef.h>
  20. #include "MWmiObject.h"
  21. #include "MWmiInstance.h"
  22. #include "Common.h"
  23. // forward declarations.
  24. //
  25. class MNLBCluster;
  26. class MNLBPortRule;
  27. class MNLBPortRuleLoadBalanced;
  28. class MNLBPortRuleFailover;
  29. class MNLBPortRuleDisabled;
  30. using namespace std;
  31. //
  32. class MNLBHost
  33. {
  34. public:
  35. enum MNLBHost_Error
  36. {
  37. MNLBHost_SUCCESS = 0,
  38. COM_FAILURE = 1,
  39. CONNECT_FAILED = 2,
  40. NO_CLUSTER = 3,
  41. UNCONSTRUCTED = 4,
  42. };
  43. //
  44. // Description:
  45. // -----------
  46. // constructor.
  47. //
  48. // Parameters:
  49. // ----------
  50. // cip IN : cluster ip address of host.
  51. // hID IN : host id.
  52. //
  53. // Returns:
  54. // -------
  55. // none.
  56. MNLBHost( _bstr_t cip,
  57. int hID );
  58. //
  59. // Description:
  60. // -----------
  61. // default constructor.
  62. //
  63. // Parameters:
  64. // ----------
  65. // none.
  66. //
  67. // Returns:
  68. // -------
  69. // none.
  70. MNLBHost();
  71. //
  72. // Description:
  73. // -----------
  74. // copy constructor.
  75. //
  76. // Parameters:
  77. // ----------
  78. // mhost IN : object to copy.
  79. //
  80. // Returns:
  81. // -------
  82. // none.
  83. MNLBHost(const MNLBHost& mhost);
  84. //
  85. // Description:
  86. // -----------
  87. // assignment operator
  88. //
  89. // Parameters:
  90. // ----------
  91. // rhs IN : object to assign.
  92. //
  93. // Returns:
  94. // -------
  95. // self
  96. MNLBHost&
  97. operator=( const MNLBHost& rhs );
  98. //
  99. // Description:
  100. // -----------
  101. // destructor
  102. //
  103. // Parameters:
  104. // ----------
  105. // none
  106. //
  107. // Returns:
  108. // -------
  109. // none.
  110. ~MNLBHost();
  111. //
  112. // Description:
  113. // -----------
  114. // refreshes the wmi connection to the host
  115. //
  116. // Parameters:
  117. // ----------
  118. // none
  119. //
  120. // Returns:
  121. // -------
  122. // SUCCESS else error code.
  123. MNLBHost_Error
  124. refreshConnection();
  125. //
  126. // Description:
  127. // -----------
  128. // gets the host properties.
  129. //
  130. // Parameters:
  131. // ----------
  132. // hp OUT : host properties.
  133. //
  134. // Returns:
  135. // -------
  136. // SUCCESS else error code.
  137. MNLBHost_Error
  138. getHostProperties( HostProperties* hp );
  139. //
  140. // Description:
  141. // -----------
  142. // gets the cluster which this host is member of.
  143. //
  144. // Parameters:
  145. // ----------
  146. // cluster OUT : cluster which this host is member of.
  147. //
  148. // Returns:
  149. // -------
  150. // SUCCESS else error code.
  151. MNLBHost_Error
  152. getCluster( MNLBCluster* cluster);
  153. //
  154. // Description:
  155. // -----------
  156. // get the load balanced port rules associated with this host.
  157. //
  158. // Parameters:
  159. // ----------
  160. // portsLB OUT : load balanced port rules associated with this node.
  161. //
  162. // Returns:
  163. // -------
  164. // SUCCESS else error code.
  165. MNLBHost::MNLBHost_Error
  166. MNLBHost::getPortRulesLoadBalanced( vector<MNLBPortRuleLoadBalanced>* portsLB );
  167. //
  168. // Description:
  169. // -----------
  170. // get the failover port rules associated with this host.
  171. //
  172. // Parameters:
  173. // ----------
  174. // portsF OUT : failover port rules associated with this node.
  175. //
  176. // Returns:
  177. // -------
  178. // SUCCESS else error code.
  179. MNLBHost::MNLBHost_Error
  180. MNLBHost::getPortRulesFailover( vector<MNLBPortRuleFailover>* portsF );
  181. //
  182. // Description:
  183. // -----------
  184. // get the disabled port rules associated with this host.
  185. //
  186. // Parameters:
  187. // ----------
  188. // portsD OUT : failover port rules associated with this node.
  189. //
  190. // Returns:
  191. // -------
  192. // SUCCESS else error code.
  193. MNLBHost::MNLBHost_Error
  194. MNLBHost::getPortRulesDisabled( vector<MNLBPortRuleDisabled>* portsD );
  195. //
  196. // Description:
  197. // -----------
  198. // starts host operations.
  199. //
  200. // Parameters:
  201. // ----------
  202. // retVal OUT : return value of method ran.
  203. //
  204. // Returns:
  205. // -------
  206. // SUCCESS else error code.
  207. MNLBHost_Error
  208. start( unsigned long* retVal );
  209. //
  210. // Description:
  211. // -----------
  212. // stops host operations.
  213. //
  214. // Parameters:
  215. // ----------
  216. // retVal OUT : return value of method ran.
  217. //
  218. // Returns:
  219. // -------
  220. // SUCCESS else error code.
  221. MNLBHost_Error
  222. stop( unsigned long* retVal );
  223. //
  224. // Description:
  225. // -----------
  226. // resume control over host operations.
  227. //
  228. // Parameters:
  229. // ----------
  230. // retVal OUT : return value of method ran.
  231. //
  232. // Returns:
  233. // -------
  234. // SUCCESS else error code.
  235. MNLBHost_Error
  236. resume( unsigned long* retVal );
  237. //
  238. // Description:
  239. // -----------
  240. // suspend control over host operations.
  241. //
  242. // Parameters:
  243. // ----------
  244. // retVal OUT : return value of method ran.
  245. //
  246. // Returns:
  247. // -------
  248. // SUCCESS else error code.
  249. MNLBHost_Error
  250. suspend( unsigned long* retVal );
  251. //
  252. // Description:
  253. // -----------
  254. // finishes all existing connections and
  255. // stops host operations.
  256. //
  257. // Parameters:
  258. // ----------
  259. // retVal OUT : return value of method ran.
  260. //
  261. // Returns:
  262. // -------
  263. // SUCCESS else error code.
  264. MNLBHost_Error
  265. drainstop( unsigned long* retVal );
  266. //
  267. // Description:
  268. // -----------
  269. // enables traffic for port rule.
  270. //
  271. // Parameters:
  272. // ----------
  273. // retVal OUT : return value of method ran.
  274. // port IN : port to affect.
  275. //
  276. // Returns:
  277. // -------
  278. // SUCCESS else error code.
  279. MNLBHost_Error
  280. enable( unsigned long* retVal, unsigned long port = Common::ALL_PORTS );
  281. //
  282. // Description:
  283. // -----------
  284. // disables ALL traffic for port rule.
  285. //
  286. // Parameters:
  287. // ----------
  288. // retVal OUT : return value of method ran.
  289. // port IN : port to affect.
  290. //
  291. // Returns:
  292. // -------
  293. // SUCCESS else error code.
  294. MNLBHost_Error
  295. disable( unsigned long* retVal, unsigned long port = Common::ALL_PORTS );
  296. //
  297. // Description:
  298. // -----------
  299. // drains NEW traffic for port rule.
  300. //
  301. // Parameters:
  302. // ----------
  303. // retVal OUT : return value of method ran.
  304. // port IN : port to affect.
  305. //
  306. // Returns:
  307. // -------
  308. // SUCCESS else error code.
  309. MNLBHost_Error
  310. drain( unsigned long* retVal, unsigned long port = Common::ALL_PORTS );
  311. MNLBHost_Error
  312. getHostIP();
  313. private:
  314. _bstr_t hostIP;
  315. // wchar_t hostIDOfConnectedMachine[100];
  316. _bstr_t clusterIP;
  317. int hostID;
  318. bool connectedToAny;
  319. MNLBHost_Error status;
  320. auto_ptr<MWmiObject> p_machine;
  321. auto_ptr<MWmiInstance> p_host;
  322. MNLBHost_Error
  323. connectToExactHost();
  324. MNLBHost_Error
  325. connectToAnyHost();
  326. MNLBHost::MNLBHost_Error
  327. MNLBHost::getPortRulesLoadBalanced_private( vector<MNLBPortRuleLoadBalanced>* portsLB,
  328. vector<MWmiInstance>* instances );
  329. MNLBHost::MNLBHost_Error
  330. MNLBHost::getPortRulesFailover_private( vector<MNLBPortRuleFailover>* portsF,
  331. vector<MWmiInstance>* instances );
  332. MNLBHost::MNLBHost_Error
  333. MNLBHost::getPortRulesDisabled_private( vector<MNLBPortRuleDisabled>* portsD,
  334. vector<MWmiInstance>* instances );
  335. friend MNLBCluster;
  336. friend MNLBPortRule;
  337. friend MNLBPortRuleLoadBalanced;
  338. friend MNLBPortRuleFailover;
  339. friend MNLBPortRuleDisabled;
  340. };
  341. //
  342. // Ensure type safety
  343. typedef class MNLBHost MNLBHost;
  344. #endif