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.

909 lines
28 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. server.h
  7. This file contains the prototypes for a DHCP Server
  8. object and the Bootp and Global Options objects
  9. contained within it. The other object that a can be
  10. within a DHCP server is a superscope, which is defined is
  11. in cdhcpss.cpp and cdhcpss.h.
  12. FILE HISTORY:
  13. */
  14. #ifndef _SERVER_H
  15. #define _SERVER_H
  16. #ifndef _DHCPHAND_H
  17. #include "dhcphand.h"
  18. #endif
  19. #ifndef _SERVSTAT_H
  20. #include "servstat.h" // Server statistics
  21. #endif
  22. #ifndef _SSCPSTAT_H
  23. #include "sscpstat.h" // Superscope statistics
  24. #endif
  25. #ifndef _CLASSMOD_H
  26. #include "classmod.h" // Class Stuff
  27. #endif
  28. #define SERVER_OPTION_AUTO_REFRESH 0x00000001
  29. #define SERVER_OPTION_AUDIT_LOGGING 0x00000002
  30. #define SERVER_OPTION_SHOW_BOOTP 0x00000004
  31. #define SERVER_OPTION_EXTENSION 0x00000008 // this server was added as an extension
  32. #define SERVER_OPTION_SHOW_ROGUE 0x00000010
  33. #define AUTO_REFRESH_HOURS_MAX 23
  34. #define AUTO_REFRESH_MINUTES_MAX 59
  35. #define AUTO_REFRESH_SECONDS_MAX 59
  36. #define DHCP_QDATA_VERSION 0x00000001
  37. #define DHCP_QDATA_SERVER_INFO 0x00000002
  38. #define DHCP_QDATA_STATS 0x00000003
  39. #define DHCP_QDATA_CLASS_INFO 0x00000004
  40. #define DHCP_QDATA_MCAST_STATS 0x00000005
  41. #define DHCP_QDATA_OPTION_VALUES 0x00000006
  42. #define DHCP_QDATA_ROGUE_INFO 0x00000007
  43. #define DHCP_QDATA_SERVER_ID 0x00000008
  44. #define DHCP_QDATA_SUBNET_INFO_CACHE 0x00000009
  45. typedef struct DhcpRogueInfo_tag
  46. {
  47. BOOL fIsRogue;
  48. BOOL fIsInNt5Domain;
  49. }
  50. DHCP_ROGUE_INFO, * LPDHCP_ROGUE_INFO;
  51. typedef struct DhcpServerInfo_tag
  52. {
  53. BOOL fAuditLog;
  54. DWORD dwPingRetries;
  55. CString strDatabasePath;
  56. CString strBackupPath;
  57. // audit logging stuff
  58. CString strAuditLogDir;
  59. DWORD dwDiskCheckInterval;
  60. DWORD dwMaxLogFilesSize;
  61. DWORD dwMinSpaceOnDisk;
  62. // Does it support DynamicBOOTP?
  63. BOOL fSupportsDynBootp;
  64. // Does it support Bindings?
  65. BOOL fSupportsBindings;
  66. }
  67. DHCP_SERVER_CONFIG, * LPDHCP_SERVER_CONFIG;
  68. typedef struct DhcpServerId_tag
  69. {
  70. CString strIp;
  71. CString strName;
  72. }
  73. DHCP_SERVER_ID, * LPDHCP_SERVER_ID;
  74. class CDhcpGlobalOptions;
  75. class CSubnetInfoCache;
  76. /*---------------------------------------------------------------------------
  77. Class: CDhcpServer
  78. ---------------------------------------------------------------------------*/
  79. class CDhcpServer : public CMTDhcpHandler
  80. {
  81. public:
  82. CDhcpServer(ITFSComponentData* pTFSComponentData, LPCWSTR pServerName = NULL);
  83. ~CDhcpServer();
  84. // Interface
  85. public:
  86. // base handler functionality we override
  87. OVERRIDE_NodeHandler_HasPropertyPages();
  88. OVERRIDE_NodeHandler_CreatePropertyPages();
  89. OVERRIDE_NodeHandler_OnAddMenuItems();
  90. OVERRIDE_NodeHandler_OnCommand();
  91. OVERRIDE_NodeHandler_GetString();
  92. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  93. OVERRIDE_NodeHandler_DestroyHandler();
  94. // Choose which messages we want to handle
  95. OVERRIDE_BaseHandlerNotify_OnDelete();
  96. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  97. // Result handler functionality
  98. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  99. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  100. OVERRIDE_ResultHandler_OnGetResultViewType();
  101. public:
  102. // CMTDhcpHandler functionality
  103. virtual HRESULT InitializeNode(ITFSNode * pNode);
  104. virtual int GetImageIndex(BOOL bOpenImage);
  105. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  106. virtual void OnHaveData(ITFSNode * pParentNode, ITFSNode * pNode);
  107. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type);
  108. virtual DWORD UpdateStatistics(ITFSNode * pNode);
  109. ITFSQueryObject* OnCreateStatsQuery(ITFSNode *pNode);
  110. virtual void UpdateToolbar(IToolbar * pToolbar, LONG_PTR dwNodeType, BOOL bSelect);
  111. void UpdateConsoleVerbs(ITFSComponent* pComponent, IConsoleVerb * pConsoleVerb, LONG_PTR dwNodeType, BOOL bMultiSelect = FALSE);
  112. STDMETHOD(OnNotifyExiting)(LPARAM);
  113. HRESULT OnUpdateToolbarButtons(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  114. public:
  115. // implementation specific
  116. BOOL FEnableCreateSuperscope(ITFSNode * pNode);
  117. void UpdateToolbarStates(ITFSNode * pNode);
  118. void SetExtensionName();
  119. HRESULT BuildDisplayName(CString * pstrDisplayName);
  120. LPCWSTR GetIpAddress();
  121. void GetIpAddress(DHCP_IP_ADDRESS *pdhcpIpAddress);
  122. LPCTSTR GetName() { return m_strDnsName; }
  123. void SetName(LPCTSTR pName) { m_strDnsName = pName; }
  124. BOOL GetDefaultOptions();
  125. CDhcpOption * FindOption(DHCP_OPTION_ID dhcpOptionId, LPCTSTR pszVendor);
  126. void SetVersion(LARGE_INTEGER & liVersion)
  127. { m_liDhcpVersion.QuadPart = liVersion.QuadPart; }
  128. void GetVersion(LARGE_INTEGER & liVersion)
  129. { liVersion.QuadPart = m_liDhcpVersion.QuadPart; }
  130. DWORD CreateScope(DHCP_IP_ADDRESS dhcpSubnetAddress,
  131. DHCP_IP_ADDRESS dhcpSubnetMask,
  132. LPCTSTR pName,
  133. LPCTSTR pComment);
  134. DWORD CreateMScope(LPDHCP_MSCOPE_INFO pMScopeInfo);
  135. DWORD DeleteScope(ITFSNode * pScopeNode, BOOL * pfWantCancel = NULL);
  136. DWORD DeleteSubnet(DWORD dwScopeId, BOOL bForce = FALSE);
  137. DWORD DeleteSuperscope(ITFSNode * pNode, BOOL * pfRefresh = NULL);
  138. DWORD RemoveSuperscope(LPCTSTR pszName);
  139. DWORD DeleteMScope(ITFSNode * pScopeNode, BOOL * pfWantCancel = NULL);
  140. DWORD DeleteMSubnet(LPCTSTR pszName, BOOL bForce = FALSE);
  141. DWORD SetConfigInfo(BOOL bAuditLogging, DWORD dwPingRetries, LPCTSTR pszDatabasePath = NULL, LPCTSTR pszBackupPath = NULL);
  142. DWORD SetConfigInfo(DWORD dwSetFlags, LPDHCP_SERVER_CONFIG_INFO pServerConfigInfo);
  143. DWORD SetConfigInfo(DWORD dwSetFlags, LPDHCP_SERVER_CONFIG_INFO_V4 pServerConfigInfo);
  144. DWORD SetAutoRefresh(ITFSNode * pNode, BOOL bAutoRefreshOn, DWORD dwRefreshInterval);
  145. BOOL IsAutoRefreshEnabled() { return m_dwServerOptions & SERVER_OPTION_AUTO_REFRESH; }
  146. void GetAutoRefresh(BOOL * pbAutoRefreshOn, LPDWORD pdwRefreshInterval)
  147. {
  148. if (pbAutoRefreshOn) *pbAutoRefreshOn = m_dwServerOptions & SERVER_OPTION_AUTO_REFRESH;
  149. if (pdwRefreshInterval) *pdwRefreshInterval = m_dwRefreshInterval;
  150. }
  151. // default option functions
  152. LONG CreateOption(CDhcpOption * pdhcType);
  153. LONG DeleteOption(DHCP_OPTION_ID dhcid, LPCTSTR pszVendor);
  154. LONG UpdateOptionList(COptionList * poblValues, COptionList * poblDefunct, CWnd *pwndMsgParent);
  155. void DisplayUpdateErrors(COptionList * poblValues, COptionList * poblDefunct, CWnd *pwndMsgParent);
  156. // Functions to get and set the DNS reg option
  157. DWORD GetDnsRegistration(LPDWORD pDnsRegOption);
  158. DWORD SetDnsRegistration(DWORD DnsRegOption);
  159. LONG ScanDatabase(DWORD FixFlag, LPDHCP_SCAN_LIST *ScanList, DHCP_IP_ADDRESS dhcpSubnetAddress);
  160. LONG ScanDatabase(DWORD FixFlag, LPDHCP_SCAN_LIST *ScanList, LPWSTR pMScopeName);
  161. CDhcpDefaultOptionsOnServer * GetDefaultOptionsList() { return m_pDefaultOptionsOnServer; }
  162. CDhcpGlobalOptions * GetGlobalOptionsContainer();
  163. // These funtions allow initialization of cached values in the server object.
  164. // use SetConfigInfo to actually set them on the server
  165. BOOL SetAuditLogging(BOOL bNewAuditLogging)
  166. {
  167. BOOL bOld = m_dwServerOptions & SERVER_OPTION_AUDIT_LOGGING;
  168. m_dwServerOptions = bNewAuditLogging ? m_dwServerOptions | SERVER_OPTION_AUDIT_LOGGING :
  169. m_dwServerOptions & ~SERVER_OPTION_AUDIT_LOGGING;
  170. return bOld;
  171. }
  172. BOOL GetAuditLogging() { return m_dwServerOptions & SERVER_OPTION_AUDIT_LOGGING; }
  173. DWORD SetPingRetries(DWORD dwNewCount) { DWORD dwOld = m_dwPingRetries; m_dwPingRetries = dwNewCount; return dwOld; }
  174. DWORD GetPingRetries() { return m_dwPingRetries; }
  175. void SetAuditLogPath(LPCTSTR pszPath) { m_strAuditLogPath = pszPath; }
  176. // determine if the server has superscopes
  177. BOOL HasSuperscopes(ITFSNode * pNode);
  178. // statistics information
  179. LPDHCP_MIB_INFO SetMibInfo(LPDHCP_MIB_INFO pMibInfo);
  180. LPDHCP_MIB_INFO DuplicateMibInfo();
  181. void FreeDupMibInfo(LPDHCP_MIB_INFO pDupMibInfo);
  182. LPDHCP_MCAST_MIB_INFO SetMCastMibInfo(LPDHCP_MCAST_MIB_INFO pMibInfo);
  183. LPDHCP_MCAST_MIB_INFO DuplicateMCastMibInfo();
  184. void FreeDupMCastMibInfo(LPDHCP_MCAST_MIB_INFO pDupMibInfo);
  185. // adding child nodes sorted
  186. HRESULT AddScopeSorted(ITFSNode * pServerNode, ITFSNode * pScopeNode);
  187. HRESULT AddSuperscopeSorted(ITFSNode * pServerNode, ITFSNode * pScopeNode);
  188. HRESULT AddMScopeSorted(ITFSNode * pServerNode, ITFSNode * pScopeNode);
  189. HRESULT GetBootpPosition(ITFSNode * pServerNode, LONG_PTR * puRelativeFlag, LONG_PTR * puRelativeID);
  190. // hide/show/query bootp folders
  191. BOOL IsBootpVisible() { return m_dwServerOptions & SERVER_OPTION_SHOW_BOOTP; }
  192. HRESULT ShowNode(ITFSNode * pServerNode, UINT uNodeType, BOOL bVisible);
  193. // access to the server options for save/restore
  194. DWORD GetServerOptions() { return m_dwServerOptions; }
  195. void SetServerOptions(DWORD dwServerOptions) { m_dwServerOptions = dwServerOptions; }
  196. HRESULT TriggerStatsRefresh(ITFSNode * pNode);
  197. void DisplayRogueWarning();
  198. // multicast scope stuff
  199. BOOL DoesMScopeExist(ITFSNode * pServerNode, DWORD dwScopeId);
  200. // Dynamic Bootp support
  201. BOOL FSupportsDynBootp() { return m_fSupportsDynBootp; }
  202. // Bindings support
  203. BOOL FSupportsBindings() { return m_fSupportsBindings; }
  204. // Access to the classInfoarray
  205. void SetClassInfoArray(CClassInfoArray * pClassInfoArray)
  206. {
  207. CSingleLock sl(&m_csMibInfo);
  208. sl.Lock();
  209. m_ClassInfoArray.RemoveAll();
  210. m_ClassInfoArray.Copy(*pClassInfoArray);
  211. }
  212. void GetClassInfoArray(CClassInfoArray & ClassInfoArray)
  213. {
  214. CSingleLock sl(&m_csMibInfo);
  215. sl.Lock();
  216. ClassInfoArray.Copy(m_ClassInfoArray);
  217. }
  218. CClassInfoArray * GetClassInfoArray()
  219. {
  220. CSingleLock sl(&m_csMibInfo);
  221. sl.Lock();
  222. return &m_ClassInfoArray;
  223. }
  224. BOOL RemoveClass(LPCTSTR pClassName)
  225. {
  226. CSingleLock sl(&m_csMibInfo);
  227. sl.Lock();
  228. return m_ClassInfoArray.RemoveClass(pClassName);
  229. }
  230. void AddClass(LPCTSTR pName, LPCTSTR pComment, CByteArray & baData)
  231. {
  232. CSingleLock sl(&m_csMibInfo);
  233. sl.Lock();
  234. CClassInfo ClassInfo;
  235. ClassInfo.strName = pName;
  236. ClassInfo.strComment = pComment;
  237. ClassInfo.baData.Copy(baData);
  238. m_ClassInfoArray.Add(ClassInfo);
  239. }
  240. void SetOptionValueEnum(COptionValueEnum * pEnum)
  241. {
  242. CSingleLock sl(&m_csMibInfo);
  243. sl.Lock();
  244. m_ServerOptionValues.DeleteAll();
  245. m_ServerOptionValues.Copy(pEnum);
  246. }
  247. COptionValueEnum * GetOptionValueEnum()
  248. {
  249. CSingleLock sl(&m_csMibInfo);
  250. sl.Lock();
  251. return &m_ServerOptionValues;
  252. }
  253. // Implementation
  254. private:
  255. // Command handlers
  256. HRESULT OnDefineUserClasses(ITFSNode * pNode);
  257. HRESULT OnDefineVendorClasses(ITFSNode * pNode);
  258. HRESULT OnCreateNewSuperscope(ITFSNode * pNode);
  259. HRESULT OnCreateNewScope(ITFSNode * pNode);
  260. HRESULT OnCreateNewMScope(ITFSNode * pNode);
  261. HRESULT OnShowServerStats(ITFSNode * pNode);
  262. HRESULT OnSetDefaultOptions(ITFSNode * pNode);
  263. HRESULT OnReconcileAll(ITFSNode * pNode);
  264. HRESULT OnServerAuthorize(ITFSNode * pNode);
  265. HRESULT OnServerDeauthorize(ITFSNode * pNode);
  266. HRESULT OnDelete(ITFSNode * pNode);
  267. HRESULT OnControlService(ITFSNode * pNode, BOOL fStart);
  268. HRESULT OnPauseResumeService(ITFSNode * pNode, BOOL fPause);
  269. HRESULT OnRestartService(ITFSNode * pNode);
  270. HRESULT OnServerBackup(ITFSNode * pNode);
  271. HRESULT OnServerRestore(ITFSNode * pNode);
  272. // Attributes
  273. public:
  274. DWORD SetBindings(LPDHCP_BIND_ELEMENT_ARRAY BindArray);
  275. DWORD GetBindings(LPDHCP_BIND_ELEMENT_ARRAY &BindArray);
  276. BOOL m_bStatsOnly;
  277. CSubnetInfoCache * m_pSubnetInfoCache;
  278. protected:
  279. void UpdateResultMessage(ITFSNode * pNode);
  280. // we override this because we handle the error messages ourselves in UpdateResultMessage
  281. // by not returning anything the base class won't put up a result pane message
  282. void GetErrorMessages(CString & strTitle, CString & strBody, IconIdentifier * icon) {};
  283. private:
  284. BOOL m_bNetbios; // Name is a NetBIOS name
  285. DHCP_IP_ADDRESS m_dhcpServerAddress; // Standard 32-bit value (eg: 0x7f000001)
  286. CString m_strServerAddress;
  287. CString m_strDnsName;
  288. CString m_strState; // rogue or not
  289. LARGE_INTEGER m_liDhcpVersion;
  290. DWORD m_dwServerOptions; // Any of the SERVER_OPTIONS
  291. DWORD m_dwRefreshInterval;
  292. DWORD m_dwPingRetries;
  293. CString m_strAuditLogPath;
  294. CString m_strDatabasePath;
  295. CString m_strBackupPath;
  296. BOOL m_fSupportsDynBootp;
  297. BOOL m_fSupportsBindings;
  298. int m_StatsTimerId;
  299. LPDHCP_MIB_INFO m_pMibInfo; // for statistics
  300. LPDHCP_MCAST_MIB_INFO m_pMCastMibInfo;
  301. DHCP_ROGUE_INFO m_RogueInfo;
  302. CCriticalSection m_csMibInfo;
  303. CDhcpDefaultOptionsOnServer * m_pDefaultOptionsOnServer;
  304. CServerStats m_dlgStats;
  305. CClassInfoArray m_ClassInfoArray;
  306. COptionValueEnum m_ServerOptionValues;
  307. };
  308. /*---------------------------------------------------------------------------
  309. Class: CDhcpGlobalOptions
  310. ---------------------------------------------------------------------------*/
  311. class CDhcpGlobalOptions : public CMTDhcpHandler
  312. {
  313. public:
  314. CDhcpGlobalOptions(ITFSComponentData * pComponentData);
  315. ~CDhcpGlobalOptions();
  316. // Interface
  317. public:
  318. // base handler functionality we override
  319. OVERRIDE_NodeHandler_OnAddMenuItems();
  320. OVERRIDE_NodeHandler_HasPropertyPages();
  321. OVERRIDE_NodeHandler_CreatePropertyPages();
  322. OVERRIDE_NodeHandler_OnCommand();
  323. OVERRIDE_NodeHandler_GetString()
  324. { return (nCol == 0) ? GetDisplayName() : NULL; }
  325. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  326. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  327. virtual HRESULT EnumerateResultPane(ITFSComponent *, MMC_COOKIE, LPARAM, LPARAM);
  328. // Result handler functionality we override
  329. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  330. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  331. OVERRIDE_BaseResultHandlerNotify_OnResultUpdateView();
  332. OVERRIDE_BaseResultHandlerNotify_OnResultPropertyChange();
  333. OVERRIDE_ResultHandler_CompareItems();
  334. OVERRIDE_ResultHandler_OnGetResultViewType();
  335. public:
  336. // CMTDhcpHandler functionality
  337. virtual HRESULT InitializeNode(ITFSNode * pNode);
  338. virtual int GetImageIndex(BOOL bOpenImage);
  339. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  340. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type);
  341. STDMETHOD(OnNotifyExiting)(LPARAM);
  342. CDhcpServer* GetServerObject(ITFSNode * pNode)
  343. {
  344. SPITFSNode spServerNode;
  345. pNode->GetParent(&spServerNode);
  346. return GETHANDLER(CDhcpServer, spServerNode);
  347. }
  348. private:
  349. // command handlers
  350. HRESULT OnCreateNewOptions(ITFSNode * pNode);
  351. // Attributes
  352. private:
  353. void UpdateResultMessage(ITFSNode * pNode);
  354. };
  355. /*---------------------------------------------------------------------------
  356. Class: CDhcpBootp
  357. ---------------------------------------------------------------------------*/
  358. class CDhcpBootp : public CMTDhcpHandler
  359. {
  360. public:
  361. CDhcpBootp(ITFSComponentData * pComponentData);
  362. ~CDhcpBootp();
  363. // Interface
  364. public:
  365. // base handler functionality we override
  366. OVERRIDE_NodeHandler_OnAddMenuItems();
  367. OVERRIDE_NodeHandler_OnCommand();
  368. OVERRIDE_NodeHandler_GetString()
  369. { return (nCol == 0) ? GetDisplayName() : NULL; }
  370. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  371. // Result handler functionality we override
  372. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  373. OVERRIDE_ResultHandler_CompareItems();
  374. OVERRIDE_ResultHandler_OnGetResultViewType();
  375. public:
  376. // CMTDhcpHandler functionality
  377. virtual HRESULT InitializeNode(ITFSNode * pNode);
  378. virtual int GetImageIndex(BOOL bOpenImage);
  379. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  380. CDhcpServer* GetServerObject(ITFSNode * pNode)
  381. {
  382. SPITFSNode spServerNode;
  383. pNode->GetParent(&spServerNode);
  384. return GETHANDLER(CDhcpServer, spServerNode);
  385. }
  386. private:
  387. // command handlers
  388. DWORD OnCreateNewBootpEntry(ITFSNode * pNode);
  389. // Implementation
  390. private:
  391. // Attributes
  392. private:
  393. };
  394. /*---------------------------------------------------------------------------
  395. Class: CDhcpSuperscope
  396. ---------------------------------------------------------------------------*/
  397. class CDhcpSuperscope : public CMTDhcpHandler
  398. {
  399. public:
  400. CDhcpSuperscope(ITFSComponentData * pComponentData, LPCWSTR pSuperscopeName = NULL);
  401. ~CDhcpSuperscope();
  402. public:
  403. // base handler functionality we override
  404. OVERRIDE_NodeHandler_HasPropertyPages() { return hrOK; }
  405. OVERRIDE_NodeHandler_CreatePropertyPages();
  406. OVERRIDE_NodeHandler_OnAddMenuItems();
  407. OVERRIDE_NodeHandler_OnCommand();
  408. OVERRIDE_NodeHandler_GetString();
  409. OVERRIDE_NodeHandler_DestroyHandler();
  410. // Choose which messages we want to handle
  411. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  412. OVERRIDE_BaseHandlerNotify_OnDelete();
  413. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  414. // Result handler functionality we override
  415. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  416. OVERRIDE_ResultHandler_OnGetResultViewType();
  417. // Implementation
  418. private:
  419. // Command handlers
  420. HRESULT OnActivateSuperscope(ITFSNode * pNode);
  421. HRESULT OnCreateNewScope(ITFSNode * pNode);
  422. HRESULT OnDelete(ITFSNode * pNode);
  423. HRESULT OnShowSuperscopeStats(ITFSNode * pNode);
  424. public:
  425. // public functions for superscope manipulation
  426. LPCWSTR GetName() { return m_strName; };
  427. void SetName(LPCWSTR pName) { m_strName = pName; }
  428. HRESULT DoesSuperscopeExist(LPCWSTR szName);
  429. HRESULT AddScope(DHCP_IP_ADDRESS scopeAddress);
  430. HRESULT RemoveScope(DHCP_IP_ADDRESS scopeAddress);
  431. HRESULT Rename(ITFSNode * pNode, LPCWSTR szNewName);
  432. HRESULT GetSuperscopeInfo(LPDHCP_SUPER_SCOPE_TABLE *pSuperscopeTable);
  433. HRESULT SetSuperscope(DHCP_IP_ADDRESS SubnetAddress, BOOL ChangeExisting);
  434. public:
  435. // helpers
  436. void SetServer(ITFSNode * pServerNode) { m_spServerNode.Set(pServerNode); }
  437. HRESULT BuildDisplayName(CString * pstrDisplayName, LPCTSTR pName);
  438. void UpdateToolbarStates();
  439. void SetState(DHCP_SUBNET_STATE dhcpState) { m_SuperscopeState = dhcpState; }
  440. void NotifyScopeStateChange(ITFSNode * pNode, DHCP_SUBNET_STATE newScopeState);
  441. // adding child nodes sorted
  442. HRESULT AddScopeSorted(ITFSNode * pServerNode, ITFSNode * pScopeNode);
  443. public:
  444. // CMTDhcpHandler functionality
  445. virtual HRESULT InitializeNode(ITFSNode * pNode);
  446. virtual void OnHaveData(ITFSNode * pParentNode, ITFSNode * pNode);
  447. virtual int GetImageIndex(BOOL bOpenImage);
  448. virtual DWORD UpdateStatistics(ITFSNode * pNode);
  449. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  450. STDMETHOD(OnNotifyExiting)(LPARAM lParam);
  451. CDhcpServer* GetServerObject()
  452. {
  453. return GETHANDLER(CDhcpServer, m_spServerNode);
  454. }
  455. HRESULT OnUpdateToolbarButtons(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  456. // Implementation
  457. private:
  458. // Attributes
  459. private:
  460. CString m_strName;
  461. CString m_strState;
  462. DHCP_SUBNET_STATE m_SuperscopeState;
  463. SPITFSNode m_spServerNode;
  464. CSuperscopeStats m_dlgStats;
  465. };
  466. /*---------------------------------------------------------------------------
  467. Class: CHostInfo
  468. ---------------------------------------------------------------------------*/
  469. class CHostInfo
  470. {
  471. public:
  472. CHostInfo()
  473. {
  474. IpAddress = 0;
  475. }
  476. CHostInfo(LPDHCP_HOST_INFO pDhcpHostInfo)
  477. {
  478. Set(pDhcpHostInfo);
  479. }
  480. CHostInfo(CHostInfo & hostInfo)
  481. {
  482. *this = hostInfo;
  483. }
  484. CHostInfo & operator = (const CHostInfo & hostInfo)
  485. {
  486. if (this != &hostInfo)
  487. {
  488. IpAddress = hostInfo.IpAddress;
  489. NetBiosName = hostInfo.NetBiosName;
  490. HostName = hostInfo.HostName;
  491. }
  492. return *this;
  493. }
  494. void Set(LPDHCP_HOST_INFO pDhcpHostInfo)
  495. {
  496. IpAddress = pDhcpHostInfo->IpAddress;
  497. NetBiosName = pDhcpHostInfo->NetBiosName;
  498. HostName = pDhcpHostInfo->HostName;
  499. }
  500. public:
  501. DHCP_IP_ADDRESS IpAddress; // minimum information always available
  502. CString NetBiosName; // optional information
  503. CString HostName; // optional information
  504. };
  505. /*---------------------------------------------------------------------------
  506. Class: CSubnetInfo
  507. ---------------------------------------------------------------------------*/
  508. class CSubnetInfo
  509. {
  510. public:
  511. CSubnetInfo()
  512. {
  513. SubnetAddress = 0;
  514. SubnetMask = 0;
  515. SubnetState = DhcpSubnetDisabled;
  516. // multicast specific fields
  517. MScopeAddressPolicy = 0;
  518. MScopeFlags = 0;
  519. TTL = 0;
  520. ExpiryTime.dwLowDateTime = 0;
  521. ExpiryTime.dwHighDateTime = 0;
  522. }
  523. CSubnetInfo(LPDHCP_SUBNET_INFO pDhcpSubnetInfo)
  524. {
  525. Set(pDhcpSubnetInfo);
  526. }
  527. CSubnetInfo(CSubnetInfo & subnetInfo)
  528. {
  529. *this = subnetInfo;
  530. }
  531. CSubnetInfo & operator = (const CSubnetInfo & subnetInfo)
  532. {
  533. if (this != &subnetInfo)
  534. {
  535. SubnetAddress = subnetInfo.SubnetAddress;
  536. SubnetMask = subnetInfo.SubnetMask;
  537. SubnetName = subnetInfo.SubnetName;
  538. SubnetComment = subnetInfo.SubnetComment;
  539. PrimaryHost = subnetInfo.PrimaryHost;
  540. SubnetState = subnetInfo.SubnetState;
  541. MScopeAddressPolicy = subnetInfo.MScopeAddressPolicy;
  542. MScopeFlags = subnetInfo.MScopeFlags;
  543. TTL = subnetInfo.TTL;
  544. ExpiryTime = subnetInfo.ExpiryTime;
  545. LangTag = subnetInfo.LangTag;
  546. }
  547. return *this;
  548. }
  549. void Set(LPDHCP_SUBNET_INFO pDhcpSubnetInfo)
  550. {
  551. SubnetAddress = pDhcpSubnetInfo->SubnetAddress;
  552. SubnetMask = pDhcpSubnetInfo->SubnetMask;
  553. SubnetName = pDhcpSubnetInfo->SubnetName;
  554. SubnetComment = pDhcpSubnetInfo->SubnetComment;
  555. PrimaryHost.Set(&pDhcpSubnetInfo->PrimaryHost);
  556. SubnetState = pDhcpSubnetInfo->SubnetState;
  557. MScopeAddressPolicy = 0;
  558. MScopeFlags = 0;
  559. TTL = 0;
  560. ExpiryTime.dwLowDateTime = 0;
  561. ExpiryTime.dwHighDateTime = 0;
  562. }
  563. void Set(LPDHCP_MSCOPE_INFO pMScopeInfo)
  564. {
  565. SubnetName = pMScopeInfo->MScopeName;
  566. SubnetComment = pMScopeInfo->MScopeComment;
  567. SubnetAddress = pMScopeInfo->MScopeId;
  568. MScopeAddressPolicy = pMScopeInfo->MScopeAddressPolicy;
  569. PrimaryHost.Set(&pMScopeInfo->PrimaryHost);
  570. SubnetState = pMScopeInfo->MScopeState;
  571. MScopeFlags = pMScopeInfo->MScopeFlags;
  572. TTL = pMScopeInfo->TTL;
  573. ExpiryTime = pMScopeInfo->ExpiryTime;
  574. LangTag = pMScopeInfo->LangTag;
  575. SubnetMask = 0;
  576. }
  577. public:
  578. // common fields
  579. DHCP_IP_ADDRESS SubnetAddress;
  580. DHCP_IP_MASK SubnetMask;
  581. CString SubnetName;
  582. CString SubnetComment;
  583. CHostInfo PrimaryHost;
  584. DHCP_SUBNET_STATE SubnetState;
  585. // multicast specific fields
  586. DWORD MScopeAddressPolicy;
  587. DWORD MScopeFlags;
  588. BYTE TTL;
  589. DATE_TIME ExpiryTime;
  590. CString LangTag;
  591. };
  592. typedef CArray<CSubnetInfo, CSubnetInfo&> CSubnetInfoArrayBase;
  593. typedef CMap<DHCP_IP_ADDRESS, DHCP_IP_ADDRESS, CSubnetInfo, CSubnetInfo &> CSubnetInfoCacheBase;
  594. /*---------------------------------------------------------------------------
  595. Class: CSubnetInfoCache
  596. ---------------------------------------------------------------------------*/
  597. class CSubnetInfoCache : public CSubnetInfoCacheBase
  598. {
  599. public:
  600. DWORD GetInfo(CString & strServer, DHCP_IP_ADDRESS ipAddress, CSubnetInfo & subnetInfo);
  601. };
  602. class CMScopeInfoCache : public CSubnetInfoArrayBase
  603. {
  604. public:
  605. DWORD GetInfo(CString & strServer, LPCTSTR pszName, CSubnetInfo & subnetInfo);
  606. BOOL Lookup(LPCTSTR pszName, CSubnetInfo & subnetInfo)
  607. {
  608. BOOL fFound = FALSE;
  609. for (int i = 0; i < GetSize(); i++)
  610. {
  611. if (GetAt(i).SubnetName.Compare(pszName) == 0)
  612. {
  613. subnetInfo = GetAt(i);
  614. fFound = TRUE;
  615. }
  616. }
  617. return fFound;
  618. }
  619. };
  620. /*---------------------------------------------------------------------------
  621. Class: CDhcpServerQueryObj
  622. ---------------------------------------------------------------------------*/
  623. class CDhcpServerQueryObj : public CDHCPQueryObj
  624. {
  625. public:
  626. CDhcpServerQueryObj(ITFSComponentData * pTFSComponentData,
  627. ITFSNodeMgr * pNodeMgr)
  628. : CDHCPQueryObj(pTFSComponentData, pNodeMgr)
  629. {
  630. // default to the cache in this object
  631. m_pSubnetInfoCache = &m_SubnetInfoCache;
  632. };
  633. STDMETHODIMP Execute();
  634. virtual void OnEventAbort(LPARAM Data, LPARAM Type);
  635. LONG CreateOption(CDhcpOption * pOption);
  636. void UpdateDefaultOptionsOnServer(CDhcpDefaultOptionsOnServer * pOptionsOnServer,
  637. CDhcpDefaultOptionsMasterList * pMasterList);
  638. void EnumSubnetsV4();
  639. void EnumSubnets();
  640. void EnumMScopes(); //Multicast scopes
  641. CDhcpSuperscope * FindSuperscope(CNodeListBase & listSuperscopes, LPWSTR pSuperScopeName);
  642. DWORD SetVersion();
  643. DWORD GetConfigInfo();
  644. DWORD GetStatistics();
  645. DWORD GetStatus();
  646. BOOL VerifyDhcpServer();
  647. public:
  648. DHCP_RESUME_HANDLE m_dhcpResumeHandle;
  649. DWORD m_dwPreferredMax;
  650. LARGE_INTEGER m_liDhcpVersion;
  651. DWORD m_dwPingRetries;
  652. BOOL m_fAuditLog;
  653. BOOL m_bStatsOnly;
  654. BOOL m_fSupportsDynBootp;
  655. BOOL m_fSupportsBindings;
  656. CString m_strDatabasePath;
  657. CString m_strBackupPath;
  658. CString m_strAuditLogPath;
  659. CString m_strServerName;
  660. CDhcpDefaultOptionsOnServer * m_pDefaultOptionsOnServer;
  661. CSubnetInfoCache * m_pSubnetInfoCache;
  662. CSubnetInfoCache m_SubnetInfoCache;
  663. CMScopeInfoCache m_MScopeInfoCache;
  664. };
  665. /*---------------------------------------------------------------------------
  666. Class: CDhcpSuperscopeQueryObj
  667. ---------------------------------------------------------------------------*/
  668. class CDhcpSuperscopeQueryObj : public CDHCPQueryObj
  669. {
  670. public:
  671. CDhcpSuperscopeQueryObj
  672. (
  673. ITFSComponentData* pTFSComponentData,
  674. ITFSNodeMgr* pNodeMgr
  675. ) : CDHCPQueryObj(pTFSComponentData, pNodeMgr) {};
  676. STDMETHODIMP Execute();
  677. public:
  678. CString m_strSuperscopeName;
  679. };
  680. /*---------------------------------------------------------------------------
  681. Class: CDhcpBootpQueryObj
  682. ---------------------------------------------------------------------------*/
  683. class CDhcpBootpQueryObj : public CDHCPQueryObj
  684. {
  685. public:
  686. CDhcpBootpQueryObj
  687. (
  688. ITFSComponentData* pTFSComponentData,
  689. ITFSNodeMgr* pNodeMgr
  690. ) : CDHCPQueryObj(pTFSComponentData, pNodeMgr) {};
  691. STDMETHODIMP Execute();
  692. };
  693. /*---------------------------------------------------------------------------
  694. Class: CDhcpGlobalOptionsQueryObj
  695. ---------------------------------------------------------------------------*/
  696. class CDhcpGlobalOptionsQueryObj : public CDHCPQueryObj
  697. {
  698. public:
  699. CDhcpGlobalOptionsQueryObj
  700. (
  701. ITFSComponentData* pTFSComponentData,
  702. ITFSNodeMgr* pNodeMgr
  703. ) : CDHCPQueryObj(pTFSComponentData, pNodeMgr) {};
  704. STDMETHODIMP Execute();
  705. public:
  706. DHCP_RESUME_HANDLE m_dhcpResumeHandle;
  707. DWORD m_dwPreferredMax;
  708. LARGE_INTEGER m_liDhcpVersion;
  709. };
  710. /*---------------------------------------------------------------------------
  711. Class: COptionNodeEnum
  712. ---------------------------------------------------------------------------*/
  713. class COptionNodeEnum : public CTFSNodeList
  714. {
  715. public:
  716. COptionNodeEnum(ITFSComponentData * pTFSCompData, ITFSNodeMgr * pNodeMgr);
  717. DWORD Enum(LPCTSTR pServer, LARGE_INTEGER & liVersion, DHCP_OPTION_SCOPE_INFO & dhcpOptionScopeInfo);
  718. protected:
  719. DWORD EnumOptions(LPCTSTR pServer, DHCP_OPTION_SCOPE_INFO & dhcpOptionScopeInfo);
  720. DWORD EnumOptionsV5(LPCTSTR pServer, DHCP_OPTION_SCOPE_INFO & dhcpOptionScopeInfo);
  721. // V5 Helper
  722. HRESULT CreateOptions(LPDHCP_OPTION_VALUE_ARRAY pOptionValues, LPCTSTR pClassName, LPCTSTR pszVendor);
  723. protected:
  724. SPITFSComponentData m_spTFSCompData;
  725. SPITFSNodeMgr m_spNodeMgr;
  726. };
  727. #endif _SERVER_H