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.

437 lines
12 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. mscope.h
  7. This file contains the prototypes for the Multicast scope node
  8. and it's children.
  9. FILE HISTORY:
  10. 07 Oct 1997 EricDav Created
  11. */
  12. #ifndef _MSCOPE_H
  13. #define _MSCOPE_H
  14. #ifndef _DHCPHAND_H
  15. #include "dhcphand.h"
  16. #endif
  17. #ifndef _DHCPNODE_H
  18. #include "nodes.h"
  19. #endif
  20. #ifndef _MSCPSTAT_H
  21. #include "mscpstat.h"
  22. #endif
  23. #ifndef _SERVER_H
  24. #include "server.h"
  25. #endif
  26. #define DHCP_QDATA_SUBNET_INFO 0x00000004
  27. class CMScopeAddressPool;
  28. void GetLangTag(CString & strLangTag);
  29. /*---------------------------------------------------------------------------
  30. Class: CDhcpMScope
  31. ---------------------------------------------------------------------------*/
  32. class CDhcpMScope : public CMTDhcpHandler
  33. {
  34. public:
  35. CDhcpMScope(ITFSComponentData * pComponentData);
  36. ~CDhcpMScope();
  37. // Interface
  38. public:
  39. // base handler functionality we override
  40. OVERRIDE_NodeHandler_OnAddMenuItems();
  41. OVERRIDE_NodeHandler_OnCommand();
  42. OVERRIDE_NodeHandler_GetString();
  43. OVERRIDE_NodeHandler_HasPropertyPages() { return hrOK; }
  44. OVERRIDE_NodeHandler_CreatePropertyPages();
  45. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  46. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  47. OVERRIDE_BaseHandlerNotify_OnDelete();
  48. // Result handler functionality we override
  49. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  50. OVERRIDE_ResultHandler_CompareItems();
  51. OVERRIDE_ResultHandler_OnGetResultViewType();
  52. public:
  53. // CMTDhcpHandler functionality
  54. virtual HRESULT InitializeNode(ITFSNode * pNode);
  55. virtual int GetImageIndex(BOOL bOpenImage);
  56. virtual void OnHaveData(ITFSNode * pParent, ITFSNode * pNew);
  57. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type);
  58. HRESULT OnUpdateToolbarButtons(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  59. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  60. CDhcpServer* GetServerObject(ITFSNode * pNode)
  61. {
  62. SPITFSNode spServerNode;
  63. pNode->GetParent(&spServerNode);
  64. return GETHANDLER(CDhcpServer, spServerNode);
  65. }
  66. CMScopeAddressPool* GetAddressPoolObject()
  67. {
  68. if (m_spAddressPool)
  69. return GETHANDLER(CMScopeAddressPool, m_spAddressPool);
  70. else
  71. return NULL;
  72. }
  73. // implementation
  74. public:
  75. // helpers
  76. void SetServer(ITFSNode * pServerNode) { m_spServerNode.Set(pServerNode); }
  77. HRESULT GetServerNode(ITFSNode ** ppNode)
  78. {
  79. m_spServerNode->AddRef();
  80. *ppNode = m_spServerNode;
  81. return hrOK;
  82. }
  83. CDhcpServer * GetServerObject() { return GETHANDLER(CDhcpServer, m_spServerNode); }
  84. LPCWSTR GetServerIpAddress();
  85. void GetServerIpAddress(DHCP_IP_ADDRESS * pdhcpIpAddress);
  86. void GetServerVersion(LARGE_INTEGER& liVersion);
  87. HRESULT BuildDisplayName(CString * pstrDisplayName, LPCTSTR pName);
  88. void UpdateToolbarStates();
  89. // dhcp specific
  90. DWORD SetInfo(LPCTSTR pNewName = NULL);
  91. HRESULT InitMScopeInfo(LPDHCP_MSCOPE_INFO pMScopeInfo);
  92. HRESULT InitMScopeInfo(CSubnetInfo & subnetInfo);
  93. // public functions for scope manipulation
  94. LPCWSTR GetName() { return m_SubnetInfo.SubnetName; };
  95. HRESULT SetName(LPCTSTR pName);
  96. LPCWSTR GetComment() { return m_SubnetInfo.SubnetComment; };
  97. void SetComment(LPCWSTR pComment) { m_SubnetInfo.SubnetComment = pComment; };
  98. DWORD GetScopeId() { return m_SubnetInfo.SubnetAddress; }
  99. // Functions to get and set the lease time
  100. DWORD GetLeaseTime(LPDWORD pdwLeaseTime);
  101. DWORD SetLeaseTime(DWORD dwLeaseTime);
  102. // Functions to get and set the madcap scope lifetime
  103. DWORD GetLifetime(DATE_TIME * pdtLifetime);
  104. DWORD SetLifetime(DATE_TIME * pdtLifetime);
  105. // Functions to get and set the TTL
  106. DWORD GetTTL(LPBYTE TTL);
  107. DWORD SetTTL(BYTE TTL);
  108. // option functionality
  109. DWORD SetOptionValue(CDhcpOption * pdhcType);
  110. DWORD GetOptionValue(DHCP_OPTION_ID OptionID,
  111. DHCP_OPTION_VALUE ** ppdhcOptionValue);
  112. DWORD RemoveOptionValue(DHCP_OPTION_ID dhcOptId);
  113. DWORD DeleteClient(DHCP_IP_ADDRESS dhcpClientIpAddress);
  114. DWORD UpdateIpRange(DHCP_IP_RANGE * pdhipr);
  115. DWORD SetIpRange(DHCP_IP_RANGE *pdhcpIpRange, BOOL bSetOnServer);
  116. DWORD SetIpRange(const CDhcpIpRange & dhcpIpRange, BOOL bSetOnServer);
  117. void QueryIpRange (DHCP_IP_RANGE * pdhipr);
  118. DWORD GetIpRange (DHCP_IP_RANGE * pdhipr);
  119. DWORD StoreExceptionList(CExclusionList * plistExclusions);
  120. DWORD AddExclusion(CDhcpIpRange & dhcpIpRange, BOOL bAddToUI = FALSE);
  121. DWORD RemoveExclusion(CDhcpIpRange & dhcpIpRange);
  122. BOOL IsOverlappingRange(CDhcpIpRange & dhcpIpRange);
  123. DWORD IsValidExclusion(CDhcpIpRange & dhcpExclusion);
  124. DWORD AddElement(DHCP_SUBNET_ELEMENT_DATA_V4 * pdhcpSubnetElementData);
  125. DWORD RemoveElement(DHCP_SUBNET_ELEMENT_DATA_V4 * pdhcpSubnetElementData, BOOL bForce = FALSE);
  126. // interal state information
  127. BOOL IsEnabled() { return m_SubnetInfo.SubnetState == DhcpSubnetEnabled; }
  128. void SetState(DHCP_SUBNET_STATE dhcpSubnetState) { m_SubnetInfo.SubnetState = dhcpSubnetState; }
  129. DHCP_SUBNET_STATE GetState() { return m_SubnetInfo.SubnetState; }
  130. private:
  131. // command handlers
  132. DWORD OnActivateScope(ITFSNode * pNode);
  133. HRESULT OnReconcileScope(ITFSNode * pNode);
  134. HRESULT OnShowScopeStats(ITFSNode * pNode);
  135. HRESULT OnDelete(ITFSNode * pNode);
  136. // Implementation
  137. private:
  138. // Attributes
  139. private:
  140. CSubnetInfo m_SubnetInfo;
  141. CString m_strState;
  142. DHCP_SUBNET_STATE m_dhcpSubnetState;
  143. DWORD m_dwLeaseTime;
  144. SPITFSNode m_spAddressPool;
  145. SPITFSNode m_spActiveLeases;
  146. SPITFSNode m_spServerNode;
  147. CMScopeStats m_dlgStats;
  148. };
  149. /*---------------------------------------------------------------------------
  150. Class: CDhcpMScopeSubobject
  151. All subobjects of a scope derive from this to provide base
  152. functionality to get information from the scope.
  153. ---------------------------------------------------------------------------*/
  154. class CDhcpMScopeSubobject
  155. {
  156. public:
  157. CDhcpMScope * GetScopeObject(ITFSNode * pNode,
  158. BOOL bResClient = FALSE)
  159. {
  160. if (pNode == NULL)
  161. return NULL;
  162. SPITFSNode spScopeNode;
  163. if (bResClient)
  164. {
  165. SPITFSNode spResNode;
  166. pNode->GetParent(&spResNode);
  167. spResNode->GetParent(&spScopeNode);
  168. }
  169. else
  170. {
  171. pNode->GetParent(&spScopeNode);
  172. }
  173. return GETHANDLER(CDhcpMScope, spScopeNode);
  174. }
  175. ITFSNode * GetServerNode(ITFSNode * pNode, BOOL bResClient = FALSE)
  176. {
  177. CDhcpMScope * pScope = GetScopeObject(pNode, bResClient);
  178. SPITFSNode spServerNode;
  179. if (pScope)
  180. {
  181. pScope->GetServerNode(&spServerNode);
  182. spServerNode->AddRef();
  183. }
  184. return spServerNode;
  185. }
  186. LPCTSTR GetServerName(ITFSNode * pNode,
  187. BOOL bResClient = FALSE)
  188. {
  189. LPCTSTR pszReturn = NULL;
  190. CDhcpMScope * pScope = GetScopeObject(pNode, bResClient);
  191. if (pScope)
  192. {
  193. CDhcpServer * pServer = pScope->GetServerObject();
  194. if (pServer)
  195. pszReturn = pServer->GetName();
  196. }
  197. return pszReturn;
  198. }
  199. LPCTSTR GetServerIpAddress(ITFSNode * pNode,
  200. BOOL bResClient = FALSE)
  201. {
  202. CDhcpMScope * pScope = GetScopeObject(pNode, bResClient);
  203. if (pScope)
  204. return pScope->GetServerIpAddress();
  205. else
  206. return NULL;
  207. }
  208. void GetServerIpAddress(ITFSNode * pNode,
  209. DHCP_IP_ADDRESS * pdhcpIpAddress,
  210. BOOL bResClient = FALSE)
  211. {
  212. CDhcpMScope * pScope = GetScopeObject(pNode, bResClient);
  213. if (pScope)
  214. pScope->GetServerIpAddress(pdhcpIpAddress);
  215. }
  216. void GetServerVersion(ITFSNode * pNode,
  217. LARGE_INTEGER& liVersion,
  218. BOOL bResClient = FALSE)
  219. {
  220. CDhcpMScope * pScope = GetScopeObject(pNode, bResClient);
  221. if (pScope)
  222. pScope->GetServerVersion(liVersion);
  223. }
  224. };
  225. /*---------------------------------------------------------------------------
  226. Class: CMScopeActiveLeases
  227. ---------------------------------------------------------------------------*/
  228. class CMScopeActiveLeases :
  229. public CMTDhcpHandler,
  230. public CDhcpMScopeSubobject
  231. {
  232. public:
  233. CMScopeActiveLeases(ITFSComponentData * pComponentData);
  234. ~CMScopeActiveLeases();
  235. // Interface
  236. public:
  237. // Node handler functionality we override
  238. OVERRIDE_NodeHandler_OnAddMenuItems();
  239. OVERRIDE_NodeHandler_OnCommand();
  240. OVERRIDE_NodeHandler_GetString()
  241. { return (nCol == 0) ? GetDisplayName() : NULL; }
  242. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  243. // Result Handler notification
  244. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  245. OVERRIDE_ResultHandler_OnGetResultViewType();
  246. OVERRIDE_ResultHandler_CompareItems();
  247. public:
  248. // CDhcpHandler overrides
  249. virtual HRESULT InitializeNode(ITFSNode * pNode);
  250. virtual int GetImageIndex(BOOL bOpenImage);
  251. public:
  252. // implementation specifiec
  253. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  254. // Implementation
  255. private:
  256. int CompareIpAddresses(CDhcpMCastLease * pDhcpAL1, CDhcpMCastLease * pDhcpAL2);
  257. // Attributes
  258. private:
  259. };
  260. /*---------------------------------------------------------------------------
  261. Class: CMScopeAddressPool
  262. ---------------------------------------------------------------------------*/
  263. class CMScopeAddressPool :
  264. public CMTDhcpHandler,
  265. public CDhcpMScopeSubobject
  266. {
  267. public:
  268. CMScopeAddressPool(ITFSComponentData * pComponentData);
  269. ~CMScopeAddressPool();
  270. // Interface
  271. public:
  272. // Node handler functionality we override
  273. OVERRIDE_NodeHandler_OnAddMenuItems();
  274. OVERRIDE_NodeHandler_OnCommand();
  275. OVERRIDE_NodeHandler_GetString()
  276. { return (nCol == 0) ? GetDisplayName() : NULL; }
  277. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  278. // Result Handler notification
  279. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  280. OVERRIDE_ResultHandler_CompareItems();
  281. OVERRIDE_ResultHandler_OnGetResultViewType();
  282. public:
  283. // CDhcpHandler overrides
  284. virtual HRESULT InitializeNode(ITFSNode * pNode);
  285. virtual int GetImageIndex(BOOL bOpenImage);
  286. public:
  287. // implementation specific
  288. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  289. private:
  290. // command handlers
  291. DWORD OnCreateNewExclusion(ITFSNode * pNode);
  292. // Attributes
  293. private:
  294. };
  295. /*---------------------------------------------------------------------------
  296. Class: CDhcpMScopeQueryObj
  297. ---------------------------------------------------------------------------*/
  298. class CDhcpMScopeQueryObj : public CDHCPQueryObj
  299. {
  300. public:
  301. CDhcpMScopeQueryObj
  302. (
  303. ITFSComponentData* pTFSComponentData,
  304. ITFSNodeMgr* pNodeMgr
  305. ) : CDHCPQueryObj(pTFSComponentData, pNodeMgr) {};
  306. STDMETHODIMP Execute();
  307. HRESULT CreateSubcontainers();
  308. public:
  309. CString m_strName;
  310. };
  311. /*---------------------------------------------------------------------------
  312. Class: CMScopeActiveLeasesQueryObj
  313. ---------------------------------------------------------------------------*/
  314. class CMScopeActiveLeasesQueryObj : public CDHCPQueryObj
  315. {
  316. public:
  317. CMScopeActiveLeasesQueryObj(ITFSComponentData * pTFSCompData,
  318. ITFSNodeMgr * pNodeMgr)
  319. : CDHCPQueryObj(pTFSCompData, pNodeMgr) { m_nQueueCountMax = 20; }
  320. STDMETHODIMP Execute();
  321. HRESULT EnumerateLeases();
  322. LARGE_INTEGER m_liDhcpVersion;
  323. DHCP_RESUME_HANDLE m_dhcpResumeHandle;
  324. DWORD m_dwPreferredMax;
  325. CString m_strName;
  326. };
  327. /*---------------------------------------------------------------------------
  328. Class: CMScopeAddressPoolQueryObj
  329. ---------------------------------------------------------------------------*/
  330. class CMScopeAddressPoolQueryObj : public CDHCPQueryObj
  331. {
  332. public:
  333. CMScopeAddressPoolQueryObj(ITFSComponentData * pTFSCompData,
  334. ITFSNodeMgr * pNodeMgr)
  335. : CDHCPQueryObj(pTFSCompData, pNodeMgr),
  336. m_dwError(0) {};
  337. STDMETHODIMP Execute();
  338. HRESULT EnumerateIpRanges();
  339. HRESULT EnumerateExcludedIpRanges();
  340. public:
  341. CString m_strName;
  342. DHCP_RESUME_HANDLE m_dhcpExclResumeHandle;
  343. DWORD m_dwExclPreferredMax;
  344. DHCP_RESUME_HANDLE m_dhcpIpResumeHandle;
  345. DWORD m_dwIpPreferredMax;
  346. DWORD m_dwError;
  347. };
  348. #endif _MSCOPE_H