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.

314 lines
7.6 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1998-2002
  3. Module Name:
  4. dnscmn.h
  5. Abstract:
  6. Domain Name System (DNS) Netdiag tests.
  7. Author:
  8. Elena Apreutesei (elenaap) 10/22/98
  9. Revision History:
  10. jamesg May 2002 -- cleanup for network info changes
  11. jamesg Sept 2000 -- more scrub and cleanup
  12. --*/
  13. #ifndef _DNSCOMMON_H_
  14. #define _DNSCOMMON_H_
  15. #include <dnslib.h>
  16. //
  17. // Version note:
  18. // - code cleanup but
  19. // - uses "fixed up" DNS_NETWORK_INFORMATION (UTF8)
  20. // - not converted to public DNS_NETWORK_INFO struct
  21. // - not unicode
  22. // - not IP6 aware
  23. //
  24. //
  25. // Currently getting DNS info in UTF8
  26. //
  27. //#define PDNS_NETINFO PDNS_NETWORK_INFOW
  28. //#define PDNS_ADAPTER PDNS_ADAPTER_INFOW
  29. //#define PDNS_NETINFO PDNS_NETWORK_INFORMATION
  30. //#define PDNS_ADAPTER PDNS_ADAPTER_INFORMATION
  31. //#define PDNS_SERVER_INFO PDNS_SERVER_INFORMATION
  32. //
  33. // DNS structures
  34. //
  35. // DCR: replace with public DNS structures
  36. //
  37. // These are a mapping of old public DNS structures onto private
  38. // netdiag structures to preserve the netdiag names and
  39. // field names. They should be replaced by switching to a
  40. // new set of unicode public structures.
  41. //
  42. typedef struct
  43. {
  44. IP4_ADDRESS IpAddress;
  45. DWORD Priority;
  46. }
  47. DNS_SERVER_INFO, *PDNS_SERVER_INFO;
  48. typedef struct
  49. {
  50. PSTR pszAdapterGuidName;
  51. PSTR pszAdapterDomain;
  52. PVOID pReserved1;
  53. PVOID pReserved2;
  54. DWORD InfoFlags;
  55. DWORD ServerCount;
  56. DNS_SERVER_INFO ServerArray[1];
  57. }
  58. DNS_ADAPTER, *PDNS_ADAPTER;
  59. typedef struct
  60. {
  61. PSTR pszDomainOrZoneName;
  62. DWORD NameCount;
  63. PSTR SearchNameArray[1];
  64. }
  65. SEARCH_LIST, *PSEARCH_LIST;
  66. typedef struct
  67. {
  68. PSEARCH_LIST pSearchList;
  69. DWORD AdapterCount;
  70. PDNS_ADAPTER AdapterArray[1];
  71. }
  72. DNS_NETINFO, *PDNS_NETINFO;
  73. //
  74. // Build sanity check
  75. //
  76. C_ASSERT( sizeof(SEARCH_LIST) == sizeof(DNS_SEARCH_INFORMATION) );
  77. C_ASSERT( sizeof(DNS_SERVER_INFO) == sizeof(DNS_SERVER_INFORMATION) );
  78. C_ASSERT( sizeof(DNS_ADAPTER) == sizeof(DNS_ADAPTER_INFORMATION) );
  79. C_ASSERT( sizeof(DNS_NETINFO) == sizeof(DNS_NETWORK_INFORMATION) );
  80. //
  81. // Map dnsapi.h def for network config retrieval
  82. //
  83. #define DnsConfigNetworkInfoUTF8 DnsConfigNetworkInformation
  84. //
  85. // Private dnsapi.dll interface for netdiag
  86. //
  87. DNS_STATUS
  88. DnsNetworkInformation_CreateFromFAZ(
  89. IN PCSTR pszName,
  90. IN DWORD dwFlags,
  91. IN PIP4_ARRAY pIp4Servers,
  92. OUT PDNS_NETINFO * ppNetworkInfo
  93. );
  94. //
  95. // Private defines
  96. //
  97. #define MAX_NAME_SERVER_COUNT (20)
  98. #define MAX_ADDRS (35)
  99. #define DNS_QUERY_DATABASE (0x200)
  100. #define IP_ARRAY_SIZE(a) (sizeof(DWORD) + (a)*sizeof(IP_ADDRESS))
  101. #define IP4_ARRAY_SIZE(a) IP_ARRAY_SIZE(a)
  102. // Use dnslib memory routines
  103. #define ALLOCATE_HEAP(iSize) Dns_Alloc(iSize)
  104. #define ALLOCATE_HEAP_ZERO(iSize) Dns_AllocZero(iSize)
  105. #define REALLOCATE_HEAP(pMem,iSize) Dns_Realloc((pMem),(iSize))
  106. #define FREE_HEAP(pMem) Dns_Free(pMem)
  107. //
  108. // Registration info blob
  109. //
  110. typedef struct
  111. {
  112. PVOID pNext;
  113. char szDomainName[DNS_MAX_NAME_BUFFER_LENGTH];
  114. char szAuthoritativeZone[DNS_MAX_NAME_BUFFER_LENGTH];
  115. DWORD dwAuthNSCount;
  116. IP_ADDRESS AuthoritativeNS[MAX_NAME_SERVER_COUNT];
  117. DWORD dwIPCount;
  118. IP_ADDRESS IPAddresses[MAX_ADDRS];
  119. DNS_STATUS AllowUpdates;
  120. }
  121. REGISTRATION_INFO, *PREGISTRATION_INFO;
  122. //
  123. // DNS test functions
  124. //
  125. BOOL
  126. SameAuthoritativeServers(
  127. IN PREGISTRATION_INFO pCurrent,
  128. IN PIP4_ARRAY pNS
  129. );
  130. DNS_STATUS
  131. ComputeExpectedRegistration(
  132. IN LPSTR pszHostName,
  133. IN LPSTR pszPrimaryDomain,
  134. IN PDNS_NETINFO pNetworkInfo,
  135. OUT PREGISTRATION_INFO * ppExpectedRegistration,
  136. OUT NETDIAG_PARAMS * pParams,
  137. OUT NETDIAG_RESULT * pResults
  138. );
  139. VOID
  140. AddToExpectedRegistration(
  141. IN LPSTR pszDomain,
  142. IN PDNS_ADAPTER pAdapterInfo,
  143. IN PDNS_NETINFO pFazResult,
  144. IN PIP4_ARRAY pNS,
  145. OUT PREGISTRATION_INFO * ppExpectedRegistration
  146. );
  147. HRESULT
  148. VerifyDnsRegistration(
  149. IN LPSTR pszHostName,
  150. IN PREGISTRATION_INFO pExpectedRegistration,
  151. IN NETDIAG_PARAMS * pParams,
  152. IN OUT NETDIAG_RESULT * pResults
  153. );
  154. HRESULT
  155. CheckDnsRegistration(
  156. IN PDNS_NETINFO pNetworkInfo,
  157. IN NETDIAG_PARAMS * pParams,
  158. IN OUT NETDIAG_RESULT * pResults
  159. );
  160. VOID
  161. CompareCachedAndRegistryNetworkInfo(
  162. IN PDNS_NETINFO pNetworkInfo
  163. );
  164. PIP4_ARRAY
  165. ServerInfoToIpArray(
  166. IN DWORD ServerCount,
  167. IN PDNS_SERVER_INFO ServerArray
  168. );
  169. DNS_STATUS
  170. DnsFindAllPrimariesAndSecondaries(
  171. IN LPSTR pszName,
  172. IN DWORD dwFlags,
  173. IN PIP4_ARRAY aipQueryServers,
  174. OUT PDNS_NETINFO * ppNetworkInfo,
  175. OUT PIP4_ARRAY * ppNameServers,
  176. OUT PIP4_ARRAY * ppPrimaries
  177. );
  178. PIP4_ARRAY
  179. GrabNameServersIp(
  180. IN PDNS_RECORD pDnsRecord
  181. );
  182. DNS_STATUS
  183. IsDnsServerPrimaryForZone_UTF8(
  184. IN IP4_ADDRESS Ip,
  185. IN PSTR pZone
  186. );
  187. DNS_STATUS
  188. IsDnsServerPrimaryForZone_W(
  189. IN IP4_ADDRESS Ip,
  190. IN PWSTR pZone
  191. );
  192. DNS_STATUS
  193. DnsUpdateAllowedTest_UTF8(
  194. IN HANDLE hContextHandle OPTIONAL,
  195. IN PSTR pszName,
  196. IN PSTR pszAuthZone,
  197. IN PIP4_ARRAY pDnsServers
  198. );
  199. DNS_STATUS
  200. DnsUpdateAllowedTest_W(
  201. IN HANDLE hContextHandle OPTIONAL,
  202. IN LPWSTR pwszName,
  203. IN LPWSTR pwszAuthZone,
  204. IN PIP4_ARRAY pDnsServers
  205. );
  206. DNS_STATUS
  207. DnsQueryAndCompare(
  208. IN LPSTR lpstrName,
  209. IN WORD wType,
  210. IN DWORD fOptions,
  211. IN PIP4_ARRAY aipServers OPTIONAL,
  212. IN OUT PDNS_RECORD * ppQueryResultsSet OPTIONAL,
  213. IN OUT PVOID * pReserved OPTIONAL,
  214. IN PDNS_RECORD pExpected OPTIONAL,
  215. IN BOOL bInclusionOk,
  216. IN BOOL bUnicode,
  217. IN OUT PDNS_RECORD * ppDiff1 OPTIONAL,
  218. IN OUT PDNS_RECORD * ppDiff2 OPTIONAL
  219. );
  220. BOOLEAN
  221. DnsCompareRRSet_W (
  222. IN PDNS_RECORD pRRSet1,
  223. IN PDNS_RECORD pRRSet2,
  224. OUT PDNS_RECORD * ppDiff1,
  225. OUT PDNS_RECORD * ppDiff2
  226. );
  227. DNS_STATUS
  228. QueryDnsServerDatabase(
  229. IN LPSTR pszName,
  230. IN WORD wType,
  231. IN IP4_ADDRESS ServerIp,
  232. OUT PDNS_RECORD * ppDnsRecord,
  233. IN BOOL bUnicode,
  234. OUT BOOL * pIsLocal
  235. );
  236. BOOL
  237. GetAnswerTtl(
  238. IN PDNS_RECORD pRec,
  239. OUT PDWORD pTtl
  240. );
  241. DNS_STATUS
  242. GetAllDnsServersFromRegistry(
  243. IN PDNS_NETINFO pNetworkInfo,
  244. OUT PIP4_ARRAY * pIpArray
  245. );
  246. LPSTR
  247. UTF8ToAnsi(
  248. IN LPSTR pStr
  249. );
  250. #endif