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.

1825 lines
42 KiB

  1. /*++
  2. Copyright (c) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. dnsapi.h
  5. Abstract:
  6. Domain Name System (DNS)
  7. DNS Client API Library
  8. Author:
  9. Jim Gilroy (jamesg) December 7, 1996
  10. Revision History:
  11. --*/
  12. #ifndef _DNSAPI_INCLUDED_
  13. #define _DNSAPI_INCLUDED_
  14. #ifndef _WINSOCK2API_
  15. #ifndef _WINSOCKAPI_
  16. #include <winsock2.h>
  17. #endif
  18. #endif
  19. #include <windns.h>
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif // __cplusplus
  24. //
  25. // Definitions for testing
  26. //
  27. #ifdef DNS_INTERNAL
  28. #define DNSTEST_BUILD 1
  29. #endif
  30. //
  31. // DCR: add to winerror.h
  32. //
  33. #define DNS_ERROR_REFFERAL_PACKET 9506L
  34. //
  35. // Handy IP string macro
  36. //
  37. #define IP_STRING( IpAddr ) inet_ntoa( *(struct in_addr *)&(IpAddr) )
  38. #define IP4_STRING( IpAddr ) inet_ntoa( *(struct in_addr *)&(IpAddr) )
  39. //
  40. // Byte flipping macros
  41. //
  42. #define FlipUnalignedDword( pDword ) \
  43. (DWORD)ntohl( *(UNALIGNED DWORD *)(pDword) )
  44. #define FlipUnalignedWord( pWord ) \
  45. (WORD)ntohs( *(UNALIGNED WORD *)(pWord) )
  46. // Inline is faster, but NO side effects allowed in marco argument
  47. #define InlineFlipUnaligned48Bits( pch ) \
  48. ( ( *(PUCHAR)(pch) << 40 ) | \
  49. ( *((PUCHAR)(pch) + 1) << 32 ) | \
  50. ( *((PUCHAR)(pch) + 2) << 24 ) | \
  51. ( *((PUCHAR)(pch) + 3) << 16 ) | \
  52. ( *((PUCHAR)(pch) + 4) << 8 ) | \
  53. ( *((PUCHAR)(pch) + 5) ) )
  54. #define InlineFlipUnalignedDword( pch ) \
  55. ( ( *(PUCHAR)(pch) << 24 ) | \
  56. ( *((PUCHAR)(pch) + 1) << 16 ) | \
  57. ( *((PUCHAR)(pch) + 2) << 8 ) | \
  58. ( *((PUCHAR)(pch) + 3) ) )
  59. #define InlineFlipUnalignedWord( pch ) \
  60. ( ((WORD)*((PUCHAR)(pch)) << 8) + (WORD)*((PUCHAR)(pch) + 1) )
  61. //
  62. // Unaligned write without flipping
  63. //
  64. #define WRITE_UNALIGNED_WORD( pout, word ) \
  65. ( *(UNALIGNED WORD *)(pout) = word )
  66. #define WRITE_UNALIGNED_DWORD( pout, dword ) \
  67. ( *(UNALIGNED DWORD *)(pout) = dword )
  68. //
  69. // DNS_ADDR -- IP4/6 sockaddr union
  70. //
  71. // DNS_ADDR allows compile and runtime IP4/6 union but also
  72. // carries sockaddr LENGTH, making it more "object-like" --
  73. // an annoying ommission from winsock2.
  74. //
  75. // In addition, this allows the developer to pack in any other
  76. // desirable context to travel with the address.
  77. //
  78. #define DNS_ADDR_MAX_SOCKADDR_LENGTH (32)
  79. #ifdef MIDL_PASS
  80. typedef struct _DnsAddr
  81. {
  82. CHAR MaxSa[ DNS_ADDR_MAX_SOCKADDR_LENGTH ];
  83. DWORD DnsAddrUserDword[8];
  84. }
  85. DNS_ADDR, *PDNS_ADDR;
  86. #else
  87. typedef struct _DnsAddr
  88. {
  89. union
  90. {
  91. SOCKADDR Sockaddr;
  92. SOCKADDR_IN SockaddrIn;
  93. #ifdef _WS2TCPIP_H_
  94. SOCKADDR_IN6 SockaddrIn6;
  95. #endif
  96. CHAR MaxSa[ DNS_ADDR_MAX_SOCKADDR_LENGTH ];
  97. };
  98. DWORD SockaddrLength;
  99. //
  100. // The remaining structure is user extensible
  101. // Define both common uses (some used internally by DNS)
  102. // and user extensions.
  103. //
  104. // At least one unique name is defined for every field so
  105. // that user can macro to an appropriate name for their application
  106. // to produce readable code.
  107. //
  108. union
  109. {
  110. struct
  111. {
  112. DWORD SubnetLength;
  113. DWORD Flags;
  114. DWORD Status;
  115. };
  116. struct
  117. {
  118. DWORD DnsAddrUser0Dword2;
  119. DWORD DnsAddrUser0Dword3;
  120. DWORD DnsAddrUser0Dword4;
  121. };
  122. };
  123. //
  124. // Last 16 bytes setup with multiple unions to give
  125. // user choice of byte, DWORD and pointer fields.
  126. //
  127. // Note that pointer fields are setup to be both 32 and 64 bit
  128. // capable. (A loss of space, but necessary -- otherwise the
  129. // structure would balloon beyond 64 bytes in 64-bit architectures.)
  130. //
  131. // Note that obviously any use of pointers will not be "understood"
  132. // by MIDL compile or transmitted by RPC.
  133. //
  134. union
  135. {
  136. CHAR DnsAddrUserBytes[16];
  137. struct
  138. {
  139. DWORD Priority;
  140. DWORD Weight;
  141. DWORD Tag;
  142. DWORD Reserved;
  143. };
  144. struct
  145. {
  146. DWORD DnsAddrUser1Dword1;
  147. DWORD DnsAddrUser1Dword2;
  148. DWORD DnsAddrUser1Dword3;
  149. DWORD DnsAddrUser1Dword4;
  150. };
  151. struct
  152. {
  153. DWORD DnsAddrUser2Dword1;
  154. DWORD DnsAddrUser2Dword2;
  155. UINT_PTR DnsAddrUser2Ptr1;
  156. };
  157. struct
  158. {
  159. UINT_PTR DnsAddrUser3Ptr1;
  160. UINT_PTR DnsAddrUser3Ptr2;
  161. };
  162. };
  163. }
  164. DNS_ADDR, *PDNS_ADDR;
  165. #endif
  166. //
  167. // DNS_ADDR macros
  168. //
  169. #define SOCKADDR_IS_IP4( pSa ) ( (pSa)->sa_family == AF_INET )
  170. #define SOCKADDR_IS_IP6( pSa ) ( (pSa)->sa_family == AF_INET6 )
  171. #define SOCKADDR_IS_ATM( pSa ) ( (pSa)->sa_family == AF_ATM )
  172. #define DNS_ADDR_IS_IP4( pA ) SOCKADDR_IS_IP4( &(pA)->Sockaddr )
  173. #define DNS_ADDR_IS_IP6( pA ) SOCKADDR_IS_IP6( &(pA)->Sockaddr )
  174. #define DNS_ADDR_IP4_STRING( p ) inet_ntoa( (p)->SockaddrIn.sin_addr )
  175. #define DNS_ADDR_IP6_STRING( p ) IPADDR_STRING( (p)->SockaddrIn6.sin6_addr )
  176. #define DNS_ADDR_IP_STRING_BUFFER_LENGTH (64)
  177. #define DNS_ADDR_STRING_BUFFER_LENGTH (128)
  178. //
  179. // DNS_ADDR_ARRAY
  180. //
  181. // This is a flat array of DNS_ADDRs
  182. // - MaxCount is the memory size count of DNS_ADDRs
  183. // - AddrCount is the in-use count of DNS_ADDRs
  184. //
  185. #ifdef MIDL_PASS
  186. typedef struct _DnsAddrArray
  187. {
  188. DWORD MaxCount;
  189. DWORD AddrCount;
  190. DWORD Tag;
  191. WORD Family;
  192. WORD WordReserved;
  193. DWORD Flags;
  194. DWORD MatchFlag;
  195. DWORD Reserved1;
  196. DWORD Reserved2;
  197. [size_is( AddrCount )] DNS_ADDR AddrArray[];
  198. }
  199. DNS_ADDR_ARRAY, *PDNS_ADDR_ARRAY;
  200. #else
  201. typedef struct _DnsAddrArray
  202. {
  203. DWORD MaxCount;
  204. DWORD AddrCount;
  205. DWORD Tag;
  206. WORD Family;
  207. WORD WordReserved;
  208. DWORD Flags;
  209. DWORD MatchFlag;
  210. DWORD Reserved1;
  211. DWORD Reserved2;
  212. DNS_ADDR AddrArray[1];
  213. }
  214. DNS_ADDR_ARRAY, *PDNS_ADDR_ARRAY;
  215. #endif
  216. //
  217. // Non-wrapping seconds timer (timer.c)
  218. //
  219. DWORD
  220. GetCurrentTimeInSeconds(
  221. VOID
  222. );
  223. //
  224. // General DNS utilities (dnsutil.c)
  225. //
  226. PSTR
  227. _fastcall
  228. DnsGetDomainName(
  229. IN PSTR pszName
  230. );
  231. PSTR
  232. _fastcall
  233. DnsStatusString(
  234. IN DNS_STATUS Status
  235. );
  236. #define DnsStatusToErrorString_A(status) DnsStatusString(status)
  237. DNS_STATUS
  238. _fastcall
  239. DnsMapRcodeToStatus(
  240. IN BYTE ResponseCode
  241. );
  242. BYTE
  243. _fastcall
  244. DnsIsStatusRcode(
  245. IN DNS_STATUS Status
  246. );
  247. //
  248. // DNS network config structures
  249. //
  250. #define DNSINFO_FLAG_IS_WAN_ADAPTER (0x00000002)
  251. #define DNSINFO_FLAG_IS_AUTONET_ADAPTER (0x00000004)
  252. #define DNSINFO_FLAG_IS_DHCP_CFG_ADAPTER (0x00000008)
  253. #define DNSINFO_FLAG_REG_ADAPTER_DOMAIN_NAME (0x00000010)
  254. #define DNSINFO_FLAG_REG_ADAPTER_ADDRESSES (0x00000020)
  255. typedef struct
  256. {
  257. PSTR pszAdapterGuidName;
  258. PSTR pszAdapterDomain;
  259. PDNS_ADDR_ARRAY pIpAddrs;
  260. PDNS_ADDR_ARRAY pDnsAddrs;
  261. DWORD Flags;
  262. DWORD InterfaceIndex;
  263. }
  264. DNS_ADAPTER_INFOA, *PDNS_ADAPTER_INFOA;
  265. typedef struct
  266. {
  267. PWSTR pszAdapterGuidName;
  268. PWSTR pszAdapterDomain;
  269. PDNS_ADDR_ARRAY pIpAddrs;
  270. PDNS_ADDR_ARRAY pDnsAddrs;
  271. DWORD Flags;
  272. DWORD InterfaceIndex;
  273. }
  274. DNS_ADAPTER_INFOW, *PDNS_ADAPTER_INFOW;
  275. typedef struct
  276. {
  277. PSTR pszPrimaryDomainName;
  278. DWORD NameCount;
  279. PSTR SearchNameArray[1];
  280. }
  281. DNS_SEARCH_LISTA, *PDNS_SEARCH_LISTA;
  282. typedef struct
  283. {
  284. PWSTR pszPrimaryDomainName;
  285. DWORD NameCount;
  286. PWSTR SearchNameArray[1];
  287. }
  288. DNS_SEARCH_LISTW, *PDNS_SEARCH_LISTW;
  289. typedef struct
  290. {
  291. PSTR pszHostName;
  292. PSTR pszPrimaryDomainName;
  293. PDNS_SEARCH_LISTA pSearchList;
  294. DWORD Flags;
  295. DWORD AdapterCount;
  296. DNS_ADAPTER_INFOA AdapterArray[1];
  297. }
  298. DNS_NETWORK_INFOA, *PDNS_NETWORK_INFOA;
  299. typedef struct
  300. {
  301. PWSTR pszHostName;
  302. PWSTR pszPrimaryDomainName;
  303. PDNS_SEARCH_LISTW pSearchList;
  304. DWORD Flags;
  305. DWORD AdapterCount;
  306. DNS_ADAPTER_INFOW AdapterArray[1];
  307. }
  308. DNS_NETWORK_INFOW, *PDNS_NETWORK_INFOW;
  309. #ifdef UNICODE
  310. typedef DNS_ADAPTER_INFOW DNS_ADAPTER_INFO, *PDNS_ADAPTER_INFO;
  311. typedef DNS_SEARCH_LISTW DNS_SEARCH_LIST, *PDNS_SEARCH_LIST;
  312. typedef DNS_NETWORK_INFOW DNS_NETWORK_INFO, *PDNS_NETWORK_INFO;
  313. #else
  314. typedef DNS_ADAPTER_INFOW DNS_ADAPTER_INFO, *PDNS_ADAPTER_INFO;
  315. typedef DNS_SEARCH_LISTW DNS_SEARCH_LIST, *PDNS_SEARCH_LIST;
  316. typedef DNS_NETWORK_INFOW DNS_NETWORK_INFO, *PDNS_NETWORK_INFO;
  317. #endif
  318. //
  319. // Limit fixed search list (for network config dialogs)
  320. //
  321. #define DNS_MAX_SEARCH_LIST_ENTRIES (50)
  322. //
  323. // Old public structures
  324. // DNS_NETWORK_INFORMATION
  325. // DNS_SEARCH_INFORMATION
  326. // DNS_ADAPTER_INFORMATION
  327. // structures
  328. //
  329. // Do NOT code to these
  330. //
  331. //#ifdef DNSAPI_BACKCOMPAT
  332. #if 0
  333. #define NETINFO_FLAG_IS_WAN_ADAPTER DNSINFO_FLAG_IS_WAN_ADAPTER
  334. #define NETINFO_FLAG_IS_AUTONET_ADAPTER DNSINFO_FLAG_IS_AUTONET_ADAPTER
  335. #define NETINFO_FLAG_IS_DHCP_CFG_ADAPTER DNSINFO_FLAG_IS_DHCP_CFG_ADAPTER
  336. #define NETINFO_FLAG_REG_ADAPTER_DOMAIN_NAME DNSINFO_FLAG_REG_ADAPTER_DOMAIN_NAME
  337. #define NETINFO_FLAG_REG_ADAPTER_ADDRESSES DNSINFO_FLAG_REG_ADAPTER_ADDRESSES
  338. #endif
  339. typedef struct
  340. {
  341. IP4_ADDRESS ipAddress;
  342. DWORD Priority;
  343. }
  344. DNS_SERVER_INFORMATION, *PDNS_SERVER_INFORMATION;
  345. typedef struct
  346. {
  347. PSTR pszAdapterGuidName;
  348. PSTR pszDomain;
  349. PIP4_ARRAY pIPAddresses;
  350. PIP4_ARRAY pIPSubnetMasks;
  351. DWORD InfoFlags;
  352. DWORD cServerCount;
  353. DNS_SERVER_INFORMATION aipServers[1];
  354. }
  355. DNS_ADAPTER_INFORMATION, *PDNS_ADAPTER_INFORMATION;
  356. typedef struct
  357. {
  358. PSTR pszPrimaryDomainName;
  359. DWORD cNameCount;
  360. PSTR aSearchListNames[1];
  361. }
  362. DNS_SEARCH_INFORMATION, *PDNS_SEARCH_INFORMATION;
  363. typedef struct
  364. {
  365. PDNS_SEARCH_INFORMATION pSearchInformation;
  366. DWORD cAdapterCount;
  367. PDNS_ADAPTER_INFORMATION aAdapterInfoList[1];
  368. }
  369. DNS_NETWORK_INFORMATION, *PDNS_NETWORK_INFORMATION;
  370. #ifdef DNSAPI_BACKCOMPAT
  371. #define NAME_SERVER_INFORMATION DNS_SERVER_INFORMATION
  372. #define PNAME_SERVER_INFORMATION PDNS_SERVER_INFORMATION
  373. #define ADAPTER_INFORMATION DNS_ADAPTER_INFORMATION
  374. #define PADAPTER_INFORMATION PDNS_ADAPTER_INFORMATION
  375. #define SEARCH_INFORMATION DNS_SEARCH_INFORMATION
  376. #define PSEARCH_INFORMATION PDNS_SEARCH_INFORMATION
  377. #define NETWORK_INFORMATION DNS_NETWORK_INFORMATION
  378. #define PNETWORK_INFORMATION PDNS_NETWORK_INFORMATION
  379. #endif
  380. //
  381. // Resource record type utilities (record.c)
  382. //
  383. BOOL
  384. _fastcall
  385. DnsIsAMailboxType(
  386. IN WORD wType
  387. );
  388. WORD
  389. DnsRecordTypeForName(
  390. IN PCHAR pszName,
  391. IN INT cchNameLength
  392. );
  393. PCHAR
  394. DnsRecordStringForType(
  395. IN WORD wType
  396. );
  397. PCHAR
  398. DnsRecordStringForWritableType(
  399. IN WORD wType
  400. );
  401. BOOL
  402. DnsIsStringCountValidForTextType(
  403. IN WORD wType,
  404. IN WORD StringCount
  405. );
  406. BOOL
  407. DnsIpv6StringToAddress(
  408. OUT PIP6_ADDRESS pAddress,
  409. IN PCHAR pchString,
  410. IN DWORD dwStringLength
  411. );
  412. VOID
  413. DnsIpv6AddressToString(
  414. OUT PCHAR pchString,
  415. IN PIP6_ADDRESS pAddress
  416. );
  417. //
  418. // Record building (rralloc.c)
  419. //
  420. PDNS_RECORD
  421. WINAPI
  422. DnsAllocateRecord(
  423. IN WORD wBufferLength
  424. );
  425. PDNS_RECORD
  426. DnsCreatePtrRecord(
  427. IN IP4_ADDRESS IpAddress,
  428. IN LPTSTR pszHostName,
  429. IN BOOL fUnicodeName
  430. );
  431. //
  432. // Record build from data strings (rrbuild.c)
  433. //
  434. PDNS_RECORD
  435. DnsRecordBuild_UTF8(
  436. IN OUT PDNS_RRSET pRRSet,
  437. IN PSTR pszOwner,
  438. IN WORD wType,
  439. IN BOOL fAdd,
  440. IN UCHAR Section,
  441. IN INT Argc,
  442. IN PCHAR * Argv
  443. );
  444. PDNS_RECORD
  445. DnsRecordBuild_W(
  446. IN OUT PDNS_RRSET pRRSet,
  447. IN PWSTR pszOwner,
  448. IN WORD wType,
  449. IN BOOL fAdd,
  450. IN UCHAR Section,
  451. IN INT Argc,
  452. IN PWCHAR * Argv
  453. );
  454. //
  455. // Parsing
  456. //
  457. #ifdef PDNS_PARSED_MESSAGE
  458. #undef PDNS_PARSED_MESSAGE
  459. #endif
  460. typedef struct _DnsParseMessage
  461. {
  462. DNS_STATUS Status;
  463. DNS_CHARSET CharSet;
  464. DNS_HEADER Header;
  465. WORD QuestionType;
  466. WORD QuestionClass;
  467. PTSTR pQuestionName;
  468. PDNS_RECORD pAnswerRecords;
  469. PDNS_RECORD pAliasRecords;
  470. PDNS_RECORD pAuthorityRecords;
  471. PDNS_RECORD pAdditionalRecords;
  472. PDNS_RECORD pSigRecords;
  473. }
  474. DNS_PARSED_MESSAGE, *PDNS_PARSED_MESSAGE;
  475. #define DNS_PARSE_FLAG_NO_QUESTION (0x00000001)
  476. #define DNS_PARSE_FLAG_NO_ANSWER (0x00000002)
  477. #define DNS_PARSE_FLAG_NO_AUTHORITY (0x00000004)
  478. #define DNS_PARSE_FLAG_NO_ADDITIONAL (0x00000008)
  479. #define DNS_PARSE_FLAG_NO_SIG (0x00000100)
  480. #define DNS_PARSE_FLAG_NO_KEY (0x00000200)
  481. #define DNS_PARSE_FLAG_NO_DATA (0x0000030f)
  482. #define DNS_PARSE_FLAG_NO_RECORDS (0x0000030e)
  483. #define DNS_PARSE_FLAG_NO_DNSSEC (0x00000300)
  484. #define DNS_PARSE_FLAG_ONLY_QUESTION (0x01000000)
  485. #define DNS_PARSE_FLAG_RCODE_ALL (0x02000000)
  486. DNS_STATUS
  487. Dns_ParseMessage(
  488. OUT PDNS_PARSED_MESSAGE pParse,
  489. IN PDNS_MESSAGE_BUFFER pDnsBuffer,
  490. IN WORD wMessageLength,
  491. IN DWORD Flags,
  492. IN DNS_CHARSET CharSet
  493. );
  494. //
  495. // Extra info to query and update
  496. //
  497. //
  498. // Results in sockaddr format
  499. //
  500. #define DNS_MAX_ALIAS_COUNT (8)
  501. typedef struct _DnsSockaddrResults
  502. {
  503. PWSTR pName;
  504. PDNS_ADDR_ARRAY pAddrArray;
  505. PVOID pHostent;
  506. DWORD AliasCount;
  507. DWORD Reserved;
  508. PWSTR AliasArray[ DNS_MAX_ALIAS_COUNT ];
  509. }
  510. DNS_SOCKADDR_RESULTS, *PDNS_SOCKADDR_RESULTS;
  511. //
  512. // Basic results for logging\eventing
  513. //
  514. typedef struct _DnsBasicResults
  515. {
  516. DNS_STATUS Status;
  517. WORD Rcode;
  518. DNS_ADDR ServerAddr;
  519. }
  520. DNS_RESULTS_BASIC, *PDNS_RESULTS_BASIC;
  521. //
  522. // Extra info format
  523. //
  524. #define DNS_MAX_PRIVATE_EXTRA_INFO_SIZE (72)
  525. typedef struct _DnsExtraInfo
  526. {
  527. PVOID pNext;
  528. DWORD Id;
  529. union
  530. {
  531. CHAR Flat[DNS_MAX_PRIVATE_EXTRA_INFO_SIZE];
  532. //
  533. // results
  534. //
  535. struct
  536. {
  537. DNS_STATUS Status;
  538. WORD Rcode;
  539. IP4_ADDRESS ServerIp4;
  540. IP6_ADDRESS ServerIp6;
  541. }
  542. ResultsV1;
  543. DNS_RESULTS_BASIC ResultsBasic;
  544. DNS_SOCKADDR_RESULTS SaResults;
  545. //
  546. // server info inputs
  547. //
  548. PDNS_ADDR_ARRAY pServerList;
  549. PIP4_ARRAY pServerList4;
  550. };
  551. }
  552. DNS_EXTRA_INFO, *PDNS_EXTRA_INFO;
  553. #define DNS_EXINFO_ID_RESULTS_V1 (1)
  554. #define DNS_EXINFO_ID_RESULTS_BASIC (2)
  555. #define DNS_EXINFO_ID_SOCKADDR_RESULTS (3)
  556. #define DNS_EXINFO_ID_SERVER_LIST (10)
  557. #define DNS_EXINFO_ID_SERVER_LIST_IP4 (11)
  558. //
  559. // Query
  560. //
  561. //
  562. // Flags NOT in windns.h
  563. //
  564. #define DNS_QUERY_ACCEPT_PARTIAL_UDP DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE
  565. #define DNS_QUERY_MULTICAST_ONLY 0x00040000
  566. #define DNS_QUERY_USE_QUICK_TIMEOUTS 0x00080000
  567. // Exposed in Win2K SDK -- deprecated
  568. #define DNS_QUERY_ALLOW_EMPTY_AUTH_RESP 0x00010000
  569. //
  570. // Extended query
  571. //
  572. typedef struct _DnsQueryInfo
  573. {
  574. DWORD Size;
  575. DWORD Version;
  576. LPTSTR pName;
  577. WORD Type;
  578. WORD Rcode;
  579. DWORD Flags;
  580. DNS_STATUS Status;
  581. DNS_CHARSET CharSet;
  582. PDNS_RECORD pAnswerRecords;
  583. PDNS_RECORD pAliasRecords;
  584. PDNS_RECORD pAdditionalRecords;
  585. PDNS_RECORD pAuthorityRecords;
  586. HANDLE hEvent;
  587. PDNS_EXTRA_INFO pExtraInfo;
  588. PVOID pServerList;
  589. PIP4_ARRAY pServerListIp4;
  590. PVOID pMessage;
  591. PVOID pReservedName;
  592. }
  593. DNS_QUERY_INFO, *PDNS_QUERY_INFO;
  594. DNS_STATUS
  595. WINAPI
  596. DnsQueryExW(
  597. IN OUT PDNS_QUERY_INFO pQueryInfo
  598. );
  599. DNS_STATUS
  600. WINAPI
  601. DnsQueryExA(
  602. IN OUT PDNS_QUERY_INFO pQueryInfo
  603. );
  604. DNS_STATUS
  605. WINAPI
  606. DnsQueryExUTF8(
  607. IN OUT PDNS_QUERY_INFO pQueryInfo
  608. );
  609. #ifdef UNICODE
  610. #define DnsQueryEx DnsQueryExW
  611. #else
  612. #define DnsQueryEx DnsQueryExA
  613. #endif
  614. //
  615. // Options for DnsCheckNameCollision
  616. //
  617. #define DNS_CHECK_AGAINST_HOST_ANY 0x00000000
  618. #define DNS_CHECK_AGAINST_HOST_ADDRESS 0x00000001
  619. #define DNS_CHECK_AGAINST_HOST_DOMAIN_NAME 0x00000002
  620. DNS_STATUS WINAPI
  621. DnsCheckNameCollision_A(
  622. IN PCSTR pszName,
  623. IN DWORD fOptions
  624. );
  625. DNS_STATUS WINAPI
  626. DnsCheckNameCollision_UTF8(
  627. IN PCSTR pszName,
  628. IN DWORD fOptions
  629. );
  630. DNS_STATUS WINAPI
  631. DnsCheckNameCollision_W(
  632. IN PCWSTR pszName,
  633. IN DWORD fOptions
  634. );
  635. #ifdef UNICODE
  636. #define DnsDnsCheckNameCollision DnsCheckNameCollision_W
  637. #else
  638. #define DnsDnsCheckNameCollision DnsCheckNameCollision_A
  639. #endif
  640. //
  641. // DNS Update API
  642. //
  643. //
  644. // Update flags NOT in windns.h
  645. //
  646. #define DNS_UPDATE_SECURITY_CHOICE_MASK 0x000001ff
  647. DNS_STATUS
  648. WINAPI
  649. DnsUpdateTest_A(
  650. IN HANDLE hContextHandle OPTIONAL,
  651. IN PCSTR pszName,
  652. IN DWORD fOptions,
  653. IN PIP4_ARRAY aipServers OPTIONAL
  654. );
  655. DNS_STATUS
  656. WINAPI
  657. DnsUpdateTest_UTF8(
  658. IN HANDLE hContextHandle OPTIONAL,
  659. IN PCSTR pszName,
  660. IN DWORD fOptions,
  661. IN PIP4_ARRAY aipServers OPTIONAL
  662. );
  663. DNS_STATUS
  664. WINAPI
  665. DnsUpdateTest_W(
  666. IN HANDLE hContextHandle OPTIONAL,
  667. IN PCWSTR pszName,
  668. IN DWORD fOptions,
  669. IN PIP4_ARRAY aipServers OPTIONAL
  670. );
  671. #ifdef UNICODE
  672. #define DnsUpdateTest DnsUpdateTest_W
  673. #else
  674. #define DnsUpdateTest DnsUpdateTest_A
  675. #endif
  676. //
  677. // DNS Update API for DHCP client
  678. //
  679. typedef struct _REGISTER_HOST_ENTRY
  680. {
  681. union
  682. {
  683. IP4_ADDRESS ipAddr;
  684. IP6_ADDRESS ipV6Addr;
  685. } Addr;
  686. DWORD dwOptions;
  687. }
  688. REGISTER_HOST_ENTRY, *PREGISTER_HOST_ENTRY;
  689. //
  690. // Options for above
  691. //
  692. #define REGISTER_HOST_A 0x00000001
  693. #define REGISTER_HOST_PTR 0x00000002
  694. #define REGISTER_HOST_AAAA 0x00000008
  695. #define REGISTER_HOST_RESERVED 0x80000000 // Not used
  696. //
  697. // DNS DHCP Client registration flags
  698. //
  699. #define DYNDNS_REG_FWD 0x0
  700. #define DYNDNS_REG_PTR 0x8
  701. #define DYNDNS_REG_RAS 0x10
  702. #define DYNDNS_DEL_ENTRY 0x20
  703. typedef struct _REGISTER_HOST_STATUS
  704. {
  705. HANDLE hDoneEvent;
  706. DWORD dwStatus;
  707. }
  708. REGISTER_HOST_STATUS, *PREGISTER_HOST_STATUS;
  709. DNS_STATUS
  710. WINAPI
  711. DnsDhcpRegisterInit(
  712. VOID
  713. );
  714. DNS_STATUS
  715. WINAPI
  716. DnsDhcpRegisterTerm(
  717. VOID
  718. );
  719. DNS_STATUS
  720. WINAPI
  721. DnsDhcpRemoveRegistrations(
  722. VOID
  723. );
  724. DNS_STATUS
  725. WINAPI
  726. DnsDhcpRegisterHostAddrs(
  727. IN PWSTR pwsAdapterName,
  728. IN PWSTR pwsHostName,
  729. IN PREGISTER_HOST_ENTRY pHostAddrs,
  730. IN DWORD dwHostAddrCount,
  731. IN PIP4_ADDRESS pipDnsServerList,
  732. IN DWORD dwDnsServerCount,
  733. IN PWSTR pwsDomainName,
  734. IN PREGISTER_HOST_STATUS pRegisterStatus,
  735. IN DWORD dwTTL,
  736. IN DWORD dwFlags
  737. );
  738. #ifdef XP_BACKCOMPAT
  739. #define DnsAsyncRegisterInit(p) DnsDhcpRegisterInit()
  740. #define DnsAsyncRegisterTerm() DnsDhcpRegisterTerm()
  741. #define DnsRemoveRegistrations() DnsDhcpRemoveRegistrations()
  742. #define DnsAsyncRegisterHostAddrs(a,b,c,d,e,f,g,h,i) \
  743. DnsDhcpRegisterHostAddrs(a,b,c,d,e,f,g,h,i)
  744. #endif
  745. //
  746. // DNS Update API for DHCP server.
  747. //
  748. //
  749. // Call back function. DHCP Server will pass a function to
  750. // DnsDhcpRegisterHostName and this will be called on successful
  751. // or unsuccessful completion of the task
  752. // If we have a condition like server down/try again later etc we
  753. // won't respond until we have an authoritative answer.
  754. //
  755. typedef VOID(*DHCP_CALLBACK_FN)(DWORD dwStatus, LPVOID pvData);
  756. //
  757. // Callback return codes
  758. //
  759. #define DNSDHCP_SUCCESS 0x0
  760. #define DNSDHCP_FWD_FAILED 0x1
  761. #define DNSDHCP_SUPERCEDED 0x2
  762. #define DNSDHCP_FAILURE (DWORD)-1 //reverse failed
  763. //
  764. // DNS DHCP Server registration function flags
  765. //
  766. #define DYNDNS_DELETE_ENTRY 0x1
  767. #define DYNDNS_ADD_ENTRY 0x2
  768. #define DYNDNS_REG_FORWARD 0x4
  769. typedef struct _DnsCredentials
  770. {
  771. PWSTR pUserName;
  772. PWSTR pDomain;
  773. PWSTR pPassword;
  774. }
  775. DNS_CREDENTIALS, *PDNS_CREDENTIALS;
  776. DNS_STATUS
  777. WINAPI
  778. DnsDhcpSrvRegisterInit(
  779. IN PDNS_CREDENTIALS pCredentials,
  780. IN DWORD MaxQueueSize
  781. );
  782. DNS_STATUS
  783. WINAPI
  784. DnsDhcpSrvRegisterTerm(
  785. VOID
  786. );
  787. DNS_STATUS
  788. WINAPI
  789. DnsDhcpSrvRegisterHostName(
  790. IN REGISTER_HOST_ENTRY HostAddr,
  791. IN PWSTR pwsName,
  792. IN DWORD dwTTL,
  793. IN DWORD dwFlags,
  794. IN DHCP_CALLBACK_FN pfnDhcpCallBack,
  795. IN PVOID pvData,
  796. IN PIP4_ADDRESS pipDnsServerList OPTIONAL,
  797. IN DWORD dwDnsServerCount
  798. );
  799. #define RETRY_TIME_SERVER_FAILURE 5*60 // 5 minutes
  800. #define RETRY_TIME_TRY_AGAIN_LATER 5*60 // 5 minutes
  801. #define RETRY_TIME_TIMEOUT 5*60 // 5 minutes
  802. #define RETRY_TIME_MAX 10*60 // back off to 10 mins if
  803. // repeated failures occur
  804. //
  805. // Memory allocation
  806. //
  807. // Many dnsapi.dll routines allocate memory.
  808. // This memory allocation defaults to routines that use:
  809. // - LocalAlloc,
  810. // - LocalReAlloc,
  811. // - LocalFree.
  812. // If you desire alternative memory allocation mechanisms, use this
  813. // function to override the DNS API defaults. All memory returned by dnsapi.dll
  814. // can then be freed with the specified free function.
  815. //
  816. typedef PVOID (* DNS_ALLOC_FUNCTION)();
  817. typedef PVOID (* DNS_REALLOC_FUNCTION)();
  818. typedef VOID (* DNS_FREE_FUNCTION)();
  819. VOID
  820. DnsApiHeapReset(
  821. IN DNS_ALLOC_FUNCTION pAlloc,
  822. IN DNS_REALLOC_FUNCTION pRealloc,
  823. IN DNS_FREE_FUNCTION pFree
  824. );
  825. //
  826. // Modules using DNSAPI memory should use these routines if
  827. // they are capable of being called by a process that resets
  828. // the dnsapi.dll heap. (Example: the DNS server.)
  829. //
  830. PVOID
  831. DnsApiAlloc(
  832. IN INT iSize
  833. );
  834. PVOID
  835. DnsApiRealloc(
  836. IN OUT PVOID pMem,
  837. IN INT iSize
  838. );
  839. VOID
  840. DnsApiFree(
  841. IN OUT PVOID pMem
  842. );
  843. //
  844. // String utilities (string.c)
  845. //
  846. // Note some of these require memory allocation, see note
  847. // on memory allocation below.
  848. //
  849. PSTR
  850. DnsCreateStringCopy(
  851. IN PCHAR pchString,
  852. IN DWORD cchString
  853. );
  854. DWORD
  855. DnsGetBufferLengthForStringCopy(
  856. IN PCHAR pchString,
  857. IN DWORD cchString,
  858. IN BOOL fUnicodeIn,
  859. IN BOOL fUnicodeOut
  860. );
  861. PVOID
  862. DnsCopyStringEx(
  863. OUT PBYTE pBuffer,
  864. IN PCHAR pchString,
  865. IN DWORD cchString,
  866. IN BOOL fUnicodeIn,
  867. IN BOOL fUnicodeOut
  868. );
  869. PVOID
  870. DnsStringCopyAllocateEx(
  871. IN PCHAR pchString,
  872. IN DWORD cchString,
  873. IN BOOL fUnicodeIn,
  874. IN BOOL fUnicodeOut
  875. );
  876. DWORD
  877. DnsNameCopy(
  878. OUT PBYTE pBuffer,
  879. IN OUT PDWORD pdwBufLength,
  880. IN PCHAR pchString,
  881. IN DWORD cchString,
  882. IN DNS_CHARSET CharSetIn,
  883. IN DNS_CHARSET CharSetOut
  884. );
  885. PVOID
  886. DnsNameCopyAllocate(
  887. IN PCHAR pchString,
  888. IN DWORD cchString,
  889. IN DNS_CHARSET CharSetIn,
  890. IN DNS_CHARSET CharSetOut
  891. );
  892. PCHAR
  893. DnsWriteReverseNameStringForIpAddress(
  894. OUT PCHAR pBuffer,
  895. IN IP4_ADDRESS IpAddress
  896. );
  897. PCHAR
  898. DnsCreateReverseNameStringForIpAddress(
  899. IN IP4_ADDRESS IpAddress
  900. );
  901. //
  902. // Name validation
  903. //
  904. // Routines are in windns.h
  905. //
  906. //
  907. // Macro away old routines
  908. //
  909. #define DnsValidateDnsName_UTF8(pname) \
  910. DnsValidateName_UTF8( (pname), DnsNameDomain )
  911. #define DnsValidateDnsName_W(pname) \
  912. DnsValidateName_W( (pname), DnsNameDomain )
  913. //
  914. // Name checking -- server name checking levels
  915. //
  916. // DCR_CLEANUP: server name checking levels move to dnsrpc.h?
  917. // but server will need to convert to some flag
  918. // ammenable to downcase\validate routine
  919. //
  920. // DCR: server name checking: perhaps lay out additional detail now?
  921. // or limit to RFC, MS-extended, ALL-binary
  922. //
  923. // DCR: server name checking: perhaps convert to enum type;
  924. // I don't think we should do bitfields here, rather
  925. // have enum type map to bitfields if that's the best
  926. // way to implement underlying check.
  927. //
  928. #define DNS_ALLOW_RFC_NAMES_ONLY (0)
  929. #define DNS_ALLOW_NONRFC_NAMES (1)
  930. #define DNS_ALLOW_MULTIBYTE_NAMES (2)
  931. #define DNS_ALLOW_ALL_NAMES (3)
  932. //
  933. // DNS Name compare
  934. //
  935. // ANSI and unicode names compare routines are in windns.h.
  936. //
  937. BOOL
  938. WINAPI
  939. DnsNameCompare_UTF8(
  940. IN PSTR pName1,
  941. IN PSTR pName2
  942. );
  943. //
  944. // Extended name compare
  945. // Includes determination of name heirarchy.
  946. //
  947. // Note: once sort out RelationalCompare issue,
  948. // better to make Equal == 0;
  949. // this simplifies macroing regular NameCompare
  950. // into a single function;
  951. //
  952. typedef enum _DnsNameCompareStatus
  953. {
  954. DnsNameCompareNotEqual,
  955. DnsNameCompareEqual,
  956. DnsNameCompareLeftParent,
  957. DnsNameCompareRightParent,
  958. DnsNameCompareInvalid
  959. }
  960. DNS_NAME_COMPARE_STATUS, *PDNS_NAME_COMPARE_STATUS;
  961. DNS_NAME_COMPARE_STATUS
  962. DnsNameCompareEx_W(
  963. IN LPCWSTR pszLeftName,
  964. IN LPCWSTR pszRightName,
  965. IN DWORD dwReserved
  966. );
  967. DNS_NAME_COMPARE_STATUS
  968. DnsNameCompareEx_A(
  969. IN LPCSTR pszLeftName,
  970. IN LPCSTR pszRightName,
  971. IN DWORD dwReserved
  972. );
  973. DNS_NAME_COMPARE_STATUS
  974. DnsNameCompareEx_UTF8(
  975. IN LPCSTR pszLeftName,
  976. IN LPCSTR pszRightName,
  977. IN DWORD dwReserved
  978. );
  979. //
  980. // Other string routines
  981. //
  982. DNS_STATUS
  983. DnsValidateDnsString_UTF8(
  984. IN LPCSTR pszName
  985. );
  986. DNS_STATUS
  987. DnsValidateDnsString_W(
  988. IN LPCWSTR pszName
  989. );
  990. PSTR
  991. DnsCreateStandardDnsNameCopy(
  992. IN PCHAR pchName,
  993. IN DWORD cchName,
  994. IN DWORD dwFlag
  995. );
  996. DWORD
  997. DnsDowncaseDnsNameLabel(
  998. OUT PCHAR pchResult,
  999. IN PCHAR pchLabel,
  1000. IN DWORD cchLabel,
  1001. IN DWORD dwFlags
  1002. );
  1003. DWORD
  1004. _fastcall
  1005. DnsUnicodeToUtf8(
  1006. IN PWCHAR pwUnicode,
  1007. IN DWORD cchUnicode,
  1008. OUT PCHAR pchResult,
  1009. IN DWORD cchResult
  1010. );
  1011. DWORD
  1012. _fastcall
  1013. DnsUtf8ToUnicode(
  1014. IN PCHAR pchUtf8,
  1015. IN DWORD cchUtf8,
  1016. OUT PWCHAR pwResult,
  1017. IN DWORD cwResult
  1018. );
  1019. DNS_STATUS
  1020. DnsValidateUtf8Byte(
  1021. IN BYTE chUtf8,
  1022. IN OUT PDWORD pdwTrailCount
  1023. );
  1024. //
  1025. // Service control
  1026. //
  1027. //
  1028. // DNS server startup service control event.
  1029. //
  1030. // Services (ex. netlogon) that want notification of DNS server start
  1031. // need to register to get notification of this user defined control code.
  1032. //
  1033. #define SERVICE_CONTROL_DNS_SERVER_START (200)
  1034. //
  1035. // Resolver service
  1036. //
  1037. // General "wake-up-something-has-changed" call.
  1038. // This was put in for cluster team to alert us to plumbing new
  1039. // addresses. Later we will move to model of picking up
  1040. // these changes ourselves.
  1041. //
  1042. VOID
  1043. DnsNotifyResolver(
  1044. IN DWORD Flag,
  1045. IN PVOID pReserved
  1046. );
  1047. VOID
  1048. DnsNotifyResolverEx(
  1049. IN DWORD Id,
  1050. IN DWORD Flag,
  1051. IN DWORD Cookie,
  1052. IN PVOID pReserved
  1053. );
  1054. //
  1055. // Cluster mappings
  1056. //
  1057. #define DNS_CLUSTER_ADD (0)
  1058. #define DNS_CLUSTER_DELETE_NAME (1)
  1059. #define DNS_CLUSTER_DELETE_IP (2)
  1060. DNS_STATUS
  1061. DnsRegisterClusterAddress(
  1062. IN DWORD Tag,
  1063. IN PWSTR pwsName,
  1064. IN PSOCKADDR pSockaddr,
  1065. IN DWORD Flag
  1066. );
  1067. // Remove once cluster upgraded
  1068. VOID
  1069. DnsNotifyResolverClusterIp(
  1070. IN IP4_ADDRESS ClusterIp,
  1071. IN BOOL fAdd
  1072. );
  1073. //
  1074. // Routines to clear all cached entries in the DNS Resolver Cache, this is
  1075. // called by ipconfig /flushdns, and add record sets to the cache.
  1076. //
  1077. BOOL WINAPI
  1078. DnsFlushResolverCache(
  1079. VOID
  1080. );
  1081. BOOL WINAPI
  1082. DnsFlushResolverCacheEntry_W(
  1083. IN PWSTR pszName
  1084. );
  1085. BOOL WINAPI
  1086. DnsFlushResolverCacheEntry_UTF8(
  1087. IN PSTR pszName
  1088. );
  1089. BOOL WINAPI
  1090. DnsFlushResolverCacheEntry_A(
  1091. IN PSTR pszName
  1092. );
  1093. #ifdef UNICODE
  1094. #define DnsFlushResolverCacheEntry DnsFlushResolverCacheEntry_W
  1095. #else
  1096. #define DnsFlushResolverCacheEntry DnsFlushResolverCacheEntry_A
  1097. #endif
  1098. DNS_STATUS WINAPI
  1099. DnsCacheRecordSet_W(
  1100. IN PWSTR lpstrName,
  1101. IN WORD wType,
  1102. IN DWORD fOptions,
  1103. IN OUT PDNS_RECORD pRRSet
  1104. );
  1105. //
  1106. // DO NOT USE!!! -- This is weak, i just haven't tested the replacement yet.
  1107. //
  1108. // Routine to read the contents of the DNS Resolver Cache. The resulting
  1109. // table contains a list of record names and types stored in the cache.
  1110. // Each of these name/type records can be queried with DnsQuery with the
  1111. // option DNS_QUERY_CACHE_ONLY.
  1112. //
  1113. // Note: this is used in ipconfig for /displaydns. Can not pull until fixed.
  1114. //
  1115. typedef struct _DNS_CACHE_TABLE_
  1116. {
  1117. struct _DNS_CACHE_TABLE_ * pNext;
  1118. PWSTR Name;
  1119. WORD Type1;
  1120. WORD Type2;
  1121. WORD Type3;
  1122. }
  1123. DNS_CACHE_TABLE, *PDNS_CACHE_TABLE;
  1124. BOOL
  1125. WINAPI
  1126. DnsGetCacheDataTable(
  1127. OUT PDNS_CACHE_TABLE * pTable
  1128. );
  1129. //
  1130. // Config info
  1131. //
  1132. //
  1133. // Alloc flag types for DnsQueryConfig()
  1134. //
  1135. // DCR: move to windns.h if supported
  1136. //
  1137. #define DNS_CONFIG_FLAG_LOCAL_ALLOC (DNS_CONFIG_FLAG_ALLOC)
  1138. #define DNS_CONFIG_FLAG_DNSAPI_ALLOC (DNS_CONFIG_FLAG_ALLOC+1)
  1139. //
  1140. // System public config -- not available in SDK
  1141. // This is stuff for
  1142. // - config UI
  1143. // - ipconfig
  1144. // - test code
  1145. //
  1146. // These are simply hidden from public until ready
  1147. #define DnsConfigDnsServers ((DNS_CONFIG_TYPE) 0x00001030)
  1148. #define DnsConfigDnsServersIp4 ((DNS_CONFIG_TYPE) 0x00001031)
  1149. #define DnsConfigDnsServersIp6 ((DNS_CONFIG_TYPE) 0x00001032)
  1150. // Above SystemBase ID, they are unavailable to public routine
  1151. #define DnsConfigSystemBase ((DNS_CONFIG_TYPE) 0x00010000)
  1152. #define DnsConfigNetworkInformation ((DNS_CONFIG_TYPE) 0x00010001)
  1153. #define DnsConfigAdapterInformation ((DNS_CONFIG_TYPE) 0x00010002)
  1154. #define DnsConfigSearchInformation ((DNS_CONFIG_TYPE) 0x00010003)
  1155. #define DnsConfigRegistrationEnabled ((DNS_CONFIG_TYPE) 0x00010010)
  1156. #define DnsConfigWaitForNameErrorOnAll ((DNS_CONFIG_TYPE) 0x00010011)
  1157. #define DnsConfigLocalAddrs ((DNS_CONFIG_TYPE) 0x00010020)
  1158. #define DnsConfigLocalAddrsIp4 ((DNS_CONFIG_TYPE) 0x00010021)
  1159. #define DnsConfigLocalAddrsIp6 ((DNS_CONFIG_TYPE) 0x00010022)
  1160. #define DnsConfigNetworkInfoA ((DNS_CONFIG_TYPE) 0x00010031)
  1161. #define DnsConfigAdapterInfoA ((DNS_CONFIG_TYPE) 0x00010032)
  1162. #define DnsConfigSearchListA ((DNS_CONFIG_TYPE) 0x00010033)
  1163. #define DnsConfigNetworkInfoW ((DNS_CONFIG_TYPE) 0x00010141)
  1164. #define DnsConfigAdapterInfoW ((DNS_CONFIG_TYPE) 0x00010142)
  1165. #define DnsConfigSearchListW ((DNS_CONFIG_TYPE) 0x00010143)
  1166. #define DnsConfigDwordGlobals ((DNS_CONFIG_TYPE) 0x00010200)
  1167. // backcompat
  1168. // still get IP4_ARRAY in mswsock myhostent() routines
  1169. #define DnsConfigIp4AddressArray ((DNS_CONFIG_TYPE) 0x00010004)
  1170. // old network info definitions
  1171. PVOID
  1172. WINAPI
  1173. DnsQueryConfigAllocEx(
  1174. IN DNS_CONFIG_TYPE Config,
  1175. IN PWSTR pwsAdapterName,
  1176. IN BOOL fLocalAlloc
  1177. );
  1178. // Desired routine has dnsapi.dll alloc
  1179. #define DnsQueryConfigAlloc( Id, pAN ) \
  1180. DnsQueryConfigAllocEx( Id, pAN, FALSE )
  1181. VOID
  1182. WINAPI
  1183. DnsFreeConfigStructure(
  1184. IN OUT PVOID pData,
  1185. IN DNS_CONFIG_TYPE ConfigId
  1186. );
  1187. //
  1188. // DWORD config get\set
  1189. //
  1190. DWORD
  1191. WINAPI
  1192. DnsQueryConfigDword(
  1193. IN DNS_CONFIG_TYPE Config,
  1194. IN PWSTR pwsAdapterName
  1195. );
  1196. DNS_STATUS
  1197. WINAPI
  1198. DnsSetConfigDword(
  1199. IN DNS_CONFIG_TYPE Config,
  1200. IN PWSTR pwsAdapterName,
  1201. IN DWORD NewValue
  1202. );
  1203. //
  1204. // End dnsapi.h
  1205. //
  1206. //
  1207. // Backward compatibility
  1208. //
  1209. // This is all the crap we should be getting out of here, but
  1210. // may still be called in the sytem somewhere.
  1211. //
  1212. // DO NOT USE!!!!
  1213. //
  1214. // These definitions are for backward compatibility only. They can be pulled at
  1215. // any time and if you use them you may break.
  1216. //
  1217. #ifdef DNS_INTERNAL
  1218. #define NO_DNSAPI_BACKCOMPAT 1
  1219. #endif
  1220. #ifndef NO_DNSAPI_BACKCOMPAT
  1221. #define DNSAPI_BACKCOMPAT 1
  1222. #endif
  1223. #ifdef DNSAPI_BACKCOMPAT
  1224. //
  1225. // IP Address
  1226. //
  1227. typedef IP4_ADDRESS IP_ADDRESS, *PIP_ADDRESS;
  1228. typedef IP4_ARRAY IP_ARRAY, *PIP_ARRAY;
  1229. #define IP_ADDRESS_STRING_LENGTH IP4_ADDRESS_STRING_LENGTH
  1230. #define SIZEOF_IP_ADDRESS SIZEOF_IP4_ADDRESS
  1231. //
  1232. // Config stuff
  1233. //
  1234. // Macro old routines
  1235. // - system-public config allocator
  1236. // - global free routine
  1237. // - these were structure allocs so were not being freed with LocalFree
  1238. //
  1239. #define DnsGetNetworkInformation() DnsQueryConfigAlloc( DnsConfigNetworkInformation, NULL )
  1240. #define DnsGetSearchInformation() DnsQueryConfigAlloc( DnsConfigSearchInformation, NULL )
  1241. #define Dns_GetDnsNetworkInfo(f,g) DnsQueryConfigAlloc( DnsConfigNetInfo, NULL )
  1242. #define DnsFreeNetworkInformation(p) DnsFreeConfigStructure( p, DnsConfigNetworkInformation )
  1243. #define DnsFreeSearchInformation(p) DnsFreeConfigStructure( p, DnsConfigSearchInformation )
  1244. #define DnsFreeAdapterInformation(p) DnsFreeConfigStructure( p, DnsConfigAdapterInformation )
  1245. #define Dns_FreeNetworkInfo(p) DnsFreeConfigStructure( p, DnsConfigNetInfo )
  1246. //
  1247. // Macro old config string allocating routines
  1248. // - no adapter name
  1249. // - allocating from dnsapi heap as main caller -- RnR -- seems to be
  1250. // using DnsApiFree
  1251. //
  1252. #define BackpatAlloc( Id ) DnsQueryConfigAllocEx( Id, NULL, FALSE )
  1253. // Public structures
  1254. #define DnsGetHostName_A() BackpatAlloc( DnsConfigHostName_A )
  1255. #define DnsGetHostName_UTF8() BackpatAlloc( DnsConfigHostName_UTF8 )
  1256. #define DnsGetHostName_W() ((PWSTR)BackpatAlloc( DnsConfigHostName_W ))
  1257. #ifdef UNICODE
  1258. #define DnsGetHostName DnsGetHostName_W
  1259. #else
  1260. #define DnsGetHostName DnsGetHostName_A
  1261. #endif
  1262. #define DnsGetPrimaryDomainName_A() BackpatAlloc( DnsConfigPrimaryDomainName_A )
  1263. #define DnsGetPrimaryDomainName_UTF8() BackpatAlloc( DnsConfigPrimaryDomainName_UTF8 )
  1264. #define DnsGetPrimaryDomainName_W() ((PWSTR)BackpatAlloc( DnsConfigPrimaryDomainName_W ))
  1265. #ifdef UNICODE
  1266. #define DnsGetPrimaryDomainName DnsGetPrimaryDomainName_W
  1267. #else
  1268. #define DnsGetPrimaryDomainName DnsGetPrimaryDomainName_A
  1269. #endif
  1270. //
  1271. // DWORD get\set backcompat
  1272. //
  1273. //
  1274. // DCR: there is a possible problem with these mappings handles generic\adapter
  1275. // difference -- not sure the mapping is complete
  1276. // may need switches -- see which are even in use with BACKCOMPAT off
  1277. //
  1278. #define DnsIsDynamicRegistrationEnabled(pA) \
  1279. (BOOL)DnsQueryConfigDword( DnsConfigRegistrationEnabled, (pA) )
  1280. #define DnsIsAdapterDomainNameRegistrationEnabled(pA) \
  1281. (BOOL)DnsQueryConfigDword( DnsConfigAdapterHostNameRegistrationEnabled, (pA) )
  1282. #define DnsGetMaxNumberOfAddressesToRegister(pA) \
  1283. DnsQueryConfigDword( DnsConfigAddressRegistrationMaxCount, (pA) )
  1284. // DWORD reg value set
  1285. #define DnsEnableDynamicRegistration(pA) \
  1286. DnsSetConfigDword( DnsConfigRegistrationEnabled, pA, (DWORD)TRUE )
  1287. #define DnsDisableDynamicRegistration(pA) \
  1288. DnsSetConfigDword( DnsConfigRegistrationEnabled, pA, (DWORD)FALSE )
  1289. #define DnsEnableAdapterDomainNameRegistration(pA) \
  1290. DnsSetConfigDword( DnsConfigAdapterHostNameRegistrationEnabled, pA, (DWORD)TRUE )
  1291. #define DnsDisableAdapterDomainNameRegistration(pA) \
  1292. DnsSetConfigDword( DnsConfigAdapterHostNameRegistrationEnabled, pA, (DWORD)FALSE )
  1293. #define DnsSetMaxNumberOfAddressesToRegister(pA, MaxCount) \
  1294. (NO_ERROR == DnsSetConfigDword( DnsConfigAddressRegistrationMaxCount, pA, MaxCount ))
  1295. //
  1296. // DNS server list backcompat
  1297. //
  1298. #define Dns_GetDnsServerList(flag) ((PIP4_ARRAY)BackpatAlloc( DnsConfigDnsServerList ))
  1299. #ifndef MIDL_PASS
  1300. __inline
  1301. DWORD
  1302. inline_DnsGetDnsServerList(
  1303. OUT PIP4_ARRAY * ppDnsArray
  1304. )
  1305. {
  1306. *ppDnsArray = Dns_GetDnsServerList( TRUE );
  1307. return ( *ppDnsArray ? (*ppDnsArray)->AddrCount : 0 );
  1308. }
  1309. #endif // MIDL
  1310. #define DnsGetDnsServerList(p) inline_DnsGetDnsServerList(p)
  1311. //
  1312. // IP list backcompat
  1313. //
  1314. //
  1315. // Machines IP address list (iplist.c)
  1316. //
  1317. // Routine to get the current IP addresses from all adapters
  1318. // configured for the machine.
  1319. //
  1320. DWORD
  1321. DnsGetIpAddressList(
  1322. OUT PIP4_ARRAY * ppIpAddresses
  1323. );
  1324. //
  1325. // Routine to get the current IP addresses and subnet masks
  1326. // from all adapters configured for the machine.
  1327. //
  1328. typedef struct _DNS_ADDRESS_INFO_
  1329. {
  1330. IP4_ADDRESS ipAddress;
  1331. IP4_ADDRESS subnetMask;
  1332. }
  1333. DNS_ADDRESS_INFO, *PDNS_ADDRESS_INFO;
  1334. DWORD
  1335. DnsGetIpAddressInfoList(
  1336. OUT PDNS_ADDRESS_INFO * ppAddrInfo
  1337. );
  1338. DWORD
  1339. Dns_GetIpAddresses(
  1340. IN OUT PDNS_ADDRESS_INFO IpAddressInfoList,
  1341. IN DWORD ListCount
  1342. );
  1343. #ifndef MIDL_PASS
  1344. __inline
  1345. DWORD
  1346. inline_DnsGetIpAddressList(
  1347. OUT PIP4_ARRAY * ppIpArray
  1348. )
  1349. {
  1350. *ppIpArray = (PIP4_ARRAY) BackpatAlloc( DnsConfigIp4AddressArray );
  1351. return( *ppIpArray ? (*ppIpArray)->AddrCount : 0 );
  1352. }
  1353. #endif // MIDL
  1354. #define DnsGetIpAddressList(p) inline_DnsGetIpAddressList(p)
  1355. //
  1356. // I've switched the DCPromo stuff. Need to verify with clean system
  1357. // build that it's completely gone, then pull.
  1358. //
  1359. #define DNS_RELATE_NEQ DnsNameCompareNotEqual
  1360. #define DNS_RELATE_EQL DnsNameCompareEqual
  1361. #define DNS_RELATE_LGT DnsNameCompareLeftParent
  1362. #define DNS_RELATE_RGT DnsNameCompareRightParent
  1363. #define DNS_RELATE_INVALID DnsNameCompareInvalid
  1364. typedef DNS_NAME_COMPARE_STATUS DNS_RELATE_STATUS, *PDNS_RELATE_STATUS;
  1365. #define DNS_UPDATE_INFO_ID_RESULT_INFO DNS_EXINFO_ID_RESULTS_V1
  1366. //
  1367. // Update additional info
  1368. //
  1369. typedef struct _DnsUpdateExtraInfo
  1370. {
  1371. PVOID pNext;
  1372. DWORD Id;
  1373. union
  1374. {
  1375. struct
  1376. {
  1377. DNS_STATUS Status;
  1378. WORD Rcode;
  1379. IP4_ADDRESS ServerIp4;
  1380. IP6_ADDRESS ServerIp6;
  1381. }
  1382. Results;
  1383. } U;
  1384. }
  1385. DNS_UPDATE_EXTRA_INFO, *PDNS_UPDATE_EXTRA_INFO;
  1386. //
  1387. // Old failed update info
  1388. //
  1389. IP_ADDRESS
  1390. WINAPI
  1391. DnsGetLastServerUpdateIP(
  1392. VOID
  1393. );
  1394. typedef struct _DnsFailedUpdateInfo
  1395. {
  1396. IP4_ADDRESS Ip4Address;
  1397. IP6_ADDRESS Ip6Address;
  1398. DNS_STATUS Status;
  1399. DWORD Rcode;
  1400. }
  1401. DNS_FAILED_UPDATE_INFO, *PDNS_FAILED_UPDATE_INFO;
  1402. #define DEFINED_DNS_FAILED_UPDATE_INFO 1
  1403. VOID
  1404. DnsGetLastFailedUpdateInfo(
  1405. OUT PDNS_FAILED_UPDATE_INFO pInfo
  1406. );
  1407. #endif // DNSAPI_BACKCOMPAT
  1408. #ifdef __cplusplus
  1409. }
  1410. #endif // __cplusplus
  1411. #endif // _DNSAPI_INCLUDED_