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.

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