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.

244 lines
4.6 KiB

  1. #ifndef _MIPADDRESSADMIN_HH
  2. #define _MIPADDRESSADMIN_HH
  3. // Copyright (c) Microsoft. All Rights Reserved
  4. //
  5. // THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Microsoft.
  6. // The copyright notice above does not evidence any
  7. // actual or intendd publication of such source code.
  8. //
  9. // OneLiner : Interface for MIPAddressAdmin.
  10. // DevUnit : wlbstest
  11. // Author : Murtaza Hakim
  12. //
  13. // Description:
  14. // ------------
  15. // Manages adding, deleting and querying for IP addresses on
  16. // a nic using wmi.
  17. // Include Files
  18. #include "MWmiObject.h"
  19. #include "MWmiInstance.h"
  20. #include <vector>
  21. #include <wbemidl.h>
  22. #include <comdef.h>
  23. using namespace std;
  24. // Class Definition
  25. class MIPAddressAdmin
  26. {
  27. public:
  28. enum MIPAddressAdmin_Error
  29. {
  30. MIPAddressAdmin_SUCCESS = 0,
  31. COM_FAILURE = 1,
  32. UNCONSTRUCTED = 2,
  33. NO_SUCH_NIC = 3,
  34. NO_SUCH_IP = 4,
  35. NOT_SUPPORTED = 5,
  36. };
  37. // Description
  38. // -----------
  39. // Constructor.
  40. //
  41. // Parameters
  42. // ----------
  43. // machineIP IN : ip of machine to administer.
  44. // nicName IN : name of nic to administer.
  45. //
  46. // Returns
  47. // -------
  48. // none.
  49. //
  50. MIPAddressAdmin( const _bstr_t& machineIP,
  51. const _bstr_t& nicName );
  52. // use this when doing locally.
  53. //
  54. MIPAddressAdmin( const _bstr_t& nicName );
  55. // Description
  56. // -----------
  57. // Copy Constructor.
  58. //
  59. // Parameters
  60. // ----------
  61. // obj : object to copy.
  62. //
  63. // Returns
  64. // -------
  65. // none.
  66. //
  67. MIPAddressAdmin( const MIPAddressAdmin& obj );
  68. // Description
  69. // -----------
  70. // Assignment operator
  71. //
  72. // Parameters
  73. // ----------
  74. // rhs : object to assign.
  75. //
  76. // Returns
  77. // -------
  78. // self.
  79. //
  80. MIPAddressAdmin&
  81. operator=(const MIPAddressAdmin& rhs );
  82. // Description
  83. // -----------
  84. // Destructor
  85. //
  86. //
  87. // Parameters
  88. // ----------
  89. // none
  90. //
  91. // Returns
  92. // -------
  93. // none.
  94. //
  95. ~MIPAddressAdmin();
  96. // Description
  97. // -----------
  98. // Adds IP address to interface.
  99. //
  100. // Parameters
  101. // ----------
  102. // ipAddrToAdd in : ipAddr to add in dotted dec notation.
  103. // subnetMask in : subnet mask in dotted dec notation.
  104. //
  105. // Returns
  106. // -------
  107. // success else error code.
  108. MIPAddressAdmin_Error
  109. addIPAddress(const _bstr_t& ipAddrToAdd,
  110. const _bstr_t& subnetMask);
  111. // Description
  112. // -----------
  113. // Deletes IP address from interface.
  114. //
  115. // Parameters
  116. // ----------
  117. // none
  118. //
  119. // Returns
  120. // -------
  121. // SUCCESS else error code.
  122. //
  123. MIPAddressAdmin_Error
  124. deleteIPAddress( const _bstr_t& ipAddrToDelete );
  125. // Description
  126. // -----------
  127. // Gets all ip addresses on nic
  128. //
  129. // Parameters
  130. // ----------
  131. // ipAddress OUT : list of ip addresses on nic.
  132. // subnetMask OUT : list of subnet mask for each ip.
  133. //
  134. // Returns
  135. // -------
  136. // SUCCESS else error code.
  137. //
  138. MIPAddressAdmin_Error
  139. getIPAddresses( vector<_bstr_t>* ipAddress,
  140. vector<_bstr_t>* subnetMask );
  141. // Description
  142. // -----------
  143. // Checks whether the nic we are administering
  144. // has dhcp enabled or not.
  145. //
  146. // Parameters
  147. // ----------
  148. // dhcpEnabled OUT : is set to true if dhcp, else set to false.
  149. //
  150. // Returns
  151. // -------
  152. // SUCCESS else error code.
  153. //
  154. MIPAddressAdmin_Error
  155. isDHCPEnabled( bool& dhcpEnabled );
  156. // Description
  157. // -----------
  158. // Enables dhcp on this nic.
  159. //
  160. // Parameters
  161. // ----------
  162. // none.
  163. //
  164. // Returns
  165. // -------
  166. // SUCCESS else error code.
  167. //
  168. MIPAddressAdmin_Error
  169. enableDHCP();
  170. // refresh connection
  171. //
  172. MIPAddressAdmin_Error
  173. refreshConnection();
  174. private:
  175. _bstr_t _machineIP;
  176. _bstr_t _nicName;
  177. MIPAddressAdmin_Error status;
  178. MWmiObject machine;
  179. MIPAddressAdmin_Error
  180. checkStatus( vector<MWmiInstance>* nicInstance );
  181. };
  182. //------------------------------------------------------
  183. //
  184. //------------------------------------------------------
  185. // Inline Functions
  186. //------------------------------------------------------
  187. //
  188. //------------------------------------------------------
  189. // Ensure Type Safety
  190. //------------------------------------------------------
  191. typedef class MIPAddressAdmin MIPAddressAdmin;
  192. //------------------------------------------------------
  193. //
  194. #endif _MIPADDRESSADMIN_HH