Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

905 lines
25 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. dns.h
  5. Abstract:
  6. Domain Name System (DNS)
  7. General DNS definitions.
  8. Author:
  9. Jim Gilroy (jamesg) December 7, 1996
  10. Revision History:
  11. --*/
  12. #ifndef _DNS_INCLUDED_
  13. #define _DNS_INCLUDED_
  14. #ifdef __cplusplus
  15. extern "C"
  16. {
  17. #endif // __cplusplus
  18. //
  19. // Basic DNS API definitions
  20. //
  21. // These are basic definitions used by both DnsAPI and DNS server RPC interface.
  22. // Since dnsapi.h is not setup for a midl compile, dns.h servers as a common
  23. // header point with simple definitions used by both.
  24. //
  25. // Use stdcall for our API conventions
  26. //
  27. // Explicitly state this as C++ compiler will otherwise
  28. // assume cdecl.
  29. //
  30. #define DNS_API_FUNCTION __stdcall
  31. //
  32. // DNS public types
  33. //
  34. typedef LONG DNS_STATUS, *PDNS_STATUS;
  35. typedef DWORD DNS_HANDLE, *PDNS_HANDLE;
  36. typedef DWORD DNS_APIOP;
  37. //
  38. // IP Address
  39. //
  40. typedef DWORD IP_ADDRESS, *PIP_ADDRESS;
  41. #define SIZEOF_IP_ADDRESS (4)
  42. #define IP_ADDRESS_STRING_LENGTH (15)
  43. #define IP_STRING( ipAddress ) inet_ntoa( *(struct in_addr *)&(ipAddress) )
  44. //
  45. // IP Address Array type
  46. //
  47. #if defined(MIDL_PASS)
  48. typedef struct _IP_ARRAY
  49. {
  50. DWORD cAddrCount;
  51. [size_is( cAddrCount )] IP_ADDRESS aipAddrs[];
  52. }
  53. IP_ARRAY, *PIP_ARRAY;
  54. #else
  55. typedef struct _IP_ARRAY
  56. {
  57. DWORD cAddrCount;
  58. IP_ADDRESS aipAddrs[1];
  59. }
  60. IP_ARRAY, *PIP_ARRAY;
  61. #endif
  62. //
  63. // IPv6 Address
  64. //
  65. typedef struct
  66. {
  67. WORD IPv6Word[8];
  68. }
  69. IPV6_ADDRESS, *PIPV6_ADDRESS;
  70. #define IPV6_ADDRESS_STRING_LENGTH (39)
  71. //
  72. // DNS dotted name
  73. // - define type simply to clarify arguments
  74. //
  75. #ifdef UNICODE
  76. typedef LPWSTR DNS_NAME;
  77. #else
  78. typedef LPSTR DNS_NAME;
  79. #endif
  80. //
  81. // DNS Text strings
  82. //
  83. #ifdef UNICODE
  84. typedef LPWSTR DNS_TEXT;
  85. #else
  86. typedef LPSTR DNS_TEXT;
  87. #endif
  88. //
  89. // Byte flipping macros
  90. //
  91. #define FlipUnalignedDword( pDword ) \
  92. (DWORD)ntohl( *(UNALIGNED DWORD *)(pDword) )
  93. #define FlipUnalignedWord( pWord ) \
  94. (WORD)ntohs( *(UNALIGNED WORD *)(pWord) )
  95. // Inline is faster, but NO side effects allowed in marco argument
  96. #define InlineFlipUnaligned48Bits( pch ) \
  97. ( ( *(PUCHAR)(pch) << 40 ) | \
  98. ( *((PUCHAR)(pch) + 1) << 32 ) | \
  99. ( *((PUCHAR)(pch) + 2) << 24 ) | \
  100. ( *((PUCHAR)(pch) + 3) << 16 ) | \
  101. ( *((PUCHAR)(pch) + 4) << 8 ) | \
  102. ( *((PUCHAR)(pch) + 5) ) )
  103. #define InlineFlipUnalignedDword( pch ) \
  104. ( ( *(PUCHAR)(pch) << 24 ) | \
  105. ( *((PUCHAR)(pch) + 1) << 16 ) | \
  106. ( *((PUCHAR)(pch) + 2) << 8 ) | \
  107. ( *((PUCHAR)(pch) + 3) ) )
  108. #define InlineFlipUnalignedWord( pch ) \
  109. ( ((WORD)*((PUCHAR)(pch)) << 8) + (WORD)*((PUCHAR)(pch) + 1) )
  110. //
  111. // Inline byte flipping -- can be done in registers
  112. //
  113. #define INLINE_WORD_FLIP(out, in) \
  114. { \
  115. WORD _in = (in); \
  116. (out) = (_in << 8) | (_in >> 8); \
  117. }
  118. #define INLINE_HTONS(out, in) INLINE_WORD_FLIP(out, in)
  119. #define INLINE_NTOHS(out, in) INLINE_WORD_FLIP(out, in)
  120. #define INLINE_DWORD_FLIP(out, in) \
  121. { \
  122. DWORD _in = (in); \
  123. (out) = ((_in << 8) & 0x00ff0000) | \
  124. (_in << 24) | \
  125. ((_in >> 8) & 0x0000ff00) | \
  126. (_in >> 24); \
  127. }
  128. #define INLINE_NTOHL(out, in) INLINE_DWORD_FLIP(out, in)
  129. #define INLINE_HTONL(out, in) INLINE_DWORD_FLIP(out, in)
  130. //
  131. // Inline byte flip and write to packet (unaligned)
  132. //
  133. #define INLINE_WRITE_FLIPPED_WORD( pout, in ) \
  134. INLINE_WORD_FLIP( *((UNALIGNED WORD *)(pout)), in )
  135. #define INLINE_WRITE_FLIPPED_DWORD( pout, in ) \
  136. INLINE_DWORD_FLIP( *((UNALIGNED DWORD *)(pout)), in )
  137. //
  138. // Unaligned write without flipping
  139. //
  140. #define WRITE_UNALIGNED_WORD( pout, word ) \
  141. ( *(UNALIGNED WORD *)(pout) = word )
  142. #define WRITE_UNALIGNED_DWORD( pout, dword ) \
  143. ( *(UNALIGNED DWORD *)(pout) = dword )
  144. //
  145. // Basic DNS definitions
  146. //
  147. //
  148. // DNS port for both UDP and TCP is 53.
  149. //
  150. #define DNS_PORT_HOST_ORDER (0x0035) // port 53
  151. #define DNS_PORT_NET_ORDER (0x3500)
  152. #define HOST_ORDER_DNS_PORT DNS_PORT_HOST_ORDER
  153. #define NET_ORDER_DNS_PORT DNS_PORT_NET_ORDER
  154. //
  155. // DNS UDP packets no more than 512 bytes
  156. //
  157. #define DNS_RFC_MAX_UDP_PACKET_LENGTH (512)
  158. // these are going away DO NOT USE!!!
  159. // 1472 is the maximum ethernet IP\UDP payload size
  160. // without causing fragmentation
  161. #define DNS_UDP_MAX_PACKET_LENGTH (512)
  162. #define DNS_CLASSICAL_UDP_MAX_PACKET_LENGTH (512)
  163. //
  164. // DNS Names limited to 255, 63 in any one label
  165. //
  166. #define DNS_MAX_NAME_LENGTH (255)
  167. #define DNS_MAX_LABEL_LENGTH (63)
  168. #define DNS_LABEL_CASE_BYTE_COUNT (8)
  169. #define DNS_MAX_NAME_BUFFER_LENGTH (256)
  170. #define DNS_NAME_BUFFER_LENGTH (256)
  171. #define DNS_LABEL_BUFFER_LENGTH (64)
  172. //
  173. // Reverse lookup domain names
  174. //
  175. #define DNS_REVERSE_DOMAIN_STRING ("in-addr.arpa.")
  176. #define DNS_MAX_REVERSE_NAME_LENGTH \
  177. (IP_ADDRESS_STRING_LENGTH+1+sizeof(DNS_REVERSE_DOMAIN_STRING))
  178. #define DNS_MAX_REVERSE_NAME_BUFFER_LENGTH \
  179. (DNS_MAX_REVERSE_NAME_LENGTH + 1)
  180. //
  181. // DNS Text string limited by size representable
  182. // in a single byte length field
  183. #define DNS_MAX_TEXT_STRING_LENGTH (255)
  184. //
  185. // DNS On-The-Wire Structures
  186. //
  187. #include <packon.h>
  188. //
  189. // DNS Message Header
  190. //
  191. typedef struct _DNS_HEADER
  192. {
  193. WORD Xid;
  194. BYTE RecursionDesired : 1;
  195. BYTE Truncation : 1;
  196. BYTE Authoritative : 1;
  197. BYTE Opcode : 4;
  198. BYTE IsResponse : 1;
  199. BYTE ResponseCode : 4;
  200. BYTE Broadcast : 1; // part of DNS reserved, use in WINS
  201. BYTE Reserved : 2;
  202. BYTE RecursionAvailable : 1;
  203. WORD QuestionCount;
  204. WORD AnswerCount;
  205. WORD NameServerCount;
  206. WORD AdditionalCount;
  207. }
  208. DNS_HEADER, *PDNS_HEADER;
  209. // Question immediately follows header so compressed question name
  210. // 0xC000 | sizeof(DNS_HEADER)
  211. #define DNS_COMPRESSED_QUESTION_NAME (0xC00C)
  212. //
  213. // Flags as WORD
  214. //
  215. #define DNS_HEADER_FLAGS(pHead) ( *((PWORD)(pHead)+1) )
  216. //
  217. // Swap count bytes
  218. // Include XID since our XID partitioning will be in host order.
  219. //
  220. #define SWAP_COUNT_BYTES(header) \
  221. { \
  222. PDNS_HEADER _head = (header); \
  223. INLINE_HTONS(_head->Xid, _head->Xid ); \
  224. INLINE_HTONS(_head->QuestionCount, _head->QuestionCount ); \
  225. INLINE_HTONS(_head->AnswerCount, _head->AnswerCount ); \
  226. INLINE_HTONS(_head->NameServerCount,_head->NameServerCount ); \
  227. INLINE_HTONS(_head->AdditionalCount,_head->AdditionalCount ); \
  228. }
  229. //
  230. // Question name follows header
  231. //
  232. #define DNS_OFFSET_TO_QUESTION_NAME sizeof(DNS_HEADER)
  233. //
  234. // Packet extraction macros
  235. //
  236. #define QUESTION_NAME_FROM_HEADER( _header_ ) \
  237. ( (PCHAR)( (PDNS_HEADER)(_header_) + 1 ) )
  238. #define ANSWER_FROM_QUESTION( _question_ ) \
  239. ( (PCHAR)( (PDNS_QUESTION)(_question_) + 1 ) )
  240. //
  241. // DNS Question
  242. //
  243. typedef struct _DNS_QUESTION
  244. {
  245. // Always preceeded by question name.
  246. WORD QuestionType;
  247. WORD QuestionClass;
  248. } DNS_QUESTION, *PDNS_QUESTION;
  249. //
  250. // DNS Resource Record
  251. //
  252. typedef struct _DNS_WIRE_RECORD
  253. {
  254. // Always preceded by an owner name.
  255. WORD RecordType;
  256. WORD RecordClass;
  257. DWORD TimeToLive;
  258. WORD ResourceDataLength;
  259. // Followed by resource data.
  260. } DNS_WIRE_RECORD, *PDNS_WIRE_RECORD;
  261. #include <packoff.h>
  262. //
  263. // DNS Query Types
  264. //
  265. #define DNS_OPCODE_QUERY 0 // Query
  266. #define DNS_OPCODE_IQUERY 1 // Obsolete: IP to name
  267. #define DNS_OPCODE_SERVER_STATUS 2 // Obsolete: DNS ping
  268. #define DNS_OPCODE_UNKNOWN 3 // Unknown
  269. #define DNS_OPCODE_NOTIFY 4 // Notify
  270. #define DNS_OPCODE_UPDATE 5 // Update
  271. //
  272. // DNS response codes.
  273. //
  274. // Sent in the "ResponseCode" field of a DNS_HEADER.
  275. //
  276. #define DNS_RCODE_NOERROR 0
  277. #define DNS_RCODE_FORMERR 1
  278. #define DNS_RCODE_SERVFAIL 2
  279. #define DNS_RCODE_NXDOMAIN 3
  280. #define DNS_RCODE_NOTIMPL 4
  281. #define DNS_RCODE_REFUSED 5
  282. #define DNS_RCODE_YXDOMAIN 6
  283. #define DNS_RCODE_YXRRSET 7
  284. #define DNS_RCODE_NXRRSET 8
  285. #define DNS_RCODE_NOTAUTH 9
  286. #define DNS_RCODE_NOTZONE 10
  287. #define DNS_RCODE_MAX 15
  288. #define DNS_RCODE_BADSIG 16
  289. #define DNS_RCODE_BADKEY 17
  290. #define DNS_RCODE_BADTIME 18
  291. #define DNS_EXTRCODE_BADSIG DNS_RCODE_BADSIG
  292. #define DNS_EXTRCODE_BADKEY DNS_RCODE_BADKEY
  293. #define DNS_EXTRCODE_BADTIME DNS_RCODE_BADTIME
  294. #define DNS_RCODE_NO_ERROR DNS_RCODE_NOERROR
  295. #define DNS_RCODE_FORMAT_ERROR DNS_RCODE_FORMERR
  296. #define DNS_RCODE_SERVER_FAILURE DNS_RCODE_SERVFAIL
  297. #define DNS_RCODE_NAME_ERROR DNS_RCODE_NXDOMAIN
  298. #define DNS_RCODE_NOT_IMPLEMENTED DNS_RCODE_NOTIMPL
  299. //
  300. // DNS Classes
  301. //
  302. // Classes are on the wire as WORDs.
  303. //
  304. // _CLASS_ defines in host order.
  305. // _RCLASS_ defines in net byte order.
  306. //
  307. // Generally we'll avoid byte flip and test class in net byte order.
  308. //
  309. #define DNS_CLASS_INTERNET 0x0001 // 1
  310. #define DNS_CLASS_CSNET 0x0002 // 2
  311. #define DNS_CLASS_CHAOS 0x0003 // 3
  312. #define DNS_CLASS_HESIOD 0x0004 // 4
  313. #define DNS_CLASS_NONE 0x00fe // 254
  314. #define DNS_CLASS_ALL 0x00ff // 255
  315. #define DNS_CLASS_ANY 0x00ff // 255
  316. #define DNS_RCLASS_INTERNET 0x0100 // 1
  317. #define DNS_RCLASS_CSNET 0x0200 // 2
  318. #define DNS_RCLASS_CHAOS 0x0300 // 3
  319. #define DNS_RCLASS_HESIOD 0x0400 // 4
  320. #define DNS_RCLASS_NONE 0xfe00 // 254
  321. #define DNS_RCLASS_ALL 0xff00 // 255
  322. #define DNS_RCLASS_ANY 0xff00 // 255
  323. //
  324. // DNS Record Types
  325. //
  326. // _TYPE_ defines are in host byte order.
  327. // _RTYPE_ defines are in net byte order.
  328. //
  329. // Generally always deal with types in host byte order as we index
  330. // resource record functions by type.
  331. //
  332. #define DNS_TYPE_ZERO 0x0000
  333. // RFC 1034/1035
  334. #define DNS_TYPE_A 0x0001 // 1
  335. #define DNS_TYPE_NS 0x0002 // 2
  336. #define DNS_TYPE_MD 0x0003 // 3
  337. #define DNS_TYPE_MF 0x0004 // 4
  338. #define DNS_TYPE_CNAME 0x0005 // 5
  339. #define DNS_TYPE_SOA 0x0006 // 6
  340. #define DNS_TYPE_MB 0x0007 // 7
  341. #define DNS_TYPE_MG 0x0008 // 8
  342. #define DNS_TYPE_MR 0x0009 // 9
  343. #define DNS_TYPE_NULL 0x000a // 10
  344. #define DNS_TYPE_WKS 0x000b // 11
  345. #define DNS_TYPE_PTR 0x000c // 12
  346. #define DNS_TYPE_HINFO 0x000d // 13
  347. #define DNS_TYPE_MINFO 0x000e // 14
  348. #define DNS_TYPE_MX 0x000f // 15
  349. #define DNS_TYPE_TEXT 0x0010 // 16
  350. // RFC 1183
  351. #define DNS_TYPE_RP 0x0011 // 17
  352. #define DNS_TYPE_AFSDB 0x0012 // 18
  353. #define DNS_TYPE_X25 0x0013 // 19
  354. #define DNS_TYPE_ISDN 0x0014 // 20
  355. #define DNS_TYPE_RT 0x0015 // 21
  356. // RFC 1348
  357. #define DNS_TYPE_NSAP 0x0016 // 22
  358. #define DNS_TYPE_NSAPPTR 0x0017 // 23
  359. // RFC 2065 (DNS security)
  360. #define DNS_TYPE_SIG 0x0018 // 24
  361. #define DNS_TYPE_KEY 0x0019 // 25
  362. // RFC 1664 (X.400 mail)
  363. #define DNS_TYPE_PX 0x001a // 26
  364. // RFC 1712 (Geographic position)
  365. #define DNS_TYPE_GPOS 0x001b // 27
  366. // RFC 1886 (IPv6 Address)
  367. #define DNS_TYPE_AAAA 0x001c // 28
  368. // RFC 1876 (Geographic location)
  369. #define DNS_TYPE_LOC 0x001d // 29
  370. // RFC 2065 (Secure negative response)
  371. #define DNS_TYPE_NXT 0x001e // 30
  372. // RFC 2052 (Service location)
  373. #define DNS_TYPE_SRV 0x0021 // 33
  374. // ATM Standard something-or-another
  375. #define DNS_TYPE_ATMA 0x0022 // 34
  376. //
  377. // Query only types (1035, 1995)
  378. //
  379. #define DNS_TYPE_TKEY 0x00f9 // 249
  380. #define DNS_TYPE_TSIG 0x00fa // 250
  381. #define DNS_TYPE_IXFR 0x00fb // 251
  382. #define DNS_TYPE_AXFR 0x00fc // 252
  383. #define DNS_TYPE_MAILB 0x00fd // 253
  384. #define DNS_TYPE_MAILA 0x00fe // 254
  385. #define DNS_TYPE_ALL 0x00ff // 255
  386. #define DNS_TYPE_ANY 0x00ff // 255
  387. //
  388. // Temp Microsoft types -- use until get IANA approval for real type
  389. //
  390. #define DNS_TYPE_WINS 0xff01 // 64K - 255
  391. #define DNS_TYPE_WINSR 0xff02 // 64K - 254
  392. #define DNS_TYPE_NBSTAT (DNS_TYPE_WINSR)
  393. //
  394. // DNS Record Types -- Net Byte Order
  395. //
  396. #define DNS_RTYPE_A 0x0100 // 1
  397. #define DNS_RTYPE_NS 0x0200 // 2
  398. #define DNS_RTYPE_MD 0x0300 // 3
  399. #define DNS_RTYPE_MF 0x0400 // 4
  400. #define DNS_RTYPE_CNAME 0x0500 // 5
  401. #define DNS_RTYPE_SOA 0x0600 // 6
  402. #define DNS_RTYPE_MB 0x0700 // 7
  403. #define DNS_RTYPE_MG 0x0800 // 8
  404. #define DNS_RTYPE_MR 0x0900 // 9
  405. #define DNS_RTYPE_NULL 0x0a00 // 10
  406. #define DNS_RTYPE_WKS 0x0b00 // 11
  407. #define DNS_RTYPE_PTR 0x0c00 // 12
  408. #define DNS_RTYPE_HINFO 0x0d00 // 13
  409. #define DNS_RTYPE_MINFO 0x0e00 // 14
  410. #define DNS_RTYPE_MX 0x0f00 // 15
  411. #define DNS_RTYPE_TEXT 0x1000 // 16
  412. // RFC 1183
  413. #define DNS_RTYPE_RP 0x1100 // 17
  414. #define DNS_RTYPE_AFSDB 0x1200 // 18
  415. #define DNS_RTYPE_X25 0x1300 // 19
  416. #define DNS_RTYPE_ISDN 0x1400 // 20
  417. #define DNS_RTYPE_RT 0x1500 // 21
  418. // RFC 1348
  419. #define DNS_RTYPE_NSAP 0x1600 // 22
  420. #define DNS_RTYPE_NSAPPTR 0x1700 // 23
  421. // RFC 2065 (DNS security)
  422. #define DNS_RTYPE_SIG 0x1800 // 24
  423. #define DNS_RTYPE_KEY 0x1900 // 25
  424. // RFC 1664 (X.400 mail)
  425. #define DNS_RTYPE_PX 0x1a00 // 26
  426. // RFC 1712 (Geographic position)
  427. #define DNS_RTYPE_GPOS 0x1b00 // 27
  428. // RFC 1886 (IPv6 Address)
  429. #define DNS_RTYPE_AAAA 0x1c00 // 28
  430. // RFC 1876 (Geographic location)
  431. #define DNS_RTYPE_LOC 0x1d00 // 29
  432. // RFC 2065 (Secure negative response)
  433. #define DNS_RTYPE_NXT 0x1e00 // 30
  434. // RFC 2052 (Service location)
  435. #define DNS_RTYPE_SRV 0x2100 // 33
  436. // ATM Standard something-or-another
  437. #define DNS_RTYPE_ATMA 0x2200 // 34
  438. //
  439. // Query only types (1035, 1995)
  440. //
  441. #define DNS_RTYPE_TKEY 0xf900 // 249
  442. #define DNS_RTYPE_TSIG 0xfa00 // 250
  443. #define DNS_RTYPE_IXFR 0xfb00 // 251
  444. #define DNS_RTYPE_AXFR 0xfc00 // 252
  445. #define DNS_RTYPE_MAILB 0xfd00 // 253
  446. #define DNS_RTYPE_MAILA 0xfe00 // 254
  447. #define DNS_RTYPE_ALL 0xff00 // 255
  448. #define DNS_RTYPE_ANY 0xff00 // 255
  449. //
  450. // Temp Microsoft types -- use until get IANA approval for real type
  451. //
  452. #define DNS_RTYPE_WINS 0x01ff // 64K - 255
  453. #define DNS_RTYPE_WINSR 0x02ff // 64K - 254
  454. //
  455. // Record type specific definitions
  456. //
  457. //
  458. // ATMA (ATM address type) formats
  459. //
  460. // Define these directly for any environment (ex NT4)
  461. // without winsock2 ATM support (ws2atm.h)
  462. //
  463. #ifndef ATMA_E164
  464. #define DNS_ATMA_FORMAT_E164 1
  465. #define DNS_ATMA_FORMAT_AESA 2
  466. #define DNS_ATMA_MAX_ADDR_LENGTH (20)
  467. #else
  468. #define DNS_ATMA_FORMAT_E164 ATM_E164
  469. #define DNS_ATMA_FORMAT_AESA ATM_AESA
  470. #define DNS_ATMA_MAX_ADDR_LENGTH ATM_ADDR_SIZE
  471. #endif
  472. #define DNS_ATMA_AESA_ADDR_LENGTH (20)
  473. #define DNS_ATMA_MAX_RECORD_LENGTH (DNS_ATMA_MAX_ADDR_LENGTH+1)
  474. //
  475. // DNSSEC defs
  476. //
  477. // DNSSEC algorithms
  478. #define DNSSEC_ALGORITHM_RSAMD5 1
  479. #define DNSSEC_ALGORITHM_NULL 253
  480. #define DNSSEC_ALGORITHM_PRIVATE 254
  481. // DNSSEC KEY protocol table
  482. #define DNSSEC_PROTOCOL_NONE 0
  483. #define DNSSEC_PROTOCOL_TLS 1
  484. #define DNSSEC_PROTOCOL_EMAIL 2
  485. #define DNSSEC_PROTOCOL_DNSSEC 3
  486. #define DNSSEC_PROTOCOL_IPSEC 4
  487. // DNSSEC KEY flag field
  488. #define DNSSEC_KEY_FLAG_NOAUTH 0x0001
  489. #define DNSSEC_KEY_FLAG_NOCONF 0x0002
  490. #define DNSSEC_KEY_FLAG_FLAG2 0x0004
  491. #define DNSSEC_KEY_FLAG_EXTEND 0x0008
  492. #define DNSSEC_KEY_FLAG_
  493. #define DNSSEC_KEY_FLAG_FLAG4 0x0010
  494. #define DNSSEC_KEY_FLAG_FLAG5 0x0020
  495. // bits 6,7 are name type
  496. #define DNSSEC_KEY_FLAG_USER 0x0000
  497. #define DNSSEC_KEY_FLAG_ZONE 0x0040
  498. #define DNSSEC_KEY_FLAG_HOST 0x0080
  499. #define DNSSEC_KEY_FLAG_NTPE3 0x00c0
  500. // bits 8-11 are reserved for future use
  501. #define DNSSEC_KEY_FLAG_FLAG8 0x0100
  502. #define DNSSEC_KEY_FLAG_FLAG9 0x0200
  503. #define DNSSEC_KEY_FLAG_FLAG10 0x0400
  504. #define DNSSEC_KEY_FLAG_FLAG11 0x0800
  505. // bits 12-15 are sig field
  506. #define DNSSEC_KEY_FLAG_SIG0 0x0000
  507. #define DNSSEC_KEY_FLAG_SIG1 0x1000
  508. #define DNSSEC_KEY_FLAG_SIG2 0x2000
  509. #define DNSSEC_KEY_FLAG_SIG3 0x3000
  510. #define DNSSEC_KEY_FLAG_SIG4 0x4000
  511. #define DNSSEC_KEY_FLAG_SIG5 0x5000
  512. #define DNSSEC_KEY_FLAG_SIG6 0x6000
  513. #define DNSSEC_KEY_FLAG_SIG7 0x7000
  514. #define DNSSEC_KEY_FLAG_SIG8 0x8000
  515. #define DNSSEC_KEY_FLAG_SIG9 0x9000
  516. #define DNSSEC_KEY_FLAG_SIG10 0xa000
  517. #define DNSSEC_KEY_FLAG_SIG11 0xb000
  518. #define DNSSEC_KEY_FLAG_SIG12 0xc000
  519. #define DNSSEC_KEY_FLAG_SIG13 0xd000
  520. #define DNSSEC_KEY_FLAG_SIG14 0xe000
  521. #define DNSSEC_KEY_FLAG_SIG15 0xf000
  522. //
  523. // TKEY modes
  524. //
  525. #define DNS_TKEY_MODE_SERVER_ASSIGN 1
  526. #define DNS_TKEY_MODE_DIFFIE_HELLMAN 2
  527. #define DNS_TKEY_MODE_GSS 3
  528. #define DNS_TKEY_MODE_RESOLVER_ASSIGN 4
  529. //
  530. // WINS + NBSTAT flag field
  531. //
  532. #define DNS_WINS_FLAG_SCOPE (0x80000000)
  533. #define DNS_WINS_FLAG_LOCAL (0x00010000)
  534. //
  535. // NT4
  536. //
  537. #ifdef DNSNT4
  538. // Sundown types
  539. #define UINT_PTR DWORD
  540. #define ULONG_PTR DWORD
  541. #define DWORD_PTR DWORD
  542. #define LONG_PTR LONG
  543. #define INT_PTR LONG
  544. //
  545. // DNS API Errors / Status Codes
  546. //
  547. // For NT5 DNS error\status codes shared by DNS API or RPC interface are in
  548. // winerror.h
  549. //
  550. #define DNS_ERROR_MASK 0xcc000000
  551. //
  552. // Response codes mapped to non-colliding errors
  553. //
  554. // Leave the first 4K of space for this in the assumption that DNS
  555. // RCODEs may be greatly expanded in some future E-DNS.
  556. //
  557. #define DNS_ERROR_RCODE_NO_ERROR ERROR_SUCCESS
  558. #define DNS_ERROR_RCODE_FORMAT_ERROR ( DNS_ERROR_MASK | DNS_RCODE_FORMAT_ERROR )
  559. #define DNS_ERROR_RCODE_SERVER_FAILURE ( DNS_ERROR_MASK | DNS_RCODE_SERVER_FAILURE )
  560. #define DNS_ERROR_RCODE_NAME_ERROR ( DNS_ERROR_MASK | DNS_RCODE_NAME_ERROR )
  561. #define DNS_ERROR_RCODE_NOT_IMPLEMENTED ( DNS_ERROR_MASK | DNS_RCODE_NOT_IMPLEMENTED )
  562. #define DNS_ERROR_RCODE_REFUSED ( DNS_ERROR_MASK | DNS_RCODE_REFUSED )
  563. #define DNS_ERROR_RCODE_YXDOMAIN ( DNS_ERROR_MASK | DNS_RCODE_YXDOMAIN )
  564. #define DNS_ERROR_RCODE_YXRRSET ( DNS_ERROR_MASK | DNS_RCODE_YXRRSET )
  565. #define DNS_ERROR_RCODE_NXRRSET ( DNS_ERROR_MASK | DNS_RCODE_NXRRSET )
  566. #define DNS_ERROR_RCODE_NOTAUTH ( DNS_ERROR_MASK | DNS_RCODE_NOTAUTH )
  567. #define DNS_ERROR_RCODE_NOTZONE ( DNS_ERROR_MASK | DNS_RCODE_NOTZONE )
  568. // Extended TSIG\TKEY RCODEs
  569. #define DNS_ERROR_RCODE_BADSIG ( DNS_ERROR_MASK | DNS_EXTRCODE_BADSIG )
  570. #define DNS_ERROR_RCODE_BADKEY ( DNS_ERROR_MASK | DNS_EXTRCODE_BADKEY )
  571. #define DNS_ERROR_RCODE_BADTIME ( DNS_ERROR_MASK | DNS_EXTRCODE_BADTIME )
  572. #define DNS_ERROR_RCODE_LAST DNS_ERROR_RCODE_BADTIME
  573. //
  574. // Packet format
  575. //
  576. #define DNS_INFO_NO_RECORDS 0x4c000030
  577. #define DNS_ERROR_BAD_PACKET 0xcc000031
  578. #define DNS_ERROR_NO_PACKET 0xcc000032
  579. #define DNS_ERROR_RCODE 0xcc000033
  580. #define DNS_STATUS_PACKET_UNSECURE 0xcc000034
  581. #define DNS_ERROR_UNSECURE_PACKET 0xcc000034
  582. //
  583. // General API errors
  584. //
  585. #define DNS_ERROR_NO_MEMORY ERROR_OUTOFMEMORY
  586. #define DNS_ERROR_INVALID_NAME ERROR_INVALID_NAME
  587. #define DNS_ERROR_INVALID_DATA ERROR_INVALID_DATA
  588. #define DNS_ERROR_INVALID_TYPE 0xcc000051
  589. #define DNS_ERROR_INVALID_IP_ADDRESS 0xcc000052
  590. #define DNS_ERROR_INVALID_PROPERTY 0xcc000053
  591. #define DNS_ERROR_TRY_AGAIN_LATER 0xcc000054
  592. #define DNS_ERROR_NOT_UNIQUE 0xcc000055
  593. #define DNS_ERROR_NON_RFC_NAME 0xcc000056
  594. #define DNS_STATUS_FQDN 0x4c000101
  595. #define DNS_STATUS_DOTTED_NAME 0x4c000102
  596. #define DNS_STATUS_SINGLE_PART_NAME 0x4c000103
  597. //
  598. // Zone errors
  599. //
  600. #define DNS_ERROR_ZONE_DOES_NOT_EXIST 0xcc000101
  601. #define DNS_ERROR_NO_ZONE_INFO 0xcc000102
  602. #define DNS_ERROR_INVALID_ZONE_OPERATION 0xcc000103
  603. #define DNS_ERROR_ZONE_CONFIGURATION_ERROR 0xcc000104
  604. #define DNS_ERROR_ZONE_HAS_NO_SOA_RECORD 0xcc000105
  605. #define DNS_ERROR_ZONE_HAS_NO_NS_RECORDS 0xcc000106
  606. #define DNS_ERROR_ZONE_LOCKED 0xcc000107
  607. #define DNS_ERROR_ZONE_CREATION_FAILED 0xcc000110
  608. #define DNS_ERROR_ZONE_ALREADY_EXISTS 0xcc000111
  609. #define DNS_ERROR_AUTOZONE_ALREADY_EXISTS 0xcc000112
  610. #define DNS_ERROR_INVALID_ZONE_TYPE 0xcc000113
  611. #define DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP 0xcc000114
  612. #define DNS_ERROR_ZONE_NOT_SECONDARY 0xcc000120
  613. #define DNS_ERROR_NEED_SECONDARY_ADDRESSES 0xcc000121
  614. #define DNS_ERROR_WINS_INIT_FAILED 0xcc000122
  615. #define DNS_ERROR_NEED_WINS_SERVERS 0xcc000123
  616. #define DNS_ERROR_NBSTAT_INIT_FAILED 0xcc000124
  617. #define DNS_ERROR_SOA_DELETE_INVALID 0xcc000125
  618. //
  619. // Datafile errors
  620. //
  621. #define DNS_ERROR_PRIMARY_REQUIRES_DATAFILE 0xcc000201
  622. #define DNS_ERROR_INVALID_DATAFILE_NAME 0xcc000202
  623. #define DNS_ERROR_DATAFILE_OPEN_FAILURE 0xcc000203
  624. #define DNS_ERROR_FILE_WRITEBACK_FAILED 0xcc000204
  625. #define DNS_ERROR_DATAFILE_PARSING 0xcc000205
  626. //
  627. // Database errors
  628. //
  629. #define DNS_ERROR_RECORD_DOES_NOT_EXIST 0xcc000300
  630. #define DNS_ERROR_RECORD_FORMAT 0xcc000301
  631. #define DNS_ERROR_NODE_CREATION_FAILED 0xcc000302
  632. #define DNS_ERROR_UNKNOWN_RECORD_TYPE 0xcc000303
  633. #define DNS_ERROR_RECORD_TIMED_OUT 0xcc000304
  634. #define DNS_ERROR_NAME_NOT_IN_ZONE 0xcc000305
  635. #define DNS_ERROR_CNAME_LOOP 0xcc000306
  636. #define DNS_ERROR_NODE_IS_CNAME 0xcc000307
  637. #define DNS_ERROR_CNAME_COLLISION 0xcc000308
  638. #define DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT 0xcc000309
  639. #define DNS_ERROR_RECORD_ALREADY_EXISTS 0xcc000310
  640. #define DNS_ERROR_SECONDARY_DATA 0xcc000311
  641. #define DNS_ERROR_NO_CREATE_CACHE_DATA 0xcc000312
  642. #define DNS_ERROR_NAME_DOES_NOT_EXIST 0xcc000313
  643. #define DNS_WARNING_PTR_CREATE_FAILED 0x8c000332
  644. #define DNS_WARNING_DOMAIN_UNDELETED 0x8c000333
  645. #define DNS_ERROR_DS_UNAVAILABLE 0xcc000340
  646. #define DNS_ERROR_DS_ZONE_ALREADY_EXISTS 0xcc000341
  647. #define DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE 0xcc000342
  648. //
  649. // Operation errors
  650. //
  651. #define DNS_INFO_AXFR_COMPLETE 0x4c000403
  652. #define DNS_ERROR_AXFR 0xcc000404
  653. #define DNS_INFO_ADDED_LOCAL_WINS 0x4c000405
  654. // Secure update
  655. #define DNS_STATUS_CONTINUE_NEEDED 0x4c000406
  656. //
  657. // Setup errors
  658. //
  659. #define DNS_ERROR_NO_TCPIP 0xcc000501
  660. #define DNS_ERROR_NO_DNS_SERVERS 0xcc000502
  661. #endif // NT4
  662. //
  663. // Helpful checks
  664. //
  665. #define VALID_USER_MEMORY(p) ( (DWORD)(p) < 0x80000000 )
  666. #define IS_DWORD_ALIGNED(p) ( !((DWORD_PTR)(p) & (DWORD_PTR)3) )
  667. #ifdef __cplusplus
  668. }
  669. #endif // __cplusplus
  670. #endif // _DNS_INCLUDED_