Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2698 lines
65 KiB

  1. /*++
  2. Copyright (c) 1997 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. Glenn Curtis (glennc) January 22, 1997
  12. Added Dynamic Update Client API for DNSAPI.DLL
  13. --*/
  14. #ifndef _DNSAPI_INCLUDED_
  15. #define _DNSAPI_INCLUDED_
  16. #ifndef _WINSOCK2API_
  17. #ifndef _WINSOCKAPI_
  18. #include <winsock2.h>
  19. #endif
  20. #endif
  21. #ifndef _DNS_INCLUDED_
  22. #include <dns.h>
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif // __cplusplus
  28. //
  29. // Non-wrapping seconds timer (timer.c)
  30. //
  31. DWORD
  32. GetCurrentTimeInSeconds(
  33. VOID
  34. );
  35. //
  36. // General DNS utilities (dnsutil.c)
  37. //
  38. LPSTR
  39. _fastcall
  40. DnsGetDomainName(
  41. IN LPSTR pszName
  42. );
  43. LPSTR
  44. _fastcall
  45. DnsStatusString(
  46. IN DNS_STATUS Status
  47. );
  48. #define DnsStatusToErrorString_A(status) DnsStatusString(status)
  49. DNS_STATUS
  50. _fastcall
  51. DnsMapRcodeToStatus(
  52. IN BYTE ResponseCode
  53. );
  54. BYTE
  55. _fastcall
  56. DnsIsStatusRcode(
  57. IN DNS_STATUS Status
  58. );
  59. //
  60. // Machines IP address list (iplist.c)
  61. //
  62. // Routine to get the current IP addresses from all adapters
  63. // configured for the machine.
  64. //
  65. DWORD
  66. DnsGetIpAddressList(
  67. OUT PIP_ARRAY * ppIpAddresses
  68. );
  69. //
  70. // Routine to get the current IP addresses and subnet masks
  71. // from all adapters configured for the machine.
  72. //
  73. typedef struct _DNS_ADDRESS_INFO_
  74. {
  75. IP_ADDRESS ipAddress;
  76. IP_ADDRESS subnetMask;
  77. }
  78. DNS_ADDRESS_INFO, *PDNS_ADDRESS_INFO;
  79. DWORD
  80. DnsGetIpAddressInfoList(
  81. OUT PDNS_ADDRESS_INFO * ppAddrInfo
  82. );
  83. DWORD
  84. DnsGetDnsServerList(
  85. OUT PIP_ARRAY * ppDnsAddresses
  86. );
  87. //
  88. // Routines and structures for getting network configuration information
  89. // for TCPIP interfaces
  90. //
  91. #define NETINFO_FLAG_IS_WAN_ADAPTER (0x00000002)
  92. #define NETINFO_FLAG_IS_AUTONET_ADAPTER (0x00000004)
  93. #define NETINFO_FLAG_IS_DHCP_CFG_ADAPTER (0x00000008)
  94. typedef struct _NAME_SERVER_INFORMATION_
  95. {
  96. IP_ADDRESS ipAddress;
  97. DWORD Priority;
  98. }
  99. NAME_SERVER_INFORMATION, *PNAME_SERVER_INFORMATION;
  100. typedef struct _ADAPTER_INFORMATION_
  101. {
  102. LPSTR pszAdapterGuidName;
  103. LPSTR pszDomain;
  104. PIP_ARRAY pIPAddresses;
  105. PIP_ARRAY pIPSubnetMasks;
  106. DWORD InfoFlags;
  107. DWORD cServerCount;
  108. NAME_SERVER_INFORMATION aipServers[1];
  109. }
  110. ADAPTER_INFORMATION, *PADAPTER_INFORMATION;
  111. typedef struct _SEARCH_INFORMATION_
  112. {
  113. LPSTR pszPrimaryDomainName;
  114. DWORD cNameCount;
  115. LPSTR aSearchListNames[1];
  116. }
  117. SEARCH_INFORMATION, *PSEARCH_INFORMATION;
  118. typedef struct _NETWORK_INFORMATION_
  119. {
  120. PSEARCH_INFORMATION pSearchInformation;
  121. DWORD cAdapterCount;
  122. PADAPTER_INFORMATION aAdapterInfoList[1];
  123. }
  124. NETWORK_INFORMATION, *PNETWORK_INFORMATION;
  125. PNETWORK_INFORMATION
  126. WINAPI
  127. DnsGetNetworkInformation(
  128. void
  129. );
  130. PSEARCH_INFORMATION
  131. WINAPI
  132. DnsGetSearchInformation(
  133. void
  134. );
  135. VOID
  136. WINAPI
  137. DnsFreeAdapterInformation(
  138. IN PADAPTER_INFORMATION pAdapterInformation
  139. );
  140. VOID
  141. WINAPI
  142. DnsFreeSearchInformation(
  143. IN PSEARCH_INFORMATION pSearchInformation
  144. );
  145. VOID
  146. WINAPI
  147. DnsFreeNetworkInformation(
  148. IN PNETWORK_INFORMATION pNetworkInformation
  149. );
  150. //
  151. // Resource record type utilities (record.c)
  152. //
  153. BOOL
  154. _fastcall
  155. DnsIsAMailboxType(
  156. IN WORD wType
  157. );
  158. WORD
  159. DnsRecordTypeForName(
  160. IN PCHAR pszName,
  161. IN INT cchNameLength
  162. );
  163. PCHAR
  164. DnsRecordStringForType(
  165. IN WORD wType
  166. );
  167. PCHAR
  168. DnsRecordStringForWritableType(
  169. IN WORD wType
  170. );
  171. BOOL
  172. DnsIsStringCountValidForTextType(
  173. IN WORD wType,
  174. IN WORD StringCount
  175. );
  176. BOOL
  177. DnsIpv6StringToAddress(
  178. OUT PIPV6_ADDRESS pAddress,
  179. IN PCHAR pchString,
  180. IN DWORD dwStringLength
  181. );
  182. VOID
  183. DnsIpv6AddressToString(
  184. OUT PCHAR pchString,
  185. IN PIPV6_ADDRESS pAddress
  186. );
  187. //
  188. // Resource record structure for send\recv records.
  189. //
  190. //
  191. // Record data for specific types
  192. //
  193. #ifdef SDK_DNS_RECORD
  194. typedef struct
  195. {
  196. IP_ADDRESS ipAddress;
  197. }
  198. DNS_A_DATA, *PDNS_A_DATA;
  199. typedef struct
  200. {
  201. LPTSTR pNameHost;
  202. }
  203. DNS_PTR_DATA, *PDNS_PTR_DATA;
  204. typedef struct
  205. {
  206. LPTSTR pNamePrimaryServer;
  207. LPTSTR pNameAdministrator;
  208. DWORD dwSerialNo;
  209. DWORD dwRefresh;
  210. DWORD dwRetry;
  211. DWORD dwExpire;
  212. DWORD dwDefaultTtl;
  213. }
  214. DNS_SOA_DATA, *PDNS_SOA_DATA;
  215. typedef struct
  216. {
  217. LPTSTR pNameMailbox;
  218. LPTSTR pNameErrorsMailbox;
  219. }
  220. DNS_MINFO_DATA, *PDNS_MINFO_DATA;
  221. typedef struct
  222. {
  223. LPTSTR pNameExchange;
  224. WORD wPreference;
  225. WORD Pad; // keep ptrs DWORD aligned
  226. }
  227. DNS_MX_DATA, *PDNS_MX_DATA;
  228. typedef struct
  229. {
  230. DWORD dwStringCount;
  231. #ifdef MIDL_PASS
  232. [size_is(dwStringCount)] LPTSTR * pStringArray;
  233. #else // MIDL_PASS
  234. LPTSTR pStringArray[1];
  235. #endif // MIDL_PASS
  236. }
  237. DNS_TXT_DATA, *PDNS_TXT_DATA;
  238. typedef struct
  239. {
  240. DWORD dwByteCount;
  241. #ifdef MIDL_PASS
  242. [size_is(dwByteCount)] PBYTE bData;
  243. #else // MIDL_PASS
  244. BYTE bData[1];
  245. #endif // MIDL_PASS
  246. }
  247. DNS_NULL_DATA, *PDNS_NULL_DATA;
  248. typedef struct
  249. {
  250. IP_ADDRESS ipAddress;
  251. UCHAR chProtocol;
  252. BYTE bBitMask[1];
  253. }
  254. DNS_WKS_DATA, *PDNS_WKS_DATA;
  255. typedef struct
  256. {
  257. IPV6_ADDRESS ipv6Address;
  258. }
  259. DNS_AAAA_DATA, *PDNS_AAAA_DATA;
  260. typedef struct
  261. {
  262. LPTSTR pNameSigner;
  263. WORD wTypeCovered;
  264. BYTE chAlgorithm;
  265. BYTE chLabelCount;
  266. DWORD dwOriginalTtl;
  267. DWORD dwExpiration;
  268. DWORD dwTimeSigned;
  269. WORD wKeyTag;
  270. WORD Pad; // keep byte field aligned
  271. BYTE Signature[1];
  272. }
  273. DNS_SIG_DATA, *PDNS_SIG_DATA;
  274. typedef struct
  275. {
  276. WORD wFlags;
  277. BYTE chProtocol;
  278. BYTE chAlgorithm;
  279. BYTE Key[1];
  280. }
  281. DNS_KEY_DATA, *PDNS_KEY_DATA;
  282. typedef struct
  283. {
  284. WORD wVersion;
  285. WORD wSize;
  286. WORD wHorPrec;
  287. WORD wVerPrec;
  288. DWORD dwLatitude;
  289. DWORD dwLongitude;
  290. DWORD dwAltitude;
  291. }
  292. DNS_LOC_DATA, *PDNS_LOC_DATA;
  293. typedef struct
  294. {
  295. LPTSTR pNameNext;
  296. BYTE bTypeBitMap[1];
  297. }
  298. DNS_NXT_DATA, *PDNS_NXT_DATA;
  299. typedef struct
  300. {
  301. LPTSTR pNameTarget;
  302. WORD wPriority;
  303. WORD wWeight;
  304. WORD wPort;
  305. WORD Pad; // keep ptrs DWORD aligned
  306. }
  307. DNS_SRV_DATA, *PDNS_SRV_DATA;
  308. typedef struct
  309. {
  310. LPTSTR pNameAlgorithm;
  311. PBYTE pAlgorithmPacket;
  312. PBYTE pKey;
  313. PBYTE pOtherData;
  314. DWORD dwCreateTime;
  315. DWORD dwExpireTime;
  316. WORD wMode;
  317. WORD wError;
  318. WORD wKeyLength;
  319. WORD wOtherLength;
  320. UCHAR cAlgNameLength;
  321. BOOL fPacketPointers;
  322. }
  323. DNS_TKEY_DATA, *PDNS_TKEY_DATA;
  324. typedef struct
  325. {
  326. LPTSTR pNameAlgorithm;
  327. PBYTE pAlgorithmPacket;
  328. PBYTE pSignature;
  329. PBYTE pOtherData;
  330. LONGLONG i64CreateTime;
  331. WORD wFudgeTime;
  332. WORD wOriginalID;
  333. WORD wError;
  334. WORD wSigLength;
  335. WORD wOtherLength;
  336. UCHAR cAlgNameLength;
  337. BOOL fPacketPointers;
  338. }
  339. DNS_TSIG_DATA, *PDNS_TSIG_DATA;
  340. #define DNS_ATM_TYPE_E164 0x01 // E.164 addressing scheme
  341. #define DNS_ATM_TYPE_NSAP 0x02 // NSAP-style addressing scheme
  342. #define DNS_ATM_TYPE_AESA DNS_ATM_TYPE_NSAP
  343. #define DNS_ATM_MAX_ADDR_SIZE 20
  344. typedef struct
  345. {
  346. BYTE AddressType;
  347. BYTE Address[ DNS_ATM_MAX_ADDR_SIZE ];
  348. // Endsystem Address IA5 digits
  349. // for E164, BCD encoding for NSAP
  350. // Array size is DNS_ATM_MAX_ADDR_SIZE for NSAP
  351. // address type, and a null terminated string
  352. // less than DNS_ATM_MAX_ADDR_SIZE characters
  353. // for E164 address type.
  354. }
  355. DNS_ATMA_DATA, *PDNS_ATMA_DATA;
  356. //
  357. // MS only types -- only hit the wire in MS-MS zone transfer
  358. //
  359. typedef struct
  360. {
  361. DWORD dwMappingFlag;
  362. DWORD dwLookupTimeout;
  363. DWORD dwCacheTimeout;
  364. DWORD cWinsServerCount;
  365. IP_ADDRESS aipWinsServers[1];
  366. }
  367. DNS_WINS_DATA, *PDNS_WINS_DATA;
  368. typedef struct
  369. {
  370. DWORD dwMappingFlag;
  371. DWORD dwLookupTimeout;
  372. DWORD dwCacheTimeout;
  373. LPTSTR pNameResultDomain;
  374. }
  375. DNS_WINSR_DATA, *PDNS_WINSR_DATA;
  376. //
  377. // Length of non-fixed-length data types
  378. //
  379. #define DNS_TEXT_RECORD_LENGTH(StringCount) \
  380. (sizeof(DWORD) + ((StringCount) * sizeof(PCHAR)))
  381. #define DNS_NULL_RECORD_LENGTH(ByteCount) \
  382. (sizeof(DWORD) + (ByteCount))
  383. #define DNS_WKS_RECORD_LENGTH(ByteCount) \
  384. (sizeof(DNS_WKS_DATA) + (ByteCount-1))
  385. #define DNS_WINS_RECORD_LENGTH(IpCount) \
  386. (sizeof(DNS_WINS_DATA) + ((IpCount-1) * sizeof(IP_ADDRESS)))
  387. //
  388. // Record flags
  389. //
  390. #if 0
  391. typedef struct _DnsRecordFlags
  392. {
  393. BYTE Section : 2;
  394. BYTE Delete : 1;
  395. BYTE Unused : 5;
  396. BYTE Unused2 : 4;
  397. BYTE FreeData : 1;
  398. BYTE FreeOwner : 1;
  399. BYTE Unicode : 1;
  400. BYTE Multiple : 1;
  401. WORD Reserved;
  402. }
  403. DNSREC_FLAGS;
  404. #endif
  405. typedef struct _DnsRecordFlags
  406. {
  407. DWORD Section : 2;
  408. DWORD Delete : 1;
  409. DWORD CharSet : 2;
  410. DWORD Unused : 3;
  411. DWORD Reserved : 24;
  412. }
  413. DNSREC_FLAGS;
  414. //
  415. // Record flags as bit flags
  416. // These may be or'd together to set the fields
  417. //
  418. // RR Section in packet
  419. #define DNSREC_SECTION (0x00000003)
  420. #define DNSREC_QUESTION (0x00000000)
  421. #define DNSREC_ANSWER (0x00000001)
  422. #define DNSREC_AUTHORITY (0x00000002)
  423. #define DNSREC_ADDITIONAL (0x00000003)
  424. // RR Section in packet (update)
  425. #define DNSREC_ZONE (0x00000000)
  426. #define DNSREC_PREREQ (0x00000001)
  427. #define DNSREC_UPDATE (0x00000002)
  428. // Delete RR (update) or No-exist (prerequisite)
  429. #define DNSREC_DELETE (0x00000004)
  430. #define DNSREC_NOEXIST (0x00000004)
  431. #ifdef MIDL_PASS
  432. typedef [switch_type(WORD)] union _DNS_RECORD_DATA_TYPES
  433. {
  434. [case(DNS_TYPE_A)] DNS_A_DATA A;
  435. [case(DNS_TYPE_SOA)] DNS_SOA_DATA SOA;
  436. [case(DNS_TYPE_PTR,
  437. DNS_TYPE_NS,
  438. DNS_TYPE_CNAME,
  439. DNS_TYPE_MB,
  440. DNS_TYPE_MD,
  441. DNS_TYPE_MF,
  442. DNS_TYPE_MG,
  443. DNS_TYPE_MR)] DNS_PTR_DATA PTR;
  444. [case(DNS_TYPE_MINFO,
  445. DNS_TYPE_RP)] DNS_MINFO_DATA MINFO;
  446. [case(DNS_TYPE_MX,
  447. DNS_TYPE_AFSDB,
  448. DNS_TYPE_RT)] DNS_MX_DATA MX;
  449. #if 0
  450. // RPC is not able to handle a proper TXT record definition
  451. // note: that if other types are needed they are fixed
  452. // (or semi-fixed) size and may be accomodated easily
  453. [case(DNS_TYPE_HINFO,
  454. DNS_TYPE_ISDN,
  455. DNS_TYPE_TEXT,
  456. DNS_TYPE_X25)] DNS_TXT_DATA TXT;
  457. [case(DNS_TYPE_NULL)] DNS_NULL_DATA Null;
  458. [case(DNS_TYPE_WKS)] DNS_WKS_DATA WKS;
  459. [case(DNS_TYPE_TKEY)] DNS_TKEY_DATA TKEY;
  460. [case(DNS_TYPE_TSIG)] DNS_TSIG_DATA TSIG;
  461. [case(DNS_TYPE_WINS)] DNS_WINS_DATA WINS;
  462. [case(DNS_TYPE_NBSTAT)] DNS_WINSR_DATA WINSR;
  463. #endif
  464. [case(DNS_TYPE_AAAA)] DNS_AAAA_DATA AAAA;
  465. [case(DNS_TYPE_SRV)] DNS_SRV_DATA SRV;
  466. [case(DNS_TYPE_ATMA)] DNS_ATMA_DATA ATMA;
  467. //
  468. // BUGBUG - Commented out since this may not be needed - Check with MarioG
  469. //
  470. //[default] ;
  471. }
  472. DNS_RECORD_DATA_TYPES;
  473. #endif // MIDL_PASS
  474. //
  475. // Record \ RR set structure
  476. //
  477. // Note: The dwReserved flag serves to insure that the substructures
  478. // start on 64-bit boundaries. Since adding the LONGLONG to
  479. // TSIG structure the compiler wants to start them there anyway
  480. // (to 64-align). This insures that no matter what data fields
  481. // are present we are properly 64-aligned.
  482. //
  483. // Do NOT pack this structure, as the substructures to be 64-aligned
  484. // for Win64.
  485. //
  486. typedef struct _DnsRecord
  487. {
  488. struct _DnsRecord * pNext;
  489. LPTSTR pName;
  490. WORD wType;
  491. WORD wDataLength; // Not referenced for DNS record types
  492. // defined above.
  493. #ifdef MIDL_PASS
  494. DWORD Flags;
  495. #else // MIDL_PASS
  496. union
  497. {
  498. DWORD DW; // flags as dword
  499. DNSREC_FLAGS S; // flags as structure
  500. } Flags;
  501. #endif // MIDL_PASS
  502. DWORD dwTtl;
  503. DWORD dwReserved;
  504. #ifdef MIDL_PASS
  505. [switch_is(wType)] DNS_RECORD_DATA_TYPES Data;
  506. #else // MIDL_PASS
  507. union
  508. {
  509. DNS_A_DATA A;
  510. DNS_SOA_DATA SOA, Soa;
  511. DNS_PTR_DATA PTR, Ptr,
  512. NS, Ns,
  513. CNAME, Cname,
  514. MB, Mb,
  515. MD, Md,
  516. MF, Mf,
  517. MG, Mg,
  518. MR, Mr;
  519. DNS_MINFO_DATA MINFO, Minfo,
  520. RP, Rp;
  521. DNS_MX_DATA MX, Mx,
  522. AFSDB, Afsdb,
  523. RT, Rt;
  524. DNS_TXT_DATA HINFO, Hinfo,
  525. ISDN, Isdn,
  526. TXT, Txt,
  527. X25;
  528. DNS_NULL_DATA Null;
  529. DNS_WKS_DATA WKS, Wks;
  530. DNS_AAAA_DATA AAAA;
  531. DNS_SRV_DATA SRV, Srv;
  532. DNS_TKEY_DATA TKEY, Tkey;
  533. DNS_TSIG_DATA TSIG, Tsig;
  534. DNS_ATMA_DATA ATMA, Atma;
  535. DNS_WINS_DATA WINS, Wins;
  536. DNS_WINSR_DATA WINSR, WinsR, NBSTAT, Nbstat;
  537. } Data;
  538. #endif // MIDL_PASS
  539. }
  540. DNS_RECORD, *PDNS_RECORD;
  541. #else // not SDK_DNS_RECORD
  542. //
  543. // Old DNS_RECORD definitions
  544. // JBUGBUG: save only until Cliff (and any other NT file)
  545. // can be converted, then dump
  546. //
  547. //
  548. // Record data for specific types
  549. //
  550. typedef struct
  551. {
  552. IP_ADDRESS ipAddress;
  553. }
  554. DNS_A_DATA, *PDNS_A_DATA;
  555. typedef struct
  556. {
  557. DNS_NAME nameHost;
  558. }
  559. DNS_PTR_DATA, *PDNS_PTR_DATA;
  560. typedef struct
  561. {
  562. DNS_NAME namePrimaryServer;
  563. DNS_NAME nameAdministrator;
  564. DWORD dwSerialNo;
  565. DWORD dwRefresh;
  566. DWORD dwRetry;
  567. DWORD dwExpire;
  568. DWORD dwDefaultTtl;
  569. }
  570. DNS_SOA_DATA, *PDNS_SOA_DATA;
  571. typedef struct
  572. {
  573. DNS_NAME nameMailbox;
  574. DNS_NAME nameErrorsMailbox;
  575. }
  576. DNS_MINFO_DATA, *PDNS_MINFO_DATA;
  577. typedef struct
  578. {
  579. DNS_NAME nameExchange;
  580. WORD wPreference;
  581. WORD Pad; // keep ptrs DWORD aligned
  582. }
  583. DNS_MX_DATA, *PDNS_MX_DATA;
  584. typedef struct
  585. {
  586. DWORD dwStringCount;
  587. DNS_TEXT pStringArray[1];
  588. }
  589. DNS_TXT_DATA, *PDNS_TXT_DATA;
  590. typedef struct
  591. {
  592. // DWORD dwByteCount;
  593. BYTE bData[1];
  594. }
  595. DNS_NULL_DATA, *PDNS_NULL_DATA;
  596. typedef struct
  597. {
  598. IP_ADDRESS ipAddress;
  599. UCHAR chProtocol;
  600. BYTE bBitMask[1];
  601. }
  602. DNS_WKS_DATA, *PDNS_WKS_DATA;
  603. typedef struct
  604. {
  605. IPV6_ADDRESS ipv6Address;
  606. }
  607. DNS_AAAA_DATA, *PDNS_AAAA_DATA;
  608. typedef struct
  609. {
  610. DNS_NAME nameSigner;
  611. WORD wTypeCovered;
  612. BYTE chAlgorithm;
  613. BYTE chLabelCount;
  614. DWORD dwOriginalTtl;
  615. DWORD dwExpiration;
  616. DWORD dwTimeSigned;
  617. WORD wKeyTag;
  618. WORD Pad; // keep byte field aligned
  619. BYTE Signature[1];
  620. }
  621. DNS_SIG_DATA, *PDNS_SIG_DATA;
  622. typedef struct
  623. {
  624. WORD wFlags;
  625. BYTE chProtocol;
  626. BYTE chAlgorithm;
  627. BYTE Key[1];
  628. }
  629. DNS_KEY_DATA, *PDNS_KEY_DATA;
  630. typedef struct
  631. {
  632. WORD wVersion;
  633. WORD wSize;
  634. WORD wHorPrec;
  635. WORD wVerPrec;
  636. DWORD dwLatitude;
  637. DWORD dwLongitude;
  638. DWORD dwAltitude;
  639. }
  640. DNS_LOC_DATA, *PDNS_LOC_DATA;
  641. typedef struct
  642. {
  643. DNS_NAME nameNext;
  644. BYTE bTypeBitMap[1];
  645. }
  646. DNS_NXT_DATA, *PDNS_NXT_DATA;
  647. typedef struct
  648. {
  649. DNS_NAME nameTarget;
  650. WORD wPriority;
  651. WORD wWeight;
  652. WORD wPort;
  653. WORD Pad; // keep ptrs DWORD aligned
  654. }
  655. DNS_SRV_DATA, *PDNS_SRV_DATA;
  656. typedef struct
  657. {
  658. DNS_NAME nameAlgorithm;
  659. PBYTE pAlgorithmPacket;
  660. PBYTE pKey;
  661. PBYTE pOtherData;
  662. DWORD dwCreateTime;
  663. DWORD dwExpireTime;
  664. WORD wMode;
  665. WORD wError;
  666. WORD wKeyLength;
  667. WORD wOtherLength;
  668. UCHAR cAlgNameLength;
  669. BOOLEAN fPacketPointers;
  670. }
  671. DNS_TKEY_DATA, *PDNS_TKEY_DATA;
  672. typedef struct
  673. {
  674. DNS_NAME nameAlgorithm;
  675. PBYTE pAlgorithmPacket;
  676. PBYTE pSignature;
  677. PBYTE pOtherData;
  678. LONGLONG i64CreateTime;
  679. WORD wFudgeTime;
  680. WORD wOriginalID;
  681. WORD wError;
  682. WORD wSigLength;
  683. WORD wOtherLength;
  684. UCHAR cAlgNameLength;
  685. BOOLEAN fPacketPointers;
  686. }
  687. DNS_TSIG_DATA, *PDNS_TSIG_DATA;
  688. #define DNS_ATM_TYPE_E164 0x01 // E.164 addressing scheme
  689. #define DNS_ATM_TYPE_NSAP 0x02 // NSAP-style addressing scheme
  690. #define DNS_ATM_TYPE_AESA DNS_ATM_TYPE_NSAP
  691. #define DNS_ATM_MAX_ADDR_SIZE 20
  692. typedef struct
  693. {
  694. BYTE AddressType; // E.164 or NSAP-style ATM Endsystem Address
  695. BYTE Address[1]; // IA5 digits for E164, BCD encoding for NSAP
  696. // Array size is DNS_ATM_MAX_ADDR_SIZE for NSAP
  697. // address type, and a null terminated string
  698. // less than DNS_ATM_MAX_ADDR_SIZE characters
  699. // for E164 address type.
  700. }
  701. DNS_ATMA_DATA, *PDNS_ATMA_DATA;
  702. //
  703. // MS only types -- only hit the wire in MS-MS zone transfer
  704. //
  705. typedef struct
  706. {
  707. DWORD dwMappingFlag;
  708. DWORD dwLookupTimeout;
  709. DWORD dwCacheTimeout;
  710. DWORD cWinsServerCount;
  711. IP_ADDRESS aipWinsServers[1];
  712. }
  713. DNS_WINS_DATA, *PDNS_WINS_DATA;
  714. typedef struct
  715. {
  716. DWORD dwMappingFlag;
  717. DWORD dwLookupTimeout;
  718. DWORD dwCacheTimeout;
  719. DNS_NAME nameResultDomain;
  720. }
  721. DNS_WINSR_DATA, *PDNS_WINSR_DATA;
  722. //
  723. // Length of non-fixed-length data types
  724. //
  725. #define DNS_TEXT_RECORD_LENGTH(StringCount) \
  726. (sizeof(DWORD) + ((StringCount) * sizeof(PCHAR)))
  727. #define DNS_NULL_RECORD_LENGTH(ByteCount) \
  728. (sizeof(DWORD) + (ByteCount))
  729. #define DNS_WKS_RECORD_LENGTH(ByteCount) \
  730. (sizeof(DNS_WKS_DATA) + (ByteCount-1))
  731. #define DNS_WINS_RECORD_LENGTH(IpCount) \
  732. (sizeof(DNS_WINS_DATA) + ((IpCount-1) * sizeof(IP_ADDRESS)))
  733. //
  734. // Record flags
  735. //
  736. typedef struct _DnsRecordFlags
  737. {
  738. DWORD Section : 2;
  739. DWORD Delete : 1;
  740. DWORD Unused : 5;
  741. DWORD Unused2 : 4;
  742. DWORD FreeData : 1;
  743. DWORD FreeOwner : 1;
  744. DWORD Unicode : 1;
  745. DWORD Multiple : 1;
  746. DWORD Reserved : 16;
  747. }
  748. DNSREC_FLAGS;
  749. //
  750. // Record flags as bit flags
  751. // These may be or'd together to set the fields
  752. //
  753. // RR Section in packet
  754. #define DNSREC_SECTION (0x00000003)
  755. #define DNSREC_QUESTION (0x00000000)
  756. #define DNSREC_ANSWER (0x00000001)
  757. #define DNSREC_AUTHORITY (0x00000002)
  758. #define DNSREC_ADDITIONAL (0x00000003)
  759. // RR Section in packet (update)
  760. #define DNSREC_ZONE (0x00000000)
  761. #define DNSREC_PREREQ (0x00000001)
  762. #define DNSREC_UPDATE (0x00000002)
  763. // Delete RR (update) or No-exist (prerequisite)
  764. #define DNSREC_DELETE (0x00000004)
  765. #define DNSREC_NOEXIST (0x00000004)
  766. // Owner name is allocated and can be freed with record cleanup
  767. #define DNSREC_FREEOWNER (0x00002000)
  768. // UNICODE names in record
  769. #define DNSREC_UNICODE (0x00004000)
  770. // Multiple RR in this record buffer
  771. // This optimization may be used with fixed types only
  772. #define DNSREC_MULTIPLE (0x00008000)
  773. //
  774. // Record \ RR set structure
  775. //
  776. // Note: The dwReserved flag serves to insure that the substructures
  777. // start on 64-bit boundaries. Since adding the LONGLONG to
  778. // TSIG structure the compiler wants to start them there anyway
  779. // (to 64-align). This insures that no matter what data fields
  780. // are present we are properly 64-aligned.
  781. //
  782. // Do NOT pack this structure, as the substructures to be 64-aligned
  783. // for Win64.
  784. //
  785. typedef struct _DnsRecord
  786. {
  787. struct _DnsRecord * pNext;
  788. DNS_NAME nameOwner;
  789. WORD wType;
  790. WORD wDataLength;
  791. union
  792. {
  793. DWORD W; // flags as dword
  794. DNSREC_FLAGS S; // flags as structure
  795. } Flags;
  796. DWORD dwTtl;
  797. DWORD dwReserved;
  798. union
  799. {
  800. DNS_A_DATA A;
  801. DNS_SOA_DATA SOA, Soa;
  802. DNS_PTR_DATA PTR, Ptr,
  803. NS, Ns,
  804. CNAME, Cname,
  805. MB, Mb,
  806. MD, Md,
  807. MF, Mf,
  808. MG, Mg,
  809. MR, Mr;
  810. DNS_MINFO_DATA MINFO, Minfo,
  811. RP, Rp;
  812. DNS_MX_DATA MX, Mx,
  813. AFSDB, Afsdb,
  814. RT, Rt;
  815. DNS_TXT_DATA HINFO, Hinfo,
  816. ISDN, Isdn,
  817. TXT, Txt,
  818. X25;
  819. DNS_NULL_DATA Null;
  820. DNS_WKS_DATA WKS, Wks;
  821. DNS_AAAA_DATA AAAA;
  822. DNS_SRV_DATA SRV, Srv;
  823. DNS_TKEY_DATA TKEY, Tkey;
  824. DNS_TSIG_DATA TSIG, Tsig;
  825. DNS_ATMA_DATA ATMA, Atma;
  826. DNS_WINS_DATA WINS, Wins;
  827. DNS_WINSR_DATA WINSR, WinsR, NBSTAT, Nbstat;
  828. } Data;
  829. }
  830. DNS_RECORD, *PDNS_RECORD;
  831. #endif // End of old DNS_RECORD definitions
  832. #define DNS_RECORD_FIXED_SIZE FIELD_OFFSET( DNS_RECORD, Data )
  833. #define SIZEOF_DNS_RECORD_HEADER DNS_RECORD_FIXED_SIZE
  834. //
  835. // Resource record set building
  836. //
  837. // pFirst points to first record in list.
  838. // pLast points to last record in list.
  839. //
  840. typedef struct _DnsRRSet
  841. {
  842. PDNS_RECORD pFirstRR;
  843. PDNS_RECORD pLastRR;
  844. }
  845. DNS_RRSET, *PDNS_RRSET;
  846. //
  847. // To init pFirst is NULL.
  848. // But pLast points at the location of the pFirst pointer -- essentially
  849. // treating the pFirst ptr as a DNS_RECORD. (It is a DNS_RECORD with
  850. // only a pNext field, but that's the only part we use.)
  851. //
  852. // Then when the first record is added to the list, the pNext field of
  853. // this dummy record (which corresponds to pFirst's value) is set to
  854. // point at the first record. So pFirst then properly points at the
  855. // first record.
  856. //
  857. // (This works only because pNext is the first field in a
  858. // DNS_RECORD structure and hence casting a PDNS_RECORD ptr to
  859. // PDNS_RECORD* and dereferencing yields its pNext field)
  860. //
  861. #define DNS_RRSET_INIT( rrset ) \
  862. { \
  863. PDNS_RRSET _prrset = &(rrset); \
  864. _prrset->pFirstRR = NULL; \
  865. _prrset->pLastRR = (PDNS_RECORD) &_prrset->pFirstRR; \
  866. }
  867. #define DNS_RRSET_ADD( rrset, pnewRR ) \
  868. { \
  869. PDNS_RRSET _prrset = &(rrset); \
  870. PDNS_RECORD _prrnew = (pnewRR); \
  871. _prrset->pLastRR->pNext = _prrnew; \
  872. _prrset->pLastRR = _prrnew; \
  873. }
  874. //
  875. // Record building (rralloc.c)
  876. //
  877. PDNS_RECORD
  878. WINAPI
  879. DnsAllocateRecord(
  880. IN WORD wBufferLength
  881. );
  882. VOID
  883. WINAPI
  884. DnsRecordListFree(
  885. IN OUT PDNS_RECORD pRecord,
  886. IN BOOL fFreeOwner
  887. );
  888. #define DnsFreeRRSet( pRRSet, fFreeOwner ) \
  889. DnsRecordListFree( (pRRSet), (fFreeOwner) )
  890. PDNS_RECORD
  891. DnsRecordSetDetach(
  892. IN OUT PDNS_RECORD pRR
  893. );
  894. PDNS_RECORD
  895. DnsCreatePtrRecord(
  896. IN IP_ADDRESS ipAddress,
  897. IN DNS_NAME pszHostName,
  898. IN BOOL fUnicodeName
  899. );
  900. //
  901. // Record build from data strings (rrbuild.c)
  902. //
  903. PDNS_RECORD
  904. DnsRecordBuild(
  905. IN OUT PDNS_RRSET pRRSet,
  906. IN LPSTR pszOwner,
  907. IN WORD wType,
  908. IN BOOL fAdd,
  909. IN UCHAR Section,
  910. IN INT Argc,
  911. IN PCHAR * Argv
  912. );
  913. PDNS_RECORD
  914. DnsRecordBuild_UTF8(
  915. IN OUT PDNS_RRSET pRRSet,
  916. IN LPSTR pszOwner,
  917. IN WORD wType,
  918. IN BOOL fAdd,
  919. IN UCHAR Section,
  920. IN INT Argc,
  921. IN PCHAR * Argv
  922. );
  923. PDNS_RECORD
  924. DnsRecordBuild_W(
  925. IN OUT PDNS_RRSET pRRSet,
  926. IN LPWSTR pszOwner,
  927. IN WORD wType,
  928. IN BOOL fAdd,
  929. IN UCHAR Section,
  930. IN INT Argc,
  931. IN PWCHAR * Argv
  932. );
  933. //
  934. // Record set manipulation
  935. //
  936. //
  937. // Record Compare
  938. //
  939. // Note: these routines will NOT do proper unicode compare, unless
  940. // records have the fUnicode flag set. Both input record lists
  941. // must be either ANSI or UNICODE, but not one of each.
  942. //
  943. BOOL
  944. WINAPI
  945. DnsRecordCompare(
  946. IN PDNS_RECORD pRecord1,
  947. IN PDNS_RECORD pRecord2
  948. );
  949. BOOL
  950. WINAPI
  951. DnsRecordSetCompare(
  952. IN OUT PDNS_RECORD pRR1,
  953. IN OUT PDNS_RECORD pRR2,
  954. OUT PDNS_RECORD * ppDiff1,
  955. OUT PDNS_RECORD * ppDiff2
  956. );
  957. //
  958. // DNS Name compare
  959. //
  960. BOOL
  961. WINAPI
  962. DnsNameCompare_A(
  963. IN LPSTR pName1,
  964. IN LPSTR pName2
  965. );
  966. BOOL
  967. WINAPI
  968. DnsNameCompare_W(
  969. IN LPWSTR pName1,
  970. IN LPWSTR pName2
  971. );
  972. //
  973. // Record Copy
  974. // Record copy functions also do conversion between character sets.
  975. //
  976. // Note, it might be advisable to directly expose non-Ex copy
  977. // functions _W, _A for record and set, to avoid exposing the
  978. // conversion enum.
  979. //
  980. typedef enum _DNS_CHARSET
  981. {
  982. DnsCharSetUnknown,
  983. DnsCharSetUnicode,
  984. DnsCharSetUtf8,
  985. DnsCharSetAnsi,
  986. }
  987. DNS_CHARSET;
  988. PDNS_RECORD
  989. WINAPI
  990. DnsRecordCopyEx(
  991. IN PDNS_RECORD pRecord,
  992. IN DNS_CHARSET CharSetIn,
  993. IN DNS_CHARSET CharSetOut
  994. );
  995. PDNS_RECORD
  996. WINAPI
  997. DnsRecordSetCopyEx(
  998. IN PDNS_RECORD pRecordSet,
  999. IN DNS_CHARSET CharSetIn,
  1000. IN DNS_CHARSET CharSetOut
  1001. );
  1002. #ifdef UNICODE
  1003. #define DnsRecordCopy(pRR) \
  1004. DnsRecordCopyEx( (pRR), DnsCharSetUnicode, DnsCharSetUnicode )
  1005. #define DnsRecordSetCopy(pRR) \
  1006. DnsRecordSetCopyEx( (pRR), DnsCharSetUnicode, DnsCharSetUnicode )
  1007. #else
  1008. #define DnsRecordCopy(pRR) \
  1009. DnsRecordCopyEx( (pRR), DnsCharSetAnsi, DnsCharSetAnsi )
  1010. #define DnsRecordSetCopy(pRR) \
  1011. DnsRecordSetCopyEx( (pRR), DnsCharSetAnsi, DnsCharSetAnsi )
  1012. #endif
  1013. #if 0
  1014. PDNS_RECORD
  1015. WINAPI
  1016. DnsRecordCopy(
  1017. IN PDNS_RECORD pRecord,
  1018. IN BOOL fUnicodeIn
  1019. );
  1020. PDNS_RECORD
  1021. DnsRecordSetCopy(
  1022. IN PDNS_RECORD pRR,
  1023. IN BOOL fUnicodeIn
  1024. );
  1025. PDNS_RECORD
  1026. WINAPI
  1027. DnsRecordCopy_W(
  1028. IN PDNS_RECORD pRecord
  1029. );
  1030. PDNS_RECORD
  1031. WINAPI
  1032. DnsRecordSetCopy_W(
  1033. IN PDNS_RECORD pRRSet
  1034. );
  1035. #endif
  1036. //
  1037. // Routines to copy and convert UNICODE records to other string type records
  1038. //
  1039. PDNS_RECORD
  1040. WINAPI
  1041. DnsCopyUnicodeRecordToUnicodeRecord(
  1042. IN PDNS_RECORD pRecord
  1043. );
  1044. PDNS_RECORD
  1045. WINAPI
  1046. DnsCopyUnicodeRecordToUtf8Record(
  1047. IN PDNS_RECORD pRecord
  1048. );
  1049. PDNS_RECORD
  1050. WINAPI
  1051. DnsCopyUnicodeRecordToAnsiRecord(
  1052. IN PDNS_RECORD pRecord
  1053. );
  1054. PDNS_RECORD
  1055. DnsCopyUnicodeRRSetToUnicodeRRSet(
  1056. IN PDNS_RECORD pRR
  1057. );
  1058. PDNS_RECORD
  1059. DnsCopyUnicodeRRSetToUtf8RRSet(
  1060. IN PDNS_RECORD pRR
  1061. );
  1062. PDNS_RECORD
  1063. DnsCopyUnicodeRRSetToAnsiRRSet(
  1064. IN PDNS_RECORD pRR
  1065. );
  1066. //
  1067. // DNS Update API
  1068. //
  1069. // NOTE:
  1070. //
  1071. // The DNS update API functions have new names to clearify their use.
  1072. // The new functions for various DNS update operations are:
  1073. //
  1074. // DnsAcquireContextHandle
  1075. // DnsReleaseContextHandle
  1076. // DnsAddRecords
  1077. // DnsAddRecordSet
  1078. // DnsModifyRecords
  1079. // DnsModifyRecordSet
  1080. // DnsRemoveRecords
  1081. // DnsReplaceRecordSet
  1082. // DnsUpdateTest
  1083. // DnsGetLastServerUpdateIP
  1084. //
  1085. // The old functions have been changed to macros so
  1086. // as not to break the build.
  1087. //
  1088. //
  1089. // Old DNS update function definitions
  1090. //
  1091. // Options for DnsModifyRRSet & DnsRegisterRRSet
  1092. //
  1093. //
  1094. // Update flags
  1095. //
  1096. //
  1097. // Old flags used for DnsModifyRRSet & DnsRegisterRRSet
  1098. //
  1099. #define DNS_UPDATE_UNIQUE 0x00000000
  1100. #define DNS_UPDATE_SHARED 0x00000001
  1101. //
  1102. // New flags used for:
  1103. // DnsModifyRecords
  1104. // DnsModifyRecordSet
  1105. // DnsAddRecords
  1106. // DnsAddRecordSet
  1107. // DnsRemoveRecords
  1108. // DnsReplaceRecordSet
  1109. //
  1110. #define DNS_UPDATE_SECURITY_USE_DEFAULT 0x00000000
  1111. #define DNS_UPDATE_SECURITY_OFF 0x00000010
  1112. #define DNS_UPDATE_SECURITY_ON 0x00000020
  1113. #define DNS_UPDATE_SECURITY_ONLY 0x00000100
  1114. #define DNS_UPDATE_CACHE_SECURITY_CONTEXT 0x00000200
  1115. #define DNS_UPDATE_TEST_USE_LOCAL_SYS_ACCT 0x00000400
  1116. #define DNS_UPDATE_FORCE_SECURITY_NEGO 0x00000800
  1117. #define DNS_UPDATE_RESERVED 0xfffff000
  1118. DNS_STATUS
  1119. WINAPI
  1120. DnsAcquireContextHandle_W(
  1121. IN DWORD CredentialFlags,
  1122. IN PVOID Credentials OPTIONAL, // Actually this will be a
  1123. // PSEC_WINNT_AUTH_IDENTITY_W,
  1124. // calling this a PVOID to avoid
  1125. // having to include rpcdce.h
  1126. OUT HANDLE * ContextHandle
  1127. );
  1128. DNS_STATUS
  1129. WINAPI
  1130. DnsAcquireContextHandle_A(
  1131. IN DWORD CredentialFlags,
  1132. IN PVOID Credentials OPTIONAL, // Actually this will be a
  1133. // PSEC_WINNT_AUTH_IDENTITY_A,
  1134. // calling this a PVOID to avoid
  1135. // having to include rpcdce.h
  1136. OUT HANDLE * ContextHandle
  1137. );
  1138. #ifdef UNICODE
  1139. #define DnsAcquireContextHandle DnsAcquireContextHandle_W
  1140. #else
  1141. #define DnsAcquireContextHandle DnsAcquireContextHandle_A
  1142. #endif
  1143. VOID
  1144. WINAPI
  1145. DnsReleaseContextHandle(
  1146. IN HANDLE ContextHandle
  1147. );
  1148. DNS_STATUS
  1149. WINAPI
  1150. DnsModifyRecords_A(
  1151. IN HANDLE hContextHandle OPTIONAL,
  1152. IN PDNS_RECORD pCurrentSet,
  1153. IN PDNS_RECORD pNewSet,
  1154. IN DWORD fOptions,
  1155. IN PIP_ARRAY aipServers OPTIONAL
  1156. );
  1157. DNS_STATUS
  1158. WINAPI
  1159. DnsModifyRecords_UTF8(
  1160. IN HANDLE hContextHandle OPTIONAL,
  1161. IN PDNS_RECORD pCurrentSet,
  1162. IN PDNS_RECORD pNewSet,
  1163. IN DWORD fOptions,
  1164. IN PIP_ARRAY aipServers OPTIONAL
  1165. );
  1166. DNS_STATUS
  1167. WINAPI
  1168. DnsModifyRecords_W(
  1169. IN HANDLE hContextHandle OPTIONAL,
  1170. IN PDNS_RECORD pCurrentSet,
  1171. IN PDNS_RECORD pNewSet,
  1172. IN DWORD fOptions,
  1173. IN PIP_ARRAY aipServers OPTIONAL
  1174. );
  1175. #ifdef UNICODE
  1176. #define DnsModifyRecords DnsModifyRecords_W
  1177. #else
  1178. #define DnsModifyRecords DnsModifyRecords_A
  1179. #endif
  1180. DNS_STATUS
  1181. WINAPI
  1182. DnsModifyRecordSet_A(
  1183. IN HANDLE hContextHandle OPTIONAL,
  1184. IN PDNS_RECORD pCurrentSet,
  1185. IN PDNS_RECORD pNewSet,
  1186. IN DWORD fOptions,
  1187. IN PIP_ARRAY aipServers OPTIONAL
  1188. );
  1189. DNS_STATUS
  1190. WINAPI
  1191. DnsModifyRecordSet_UTF8(
  1192. IN HANDLE hContextHandle OPTIONAL,
  1193. IN PDNS_RECORD pCurrentSet,
  1194. IN PDNS_RECORD pNewSet,
  1195. IN DWORD fOptions,
  1196. IN PIP_ARRAY aipServers OPTIONAL
  1197. );
  1198. DNS_STATUS
  1199. WINAPI
  1200. DnsModifyRecordSet_W(
  1201. IN HANDLE hContextHandle OPTIONAL,
  1202. IN PDNS_RECORD pCurrentSet,
  1203. IN PDNS_RECORD pNewSet,
  1204. IN DWORD fOptions,
  1205. IN PIP_ARRAY aipServers OPTIONAL
  1206. );
  1207. #ifdef UNICODE
  1208. #define DnsModifyRecordSet DnsModifyRecordSet_W
  1209. #else
  1210. #define DnsModifyRecordSet DnsModifyRecordSet_A
  1211. #endif
  1212. #define DnsModifyRRSet_A( _pCSet, \
  1213. _pNSet, \
  1214. _Options, \
  1215. _Servers ) \
  1216. ( _Options & DNS_UPDATE_SHARED ) ? \
  1217. DnsModifyRecords_A( NULL, \
  1218. ( _pCSet ), \
  1219. ( _pNSet ), \
  1220. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1221. ( _Servers ) ) \
  1222. : \
  1223. DnsModifyRecordSet_A( NULL, \
  1224. ( _pCSet ), \
  1225. ( _pNSet ), \
  1226. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1227. ( _Servers ) )
  1228. #define DnsModifyRRSet_W( _pCSet, \
  1229. _pNSet, \
  1230. _Options, \
  1231. _Servers ) \
  1232. ( _Options & DNS_UPDATE_SHARED ) ? \
  1233. DnsModifyRecords_W( NULL, \
  1234. ( _pCSet ), \
  1235. ( _pNSet ), \
  1236. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1237. ( _Servers ) ) \
  1238. : \
  1239. DnsModifyRecordSet_W( NULL, \
  1240. ( _pCSet ), \
  1241. ( _pNSet ), \
  1242. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1243. ( _Servers ) )
  1244. #ifdef UNICODE
  1245. #define DnsModifyRRSet( _pCSet, \
  1246. _pNSet, \
  1247. _Options, \
  1248. _Servers ) \
  1249. ( _Options & DNS_UPDATE_SHARED ) ? \
  1250. DnsModifyRecords_W( NULL, \
  1251. ( _pCSet ), \
  1252. ( _pNSet ), \
  1253. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1254. ( _Servers ) ) \
  1255. : \
  1256. DnsModifyRecordSet_W( NULL, \
  1257. ( _pCSet ), \
  1258. ( _pNSet ), \
  1259. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1260. ( _Servers ) )
  1261. #else
  1262. #define DnsModifyRRSet( _pCSet, \
  1263. _pNSet, \
  1264. _Options, \
  1265. _Servers ) \
  1266. ( _Options & DNS_UPDATE_SHARED ) ? \
  1267. DnsModifyRecords_A( NULL, \
  1268. ( _pCSet ), \
  1269. ( _pNSet ), \
  1270. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1271. ( _Servers ) ) \
  1272. : \
  1273. DnsModifyRecordSet_A( NULL, \
  1274. ( _pCSet ), \
  1275. ( _pNSet ), \
  1276. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1277. ( _Servers ) )
  1278. #endif
  1279. DNS_STATUS
  1280. WINAPI
  1281. DnsAddRecords_A(
  1282. IN HANDLE hContextHandle OPTIONAL,
  1283. IN PDNS_RECORD pRRSet,
  1284. IN DWORD fOptions,
  1285. IN PIP_ARRAY aipServers OPTIONAL
  1286. );
  1287. DNS_STATUS
  1288. WINAPI
  1289. DnsAddRecords_UTF8(
  1290. IN HANDLE hContextHandle OPTIONAL,
  1291. IN PDNS_RECORD pRRSet,
  1292. IN DWORD fOptions,
  1293. IN PIP_ARRAY aipServers OPTIONAL
  1294. );
  1295. DNS_STATUS
  1296. WINAPI
  1297. DnsAddRecords_W(
  1298. IN HANDLE hContextHandle OPTIONAL,
  1299. IN PDNS_RECORD pRRSet,
  1300. IN DWORD fOptions,
  1301. IN PIP_ARRAY aipServers OPTIONAL
  1302. );
  1303. #ifdef UNICODE
  1304. #define DnsAddRecords DnsAddRecords_W
  1305. #else
  1306. #define DnsAddRecords DnsAddRecords_A
  1307. #endif
  1308. DNS_STATUS
  1309. WINAPI
  1310. DnsAddRecordSet_A(
  1311. IN HANDLE hContextHandle OPTIONAL,
  1312. IN PDNS_RECORD pRRSet,
  1313. IN DWORD fOptions,
  1314. IN PIP_ARRAY aipServers OPTIONAL
  1315. );
  1316. DNS_STATUS
  1317. WINAPI
  1318. DnsAddRecordSet_UTF8(
  1319. IN HANDLE hContextHandle OPTIONAL,
  1320. IN PDNS_RECORD pRRSet,
  1321. IN DWORD fOptions,
  1322. IN PIP_ARRAY aipServers OPTIONAL
  1323. );
  1324. DNS_STATUS
  1325. WINAPI
  1326. DnsAddRecordSet_W(
  1327. IN HANDLE hContextHandle OPTIONAL,
  1328. IN PDNS_RECORD pRRSet,
  1329. IN DWORD fOptions,
  1330. IN PIP_ARRAY aipServers OPTIONAL
  1331. );
  1332. #ifdef UNICODE
  1333. #define DnsAddRecordSet DnsAddRecordSet_W
  1334. #else
  1335. #define DnsAddRecordSet DnsAddRecordSet_A
  1336. #endif
  1337. #define DnsRegisterRRSet_A( _pRSet, \
  1338. _Options, \
  1339. _Servers ) \
  1340. ( _Options & DNS_UPDATE_SHARED ) ? \
  1341. DnsAddRecords_A( NULL, \
  1342. ( _pRSet ), \
  1343. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1344. ( _Servers ) ) \
  1345. : \
  1346. DnsAddRecordSet_A( NULL, \
  1347. ( _pRSet ), \
  1348. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1349. ( _Servers ) )
  1350. #define DnsRegisterRRSet_W( _pRSet, \
  1351. _Options, \
  1352. _Servers ) \
  1353. ( _Options & DNS_UPDATE_SHARED ) ? \
  1354. DnsAddRecords_W( NULL, \
  1355. ( _pRSet ), \
  1356. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1357. ( _Servers ) ) \
  1358. : \
  1359. DnsAddRecordSet_W( NULL, \
  1360. ( _pRSet ), \
  1361. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1362. ( _Servers ) )
  1363. #ifdef UNICODE
  1364. #define DnsRegisterRRSet( _pRSet, \
  1365. _Options, \
  1366. _Servers ) \
  1367. ( _Options & DNS_UPDATE_SHARED ) ? \
  1368. DnsAddRecords_W( NULL, \
  1369. ( _pRSet ), \
  1370. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1371. ( _Servers ) ) \
  1372. : \
  1373. DnsAddRecordSet_W( NULL, \
  1374. ( _pRSet ), \
  1375. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1376. ( _Servers ) )
  1377. #else
  1378. #define DnsRegisterRRSet( _pRSet, \
  1379. _Options, \
  1380. _Servers ) \
  1381. ( _Options & DNS_UPDATE_SHARED ) ? \
  1382. DnsAddRecords_A( NULL, \
  1383. ( _pRSet ), \
  1384. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1385. ( _Servers ) ) \
  1386. : \
  1387. DnsAddRecordSet_A( NULL, \
  1388. ( _pRSet ), \
  1389. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1390. ( _Servers ) )
  1391. #endif
  1392. DNS_STATUS
  1393. WINAPI
  1394. DnsRemoveRecords_A(
  1395. IN HANDLE hContextHandle OPTIONAL,
  1396. IN PDNS_RECORD pRRSet,
  1397. IN DWORD fOptions,
  1398. IN PIP_ARRAY aipServers OPTIONAL
  1399. );
  1400. DNS_STATUS
  1401. WINAPI
  1402. DnsRemoveRecords_UTF8(
  1403. IN HANDLE hContextHandle OPTIONAL,
  1404. IN PDNS_RECORD pRRSet,
  1405. IN DWORD fOptions,
  1406. IN PIP_ARRAY aipServers OPTIONAL
  1407. );
  1408. DNS_STATUS
  1409. WINAPI
  1410. DnsRemoveRecords_W(
  1411. IN HANDLE hContextHandle OPTIONAL,
  1412. IN PDNS_RECORD pRRSet,
  1413. IN DWORD fOptions,
  1414. IN PIP_ARRAY aipServers OPTIONAL
  1415. );
  1416. #ifdef UNICODE
  1417. #define DnsRemoveRecords DnsRemoveRecords_W
  1418. #else
  1419. #define DnsRemoveRecords DnsRemoveRecords_A
  1420. #endif
  1421. #define DnsRemoveRRSet_A( _pRSet, \
  1422. _Servers ) \
  1423. DnsRemoveRecords_A( NULL, \
  1424. ( _pRSet ), \
  1425. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1426. ( _Servers ) )
  1427. #define DnsRemoveRRSet_W( _pRSet, \
  1428. _Servers ) \
  1429. DnsRemoveRecords_W( NULL, \
  1430. ( _pRSet ), \
  1431. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1432. ( _Servers ) )
  1433. #ifdef UNICODE
  1434. #define DnsRemoveRRSet( _pRSet, \
  1435. _Servers ) \
  1436. DnsRemoveRecords_W( NULL, \
  1437. ( _pRSet ), \
  1438. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1439. ( _Servers ) )
  1440. #else
  1441. #define DnsRemoveRRSet( _pRSet, \
  1442. _Servers ) \
  1443. DnsRemoveRecords_A( NULL, \
  1444. ( _pRSet ), \
  1445. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1446. ( _Servers ) )
  1447. #endif
  1448. DNS_STATUS
  1449. WINAPI
  1450. DnsReplaceRecordSet_A(
  1451. IN HANDLE hContextHandle OPTIONAL,
  1452. IN PDNS_RECORD pRRSet,
  1453. IN DWORD fOptions,
  1454. IN PIP_ARRAY aipServers OPTIONAL
  1455. );
  1456. DNS_STATUS
  1457. WINAPI
  1458. DnsReplaceRecordSet_UTF8(
  1459. IN HANDLE hContextHandle OPTIONAL,
  1460. IN PDNS_RECORD pRRSet,
  1461. IN DWORD fOptions,
  1462. IN PIP_ARRAY aipServers OPTIONAL
  1463. );
  1464. DNS_STATUS
  1465. WINAPI
  1466. DnsReplaceRecordSet_W(
  1467. IN HANDLE hContextHandle OPTIONAL,
  1468. IN PDNS_RECORD pRRSet,
  1469. IN DWORD fOptions,
  1470. IN PIP_ARRAY aipServers OPTIONAL
  1471. );
  1472. #ifdef UNICODE
  1473. #define DnsReplaceRecordSet DnsReplaceRecordSet_W
  1474. #else
  1475. #define DnsReplaceRecordSet DnsReplaceRecordSet_A
  1476. #endif
  1477. #define DnsReplaceRRSet_A( _pRSet, \
  1478. _Servers ) \
  1479. DnsReplaceRecordSet_A( NULL, \
  1480. ( _pRSet ), \
  1481. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1482. ( _Servers ) )
  1483. #define DnsReplaceRRSet_W( _pRSet, \
  1484. _Servers ) \
  1485. DnsReplaceRecordSet_W( NULL, \
  1486. ( _pRSet ), \
  1487. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1488. ( _Servers ) )
  1489. #ifdef UNICODE
  1490. #define DnsReplaceRRSet( _pRSet, \
  1491. _Servers ) \
  1492. DnsReplaceRecordSet_W( NULL, \
  1493. ( _pRSet ), \
  1494. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1495. ( _Servers ) )
  1496. #else
  1497. #define DnsReplaceRRSet( _pRSet, \
  1498. _Servers ) \
  1499. DnsReplaceRecordSet_A( NULL, \
  1500. ( _pRSet ), \
  1501. DNS_UPDATE_SECURITY_USE_DEFAULT, \
  1502. ( _Servers ) )
  1503. #endif
  1504. DNS_STATUS
  1505. WINAPI
  1506. DnsUpdateTest_A(
  1507. IN HANDLE hContextHandle OPTIONAL,
  1508. IN LPSTR pszName,
  1509. IN DWORD fOptions,
  1510. IN PIP_ARRAY aipServers OPTIONAL
  1511. );
  1512. DNS_STATUS
  1513. WINAPI
  1514. DnsUpdateTest_UTF8(
  1515. IN HANDLE hContextHandle OPTIONAL,
  1516. IN LPSTR pszName,
  1517. IN DWORD fOptions,
  1518. IN PIP_ARRAY aipServers OPTIONAL
  1519. );
  1520. DNS_STATUS
  1521. WINAPI
  1522. DnsUpdateTest_W(
  1523. IN HANDLE hContextHandle OPTIONAL,
  1524. IN LPWSTR pszName,
  1525. IN DWORD fOptions,
  1526. IN PIP_ARRAY aipServers OPTIONAL
  1527. );
  1528. #ifdef UNICODE
  1529. #define DnsUpdateTest DnsUpdateTest_W
  1530. #else
  1531. #define DnsUpdateTest DnsUpdateTest_A
  1532. #endif
  1533. IP_ADDRESS
  1534. WINAPI
  1535. DnsGetLastServerUpdateIP (
  1536. VOID
  1537. );
  1538. //
  1539. // DNS Query API
  1540. //
  1541. //
  1542. // Options for DnsQuery
  1543. //
  1544. #define DNS_QUERY_STANDARD 0x00000000
  1545. #define DNS_QUERY_ACCEPT_PARTIAL_UDP 0x00000001
  1546. #define DNS_QUERY_USE_TCP_ONLY 0x00000002
  1547. #define DNS_QUERY_NO_RECURSION 0x00000004
  1548. #define DNS_QUERY_BYPASS_CACHE 0x00000008
  1549. #define DNS_QUERY_CACHE_ONLY 0x00000010
  1550. #define DNS_QUERY_SOCKET_KEEPALIVE 0x00000100
  1551. #define DNS_QUERY_TREAT_AS_FQDN 0x00001000
  1552. #define DNS_QUERY_ALLOW_EMPTY_AUTH_RESP 0x00010000
  1553. #define DNS_QUERY_RESERVED 0xfff00000
  1554. #define DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE DNS_QUERY_ACCEPT_PARTIAL_UDP
  1555. DNS_STATUS WINAPI
  1556. DnsQuery_A(
  1557. IN LPSTR lpstrName,
  1558. IN WORD wType,
  1559. IN DWORD fOptions,
  1560. IN PIP_ARRAY aipServers OPTIONAL,
  1561. IN OUT PDNS_RECORD * ppQueryResultsSet OPTIONAL,
  1562. IN OUT PVOID * pReserved OPTIONAL
  1563. );
  1564. DNS_STATUS WINAPI
  1565. DnsQuery_UTF8(
  1566. IN LPSTR lpstrName,
  1567. IN WORD wType,
  1568. IN DWORD fOptions,
  1569. IN PIP_ARRAY aipServers OPTIONAL,
  1570. IN OUT PDNS_RECORD * ppQueryResultsSet OPTIONAL,
  1571. IN OUT PVOID * pReserved OPTIONAL
  1572. );
  1573. DNS_STATUS WINAPI
  1574. DnsQuery_W(
  1575. IN LPWSTR lpstrName,
  1576. IN WORD wType,
  1577. IN DWORD fOptions,
  1578. IN PIP_ARRAY aipServers OPTIONAL,
  1579. IN OUT PDNS_RECORD * ppQueryResultsSet OPTIONAL,
  1580. IN OUT PVOID * pReserved OPTIONAL
  1581. );
  1582. #ifdef UNICODE
  1583. #define DnsQuery DnsQuery_W
  1584. #else
  1585. #define DnsQuery DnsQuery_A
  1586. #endif
  1587. //
  1588. // Options for DnsCheckNameCollision
  1589. //
  1590. #define DNS_CHECK_AGAINST_HOST_ANY 0x00000000
  1591. #define DNS_CHECK_AGAINST_HOST_ADDRESS 0x00000001
  1592. #define DNS_CHECK_AGAINST_HOST_DOMAIN_NAME 0x00000002
  1593. DNS_STATUS WINAPI
  1594. DnsCheckNameCollision_A (
  1595. IN LPSTR pszName,
  1596. IN DWORD fOptions
  1597. );
  1598. DNS_STATUS WINAPI
  1599. DnsCheckNameCollision_UTF8 (
  1600. IN LPSTR pszName,
  1601. IN DWORD fOptions
  1602. );
  1603. DNS_STATUS WINAPI
  1604. DnsCheckNameCollision_W (
  1605. IN LPWSTR pszName,
  1606. IN DWORD fOptions
  1607. );
  1608. #ifdef UNICODE
  1609. #define DnsDnsCheckNameCollision DnsCheckNameCollision_W
  1610. #else
  1611. #define DnsDnsCheckNameCollision DnsCheckNameCollision_A
  1612. #endif
  1613. LPSTR WINAPI
  1614. DnsGetHostName_A(
  1615. VOID
  1616. );
  1617. LPSTR WINAPI
  1618. DnsGetHostName_UTF8(
  1619. VOID
  1620. );
  1621. LPWSTR WINAPI
  1622. DnsGetHostName_W(
  1623. VOID
  1624. );
  1625. #ifdef UNICODE
  1626. #define DnsGetHostName DnsGetHostName_W
  1627. #else
  1628. #define DnsGetHostName DnsGetHostName_A
  1629. #endif
  1630. LPSTR WINAPI
  1631. DnsGetPrimaryDomainName_A(
  1632. VOID
  1633. );
  1634. LPSTR WINAPI
  1635. DnsGetPrimaryDomainName_UTF8(
  1636. VOID
  1637. );
  1638. LPWSTR WINAPI
  1639. DnsGetPrimaryDomainName_W(
  1640. VOID
  1641. );
  1642. #ifdef UNICODE
  1643. #define DnsGetPrimaryDomainName DnsGetPrimaryDomainName_W
  1644. #else
  1645. #define DnsGetPrimaryDomainName DnsGetPrimaryDomainName_A
  1646. #endif
  1647. //
  1648. // DNS Update API for DHCP client
  1649. //
  1650. typedef struct _REGISTER_HOST_ENTRY
  1651. {
  1652. union
  1653. {
  1654. IP_ADDRESS ipAddr;
  1655. IPV6_ADDRESS ipV6Addr;
  1656. } Addr;
  1657. DWORD dwOptions;
  1658. }
  1659. REGISTER_HOST_ENTRY, *PREGISTER_HOST_ENTRY;
  1660. //
  1661. // Options for above
  1662. //
  1663. #define REGISTER_HOST_A 0x00000001
  1664. #define REGISTER_HOST_PTR 0x00000002 // Used by DHCP server
  1665. #define REGISTER_HOST_TRANSIENT 0x00000004 // Don't use, use DYNDNS_REG_RAS
  1666. #define REGISTER_HOST_AAAA 0x00000008
  1667. #define REGISTER_HOST_RESERVED 0x80000000 // Not used
  1668. #define DYNDNS_REG_FWD 0x0
  1669. #define DYNDNS_REG_PTR 0x8
  1670. #define DYNDNS_REG_RAS 0x10
  1671. #define DYNDNS_DEL_ENTRY 0x20
  1672. typedef struct _REGISTER_HOST_STATUS
  1673. {
  1674. HANDLE hDoneEvent;
  1675. DWORD dwStatus;
  1676. }
  1677. REGISTER_HOST_STATUS, *PREGISTER_HOST_STATUS;
  1678. DNS_STATUS
  1679. WINAPI
  1680. DnsAsyncRegisterInit(
  1681. LPSTR lpstrRootRegKey
  1682. );
  1683. DNS_STATUS
  1684. WINAPI
  1685. DnsAsyncRegisterTerm(
  1686. VOID
  1687. );
  1688. DNS_STATUS WINAPI
  1689. DnsRemoveRegistrations(
  1690. VOID
  1691. );
  1692. DNS_STATUS
  1693. WINAPI
  1694. DnsAsyncRegisterHostAddrs_W(
  1695. IN LPWSTR lpstrAdapterName,
  1696. IN LPWSTR lpstrHostName,
  1697. IN PREGISTER_HOST_ENTRY pHostAddrs,
  1698. IN DWORD dwHostAddrCount,
  1699. IN PIP_ADDRESS pipDnsServerList,
  1700. IN DWORD dwDnsServerCount,
  1701. IN LPWSTR lpstrDomainName,
  1702. IN PREGISTER_HOST_STATUS pRegisterStatus,
  1703. IN DWORD dwTTL,
  1704. IN DWORD dwFlags
  1705. );
  1706. DNS_STATUS
  1707. WINAPI
  1708. DnsAsyncRegisterHostAddrs_UTF8(
  1709. IN LPSTR lpstrAdapterName,
  1710. IN LPSTR lpstrHostName,
  1711. IN PREGISTER_HOST_ENTRY pHostAddrs,
  1712. IN DWORD dwHostAddrCount,
  1713. IN PIP_ADDRESS pipDnsServerList,
  1714. IN DWORD dwDnsServerCount,
  1715. IN LPSTR lpstrDomainName,
  1716. IN PREGISTER_HOST_STATUS pRegisterStatus,
  1717. IN DWORD dwTTL,
  1718. IN DWORD dwFlags
  1719. );
  1720. DNS_STATUS
  1721. WINAPI
  1722. DnsAsyncRegisterHostAddrs_A(
  1723. IN LPSTR lpstrAdapterName,
  1724. IN LPSTR lpstrHostName,
  1725. IN PREGISTER_HOST_ENTRY pHostAddrs,
  1726. IN DWORD dwHostAddrCount,
  1727. IN PIP_ADDRESS pipDnsServerList,
  1728. IN DWORD dwDnsServerCount,
  1729. IN LPSTR lpstrDomainName,
  1730. IN PREGISTER_HOST_STATUS pRegisterStatus,
  1731. IN DWORD dwTTL,
  1732. IN DWORD dwFlags
  1733. );
  1734. #ifdef UNICODE
  1735. #define DnsAsyncRegisterHostAddrs DnsAsyncRegisterHostAddrs_W
  1736. #else
  1737. #define DnsAsyncRegisterHostAddrs DnsAsyncRegisterHostAddrs_A
  1738. #endif
  1739. //
  1740. // DNS Update API for DHCP server.
  1741. //
  1742. //
  1743. // Call back function. DHCP Server will pass a function to
  1744. // DnsDhcpRegisterHostName and this will be called on successful
  1745. // or unsuccessful completion of the task
  1746. // If we have a condition like server down/try again later etc we
  1747. // won't respond until we have an authoritative answer.
  1748. //
  1749. typedef VOID(*DHCP_CALLBACK_FN)(DWORD dwStatus, LPVOID pvData);
  1750. //
  1751. // Callback return codes
  1752. //
  1753. #define DNSDHCP_SUCCESS 0x0
  1754. #define DNSDHCP_FWD_FAILED 0x1
  1755. #define DNSDHCP_SUPERCEDED 0x2
  1756. #define DNSDHCP_FAILURE (DWORD)-1 //reverse failed
  1757. #define DYNDNS_DELETE_ENTRY 0x1
  1758. #define DYNDNS_ADD_ENTRY 0x2
  1759. #define DYNDNS_REG_FORWARD 0x4
  1760. DNS_STATUS
  1761. WINAPI
  1762. DnsDhcpSrvRegisterInit(
  1763. VOID
  1764. );
  1765. DNS_STATUS
  1766. WINAPI
  1767. DnsDhcpSrvRegisterTerm(
  1768. VOID
  1769. );
  1770. DNS_STATUS
  1771. WINAPI
  1772. DnsDhcpSrvRegisterHostName_A(
  1773. IN REGISTER_HOST_ENTRY HostAddr,
  1774. IN LPSTR pszName,
  1775. IN DWORD dwTTL,
  1776. IN DWORD dwFlags,
  1777. IN DHCP_CALLBACK_FN pfnDhcpCallBack,
  1778. IN PVOID pvData,
  1779. IN PIP_ADDRESS pipDnsServerList OPTIONAL,
  1780. IN DWORD dwDnsServerCount
  1781. );
  1782. DNS_STATUS
  1783. WINAPI
  1784. DnsDhcpSrvRegisterHostName_UTF8(
  1785. IN REGISTER_HOST_ENTRY HostAddr,
  1786. IN LPSTR pszName,
  1787. IN DWORD dwTTL,
  1788. IN DWORD dwFlags,
  1789. IN DHCP_CALLBACK_FN pfnDhcpCallBack,
  1790. IN PVOID pvData,
  1791. IN PIP_ADDRESS pipDnsServerList OPTIONAL,
  1792. IN DWORD dwDnsServerCount
  1793. );
  1794. DNS_STATUS
  1795. WINAPI
  1796. DnsDhcpSrvRegisterHostName_W(
  1797. IN REGISTER_HOST_ENTRY HostAddr,
  1798. IN LPWSTR pszName,
  1799. IN DWORD dwTTL,
  1800. IN DWORD dwFlags,
  1801. IN DHCP_CALLBACK_FN pfnDhcpCallBack,
  1802. IN PVOID pvData,
  1803. IN PIP_ADDRESS pipDnsServerList OPTIONAL,
  1804. IN DWORD dwDnsServerCount
  1805. );
  1806. #define DnsDhcpSrvRegisterHostName DnsDhcpSrvRegisterHostName_A
  1807. #define RETRY_TIME_SERVER_FAILURE 5*60 // 5 minutes
  1808. #define RETRY_TIME_TRY_AGAIN_LATER 5*60 // 5 minutes
  1809. #define RETRY_TIME_TIMEOUT 5*60 // 5 minutes
  1810. #define RETRY_TIME_MAX 10*60 // back off to 10 mins if
  1811. // repeated failures occur
  1812. //
  1813. // Memory allocation
  1814. //
  1815. // Many dnsapi.dll routines allocate memory.
  1816. // This memory allocation defaults to routines that use:
  1817. // - LocalAlloc,
  1818. // - LocalReAlloc,
  1819. // - LocalFree.
  1820. // If you desire alternative memory allocation mechanisms, use this
  1821. // function to override the DNS API defaults. All memory returned by dnsapi.dll
  1822. // can then be freed with the specified free function.
  1823. //
  1824. typedef PVOID (* DNS_ALLOC_FUNCTION)();
  1825. typedef PVOID (* DNS_REALLOC_FUNCTION)();
  1826. typedef VOID (* DNS_FREE_FUNCTION)();
  1827. VOID
  1828. DnsApiHeapReset(
  1829. IN DNS_ALLOC_FUNCTION pAlloc,
  1830. IN DNS_REALLOC_FUNCTION pRealloc,
  1831. IN DNS_FREE_FUNCTION pFree
  1832. );
  1833. //
  1834. // Modules using DNSAPI memory should use these routines if
  1835. // they are capable of being called by a process that resets
  1836. // the dnsapi.dll heap. (Example: the DNS server.)
  1837. //
  1838. PVOID
  1839. DnsApiAlloc(
  1840. IN INT iSize
  1841. );
  1842. PVOID
  1843. DnsApiRealloc(
  1844. IN OUT PVOID pMem,
  1845. IN INT iSize
  1846. );
  1847. VOID
  1848. DnsApiFree(
  1849. IN OUT PVOID pMem
  1850. );
  1851. //
  1852. // String utilities (string.c)
  1853. //
  1854. // Note some of these require memory allocation, see note
  1855. // on memory allocation below.
  1856. //
  1857. #define DNS_ALLOW_RFC_NAMES_ONLY (0)
  1858. #define DNS_ALLOW_NONRFC_NAMES (0x00000001)
  1859. #define DNS_ALLOW_MULTIBYTE_NAMES (0x00000002)
  1860. #define DNS_ALLOW_ALL_NAMES (0x00000003)
  1861. LPSTR
  1862. DnsCreateStringCopy(
  1863. IN PCHAR pchString,
  1864. IN DWORD cchString
  1865. );
  1866. DWORD
  1867. DnsGetBufferLengthForStringCopy(
  1868. IN PCHAR pchString,
  1869. IN DWORD cchString,
  1870. IN BOOL fUnicodeIn,
  1871. IN BOOL fUnicodeOut
  1872. );
  1873. PVOID
  1874. DnsCopyStringEx(
  1875. OUT PBYTE pBuffer,
  1876. IN PCHAR pchString,
  1877. IN DWORD cchString,
  1878. IN BOOL fUnicodeIn,
  1879. IN BOOL fUnicodeOut
  1880. );
  1881. PVOID
  1882. DnsStringCopyAllocateEx(
  1883. IN PCHAR pchString,
  1884. IN DWORD cchString,
  1885. IN BOOL fUnicodeIn,
  1886. IN BOOL fUnicodeOut
  1887. );
  1888. PCHAR
  1889. DnsWriteReverseNameStringForIpAddress(
  1890. OUT PCHAR pBuffer,
  1891. IN IP_ADDRESS ipAddress
  1892. );
  1893. PCHAR
  1894. DnsCreateReverseNameStringForIpAddress(
  1895. IN IP_ADDRESS ipAddress
  1896. );
  1897. //
  1898. // Name validation
  1899. //
  1900. typedef enum _DNS_NAME_FORMAT
  1901. {
  1902. DnsNameDomain,
  1903. DnsNameDomainLabel,
  1904. DnsNameHostnameFull,
  1905. DnsNameHostnameLabel,
  1906. DnsNameWildcard,
  1907. DnsNameSrvRecord
  1908. }
  1909. DNS_NAME_FORMAT;
  1910. DNS_STATUS
  1911. DnsValidateName_UTF8(
  1912. IN LPCSTR pszName,
  1913. IN DNS_NAME_FORMAT Format
  1914. );
  1915. DNS_STATUS
  1916. DnsValidateName_W(
  1917. IN LPCWSTR pwszName,
  1918. IN DNS_NAME_FORMAT Format
  1919. );
  1920. DNS_STATUS
  1921. DnsValidateName_A(
  1922. IN LPCSTR pszName,
  1923. IN DNS_NAME_FORMAT Format
  1924. );
  1925. #ifdef UNICODE
  1926. #define DnsValidateName(p,f) DnsValidateName_W( (p), (f) )
  1927. #else
  1928. #define DnsValidateName(p,f) DnsValidateName_A( (p), (f) )
  1929. #endif
  1930. //
  1931. // Macro away old routines
  1932. //
  1933. #define DnsValidateDnsName_UTF8(pname) \
  1934. DnsValidateName_UTF8( (pname), DnsNameDomain )
  1935. #define DnsValidateDnsName_W(pname) \
  1936. DnsValidateName_W( (pname), DnsNameDomain )
  1937. //
  1938. // Relational name compare result
  1939. //
  1940. typedef enum
  1941. {
  1942. DNS_RELATE_NEQ, // NOT EQUAL: name's in different name space.
  1943. DNS_RELATE_EQL, // EQUAL: name's are identical DNS names
  1944. DNS_RELATE_LGT, // LEFT GREATER THAN: left name is parent (contains) to right name
  1945. DNS_RELATE_RGT, // RIGHT GREATER THAN: right name is parent (contains) to left name
  1946. DNS_RELATE_INVALID // INVALID STATE: accompanied with DNS_STATUS return code
  1947. } DNS_RELATE_STATUS, *PDNS_RELATE_STATUS;
  1948. DNS_STATUS
  1949. DnsRelationalCompare_UTF8(
  1950. IN LPCSTR pszLeftName,
  1951. IN LPCSTR pszRightName,
  1952. IN DWORD dwReserved,
  1953. IN OUT DNS_RELATE_STATUS *pRelation
  1954. );
  1955. DNS_STATUS
  1956. DnsRelationalCompare_W(
  1957. IN LPCWSTR pszLeftName,
  1958. IN LPCWSTR pszRightName,
  1959. IN DWORD dwReserved,
  1960. IN OUT DNS_RELATE_STATUS *pRelation
  1961. );
  1962. DNS_STATUS
  1963. DnsValidateDnsString_UTF8(
  1964. IN LPCSTR pszName
  1965. );
  1966. DNS_STATUS
  1967. DnsValidateDnsString_W(
  1968. IN LPCWSTR pszName
  1969. );
  1970. LPSTR
  1971. DnsCreateStandardDnsNameCopy(
  1972. IN PCHAR pchName,
  1973. IN DWORD cchName,
  1974. IN DWORD dwFlag
  1975. );
  1976. DWORD
  1977. DnsDowncaseDnsNameLabel(
  1978. OUT PCHAR pchResult,
  1979. IN PCHAR pchLabel,
  1980. IN DWORD cchLabel,
  1981. IN DWORD dwFlags
  1982. );
  1983. DWORD
  1984. _fastcall
  1985. DnsUnicodeToUtf8(
  1986. IN PWCHAR pwUnicode,
  1987. IN DWORD cchUnicode,
  1988. OUT PCHAR pchResult,
  1989. IN DWORD cchResult
  1990. );
  1991. DWORD
  1992. _fastcall
  1993. DnsUtf8ToUnicode(
  1994. IN PCHAR pchUtf8,
  1995. IN DWORD cchUtf8,
  1996. OUT PWCHAR pwResult,
  1997. IN DWORD cwResult
  1998. );
  1999. DNS_STATUS
  2000. DnsValidateUtf8Byte(
  2001. IN BYTE chUtf8,
  2002. IN OUT PDWORD pdwTrailCount
  2003. );
  2004. //
  2005. // Routines for NT services to call to get a Service Control Manager
  2006. // control message, (i.e. SERVICE_CONTROL_PARAMCHANGE - 0x00000006, etc.), in
  2007. // the event of a PnP change that affects DNS related data.
  2008. //
  2009. BOOL WINAPI
  2010. DnsServiceNotificationRegister_W (
  2011. IN LPWSTR pszServiceName,
  2012. IN DWORD dwControl
  2013. );
  2014. BOOL WINAPI
  2015. DnsServiceNotificationRegister_UTF8 (
  2016. IN LPSTR pszServiceName,
  2017. IN DWORD dwControl
  2018. );
  2019. BOOL WINAPI
  2020. DnsServiceNotificationRegister_A (
  2021. IN LPSTR pszServiceName,
  2022. IN DWORD dwControl
  2023. );
  2024. #ifdef UNICODE
  2025. #define DnsServiceNotificationRegister DnsServiceNotificationRegister_W
  2026. #else
  2027. #define DnsServiceNotificationRegister DnsServiceNotificationRegister_A
  2028. #endif
  2029. BOOL WINAPI
  2030. DnsServiceNotificationDeregister_W (
  2031. IN LPWSTR pszServiceName
  2032. );
  2033. BOOL WINAPI
  2034. DnsServiceNotificationDeregister_UTF8 (
  2035. IN LPSTR pszServiceName
  2036. );
  2037. BOOL WINAPI
  2038. DnsServiceNotificationDeregister_A (
  2039. IN LPSTR pszServiceName
  2040. );
  2041. #ifdef UNICODE
  2042. #define DnsServiceNotificationDeregister DnsServiceNotificationDeregister_W
  2043. #else
  2044. #define DnsServiceNotificationDeregister DnsServiceNotificationDeregister_A
  2045. #endif
  2046. //
  2047. // Routines to clear all cached entries in the DNS Resolver Cache, this is
  2048. // called by ipconfig /flushdns, and add record sets to the cache.
  2049. //
  2050. BOOL WINAPI
  2051. DnsFlushResolverCache (
  2052. VOID
  2053. );
  2054. BOOL WINAPI
  2055. DnsFlushResolverCacheEntry_W (
  2056. IN LPWSTR pszName
  2057. );
  2058. BOOL WINAPI
  2059. DnsFlushResolverCacheEntry_UTF8 (
  2060. IN LPSTR pszName
  2061. );
  2062. BOOL WINAPI
  2063. DnsFlushResolverCacheEntry_A (
  2064. IN LPSTR pszName
  2065. );
  2066. #ifdef UNICODE
  2067. #define DnsFlushResolverCacheEntry DnsFlushResolverCacheEntry_W
  2068. #else
  2069. #define DnsFlushResolverCacheEntry DnsFlushResolverCacheEntry_A
  2070. #endif
  2071. DNS_STATUS WINAPI
  2072. DnsCacheRecordSet_W(
  2073. IN LPWSTR lpstrName,
  2074. IN WORD wType,
  2075. IN DWORD fOptions,
  2076. IN OUT PDNS_RECORD pRRSet
  2077. );
  2078. //
  2079. // Routines to enable or disable B-Node resolver service listening thread
  2080. //
  2081. VOID WINAPI
  2082. DnsEnableBNodeResolverThread (
  2083. VOID
  2084. );
  2085. VOID WINAPI
  2086. DnsDisableBNodeResolverThread (
  2087. VOID
  2088. );
  2089. //
  2090. // Routines to enable or disable dynamic DNS registrations on local machine
  2091. //
  2092. VOID WINAPI
  2093. DnsEnableDynamicRegistration (
  2094. LPWSTR szAdapterName OPTIONAL // If NULL, enables DDNS in general
  2095. );
  2096. VOID WINAPI
  2097. DnsDisableDynamicRegistration (
  2098. LPWSTR szAdapterName OPTIONAL // If NULL, disables DDNS in general
  2099. );
  2100. BOOL
  2101. DnsIsDynamicRegistrationEnabled (
  2102. LPWSTR szAdapterName OPTIONAL // If NULL, tells whether system has
  2103. ); // DDNS enabled.
  2104. //
  2105. // Routines to enable or disable dynamic DNS registration of a given
  2106. // adapter's domain name on the local machine
  2107. //
  2108. VOID WINAPI
  2109. DnsEnableAdapterDomainNameRegistration (
  2110. LPWSTR szAdapterName
  2111. );
  2112. VOID WINAPI
  2113. DnsDisableAdapterDomainNameRegistration (
  2114. LPWSTR szAdapterName
  2115. );
  2116. BOOL
  2117. DnsIsAdapterDomainNameRegistrationEnabled (
  2118. LPWSTR szAdapterName
  2119. );
  2120. //
  2121. // Routines to write a DNS Query packet request question in a buffer and
  2122. // convert response packet buffer to DNS_RECORD structure list.
  2123. //
  2124. typedef struct _DNS_MESSAGE_BUFFER
  2125. {
  2126. DNS_HEADER MessageHead;
  2127. CHAR MessageBody[1];
  2128. }
  2129. DNS_MESSAGE_BUFFER, *PDNS_MESSAGE_BUFFER;
  2130. BOOL WINAPI
  2131. DnsWriteQuestionToBuffer_W (
  2132. IN OUT PDNS_MESSAGE_BUFFER pDnsBuffer,
  2133. IN OUT LPDWORD pdwBufferSize,
  2134. IN LPWSTR pszName,
  2135. IN WORD wType,
  2136. IN WORD Xid,
  2137. IN BOOL fRecursionDesired
  2138. );
  2139. BOOL WINAPI
  2140. DnsWriteQuestionToBuffer_UTF8 (
  2141. IN OUT PDNS_MESSAGE_BUFFER pDnsBuffer,
  2142. IN OUT LPDWORD pdwBufferSize,
  2143. IN LPSTR pszName,
  2144. IN WORD wType,
  2145. IN WORD Xid,
  2146. IN BOOL fRecursionDesired
  2147. );
  2148. DNS_STATUS WINAPI
  2149. DnsExtractRecordsFromMessage_W (
  2150. IN PDNS_MESSAGE_BUFFER pDnsBuffer,
  2151. IN WORD wMessageLength,
  2152. OUT PDNS_RECORD * ppRecord
  2153. );
  2154. DNS_STATUS WINAPI
  2155. DnsExtractRecordsFromMessage_UTF8 (
  2156. IN PDNS_MESSAGE_BUFFER pDnsBuffer,
  2157. IN WORD wMessageLength,
  2158. OUT PDNS_RECORD * ppRecord
  2159. );
  2160. //
  2161. // Routine to read the contents of the DNS Resolver Cache. The resulting
  2162. // table contains a list of record names and types stored in the cache.
  2163. // Each of these name/type records can be queried with DnsQuery with the
  2164. // option DNS_QUERY_CACHE_ONLY.
  2165. //
  2166. typedef struct _DNS_CACHE_TABLE_
  2167. {
  2168. struct _DNS_CACHE_TABLE_ * pNext;
  2169. LPWSTR Name;
  2170. WORD Type1;
  2171. WORD Type2;
  2172. WORD Type3;
  2173. }
  2174. DNS_CACHE_TABLE, *PDNS_CACHE_TABLE;
  2175. BOOL WINAPI
  2176. DnsGetCacheDataTable (
  2177. OUT PDNS_CACHE_TABLE * pTable
  2178. );
  2179. //
  2180. // Backward compatibility
  2181. //
  2182. // Previously exposed functions now macroed to new functions.
  2183. // Eventually need to clean this stuff out of build or
  2184. // separate these defs from public headers
  2185. //
  2186. #define DNSBACKCOMPAT 1
  2187. #ifdef DNSBACKCOMPAT
  2188. #ifdef UNICODE
  2189. #define DnsCompareName(p1,p2) DnsNameCompare_W( (p1), (p2) )
  2190. #else
  2191. #define DnsCompareName(p1,p2) DnsNameCompare( (p1), (p2) )
  2192. #endif
  2193. #define DnsCompareName_W(p1,p2) DnsNameCompare_W( (p1), (p2) )
  2194. #define DnsCompareName_A(p1,p2) DnsNameCompare( (p1), (p2) )
  2195. #ifdef UNICODE
  2196. #define DnsCopyRR(pRR) DnsRecordCopy( pRR, TRUE )
  2197. #else
  2198. #define DnsCopyRR(pRR) DnsRecordCopy( pRR, FALSE )
  2199. #endif
  2200. #ifdef UNICODE
  2201. #define DnsCopyRRSet(pRRSet) DnsRecordSetCopy( pRRSet, TRUE )
  2202. #else
  2203. #define DnsCopyRRSet(pRRSet) DnsRecordSetCopy( pRRSet, FALSE )
  2204. #endif
  2205. // Async registration only from DHCP client.
  2206. // Once it is cleanedup, these can be deleted.
  2207. #define DnsMHAsyncRegisterInit(a) DnsAsyncRegisterInit(a)
  2208. #define DnsMHAsyncRegisterTerm() DnsAsyncRegisterTerm()
  2209. #define DnsMHRemoveRegistrations() DnsRemoveRegistrations()
  2210. #define DnsMHAsyncRegisterHostAddrs_A(a,b,c,d,e,f,g,h,i,j) \
  2211. DnsAsyncRegisterHostAddrs_A(a,b,c,d,e,f,g,h,i,j)
  2212. #define DnsMHAsyncRegisterHostAddrs_W(a,b,c,d,e,f,g,h,i,j) \
  2213. DnsAsyncRegisterHostAddrs_W(a,b,c,d,e,f,g,h,i,j)
  2214. #define DnsMHAsyncRegisterHostAddrs_UTF8(a,b,c,d,e,f,g,h,i,j) \
  2215. DnsAsyncRegisterHostAddrs_UTF8(a,b,c,d,e,f,g,h,i,j)
  2216. // cleanup after clean build
  2217. #define DnsNameCompare(a,b) \
  2218. DnsNameCompare_A((a),(b))
  2219. #endif DNSBACKCOMPAT
  2220. #ifdef __cplusplus
  2221. }
  2222. #endif // __cplusplus
  2223. #endif // _DNSAPI_INCLUDED_