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.

963 lines
23 KiB

  1. //***************************************************************************
  2. //
  3. // CFGUTIL.H
  4. //
  5. // Purpose: NLB configuration-related helper utilities for:
  6. // -- bind/unbind of nlb
  7. // -- wmi client and server helper APIs
  8. // -- utility functions with no side effects like allocate array
  9. // -- wrappers around some wlbsctrl APIs -- it will dynamically
  10. // load wlbsctrl and do the appropriate thing for W2K and XP.
  11. //
  12. // Copyright (c)2001 Microsoft Corporation, All Rights Reserved
  13. //
  14. // History:
  15. //
  16. // 07/23/01 JosephJ Created -- used to live under nlbmgr\provider as
  17. // cfgutils.h (i.e., with ending 's').
  18. // Lib which implements the functionality is in
  19. // nlbmgr\cfgutillib.
  20. //
  21. //***************************************************************************
  22. typedef enum
  23. {
  24. WLBS_START = 0,
  25. WLBS_STOP,
  26. WLBS_DRAIN,
  27. WLBS_SUSPEND,
  28. WLBS_RESUME,
  29. WLBS_PORT_ENABLE,
  30. WLBS_PORT_DISABLE,
  31. WLBS_PORT_DRAIN,
  32. WLBS_QUERY,
  33. WLBS_QUERY_PORT_STATE
  34. } WLBS_OPERATION_CODES;
  35. typedef struct _NLB_IP_ADDRESS_INFO
  36. {
  37. WCHAR IpAddress[WLBS_MAX_CL_IP_ADDR];
  38. WCHAR SubnetMask[WLBS_MAX_CL_NET_MASK];
  39. } NLB_IP_ADDRESS_INFO;
  40. typedef struct _NLB_CLUSTER_MEMBER_INFO
  41. {
  42. UINT HostId;
  43. WCHAR DedicatedIpAddress[WLBS_MAX_CL_IP_ADDR];
  44. WCHAR HostName[CVY_MAX_FQDN+1];
  45. } NLB_CLUSTER_MEMBER_INFO;
  46. WBEMSTATUS
  47. CfgUtilInitialize(BOOL fServer, BOOL fNoPing);
  48. VOID
  49. CfgUtilDeitialize(VOID);
  50. //
  51. // Gets the list of IP addresses and the friendly name for the specified NIC.
  52. //
  53. WBEMSTATUS
  54. CfgUtilGetIpAddressesAndFriendlyName(
  55. IN LPCWSTR szNic,
  56. OUT UINT *pNumIpAddresses,
  57. OUT NLB_IP_ADDRESS_INFO **ppIpInfo, // Free using c++ delete operator.
  58. OUT LPWSTR *pszFriendlyName // Optional, Free using c++ delete
  59. );
  60. //
  61. // Sets the list of statically-bound IP addresses for the NIC.
  62. // if NumIpAddresses is 0, the NIC is configured with a made-up autonet.
  63. // (call CfgUtilSetDHCP to set a DHCP-assigned address).
  64. //
  65. WBEMSTATUS
  66. CfgUtilSetStaticIpAddresses(
  67. IN LPCWSTR szNic,
  68. IN UINT NumIpAddresses,
  69. IN NLB_IP_ADDRESS_INFO *pIpInfo
  70. );
  71. //
  72. // Sets the IP addresses for the NIC to be DHCP-assigned.
  73. //
  74. WBEMSTATUS
  75. CfgUtilSetDHCP(
  76. IN LPCWSTR szNic
  77. );
  78. //
  79. // Determines whether the specified nic is configured with DHCP or not.
  80. //
  81. WBEMSTATUS
  82. CfgUtilGetDHCP(
  83. IN LPCWSTR szNic,
  84. OUT BOOL *pfDHCP
  85. );
  86. //
  87. // Returns an array of pointers to string-version of GUIDS
  88. // that represent the set of alive and healthy NICS that are
  89. // suitable for NLB to bind to -- basically alive ethernet NICs.
  90. //
  91. // Delete ppNics using the delete WCHAR[] operator. Do not
  92. // delete the individual strings.
  93. //
  94. WBEMSTATUS
  95. CfgUtilsGetNlbCompatibleNics(
  96. OUT LPWSTR **ppszNics,
  97. OUT UINT *pNumNics,
  98. OUT UINT *pNumBoundToNlb // Optional
  99. );
  100. //
  101. // Determines whether NLB is bound to the specified NIC.
  102. //
  103. WBEMSTATUS
  104. CfgUtilCheckIfNlbBound(
  105. IN LPCWSTR szNic,
  106. OUT BOOL *pfBound
  107. );
  108. //
  109. // On success, *pfCanLock is set to TRUE IFF the NETCFG write lock
  110. // CAN be locked at this point in time.
  111. // WARNING: this is really just a hint, as immediately after the function
  112. // returns the state may change.
  113. //
  114. WBEMSTATUS
  115. CfgUtilGetNetcfgWriteLockState(
  116. OUT BOOL *pfCanLock,
  117. LPWSTR *pszHeldBy // OPTIONAL, free using delete[].
  118. );
  119. //
  120. // Binds/unbinds NLB to the specified NIC.
  121. //
  122. WBEMSTATUS
  123. CfgUtilChangeNlbBindState(
  124. IN LPCWSTR szNic,
  125. IN BOOL fBind
  126. );
  127. //
  128. // Initializes pParams using default values.
  129. //
  130. VOID
  131. CfgUtilInitializeParams(
  132. OUT WLBS_REG_PARAMS *pParams
  133. );
  134. //
  135. // Converts the specified plain-text password into the hashed version
  136. // and saves it in pParams.
  137. //
  138. DWORD
  139. CfgUtilSetRemotePassword(
  140. IN WLBS_REG_PARAMS *pParams,
  141. IN LPCWSTR szPassword
  142. );
  143. //
  144. // Gets the current NLB configuration for the specified NIC
  145. //
  146. WBEMSTATUS
  147. CfgUtilGetNlbConfig(
  148. IN LPCWSTR szNic,
  149. OUT WLBS_REG_PARAMS *pParams
  150. );
  151. //
  152. // Sets the current NLB configuration for the specified NIC. This
  153. // includes notifying the driver if required.
  154. //
  155. WBEMSTATUS
  156. CfgUtilSetNlbConfig(
  157. IN LPCWSTR szNic,
  158. IN WLBS_REG_PARAMS *pParams,
  159. IN BOOL fJustBound
  160. );
  161. //
  162. // Just writes the current NLB configuration for the specified NIC to the
  163. // registry. MAY BE CALLED WHEN NLB IS UNBOUND.
  164. //
  165. WBEMSTATUS
  166. CfgUtilRegWriteParams(
  167. IN LPCWSTR szNic,
  168. IN WLBS_REG_PARAMS *pParams
  169. );
  170. //
  171. // Recommends whether the update should be performed async or sync
  172. // Returns WBEM_S_FALSE if the update is a no op.
  173. // Returns WBEM_INVALID_PARAMATER if the params are invalid.
  174. //
  175. WBEMSTATUS
  176. CfgUtilsAnalyzeNlbUpdate(
  177. IN const WLBS_REG_PARAMS *pCurrentParams, OPTIONAL
  178. IN WLBS_REG_PARAMS *pNewParams,
  179. OUT BOOL *pfConnectivityChange
  180. );
  181. //
  182. // Verifies that the NIC GUID exists.
  183. //
  184. WBEMSTATUS
  185. CfgUtilsValidateNicGuid(
  186. IN LPCWSTR szGuid
  187. );
  188. //
  189. // Validates a network address
  190. //
  191. WBEMSTATUS
  192. CfgUtilsValidateNetworkAddress(
  193. IN LPCWSTR szAddress, // format: "10.0.0.1[/255.0.0.0]"
  194. OUT PUINT puIpAddress, // in network byte order
  195. OUT PUINT puSubnetMask, // in network byte order (0 if unspecified)
  196. OUT PUINT puDefaultSubnetMask // depends on class: 'a', 'b', 'c', 'd', 'e'
  197. );
  198. WBEMSTATUS
  199. CfgUtilControlCluster(
  200. IN LPCWSTR szNic,
  201. IN WLBS_OPERATION_CODES Opcode,
  202. IN DWORD Vip,
  203. IN DWORD PortNum,
  204. OUT DWORD * pdwHostMap,
  205. OUT DWORD * pdwNlbStatus
  206. );
  207. WBEMSTATUS
  208. CfgUtilGetClusterMembers(
  209. IN LPCWSTR szNic,
  210. OUT DWORD *pNumMembers,
  211. OUT NLB_CLUSTER_MEMBER_INFO **ppMembers // free using delete[]
  212. );
  213. WBEMSTATUS
  214. CfgUtilSafeArrayFromStrings(
  215. IN LPCWSTR *pStrings,
  216. IN UINT NumStrings,
  217. OUT SAFEARRAY **ppSA
  218. );
  219. WBEMSTATUS
  220. CfgUtilStringsFromSafeArray(
  221. IN SAFEARRAY *pSA,
  222. OUT LPWSTR **ppStrings,
  223. OUT UINT *pNumStrings
  224. );
  225. _COM_SMARTPTR_TYPEDEF(IWbemClassObject, __uuidof(IWbemClassObject));
  226. _COM_SMARTPTR_TYPEDEF(IWbemServices, __uuidof(IWbemServices));
  227. _COM_SMARTPTR_TYPEDEF(IWbemLocator, __uuidof(IWbemLocator));
  228. _COM_SMARTPTR_TYPEDEF(IWbemClassObject, __uuidof(IWbemClassObject));
  229. _COM_SMARTPTR_TYPEDEF(IEnumWbemClassObject, __uuidof(IEnumWbemClassObject));
  230. _COM_SMARTPTR_TYPEDEF(IWbemCallResult, __uuidof(IWbemCallResult));
  231. _COM_SMARTPTR_TYPEDEF(IWbemStatusCodeText, __uuidof(IWbemStatusCodeText));
  232. WBEMSTATUS
  233. get_string_parameter(
  234. IN IWbemClassObjectPtr spObj,
  235. IN LPCWSTR szParameterName,
  236. OUT LPWSTR *ppStringValue
  237. );
  238. WBEMSTATUS
  239. CfgUtilGetWmiObjectInstance(
  240. IN IWbemServicesPtr spWbemServiceIF,
  241. IN LPCWSTR szClassName,
  242. IN LPCWSTR szPropertyName,
  243. IN LPCWSTR szPropertyValue,
  244. OUT IWbemClassObjectPtr &sprefObj // smart pointer
  245. );
  246. WBEMSTATUS
  247. CfgUtilGetWmiRelPath(
  248. IN IWbemClassObjectPtr spObj,
  249. OUT LPWSTR * pszRelPath // free using delete
  250. );
  251. WBEMSTATUS
  252. CfgUtilGetWmiInputInstanceAndRelPath(
  253. IN IWbemServicesPtr spWbemServiceIF,
  254. IN LPCWSTR szClassName,
  255. IN LPCWSTR szPropertyName, // NULL: return Class rel path
  256. IN LPCWSTR szPropertyValue,
  257. IN LPCWSTR szMethodName,
  258. OUT IWbemClassObjectPtr &spWbemInputInstance, // smart pointer
  259. OUT LPWSTR * pszRelPath // free using delete
  260. );
  261. WBEMSTATUS
  262. CfgUtilGetWmiMachineName(
  263. IN IWbemServicesPtr spWbemServiceIF,
  264. OUT LPWSTR * pszMachineName // free using delete
  265. );
  266. WBEMSTATUS
  267. CfgUtilGetWmiStringParam(
  268. IN IWbemClassObjectPtr spObj,
  269. IN LPCWSTR szParameterName,
  270. OUT LPWSTR *ppStringValue
  271. );
  272. WBEMSTATUS
  273. CfgUtilSetWmiStringParam(
  274. IN IWbemClassObjectPtr spObj,
  275. IN LPCWSTR szParameterName,
  276. IN LPCWSTR szValue
  277. );
  278. WBEMSTATUS
  279. CfgUtilGetWmiStringArrayParam(
  280. IN IWbemClassObjectPtr spObj,
  281. IN LPCWSTR szParameterName,
  282. OUT LPWSTR **ppStrings,
  283. OUT UINT *pNumStrings
  284. );
  285. WBEMSTATUS
  286. CfgUtilSetWmiStringArrayParam(
  287. IN IWbemClassObjectPtr spObj,
  288. IN LPCWSTR szParameterName,
  289. IN LPCWSTR *ppStrings,
  290. IN UINT NumStrings
  291. );
  292. WBEMSTATUS
  293. CfgUtilGetWmiDWORDParam(
  294. IN IWbemClassObjectPtr spObj,
  295. IN LPCWSTR szParameterName,
  296. OUT DWORD *pValue
  297. );
  298. WBEMSTATUS
  299. CfgUtilSetWmiDWORDParam(
  300. IN IWbemClassObjectPtr spObj,
  301. IN LPCWSTR szParameterName,
  302. IN DWORD Value
  303. );
  304. WBEMSTATUS
  305. CfgUtilGetWmiBoolParam(
  306. IN IWbemClassObjectPtr spObj,
  307. IN LPCWSTR szParameterName,
  308. OUT BOOL *pValue
  309. );
  310. WBEMSTATUS
  311. CfgUtilSetWmiBoolParam(
  312. IN IWbemClassObjectPtr spObj,
  313. IN LPCWSTR szParameterName,
  314. IN BOOL Value
  315. );
  316. WBEMSTATUS
  317. CfgUtilConnectToServer(
  318. IN LPCWSTR szNetworkResource, // \\machinename\root\microsoftnlb \root\...
  319. IN LPCWSTR szUser, // Must be NULL for local server
  320. IN LPCWSTR szPassword, // Must be NULL for local server
  321. IN LPCWSTR szAuthority, // Must be NULL for local server
  322. OUT IWbemServices **ppWbemService // deref when done.
  323. );
  324. LPWSTR *
  325. CfgUtilsAllocateStringArray(
  326. UINT NumStrings,
  327. UINT MaxStringLen // excluding ending NULL
  328. );
  329. #define NLB_MAX_PORT_STRING_SIZE 128 // in WCHARS, including ending NULL
  330. BOOL
  331. CfgUtilsGetPortRuleString(
  332. IN PWLBS_PORT_RULE pPr,
  333. OUT LPWSTR pString // At least NLB_MAX_PORT_STRING_SIZE wchars
  334. );
  335. BOOL
  336. CfgUtilsSetPortRuleString(
  337. IN LPCWSTR pString,
  338. OUT PWLBS_PORT_RULE pPr
  339. );
  340. //
  341. // Gets the port rules, if any, from the specfied nlb params structure
  342. //
  343. WBEMSTATUS
  344. CfgUtilGetPortRules(
  345. IN const WLBS_REG_PARAMS *pParams,
  346. OUT WLBS_PORT_RULE **ppRules, // Free using delete
  347. OUT UINT *pNumRules
  348. );
  349. //
  350. // Sets the specified port rules in the specfied nlb params structure
  351. //
  352. WBEMSTATUS
  353. CfgUtilSetPortRules(
  354. IN WLBS_PORT_RULE *pRules,
  355. IN UINT NumRules,
  356. IN OUT WLBS_REG_PARAMS *pParams
  357. );
  358. //
  359. // Sets the hashed version of the remote control password
  360. //
  361. VOID
  362. CfgUtilSetHashedRemoteControlPassword(
  363. IN OUT WLBS_REG_PARAMS *pParams,
  364. IN DWORD dwHashedPassword
  365. );
  366. //
  367. // Gets the hashed version of the remote control password
  368. //
  369. DWORD
  370. CfgUtilGetHashedRemoteControlPassword(
  371. IN const WLBS_REG_PARAMS *pParams
  372. );
  373. //
  374. // Attempts to resolve the ip address and ping the host.
  375. //
  376. WBEMSTATUS
  377. CfgUtilPing(
  378. IN LPCWSTR szBindString,
  379. IN UINT Timeout, // In milliseconds.
  380. OUT ULONG *pResolvedIpAddress // in network byte order.
  381. );
  382. BOOL
  383. CfgUtilEncryptPassword(
  384. IN LPCWSTR szPassword,
  385. OUT UINT cchEncPwd, // size in chars of szEncPwd, inc space for ending 0
  386. OUT LPWSTR szEncPwd
  387. );
  388. BOOL
  389. CfgUtilDecryptPassword(
  390. IN LPCWSTR szEncPwd,
  391. OUT UINT cchPwd, // size in chars of szPwd, inc space for ending 0
  392. OUT LPWSTR szPwd
  393. );
  394. //
  395. // Returns TRUE if MSCS is installed, false otherwise
  396. //
  397. BOOL
  398. CfgUtilIsMSCSInstalled(VOID);
  399. // Enables SE_LOAD_DRIVER_NAME privilege
  400. BOOL
  401. CfgUtils_Enable_Load_Unload_Driver_Privilege(VOID);
  402. typedef struct _NLB_IP_ADDRESS_INFO NLB_IP_ADDRESS_INFO;
  403. //
  404. // This structure contains all information associated with a particular NIC
  405. // that is relevant to NLB. This includes the IP addresses bound the NIC,
  406. // whether or not NLB is bound to the NIC, and if NLB is bound, all
  407. // the NLB-specific properties.
  408. //
  409. class NLB_EXTENDED_CLUSTER_CONFIGURATION
  410. {
  411. public:
  412. NLB_EXTENDED_CLUSTER_CONFIGURATION(VOID) {ZeroMemory(this, sizeof(*this));}
  413. ~NLB_EXTENDED_CLUSTER_CONFIGURATION()
  414. {
  415. Clear();
  416. };
  417. VOID
  418. Clear(VOID)
  419. {
  420. delete pIpAddressInfo;
  421. delete m_szFriendlyName;
  422. delete m_szNewRemoteControlPassword;
  423. ZeroMemory(this, sizeof(*this));
  424. CfgUtilInitializeParams(&NlbParams);
  425. }
  426. VOID
  427. SetDefaultNlbCluster(VOID)
  428. {
  429. CfgUtilInitializeParams(&NlbParams);
  430. fValidNlbCfg = TRUE;
  431. fBound = TRUE;
  432. }
  433. NLBERROR
  434. AnalyzeUpdate(
  435. IN NLB_EXTENDED_CLUSTER_CONFIGURATION *pNewCfg,
  436. OUT BOOL *pfConnectivityChange
  437. );
  438. WBEMSTATUS
  439. Update(
  440. IN const NLB_EXTENDED_CLUSTER_CONFIGURATION *pNewCfg
  441. );
  442. WBEMSTATUS
  443. SetNetworkAddresses(
  444. IN LPCWSTR *pszNetworkAddresses,
  445. IN UINT NumNetworkAddresses
  446. );
  447. WBEMSTATUS
  448. SetNetworkAddressesSafeArray(
  449. IN SAFEARRAY *pSA
  450. );
  451. VOID
  452. SetNetworkAddressesRaw(
  453. IN NLB_IP_ADDRESS_INFO *pNewInfo, // Allocated using new, can be NULL
  454. IN UINT NumNew
  455. )
  456. {
  457. delete pIpAddressInfo;
  458. pIpAddressInfo = pNewInfo;
  459. NumIpAddresses = NumNew;
  460. }
  461. WBEMSTATUS
  462. GetNetworkAddresses(
  463. OUT LPWSTR **ppszNetworkAddresses, // free using delete
  464. OUT UINT *pNumNetworkAddresses
  465. );
  466. WBEMSTATUS
  467. GetNetworkAddressesSafeArray(
  468. OUT SAFEARRAY **ppSA
  469. );
  470. WBEMSTATUS
  471. SetNetworkAddresPairs(
  472. IN LPCWSTR *pszIpAddresses,
  473. IN LPCWSTR *pszSubnetMasks,
  474. IN UINT NumNetworkAddresses
  475. );
  476. WBEMSTATUS
  477. GetNetworkAddressPairs(
  478. OUT LPWSTR **ppszIpAddresses, // free using delete
  479. OUT LPWSTR **ppszIpSubnetMasks, // free using delete
  480. OUT UINT *pNumNetworkAddresses
  481. );
  482. WBEMSTATUS
  483. ModifyNetworkAddress(
  484. IN LPCWSTR szOldNetworkAddress, OPTIONAL
  485. IN LPCWSTR szNewIpAddress, OPTIONAL
  486. IN LPCWSTR szNewSubnetMask OPTIONAL
  487. );
  488. //
  489. // NULL, NULL: clear all network addresses
  490. // NULL, szNew: add
  491. // szOld, NULL: remove
  492. // szOld, szNew: replace (or add, if old doesn't exist)
  493. //
  494. WBEMSTATUS
  495. GetPortRules(
  496. OUT LPWSTR **ppszPortRules,
  497. OUT UINT *pNumPortRules
  498. );
  499. WBEMSTATUS
  500. SetPortRules(
  501. IN LPCWSTR *pszPortRules,
  502. IN UINT NumPortRules
  503. );
  504. WBEMSTATUS
  505. GetPortRulesSafeArray(
  506. OUT SAFEARRAY **ppSA
  507. );
  508. WBEMSTATUS
  509. SetPortRulesSafeArray(
  510. IN SAFEARRAY *pSA
  511. );
  512. UINT GetGeneration(VOID) {return Generation;}
  513. BOOL IsNlbBound(VOID) const {return fBound;}
  514. BOOL IsValidNlbConfig(VOID) const {return fBound && fValidNlbCfg;}
  515. VOID SetNlbBound(BOOL fNlbBound) {fBound = (fNlbBound!=0);}
  516. WBEMSTATUS
  517. GetClusterName(
  518. OUT LPWSTR *pszName
  519. );
  520. VOID
  521. SetClusterName(
  522. IN LPCWSTR szName // NULL ok
  523. );
  524. WBEMSTATUS
  525. GetClusterNetworkAddress(
  526. OUT LPWSTR *pszAddress
  527. );
  528. VOID
  529. SetClusterNetworkAddress(
  530. IN LPCWSTR szAddress // NULL ok
  531. );
  532. WBEMSTATUS
  533. GetDedicatedNetworkAddress(
  534. OUT LPWSTR *pszAddress
  535. );
  536. VOID
  537. SetDedicatedNetworkAddress(
  538. IN LPCWSTR szAddress // NULL ok
  539. );
  540. typedef enum
  541. {
  542. TRAFFIC_MODE_UNICAST,
  543. TRAFFIC_MODE_MULTICAST,
  544. TRAFFIC_MODE_IGMPMULTICAST
  545. } TRAFFIC_MODE;
  546. TRAFFIC_MODE
  547. GetTrafficMode(
  548. VOID
  549. ) const;
  550. VOID
  551. SetTrafficMode(
  552. TRAFFIC_MODE Mode
  553. );
  554. UINT
  555. GetHostPriority(
  556. VOID
  557. );
  558. VOID
  559. SetHostPriority(
  560. UINT Priority
  561. );
  562. /* OBSOLETE
  563. typedef enum
  564. {
  565. START_MODE_STARTED,
  566. START_MODE_STOPPED
  567. } START_MODE;
  568. */
  569. DWORD
  570. GetClusterModeOnStart(
  571. VOID
  572. );
  573. VOID
  574. SetClusterModeOnStart(
  575. DWORD Mode
  576. );
  577. BOOL
  578. GetPersistSuspendOnReboot(
  579. VOID
  580. );
  581. VOID
  582. SetPersistSuspendOnReboot(
  583. BOOL bPersistSuspendOnReboot
  584. );
  585. BOOL
  586. GetRemoteControlEnabled(
  587. VOID
  588. ) const;
  589. VOID
  590. SetRemoteControlEnabled(
  591. BOOL fEnabled
  592. );
  593. WBEMSTATUS
  594. GetFriendlyName(
  595. OUT LPWSTR *pszFriendlyName // Free using delete
  596. ) const;
  597. WBEMSTATUS
  598. SetFriendlyName(
  599. IN LPCWSTR szFriendlyName // Saves a copy of szFriendlyName
  600. );
  601. LPCWSTR
  602. GetNewRemoteControlPasswordRaw(VOID) const
  603. {
  604. if (NewRemoteControlPasswordSet())
  605. {
  606. return m_szNewRemoteControlPassword;
  607. }
  608. else
  609. {
  610. return NULL;
  611. }
  612. }
  613. BOOL
  614. NewRemoteControlPasswordSet(
  615. VOID
  616. ) const
  617. {
  618. return GetRemoteControlEnabled() && m_fSetPassword;
  619. }
  620. WBEMSTATUS
  621. SetNewRemoteControlPassword(
  622. IN LPCWSTR szFriendlyName // Saves a copy of szRemoteControlPassword
  623. );
  624. VOID
  625. SetNewHashedRemoteControlPassword(
  626. DWORD dwHash
  627. )
  628. {
  629. delete m_szNewRemoteControlPassword;
  630. m_szNewRemoteControlPassword = NULL;
  631. m_fSetPassword = TRUE;
  632. m_dwNewHashedRemoteControlPassword = dwHash;
  633. }
  634. VOID
  635. ClearNewRemoteControlPassword(
  636. VOID
  637. )
  638. {
  639. delete m_szNewRemoteControlPassword;
  640. m_szNewRemoteControlPassword = NULL;
  641. m_fSetPassword = FALSE;
  642. m_dwNewHashedRemoteControlPassword = 0;
  643. }
  644. BOOL
  645. GetNewHashedRemoteControlPassword(
  646. DWORD &dwHash
  647. ) const
  648. {
  649. BOOL fRet = FALSE;
  650. if (NewRemoteControlPasswordSet())
  651. {
  652. dwHash = m_dwNewHashedRemoteControlPassword;
  653. fRet = TRUE;
  654. }
  655. else
  656. {
  657. dwHash = 0;
  658. }
  659. return fRet;
  660. }
  661. BOOL
  662. IsBlankDedicatedIp(
  663. VOID
  664. ) const;
  665. //
  666. // Following fields are public because this class started out as a
  667. // structure. TODO: wrap these with access methods.
  668. //
  669. BOOL fValidNlbCfg; // True iff all the information is valid.
  670. UINT Generation; // Generation ID of this Update.
  671. BOOL fBound; // Whether or not NLB is bound to this NIC.
  672. BOOL fDHCP; // Whether the address is DHCP assigned.
  673. //
  674. // The following three fields are used only when updating the configuration.
  675. // They are all set to false on reading the configuration.
  676. //
  677. BOOL fAddDedicatedIp; // add ded ip (if present)
  678. BOOL fAddClusterIps; // add cluster vips (if bound)
  679. BOOL fCheckForAddressConflicts;
  680. //
  681. // When GETTING configuration info, the following provide the full
  682. // list of statically configured IP addresses on the specified NIC.
  683. //
  684. // When SETTING configuration info, the following can either be zero
  685. // or non-zero. If zero, the set of IP addresses to be added will
  686. // be inferred from other fields (like cluster vip, per-port vips,
  687. // existing IP addresses and the three fields above).
  688. // If non-zero, the exact set of VIPS specified will be used.
  689. //
  690. UINT NumIpAddresses; // Number of IP addresses bound to the NIC
  691. NLB_IP_ADDRESS_INFO *pIpAddressInfo; // The actual IP addresses & masks
  692. WLBS_REG_PARAMS NlbParams; // The WLBS-specific configuration
  693. //
  694. // TODO move all data stuff below here...
  695. //
  696. private:
  697. LPCWSTR m_szFriendlyName; // Friendly name of NIC.
  698. //
  699. // IF nlb is bound AND remote control is enabled,
  700. // AND this field is true, we'll set the password -- either
  701. // m_szNewRemoteControlPassword or (if former is NULL)
  702. // m_dwNewHashedRemoteControlPassword.
  703. //
  704. // Access methods:
  705. // SetNewRemoteControlPassword
  706. // SetNewHashedRemoteControlPassword
  707. // ClearNewRemoteControlPassword
  708. // GetNewRemoteControlPasswordRaw
  709. // GetNewHashedRemoteControlPassword
  710. //
  711. BOOL m_fSetPassword;
  712. LPCWSTR m_szNewRemoteControlPassword;
  713. DWORD m_dwNewHashedRemoteControlPassword;
  714. //
  715. // Enable the following to identify places in code that do a struct
  716. // copy or initialization from struct.
  717. // TODO: clean up the maintenance of the embedded pointers during copy.
  718. //
  719. #if 0
  720. NLB_EXTENDED_CLUSTER_CONFIGURATION(
  721. const NLB_EXTENDED_CLUSTER_CONFIGURATION&
  722. );
  723. NLB_EXTENDED_CLUSTER_CONFIGURATION&
  724. operator = (const NLB_EXTENDED_CLUSTER_CONFIGURATION&);
  725. #endif // 0
  726. };
  727. typedef NLB_EXTENDED_CLUSTER_CONFIGURATION *PNLB_EXTENDED_CLUSTER_CONFIGURATION;
  728. //
  729. // Class for manipulating lists of IP addresses and subnet masks.
  730. // See provider\tests\tprov.cpp for examples of it's use.
  731. //
  732. class NlbIpAddressList
  733. {
  734. public:
  735. NlbIpAddressList(void)
  736. : m_uNum(0), m_uMax(0), m_pIpInfo(NULL)
  737. {
  738. }
  739. ~NlbIpAddressList()
  740. {
  741. delete[] m_pIpInfo;
  742. m_pIpInfo = NULL;
  743. m_uNum=0;
  744. m_uMax=0;
  745. }
  746. BOOL
  747. Copy(const NlbIpAddressList &refList);
  748. BOOL
  749. Validate(void); // checks that there are no dups and all valid ip/subnets
  750. BOOL
  751. Set(UINT uNew, const NLB_IP_ADDRESS_INFO *pNewInfo, UINT uExtraCount);
  752. //
  753. // Looks for the specified IP address -- returns an internal pointer
  754. // to the found IP address info, if fount, otherwise NULL.
  755. //
  756. const NLB_IP_ADDRESS_INFO *
  757. Find(
  758. LPCWSTR szIp // IF NULL, returns first address
  759. ) const;
  760. VOID
  761. Extract(UINT &uNum, NLB_IP_ADDRESS_INFO * &pNewInfo);
  762. BOOL
  763. Modify(LPCWSTR szOldIp, LPCWSTR szNewIp, LPCWSTR szNewSubnet);
  764. BOOL
  765. Apply(UINT uNew, const NLB_IP_ADDRESS_INFO *pNewInfo);
  766. VOID
  767. Clear(VOID)
  768. {
  769. (VOID) this->Set(0, NULL, 0);
  770. }
  771. UINT
  772. NumAddresses(VOID)
  773. {
  774. return m_uNum;
  775. }
  776. private:
  777. UINT m_uNum; // current count of valid ip addresses
  778. UINT m_uMax; // allocated ip addresses
  779. NLB_IP_ADDRESS_INFO *m_pIpInfo; // allocated array.
  780. //
  781. // Assignment and pass-by-value aren't supported at this time.
  782. // Defining these as private make sure that they can't be called.
  783. //
  784. NlbIpAddressList(const NlbIpAddressList&);
  785. NlbIpAddressList& operator = (const NlbIpAddressList&);
  786. static
  787. BOOL
  788. sfn_validate_info(
  789. const NLB_IP_ADDRESS_INFO &Info,
  790. UINT &uIpAddress
  791. );
  792. };