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.

1032 lines
26 KiB

  1. //***************************************************************************
  2. //
  3. // ENGINE.H
  4. //
  5. // Module: NLB Manager (client-side exe)
  6. //
  7. // Purpose: Engine used to operate on groups of NLB hosts.
  8. // This file has no UI aspects.
  9. //
  10. // Copyright (c)2001 Microsoft Corporation, All Rights Reserved
  11. //
  12. // History:
  13. //
  14. // 07/25/01 JosephJ Created
  15. //
  16. //***************************************************************************
  17. #pragma once
  18. //
  19. // This class deliberately causes the following errors...
  20. // CNoCopy xx;
  21. // CNoCopy yy = xx; << Will cause compiler error
  22. // CNoCopy zz;
  23. // zz = xx; << Will cause compiler error
  24. //
  25. // Inheret from it if you want your class to also forbid the above operations.
  26. //
  27. class CNoCopy
  28. {
  29. protected:
  30. CNoCopy(void) {}
  31. ~CNoCopy() {}
  32. private:
  33. CNoCopy(const CNoCopy&);
  34. CNoCopy& operator = (const CNoCopy&);
  35. };
  36. typedef ULONG ENGINEHANDLE;
  37. //
  38. // Specification, or settings of a cluster.
  39. // This includes the list of interfacees (i.e., specific adapters on
  40. // specific hosts) that constitute the cluster.
  41. //
  42. class CClusterSpec // : private CNoCopy
  43. {
  44. public:
  45. CClusterSpec(void)
  46. : m_fMisconfigured(FALSE),
  47. m_fPending(FALSE),
  48. m_ehDefaultInterface(NULL),
  49. m_ehPendingOperation(NULL),
  50. m_fNewRctPassword(NULL)
  51. {
  52. // can't do this (vector)! ZeroMemory(this, sizeof(*this));
  53. ZeroMemory(&m_timeLastUpdate, sizeof(m_timeLastUpdate));
  54. }
  55. ~CClusterSpec() {}
  56. NLBERROR
  57. Copy(const CClusterSpec &);
  58. NLBERROR
  59. UpdateClusterConfig(
  60. const NLB_EXTENDED_CLUSTER_CONFIGURATION &refNewConfig
  61. )
  62. {
  63. NLBERROR nerr = NLBERR_OK;
  64. WBEMSTATUS wStat;
  65. wStat = m_ClusterNlbCfg.Update(&refNewConfig);
  66. if (FAILED(wStat))
  67. {
  68. nerr = NLBERR_INTERNAL_ERROR;
  69. }
  70. return nerr;
  71. }
  72. // _bstr_t m_bstrId; // Uniquely identifies this cluster in NLB Manager.
  73. _bstr_t m_bstrDisplayName; // Name use for display only (eg: "Cluster1");
  74. BOOL m_fMisconfigured; // Whether or not the cluster is misconfigured.
  75. BOOL m_fPending; // Whether or not there is a pending operation on
  76. // this cluster.
  77. BOOL m_fNewRctPassword; // A new remote-control password is specified
  78. // As long as it is set, the dwHashedPassword
  79. // value can not be trusted.
  80. //
  81. // List of interfaces that form this cluster.
  82. //
  83. vector<ENGINEHANDLE> m_ehInterfaceIdList;
  84. SYSTEMTIME m_timeLastUpdate;
  85. //
  86. // ClusterNlbCfg is the "official" NLB configuration for the cluster.
  87. // It is obtained from one of the hosts.
  88. //
  89. NLB_EXTENDED_CLUSTER_CONFIGURATION m_ClusterNlbCfg;
  90. //
  91. // The host that was last used to get the cluster config.
  92. //
  93. ENGINEHANDLE m_ehDefaultInterface;
  94. ENGINEHANDLE m_ehPendingOperation;
  95. };
  96. //
  97. // Specification, or settings of a host. This includes the list of
  98. // NLB compatible interfaces on the host, machine name, machine GUID,
  99. // connection string, etc.
  100. //
  101. class CHostSpec // : private CNoCopy
  102. {
  103. public:
  104. CHostSpec(void)
  105. : m_fReal(FALSE),
  106. m_fUnreachable(FALSE),
  107. m_ConnectionIpAddress(0)
  108. {
  109. // can't do this! ZeroMemory(this, sizeof(*this));
  110. }
  111. ~CHostSpec() {}
  112. void Copy(const CHostSpec &);
  113. BOOL m_fReal; // Whether or not this host is known to correspond
  114. // to real hosts.
  115. BOOL m_fUnreachable; // Whether or not this host is contactable.
  116. // to real hosts.
  117. //
  118. // List of NLB-compatible interfaces (adapters) on this host.
  119. //
  120. vector<ENGINEHANDLE> m_ehInterfaceIdList;
  121. //
  122. // Connection info.
  123. //
  124. _bstr_t m_ConnectionString;
  125. _bstr_t m_UserName;
  126. _bstr_t m_Password;
  127. ULONG m_ConnectionIpAddress; // in network byte order.
  128. _bstr_t m_MachineName;
  129. _bstr_t m_MachineGuid;
  130. };
  131. //
  132. // Specification, or settings of a specific interface (adapter) on a specifc
  133. // host. This includes the NLB configuration on that interface, ip addresses
  134. // bound to the interface, friendly name of the interface, etc.
  135. //
  136. class CInterfaceSpec // : private CNoCopy
  137. {
  138. public:
  139. CInterfaceSpec(void)
  140. : m_fPending(FALSE),
  141. m_fMisconfigured(FALSE),
  142. m_fReal(FALSE),
  143. m_ehHostId(NULL),
  144. m_ehCluster(NULL),
  145. m_fValidClusterState(FALSE),
  146. m_ehPendingOperation(FALSE)
  147. {
  148. // can't do this! ZeroMemory(this, sizeof(*this));
  149. }
  150. ~CInterfaceSpec() {}
  151. void Copy(const CInterfaceSpec &);
  152. ENGINEHANDLE m_ehHostId; // The ID of the host that owns this interface.
  153. ENGINEHANDLE m_ehCluster; // The ID of the cluster that this interface is
  154. // a part of, if any.
  155. BOOL m_fPending; // Whether or not there is a pending operation on
  156. // this host.
  157. BOOL m_fMisconfigured; // Whether or not the cluster is misconfigured.
  158. BOOL m_fReal; // Whether or not this cluster is known to correspond
  159. // to real hosts.
  160. BOOL m_fValidClusterState; // Whether or not the "m_dwClusterState" contains a valid value
  161. DWORD m_dwClusterState; // Cluster State : If valid (ie. if m_fValidClusterState is TRUE)
  162. // One of WLBS_CONVERGING/CONVERGED/DEFAULT/DRAINING/STOPPED/SUSPENDED
  163. _bstr_t m_Guid;
  164. _bstr_t m_bstrMachineName; // Cache of the host name -- so we don't have to
  165. // keep looking up the host info just for getting
  166. // the host's name.
  167. NLB_EXTENDED_CLUSTER_CONFIGURATION m_NlbCfg;
  168. _bstr_t m_bstrStatusDetails; // Details (if any) of ongoing updates or
  169. // misconfiguration.
  170. ENGINEHANDLE m_ehPendingOperation;
  171. };
  172. //
  173. // Abstract class (interface) for callbacks to the UI to provide status
  174. // updates and logging etc...
  175. //
  176. class IUICallbacks
  177. {
  178. public:
  179. typedef enum
  180. {
  181. OBJ_INVALID=0,
  182. OBJ_CLUSTER,
  183. OBJ_HOST,
  184. OBJ_INTERFACE,
  185. OBJ_OPERATION
  186. } ObjectType;
  187. typedef enum
  188. {
  189. EVT_ADDED,
  190. EVT_REMOVED,
  191. EVT_STATUS_CHANGE,
  192. EVT_INTERFACE_ADDED_TO_CLUSTER,
  193. EVT_INTERFACE_REMOVED_FROM_CLUSTER
  194. } EventCode;
  195. typedef enum
  196. {
  197. LOG_ERROR,
  198. LOG_WARNING,
  199. LOG_INFORMATIONAL
  200. } LogEntryType;
  201. class LogEntryHeader
  202. {
  203. public:
  204. LogEntryHeader(void)
  205. : type(LOG_INFORMATIONAL),
  206. szCluster(NULL),
  207. szHost(NULL),
  208. szInterface(NULL),
  209. szDetails(NULL)
  210. {}
  211. LogEntryType type;
  212. const wchar_t *szCluster; // OPTIONAL
  213. const wchar_t *szHost; // OPTIONAL
  214. const wchar_t *szInterface; // OPTIONAL
  215. const wchar_t *szDetails; // OPTIONAL
  216. };
  217. //
  218. // Asks the user to update user-supplied info about a host.
  219. //
  220. virtual
  221. BOOL
  222. UpdateHostInformation(
  223. IN BOOL fNeedCredentials,
  224. IN BOOL fNeedConnectionString,
  225. IN OUT CHostSpec& host
  226. ) = NULL;
  227. //
  228. // Log a message in human-readable form.
  229. //
  230. virtual
  231. void
  232. Log(
  233. IN LogEntryType Type,
  234. IN const wchar_t *szCluster, OPTIONAL
  235. IN const wchar_t *szHost, OPTIONAL
  236. IN UINT ResourceID,
  237. ...
  238. ) = NULL;
  239. virtual
  240. void
  241. LogEx(
  242. IN const LogEntryHeader *pHeader,
  243. IN UINT ResourceID,
  244. ...
  245. ) = NULL;
  246. //
  247. // Handle an event relating to a specific instance of a specific
  248. // object type.
  249. //
  250. virtual
  251. void
  252. HandleEngineEvent(
  253. IN ObjectType objtype,
  254. IN ENGINEHANDLE ehClusterId, // could be NULL
  255. IN ENGINEHANDLE ehObjId,
  256. IN EventCode evt
  257. ) = NULL;
  258. };
  259. //
  260. // Used internally by CNlbEngine
  261. //
  262. class CEngineCluster
  263. {
  264. public:
  265. CEngineCluster(VOID)
  266. {
  267. }
  268. ~CEngineCluster() {};
  269. CClusterSpec m_cSpec;
  270. };
  271. class CEngineOperation
  272. {
  273. public:
  274. CEngineOperation(ENGINEHANDLE ehOp, ENGINEHANDLE ehObj, PVOID pvCtxt)
  275. : ehOperation(ehOp),
  276. ehObject(ehObj),
  277. pvContext(pvCtxt),
  278. fCanceled(FALSE)
  279. {}
  280. ~CEngineOperation()
  281. {
  282. }
  283. ENGINEHANDLE ehOperation;
  284. ENGINEHANDLE ehObject;
  285. _bstr_t bstrDescription;
  286. BOOL fCanceled;
  287. PVOID pvContext;
  288. };
  289. class CNlbEngine
  290. {
  291. public:
  292. CNlbEngine(void)
  293. : m_pCallbacks(NULL),
  294. m_NewHandleValue(1),
  295. m_fHandleOverflow(FALSE),
  296. m_fDeinitializing(FALSE),
  297. m_fPrepareToDeinitialize(FALSE),
  298. m_WorkItemCount(0)
  299. {
  300. InitializeCriticalSection(&m_crit);
  301. }
  302. ~CNlbEngine()
  303. {
  304. ASSERT(m_WorkItemCount > 0);
  305. DeleteCriticalSection(&m_crit);
  306. }
  307. NLBERROR
  308. Initialize(
  309. IN IUICallbacks & ui,
  310. BOOL fDemo,
  311. BOOL fNoPing
  312. ); // logging, UI callbacks of various kinds.
  313. void
  314. Deinitialize(void);
  315. //
  316. // Called to indicate that deinitialization will soon follow.
  317. // After return from this call, the engine will not create any new
  318. // objects -- interface, host, cluster, operations or start operations.
  319. // The engine may however continue to call the UI callback routines.
  320. //
  321. void
  322. PrepareToDeinitialize(void)
  323. {
  324. m_fPrepareToDeinitialize = TRUE;
  325. }
  326. NLBERROR
  327. ConnectToHost(
  328. IN PWMI_CONNECTION_INFO pConnInfo,
  329. IN BOOL fOverwriteConnectionInfo,
  330. OUT ENGINEHANDLE &ehHost,
  331. OUT _bstr_t &bstrError
  332. );
  333. NLBERROR
  334. LookupClusterByIP(
  335. IN LPCWSTR szIP,
  336. IN const NLB_EXTENDED_CLUSTER_CONFIGURATION *pInitialConfig OPTIONAL,
  337. OUT ENGINEHANDLE &ehCluster,
  338. OUT BOOL &fIsNew
  339. );
  340. //
  341. // if pInitialConfig is NULL we'll lookup and not try to create.
  342. // if not NULL and we don't find an existing cluster, well create
  343. // a new one and initialize it with the specified configuration.
  344. //
  345. NLBERROR
  346. LookupInterfaceByIp(
  347. IN ENGINEHANDLE ehHost, // OPTIONAL -- if NULL all hosts are looked
  348. IN LPCWSTR szIpAddress,
  349. OUT ENGINEHANDLE &ehIf
  350. );
  351. NLBERROR
  352. LookupConnectionInfo(
  353. IN LPCWSTR szConnectionString,
  354. OUT _bstr_t &bstrUsername,
  355. OUT _bstr_t &bstrPassword
  356. );
  357. void
  358. DeleteCluster(IN ENGINEHANDLE ehCluster, BOOL fRemoveInterfaces);
  359. NLBERROR
  360. AutoExpandCluster(
  361. IN ENGINEHANDLE ehCluster
  362. );
  363. NLBERROR
  364. AddInterfaceToCluster(
  365. IN ENGINEHANDLE ehCluster,
  366. IN ENGINEHANDLE ehInterface
  367. );
  368. NLBERROR
  369. RemoveInterfaceFromCluster(
  370. IN ENGINEHANDLE ehCluster,
  371. IN ENGINEHANDLE ehInterface
  372. );
  373. NLBERROR
  374. RefreshAllHosts(
  375. void
  376. );
  377. NLBERROR
  378. RefreshCluster(
  379. IN ENGINEHANDLE ehCluster
  380. );
  381. #if OBSOLETE
  382. NLBERROR
  383. RefreshInterfaceOld(
  384. IN ENGINEHANDLE ehInterface,
  385. IN BOOL fRemoveFromClusterIfUnbound,
  386. IN OUT BOOL &fClusterPropertiesUpdated
  387. );
  388. #endif // OBSOLETE
  389. //
  390. // Queries the host that owns the interface for other
  391. // cluster members, and connects to those and adds those
  392. // members to the cluster.
  393. //
  394. // If (fSync) it will do this synchronously, else it will do it
  395. // in the background.
  396. //
  397. VOID
  398. AddOtherClusterMembers(
  399. IN ENGINEHANDLE ehInterface,
  400. IN BOOL fSync
  401. );
  402. //
  403. // Only call this from the background thread work item thread
  404. // (i.e., not really a public function, but I don't like using
  405. // "friend").
  406. //
  407. VOID
  408. AddOtherClusterMembersWorkItem(
  409. IN ENGINEHANDLE ehInterface
  410. );
  411. NLBERROR
  412. RefreshInterface(
  413. IN ENGINEHANDLE ehInterface,
  414. IN BOOL fNewOperation,
  415. IN BOOL fClusterWide
  416. );
  417. NLBERROR
  418. AnalyzeCluster(
  419. const ENGINEHANDLE ehCluster
  420. );
  421. NLBERROR
  422. GetHostSpec(
  423. IN ENGINEHANDLE ehHost,
  424. OUT CHostSpec& HostSpec
  425. );
  426. NLBERROR
  427. GetHostConnectionInformation(
  428. IN ENGINEHANDLE ehHost,
  429. OUT ENGINEHANDLE &ehConnectionIF,
  430. OUT _bstr_t &bstrConnectionString,
  431. OUT UINT &uConnectionIp
  432. );
  433. NLBERROR
  434. GetClusterSpec(
  435. IN ENGINEHANDLE ehCluster,
  436. OUT CClusterSpec& ClusterSpec
  437. );
  438. NLBERROR
  439. GetInterfaceSpec(
  440. IN ENGINEHANDLE ehInterface,
  441. OUT CInterfaceSpec&
  442. );
  443. NLBERROR
  444. UpdateInterface(
  445. IN ENGINEHANDLE ehInterface,
  446. IN NLB_EXTENDED_CLUSTER_CONFIGURATION &refNewConfig,
  447. // IN OUT BOOL &fClusterPropertiesUpdated,
  448. OUT CLocalLogger logConflict
  449. );
  450. NLBERROR
  451. UpdateCluster(
  452. IN ENGINEHANDLE ehCluster,
  453. IN const NLB_EXTENDED_CLUSTER_CONFIGURATION *pNewConfig OPTIONAL,
  454. IN OUT CLocalLogger &logConflict
  455. );
  456. NLBERROR
  457. EnumerateClusters(
  458. OUT vector <ENGINEHANDLE> & ehClusterList
  459. );
  460. NLBERROR
  461. EnumerateHosts(
  462. OUT vector <ENGINEHANDLE> & ehHostList
  463. );
  464. BOOL
  465. GetObjectType(
  466. IN ENGINEHANDLE ehObj,
  467. OUT IUICallbacks::ObjectType &objType
  468. );
  469. //
  470. // Return a bitmap of available host IDs for the specified cluster.
  471. //
  472. ULONG
  473. GetAvailableHostPriorities(
  474. ENGINEHANDLE ehCluster // OPTIONAL
  475. );
  476. //
  477. // Fill in an array of bitmaps of available priorities for each specified
  478. // port rule.
  479. //
  480. NLBERROR
  481. GetAvailablePortRulePriorities(
  482. IN ENGINEHANDLE ehCluster, OPTIONAL
  483. IN UINT NumRules,
  484. IN WLBS_PORT_RULE rgRules[],
  485. IN OUT ULONG rgAvailablePriorities[] // At least NumRules
  486. );
  487. NLBERROR
  488. GetAllHostConnectionStrings(
  489. OUT vector <_bstr_t> & ConnectionStringList
  490. );
  491. NLBERROR
  492. ControlClusterOnInterface(
  493. IN ENGINEHANDLE ehInterfaceId,
  494. IN WLBS_OPERATION_CODES Operation,
  495. IN CString szVipArray[],
  496. IN DWORD pdwPortNumArray[],
  497. IN DWORD dwNumOfPortRules,
  498. IN BOOL fNewOperation
  499. );
  500. NLBERROR
  501. ControlClusterOnCluster(
  502. IN ENGINEHANDLE ehClusterId,
  503. IN WLBS_OPERATION_CODES Operation,
  504. IN CString szVipArray[],
  505. IN DWORD pdwPortNumArray[],
  506. IN DWORD dwNumOfPortRules
  507. );
  508. NLBERROR
  509. FindInterfaceOnHostByClusterIp(
  510. IN ENGINEHANDLE ehHostId,
  511. IN LPCWSTR szClusterIp, // OPTIONAL
  512. OUT ENGINEHANDLE &ehInterfaceId, // first found
  513. OUT UINT &NumFound
  514. );
  515. NLBERROR
  516. InitializeNewHostConfig(
  517. IN ENGINEHANDLE ehClusterId,
  518. OUT NLB_EXTENDED_CLUSTER_CONFIGURATION &NlbCfg
  519. );
  520. static // TODO: move somewhere else -- more a utility function.
  521. NLBERROR
  522. ApplyClusterWideConfiguration(
  523. IN const NLB_EXTENDED_CLUSTER_CONFIGURATION &ClusterConfig,
  524. IN OUT NLB_EXTENDED_CLUSTER_CONFIGURATION &ConfigToUpdate
  525. );
  526. NLBERROR
  527. GetInterfaceInformation(
  528. IN ENGINEHANDLE ehInterface,
  529. OUT CHostSpec& hSpec,
  530. OUT CInterfaceSpec& iSpec,
  531. OUT _bstr_t& bstrDisplayName,
  532. OUT INT& iIcon,
  533. OUT _bstr_t& bstrStatus
  534. );
  535. NLBERROR
  536. GetInterfaceIdentification(
  537. IN ENGINEHANDLE ehInterface,
  538. OUT ENGINEHANDLE& ehHost,
  539. OUT ENGINEHANDLE& ehCluster,
  540. OUT _bstr_t & bstrFriendlyName,
  541. OUT _bstr_t & bstrDisplayName,
  542. OUT _bstr_t & bstrHostName
  543. );
  544. NLBERROR
  545. GetClusterIdentification(
  546. IN ENGINEHANDLE ehCluster,
  547. OUT _bstr_t & bstrIpAddress,
  548. OUT _bstr_t & bstrDomainName,
  549. OUT _bstr_t & bstrDisplayName
  550. );
  551. //
  552. // Verify that the specified ip address may be used as a new cluster IP
  553. // address for the specified existing cluster ehCluster (or a new
  554. // cluster, if ehCluster is NULL).
  555. //
  556. // If there is no conflict (i.e. address can be used), the function returns
  557. // NLBERR_OK.
  558. //
  559. // If the IP address is already used for something, that "something"
  560. // is specified in logConflict and the function returns
  561. // NLBERR_INVALID_IP_ADDRESS_SPECIFICATION.
  562. //
  563. // If the IP address already exists on an interface that is NOT
  564. // part of a cluster known to NLBManager, fExistOnRawInterface is set
  565. // to TRUE, else fExistOnRawInterface is set to FALSE.
  566. //
  567. NLBERROR
  568. ValidateNewClusterIp(
  569. IN ENGINEHANDLE ehCluster, // OPTIONAL
  570. IN LPCWSTR szIp,
  571. OUT BOOL &fExistsOnRawIterface,
  572. IN OUT CLocalLogger &logConflict
  573. );
  574. //
  575. // Verify that the specified ip address may be used as the dedicated IP
  576. // address for the specified existing interface.
  577. //
  578. // If there is no conflict (i.e. address can be used), the function returns
  579. // NLBERR_OK.
  580. //
  581. // If the IP address is already used for something, that "something"
  582. // is specified in logConflict and the function returns
  583. // NLBERR_INVALID_IP_ADDRESS_SPECIFICATION.
  584. //
  585. NLBERROR
  586. ValidateNewDedicatedIp(
  587. IN ENGINEHANDLE ehIF,
  588. IN LPCWSTR szIp,
  589. IN OUT CLocalLogger &logConflict
  590. );
  591. //
  592. // Updates the specified interface, assuming it has already been set up
  593. // to do an update in the background -- this function is ONLY
  594. // called from the work-item thread internally to CNlbEngine.
  595. //
  596. VOID
  597. UpdateInterfaceWorkItem(
  598. IN ENGINEHANDLE ehIF
  599. );
  600. //
  601. // If it's possible to start an interface operation at this time,
  602. // the function returns NLB_OK, setting fCanStart to TRUE.
  603. //
  604. // If it can't start an interface, because there is an existing interface
  605. // operation or a cluster operation ongoing, the function returns NLB_OK,
  606. // and sets fCanStart to FALSE.
  607. //
  608. // Otherwise (some kind of error) it returns an error value.
  609. //
  610. NLBERROR
  611. CanStartInterfaceOperation(
  612. IN ENGINEHANDLE ehIF,
  613. OUT BOOL &fCanStart
  614. );
  615. //
  616. // Similar to CanStartInterfaceOperation, except it applies to the specified
  617. // cluster.
  618. //
  619. NLBERROR
  620. CanStartClusterOperation(
  621. IN ENGINEHANDLE ehCluster,
  622. OUT BOOL &fCanStart
  623. );
  624. UINT
  625. ListPendingOperations(
  626. CLocalLogger &logOperations
  627. );
  628. //
  629. // Mark all pending operations as cancelled.
  630. // If (fBlock), will block until no more operations are pending.
  631. //
  632. void
  633. CancelAllPendingOperations(
  634. BOOL fBlock
  635. );
  636. //
  637. // Attempts to connect to the specified host and manages
  638. // the specified cluster (szClusterIp) under nlb manager.
  639. // If szClusterIp is NULL, it will manage all clusters on the host.
  640. //
  641. NLBERROR
  642. LoadHost(
  643. IN PWMI_CONNECTION_INFO pConnInfo,
  644. IN LPCWSTR szClusterIp OPTIONAL
  645. );
  646. VOID
  647. AnalyzeInterface_And_LogResult(ENGINEHANDLE ehIID);
  648. //
  649. // Goes through all hosts, and deletes any that have no interface
  650. // that is being managed as a cluster in Nlbmgr.exe. Will skip (not delete)
  651. // hosts that have pending operations on them.
  652. //
  653. VOID
  654. PurgeUnmanagedHosts(void);
  655. VOID
  656. UnmanageHost(ENGINEHANDLE ehHost);
  657. private:
  658. IUICallbacks *m_pCallbacks;
  659. CRITICAL_SECTION m_crit;
  660. void mfn_Lock(void) {EnterCriticalSection(&m_crit);}
  661. void mfn_Unlock(void) {LeaveCriticalSection(&m_crit);}
  662. NLBERROR
  663. mfn_RefreshHost(
  664. IN PWMI_CONNECTION_INFO pConnInfo,
  665. IN ENGINEHANDLE ehHost,
  666. IN BOOL fOverwriteConnectionInfo
  667. );
  668. NLBERROR
  669. mfn_GetHostFromInterfaceLk(
  670. IN ENGINEHANDLE ehIId,
  671. OUT CInterfaceSpec* &pISpec,
  672. OUT CHostSpec* &pHSpec
  673. );
  674. void
  675. mfn_GetInterfaceHostNameLk(
  676. ENGINEHANDLE ehIId,
  677. _bstr_t &bstrHostName
  678. );
  679. NLBERROR
  680. mfn_LookupHostByNameLk(
  681. IN LPCWSTR szHostName,
  682. IN BOOL fCreate,
  683. OUT ENGINEHANDLE &ehHost,
  684. OUT CHostSpec* &pHostSpec,
  685. OUT BOOL &fIsNew
  686. );
  687. NLBERROR
  688. mfn_LookupInterfaceByGuidLk(
  689. IN LPCWSTR szInterfaceGuid,
  690. IN BOOL fCreate,
  691. OUT ENGINEHANDLE &ehInterface,
  692. OUT CInterfaceSpec* &pISpec,
  693. OUT BOOL &fIsNew
  694. );
  695. NLBERROR
  696. mfn_LookupInterfaceByIpLk(
  697. IN ENGINEHANDLE ehHost, // OPTIONAL -- if NULL all hosts are looked
  698. IN LPCWSTR szIpAddress,
  699. OUT ENGINEHANDLE &ehIf
  700. );
  701. VOID
  702. CNlbEngine::mfn_NotifyHostInterfacesChange(ENGINEHANDLE ehHost);
  703. VOID
  704. mfn_ReallyUpdateInterface(
  705. IN ENGINEHANDLE ehInterface,
  706. IN NLB_EXTENDED_CLUSTER_CONFIGURATION &refNewConfig
  707. // IN OUT BOOL &fClusterPropertiesUpdated
  708. );
  709. VOID
  710. mfn_GetLogStrings(
  711. IN WLBS_OPERATION_CODES Operation,
  712. IN LPCWSTR szVip,
  713. IN DWORD * pdwPortNum,
  714. IN DWORD dwOperationStatus,
  715. IN DWORD dwClusterOrPortStatus,
  716. OUT IUICallbacks::LogEntryType & LogLevel,
  717. OUT _bstr_t & OperationStr,
  718. OUT _bstr_t & OperationStatusStr,
  719. OUT _bstr_t & ClusterOrPortStatusStr
  720. );
  721. NLBERROR
  722. mfn_AnalyzeInterfaceLk(
  723. ENGINEHANDLE ehInterface,
  724. CLocalLogger &logger
  725. );
  726. NLBERROR
  727. mfn_ClusterOrInterfaceOperationsPendingLk(
  728. IN CEngineCluster *pECluster,
  729. OUT BOOL &fCanStart
  730. );
  731. VOID
  732. mfn_DeleteHostIfNotManagedLk(
  733. ENGINEHANDLE ehHost
  734. );
  735. map< ENGINEHANDLE, CEngineCluster* > m_mapIdToEngineCluster;
  736. map< ENGINEHANDLE, CHostSpec* > m_mapIdToHostSpec;
  737. map< ENGINEHANDLE, CInterfaceSpec* > m_mapIdToInterfaceSpec;
  738. map< ENGINEHANDLE, CEngineOperation* > m_mapIdToOperation;
  739. //
  740. // Following is dummy...
  741. //
  742. map< _bstr_t, ENGINEHANDLE> m_mapHostNameToHostId;
  743. //
  744. // Used to create new handle values.
  745. // Incremented using InterlockedIncrement each time
  746. // a new handle value is reached.
  747. // 0 is an invalid handle value,
  748. //
  749. LONG m_NewHandleValue;
  750. BOOL m_fHandleOverflow;
  751. BOOL m_fDeinitializing;
  752. BOOL m_fPrepareToDeinitialize;
  753. //
  754. // Count of outstanding work items -- maintained by
  755. // InterlockedIncrement/Decrement.
  756. // CancelAllPendingOperations waits for this count to go to zero
  757. // before returning.
  758. //
  759. // Also, the destructor blocks until this count goes to zero.
  760. //
  761. LONG m_WorkItemCount;
  762. ENGINEHANDLE
  763. mfn_NewHandleLk(IUICallbacks::ObjectType);
  764. void
  765. mfn_SetInterfaceMisconfigStateLk(
  766. IN CInterfaceSpec *pIF,
  767. IN BOOL fMisconfig,
  768. IN LPCWSTR szMisconfigDetails
  769. );
  770. BOOL
  771. mfn_HostHasManagedClustersLk(CHostSpec *pHSpec);
  772. void
  773. mfn_UpdateInterfaceStatusDetails(ENGINEHANDLE ehIF, LPCWSTR szDetails);
  774. CEngineOperation *
  775. mfn_NewOperationLk(ENGINEHANDLE ehObj, PVOID pvCtxt, LPCWSTR szDescription);
  776. VOID
  777. mfn_DeleteOperationLk(ENGINEHANDLE ehOperation);
  778. CEngineOperation *
  779. mfn_GetOperationLk(ENGINEHANDLE ehOp);
  780. NLBERROR
  781. mfn_StartInterfaceOperationLk(
  782. IN ENGINEHANDLE ehIF,
  783. IN PVOID pvCtxt,
  784. IN LPCWSTR szDescription,
  785. OUT ENGINEHANDLE *pExistingOperation
  786. );
  787. VOID
  788. mfn_StopInterfaceOperationLk(
  789. IN ENGINEHANDLE ehIF
  790. );
  791. NLBERROR
  792. mfn_StartClusterOperationLk(
  793. IN ENGINEHANDLE ehCluster,
  794. IN PVOID pvCtxt,
  795. IN LPCWSTR szDescription,
  796. OUT ENGINEHANDLE *pExistingOperation
  797. );
  798. VOID
  799. mfn_StopClusterOperationLk(
  800. ENGINEHANDLE ehCluster
  801. );
  802. NLBERROR
  803. mfn_RefreshInterface(
  804. IN ENGINEHANDLE ehInterface
  805. );
  806. BOOL
  807. mfn_UpdateClusterProps(
  808. ENGINEHANDLE ehClusterId,
  809. ENGINEHANDLE ehIId
  810. );
  811. //
  812. // Waits for the count of pending operations on interfaces in this cluster
  813. // got go to zero.
  814. //
  815. NLBERROR
  816. mfn_WaitForInterfaceOperationCompletions(
  817. IN ENGINEHANDLE ehCluster
  818. );
  819. //
  820. // Verifies that all interfaces and the cluster have the same cluster mode.
  821. //
  822. // Will fail if any interface is marked misconfigured or is
  823. // not bound to NLB.
  824. //
  825. // On returning success, fSameMode is set to TRUE iff all IFs and the
  826. // cluster have the same mode.
  827. //
  828. NLBERROR
  829. mfn_VerifySameModeLk(
  830. IN ENGINEHANDLE ehCluster,
  831. OUT BOOL &fSameMode
  832. );
  833. //
  834. // Check connectivity to the host. If not available mark
  835. // it as such. Update the UI.
  836. //
  837. NLBERROR
  838. mfn_CheckHost(
  839. IN PWMI_CONNECTION_INFO pConnInfo,
  840. IN ENGINEHANDLE ehHost // OPTIONAL
  841. );
  842. VOID
  843. mfn_UnlinkHostFromClusters(
  844. IN ENGINEHANDLE ehHost
  845. );
  846. };