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.

1705 lines
40 KiB

  1. /*++
  2. Copyright (c) 1996-2000 Microsoft Corporation
  3. Module Name:
  4. windns.h
  5. Abstract:
  6. Domain Name System (DNS)
  7. DNS definitions and DNS API.
  8. Author:
  9. Jim Gilroy (jamesg) December 7, 1996
  10. Glenn Curtis (glennc) January 22, 1997
  11. Revision History:
  12. --*/
  13. #ifndef _WINDNS_INCLUDED_
  14. #define _WINDNS_INCLUDED_
  15. #ifdef __cplusplus
  16. extern "C"
  17. {
  18. #endif // __cplusplus
  19. //
  20. // Define QWORD -- not yet defined globally
  21. //
  22. typedef unsigned __int64 QWORD;
  23. //
  24. // DNS public types
  25. //
  26. typedef LONG DNS_STATUS, *PDNS_STATUS;
  27. //
  28. // IP Address
  29. //
  30. typedef DWORD IP4_ADDRESS, *PIP4_ADDRESS;
  31. #define SIZEOF_IP4_ADDRESS (4)
  32. #define IP4_ADDRESS_STRING_LENGTH (15)
  33. #define IP4_ADDRESS_STRING_BUFFER_LENGTH (16)
  34. //
  35. // IP Address Array type
  36. //
  37. typedef struct _IP4_ARRAY
  38. {
  39. DWORD AddrCount;
  40. #ifdef MIDL_PASS
  41. [size_is( AddrCount )] IP4_ADDRESS AddrArray[];
  42. #else
  43. IP4_ADDRESS AddrArray[1];
  44. #endif
  45. }
  46. IP4_ARRAY, *PIP4_ARRAY;
  47. //
  48. // IPv6 Address
  49. //
  50. #ifdef MIDL_PASS
  51. typedef struct
  52. {
  53. #ifdef _WIN64
  54. QWORD IP6Qword[2];
  55. #else
  56. DWORD IP6Dword[4];
  57. #endif
  58. }
  59. IP6_ADDRESS, *PIP6_ADDRESS;
  60. #else
  61. typedef union
  62. {
  63. #ifdef _WIN64
  64. QWORD IP6Qword[2];
  65. #endif
  66. DWORD IP6Dword[4];
  67. WORD IP6Word[8];
  68. BYTE IP6Byte[16];
  69. #ifdef IN6_ADDR
  70. IN6_ADDR In6;
  71. #endif
  72. }
  73. IP6_ADDRESS, *PIP6_ADDRESS;
  74. #endif
  75. // Backward compatibility
  76. typedef IP6_ADDRESS DNS_IP6_ADDRESS, *PDNS_IP6_ADDRESS;
  77. //
  78. // IP6 string max is 45 bytes
  79. // - 6 WORDs in colon+hex (5 chars)
  80. // - last DWORD as IP4 (15 chars)
  81. //
  82. #undef IP6_ADDRESS_STRING_LENGTH
  83. #define IP6_ADDRESS_STRING_LENGTH (47)
  84. #define IP6_ADDRESS_STRING_BUFFER_LENGTH (48)
  85. // backcompat
  86. #define IPV6_ADDRESS_STRING_LENGTH IP6_ADDRESS_STRING_LENGTH
  87. //
  88. // Inline byte flipping -- can be done in registers
  89. //
  90. #define INLINE_WORD_FLIP(out, in) \
  91. { \
  92. WORD _in = (in); \
  93. (out) = (_in << 8) | (_in >> 8); \
  94. }
  95. #define INLINE_HTONS(out, in) INLINE_WORD_FLIP(out, in)
  96. #define INLINE_NTOHS(out, in) INLINE_WORD_FLIP(out, in)
  97. #define INLINE_DWORD_FLIP(out, in) \
  98. { \
  99. DWORD _in = (in); \
  100. (out) = ((_in << 8) & 0x00ff0000) | \
  101. (_in << 24) | \
  102. ((_in >> 8) & 0x0000ff00) | \
  103. (_in >> 24); \
  104. }
  105. #define INLINE_NTOHL(out, in) INLINE_DWORD_FLIP(out, in)
  106. #define INLINE_HTONL(out, in) INLINE_DWORD_FLIP(out, in)
  107. //
  108. // Inline byte flip and write to packet (unaligned)
  109. //
  110. #define INLINE_WRITE_FLIPPED_WORD( pout, in ) \
  111. INLINE_WORD_FLIP( *((UNALIGNED WORD *)(pout)), in )
  112. #define INLINE_WRITE_FLIPPED_DWORD( pout, in ) \
  113. INLINE_DWORD_FLIP( *((UNALIGNED DWORD *)(pout)), in )
  114. //
  115. // Basic DNS definitions
  116. //
  117. //
  118. // DNS port for both UDP and TCP is 53.
  119. //
  120. #define DNS_PORT_HOST_ORDER (0x0035) // port 53
  121. #define DNS_PORT_NET_ORDER (0x3500)
  122. //
  123. // DNS UDP packets no more than 512 bytes
  124. //
  125. #define DNS_RFC_MAX_UDP_PACKET_LENGTH (512)
  126. //
  127. // DNS Names limited to 255, 63 in any one label
  128. //
  129. #define DNS_MAX_NAME_LENGTH (255)
  130. #define DNS_MAX_LABEL_LENGTH (63)
  131. #define DNS_MAX_NAME_BUFFER_LENGTH (256)
  132. #define DNS_MAX_LABEL_BUFFER_LENGTH (64)
  133. //
  134. // Reverse lookup domain names
  135. //
  136. #define DNS_IP4_REVERSE_DOMAIN_STRING ("in-addr.arpa.")
  137. #define DNS_MAX_IP4_REVERSE_NAME_LENGTH \
  138. (IP_ADDRESS_STRING_LENGTH+1+sizeof(DNS_IP4_REVERSE_DOMAIN_STRING))
  139. #define DNS_MAX_IP4_REVERSE_NAME_BUFFER_LENGTH \
  140. (DNS_MAX_IP4_REVERSE_NAME_LENGTH + 1)
  141. #define DNS_IP6_REVERSE_DOMAIN_STRING ("ip6.int.")
  142. #define DNS_MAX_IP6_REVERSE_NAME_LENGTH \
  143. (64+sizeof(DNS_IP6_REVERSE_DOMAIN_STRING))
  144. #define DNS_MAX_IP6_REVERSE_NAME_BUFFER_LENGTH \
  145. (DNS_MAX_IP6_REVERSE_NAME_LENGTH + 1)
  146. // Combined
  147. #define DNS_MAX_REVERSE_NAME_LENGTH \
  148. DNS_MAX_IP6_REVERSE_NAME_LENGTH \
  149. #define DNS_MAX_REVERSE_NAME_BUFFER_LENGTH \
  150. DNS_MAX_IP6_REVERSE_NAME_BUFFER_LENGTH
  151. //
  152. // DNS Text string limited by size representable
  153. // in a single byte length field
  154. #define DNS_MAX_TEXT_STRING_LENGTH (255)
  155. //
  156. // DNS On-The-Wire Structures
  157. //
  158. #pragma pack(1)
  159. //
  160. // DNS Message Header
  161. //
  162. typedef struct _DNS_HEADER
  163. {
  164. WORD Xid;
  165. BYTE RecursionDesired : 1;
  166. BYTE Truncation : 1;
  167. BYTE Authoritative : 1;
  168. BYTE Opcode : 4;
  169. BYTE IsResponse : 1;
  170. BYTE ResponseCode : 4;
  171. BYTE Reserved : 3;
  172. BYTE RecursionAvailable : 1;
  173. WORD QuestionCount;
  174. WORD AnswerCount;
  175. WORD NameServerCount;
  176. WORD AdditionalCount;
  177. }
  178. DNS_HEADER, *PDNS_HEADER;
  179. //
  180. // Flags as WORD
  181. //
  182. #define DNS_HEADER_FLAGS(pHead) ( *((PWORD)(pHead)+1) )
  183. //
  184. // Byte flip DNS header to\from host order.
  185. //
  186. // Note that this does NOT flip flags, as definition above defines
  187. // flags as individual bytes for direct access to net byte order.
  188. //
  189. #define DNS_BYTE_FLIP_HEADER_COUNTS(pHeader) \
  190. { \
  191. PDNS_HEADER _head = (pHeader); \
  192. INLINE_HTONS(_head->Xid, _head->Xid ); \
  193. INLINE_HTONS(_head->QuestionCount, _head->QuestionCount ); \
  194. INLINE_HTONS(_head->AnswerCount, _head->AnswerCount ); \
  195. INLINE_HTONS(_head->NameServerCount,_head->NameServerCount ); \
  196. INLINE_HTONS(_head->AdditionalCount,_head->AdditionalCount ); \
  197. }
  198. //
  199. // Question name follows header
  200. //
  201. #define DNS_OFFSET_TO_QUESTION_NAME sizeof(DNS_HEADER)
  202. //
  203. // Question immediately follows header so compressed question name
  204. // 0xC000 | sizeof(DNS_HEADER)
  205. #define DNS_COMPRESSED_QUESTION_NAME (0xC00C)
  206. //
  207. // Packet extraction macros
  208. //
  209. #define DNS_QUESTION_NAME_FROM_HEADER( _pHeader_ ) \
  210. ( (PCHAR)( (PDNS_HEADER)(_pHeader_) + 1 ) )
  211. #define DNS_ANSWER_FROM_QUESTION( _pQuestion_ ) \
  212. ( (PCHAR)( (PDNS_QUESTION)(_pQuestion_) + 1 ) )
  213. //
  214. // DNS Question
  215. //
  216. typedef struct _DNS_WIRE_QUESTION
  217. {
  218. // Preceded by question name
  219. WORD QuestionType;
  220. WORD QuestionClass;
  221. }
  222. DNS_WIRE_QUESTION, *PDNS_WIRE_QUESTION;
  223. //
  224. // DNS Resource Record
  225. //
  226. typedef struct _DNS_WIRE_RECORD
  227. {
  228. // Preceded by record owner name
  229. WORD RecordType;
  230. WORD RecordClass;
  231. DWORD TimeToLive;
  232. WORD DataLength;
  233. // Followed by record data
  234. }
  235. DNS_WIRE_RECORD, *PDNS_WIRE_RECORD;
  236. #pragma pack()
  237. //
  238. // DNS Query Types
  239. //
  240. #define DNS_OPCODE_QUERY 0 // Query
  241. #define DNS_OPCODE_IQUERY 1 // Obsolete: IP to name
  242. #define DNS_OPCODE_SERVER_STATUS 2 // Obsolete: DNS ping
  243. #define DNS_OPCODE_UNKNOWN 3 // Unknown
  244. #define DNS_OPCODE_NOTIFY 4 // Notify
  245. #define DNS_OPCODE_UPDATE 5 // Dynamic Update
  246. //
  247. // DNS response codes.
  248. //
  249. // Sent in the "ResponseCode" field of a DNS_HEADER.
  250. //
  251. #define DNS_RCODE_NOERROR 0
  252. #define DNS_RCODE_FORMERR 1 // Format error
  253. #define DNS_RCODE_SERVFAIL 2 // Server failure
  254. #define DNS_RCODE_NXDOMAIN 3 // Name error
  255. #define DNS_RCODE_NOTIMPL 4 // Not implemented
  256. #define DNS_RCODE_REFUSED 5 // Refused
  257. #define DNS_RCODE_YXDOMAIN 6 // Domain name should not exist
  258. #define DNS_RCODE_YXRRSET 7 // RR set should not exist
  259. #define DNS_RCODE_NXRRSET 8 // RR set does not exist
  260. #define DNS_RCODE_NOTAUTH 9 // Not authoritative for zone
  261. #define DNS_RCODE_NOTZONE 10 // Name is not zone
  262. #define DNS_RCODE_MAX 15
  263. //
  264. // Extended RCODEs
  265. //
  266. #define DNS_RCODE_BADVERS 16 // Bad EDNS version
  267. #define DNS_RCODE_BADSIG 16 // Bad signature
  268. #define DNS_RCODE_BADKEY 17 // Bad key
  269. #define DNS_RCODE_BADTIME 18 // Bad timestamp
  270. //
  271. // Mappings to friendly names
  272. //
  273. #define DNS_RCODE_NO_ERROR DNS_RCODE_NOERROR
  274. #define DNS_RCODE_FORMAT_ERROR DNS_RCODE_FORMERR
  275. #define DNS_RCODE_SERVER_FAILURE DNS_RCODE_SERVFAIL
  276. #define DNS_RCODE_NAME_ERROR DNS_RCODE_NXDOMAIN
  277. #define DNS_RCODE_NOT_IMPLEMENTED DNS_RCODE_NOTIMPL
  278. //
  279. // DNS Classes
  280. //
  281. // Classes are on the wire as WORDs.
  282. //
  283. // _CLASS_ defines in host order.
  284. // _RCLASS_ defines in net byte order.
  285. //
  286. // Generally we'll avoid byte flip and test class in net byte order.
  287. //
  288. #define DNS_CLASS_INTERNET 0x0001 // 1
  289. #define DNS_CLASS_CSNET 0x0002 // 2
  290. #define DNS_CLASS_CHAOS 0x0003 // 3
  291. #define DNS_CLASS_HESIOD 0x0004 // 4
  292. #define DNS_CLASS_NONE 0x00fe // 254
  293. #define DNS_CLASS_ALL 0x00ff // 255
  294. #define DNS_CLASS_ANY 0x00ff // 255
  295. #define DNS_RCLASS_INTERNET 0x0100 // 1
  296. #define DNS_RCLASS_CSNET 0x0200 // 2
  297. #define DNS_RCLASS_CHAOS 0x0300 // 3
  298. #define DNS_RCLASS_HESIOD 0x0400 // 4
  299. #define DNS_RCLASS_NONE 0xfe00 // 254
  300. #define DNS_RCLASS_ALL 0xff00 // 255
  301. #define DNS_RCLASS_ANY 0xff00 // 255
  302. //
  303. // DNS Record Types
  304. //
  305. // _TYPE_ defines are in host byte order.
  306. // _RTYPE_ defines are in net byte order.
  307. //
  308. // Generally always deal with types in host byte order as we index
  309. // resource record functions by type.
  310. //
  311. #define DNS_TYPE_ZERO 0x0000
  312. // RFC 1034/1035
  313. #define DNS_TYPE_A 0x0001 // 1
  314. #define DNS_TYPE_NS 0x0002 // 2
  315. #define DNS_TYPE_MD 0x0003 // 3
  316. #define DNS_TYPE_MF 0x0004 // 4
  317. #define DNS_TYPE_CNAME 0x0005 // 5
  318. #define DNS_TYPE_SOA 0x0006 // 6
  319. #define DNS_TYPE_MB 0x0007 // 7
  320. #define DNS_TYPE_MG 0x0008 // 8
  321. #define DNS_TYPE_MR 0x0009 // 9
  322. #define DNS_TYPE_NULL 0x000a // 10
  323. #define DNS_TYPE_WKS 0x000b // 11
  324. #define DNS_TYPE_PTR 0x000c // 12
  325. #define DNS_TYPE_HINFO 0x000d // 13
  326. #define DNS_TYPE_MINFO 0x000e // 14
  327. #define DNS_TYPE_MX 0x000f // 15
  328. #define DNS_TYPE_TEXT 0x0010 // 16
  329. // RFC 1183
  330. #define DNS_TYPE_RP 0x0011 // 17
  331. #define DNS_TYPE_AFSDB 0x0012 // 18
  332. #define DNS_TYPE_X25 0x0013 // 19
  333. #define DNS_TYPE_ISDN 0x0014 // 20
  334. #define DNS_TYPE_RT 0x0015 // 21
  335. // RFC 1348
  336. #define DNS_TYPE_NSAP 0x0016 // 22
  337. #define DNS_TYPE_NSAPPTR 0x0017 // 23
  338. // RFC 2065 (DNS security)
  339. #define DNS_TYPE_SIG 0x0018 // 24
  340. #define DNS_TYPE_KEY 0x0019 // 25
  341. // RFC 1664 (X.400 mail)
  342. #define DNS_TYPE_PX 0x001a // 26
  343. // RFC 1712 (Geographic position)
  344. #define DNS_TYPE_GPOS 0x001b // 27
  345. // RFC 1886 (IPv6 Address)
  346. #define DNS_TYPE_AAAA 0x001c // 28
  347. // RFC 1876 (Geographic location)
  348. #define DNS_TYPE_LOC 0x001d // 29
  349. // RFC 2065 (Secure negative response)
  350. #define DNS_TYPE_NXT 0x001e // 30
  351. // Patton (Endpoint Identifier)
  352. #define DNS_TYPE_EID 0x001f // 31
  353. // Patton (Nimrod Locator)
  354. #define DNS_TYPE_NIMLOC 0x0020 // 32
  355. // RFC 2052 (Service location)
  356. #define DNS_TYPE_SRV 0x0021 // 33
  357. // ATM Standard something-or-another (ATM Address)
  358. #define DNS_TYPE_ATMA 0x0022 // 34
  359. // RFC 2168 (Naming Authority Pointer)
  360. #define DNS_TYPE_NAPTR 0x0023 // 35
  361. // RFC 2230 (Key Exchanger)
  362. #define DNS_TYPE_KX 0x0024 // 36
  363. // RFC 2538 (CERT)
  364. #define DNS_TYPE_CERT 0x0025 // 37
  365. // A6 Draft (A6)
  366. #define DNS_TYPE_A6 0x0026 // 38
  367. // DNAME Draft (DNAME)
  368. #define DNS_TYPE_DNAME 0x0027 // 39
  369. // Eastlake (Kitchen Sink)
  370. #define DNS_TYPE_SINK 0x0028 // 40
  371. // RFC 2671 (EDNS OPT)
  372. #define DNS_TYPE_OPT 0x0029 // 41
  373. //
  374. // IANA Reserved
  375. //
  376. #define DNS_TYPE_UINFO 0x0064 // 100
  377. #define DNS_TYPE_UID 0x0065 // 101
  378. #define DNS_TYPE_GID 0x0066 // 102
  379. #define DNS_TYPE_UNSPEC 0x0067 // 103
  380. //
  381. // Query only types (1035, 1995)
  382. // - Crawford (ADDRS)
  383. // - TKEY draft (TKEY)
  384. // - TSIG draft (TSIG)
  385. // - RFC 1995 (IXFR)
  386. // - RFC 1035 (AXFR up)
  387. //
  388. #define DNS_TYPE_ADDRS 0x00f8 // 248
  389. #define DNS_TYPE_TKEY 0x00f9 // 249
  390. #define DNS_TYPE_TSIG 0x00fa // 250
  391. #define DNS_TYPE_IXFR 0x00fb // 251
  392. #define DNS_TYPE_AXFR 0x00fc // 252
  393. #define DNS_TYPE_MAILB 0x00fd // 253
  394. #define DNS_TYPE_MAILA 0x00fe // 254
  395. #define DNS_TYPE_ALL 0x00ff // 255
  396. #define DNS_TYPE_ANY 0x00ff // 255
  397. //
  398. // Temp Microsoft types -- use until get IANA approval for real type
  399. //
  400. #define DNS_TYPE_WINS 0xff01 // 64K - 255
  401. #define DNS_TYPE_WINSR 0xff02 // 64K - 254
  402. #define DNS_TYPE_NBSTAT (DNS_TYPE_WINSR)
  403. //
  404. // DNS Record Types -- Net Byte Order
  405. //
  406. #define DNS_RTYPE_A 0x0100 // 1
  407. #define DNS_RTYPE_NS 0x0200 // 2
  408. #define DNS_RTYPE_MD 0x0300 // 3
  409. #define DNS_RTYPE_MF 0x0400 // 4
  410. #define DNS_RTYPE_CNAME 0x0500 // 5
  411. #define DNS_RTYPE_SOA 0x0600 // 6
  412. #define DNS_RTYPE_MB 0x0700 // 7
  413. #define DNS_RTYPE_MG 0x0800 // 8
  414. #define DNS_RTYPE_MR 0x0900 // 9
  415. #define DNS_RTYPE_NULL 0x0a00 // 10
  416. #define DNS_RTYPE_WKS 0x0b00 // 11
  417. #define DNS_RTYPE_PTR 0x0c00 // 12
  418. #define DNS_RTYPE_HINFO 0x0d00 // 13
  419. #define DNS_RTYPE_MINFO 0x0e00 // 14
  420. #define DNS_RTYPE_MX 0x0f00 // 15
  421. #define DNS_RTYPE_TEXT 0x1000 // 16
  422. #define DNS_RTYPE_RP 0x1100 // 17
  423. #define DNS_RTYPE_AFSDB 0x1200 // 18
  424. #define DNS_RTYPE_X25 0x1300 // 19
  425. #define DNS_RTYPE_ISDN 0x1400 // 20
  426. #define DNS_RTYPE_RT 0x1500 // 21
  427. #define DNS_RTYPE_NSAP 0x1600 // 22
  428. #define DNS_RTYPE_NSAPPTR 0x1700 // 23
  429. #define DNS_RTYPE_SIG 0x1800 // 24
  430. #define DNS_RTYPE_KEY 0x1900 // 25
  431. #define DNS_RTYPE_PX 0x1a00 // 26
  432. #define DNS_RTYPE_GPOS 0x1b00 // 27
  433. #define DNS_RTYPE_AAAA 0x1c00 // 28
  434. #define DNS_RTYPE_LOC 0x1d00 // 29
  435. #define DNS_RTYPE_NXT 0x1e00 // 30
  436. #define DNS_RTYPE_EID 0x1f00 // 31
  437. #define DNS_RTYPE_NIMLOC 0x2000 // 32
  438. #define DNS_RTYPE_SRV 0x2100 // 33
  439. #define DNS_RTYPE_ATMA 0x2200 // 34
  440. #define DNS_RTYPE_NAPTR 0x2300 // 35
  441. #define DNS_RTYPE_KX 0x2400 // 36
  442. #define DNS_RTYPE_CERT 0x2500 // 37
  443. #define DNS_RTYPE_A6 0x2600 // 38
  444. #define DNS_RTYPE_DNAME 0x2700 // 39
  445. #define DNS_RTYPE_SINK 0x2800 // 40
  446. #define DNS_RTYPE_OPT 0x2900 // 41
  447. //
  448. // IANA Reserved
  449. //
  450. #define DNS_RTYPE_UINFO 0x6400 // 100
  451. #define DNS_RTYPE_UID 0x6500 // 101
  452. #define DNS_RTYPE_GID 0x6600 // 102
  453. #define DNS_RTYPE_UNSPEC 0x6700 // 103
  454. //
  455. // Query only types
  456. //
  457. #define DNS_RTYPE_TKEY 0xf900 // 249
  458. #define DNS_RTYPE_TSIG 0xfa00 // 250
  459. #define DNS_RTYPE_IXFR 0xfb00 // 251
  460. #define DNS_RTYPE_AXFR 0xfc00 // 252
  461. #define DNS_RTYPE_MAILB 0xfd00 // 253
  462. #define DNS_RTYPE_MAILA 0xfe00 // 254
  463. #define DNS_RTYPE_ALL 0xff00 // 255
  464. #define DNS_RTYPE_ANY 0xff00 // 255
  465. //
  466. // Temp Microsoft types -- use until get IANA approval for real type
  467. //
  468. #define DNS_RTYPE_WINS 0x01ff // 64K - 255
  469. #define DNS_RTYPE_WINSR 0x02ff // 64K - 254
  470. //
  471. // Record type specific definitions
  472. //
  473. //
  474. // ATMA (ATM address type) formats
  475. //
  476. // Define these directly for any environment (ex NT4)
  477. // without winsock2 ATM support (ws2atm.h)
  478. //
  479. #ifndef ATMA_E164
  480. #define DNS_ATMA_FORMAT_E164 1
  481. #define DNS_ATMA_FORMAT_AESA 2
  482. #define DNS_ATMA_MAX_ADDR_LENGTH (20)
  483. #else
  484. #define DNS_ATMA_FORMAT_E164 ATM_E164
  485. #define DNS_ATMA_FORMAT_AESA ATM_AESA
  486. #define DNS_ATMA_MAX_ADDR_LENGTH ATM_ADDR_SIZE
  487. #endif
  488. #define DNS_ATMA_AESA_ADDR_LENGTH (20)
  489. #define DNS_ATMA_MAX_RECORD_LENGTH (DNS_ATMA_MAX_ADDR_LENGTH+1)
  490. //
  491. // DNSSEC defs
  492. //
  493. // DNSSEC algorithms
  494. #define DNSSEC_ALGORITHM_RSAMD5 1
  495. #define DNSSEC_ALGORITHM_NULL 253
  496. #define DNSSEC_ALGORITHM_PRIVATE 254
  497. // DNSSEC KEY protocol table
  498. #define DNSSEC_PROTOCOL_NONE 0
  499. #define DNSSEC_PROTOCOL_TLS 1
  500. #define DNSSEC_PROTOCOL_EMAIL 2
  501. #define DNSSEC_PROTOCOL_DNSSEC 3
  502. #define DNSSEC_PROTOCOL_IPSEC 4
  503. // DNSSEC KEY flag field
  504. #define DNSSEC_KEY_FLAG_NOAUTH 0x0001
  505. #define DNSSEC_KEY_FLAG_NOCONF 0x0002
  506. #define DNSSEC_KEY_FLAG_FLAG2 0x0004
  507. #define DNSSEC_KEY_FLAG_EXTEND 0x0008
  508. #define DNSSEC_KEY_FLAG_
  509. #define DNSSEC_KEY_FLAG_FLAG4 0x0010
  510. #define DNSSEC_KEY_FLAG_FLAG5 0x0020
  511. // bits 6,7 are name type
  512. #define DNSSEC_KEY_FLAG_USER 0x0000
  513. #define DNSSEC_KEY_FLAG_ZONE 0x0040
  514. #define DNSSEC_KEY_FLAG_HOST 0x0080
  515. #define DNSSEC_KEY_FLAG_NTPE3 0x00c0
  516. // bits 8-11 are reserved for future use
  517. #define DNSSEC_KEY_FLAG_FLAG8 0x0100
  518. #define DNSSEC_KEY_FLAG_FLAG9 0x0200
  519. #define DNSSEC_KEY_FLAG_FLAG10 0x0400
  520. #define DNSSEC_KEY_FLAG_FLAG11 0x0800
  521. // bits 12-15 are sig field
  522. #define DNSSEC_KEY_FLAG_SIG0 0x0000
  523. #define DNSSEC_KEY_FLAG_SIG1 0x1000
  524. #define DNSSEC_KEY_FLAG_SIG2 0x2000
  525. #define DNSSEC_KEY_FLAG_SIG3 0x3000
  526. #define DNSSEC_KEY_FLAG_SIG4 0x4000
  527. #define DNSSEC_KEY_FLAG_SIG5 0x5000
  528. #define DNSSEC_KEY_FLAG_SIG6 0x6000
  529. #define DNSSEC_KEY_FLAG_SIG7 0x7000
  530. #define DNSSEC_KEY_FLAG_SIG8 0x8000
  531. #define DNSSEC_KEY_FLAG_SIG9 0x9000
  532. #define DNSSEC_KEY_FLAG_SIG10 0xa000
  533. #define DNSSEC_KEY_FLAG_SIG11 0xb000
  534. #define DNSSEC_KEY_FLAG_SIG12 0xc000
  535. #define DNSSEC_KEY_FLAG_SIG13 0xd000
  536. #define DNSSEC_KEY_FLAG_SIG14 0xe000
  537. #define DNSSEC_KEY_FLAG_SIG15 0xf000
  538. //
  539. // TKEY modes
  540. //
  541. #define DNS_TKEY_MODE_SERVER_ASSIGN 1
  542. #define DNS_TKEY_MODE_DIFFIE_HELLMAN 2
  543. #define DNS_TKEY_MODE_GSS 3
  544. #define DNS_TKEY_MODE_RESOLVER_ASSIGN 4
  545. //
  546. // WINS + NBSTAT flag field
  547. //
  548. #define DNS_WINS_FLAG_SCOPE (0x80000000)
  549. #define DNS_WINS_FLAG_LOCAL (0x00010000)
  550. //
  551. // Helpful checks
  552. //
  553. #define IS_WORD_ALIGNED(p) ( !((UINT_PTR)(p) & (UINT_PTR)1) )
  554. #define IS_DWORD_ALIGNED(p) ( !((UINT_PTR)(p) & (UINT_PTR)3) )
  555. #define IS_QWORD_ALIGNED(p) ( !((UINT_PTR)(p) & (UINT_PTR)7) )
  556. //
  557. // DNS config API
  558. //
  559. //
  560. // Types of DNS configuration info
  561. //
  562. typedef enum
  563. {
  564. // In Win2K
  565. DnsConfigPrimaryDomainName_W,
  566. DnsConfigPrimaryDomainName_A,
  567. DnsConfigPrimaryDomainName_UTF8,
  568. // Not available yet
  569. DnsConfigAdapterDomainName_W,
  570. DnsConfigAdapterDomainName_A,
  571. DnsConfigAdapterDomainName_UTF8,
  572. // In Win2K
  573. DnsConfigDnsServerList,
  574. // Not available yet
  575. DnsConfigSearchList,
  576. DnsConfigAdapterInfo,
  577. // In Win2K
  578. DnsConfigPrimaryHostNameRegistrationEnabled,
  579. DnsConfigAdapterHostNameRegistrationEnabled,
  580. DnsConfigAddressRegistrationMaxCount,
  581. // In WindowsXP
  582. DnsConfigHostName_W,
  583. DnsConfigHostName_A,
  584. DnsConfigHostName_UTF8,
  585. DnsConfigFullHostName_W,
  586. DnsConfigFullHostName_A,
  587. DnsConfigFullHostName_UTF8
  588. }
  589. DNS_CONFIG_TYPE;
  590. //
  591. // Config API flags
  592. //
  593. //
  594. // Causes config info to be allocated with LocalAlloc()
  595. //
  596. #define DNS_CONFIG_FLAG_ALLOC (0x00000001)
  597. DNS_STATUS
  598. WINAPI
  599. DnsQueryConfig(
  600. IN DNS_CONFIG_TYPE Config,
  601. IN DWORD Flag,
  602. IN PWSTR pwsAdapterName,
  603. IN PVOID pReserved,
  604. OUT PVOID pBuffer,
  605. IN OUT PDWORD pBufferLength
  606. );
  607. //
  608. // DNS resource record structure
  609. //
  610. //
  611. // Record data for specific types
  612. //
  613. typedef struct
  614. {
  615. IP4_ADDRESS IpAddress;
  616. }
  617. DNS_A_DATA, *PDNS_A_DATA;
  618. typedef struct
  619. {
  620. LPTSTR pNameHost;
  621. }
  622. DNS_PTR_DATA, *PDNS_PTR_DATA;
  623. typedef struct
  624. {
  625. LPTSTR pNamePrimaryServer;
  626. LPTSTR pNameAdministrator;
  627. DWORD dwSerialNo;
  628. DWORD dwRefresh;
  629. DWORD dwRetry;
  630. DWORD dwExpire;
  631. DWORD dwDefaultTtl;
  632. }
  633. DNS_SOA_DATA, *PDNS_SOA_DATA;
  634. typedef struct
  635. {
  636. LPTSTR pNameMailbox;
  637. LPTSTR pNameErrorsMailbox;
  638. }
  639. DNS_MINFO_DATA, *PDNS_MINFO_DATA;
  640. typedef struct
  641. {
  642. LPTSTR pNameExchange;
  643. WORD wPreference;
  644. WORD Pad; // keep ptrs DWORD aligned
  645. }
  646. DNS_MX_DATA, *PDNS_MX_DATA;
  647. typedef struct
  648. {
  649. DWORD dwStringCount;
  650. #ifdef MIDL_PASS
  651. [size_is(dwStringCount)] LPTSTR pStringArray[];
  652. #else
  653. LPTSTR pStringArray[1];
  654. #endif
  655. }
  656. DNS_TXT_DATA, *PDNS_TXT_DATA;
  657. typedef struct
  658. {
  659. DWORD dwByteCount;
  660. #ifdef MIDL_PASS
  661. [size_is(dwByteCount)] BYTE Data[];
  662. #else
  663. BYTE Data[1];
  664. #endif
  665. }
  666. DNS_NULL_DATA, *PDNS_NULL_DATA;
  667. typedef struct
  668. {
  669. IP4_ADDRESS IpAddress;
  670. UCHAR chProtocol;
  671. BYTE BitMask[1];
  672. }
  673. DNS_WKS_DATA, *PDNS_WKS_DATA;
  674. typedef struct
  675. {
  676. DNS_IP6_ADDRESS Ip6Address;
  677. }
  678. DNS_AAAA_DATA, *PDNS_AAAA_DATA;
  679. typedef struct
  680. {
  681. LPTSTR pNameSigner;
  682. WORD wTypeCovered;
  683. BYTE chAlgorithm;
  684. BYTE chLabelCount;
  685. DWORD dwOriginalTtl;
  686. DWORD dwExpiration;
  687. DWORD dwTimeSigned;
  688. WORD wKeyTag;
  689. WORD Pad; // keep byte field aligned
  690. BYTE Signature[1];
  691. }
  692. DNS_SIG_DATA, *PDNS_SIG_DATA;
  693. typedef struct
  694. {
  695. WORD wFlags;
  696. BYTE chProtocol;
  697. BYTE chAlgorithm;
  698. BYTE Key[1];
  699. }
  700. DNS_KEY_DATA, *PDNS_KEY_DATA;
  701. typedef struct
  702. {
  703. WORD wVersion;
  704. WORD wSize;
  705. WORD wHorPrec;
  706. WORD wVerPrec;
  707. DWORD dwLatitude;
  708. DWORD dwLongitude;
  709. DWORD dwAltitude;
  710. }
  711. DNS_LOC_DATA, *PDNS_LOC_DATA;
  712. typedef struct
  713. {
  714. LPTSTR pNameNext;
  715. WORD wNumTypes;
  716. WORD wTypes[1];
  717. }
  718. DNS_NXT_DATA, *PDNS_NXT_DATA;
  719. typedef struct
  720. {
  721. LPTSTR pNameTarget;
  722. WORD wPriority;
  723. WORD wWeight;
  724. WORD wPort;
  725. WORD Pad; // keep ptrs DWORD aligned
  726. }
  727. DNS_SRV_DATA, *PDNS_SRV_DATA;
  728. typedef struct
  729. {
  730. BYTE AddressType;
  731. BYTE Address[ DNS_ATMA_MAX_ADDR_LENGTH ];
  732. // E164 -- Null terminated string of less than
  733. // DNS_ATMA_MAX_ADDR_LENGTH
  734. //
  735. // For NSAP (AESA) BCD encoding of exactly
  736. // DNS_ATMA_AESA_ADDR_LENGTH
  737. }
  738. DNS_ATMA_DATA, *PDNS_ATMA_DATA;
  739. typedef struct
  740. {
  741. LPTSTR pNameAlgorithm;
  742. PBYTE pAlgorithmPacket;
  743. PBYTE pKey;
  744. PBYTE pOtherData;
  745. DWORD dwCreateTime;
  746. DWORD dwExpireTime;
  747. WORD wMode;
  748. WORD wError;
  749. WORD wKeyLength;
  750. WORD wOtherLength;
  751. UCHAR cAlgNameLength;
  752. BOOL bPacketPointers;
  753. }
  754. DNS_TKEY_DATA, *PDNS_TKEY_DATA;
  755. typedef struct
  756. {
  757. LPTSTR pNameAlgorithm;
  758. PBYTE pAlgorithmPacket;
  759. PBYTE pSignature;
  760. PBYTE pOtherData;
  761. LONGLONG i64CreateTime;
  762. WORD wFudgeTime;
  763. WORD wOriginalXid;
  764. WORD wError;
  765. WORD wSigLength;
  766. WORD wOtherLength;
  767. UCHAR cAlgNameLength;
  768. BOOL bPacketPointers;
  769. }
  770. DNS_TSIG_DATA, *PDNS_TSIG_DATA;
  771. //
  772. // MS only types -- only hit the wire in MS-MS zone transfer
  773. //
  774. typedef struct
  775. {
  776. DWORD dwMappingFlag;
  777. DWORD dwLookupTimeout;
  778. DWORD dwCacheTimeout;
  779. DWORD cWinsServerCount;
  780. IP4_ADDRESS WinsServers[1];
  781. }
  782. DNS_WINS_DATA, *PDNS_WINS_DATA;
  783. typedef struct
  784. {
  785. DWORD dwMappingFlag;
  786. DWORD dwLookupTimeout;
  787. DWORD dwCacheTimeout;
  788. LPTSTR pNameResultDomain;
  789. }
  790. DNS_WINSR_DATA, *PDNS_WINSR_DATA;
  791. //
  792. // Length of non-fixed-length data types
  793. //
  794. #define DNS_TEXT_RECORD_LENGTH(StringCount) \
  795. (FIELD_OFFSET(DNS_TXT_DATA, pStringArray) + ((StringCount) * sizeof(PCHAR)))
  796. #define DNS_NULL_RECORD_LENGTH(ByteCount) \
  797. (FIELD_OFFSET(DNS_NULL_DATA, Data) + (ByteCount))
  798. #define DNS_WKS_RECORD_LENGTH(ByteCount) \
  799. (FIELD_OFFSET(DNS_WKS_DATA, BitMask) + (ByteCount))
  800. #define DNS_WINS_RECORD_LENGTH(IpCount) \
  801. (FIELD_OFFSET(DNS_WINS_DATA, WinsServers) + ((IpCount) * sizeof(IP4_ADDRESS)))
  802. //
  803. // Record flags
  804. //
  805. typedef struct _DnsRecordFlags
  806. {
  807. DWORD Section : 2;
  808. DWORD Delete : 1;
  809. DWORD CharSet : 2;
  810. DWORD Unused : 3;
  811. DWORD Reserved : 24;
  812. }
  813. DNS_RECORD_FLAGS;
  814. //
  815. // Wire Record Sections
  816. //
  817. // Useable both in record flags "Section" and as index into
  818. // wire message header section counts.
  819. //
  820. typedef enum _DnsSection
  821. {
  822. DnsSectionQuestion,
  823. DnsSectionAnswer,
  824. DnsSectionAuthority,
  825. DnsSectionAddtional,
  826. }
  827. DNS_SECTION;
  828. // Update message section names
  829. #define DnsSectionZone DnsSectionQuestion
  830. #define DnsSectionPrereq DnsSectionAnswer
  831. #define DnsSectionUpdate DnsSectionAuthority
  832. //
  833. // Record flags as bit flags
  834. // These may be or'd together to set the fields
  835. //
  836. // RR Section in packet
  837. #define DNSREC_SECTION (0x00000003)
  838. #define DNSREC_QUESTION (0x00000000)
  839. #define DNSREC_ANSWER (0x00000001)
  840. #define DNSREC_AUTHORITY (0x00000002)
  841. #define DNSREC_ADDITIONAL (0x00000003)
  842. // RR Section in packet (update)
  843. #define DNSREC_ZONE (0x00000000)
  844. #define DNSREC_PREREQ (0x00000001)
  845. #define DNSREC_UPDATE (0x00000002)
  846. // Delete RR (update) or No-exist (prerequisite)
  847. #define DNSREC_DELETE (0x00000004)
  848. #define DNSREC_NOEXIST (0x00000004)
  849. //
  850. // Record \ RR set structure
  851. //
  852. // Note: The dwReserved flag serves to insure that the substructures
  853. // start on 64-bit boundaries. Do NOT pack this structure, as the
  854. // substructures may contain pointers or int64 values which are
  855. // properly aligned unpacked.
  856. //
  857. #ifdef MIDL_PASS
  858. #define PDNS_RECORD PVOID
  859. #else
  860. typedef struct _DnsRecord
  861. {
  862. struct _DnsRecord * pNext;
  863. LPTSTR pName;
  864. WORD wType;
  865. WORD wDataLength; // Not referenced for DNS record types
  866. // defined above.
  867. union
  868. {
  869. DWORD DW; // flags as DWORD
  870. DNS_RECORD_FLAGS S; // flags as structure
  871. } Flags;
  872. DWORD dwTtl;
  873. DWORD dwReserved;
  874. // Record Data
  875. union
  876. {
  877. DNS_A_DATA A;
  878. DNS_SOA_DATA SOA, Soa;
  879. DNS_PTR_DATA PTR, Ptr,
  880. NS, Ns,
  881. CNAME, Cname,
  882. MB, Mb,
  883. MD, Md,
  884. MF, Mf,
  885. MG, Mg,
  886. MR, Mr;
  887. DNS_MINFO_DATA MINFO, Minfo,
  888. RP, Rp;
  889. DNS_MX_DATA MX, Mx,
  890. AFSDB, Afsdb,
  891. RT, Rt;
  892. DNS_TXT_DATA HINFO, Hinfo,
  893. ISDN, Isdn,
  894. TXT, Txt,
  895. X25;
  896. DNS_NULL_DATA Null;
  897. DNS_WKS_DATA WKS, Wks;
  898. DNS_AAAA_DATA AAAA;
  899. DNS_KEY_DATA KEY, Key;
  900. DNS_SIG_DATA SIG, Sig;
  901. DNS_ATMA_DATA ATMA, Atma;
  902. DNS_NXT_DATA NXT, Nxt;
  903. DNS_SRV_DATA SRV, Srv;
  904. DNS_TKEY_DATA TKEY, Tkey;
  905. DNS_TSIG_DATA TSIG, Tsig;
  906. DNS_WINS_DATA WINS, Wins;
  907. DNS_WINSR_DATA WINSR, WinsR, NBSTAT, Nbstat;
  908. } Data;
  909. }
  910. DNS_RECORD, *PDNS_RECORD;
  911. //
  912. // Header or fixed size of DNS_RECORD
  913. //
  914. #define DNS_RECORD_FIXED_SIZE FIELD_OFFSET( DNS_RECORD, Data )
  915. #define SIZEOF_DNS_RECORD_HEADER DNS_RECORD_FIXED_SIZE
  916. #endif // PRIVATE_DNS_RECORD
  917. //
  918. // Resource record set building
  919. //
  920. // pFirst points to first record in list.
  921. // pLast points to last record in list.
  922. //
  923. typedef struct _DnsRRSet
  924. {
  925. PDNS_RECORD pFirstRR;
  926. PDNS_RECORD pLastRR;
  927. }
  928. DNS_RRSET, *PDNS_RRSET;
  929. //
  930. // To init pFirst is NULL.
  931. // But pLast points at the location of the pFirst pointer -- essentially
  932. // treating the pFirst ptr as a DNS_RECORD. (It is a DNS_RECORD with
  933. // only a pNext field, but that's the only part we use.)
  934. //
  935. // Then when the first record is added to the list, the pNext field of
  936. // this dummy record (which corresponds to pFirst's value) is set to
  937. // point at the first record. So pFirst then properly points at the
  938. // first record.
  939. //
  940. // (This works only because pNext is the first field in a
  941. // DNS_RECORD structure and hence casting a PDNS_RECORD ptr to
  942. // PDNS_RECORD* and dereferencing yields its pNext field)
  943. //
  944. // Use TERMINATE when have built RR set by grabbing records out of
  945. // existing set. This makes sure that at the end, the last RR is
  946. // properly NULL terminated.
  947. //
  948. #define DNS_RRSET_INIT( rrset ) \
  949. { \
  950. PDNS_RRSET _prrset = &(rrset); \
  951. _prrset->pFirstRR = NULL; \
  952. _prrset->pLastRR = (PDNS_RECORD) &_prrset->pFirstRR; \
  953. }
  954. #define DNS_RRSET_ADD( rrset, pnewRR ) \
  955. { \
  956. PDNS_RRSET _prrset = &(rrset); \
  957. PDNS_RECORD _prrnew = (pnewRR); \
  958. _prrset->pLastRR->pNext = _prrnew; \
  959. _prrset->pLastRR = _prrnew; \
  960. }
  961. #define DNS_RRSET_TERMINATE( rrset ) \
  962. { \
  963. PDNS_RRSET _prrset = &(rrset); \
  964. _prrset->pLastRR->pNext = NULL; \
  965. }
  966. //
  967. // Record set manipulation
  968. //
  969. //
  970. // Record Copy
  971. // Record copy functions also do conversion between character sets.
  972. //
  973. // Note, it might be advisable to directly expose non-Ex copy
  974. // functions _W, _A for record and set, to avoid exposing the
  975. // conversion enum.
  976. //
  977. typedef enum _DNS_CHARSET
  978. {
  979. DnsCharSetUnknown,
  980. DnsCharSetUnicode,
  981. DnsCharSetUtf8,
  982. DnsCharSetAnsi,
  983. }
  984. DNS_CHARSET;
  985. PDNS_RECORD
  986. WINAPI
  987. DnsRecordCopyEx(
  988. IN PDNS_RECORD pRecord,
  989. IN DNS_CHARSET CharSetIn,
  990. IN DNS_CHARSET CharSetOut
  991. );
  992. PDNS_RECORD
  993. WINAPI
  994. DnsRecordSetCopyEx(
  995. IN PDNS_RECORD pRecordSet,
  996. IN DNS_CHARSET CharSetIn,
  997. IN DNS_CHARSET CharSetOut
  998. );
  999. #ifdef UNICODE
  1000. #define DnsRecordCopy(pRR) \
  1001. DnsRecordCopyEx( (pRR), DnsCharSetUnicode, DnsCharSetUnicode )
  1002. #define DnsRecordSetCopy(pRR) \
  1003. DnsRecordSetCopyEx( (pRR), DnsCharSetUnicode, DnsCharSetUnicode )
  1004. #else
  1005. #define DnsRecordCopy(pRR) \
  1006. DnsRecordCopyEx( (pRR), DnsCharSetAnsi, DnsCharSetAnsi )
  1007. #define DnsRecordSetCopy(pRR) \
  1008. DnsRecordSetCopyEx( (pRR), DnsCharSetAnsi, DnsCharSetAnsi )
  1009. #endif
  1010. //
  1011. // Record Compare
  1012. //
  1013. // Note: these routines only compare records of the SAME character set.
  1014. // (ANSI, unicode or UTF8). Furthermore the routines assume the character
  1015. // set is indicated within the record. If compare of user created, rather
  1016. // than DNS API created record lists is desired, then caller should use
  1017. // DnsRecordCopy API and compare copies.
  1018. //
  1019. BOOL
  1020. WINAPI
  1021. DnsRecordCompare(
  1022. IN PDNS_RECORD pRecord1,
  1023. IN PDNS_RECORD pRecord2
  1024. );
  1025. BOOL
  1026. WINAPI
  1027. DnsRecordSetCompare(
  1028. IN OUT PDNS_RECORD pRR1,
  1029. IN OUT PDNS_RECORD pRR2,
  1030. OUT PDNS_RECORD * ppDiff1,
  1031. OUT PDNS_RECORD * ppDiff2
  1032. );
  1033. //
  1034. // Detach next record set from record list
  1035. //
  1036. PDNS_RECORD
  1037. DnsRecordSetDetach(
  1038. IN OUT PDNS_RECORD pRecordList
  1039. );
  1040. //
  1041. // Free record list
  1042. //
  1043. // Only supported free is deep free of entire record list with LocalFree().
  1044. // This correctly frees record list returned by DnsQuery() or DnsRecordSetCopy()
  1045. //
  1046. typedef enum
  1047. {
  1048. DnsFreeFlat = 0,
  1049. DnsFreeRecordList
  1050. }
  1051. DNS_FREE_TYPE;
  1052. #define DnsFreeRecordListDeep DnsFreeRecordList
  1053. VOID
  1054. WINAPI
  1055. DnsRecordListFree(
  1056. IN OUT PDNS_RECORD pRecordList,
  1057. IN DNS_FREE_TYPE FreeType
  1058. );
  1059. VOID
  1060. WINAPI
  1061. DnsFree(
  1062. IN OUT PVOID pData,
  1063. IN DNS_FREE_TYPE FreeType
  1064. );
  1065. //
  1066. // DNS Query API
  1067. //
  1068. //
  1069. // Options for DnsQuery
  1070. //
  1071. #define DNS_QUERY_STANDARD 0x00000000
  1072. #define DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE 0x00000001
  1073. #define DNS_QUERY_USE_TCP_ONLY 0x00000002
  1074. #define DNS_QUERY_NO_RECURSION 0x00000004
  1075. #define DNS_QUERY_BYPASS_CACHE 0x00000008
  1076. #define DNS_QUERY_NO_WIRE_QUERY 0x00000010
  1077. #define DNS_QUERY_NO_LOCAL_NAME 0x00000020
  1078. #define DNS_QUERY_NO_HOSTS_FILE 0x00000040
  1079. #define DNS_QUERY_NO_NETBT 0x00000080
  1080. #define DNS_QUERY_WIRE_ONLY 0x00000100
  1081. #define DNS_QUERY_RETURN_MESSAGE 0x00000200
  1082. #define DNS_QUERY_TREAT_AS_FQDN 0x00001000
  1083. #define DNS_QUERY_DONT_RESET_TTL_VALUES 0x00100000
  1084. #define DNS_QUERY_RESERVED 0xff000000
  1085. // Backward compatibility with Win2K
  1086. // Do not use
  1087. #define DNS_QUERY_CACHE_ONLY DNS_QUERY_NO_WIRE_QUERY
  1088. DNS_STATUS
  1089. WINAPI
  1090. DnsQuery_A(
  1091. IN PCSTR pszName,
  1092. IN WORD wType,
  1093. IN DWORD Options,
  1094. IN PIP4_ARRAY aipServers OPTIONAL,
  1095. IN OUT PDNS_RECORD * ppQueryResults OPTIONAL,
  1096. IN OUT PVOID * pReserved OPTIONAL
  1097. );
  1098. DNS_STATUS
  1099. WINAPI
  1100. DnsQuery_UTF8(
  1101. IN PCSTR pszName,
  1102. IN WORD wType,
  1103. IN DWORD Options,
  1104. IN PIP4_ARRAY aipServers OPTIONAL,
  1105. IN OUT PDNS_RECORD * ppQueryResults OPTIONAL,
  1106. IN OUT PVOID * pReserved OPTIONAL
  1107. );
  1108. DNS_STATUS
  1109. WINAPI
  1110. DnsQuery_W(
  1111. IN PCWSTR pszName,
  1112. IN WORD wType,
  1113. IN DWORD Options,
  1114. IN PIP4_ARRAY aipServers OPTIONAL,
  1115. IN OUT PDNS_RECORD * ppQueryResults OPTIONAL,
  1116. IN OUT PVOID * pReserved OPTIONAL
  1117. );
  1118. #ifdef UNICODE
  1119. #define DnsQuery DnsQuery_W
  1120. #else
  1121. #define DnsQuery DnsQuery_A
  1122. #endif
  1123. //
  1124. // DNS Update API
  1125. //
  1126. // DnsAcquireContextHandle
  1127. // DnsReleaseContextHandle
  1128. // DnsModifyRecordsInSet
  1129. // DnsReplaceRecordSet
  1130. //
  1131. //
  1132. // Update flags
  1133. //
  1134. #define DNS_UPDATE_SECURITY_USE_DEFAULT 0x00000000
  1135. #define DNS_UPDATE_SECURITY_OFF 0x00000010
  1136. #define DNS_UPDATE_SECURITY_ON 0x00000020
  1137. #define DNS_UPDATE_SECURITY_ONLY 0x00000100
  1138. #define DNS_UPDATE_CACHE_SECURITY_CONTEXT 0x00000200
  1139. #define DNS_UPDATE_TEST_USE_LOCAL_SYS_ACCT 0x00000400
  1140. #define DNS_UPDATE_FORCE_SECURITY_NEGO 0x00000800
  1141. #define DNS_UPDATE_TRY_ALL_MASTER_SERVERS 0x00001000
  1142. #define DNS_UPDATE_SKIP_NO_UPDATE_ADAPTERS 0x00002000
  1143. #define DNS_UPDATE_RESERVED 0xffff0000
  1144. //
  1145. // Note: pCredentials paramater is currently respectively
  1146. // PSEC_WINNT_AUTH_IDENTITY_W or PSEC_WINNT_AUTH_IDENTITY_A.
  1147. // Using PVOID to obviate the need for including rpcdce.h
  1148. // in order to include this file and to leave open the
  1149. // possibility of alternative credential specifications in
  1150. // the future.
  1151. //
  1152. DNS_STATUS
  1153. WINAPI
  1154. DnsAcquireContextHandle_W(
  1155. IN DWORD CredentialFlags,
  1156. IN PVOID pCredentials, OPTIONAL
  1157. //IN PSEC_WINNT_AUTH_IDENTITY_W pCredentials,
  1158. OUT PHANDLE pContextHandle
  1159. );
  1160. DNS_STATUS
  1161. WINAPI
  1162. DnsAcquireContextHandle_A(
  1163. IN DWORD CredentialFlags,
  1164. IN PVOID pCredentials, OPTIONAL
  1165. //IN PSEC_WINNT_AUTH_IDENTITY_A pCredentials,
  1166. OUT PHANDLE pContextHandle
  1167. );
  1168. #ifdef UNICODE
  1169. #define DnsAcquireContextHandle DnsAcquireContextHandle_W
  1170. #else
  1171. #define DnsAcquireContextHandle DnsAcquireContextHandle_A
  1172. #endif
  1173. VOID
  1174. WINAPI
  1175. DnsReleaseContextHandle(
  1176. IN HANDLE hContext
  1177. );
  1178. //
  1179. // Dynamic Update API
  1180. //
  1181. DNS_STATUS
  1182. WINAPI
  1183. DnsModifyRecordsInSet_W(
  1184. IN PDNS_RECORD pAddRecords,
  1185. IN PDNS_RECORD pDeleteRecords,
  1186. IN DWORD Options,
  1187. IN HANDLE hContext, OPTIONAL
  1188. IN PIP4_ARRAY pServerList, OPTIONAL
  1189. IN PVOID pReserved
  1190. );
  1191. DNS_STATUS
  1192. WINAPI
  1193. DnsModifyRecordsInSet_A(
  1194. IN PDNS_RECORD pAddRecords,
  1195. IN PDNS_RECORD pDeleteRecords,
  1196. IN DWORD Options,
  1197. IN HANDLE hContext, OPTIONAL
  1198. IN PIP4_ARRAY pServerList, OPTIONAL
  1199. IN PVOID pReserved
  1200. );
  1201. DNS_STATUS
  1202. WINAPI
  1203. DnsModifyRecordsInSet_UTF8(
  1204. IN PDNS_RECORD pAddRecords,
  1205. IN PDNS_RECORD pDeleteRecords,
  1206. IN DWORD Options,
  1207. IN HANDLE hContext, OPTIONAL
  1208. IN PIP4_ARRAY pServerList, OPTIONAL
  1209. IN PVOID pReserved
  1210. );
  1211. #ifdef UNICODE
  1212. #define DnsModifyRecordsInSet DnsModifyRecordsInSet_W
  1213. #else
  1214. #define DnsModifyRecordsInSet DnsModifyRecordsInSet_A
  1215. #endif
  1216. DNS_STATUS
  1217. WINAPI
  1218. DnsReplaceRecordSetW(
  1219. IN PDNS_RECORD pNewSet,
  1220. IN DWORD Options,
  1221. IN HANDLE hContext, OPTIONAL
  1222. IN PIP4_ARRAY pServerList, OPTIONAL
  1223. IN PVOID pReserved
  1224. );
  1225. DNS_STATUS
  1226. WINAPI
  1227. DnsReplaceRecordSetA(
  1228. IN PDNS_RECORD pNewSet,
  1229. IN DWORD Options,
  1230. IN HANDLE hContext, OPTIONAL
  1231. IN PIP4_ARRAY pServerList, OPTIONAL
  1232. IN PVOID pReserved
  1233. );
  1234. DNS_STATUS
  1235. WINAPI
  1236. DnsReplaceRecordSetUTF8(
  1237. IN PDNS_RECORD pNewSet,
  1238. IN DWORD Options,
  1239. IN HANDLE hContext, OPTIONAL
  1240. IN PIP4_ARRAY pServerList, OPTIONAL
  1241. IN PVOID pReserved
  1242. );
  1243. #ifdef UNICODE
  1244. #define DnsReplaceRecordSet DnsReplaceRecordSetW
  1245. #else
  1246. #define DnsReplaceRecordSet DnsReplaceRecordSetA
  1247. #endif
  1248. //
  1249. // DNS name validation
  1250. //
  1251. typedef enum _DNS_NAME_FORMAT
  1252. {
  1253. DnsNameDomain,
  1254. DnsNameDomainLabel,
  1255. DnsNameHostnameFull,
  1256. DnsNameHostnameLabel,
  1257. DnsNameWildcard,
  1258. DnsNameSrvRecord
  1259. }
  1260. DNS_NAME_FORMAT;
  1261. DNS_STATUS
  1262. DnsValidateName_UTF8(
  1263. IN LPCSTR pszName,
  1264. IN DNS_NAME_FORMAT Format
  1265. );
  1266. DNS_STATUS
  1267. DnsValidateName_W(
  1268. IN LPCWSTR pwszName,
  1269. IN DNS_NAME_FORMAT Format
  1270. );
  1271. DNS_STATUS
  1272. DnsValidateName_A(
  1273. IN LPCSTR pszName,
  1274. IN DNS_NAME_FORMAT Format
  1275. );
  1276. #ifdef UNICODE
  1277. #define DnsValidateName(p,f) DnsValidateName_W( (p), (f) )
  1278. #else
  1279. #define DnsValidateName(p,f) DnsValidateName_A( (p), (f) )
  1280. #endif
  1281. //
  1282. // DNS name comparison
  1283. //
  1284. BOOL
  1285. WINAPI
  1286. DnsNameCompare_A(
  1287. IN LPSTR pName1,
  1288. IN LPSTR pName2
  1289. );
  1290. BOOL
  1291. WINAPI
  1292. DnsNameCompare_W(
  1293. IN LPWSTR pName1,
  1294. IN LPWSTR pName2
  1295. );
  1296. #ifdef UNICODE
  1297. #define DnsNameCompare(n1,n2) DnsNameCompare_W( (n1),(n2) )
  1298. #else
  1299. #define DnsNameCompare(n1,n2) DnsNameCompare_A( (n1),(n2) )
  1300. #endif
  1301. //
  1302. // DNS message "roll-your-own" routines
  1303. //
  1304. typedef struct _DNS_MESSAGE_BUFFER
  1305. {
  1306. DNS_HEADER MessageHead;
  1307. CHAR MessageBody[1];
  1308. }
  1309. DNS_MESSAGE_BUFFER, *PDNS_MESSAGE_BUFFER;
  1310. BOOL
  1311. WINAPI
  1312. DnsWriteQuestionToBuffer_W(
  1313. IN OUT PDNS_MESSAGE_BUFFER pDnsBuffer,
  1314. IN OUT LPDWORD pdwBufferSize,
  1315. IN LPWSTR pszName,
  1316. IN WORD wType,
  1317. IN WORD Xid,
  1318. IN BOOL fRecursionDesired
  1319. );
  1320. BOOL WINAPI
  1321. DnsWriteQuestionToBuffer_UTF8(
  1322. IN OUT PDNS_MESSAGE_BUFFER pDnsBuffer,
  1323. IN OUT LPDWORD pdwBufferSize,
  1324. IN LPSTR pszName,
  1325. IN WORD wType,
  1326. IN WORD Xid,
  1327. IN BOOL fRecursionDesired
  1328. );
  1329. DNS_STATUS
  1330. WINAPI
  1331. DnsExtractRecordsFromMessage_W(
  1332. IN PDNS_MESSAGE_BUFFER pDnsBuffer,
  1333. IN WORD wMessageLength,
  1334. OUT PDNS_RECORD * ppRecord
  1335. );
  1336. DNS_STATUS
  1337. WINAPI
  1338. DnsExtractRecordsFromMessage_UTF8(
  1339. IN PDNS_MESSAGE_BUFFER pDnsBuffer,
  1340. IN WORD wMessageLength,
  1341. OUT PDNS_RECORD * ppRecord
  1342. );
  1343. #ifdef __cplusplus
  1344. }
  1345. #endif // __cplusplus
  1346. #endif // _WINDNS_INCLUDED_