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.

863 lines
26 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. scope.cpp
  7. This file contains all of the prototypes for the DHCP
  8. scope object and all objects that it may contain.
  9. They include:
  10. CDhcpScope
  11. CDhcpReservations
  12. CDhcpReservationClient
  13. CDhcpActiveLeases
  14. CDhcpAddressPool
  15. CDhcpScopeOptions
  16. FILE HISTORY:
  17. */
  18. #ifndef _SCOPE_H
  19. #define _SCOPE_H
  20. #ifndef _SCOPSTAT_H
  21. #include "scopstat.h" // Scope statistics
  22. #endif
  23. #ifndef _DHCPHAND_H
  24. #include "dhcphand.h"
  25. #endif
  26. #ifndef _SERVER_H
  27. #include "server.h"
  28. #endif
  29. class CDhcpScope;
  30. class CDhcpAddressPool;
  31. class CDhcpReservations;
  32. class CDhcpActiveLeases;
  33. class CDhcpActiveLease;
  34. class CDhcpScopeOptions;
  35. #define DHCP_QDATA_SUBNET_INFO 0x00000004
  36. /*---------------------------------------------------------------------------
  37. Class: QSort compare routine for sorting ip addresses in an array.
  38. ----------------------------------------------------------------------------*/
  39. int __cdecl QCompare( const void *ip1, const void *ip2 );
  40. /*---------------------------------------------------------------------------
  41. Class: CDhcpScope
  42. ---------------------------------------------------------------------------*/
  43. class CDhcpScope : public CMTDhcpHandler
  44. {
  45. public:
  46. CDhcpScope
  47. (
  48. ITFSComponentData * pComponentData,
  49. DHCP_IP_ADDRESS dhcpScopeIp,
  50. DHCP_IP_MASK dhcpSubnetMask,
  51. LPCWSTR pName,
  52. LPCWSTR pComment,
  53. DHCP_SUBNET_STATE dhcpSubnetState = DhcpSubnetDisabled
  54. );
  55. CDhcpScope(ITFSComponentData * pComponentData, LPDHCP_SUBNET_INFO pdhcpSubnetInfo);
  56. CDhcpScope(ITFSComponentData * pComponentData, CSubnetInfo & subnetInfo);
  57. ~CDhcpScope();
  58. // Interface
  59. public:
  60. // Node handler functionality we override
  61. OVERRIDE_NodeHandler_HasPropertyPages();
  62. OVERRIDE_NodeHandler_CreatePropertyPages();
  63. OVERRIDE_NodeHandler_OnAddMenuItems();
  64. OVERRIDE_NodeHandler_OnCommand();
  65. OVERRIDE_NodeHandler_GetString();
  66. OVERRIDE_NodeHandler_DestroyHandler();
  67. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  68. // choose the notifications that we want to handle
  69. OVERRIDE_BaseHandlerNotify_OnDelete();
  70. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  71. // Result handler functionality we override
  72. public:
  73. // CDhcpHandler overrides
  74. virtual HRESULT InitializeNode(ITFSNode * pNode);
  75. virtual DWORD UpdateStatistics(ITFSNode * pNode);
  76. HRESULT OnUpdateToolbarButtons(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  77. int GetImageIndex(BOOL bOpenImage);
  78. // CMTDhcpHandler overrides
  79. virtual void OnHaveData(ITFSNode * pParent, ITFSNode * pNew);
  80. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type);
  81. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  82. public:
  83. void SetServer(ITFSNode * pServerNode) { m_spServerNode.Set(pServerNode); }
  84. // public functions for scope manipulation
  85. LPCWSTR GetName() { return m_strName; };
  86. HRESULT SetName(LPCWSTR pName);
  87. LPCWSTR GetComment() { return m_strComment; };
  88. void SetComment(LPCWSTR pComment) { m_strComment = pComment; };
  89. DWORD UpdateIpRange(DHCP_IP_RANGE * pdhipr);
  90. DWORD SetIpRange(DHCP_IP_RANGE *pdhcpIpRange, BOOL bSetOnServer);
  91. DWORD SetIpRange(CDhcpIpRange & dhcpIpRange, BOOL bSetOnServer);
  92. void QueryIpRange (DHCP_IP_RANGE * pdhipr);
  93. DWORD GetIpRange (CDhcpIpRange * pdhipr);
  94. DHCP_IP_MASK QuerySubnetMask() { return m_dhcpSubnetMask; };
  95. DHCP_IP_ADDRESS GetAddress() { return m_dhcpIpAddress; }
  96. DWORD AddElement(DHCP_SUBNET_ELEMENT_DATA * pdhcpSubnetElementData);
  97. DWORD RemoveElement(DHCP_SUBNET_ELEMENT_DATA * pdhcpSubnetElementData, BOOL bForce = FALSE);
  98. // NT4 SP2 added functionality
  99. DWORD AddElementV4(DHCP_SUBNET_ELEMENT_DATA_V4 * pdhcpSubnetElementData);
  100. DWORD RemoveElementV4(DHCP_SUBNET_ELEMENT_DATA_V4 * pdhcpSubnetElementData, BOOL bForce = FALSE);
  101. // NT5 functionality
  102. DWORD AddElementV5(DHCP_SUBNET_ELEMENT_DATA_V5 * pdhcpSubnetElementData);
  103. DWORD RemoveElementV5(DHCP_SUBNET_ELEMENT_DATA_V5 * pdhcpSubnetElementData, BOOL bForce = FALSE);
  104. LPCWSTR GetServerIpAddress();
  105. void GetServerIpAddress(DHCP_IP_ADDRESS * pdhcpIpAddress);
  106. void GetServerVersion(LARGE_INTEGER& liVersion);
  107. CDhcpReservations * GetReservationsObject();
  108. CDhcpActiveLeases * GetActiveLeasesObject();
  109. CDhcpAddressPool * GetAddressPoolObject();
  110. CDhcpScopeOptions * GetScopeOptionsObject();
  111. HRESULT GetReservationsNode(ITFSNode ** ppNode)
  112. {
  113. Assert(ppNode);
  114. SetI((LPUNKNOWN *) ppNode, m_spReservations);
  115. return hrOK;
  116. }
  117. HRESULT GetActiveLeasesNode(ITFSNode ** ppNode)
  118. {
  119. Assert(ppNode);
  120. SetI((LPUNKNOWN *) ppNode, m_spActiveLeases);
  121. return hrOK;
  122. }
  123. HRESULT GetScopeOptionsNode(ITFSNode ** ppNode)
  124. {
  125. Assert(ppNode);
  126. SetI((LPUNKNOWN *) ppNode, m_spOptions);
  127. return hrOK;
  128. }
  129. HRESULT GetAddressPoolNode(ITFSNode ** ppNode)
  130. {
  131. Assert(ppNode);
  132. SetI((LPUNKNOWN *) ppNode, m_spAddressPool);
  133. return hrOK;
  134. }
  135. // reservation functionality
  136. DWORD CreateReservation(const CDhcpClient * pClient);
  137. DWORD AddReservation(const CDhcpClient *pClient);
  138. DWORD DeleteReservation(CByteArray& baHardwareAddress, DHCP_IP_ADDRESS dhcpReservedIpAddress);
  139. DWORD DeleteReservation(DHCP_CLIENT_UID &dhcpClientUID, DHCP_IP_ADDRESS dhcpReservedIpAddress);
  140. DWORD UpdateReservation(const CDhcpClient * pClient, COptionValueEnum * pOptionValueEnum);
  141. DWORD RestoreReservationOptions(const CDhcpClient * pClient, COptionValueEnum * pOptionValueEnum);
  142. // lease functionality
  143. DWORD CreateClient(const CDhcpClient * pClient);
  144. DWORD SetClientInfo(const CDhcpClient * pClient);
  145. DWORD GetClientInfo(DHCP_IP_ADDRESS dhcpClientIpAddress, LPDHCP_CLIENT_INFO * pdhcpClientInfo);
  146. DWORD DeleteClient(DHCP_IP_ADDRESS dhcpClientIpAddress);
  147. // exclusion functionality
  148. LONG StoreExceptionList(CExclusionList * plistExclusions);
  149. DWORD AddExclusion(CDhcpIpRange & dhcpIpRange, BOOL bAddToUI = FALSE);
  150. DWORD RemoveExclusion(CDhcpIpRange & dhcpIpRange);
  151. BOOL IsOverlappingRange(CDhcpIpRange & dhcpIpRange);
  152. DWORD IsValidExclusion(CDhcpIpRange & dhcpExclusion);
  153. // Functions to get and set the lease time
  154. DWORD GetLeaseTime(LPDWORD pdwLeaseTime);
  155. DWORD SetLeaseTime(DWORD dwLeaseTime);
  156. // Functions to get and set the dynamic bootp lease time
  157. DWORD GetDynBootpLeaseTime(LPDWORD pdwLeaseTime);
  158. DWORD SetDynBootpLeaseTime(DWORD dwLeaseTime);
  159. DWORD SetDynamicBootpInfo(UINT uRangeType, DWORD dwLeaseTime);
  160. // Functions to get and set the DNS reg option
  161. DWORD GetDnsRegistration(LPDWORD pDnsRegOption);
  162. DWORD SetDnsRegistration(DWORD DnsRegOption);
  163. // option functionality
  164. DWORD SetOptionValue(CDhcpOption * pdhcType,
  165. DHCP_OPTION_SCOPE_TYPE dhcOptType,
  166. DHCP_IP_ADDRESS dhipaReservation = 0,
  167. LPCTSTR pClassName = NULL,
  168. LPCTSTR pVendorName = NULL);
  169. DWORD GetOptionValue(DHCP_OPTION_ID OptionID,
  170. DHCP_OPTION_SCOPE_TYPE dhcOptType,
  171. DHCP_OPTION_VALUE ** ppdhcOptionValue,
  172. DHCP_IP_ADDRESS dhipaReservation = 0,
  173. LPCTSTR pClassName = NULL,
  174. LPCTSTR pVendorName = NULL);
  175. DWORD RemoveOptionValue(DHCP_OPTION_ID dhcOptId,
  176. DHCP_OPTION_SCOPE_TYPE dhcOptType,
  177. DHCP_IP_ADDRESS dhipaReservation = 0);
  178. DWORD SetInfo();
  179. // used to set this scope on the server
  180. DWORD SetSuperscope(LPCTSTR pSuperscopeName, BOOL bRemove);
  181. // interal state information
  182. BOOL IsEnabled() {
  183. return m_dhcpSubnetState == DhcpSubnetEnabled ||
  184. m_dhcpSubnetState == DhcpSubnetEnabledSwitched; }
  185. void SetState(DHCP_SUBNET_STATE dhcpSubnetState);
  186. DHCP_SUBNET_STATE GetState() {
  187. return IsEnabled() ? DhcpSubnetEnabled :
  188. DhcpSubnetDisabled; }
  189. // used for initialization and querring of internal flag
  190. BOOL IsInSuperscope() { return m_bInSuperscope; }
  191. void SetInSuperscope(BOOL bInSuperscope) { m_bInSuperscope = bInSuperscope; }
  192. void SetOptionValueEnum(COptionValueEnum * pEnum)
  193. {
  194. m_ScopeOptionValues.DeleteAll();
  195. m_ScopeOptionValues.Copy(pEnum);
  196. }
  197. COptionValueEnum * GetOptionValueEnum()
  198. {
  199. return &m_ScopeOptionValues;
  200. }
  201. // dynamic bootp stuff
  202. void GetDynBootpClassName(CString & strName);
  203. // Implementation
  204. public:
  205. // helpers
  206. HRESULT GetServerNode(ITFSNode ** ppNode)
  207. {
  208. m_spServerNode->AddRef();
  209. *ppNode = m_spServerNode;
  210. return hrOK;
  211. }
  212. CDhcpServer * GetServerObject() { return GETHANDLER(CDhcpServer, m_spServerNode); }
  213. HRESULT BuildDisplayName(CString * pstrDisplayName, LPCTSTR pIpAddress, LPCTSTR pName);
  214. void UpdateToolbarStates();
  215. HRESULT TriggerStatsRefresh();
  216. private:
  217. // command Handlers
  218. DWORD OnActivateScope(ITFSNode * pNode);
  219. HRESULT OnRefreshScope(ITFSNode * pNode, LPDATAOBJECT pDataObject, DWORD dwType);
  220. HRESULT OnReconcileScope(ITFSNode * pNode);
  221. HRESULT OnShowScopeStats(ITFSNode * pNode);
  222. HRESULT OnDelete(ITFSNode * pNode);
  223. HRESULT OnAddToSuperscope(ITFSNode * pNode);
  224. HRESULT OnRemoveFromSuperscope(ITFSNode * pNode);
  225. // Helpers
  226. HRESULT CreateSubcontainers(ITFSNode * pNode);
  227. // Attributes
  228. private:
  229. DHCP_IP_ADDRESS m_dhcpIpAddress; // Ip address for this scope
  230. DHCP_IP_MASK m_dhcpSubnetMask;
  231. DWORD m_dwClusterSize;
  232. DWORD m_dwPreallocate;
  233. CString m_strName;
  234. CString m_strComment;
  235. CString m_strState;
  236. DHCP_SUBNET_STATE m_dhcpSubnetState;
  237. BOOL m_bInSuperscope;
  238. SPITFSNode m_spAddressPool;
  239. SPITFSNode m_spActiveLeases;
  240. SPITFSNode m_spReservations;
  241. SPITFSNode m_spOptions;
  242. SPITFSNode m_spServerNode;
  243. CScopeStats m_dlgStats;
  244. COptionValueEnum m_ScopeOptionValues;
  245. };
  246. /*---------------------------------------------------------------------------
  247. Class: CDhcpScopeSubobject
  248. All subobjects of a scope derive from this to provide base
  249. functionality to get information from the scope.
  250. ---------------------------------------------------------------------------*/
  251. class CDhcpScopeSubobject
  252. {
  253. public:
  254. CDhcpScope * GetScopeObject(ITFSNode * pNode,
  255. BOOL bResClient = FALSE)
  256. {
  257. if (pNode == NULL)
  258. return NULL;
  259. SPITFSNode spScopeNode;
  260. if (bResClient)
  261. {
  262. SPITFSNode spResNode;
  263. pNode->GetParent(&spResNode);
  264. spResNode->GetParent(&spScopeNode);
  265. }
  266. else
  267. {
  268. pNode->GetParent(&spScopeNode);
  269. }
  270. return GETHANDLER(CDhcpScope, spScopeNode);
  271. }
  272. ITFSNode * GetServerNode(ITFSNode * pNode, BOOL bResClient = FALSE)
  273. {
  274. CDhcpScope * pScope = GetScopeObject(pNode, bResClient);
  275. SPITFSNode spServerNode;
  276. if (pScope)
  277. {
  278. pScope->GetServerNode(&spServerNode);
  279. spServerNode->AddRef();
  280. }
  281. return spServerNode;
  282. }
  283. LPCTSTR GetServerName(ITFSNode * pNode,
  284. BOOL bResClient = FALSE)
  285. {
  286. LPCTSTR pszReturn = NULL;
  287. CDhcpScope * pScope = GetScopeObject(pNode, bResClient);
  288. if (pScope)
  289. {
  290. CDhcpServer * pServer = pScope->GetServerObject();
  291. if (pServer)
  292. pszReturn = pServer->GetName();
  293. }
  294. return pszReturn;
  295. }
  296. LPCTSTR GetServerIpAddress(ITFSNode * pNode,
  297. BOOL bResClient = FALSE)
  298. {
  299. CDhcpScope * pScope = GetScopeObject(pNode, bResClient);
  300. if (pScope)
  301. return pScope->GetServerIpAddress();
  302. else
  303. return NULL;
  304. }
  305. void GetServerIpAddress(ITFSNode * pNode,
  306. DHCP_IP_ADDRESS * pdhcpIpAddress,
  307. BOOL bResClient = FALSE)
  308. {
  309. CDhcpScope * pScope = GetScopeObject(pNode, bResClient);
  310. if (pScope)
  311. pScope->GetServerIpAddress(pdhcpIpAddress);
  312. }
  313. void GetServerVersion(ITFSNode * pNode,
  314. LARGE_INTEGER& liVersion,
  315. BOOL bResClient = FALSE)
  316. {
  317. CDhcpScope * pScope = GetScopeObject(pNode, bResClient);
  318. if (pScope)
  319. pScope->GetServerVersion(liVersion);
  320. }
  321. };
  322. /*---------------------------------------------------------------------------
  323. Class: CDhcpReservations
  324. ---------------------------------------------------------------------------*/
  325. class CDhcpReservations :
  326. public CMTDhcpHandler,
  327. public CDhcpScopeSubobject
  328. {
  329. public:
  330. CDhcpReservations(ITFSComponentData * pComponentData);
  331. ~CDhcpReservations();
  332. // Interface
  333. public:
  334. // Node handler functionality we override
  335. OVERRIDE_NodeHandler_OnAddMenuItems();
  336. OVERRIDE_NodeHandler_OnCommand();
  337. OVERRIDE_NodeHandler_GetString()
  338. { return (nCol == 0) ? GetDisplayName() : NULL; }
  339. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  340. // result handler overrides
  341. OVERRIDE_ResultHandler_CompareItems();
  342. OVERRIDE_ResultHandler_OnGetResultViewType();
  343. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  344. public:
  345. // CDhcpHandler overrides
  346. virtual HRESULT InitializeNode(ITFSNode * pNode);
  347. virtual int GetImageIndex(BOOL bOpenImage);
  348. // CMTDhcpHandler overrides
  349. virtual void OnHaveData(ITFSNode * pParent, ITFSNode * pNew);
  350. STDMETHOD(OnNotifyExiting)(LPARAM);
  351. public:
  352. // implementation specific functionality
  353. DWORD RemoveReservationFromUI(ITFSNode *pReservationsNode, DHCP_IP_ADDRESS dhcpReservationIp);
  354. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  355. HRESULT AddReservationSorted(ITFSNode * pReservationsNode, ITFSNode * pResClientNode);
  356. // Implementation
  357. private:
  358. // message handlers
  359. DWORD OnCreateNewReservation(ITFSNode* pNode);
  360. // Attributes
  361. private:
  362. void UpdateResultMessage(ITFSNode * pNode);
  363. };
  364. /*---------------------------------------------------------------------------
  365. Class: CDhcpReservationClient
  366. ---------------------------------------------------------------------------*/
  367. class CDhcpReservationClient :
  368. public CMTDhcpHandler,
  369. public CDhcpScopeSubobject
  370. {
  371. public:
  372. CDhcpReservationClient(ITFSComponentData * pComponentData,
  373. LPDHCP_CLIENT_INFO pDhcpClientInfo);
  374. CDhcpReservationClient(ITFSComponentData * pComponentData,
  375. LPDHCP_CLIENT_INFO_V4 pDhcpClientInfo);
  376. CDhcpReservationClient(ITFSComponentData * pComponentData,
  377. CDhcpClient & dhcpClient);
  378. ~CDhcpReservationClient();
  379. // Interface
  380. public:
  381. // Node handler functionality we override
  382. OVERRIDE_NodeHandler_HasPropertyPages() { return hrOK; }
  383. OVERRIDE_NodeHandler_CreatePropertyPages();
  384. OVERRIDE_NodeHandler_OnAddMenuItems();
  385. OVERRIDE_NodeHandler_OnCommand();
  386. OVERRIDE_NodeHandler_GetString()
  387. { return (nCol == 0) ? GetDisplayName() : NULL; }
  388. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  389. // choose the notifications that we want to handle
  390. OVERRIDE_BaseHandlerNotify_OnDelete();
  391. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  392. // Result Handler notification
  393. OVERRIDE_BaseResultHandlerNotify_OnResultPropertyChange();
  394. OVERRIDE_BaseResultHandlerNotify_OnResultUpdateView();
  395. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  396. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  397. OVERRIDE_ResultHandler_CompareItems();
  398. OVERRIDE_ResultHandler_OnGetResultViewType();
  399. virtual HRESULT EnumerateResultPane(ITFSComponent *, MMC_COOKIE, LPARAM, LPARAM);
  400. HRESULT DoResPages(ITFSNode * pNode, LPPROPERTYSHEETCALLBACK lpProvider, LPDATAOBJECT pDataObject, LONG_PTR handle, DWORD dwType);
  401. HRESULT DoOptCfgPages(ITFSNode * pNode, LPPROPERTYSHEETCALLBACK lpProvider, LPDATAOBJECT pDataObject, LONG_PTR handle, DWORD dwType);
  402. public:
  403. // CDhcpHandler overrides
  404. virtual HRESULT InitializeNode(ITFSNode * pNode);
  405. virtual int GetImageIndex(BOOL bOpenImage);
  406. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type);
  407. STDMETHOD(OnNotifyExiting)(LPARAM);
  408. public:
  409. // command handlers
  410. HRESULT OnCreateNewOptions(ITFSNode * pNode);
  411. public:
  412. // implementation specifc
  413. DHCP_IP_ADDRESS GetIpAddress() { return m_dhcpClientIpAddress; };
  414. HRESULT BuildDisplayName(CString * pstrDisplayName, LPCTSTR pIpAddress, LPCTSTR pName);
  415. HRESULT SetName(LPCTSTR pName);
  416. HRESULT SetComment(LPCTSTR pComment);
  417. HRESULT SetUID(const CByteArray & baClientUID);
  418. BYTE SetClientType(BYTE bClientType);
  419. LPCTSTR GetName() { return (m_pstrClientName == NULL) ? NULL : (LPCTSTR) *m_pstrClientName; }
  420. BYTE GetClientType() { return m_bClientType; }
  421. // Functions to get and set the DNS reg option
  422. DWORD GetDnsRegistration(ITFSNode * pNode, LPDWORD pDnsRegOption);
  423. DWORD SetDnsRegistration(ITFSNode * pNode, DWORD DnsRegOption);
  424. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  425. void SetOptionValueEnum(COptionValueEnum * pEnum)
  426. {
  427. m_ResClientOptionValues.DeleteAll();
  428. m_ResClientOptionValues.Copy(pEnum);
  429. }
  430. COptionValueEnum * GetOptionValueEnum()
  431. {
  432. return &m_ResClientOptionValues;
  433. }
  434. // Implementation
  435. private:
  436. // command handlers
  437. DWORD OnDelete(ITFSNode * pNode);
  438. // helpers
  439. void InitializeData(LPDHCP_CLIENT_INFO pDhcpClientInfo);
  440. void UpdateResultMessage(ITFSNode * pNode);
  441. // Attributes
  442. public:
  443. DHCP_IP_ADDRESS m_dhcpClientIpAddress;
  444. private:
  445. CString * m_pstrClientName;
  446. CString * m_pstrClientComment;
  447. CString m_strLeaseExpires;
  448. CByteArray m_baHardwareAddress;
  449. BYTE m_bClientType;
  450. COptionValueEnum m_ResClientOptionValues;
  451. BOOL m_fResProp;
  452. };
  453. /*---------------------------------------------------------------------------
  454. Class: CDhcpActiveLeases
  455. ---------------------------------------------------------------------------*/
  456. class CDhcpActiveLeases :
  457. public CMTDhcpHandler,
  458. public CDhcpScopeSubobject
  459. {
  460. // friend class CDhcpComponent;
  461. // friend class CDhcpComponentData;
  462. public:
  463. CDhcpActiveLeases(ITFSComponentData * pComponentData);
  464. ~CDhcpActiveLeases();
  465. // Interface
  466. public:
  467. // Node handler functionality we override
  468. OVERRIDE_NodeHandler_OnAddMenuItems();
  469. OVERRIDE_NodeHandler_OnCommand();
  470. OVERRIDE_NodeHandler_GetString()
  471. { return (nCol == 0) ? GetDisplayName() : NULL; }
  472. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  473. // Result Handler notification
  474. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  475. OVERRIDE_ResultHandler_OnGetResultViewType();
  476. OVERRIDE_ResultHandler_CompareItems();
  477. public:
  478. // CDhcpHandler overrides
  479. virtual HRESULT InitializeNode(ITFSNode * pNode);
  480. virtual int GetImageIndex(BOOL bOpenImage);
  481. public:
  482. // implementation specifiec
  483. HRESULT OnExportLeases(ITFSNode * pNode);
  484. DWORD DeleteClient(ITFSNode * pActiveLeasesNode, DHCP_IP_ADDRESS dhcpIpAddress);
  485. HRESULT FillFakeLeases(int nNumEntries);
  486. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  487. // Implementation
  488. private:
  489. int CompareIpAddresses(CDhcpActiveLease * pDhcpAL1, CDhcpActiveLease * pDhcpAL2);
  490. // Attributes
  491. private:
  492. };
  493. /*---------------------------------------------------------------------------
  494. Class: CDhcpAddressPool
  495. ---------------------------------------------------------------------------*/
  496. class CDhcpAddressPool :
  497. public CMTDhcpHandler,
  498. public CDhcpScopeSubobject
  499. {
  500. public:
  501. CDhcpAddressPool(ITFSComponentData * pComponentData);
  502. ~CDhcpAddressPool();
  503. // Interface
  504. public:
  505. // Node handler functionality we override
  506. OVERRIDE_NodeHandler_OnAddMenuItems();
  507. OVERRIDE_NodeHandler_OnCommand();
  508. OVERRIDE_NodeHandler_GetString()
  509. { return (nCol == 0) ? GetDisplayName() : NULL; }
  510. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  511. // Result Handler notification
  512. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  513. OVERRIDE_ResultHandler_CompareItems();
  514. OVERRIDE_ResultHandler_OnGetResultViewType();
  515. public:
  516. // CDhcpHandler overrides
  517. virtual HRESULT InitializeNode(ITFSNode * pNode);
  518. virtual int GetImageIndex(BOOL bOpenImage);
  519. public:
  520. // implementation specific
  521. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  522. private:
  523. // command handlers
  524. DWORD OnCreateNewExclusion(ITFSNode * pNode);
  525. // Attributes
  526. private:
  527. };
  528. /*---------------------------------------------------------------------------
  529. Class: CDhcpScopeOptions
  530. ---------------------------------------------------------------------------*/
  531. class CDhcpScopeOptions :
  532. public CMTDhcpHandler,
  533. public CDhcpScopeSubobject
  534. {
  535. public:
  536. CDhcpScopeOptions(ITFSComponentData * pComponentData);
  537. ~CDhcpScopeOptions();
  538. // Interface
  539. public:
  540. // Node handler functionality we override
  541. OVERRIDE_NodeHandler_OnAddMenuItems();
  542. OVERRIDE_NodeHandler_OnCommand();
  543. OVERRIDE_NodeHandler_HasPropertyPages();
  544. OVERRIDE_NodeHandler_CreatePropertyPages();
  545. OVERRIDE_NodeHandler_GetString()
  546. { return (nCol == 0) ? GetDisplayName() : NULL; }
  547. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  548. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  549. // Result Handler notification
  550. OVERRIDE_BaseResultHandlerNotify_OnResultPropertyChange();
  551. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  552. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  553. OVERRIDE_BaseResultHandlerNotify_OnResultUpdateView();
  554. OVERRIDE_ResultHandler_CompareItems();
  555. OVERRIDE_ResultHandler_OnGetResultViewType();
  556. virtual HRESULT EnumerateResultPane(ITFSComponent *, MMC_COOKIE, LPARAM, LPARAM);
  557. public:
  558. // CDhcpHandler overrides
  559. virtual HRESULT InitializeNode(ITFSNode * pNode);
  560. virtual int GetImageIndex(BOOL bOpenImage);
  561. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type);
  562. STDMETHOD(OnNotifyExiting)(LPARAM);
  563. public:
  564. // command handlers
  565. HRESULT OnCreateNewOptions(ITFSNode * pNode);
  566. public:
  567. // implementation specific
  568. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  569. // Implementation
  570. private:
  571. void UpdateResultMessage(ITFSNode * pNode);
  572. // Attributes
  573. private:
  574. };
  575. /*---------------------------------------------------------------------------
  576. Class: CDhcpScopeQueryObj
  577. ---------------------------------------------------------------------------*/
  578. class CDhcpScopeQueryObj : public CDHCPQueryObj
  579. {
  580. public:
  581. CDhcpScopeQueryObj(ITFSComponentData * pTFSCompData,
  582. ITFSNodeMgr * pNodeMgr)
  583. : CDHCPQueryObj(pTFSCompData, pNodeMgr) { m_nQueueCountMax = 20; }
  584. STDMETHODIMP Execute();
  585. HRESULT CreateSubcontainers();
  586. LARGE_INTEGER m_liVersion;
  587. DHCP_IP_ADDRESS m_dhcpScopeAddress;
  588. };
  589. /*---------------------------------------------------------------------------
  590. Class: CDhcpActiveLeasesQueryObj
  591. ---------------------------------------------------------------------------*/
  592. class CDhcpActiveLeasesQueryObj : public CDHCPQueryObj
  593. {
  594. public:
  595. CDhcpActiveLeasesQueryObj(ITFSComponentData * pTFSCompData,
  596. ITFSNodeMgr * pNodeMgr)
  597. : CDHCPQueryObj(pTFSCompData, pNodeMgr) { m_nQueueCountMax = 20; }
  598. STDMETHODIMP Execute();
  599. HRESULT EnumerateLeasesV5();
  600. HRESULT EnumerateLeasesV4();
  601. HRESULT EnumerateLeases();
  602. HRESULT BuildReservationList();
  603. BOOL IsReservation(DWORD dwIp);
  604. public:
  605. LARGE_INTEGER m_liDhcpVersion;
  606. DHCP_IP_ADDRESS m_dhcpScopeAddress;
  607. DHCP_RESUME_HANDLE m_dhcpResumeHandle;
  608. DWORD m_dwPreferredMax;
  609. CDWordArray m_ReservationArray;
  610. };
  611. /*---------------------------------------------------------------------------
  612. Class: CDhcpReservationsQueryObj
  613. ---------------------------------------------------------------------------*/
  614. typedef CMap< DHCP_IP_ADDRESS, DHCP_IP_ADDRESS,
  615. LPDHCP_SUBNET_ELEMENT_DATA_V4, LPDHCP_SUBNET_ELEMENT_DATA_V4 > CSubnetElementMap;
  616. class CDhcpReservationsQueryObj : public CDHCPQueryObj
  617. {
  618. public:
  619. CDhcpReservationsQueryObj(ITFSComponentData * pTFSCompData,
  620. ITFSNodeMgr * pNodeMgr)
  621. : CDHCPQueryObj(pTFSCompData, pNodeMgr) {};
  622. STDMETHODIMP Execute();
  623. HRESULT EnumerateReservationsV4();
  624. HRESULT EnumerateReservationsForLessResvsV4( );
  625. HRESULT EnumerateReservations();
  626. BOOL AddReservedIPsToArray( );
  627. LARGE_INTEGER m_liVersion;
  628. DHCP_IP_ADDRESS m_dhcpScopeAddress;
  629. DHCP_RESUME_HANDLE m_dhcpResumeHandle;
  630. DWORD m_dwPreferredMax;
  631. DWORD m_totalResvs;
  632. CSubnetElementMap m_resvMap;
  633. LPDHCP_SUBNET_ELEMENT_INFO_ARRAY_V4 m_subnetElements;
  634. };
  635. /*---------------------------------------------------------------------------
  636. Class: CDhcpReservationClientQueryObj
  637. ---------------------------------------------------------------------------*/
  638. class CDhcpReservationClientQueryObj : public CDHCPQueryObj
  639. {
  640. public:
  641. CDhcpReservationClientQueryObj(ITFSComponentData * pTFSCompData,
  642. ITFSNodeMgr * pNodeMgr)
  643. : CDHCPQueryObj(pTFSCompData, pNodeMgr) {};
  644. STDMETHODIMP Execute();
  645. public:
  646. DHCP_IP_ADDRESS m_dhcpScopeAddress;
  647. DHCP_IP_ADDRESS m_dhcpClientIpAddress;
  648. DHCP_RESUME_HANDLE m_dhcpResumeHandle;
  649. DWORD m_dwPreferredMax;
  650. LARGE_INTEGER m_liDhcpVersion;
  651. CString m_strDynBootpClassName;
  652. };
  653. /*---------------------------------------------------------------------------
  654. Class: CDhcpAddressPoolQueryObj
  655. ---------------------------------------------------------------------------*/
  656. class CDhcpAddressPoolQueryObj : public CDHCPQueryObj
  657. {
  658. public:
  659. CDhcpAddressPoolQueryObj(ITFSComponentData * pTFSCompData,
  660. ITFSNodeMgr * pNodeMgr)
  661. : CDHCPQueryObj(pTFSCompData, pNodeMgr),
  662. m_dwError(0),
  663. m_fSupportsDynBootp(FALSE) {};
  664. STDMETHODIMP Execute();
  665. HRESULT EnumerateIpRanges();
  666. HRESULT EnumerateIpRangesV5();
  667. HRESULT EnumerateExcludedIpRanges();
  668. public:
  669. DHCP_IP_ADDRESS m_dhcpScopeAddress;
  670. DHCP_RESUME_HANDLE m_dhcpExclResumeHandle;
  671. DWORD m_dwExclPreferredMax;
  672. DHCP_RESUME_HANDLE m_dhcpIpResumeHandle;
  673. DWORD m_dwIpPreferredMax;
  674. DWORD m_dwError;
  675. BOOL m_fSupportsDynBootp;
  676. };
  677. /*---------------------------------------------------------------------------
  678. Class: CDhcpScopeOptionsQueryObj
  679. ---------------------------------------------------------------------------*/
  680. class CDhcpScopeOptionsQueryObj : public CDHCPQueryObj
  681. {
  682. public:
  683. CDhcpScopeOptionsQueryObj(ITFSComponentData * pTFSCompData,
  684. ITFSNodeMgr * pNodeMgr)
  685. : CDHCPQueryObj(pTFSCompData, pNodeMgr) {};
  686. STDMETHODIMP Execute();
  687. public:
  688. DHCP_IP_ADDRESS m_dhcpScopeAddress;
  689. DHCP_RESUME_HANDLE m_dhcpResumeHandle;
  690. DWORD m_dwPreferredMax;
  691. LARGE_INTEGER m_liDhcpVersion;
  692. CString m_strDynBootpClassName;
  693. };
  694. #endif _SCOPE_H