forked from gentilkiwi/mimikatz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinDNS.h
2230 lines (1796 loc) · 56.2 KB
/
WinDNS.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*++
Copyright (c) 1996-2005 Microsoft Corporation
Module Name:
windns.h
Abstract:
Domain Name System (DNS)
DNS definitions and DNS API.
Author:
Jim Gilroy (jamesg) December 7, 1996
Revision History:
--*/
#ifndef _WINDNS_INCLUDED_
#define _WINDNS_INCLUDED_
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
//
// Define QWORD -- not yet defined globally
//
typedef unsigned __int64 QWORD, *PQWORD;
//
// DNS public types
//
typedef __success(return == 0) LONG DNS_STATUS;
typedef DNS_STATUS *PDNS_STATUS;
//
// IP Address
//
typedef DWORD IP4_ADDRESS, *PIP4_ADDRESS;
#define SIZEOF_IP4_ADDRESS (4)
#define IP4_ADDRESS_STRING_LENGTH (16)
// Backcompat only -- length def contains terminating NULL
#define IP4_ADDRESS_STRING_BUFFER_LENGTH (16)
//
// IP Address Array type
//
typedef struct _IP4_ARRAY
{
DWORD AddrCount;
#ifdef MIDL_PASS
[size_is( AddrCount )] IP4_ADDRESS AddrArray[];
#else
IP4_ADDRESS AddrArray[1];
#endif
}
IP4_ARRAY, *PIP4_ARRAY;
//
// IPv6 Address
//
#ifdef MIDL_PASS
#ifdef _WIN64
#pragma pack(push, 8)
#else
#pragma pack(push, 4)
#endif
typedef struct
{
QWORD IP6Qword[2];
}
IP6_ADDRESS, *PIP6_ADDRESS;
#pragma pack(pop)
#else // MIDL_PASS
typedef union
{
#ifdef _WIN64
QWORD IP6Qword[2];
#endif
DWORD IP6Dword[4];
WORD IP6Word[8];
BYTE IP6Byte[16];
#ifdef IN6_ADDR
IN6_ADDR In6;
#endif
}
IP6_ADDRESS, *PIP6_ADDRESS;
#endif // MIDL_PASS
//
// IP6 string max is 45 bytes
// - 6 WORDs in colon+hex (5 chars)
// - last DWORD as IP4 (15 chars)
// but include
// - 11 bytes for scope ID
// - 6 bytes for port (inc. colon)
// - two bytes to bracket address with port
// - terminating NULL
//
// Note: this is a change to previous def, but a single
// definition continaing space for ALL possible IPv6
// address strings, we elminate many possible errors
#undef IP6_ADDRESS_STRING_LENGTH
#define IP6_ADDRESS_STRING_LENGTH (65)
#define IP6_ADDRESS_STRING_BUFFER_LENGTH (65)
//
// IP4/IP6 combined maximum
//
#define DNS_ADDRESS_STRING_LENGTH (IP6_ADDRESS_STRING_LENGTH)
//
// Inline byte flipping -- can be done in registers
//
#define INLINE_WORD_FLIP(out, in) \
{ \
WORD _in = (in); \
(out) = (_in << 8) | (_in >> 8); \
}
#define INLINE_HTONS(out, in) INLINE_WORD_FLIP(out, in)
#define INLINE_NTOHS(out, in) INLINE_WORD_FLIP(out, in)
#define INLINE_DWORD_FLIP(out, in) \
{ \
DWORD _in = (in); \
(out) = ((_in << 8) & 0x00ff0000) | \
(_in << 24) | \
((_in >> 8) & 0x0000ff00) | \
(_in >> 24); \
}
#define INLINE_NTOHL(out, in) INLINE_DWORD_FLIP(out, in)
#define INLINE_HTONL(out, in) INLINE_DWORD_FLIP(out, in)
//
// Inline byte flip and write to packet (unaligned)
//
#define INLINE_WRITE_FLIPPED_WORD( pout, in ) \
INLINE_WORD_FLIP( *((UNALIGNED WORD *)(pout)), in )
#define INLINE_WRITE_FLIPPED_DWORD( pout, in ) \
INLINE_DWORD_FLIP( *((UNALIGNED DWORD *)(pout)), in )
//
// Basic DNS definitions
//
//
// DNS port for both UDP and TCP is 53.
//
#define DNS_PORT_HOST_ORDER (0x0035) // port 53
#define DNS_PORT_NET_ORDER (0x3500)
//
// DNS UDP packets no more than 512 bytes
//
#define DNS_RFC_MAX_UDP_PACKET_LENGTH (512)
//
// DNS Names limited to 255, 63 in any one label
//
#define DNS_MAX_NAME_LENGTH (255)
#define DNS_MAX_LABEL_LENGTH (63)
#define DNS_MAX_NAME_BUFFER_LENGTH (256)
#define DNS_MAX_LABEL_BUFFER_LENGTH (64)
//
// Reverse lookup domain names
//
#define DNS_IP4_REVERSE_DOMAIN_STRING_A ("in-addr.arpa.")
#define DNS_IP4_REVERSE_DOMAIN_STRING_W (L"in-addr.arpa.")
#define DNS_MAX_IP4_REVERSE_NAME_LENGTH (IP4_ADDRESS_STRING_LENGTH+15)
//(IP4_ADDRESS_STRING_LENGTH+1+sizeof(DNS_IP4_REVERSE_DOMAIN_STRING_A))
#define DNS_IP6_REVERSE_DOMAIN_STRING_A ("ip6.arpa.")
#define DNS_IP6_REVERSE_DOMAIN_STRING_W (L"ip6.arpa.")
#define DNS_MAX_IP6_REVERSE_NAME_LENGTH (75)
//(64+sizeof(DNS_IP6_REVERSE_DOMAIN_STRING_A))
// Combined
#define DNS_MAX_REVERSE_NAME_LENGTH DNS_MAX_IP6_REVERSE_NAME_LENGTH
#ifdef UNICODE
#define DNS_IP4_REVERSE_DOMAIN_STRING DNS_IP4_REVERSE_DOMAIN_STRING_W
#define DNS_IP6_REVERSE_DOMAIN_STRING DNS_IP6_REVERSE_DOMAIN_STRING_W
#else
#define DNS_IP4_REVERSE_DOMAIN_STRING DNS_IP4_REVERSE_DOMAIN_STRING_A
#define DNS_IP6_REVERSE_DOMAIN_STRING DNS_IP6_REVERSE_DOMAIN_STRING_A
#endif
//
// Backcompat only -- name def contains terminating NULL
//
#define DNS_MAX_IP4_REVERSE_NAME_BUFFER_LENGTH DNS_MAX_IP4_REVERSE_NAME_LENGTH
#define DNS_MAX_IP6_REVERSE_NAME_BUFFER_LENGTH DNS_MAX_IP6_REVERSE_NAME_LENGTH
#define DNS_MAX_REVERSE_NAME_BUFFER_LENGTH DNS_MAX_REVERSE_NAME_LENGTH
//
// DNS Text string limited by size representable
// in a single byte length field
#define DNS_MAX_TEXT_STRING_LENGTH (255)
//
// DNS On-The-Wire Structures
//
#pragma pack(push, 1)
//
// DNS Message Header
//
typedef struct _DNS_HEADER
{
WORD Xid;
BYTE RecursionDesired : 1;
BYTE Truncation : 1;
BYTE Authoritative : 1;
BYTE Opcode : 4;
BYTE IsResponse : 1;
BYTE ResponseCode : 4;
BYTE CheckingDisabled : 1;
BYTE AuthenticatedData : 1;
BYTE Reserved : 1;
BYTE RecursionAvailable : 1;
WORD QuestionCount;
WORD AnswerCount;
WORD NameServerCount;
WORD AdditionalCount;
}
DNS_HEADER, *PDNS_HEADER;
typedef struct _DNS_HEADER_EXT
{
WORD Reserved : 15;
WORD DnssecOk : 1;
BYTE chRcode;
BYTE chVersion;
}
DNS_HEADER_EXT, *PDNS_HEADER_EXT;
//
// Flags as WORD
//
#define DNS_HEADER_FLAGS(pHead) ( *((PWORD)(pHead)+1) )
//
// Byte flip DNS header to\from host order.
//
// Note that this does NOT flip flags, as definition above defines
// flags as individual bytes for direct access to net byte order.
//
#define DNS_BYTE_FLIP_HEADER_COUNTS(pHeader) \
{ \
PDNS_HEADER _head = (pHeader); \
INLINE_HTONS(_head->Xid, _head->Xid ); \
INLINE_HTONS(_head->QuestionCount, _head->QuestionCount ); \
INLINE_HTONS(_head->AnswerCount, _head->AnswerCount ); \
INLINE_HTONS(_head->NameServerCount,_head->NameServerCount ); \
INLINE_HTONS(_head->AdditionalCount,_head->AdditionalCount ); \
}
//
// Question name follows header
//
#define DNS_OFFSET_TO_QUESTION_NAME sizeof(DNS_HEADER)
//
// Question immediately follows header so compressed question name
// 0xC000 | sizeof(DNS_HEADER)
#define DNS_COMPRESSED_QUESTION_NAME (0xC00C)
//
// Packet extraction macros
//
#define DNS_QUESTION_NAME_FROM_HEADER( _pHeader_ ) \
( (PCHAR)( (PDNS_HEADER)(_pHeader_) + 1 ) )
#define DNS_ANSWER_FROM_QUESTION( _pQuestion_ ) \
( (PCHAR)( (PDNS_QUESTION)(_pQuestion_) + 1 ) )
//
// DNS Question
//
typedef struct _DNS_WIRE_QUESTION
{
// Preceded by question name
WORD QuestionType;
WORD QuestionClass;
}
DNS_WIRE_QUESTION, *PDNS_WIRE_QUESTION;
//
// DNS Resource Record
//
typedef struct _DNS_WIRE_RECORD
{
// Preceded by record owner name
WORD RecordType;
WORD RecordClass;
DWORD TimeToLive;
WORD DataLength;
// Followed by record data
}
DNS_WIRE_RECORD, *PDNS_WIRE_RECORD;
#pragma pack(pop)
//
// DNS Query Types
//
#define DNS_OPCODE_QUERY 0 // Query
#define DNS_OPCODE_IQUERY 1 // Obsolete: IP to name
#define DNS_OPCODE_SERVER_STATUS 2 // Obsolete: DNS ping
#define DNS_OPCODE_UNKNOWN 3 // Unknown
#define DNS_OPCODE_NOTIFY 4 // Notify
#define DNS_OPCODE_UPDATE 5 // Dynamic Update
//
// DNS response codes.
//
// Sent in the "ResponseCode" field of a DNS_HEADER.
//
#define DNS_RCODE_NOERROR 0
#define DNS_RCODE_FORMERR 1 // Format error
#define DNS_RCODE_SERVFAIL 2 // Server failure
#define DNS_RCODE_NXDOMAIN 3 // Name error
#define DNS_RCODE_NOTIMPL 4 // Not implemented
#define DNS_RCODE_REFUSED 5 // Refused
#define DNS_RCODE_YXDOMAIN 6 // Domain name should not exist
#define DNS_RCODE_YXRRSET 7 // RR set should not exist
#define DNS_RCODE_NXRRSET 8 // RR set does not exist
#define DNS_RCODE_NOTAUTH 9 // Not authoritative for zone
#define DNS_RCODE_NOTZONE 10 // Name is not zone
#define DNS_RCODE_MAX 15
//
// Extended RCODEs
//
#define DNS_RCODE_BADVERS 16 // Bad EDNS version
#define DNS_RCODE_BADSIG 16 // Bad signature
#define DNS_RCODE_BADKEY 17 // Bad key
#define DNS_RCODE_BADTIME 18 // Bad timestamp
//
// Mappings to friendly names
//
#define DNS_RCODE_NO_ERROR DNS_RCODE_NOERROR
#define DNS_RCODE_FORMAT_ERROR DNS_RCODE_FORMERR
#define DNS_RCODE_SERVER_FAILURE DNS_RCODE_SERVFAIL
#define DNS_RCODE_NAME_ERROR DNS_RCODE_NXDOMAIN
#define DNS_RCODE_NOT_IMPLEMENTED DNS_RCODE_NOTIMPL
//
// DNS Classes
//
// Classes are on the wire as WORDs.
//
// _CLASS_ defines in host order.
// _RCLASS_ defines in net byte order.
//
// Generally we'll avoid byte flip and test class in net byte order.
//
#define DNS_CLASS_INTERNET 0x0001 // 1
#define DNS_CLASS_CSNET 0x0002 // 2
#define DNS_CLASS_CHAOS 0x0003 // 3
#define DNS_CLASS_HESIOD 0x0004 // 4
#define DNS_CLASS_NONE 0x00fe // 254
#define DNS_CLASS_ALL 0x00ff // 255
#define DNS_CLASS_ANY 0x00ff // 255
#define DNS_RCLASS_INTERNET 0x0100 // 1
#define DNS_RCLASS_CSNET 0x0200 // 2
#define DNS_RCLASS_CHAOS 0x0300 // 3
#define DNS_RCLASS_HESIOD 0x0400 // 4
#define DNS_RCLASS_NONE 0xfe00 // 254
#define DNS_RCLASS_ALL 0xff00 // 255
#define DNS_RCLASS_ANY 0xff00 // 255
//
// DNS Record Types
//
// _TYPE_ defines are in host byte order.
// _RTYPE_ defines are in net byte order.
//
// Generally always deal with types in host byte order as we index
// resource record functions by type.
//
#define DNS_TYPE_ZERO 0x0000
// RFC 1034/1035
#define DNS_TYPE_A 0x0001 // 1
#define DNS_TYPE_NS 0x0002 // 2
#define DNS_TYPE_MD 0x0003 // 3
#define DNS_TYPE_MF 0x0004 // 4
#define DNS_TYPE_CNAME 0x0005 // 5
#define DNS_TYPE_SOA 0x0006 // 6
#define DNS_TYPE_MB 0x0007 // 7
#define DNS_TYPE_MG 0x0008 // 8
#define DNS_TYPE_MR 0x0009 // 9
#define DNS_TYPE_NULL 0x000a // 10
#define DNS_TYPE_WKS 0x000b // 11
#define DNS_TYPE_PTR 0x000c // 12
#define DNS_TYPE_HINFO 0x000d // 13
#define DNS_TYPE_MINFO 0x000e // 14
#define DNS_TYPE_MX 0x000f // 15
#define DNS_TYPE_TEXT 0x0010 // 16
// RFC 1183
#define DNS_TYPE_RP 0x0011 // 17
#define DNS_TYPE_AFSDB 0x0012 // 18
#define DNS_TYPE_X25 0x0013 // 19
#define DNS_TYPE_ISDN 0x0014 // 20
#define DNS_TYPE_RT 0x0015 // 21
// RFC 1348
#define DNS_TYPE_NSAP 0x0016 // 22
#define DNS_TYPE_NSAPPTR 0x0017 // 23
// RFC 2065 (DNS security)
#define DNS_TYPE_SIG 0x0018 // 24
#define DNS_TYPE_KEY 0x0019 // 25
// RFC 1664 (X.400 mail)
#define DNS_TYPE_PX 0x001a // 26
// RFC 1712 (Geographic position)
#define DNS_TYPE_GPOS 0x001b // 27
// RFC 1886 (IPv6 Address)
#define DNS_TYPE_AAAA 0x001c // 28
// RFC 1876 (Geographic location)
#define DNS_TYPE_LOC 0x001d // 29
// RFC 2065 (Secure negative response)
#define DNS_TYPE_NXT 0x001e // 30
// Patton (Endpoint Identifier)
#define DNS_TYPE_EID 0x001f // 31
// Patton (Nimrod Locator)
#define DNS_TYPE_NIMLOC 0x0020 // 32
// RFC 2052 (Service location)
#define DNS_TYPE_SRV 0x0021 // 33
// ATM Standard something-or-another (ATM Address)
#define DNS_TYPE_ATMA 0x0022 // 34
// RFC 2168 (Naming Authority Pointer)
#define DNS_TYPE_NAPTR 0x0023 // 35
// RFC 2230 (Key Exchanger)
#define DNS_TYPE_KX 0x0024 // 36
// RFC 2538 (CERT)
#define DNS_TYPE_CERT 0x0025 // 37
// A6 Draft (A6)
#define DNS_TYPE_A6 0x0026 // 38
// DNAME Draft (DNAME)
#define DNS_TYPE_DNAME 0x0027 // 39
// Eastlake (Kitchen Sink)
#define DNS_TYPE_SINK 0x0028 // 40
// RFC 2671 (EDNS OPT)
#define DNS_TYPE_OPT 0x0029 // 41
// RFC 4034 (DNSSEC DS)
#define DNS_TYPE_DS 0x002b // 43
// RFC 4034 (DNSSEC RRSIG)
#define DNS_TYPE_RRSIG 0x002e // 46
// RFC 4034 (DNSSEC NSEC)
#define DNS_TYPE_NSEC 0x002f // 47
// RFC 4034 (DNSSEC DNSKEY)
#define DNS_TYPE_DNSKEY 0x0030 // 48
// RFC 4701 (DHCID)
#define DNS_TYPE_DHCID 0x0031 // 49
//
// IANA Reserved
//
#define DNS_TYPE_UINFO 0x0064 // 100
#define DNS_TYPE_UID 0x0065 // 101
#define DNS_TYPE_GID 0x0066 // 102
#define DNS_TYPE_UNSPEC 0x0067 // 103
//
// Query only types (1035, 1995)
// - Crawford (ADDRS)
// - TKEY draft (TKEY)
// - TSIG draft (TSIG)
// - RFC 1995 (IXFR)
// - RFC 1035 (AXFR up)
//
#define DNS_TYPE_ADDRS 0x00f8 // 248
#define DNS_TYPE_TKEY 0x00f9 // 249
#define DNS_TYPE_TSIG 0x00fa // 250
#define DNS_TYPE_IXFR 0x00fb // 251
#define DNS_TYPE_AXFR 0x00fc // 252
#define DNS_TYPE_MAILB 0x00fd // 253
#define DNS_TYPE_MAILA 0x00fe // 254
#define DNS_TYPE_ALL 0x00ff // 255
#define DNS_TYPE_ANY 0x00ff // 255
//
// Temp Microsoft types -- use until get IANA approval for real type
//
#define DNS_TYPE_WINS 0xff01 // 64K - 255
#define DNS_TYPE_WINSR 0xff02 // 64K - 254
#define DNS_TYPE_NBSTAT (DNS_TYPE_WINSR)
//
// DNS Record Types -- Net Byte Order
//
#define DNS_RTYPE_A 0x0100 // 1
#define DNS_RTYPE_NS 0x0200 // 2
#define DNS_RTYPE_MD 0x0300 // 3
#define DNS_RTYPE_MF 0x0400 // 4
#define DNS_RTYPE_CNAME 0x0500 // 5
#define DNS_RTYPE_SOA 0x0600 // 6
#define DNS_RTYPE_MB 0x0700 // 7
#define DNS_RTYPE_MG 0x0800 // 8
#define DNS_RTYPE_MR 0x0900 // 9
#define DNS_RTYPE_NULL 0x0a00 // 10
#define DNS_RTYPE_WKS 0x0b00 // 11
#define DNS_RTYPE_PTR 0x0c00 // 12
#define DNS_RTYPE_HINFO 0x0d00 // 13
#define DNS_RTYPE_MINFO 0x0e00 // 14
#define DNS_RTYPE_MX 0x0f00 // 15
#define DNS_RTYPE_TEXT 0x1000 // 16
#define DNS_RTYPE_RP 0x1100 // 17
#define DNS_RTYPE_AFSDB 0x1200 // 18
#define DNS_RTYPE_X25 0x1300 // 19
#define DNS_RTYPE_ISDN 0x1400 // 20
#define DNS_RTYPE_RT 0x1500 // 21
#define DNS_RTYPE_NSAP 0x1600 // 22
#define DNS_RTYPE_NSAPPTR 0x1700 // 23
#define DNS_RTYPE_SIG 0x1800 // 24
#define DNS_RTYPE_KEY 0x1900 // 25
#define DNS_RTYPE_PX 0x1a00 // 26
#define DNS_RTYPE_GPOS 0x1b00 // 27
#define DNS_RTYPE_AAAA 0x1c00 // 28
#define DNS_RTYPE_LOC 0x1d00 // 29
#define DNS_RTYPE_NXT 0x1e00 // 30
#define DNS_RTYPE_EID 0x1f00 // 31
#define DNS_RTYPE_NIMLOC 0x2000 // 32
#define DNS_RTYPE_SRV 0x2100 // 33
#define DNS_RTYPE_ATMA 0x2200 // 34
#define DNS_RTYPE_NAPTR 0x2300 // 35
#define DNS_RTYPE_KX 0x2400 // 36
#define DNS_RTYPE_CERT 0x2500 // 37
#define DNS_RTYPE_A6 0x2600 // 38
#define DNS_RTYPE_DNAME 0x2700 // 39
#define DNS_RTYPE_SINK 0x2800 // 40
#define DNS_RTYPE_OPT 0x2900 // 41
#define DNS_RTYPE_DS 0x2b00 // 43
#define DNS_RTYPE_RRSIG 0x2e00 // 46
#define DNS_RTYPE_NSEC 0x2f00 // 47
#define DNS_RTYPE_DNSKEY 0x3000 // 48
#define DNS_RTYPE_DHCID 0x3100 // 49
//
// IANA Reserved
//
#define DNS_RTYPE_UINFO 0x6400 // 100
#define DNS_RTYPE_UID 0x6500 // 101
#define DNS_RTYPE_GID 0x6600 // 102
#define DNS_RTYPE_UNSPEC 0x6700 // 103
//
// Query only types
//
#define DNS_RTYPE_TKEY 0xf900 // 249
#define DNS_RTYPE_TSIG 0xfa00 // 250
#define DNS_RTYPE_IXFR 0xfb00 // 251
#define DNS_RTYPE_AXFR 0xfc00 // 252
#define DNS_RTYPE_MAILB 0xfd00 // 253
#define DNS_RTYPE_MAILA 0xfe00 // 254
#define DNS_RTYPE_ALL 0xff00 // 255
#define DNS_RTYPE_ANY 0xff00 // 255
//
// Temp Microsoft types -- use until get IANA approval for real type
//
#define DNS_RTYPE_WINS 0x01ff // 64K - 255
#define DNS_RTYPE_WINSR 0x02ff // 64K - 254
//
// Record type specific definitions
//
//
// ATMA (ATM address type) formats
//
// Define these directly for any environment (ex NT4)
// without winsock2 ATM support (ws2atm.h)
//
#ifndef ATMA_E164
#define DNS_ATMA_FORMAT_E164 1
#define DNS_ATMA_FORMAT_AESA 2
#define DNS_ATMA_MAX_ADDR_LENGTH (20)
#else
#define DNS_ATMA_FORMAT_E164 ATM_E164
#define DNS_ATMA_FORMAT_AESA ATM_AESA
#define DNS_ATMA_MAX_ADDR_LENGTH ATM_ADDR_SIZE
#endif
#define DNS_ATMA_AESA_ADDR_LENGTH (20)
#define DNS_ATMA_MAX_RECORD_LENGTH (DNS_ATMA_MAX_ADDR_LENGTH+1)
//
// DNSSEC defs
//
// DNSSEC algorithms
#define DNSSEC_ALGORITHM_RSAMD5 1
#define DNSSEC_ALGORITHM_RSASHA1 5
#define DNSSEC_ALGORITHM_NULL 253
#define DNSSEC_ALGORITHM_PRIVATE 254
// DNSSEC KEY protocol table
#define DNSSEC_PROTOCOL_NONE 0
#define DNSSEC_PROTOCOL_TLS 1
#define DNSSEC_PROTOCOL_EMAIL 2
#define DNSSEC_PROTOCOL_DNSSEC 3
#define DNSSEC_PROTOCOL_IPSEC 4
// DNSSEC KEY flag field
#define DNSSEC_KEY_FLAG_NOAUTH 0x0001
#define DNSSEC_KEY_FLAG_NOCONF 0x0002
#define DNSSEC_KEY_FLAG_FLAG2 0x0004
#define DNSSEC_KEY_FLAG_EXTEND 0x0008
#define DNSSEC_KEY_FLAG_
#define DNSSEC_KEY_FLAG_FLAG4 0x0010
#define DNSSEC_KEY_FLAG_FLAG5 0x0020
// bits 6,7 are name type
#define DNSSEC_KEY_FLAG_USER 0x0000
#define DNSSEC_KEY_FLAG_ZONE 0x0040
#define DNSSEC_KEY_FLAG_HOST 0x0080
#define DNSSEC_KEY_FLAG_NTPE3 0x00c0
// bits 8-11 are reserved for future use
#define DNSSEC_KEY_FLAG_FLAG8 0x0100
#define DNSSEC_KEY_FLAG_FLAG9 0x0200
#define DNSSEC_KEY_FLAG_FLAG10 0x0400
#define DNSSEC_KEY_FLAG_FLAG11 0x0800
// bits 12-15 are sig field
#define DNSSEC_KEY_FLAG_SIG0 0x0000
#define DNSSEC_KEY_FLAG_SIG1 0x1000
#define DNSSEC_KEY_FLAG_SIG2 0x2000
#define DNSSEC_KEY_FLAG_SIG3 0x3000
#define DNSSEC_KEY_FLAG_SIG4 0x4000
#define DNSSEC_KEY_FLAG_SIG5 0x5000
#define DNSSEC_KEY_FLAG_SIG6 0x6000
#define DNSSEC_KEY_FLAG_SIG7 0x7000
#define DNSSEC_KEY_FLAG_SIG8 0x8000
#define DNSSEC_KEY_FLAG_SIG9 0x9000
#define DNSSEC_KEY_FLAG_SIG10 0xa000
#define DNSSEC_KEY_FLAG_SIG11 0xb000
#define DNSSEC_KEY_FLAG_SIG12 0xc000
#define DNSSEC_KEY_FLAG_SIG13 0xd000
#define DNSSEC_KEY_FLAG_SIG14 0xe000
#define DNSSEC_KEY_FLAG_SIG15 0xf000
//
// TKEY modes
//
#define DNS_TKEY_MODE_SERVER_ASSIGN 1
#define DNS_TKEY_MODE_DIFFIE_HELLMAN 2
#define DNS_TKEY_MODE_GSS 3
#define DNS_TKEY_MODE_RESOLVER_ASSIGN 4
//
// WINS + NBSTAT flag field
//
#define DNS_WINS_FLAG_SCOPE (0x80000000)
#define DNS_WINS_FLAG_LOCAL (0x00010000)
//
// Helpful checks
//
#define IS_WORD_ALIGNED(p) ( !((UINT_PTR)(p) & (UINT_PTR)1) )
#define IS_DWORD_ALIGNED(p) ( !((UINT_PTR)(p) & (UINT_PTR)3) )
#define IS_QWORD_ALIGNED(p) ( !((UINT_PTR)(p) & (UINT_PTR)7) )
//
// DNS config API
//
//
// Types of DNS configuration info
//
typedef enum
{
// In Win2K
DnsConfigPrimaryDomainName_W,
DnsConfigPrimaryDomainName_A,
DnsConfigPrimaryDomainName_UTF8,
// Not available yet
DnsConfigAdapterDomainName_W,
DnsConfigAdapterDomainName_A,
DnsConfigAdapterDomainName_UTF8,
// In Win2K
DnsConfigDnsServerList,
// Not available yet
DnsConfigSearchList,
DnsConfigAdapterInfo,
// In Win2K
DnsConfigPrimaryHostNameRegistrationEnabled,
DnsConfigAdapterHostNameRegistrationEnabled,
DnsConfigAddressRegistrationMaxCount,
// In WindowsXP
DnsConfigHostName_W,
DnsConfigHostName_A,
DnsConfigHostName_UTF8,
DnsConfigFullHostName_W,
DnsConfigFullHostName_A,
DnsConfigFullHostName_UTF8
// In XP-SP1 (Server.net)
}
DNS_CONFIG_TYPE;
//
// Config API flags
//
//
// DNS_CONFIG_FLAG_ALLOC -- Causes config info to be allocated.
// Free with LocalFree().
//
#define DNS_CONFIG_FLAG_ALLOC (0x00000001)
DNS_STATUS
WINAPI
DnsQueryConfig(
__in DNS_CONFIG_TYPE Config,
__in DWORD Flag,
__in_opt PCWSTR pwsAdapterName,
__in_opt PVOID pReserved,
__out_bcount_part(*pBufLen, *pBufLen) PVOID pBuffer,
__inout PDWORD pBufLen
);
//
// DNS resource record structure
//
//
// Record data for specific types
//
typedef struct
{
IP4_ADDRESS IpAddress;
}
DNS_A_DATA, *PDNS_A_DATA;
typedef struct
{
PWSTR pNameHost;
}
DNS_PTR_DATAW, *PDNS_PTR_DATAW;
typedef struct
{
PSTR pNameHost;
}
DNS_PTR_DATAA, *PDNS_PTR_DATAA;
typedef struct
{
PWSTR pNamePrimaryServer;
PWSTR pNameAdministrator;
DWORD dwSerialNo;
DWORD dwRefresh;
DWORD dwRetry;
DWORD dwExpire;
DWORD dwDefaultTtl;
}
DNS_SOA_DATAW, *PDNS_SOA_DATAW;
typedef struct
{
PSTR pNamePrimaryServer;
PSTR pNameAdministrator;
DWORD dwSerialNo;
DWORD dwRefresh;
DWORD dwRetry;
DWORD dwExpire;
DWORD dwDefaultTtl;
}
DNS_SOA_DATAA, *PDNS_SOA_DATAA;
typedef struct
{
PWSTR pNameMailbox;
PWSTR pNameErrorsMailbox;
}
DNS_MINFO_DATAW, *PDNS_MINFO_DATAW;
typedef struct
{
PSTR pNameMailbox;
PSTR pNameErrorsMailbox;
}
DNS_MINFO_DATAA, *PDNS_MINFO_DATAA;
typedef struct
{
PWSTR pNameExchange;
WORD wPreference;
WORD Pad; // keep ptrs DWORD aligned
}
DNS_MX_DATAW, *PDNS_MX_DATAW;
typedef struct
{
PSTR pNameExchange;
WORD wPreference;
WORD Pad; // keep ptrs DWORD aligned
}
DNS_MX_DATAA, *PDNS_MX_DATAA;
typedef struct
{
DWORD dwStringCount;
#ifdef MIDL_PASS
[size_is(dwStringCount)] PWSTR pStringArray[];
#else
PWSTR pStringArray[1];
#endif
}
DNS_TXT_DATAW, *PDNS_TXT_DATAW;
typedef struct
{
DWORD dwStringCount;
#ifdef MIDL_PASS
[size_is(dwStringCount)] PSTR pStringArray[];
#else
PSTR pStringArray[1];
#endif
}
DNS_TXT_DATAA, *PDNS_TXT_DATAA;
typedef struct
{
DWORD dwByteCount;
#ifdef MIDL_PASS
[size_is(dwByteCount)] BYTE Data[];
#else
BYTE Data[1];
#endif
}
DNS_NULL_DATA, *PDNS_NULL_DATA;
typedef struct
{
IP4_ADDRESS IpAddress;
UCHAR chProtocol;
BYTE BitMask[1];
}
DNS_WKS_DATA, *PDNS_WKS_DATA;
typedef struct
{
IP6_ADDRESS Ip6Address;
}
DNS_AAAA_DATA, *PDNS_AAAA_DATA;
typedef struct
{
WORD wTypeCovered;
BYTE chAlgorithm;
BYTE chLabelCount;
DWORD dwOriginalTtl;
DWORD dwExpiration;