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.

332 lines
11 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: zone.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _ZONE_H
  11. #define _ZONE_H
  12. #include "dnsutil.h"
  13. #include "ZoneUI.h"
  14. #define ASSERT_VALID_ZONE_INFO() \
  15. ASSERT((m_pZoneInfoEx != NULL) && (m_pZoneInfoEx->HasData()) )
  16. #define DNS_ZONE_FLAG_REVERSE (0x0)
  17. #define DNS_ZONE_Paused 0x1
  18. #define DNS_ZONE_Shutdown 0x2
  19. #define DNS_ZONE_Reverse 0x4
  20. #define DNS_ZONE_AutoCreated 0x8
  21. #define DNS_ZONE_DsIntegrated 0x10
  22. #define DNS_ZONE_Unicode 0x20
  23. /////////////////////////////////////////////////////////////////////////
  24. // CDNSZoneNode
  25. class CDNSZoneNode : public CDNSDomainNode
  26. {
  27. public:
  28. CDNSZoneNode();
  29. virtual ~CDNSZoneNode();
  30. // node info
  31. DECLARE_NODE_GUID()
  32. void InitializeFromRPCZoneInfo(PDNS_RPC_ZONE pZoneInfo, BOOL bAdvancedView);
  33. BOOL IsRootZone()
  34. {
  35. USES_CONVERSION;
  36. ASSERT(m_pZoneInfoEx != NULL);
  37. return (_wcsicmp(GetFullName(), _T(".")) == 0);
  38. }
  39. BOOL IsReverse()
  40. {
  41. ASSERT(m_pZoneInfoEx != NULL);
  42. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->fReverse :
  43. ((m_dwZoneFlags & DNS_ZONE_Reverse) != 0);
  44. }
  45. BOOL IsAutocreated()
  46. {
  47. ASSERT(m_pZoneInfoEx != NULL);
  48. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->fAutoCreated :
  49. ((m_dwZoneFlags & DNS_ZONE_AutoCreated) != 0);
  50. }
  51. DWORD GetZoneType()
  52. {
  53. ASSERT(m_pZoneInfoEx != NULL);
  54. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->dwZoneType : m_wZoneType;
  55. }
  56. DWORD GetSOARecordMinTTL()
  57. {
  58. ASSERT(m_pSOARecordNode != NULL);
  59. return m_pSOARecordNode->GetMinTTL();
  60. }
  61. // Aging/Scavenging Data Accessors
  62. DWORD GetAgingNoRefreshInterval()
  63. {
  64. ASSERT(m_pZoneInfoEx != NULL);
  65. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->dwNoRefreshInterval : DNS_DEFAULT_NOREFRESH_INTERVAL;
  66. }
  67. DWORD GetAgingRefreshInterval()
  68. {
  69. ASSERT(m_pZoneInfoEx != NULL);
  70. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->dwRefreshInterval : DNS_DEFAULT_REFRESH_INTERVAL;
  71. }
  72. DWORD GetScavengingStart()
  73. {
  74. ASSERT(m_pZoneInfoEx != NULL);
  75. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->dwAvailForScavengeTime : DNS_DEFAULT_SCAVENGING_INTERVAL;
  76. }
  77. BOOL IsScavengingEnabled()
  78. {
  79. ASSERT(m_pZoneInfoEx != NULL);
  80. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->fAging : DNS_DEFAULT_AGING_STATE;
  81. }
  82. #ifdef USE_NDNC
  83. DWORD GetDirectoryPartitionFlags()
  84. {
  85. ASSERT(m_pZoneInfoEx != NULL);
  86. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->dwDpFlags : 0;
  87. }
  88. ReplicationType GetDirectoryPartitionFlagsAsReplType();
  89. PCWSTR GetCustomPartitionName();
  90. DNS_STATUS ChangeDirectoryPartitionType(ReplicationType type, PCWSTR pszCustomPartition);
  91. #endif
  92. DNS_STATUS SetAgingNoRefreshInterval(DWORD dwNoRefreshInterval);
  93. DNS_STATUS SetAgingRefreshInterval(DWORD dwRefreshInterval);
  94. DNS_STATUS SetScavengingEnabled(BOOL bEnable);
  95. BOOL IsForwarderSlave()
  96. {
  97. ASSERT(m_pZoneInfoEx != NULL);
  98. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->fForwarderSlave : DNS_DEFAULT_SLAVE;
  99. }
  100. DWORD ForwarderTimeout()
  101. {
  102. ASSERT(m_pZoneInfoEx != NULL);
  103. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->dwForwarderTimeout : DNS_DEFAULT_FORWARD_TIMEOUT;
  104. }
  105. virtual LPCWSTR GetString(int nCol);
  106. void ChangeViewOption(BOOL bAdvanced, CComponentDataObject* pComponentDataObject);
  107. static void SetZoneNormalViewHelper(CString& szDisplayName);
  108. virtual int GetImageIndex(BOOL bOpenImage);
  109. virtual HRESULT OnCommand(long nCommandID,
  110. DATA_OBJECT_TYPES type,
  111. CComponentDataObject* pComponentData,
  112. CNodeList* pNodeList);
  113. virtual void OnDelete(CComponentDataObject* pComponentData,
  114. CNodeList* pNodeList);
  115. virtual BOOL OnRefresh(CComponentDataObject* pComponentData,
  116. CNodeList* pNodeList);
  117. virtual BOOL HasPropertyPages(DATA_OBJECT_TYPES type,
  118. BOOL* pbHideVerb,
  119. CNodeList* pNodeList);
  120. virtual HRESULT CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  121. LONG_PTR handle,
  122. CNodeList* pNodeList);
  123. virtual HRESULT CreatePropertyPagesHelper(LPPROPERTYSHEETCALLBACK lpProvider,
  124. LONG_PTR handle, long nStartPageCode);
  125. virtual void Show(BOOL bShow, CComponentDataObject* pComponentData);
  126. virtual HRESULT GetResultViewType(CComponentDataObject* pComponentData,
  127. LPOLESTR *ppViewType,
  128. long *pViewOptions);
  129. virtual HRESULT OnShow(LPCONSOLE lpConsole);
  130. virtual void ShowPageForNode(CComponentDataObject* pComponentDataObject)
  131. {
  132. if (GetSheetCount() > 0)
  133. {
  134. // bring up the sheet of the container
  135. ASSERT(pComponentDataObject != NULL);
  136. pComponentDataObject->GetPropertyPageHolderTable()->BroadcastSelectPage(this, ZONE_HOLDER_GEN);
  137. }
  138. }
  139. virtual BOOL OnSetRenameVerbState(DATA_OBJECT_TYPES type,
  140. BOOL* pbHide,
  141. CNodeList* pNodeList);
  142. virtual HRESULT OnRename(CComponentDataObject* pComponentData,
  143. LPWSTR lpszNewName);
  144. virtual BOOL CanExpandSync() { return FALSE; }
  145. protected:
  146. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  147. { return CDNSZoneMenuHolder::GetContextMenuItem(); }
  148. virtual BOOL OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  149. long *pInsertionAllowed);
  150. private:
  151. // command handlers
  152. void OnUpdateDataFile(CComponentDataObject* pComponentData);
  153. void OnReload(CComponentDataObject* pComponentData);
  154. void OnTransferFromMaster(CComponentDataObject* pComponentData);
  155. void OnReloadFromMaster(CComponentDataObject* pComponentData);
  156. // DNS specific data
  157. // cached pointers to special record types
  158. CDNS_SOA_RecordNode* m_pSOARecordNode;
  159. CDNSRecordNodeBase* m_pWINSRecordNode; // can be a WINS or an NBSTAT record
  160. // DNS specific helpers
  161. public:
  162. // creation
  163. DNS_STATUS CreatePrimary(LPCTSTR lpszDBName,
  164. BOOL bLoadExisting,
  165. BOOL bDSIntegrated,
  166. UINT nDynamicUpdate);
  167. DNS_STATUS CreateSecondary(DWORD* ipMastersArray, int nIPMastersCount,
  168. LPCTSTR lpszDBName, BOOL bLoadExisting);
  169. DNS_STATUS CreateStub(DWORD* ipMastersArray,
  170. int nIPMastersCount,
  171. LPCTSTR lpszDBName,
  172. BOOL bLoadExisting,
  173. BOOL bDSIntegrated);
  174. DNS_STATUS CreateForwarder(DWORD* ipMastersArray,
  175. int nIPMastersCount,
  176. DWORD dwTimeout,
  177. DWORD fSlave);
  178. #ifdef USE_NDNC
  179. DNS_STATUS CreatePrimaryInDirectoryPartition(BOOL bLoadExisting,
  180. UINT nDynamicUpdate,
  181. ReplicationType replType,
  182. PCWSTR pszPartitionName);
  183. DNS_STATUS CreateStubInDirectoryPartition(DWORD* ipMastersArray,
  184. int nIPMastersCount,
  185. BOOL bLoadExisting,
  186. ReplicationType replType,
  187. PCWSTR pszPartitionName);
  188. #endif
  189. //
  190. // change zone type
  191. //
  192. DNS_STATUS SetStub(DWORD cMasters,
  193. PIP_ADDRESS aipMasters,
  194. DWORD dwLoadOptions,
  195. BOOL bDSIntegrated,
  196. LPCTSTR lpszDataFile,
  197. BOOL bLocalListOfMasters);
  198. DNS_STATUS SetSecondary(DWORD cMasters,
  199. PIP_ADDRESS aipMasters,
  200. DWORD dwLoadOptions,
  201. LPCTSTR lpszDataFile);
  202. DNS_STATUS SetPrimary(DWORD dwLoadOptions,
  203. BOOL bDSIntegrated,
  204. LPCTSTR lpszDataFile);
  205. // pause/expire
  206. DNS_STATUS TogglePauseHelper(CComponentDataObject* pComponentData);
  207. BOOL IsPaused();
  208. BOOL IsExpired();
  209. // Update the result view
  210. void ToggleView(CComponentDataObject* pComponentData);
  211. // database operations
  212. BOOL IsDSIntegrated();
  213. void GetDataFile(CString& szName);
  214. LPCSTR GetDataFile();
  215. DNS_STATUS ResetDatabase(BOOL bDSIntegrated, LPCTSTR lpszDataFile);
  216. DNS_STATUS WriteToDatabase();
  217. static DNS_STATUS WriteToDatabase(LPCWSTR lpszServer, LPCWSTR lpszZone);
  218. static DNS_STATUS WriteToDatabase(LPCWSTR lpszServer, LPCSTR lpszZone);
  219. DNS_STATUS IncrementVersion();
  220. DNS_STATUS Reload();
  221. DNS_STATUS TransferFromMaster();
  222. DNS_STATUS ReloadFromMaster();
  223. PCWSTR GetDN();
  224. // dynamic update (primary only)
  225. UINT GetDynamicUpdate();
  226. DNS_STATUS SetDynamicUpdate(UINT nDynamic);
  227. // primary/secondary zone secondaries manipulation
  228. DNS_STATUS ResetSecondaries(DWORD fSecureSecondaries,
  229. DWORD cSecondaries, PIP_ADDRESS aipSecondaries,
  230. DWORD fNotifyLevel,
  231. DWORD cNotify, PIP_ADDRESS aipNotify);
  232. void GetSecondariesInfo(DWORD* pfSecureSecondaries,
  233. DWORD* cSecondaries, PIP_ADDRESS* paipSecondaries,
  234. DWORD* pfNotifyLevel,
  235. DWORD* pcNotify, PIP_ADDRESS* paipNotify);
  236. // secondary zone masters manipulation
  237. DNS_STATUS ResetMasters(DWORD cMasters, PIP_ADDRESS aipMasters, BOOL bLocalMasters = FALSE);
  238. void GetMastersInfo(DWORD* pcAddrCount, PIP_ADDRESS* ppipAddrs);
  239. void GetLocalListOfMasters(DWORD* pcAddrCount, PIP_ADDRESS* ppipAddrs);
  240. // editing API's for special record types
  241. // SOA record (edit only, cannot delete or create)
  242. BOOL HasSOARecord() { return m_pSOARecordNode != NULL; }
  243. CDNS_SOA_Record* GetSOARecordCopy();
  244. DNS_STATUS UpdateSOARecord(CDNS_SOA_Record* pNewRecord,
  245. CComponentDataObject* pComponentData);
  246. // WINS record
  247. BOOL HasWinsRecord() { return (m_pWINSRecordNode != NULL);}
  248. CDNSRecord* GetWINSRecordCopy();
  249. DNS_STATUS CreateWINSRecord(CDNSRecord* pNewWINSRecord,
  250. CComponentDataObject* pComponentData);
  251. DNS_STATUS UpdateWINSRecord(CDNSRecord* pNewWINSRecord,
  252. CComponentDataObject* pComponentData);
  253. DNS_STATUS DeleteWINSRecord(CComponentDataObject* pComponentData);
  254. DNS_STATUS Delete(BOOL bDeleteFromDs);
  255. protected:
  256. virtual void OnHaveData(CObjBase* pObj, CComponentDataObject* pComponentDataObject);
  257. // called by OnHaveData() to set cached RR ptrs and generally preprocess RR's
  258. virtual void OnHaveRecord(CDNSRecordNodeBase* pRecordNode,
  259. CComponentDataObject* pComponentDataObject);
  260. private:
  261. void NullCachedPointers();
  262. DNS_STATUS TogglePause();
  263. void FreeZoneInfo();
  264. DNS_STATUS GetZoneInfo();
  265. void AttachZoneInfo(CDNSZoneInfoEx* pNewInfo);
  266. CDNSZoneInfoEx* m_pZoneInfoEx;
  267. // following members valid only when m_pZoneInfoEx->HasInfo() is FALSE
  268. DWORD m_dwZoneFlags;
  269. WORD m_wZoneType;
  270. #ifdef USE_NDNC
  271. CString m_szPartitionName;
  272. #endif
  273. };
  274. #endif // _ZONE_H