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.

869 lines
28 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: record.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _RECORD_H
  11. #define _RECORD_H
  12. #include "dnsutil.h"
  13. #include "recordUI.h"
  14. #include "recpag1.h"
  15. #include "recpag2.h"
  16. #define DNS_RPC_RECORD_FLAG_DEFAULT 0x0
  17. //
  18. // the _USE_BLANK define would revert to using blank for inputting names
  19. // RR's at the node
  20. //
  21. #define _USE_BLANK
  22. #ifdef _USE_BLANK
  23. #else
  24. extern const WCHAR* g_szAtTheNodeInput; // string to mark the "At the node RR"
  25. #endif
  26. #define KEY_TYPE_COUNT 4
  27. #define NAME_TYPE_COUNT 3
  28. #define PROTOCOL_COUNT 5
  29. #define ALGORITHMS_COUNT 4
  30. ////////////////////////////////////////////////////////////////////////////
  31. // CDNSRecord : base class for all the DNS record types
  32. class CDNSRecord
  33. {
  34. public:
  35. CDNSRecord();
  36. virtual ~CDNSRecord() {};
  37. //protected:
  38. public:
  39. WORD m_wType;
  40. DWORD m_dwFlags;
  41. DWORD m_dwTtlSeconds;
  42. DWORD m_dwScavengeStart;
  43. public:
  44. WORD GetType() { return m_wType; }
  45. DNS_STATUS Update(LPCTSTR lpszServerName, LPCTSTR lpszZoneName, LPCTSTR lpszNodeName,
  46. CDNSRecord* pDNSRecordOld, BOOL bUseDefaultTTL);
  47. DNS_STATUS Delete(LPCTSTR lpszServerName, LPCTSTR lpszZoneName, LPCTSTR lpszNodeName);
  48. void CloneValue(CDNSRecord* pClone);
  49. void SetValue(CDNSRecord* pRecord);
  50. WORD GetRPCRecordLength()
  51. { return static_cast<WORD>(SIZEOF_DNS_RPC_RECORD_HEADER + GetRPCDataLength());}
  52. virtual WORD GetRPCDataLength() = 0;
  53. virtual void ReadRPCData(DNS_RPC_RECORD* pDnsRecord);
  54. virtual void ReadDnsQueryData(DNS_RECORD* pDnsQueryRecord);
  55. virtual void UpdateDisplayData(CString& szDisplayData) = 0;
  56. #ifdef _DEBUG
  57. void TestRPCStuff(DNS_RPC_RECORD* pDnsRecord); // TEST ONLY
  58. #endif
  59. protected:
  60. virtual void WriteRPCData(BYTE* pMem, DNS_RPC_RECORD** ppDnsRecord);
  61. // static helpers
  62. protected:
  63. static WORD RPCBufferStringLen(LPCWSTR lpsz);
  64. static void ReadRPCString(CString& sz, DNS_RPC_NAME* pDnsRPCName);
  65. static WORD WriteString(DNS_RPC_NAME* pDnsRPCName, LPCTSTR lpsz);
  66. void CopyDNSRecordData(CDNSRecord* pDest, CDNSRecord* pSource);
  67. };
  68. ////////////////////////////////////////////////////////////////////////////
  69. // CDNSRecordNodeBase : base class for all the DNS record types in the UI
  70. class CDNSRecordNodeBase : public CLeafNode
  71. {
  72. public:
  73. CDNSRecordNodeBase()
  74. {
  75. m_bAtTheNode = FALSE;
  76. m_pDNSRecord = NULL;
  77. }
  78. virtual ~CDNSRecordNodeBase();
  79. // node info
  80. DECLARE_NODE_GUID()
  81. void SetViewOptions(DWORD dwRecordViewOptions);
  82. virtual HRESULT OnCommand(long nCommandID,
  83. DATA_OBJECT_TYPES type,
  84. CComponentDataObject* pComponentData,
  85. CNodeList* pNodeList);
  86. void OnDelete(CComponentDataObject* pComponentData,
  87. CNodeList* pNodeList);
  88. virtual HRESULT OnSetToolbarVerbState(IToolbar* pToolbar,
  89. CNodeList* pNodeList);
  90. virtual LPCWSTR GetString(int nCol);
  91. virtual int GetImageIndex(BOOL bOpenImage);
  92. virtual BOOL HasPropertyPages(DATA_OBJECT_TYPES type,
  93. BOOL* pbHideVerb,
  94. CNodeList* pNodeList);
  95. virtual HRESULT CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  96. LONG_PTR handle,
  97. CNodeList* pNodeList);
  98. // DNS specific
  99. public:
  100. BOOL IsAtTheNode() { return m_bAtTheNode;}
  101. virtual void SetRecordName(LPCTSTR lpszName, BOOL bAtTheNode);
  102. CDNSDomainNode* GetDomainNode()
  103. {
  104. ASSERT(m_pContainer != NULL);
  105. return (CDNSDomainNode*)m_pContainer;
  106. }
  107. BOOL ZoneIsCache();
  108. // will override for PTR record
  109. virtual LPCWSTR GetTrueRecordName() { return GetDisplayName();}
  110. void GetFullName(CString& szFullName);
  111. void CreateFromRPCRecord(DNS_RPC_RECORD* pDnsRecord);
  112. void CreateFromDnsQueryRecord(DNS_RECORD* pDnsQueryRecord, DWORD dwFlags);
  113. DNS_STATUS Update(CDNSRecord* pDNSRecordNew, BOOL bUseDefaultTTL,
  114. BOOL bIgnoreAlreadyExists = FALSE);
  115. void SetScavengingTime(CDNSRecord* pRecord);
  116. DWORD CalculateScavengingTime();
  117. WORD GetType()
  118. { ASSERT(m_pDNSRecord != NULL); return m_pDNSRecord->GetType();}
  119. CDNSRecord* CreateCloneRecord();
  120. // delete the record from the backend and UI, keep the C++ obj
  121. DNS_STATUS DeleteOnServer();
  122. DNS_STATUS DeleteOnServerAndUI(CComponentDataObject* pComponentData);
  123. virtual CDNSRecord* CreateRecord() = 0; // see templatized derived classes
  124. void CreateDsRecordLdapPath(CString& sz);
  125. protected:
  126. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  127. { return CDNSRecordMenuHolder::GetContextMenuItem(); }
  128. virtual BOOL OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  129. long *pInsertionAllowed);
  130. virtual BOOL OnSetDeleteVerbState(DATA_OBJECT_TYPES type,
  131. BOOL* pbHide,
  132. CNodeList* pNodeList);
  133. virtual BOOL CanCloseSheets();
  134. // command handlers
  135. // pure virtual, see templatized derived classes
  136. virtual void CreatePropertyPages(CDNSRecordPropertyPage** pPageArray, int* pNmax) = 0;
  137. public:
  138. BOOL m_bAtTheNode;
  139. protected:
  140. CString m_szDisplayData; // formatted display string
  141. CDNSRecord* m_pDNSRecord;
  142. friend class CDNSRecordPropertyPageHolder; // because of CreatePropertyPages()
  143. };
  144. //////////////////////////////////////////////////////////////////////////////////
  145. // CDNSRecordNode<>
  146. // templatized class to "glue" a DNS record to a UI record node and its Property Page
  147. template <class record_class, class prop_page> class CDNSRecordNode : public CDNSRecordNodeBase
  148. {
  149. public:
  150. virtual CDNSRecord* CreateRecord() { return new record_class;}
  151. protected:
  152. virtual void CreatePropertyPages(CDNSRecordPropertyPage** pPageArray, int* pNmax)
  153. {
  154. // this template provides only one property page
  155. ASSERT(*pNmax == 0);
  156. *pNmax = 1;
  157. pPageArray[0] = new prop_page();
  158. }
  159. };
  160. //////////////////////////////////////////////////////////////////////////////////
  161. // CDNSRecordDelegatePPageNode<> :
  162. // templatized class to "glue" a DNS record to a UI record node.
  163. // This node type has no property page of its own and invokes the parent container's Property Page
  164. template <class record_class, long nStartPageCode> class CDNSRecordDelegatePPageNode :
  165. public CDNSRecordNodeBase
  166. {
  167. public:
  168. CDNSRecordDelegatePPageNode()
  169. {
  170. }
  171. virtual BOOL DelegatesPPToContainer()
  172. {
  173. if (ZoneIsCache())
  174. return FALSE;
  175. return TRUE;
  176. }
  177. virtual void ShowPageForNode(CComponentDataObject* pComponentDataObject)
  178. {
  179. CContainerNode* pCont = GetContainer();
  180. ASSERT(pCont != NULL);
  181. if (pCont->GetSheetCount() > 0)
  182. {
  183. // bring up the sheet of the container
  184. ASSERT(pComponentDataObject != NULL);
  185. pComponentDataObject->GetPropertyPageHolderTable()->BroadcastSelectPage(pCont, nStartPageCode);
  186. }
  187. }
  188. virtual HRESULT CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  189. LONG_PTR handle, CNodeList* pNodeList)
  190. {
  191. ASSERT(pNodeList->GetCount() == 1); // multi-select not supported
  192. CContainerNode* pCont = GetContainer();
  193. ASSERT(pCont != NULL);
  194. // if the RR is in the cache, need to show the page on this node
  195. if (ZoneIsCache())
  196. {
  197. return CDNSRecordNodeBase::CreatePropertyPages(lpProvider, handle, pNodeList);
  198. }
  199. // tell the container to create a new sheet
  200. return pCont->CreatePropertyPagesHelper(lpProvider, handle, nStartPageCode);
  201. }
  202. virtual CDNSRecord* CreateRecord() { return new record_class;}
  203. protected:
  204. };
  205. /////////////////////////////////////////////////////////////////////////////
  206. /////////////////// VARIOUS TYPES OF DNS RECORDS ////////////////////////////
  207. /////////////////////////////////////////////////////////////////////////////
  208. #define BEGIN_CLASS_DNS_RECORD(recClass) \
  209. class recClass : public CDNSRecord \
  210. { \
  211. public: \
  212. recClass(); \
  213. public: \
  214. virtual WORD GetRPCDataLength();\
  215. virtual void ReadRPCData(DNS_RPC_RECORD* pDnsRecord); \
  216. virtual void ReadDnsQueryData(DNS_RECORD* pDnsQueryRecord);\
  217. protected: \
  218. virtual void WriteRPCData(BYTE* pMem, DNS_RPC_RECORD** ppDnsRecord); \
  219. virtual void UpdateDisplayData(CString& szDisplayData); \
  220. public:
  221. //protected:
  222. #define END_CLASS_DNS_RECORD };
  223. #define BEGIN_DERIVED_CLASS_DNS_RECORD(baseClass, derClass, wType) \
  224. class derClass : public baseClass \
  225. { \
  226. public: \
  227. derClass() { m_wType = wType; }
  228. #define BEGIN_DERIVED_CLASS_DNS_RECORD_CONSTR(baseClass, derClass) \
  229. class derClass : public baseClass \
  230. { \
  231. public: \
  232. derClass();
  233. #define DERIVED_CLASS_DNS_RECORD(baseClass, derClass, wType) \
  234. BEGIN_DERIVED_CLASS_DNS_RECORD(baseClass, derClass, wType) END_CLASS_DNS_RECORD
  235. #define DERIVED_CLASS_DNS_RECORD_CONSTR(baseClass, derClass) \
  236. BEGIN_DERIVED_CLASS_DNS_RECORD_CONSTR(baseClass, derClass) END_CLASS_DNS_RECORD
  237. ///////////////////////////////////////////////////////////////////
  238. // CDNS_Null_Record (same as Unk Record)
  239. BEGIN_CLASS_DNS_RECORD(CDNS_Null_Record)
  240. CByteBlob m_blob;
  241. END_CLASS_DNS_RECORD
  242. ///////////////////////////////////////////////////////////////////
  243. // CDNS_A_Record
  244. BEGIN_CLASS_DNS_RECORD(CDNS_A_Record)
  245. IP_ADDRESS m_ipAddress;
  246. END_CLASS_DNS_RECORD
  247. ///////////////////////////////////////////////////////////////////
  248. // CDNS_ATMA_Record
  249. BEGIN_CLASS_DNS_RECORD(CDNS_ATMA_Record)
  250. UCHAR m_chFormat;
  251. CString m_szAddress;
  252. END_CLASS_DNS_RECORD
  253. ///////////////////////////////////////////////////////////////////
  254. // CDNS_SOA_Record
  255. BEGIN_CLASS_DNS_RECORD(CDNS_SOA_Record)
  256. DWORD m_dwSerialNo;
  257. DWORD m_dwRefresh;
  258. DWORD m_dwRetry;
  259. DWORD m_dwExpire;
  260. DWORD m_dwMinimumTtl;
  261. CString m_szNamePrimaryServer;
  262. CString m_szResponsibleParty;
  263. END_CLASS_DNS_RECORD
  264. ///////////////////////////////////////////////////////////////////
  265. // CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record
  266. BEGIN_CLASS_DNS_RECORD(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record)
  267. CString m_szNameNode;
  268. END_CLASS_DNS_RECORD
  269. DERIVED_CLASS_DNS_RECORD(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record, CDNS_PTR_Record, DNS_TYPE_PTR)
  270. DERIVED_CLASS_DNS_RECORD(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record, CDNS_NS_Record, DNS_TYPE_NS)
  271. DERIVED_CLASS_DNS_RECORD(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record, CDNS_CNAME_Record, DNS_TYPE_CNAME)
  272. DERIVED_CLASS_DNS_RECORD(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record, CDNS_MB_Record, DNS_TYPE_MB)
  273. DERIVED_CLASS_DNS_RECORD(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record, CDNS_MD_Record, DNS_TYPE_MD)
  274. DERIVED_CLASS_DNS_RECORD(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record, CDNS_MF_Record, DNS_TYPE_MF)
  275. DERIVED_CLASS_DNS_RECORD(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record, CDNS_MG_Record, DNS_TYPE_MG)
  276. DERIVED_CLASS_DNS_RECORD(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record, CDNS_MR_Record, DNS_TYPE_MR)
  277. ///////////////////////////////////////////////////////////////////
  278. // CDNS_MINFO_RP_Record
  279. BEGIN_CLASS_DNS_RECORD(CDNS_MINFO_RP_Record)
  280. CString m_szNameMailBox;
  281. CString m_szErrorToMailbox;
  282. END_CLASS_DNS_RECORD
  283. DERIVED_CLASS_DNS_RECORD(CDNS_MINFO_RP_Record, CDNS_MINFO_Record, DNS_TYPE_MINFO)
  284. DERIVED_CLASS_DNS_RECORD(CDNS_MINFO_RP_Record, CDNS_RP_Record, DNS_TYPE_RP)
  285. ///////////////////////////////////////////////////////////////////
  286. // CDNS_MX_AFSDB_RT_Record
  287. BEGIN_CLASS_DNS_RECORD(CDNS_MX_AFSDB_RT_Record)
  288. WORD m_wPreference;
  289. CString m_szNameExchange;
  290. END_CLASS_DNS_RECORD
  291. DERIVED_CLASS_DNS_RECORD_CONSTR(CDNS_MX_AFSDB_RT_Record, CDNS_MX_Record)
  292. inline CDNS_MX_Record::CDNS_MX_Record()
  293. {
  294. m_wType = DNS_TYPE_MX;
  295. m_wPreference = 10;
  296. }
  297. #define AFSDB_PREF_AFS_CELL_DB_SERV (1)
  298. #define AFSDB_PREF_DCE_AUTH_NAME_SERV (2)
  299. DERIVED_CLASS_DNS_RECORD_CONSTR(CDNS_MX_AFSDB_RT_Record, CDNS_AFSDB_Record)
  300. inline CDNS_AFSDB_Record::CDNS_AFSDB_Record()
  301. {
  302. m_wType = DNS_TYPE_AFSDB;
  303. m_wPreference = AFSDB_PREF_AFS_CELL_DB_SERV;
  304. }
  305. DERIVED_CLASS_DNS_RECORD_CONSTR(CDNS_MX_AFSDB_RT_Record, CDNS_RT_Record)
  306. inline CDNS_RT_Record::CDNS_RT_Record()
  307. {
  308. m_wType = DNS_TYPE_RT;
  309. m_wPreference = 0;
  310. }
  311. ///////////////////////////////////////////////////////////////////
  312. // CDNS_AAAA_Record
  313. BEGIN_CLASS_DNS_RECORD(CDNS_AAAA_Record)
  314. IPV6_ADDRESS m_ipv6Address;
  315. END_CLASS_DNS_RECORD
  316. ///////////////////////////////////////////////////////////////////
  317. // CDNS_HINFO_ISDN_TXT_X25_Record
  318. BEGIN_CLASS_DNS_RECORD(CDNS_HINFO_ISDN_TXT_X25_Record)
  319. protected:
  320. // overrides for derived classes
  321. virtual void SetStringCount(int n) = 0;
  322. virtual int GetStringCount() = 0;
  323. virtual void OnReadRPCString(LPCTSTR lpszStr, int k) = 0;
  324. virtual WORD OnWriteString(DNS_RPC_NAME* pDnsRPCName, int k) = 0;
  325. END_CLASS_DNS_RECORD
  326. ///////////////////////////////////////////////////////////////////
  327. // CDNS_HINFO_Record
  328. BEGIN_DERIVED_CLASS_DNS_RECORD(CDNS_HINFO_ISDN_TXT_X25_Record, CDNS_HINFO_Record, DNS_TYPE_HINFO)
  329. CString m_szCPUType;
  330. CString m_szOperatingSystem;
  331. public:
  332. virtual WORD GetRPCDataLength();
  333. protected:
  334. void UpdateDisplayData(CString& szDisplayData);
  335. virtual void SetStringCount(int n) { ASSERT(n == 2);}
  336. virtual int GetStringCount() { return 2; }
  337. virtual void OnReadRPCString(LPCTSTR lpszStr, int k);
  338. virtual WORD OnWriteString(DNS_RPC_NAME* pDnsRPCName, int k);
  339. END_CLASS_DNS_RECORD
  340. ///////////////////////////////////////////////////////////////////
  341. // CDNS_ISDN_Record
  342. BEGIN_DERIVED_CLASS_DNS_RECORD_CONSTR(CDNS_HINFO_ISDN_TXT_X25_Record, CDNS_ISDN_Record)
  343. CString m_szPhoneNumberAndDDI;
  344. CString m_szSubAddress;
  345. public:
  346. virtual WORD GetRPCDataLength();
  347. protected:
  348. void UpdateDisplayData(CString& szDisplayData);
  349. virtual void SetStringCount(int n) { ASSERT( (n == 1) || (n == 2) );}
  350. virtual int GetStringCount() { return m_szSubAddress.IsEmpty() ? 1 : 2; }
  351. virtual void OnReadRPCString(LPCTSTR lpszStr, int k);
  352. virtual WORD OnWriteString(DNS_RPC_NAME* pDnsRPCName, int k);
  353. END_CLASS_DNS_RECORD
  354. ///////////////////////////////////////////////////////////////////
  355. // CDNS_TXT_Record
  356. BEGIN_DERIVED_CLASS_DNS_RECORD_CONSTR(CDNS_HINFO_ISDN_TXT_X25_Record, CDNS_TXT_Record)
  357. CStringArray m_stringDataArray;
  358. int m_nStringDataCount;
  359. public:
  360. virtual WORD GetRPCDataLength();
  361. protected:
  362. void UpdateDisplayData(CString& szDisplayData);
  363. virtual void SetStringCount(int n) { m_nStringDataCount = n; }
  364. virtual int GetStringCount() { return m_nStringDataCount; }
  365. virtual void OnReadRPCString(LPCTSTR lpszStr, int k);
  366. virtual WORD OnWriteString(DNS_RPC_NAME* pDnsRPCName, int k);
  367. END_CLASS_DNS_RECORD
  368. ///////////////////////////////////////////////////////////////////
  369. // CDNS_X25_Record
  370. BEGIN_DERIVED_CLASS_DNS_RECORD(CDNS_HINFO_ISDN_TXT_X25_Record, CDNS_X25_Record, DNS_TYPE_X25)
  371. CString m_szX121PSDNAddress;
  372. public:
  373. virtual WORD GetRPCDataLength();
  374. protected:
  375. void UpdateDisplayData(CString& szDisplayData);
  376. virtual void SetStringCount(int n) { ASSERT(n == 1);}
  377. virtual int GetStringCount() { return 1; }
  378. virtual void OnReadRPCString(LPCTSTR lpszStr, int k);
  379. virtual WORD OnWriteString(DNS_RPC_NAME* pDnsRPCName, int k);
  380. END_CLASS_DNS_RECORD
  381. ///////////////////////////////////////////////////////////////////
  382. // CDNS_WKS_Record
  383. #define DNS_WKS_PROTOCOL_TCP (6)
  384. #define DNS_WKS_PROTOCOL_UDP (17)
  385. BEGIN_CLASS_DNS_RECORD(CDNS_WKS_Record)
  386. IP_ADDRESS m_ipAddress;
  387. UCHAR m_chProtocol;
  388. // this is not what the wire sends
  389. // currently sending a blank separated string with service names
  390. // such as "ftp telnet shell", so we use a string
  391. CString m_szServiceList;
  392. //BYTE m_bBitMask[1];
  393. END_CLASS_DNS_RECORD
  394. ///////////////////////////////////////////////////////////////////
  395. // CDNS_WINS_Record
  396. #define DNS_RR_WINS_LOOKUP_DEFAULT_TIMEOUT (2) // in seconds
  397. #define DNS_RR_WINS_CACHE_DEFAULT_TIMEOUT (60*15) // in seconds
  398. BEGIN_CLASS_DNS_RECORD(CDNS_WINS_Record)
  399. DWORD m_dwMappingFlag;
  400. DWORD m_dwLookupTimeout;
  401. DWORD m_dwCacheTimeout;
  402. CIpAddressArray m_ipWinsServersArray;
  403. int m_nWinsServerCount;
  404. END_CLASS_DNS_RECORD
  405. ///////////////////////////////////////////////////////////////////
  406. // CDNS_NBSTAT_Record
  407. BEGIN_CLASS_DNS_RECORD(CDNS_NBSTAT_Record)
  408. DWORD m_dwMappingFlag;
  409. DWORD m_dwLookupTimeout;
  410. DWORD m_dwCacheTimeout;
  411. CString m_szNameResultDomain;
  412. END_CLASS_DNS_RECORD
  413. ///////////////////////////////////////////////////////////////////
  414. // CDNS_SRV_Record
  415. BEGIN_CLASS_DNS_RECORD(CDNS_SRV_Record)
  416. WORD m_wPriority;
  417. WORD m_wWeight;
  418. WORD m_wPort;
  419. CString m_szNameTarget;
  420. END_CLASS_DNS_RECORD
  421. ///////////////////////////////////////////////////////////////////
  422. // CDNS_SIG_Record
  423. BEGIN_CLASS_DNS_RECORD(CDNS_SIG_Record)
  424. WORD m_wTypeCovered; // DNS_TYPE_<x>
  425. BYTE m_chAlgorithm; // 0,255 unsigned int
  426. BYTE m_chLabels; // 0,255 unsigned int (count)
  427. DWORD m_dwOriginalTtl;
  428. DWORD m_dwExpiration; // time in sec. from 1 Jan 1970
  429. DWORD m_dwTimeSigned; // time in sec. from 1 Jan 1970
  430. WORD m_wKeyFootprint; // algorithm dependent
  431. CString m_szSignerName;
  432. CByteBlob m_Signature;
  433. END_CLASS_DNS_RECORD
  434. ///////////////////////////////////////////////////////////////////
  435. // CDNS_KEY_Record
  436. BEGIN_CLASS_DNS_RECORD(CDNS_KEY_Record)
  437. WORD m_wFlags; // 16 one bit flags
  438. BYTE m_chProtocol; // 0,255 unsigned int
  439. BYTE m_chAlgorithm; // 0,255 unsigned int
  440. CByteBlob m_Key;
  441. END_CLASS_DNS_RECORD
  442. ///////////////////////////////////////////////////////////////////
  443. // CDNS_NXT_RECORD
  444. BEGIN_CLASS_DNS_RECORD(CDNS_NXT_Record)
  445. CDNS_NXT_Record::~CDNS_NXT_Record();
  446. CString m_szNextDomain;
  447. WORD m_wNumTypesCovered;
  448. WORD* m_pwTypesCovered;
  449. END_CLASS_DNS_RECORD
  450. ///////////////////////////////////////////////////////////////////
  451. // special derivation for PTR record node
  452. // CDNS_PTR_RecordNode
  453. class CDNS_PTR_RecordNode : public CDNSRecordNode< CDNS_PTR_Record, CDNS_PTR_RecordPropertyPage >
  454. {
  455. public:
  456. virtual LPCWSTR GetTrueRecordName();
  457. virtual void SetRecordName(LPCTSTR lpszName, BOOL bAtTheNode);
  458. void ChangeDisplayName(CDNSDomainNode* pDomainNode, BOOL bAdvancedView);
  459. private:
  460. CString m_szLastOctectName;
  461. };
  462. //////////////////////////////////////////////////////////////////
  463. // special derivation for MB record, to access name node
  464. class CDNS_MB_RecordNode : public CDNSRecordNode< CDNS_MB_Record, CDNS_MB_RecordPropertyPage >
  465. {
  466. public:
  467. LPCTSTR GetNameNodeString()
  468. {
  469. ASSERT(m_pDNSRecord != NULL);
  470. return ((CDNS_MB_Record*)m_pDNSRecord)->m_szNameNode;
  471. }
  472. };
  473. //////////////////////////////////////////////////////////////////
  474. // special derivation for A record, to access IP address
  475. class CDNS_A_RecordNode : public CDNSRecordNode< CDNS_A_Record, CDNS_A_RecordPropertyPage >
  476. {
  477. public:
  478. IP_ADDRESS GetIPAddress()
  479. {
  480. ASSERT(m_pDNSRecord != NULL);
  481. return ((CDNS_A_Record*)m_pDNSRecord)->m_ipAddress;
  482. }
  483. };
  484. ////////////////////////////////////////////////////////////////////////////////////////////////////
  485. // template classes that glue an RPC record with its property page and the corresponding UI record node
  486. typedef CDNSRecordNode<CDNS_Null_Record, CDNS_Unk_RecordPropertyPage > CDNS_Null_RecordNode;
  487. typedef CDNSRecordNode< CDNS_ATMA_Record, CDNS_ATMA_RecordPropertyPage > CDNS_ATMA_RecordNode;
  488. typedef CDNSRecordNode< CDNS_CNAME_Record, CDNS_CNAME_RecordPropertyPage > CDNS_CNAME_RecordNode;
  489. typedef CDNSRecordNode< CDNS_MD_Record, CDNS_MD_RecordPropertyPage > CDNS_MD_RecordNode;
  490. typedef CDNSRecordNode< CDNS_MF_Record, CDNS_MF_RecordPropertyPage > CDNS_MF_RecordNode;
  491. typedef CDNSRecordNode< CDNS_MG_Record, CDNS_MG_RecordPropertyPage > CDNS_MG_RecordNode;
  492. typedef CDNSRecordNode< CDNS_MR_Record, CDNS_MR_RecordPropertyPage > CDNS_MR_RecordNode;
  493. typedef CDNSRecordNode< CDNS_MINFO_Record, CDNS_MINFO_RecordPropertyPage > CDNS_MINFO_RecordNode;
  494. typedef CDNSRecordNode< CDNS_RP_Record, CDNS_RP_RecordPropertyPage > CDNS_RP_RecordNode;
  495. typedef CDNSRecordNode< CDNS_MX_Record, CDNS_MX_RecordPropertyPage > CDNS_MX_RecordNode;
  496. typedef CDNSRecordNode< CDNS_AFSDB_Record, CDNS_AFSDB_RecordPropertyPage > CDNS_AFSDB_RecordNode;
  497. typedef CDNSRecordNode< CDNS_RT_Record, CDNS_RT_RecordPropertyPage > CDNS_RT_RecordNode;
  498. typedef CDNSRecordNode< CDNS_AAAA_Record, CDNS_AAAA_RecordPropertyPage > CDNS_AAAA_RecordNode;
  499. typedef CDNSRecordNode< CDNS_HINFO_Record, CDNS_HINFO_RecordPropertyPage > CDNS_HINFO_RecordNode;
  500. typedef CDNSRecordNode< CDNS_ISDN_Record, CDNS_ISDN_RecordPropertyPage > CDNS_ISDN_RecordNode;
  501. typedef CDNSRecordNode< CDNS_TXT_Record, CDNS_TXT_RecordPropertyPage > CDNS_TXT_RecordNode;
  502. typedef CDNSRecordNode< CDNS_X25_Record, CDNS_X25_RecordPropertyPage > CDNS_X25_RecordNode;
  503. typedef CDNSRecordNode<CDNS_WKS_Record, CDNS_WKS_RecordPropertyPage > CDNS_WKS_RecordNode;
  504. typedef CDNSRecordNode<CDNS_SRV_Record, CDNS_SRV_RecordPropertyPage > CDNS_SRV_RecordNode;
  505. typedef CDNSRecordNode<CDNS_SIG_Record, CDNS_SIG_RecordPropertyPage > CDNS_SIG_RecordNode;
  506. typedef CDNSRecordNode<CDNS_KEY_Record, CDNS_KEY_RecordPropertyPage > CDNS_KEY_RecordNode;
  507. typedef CDNSRecordNode<CDNS_NXT_Record, CDNS_NXT_RecordPropertyPage > CDNS_NXT_RecordNode;
  508. ////////////////////////////////////////////////////////////////////////////
  509. // special nodes that do not have property pages by their own
  510. // unless they are in the cache
  511. #define RR_HOLDER_SOA 1
  512. #define RR_HOLDER_NS 2
  513. #define RR_HOLDER_WINS 3
  514. #include "zoneui.h" // SOA RR page
  515. class CDNS_SOA_RecordNode : public CDNSRecordDelegatePPageNode< CDNS_SOA_Record, RR_HOLDER_SOA>
  516. {
  517. public:
  518. DWORD GetMinTTL()
  519. {
  520. ASSERT(m_pDNSRecord != NULL);
  521. ASSERT(m_pDNSRecord->GetType() == DNS_TYPE_SOA);
  522. return ((CDNS_SOA_Record*)m_pDNSRecord)->m_dwMinimumTtl;
  523. }
  524. protected:
  525. virtual void CreatePropertyPages(CDNSRecordPropertyPage** pPageArray, int* pNmax)
  526. {
  527. ASSERT(ZoneIsCache());
  528. ASSERT(*pNmax == 0);
  529. *pNmax = 1;
  530. pPageArray[0] = new CDNSZone_SOA_PropertyPage(FALSE);
  531. }
  532. };
  533. class CDNS_NS_RecordNode : public CDNSRecordDelegatePPageNode< CDNS_NS_Record, RR_HOLDER_NS>
  534. {
  535. public:
  536. protected:
  537. virtual void CreatePropertyPages(CDNSRecordPropertyPage** pPageArray, int* pNmax)
  538. {
  539. ASSERT(ZoneIsCache());
  540. ASSERT(*pNmax == 0);
  541. *pNmax = 1;
  542. pPageArray[0] = new CDNS_NSCache_RecordPropertyPage();
  543. }
  544. };
  545. class CDNS_NBSTAT_RecordNode : public CDNSRecordDelegatePPageNode< CDNS_NBSTAT_Record, RR_HOLDER_WINS >
  546. {
  547. public:
  548. virtual BOOL HasPropertyPages(DATA_OBJECT_TYPES type,
  549. BOOL* pbHideVerb,
  550. CNodeList* pNodeList)
  551. {
  552. if (pNodeList->GetCount() > 1) // multiple selection
  553. {
  554. return FALSE;
  555. }
  556. if (ZoneIsCache())
  557. return FALSE;
  558. return CDNSRecordNodeBase::HasPropertyPages(type, pbHideVerb, pNodeList);
  559. }
  560. protected:
  561. virtual void CreatePropertyPages(CDNSRecordPropertyPage**, int* pNmax)
  562. {
  563. // this function should NEVER be called, because this record type
  564. // is never created fron the RR Wiz and does not have PP's
  565. ASSERT(*pNmax == 0);
  566. *pNmax = 0;
  567. }
  568. };
  569. class CDNS_WINS_RecordNode : public CDNSRecordDelegatePPageNode< CDNS_WINS_Record, RR_HOLDER_WINS >
  570. {
  571. public:
  572. virtual BOOL HasPropertyPages(DATA_OBJECT_TYPES type,
  573. BOOL* pbHideVerb,
  574. CNodeList* pNodeList)
  575. {
  576. if (pNodeList->GetCount() > 1) // multiple selection
  577. {
  578. return FALSE;
  579. }
  580. if (ZoneIsCache())
  581. return FALSE;
  582. return CDNSRecordNodeBase::HasPropertyPages(type, pbHideVerb, pNodeList);
  583. }
  584. protected:
  585. virtual void CreatePropertyPages(CDNSRecordPropertyPage**, int* pNmax)
  586. {
  587. // this function should NEVER be called, because this record type
  588. // is never created fron the RR Wiz and does not have PP's
  589. ASSERT(*pNmax == 0);
  590. *pNmax = 0;
  591. }
  592. };
  593. ////////////////////////////////////////////////////////////////////////////
  594. // special data structures and definitions to handle NS record editing
  595. ////////////////////////////////////////////////////////////////////////////
  596. // CDNS_NS_RecordNodeList
  597. // used in domain node(s) (domain, zone and root hints)
  598. class CDNS_NS_RecordNodeList : public CList< CDNS_NS_RecordNode*, CDNS_NS_RecordNode* > {};
  599. ////////////////////////////////////////////////////////////////////////////
  600. // CDNSRecordNodeEditInfo
  601. class CDNSRecordNodeEditInfoList; // fwd decl
  602. class CDNSRecordNodeEditInfo
  603. {
  604. public:
  605. typedef enum { unchanged = 0, add, remove, edit, none } actionType;
  606. CDNSRecordNodeEditInfo();
  607. ~CDNSRecordNodeEditInfo();
  608. void CreateFromExistingRecord(CDNSRecordNodeBase* pNode, BOOL bOwnMemory, BOOL bUpdateUI);
  609. void CreateFromNewRecord(CDNSRecordNodeBase* pNode);
  610. DNS_STATUS Update(CDNSDomainNode* pDomainNode, CComponentDataObject* pComponentData);
  611. DNS_STATUS Remove(CDNSDomainNode* pDomainNode, CComponentDataObject* pComponentData);
  612. private:
  613. void Cleanup();
  614. public:
  615. CDNSRecordNodeBase* m_pRecordNode;
  616. CDNSRecord* m_pRecord;
  617. CDNSRecordNodeEditInfoList* m_pEditInfoList; // list of associated records
  618. BOOL m_bExisting; // it exists in the UI or in the server
  619. BOOL m_bUpdateUI; // change the UI data structures
  620. BOOL m_bOwnMemory; // own memory pointed by m_pRecordNode
  621. BOOL m_bFromDnsQuery; // the record was obtained through DnsQuery not from the server
  622. actionType m_action; // action to be performed when committing
  623. DNS_STATUS m_dwErr; // error code when committing
  624. };
  625. class CDNSRecordNodeEditInfoList : public CList< CDNSRecordNodeEditInfo*, CDNSRecordNodeEditInfo* >
  626. {
  627. public:
  628. CDNSRecordNodeEditInfoList() { }
  629. ~CDNSRecordNodeEditInfoList() { RemoveAllNodes(); }
  630. void RemoveAllNodes()
  631. {
  632. while (!IsEmpty())
  633. {
  634. CDNSRecordNodeEditInfo* p = RemoveTail();
  635. delete p;
  636. }
  637. }
  638. };
  639. ////////////////////////////////////////////////////////////////////////////
  640. // CDNSRecordInfo : table driven info for record types
  641. #define MAX_RECORD_RESOURCE_STRLEN (1024) // lenght of the string in the RC file
  642. #define DNS_RECORD_INFO_END_OF_TABLE ((UINT)-1) // for looping through record resource tables
  643. // flags for record info entries
  644. #define DNS_RECORD_INFO_FLAG_UICREATE (0x00000001) // can create through UI
  645. #define DNS_RECORD_INFO_FLAG_CREATE_AT_NODE (0x00000002) // can create at the node
  646. #define DNS_RECORD_INFO_FLAG_SHOW_NXT (0x00000004) // can show the record in the NXT property page
  647. #define DNS_RECORD_INFO_FLAG_WHISTLER_OR_LATER (0x00000008) // the record will only show up if targetting a Whistler server
  648. #define DNS_RECORD_INFO_FLAG_UICREATE_AT_NODE \
  649. (DNS_RECORD_INFO_FLAG_UICREATE | DNS_RECORD_INFO_FLAG_CREATE_AT_NODE)
  650. struct DNS_RECORD_INFO_ENTRY
  651. {
  652. WORD wType; // as in dnsapi.h for record types
  653. LPCWSTR lpszShortName; // e.g. "SOA"
  654. LPCWSTR lpszFullName; // e.g. "Start of Authority"
  655. LPCWSTR lpszDescription; // e.g. "Record used for..."
  656. UINT nResourceID; // string resource ID in the RC file
  657. WCHAR cStringData[MAX_RECORD_RESOURCE_STRLEN];// e.g. "Start of Authority\nRecord used for..."
  658. DWORD dwFlags;
  659. };
  660. class CDNSRecordInfo
  661. {
  662. public:
  663. enum stringType { shortName, fullName, description};
  664. static const DNS_RECORD_INFO_ENTRY* GetTypeEntry(WORD wType);
  665. static LPCWSTR GetTypeString(WORD wType, stringType type);
  666. static LPCWSTR GetAtTheNodeDisplayString()
  667. { return m_szAtTheNodeDisplayString;}
  668. static const DNS_RECORD_INFO_ENTRY* GetEntry(int nIndex);
  669. static const DNS_RECORD_INFO_ENTRY* GetEntryFromName(LPCWSTR lpszName);
  670. static CDNSRecordNodeBase* CreateRecordNodeFromRPCData(LPCTSTR lpszName,
  671. DNS_RPC_RECORD* pDnsRecord, BOOL bAtTheNode);
  672. static CDNSRecordNodeBase* CreateRecordNode(WORD wType);
  673. static const DNS_RECORD_INFO_ENTRY* GetInfoEntryTable();
  674. static BOOL LoadResources();
  675. private:
  676. static CString m_szAtTheNodeDisplayString;
  677. };
  678. #endif // _RECORD_H