-
Notifications
You must be signed in to change notification settings - Fork 2
/
record.go
8349 lines (8088 loc) · 266 KB
/
record.go
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
// The record package implements the RECORD client protocol.
//
// # Introduction
//
// The Domain Name Service (DNS) Server Management Protocol defines RPC interfaces that
// provide methods for remotely accessing and administering a DNS server. It is a client/server
// protocol based on RPC that is used in the configuration, management, and monitoring
// of a DNS server.
//
// # Overview
//
// The DNS Server Management Protocol is a client/server protocol that is used to remotely
// query, monitor and configure DNS server settings, its zones, and resource records.
// The protocol allows a client to access DNS server settings and properties and also
// to enumerate all DNS data stored on the server (DNS zones and DNS records).
//
// The DNS Server Management Protocol is a simple protocol with no state shared across
// RPC method calls. Each RPC method call contains one complete request. Output from
// one method call can be used as input to another call but the DNS Server Management
// Protocol does not provide for locking of DNS data across method calls. For example,
// a client can enumerate DNS zones with one call and retrieve the properties of one
// or more of the enumerated DNS zones with another call. However, no guarantee is made
// that the zone has not been deleted by another DNS Server Management Protocol client
// between these two method calls.
//
// When the DNS server is directory server-integrated, some client requests can require
// or trigger Lightweight Directory Access Protocol (LDAP) requests from the DNS server
// to the local directory server or another directory server.
//
// In particular, the DNS server can use the defaultNamingContext of the directory server's
// rootDSE, a DNS domain partition named DnsDomainZones, or a DNS forest partition named
// DnsForestZones to store zone information and zone records. (See section 2.3 for a
// discussion of the schemas used to store this information.) A DNS Server integrated
// with a directory server creates and automatically enlists itself in these default
// application directory partitions. Alternatively, zone information and zone records
// can be stored in additional application directory partitions, which can be created
// (and removed) by the DNS Server Management Protocol client in order to control the
// granularity of zone replication. Zones created in these additional application directory
// partitions will only be visible to directory servers enlisted in those partitions,
// thus allowing for granular control over replication.
//
// A typical remote management involves the client querying or setting the configuration
// parameters of the DNS server. The client can also enumerate DNS zones and the DNS
// records stored in one or more zones. The client can modify the configuration of the
// DNS server as required. The client can also add, delete, or modify DNS zones or the
// DNS records held in zones as required. For example, a remote management client can:
//
// * Set or retrieve the server's forwarders ( a95b05da-f1fd-4db3-94b4-817fdaa1f642#gt_025cfacf-ebc5-4659-971a-ee2ab5903575
// ).
//
// * Set or retrieve various DNS server settings.
//
// * Create or modify zones.
//
// * Create or modify zone records.
//
// This usually involves sending a request to the DNS server specifying the type of
// operation (get, set and execute are examples of types of operations) to perform and
// any specific parameters that are associated with that operation. The DNS server responds
// to the client with the result of the operation.
//
// The following diagram shows an example of a remote client creating a zone on the
// DNS server using the DNS server Management Protocol. The client sends a request to
// the server with the operation type and parameters. The server responds with a success
// or an error.
package record
import (
"context"
"fmt"
"strings"
"unicode/utf16"
dcerpc "github.com/oiweiwei/go-msrpc/dcerpc"
errors "github.com/oiweiwei/go-msrpc/dcerpc/errors"
uuid "github.com/oiweiwei/go-msrpc/midl/uuid"
dtyp "github.com/oiweiwei/go-msrpc/msrpc/dtyp"
ndr "github.com/oiweiwei/go-msrpc/ndr"
)
var (
_ = context.Background
_ = fmt.Errorf
_ = utf16.Encode
_ = strings.TrimPrefix
_ = ndr.ZeroString
_ = (*uuid.UUID)(nil)
_ = (*dcerpc.SyntaxID)(nil)
_ = (*errors.Error)(nil)
_ = dtyp.GoPackage
)
var (
// import guard
GoPackage = "dnsp/record"
)
// TypeRecord type represents DNS_RPC_TYPE_RECORD RPC enumeration.
type TypeRecord uint16
var (
TypeRecordZERO TypeRecord = 0
TypeRecordA TypeRecord = 1
TypeRecordNS TypeRecord = 2
TypeRecordMD TypeRecord = 3
TypeRecordMF TypeRecord = 4
TypeRecordCNAME TypeRecord = 5
TypeRecordSOA TypeRecord = 6
TypeRecordMB TypeRecord = 7
TypeRecordMG TypeRecord = 8
TypeRecordMR TypeRecord = 9
TypeRecordNULL TypeRecord = 10
TypeRecordWKS TypeRecord = 11
TypeRecordPTR TypeRecord = 12
TypeRecordHINFO TypeRecord = 13
TypeRecordMINFO TypeRecord = 14
TypeRecordMX TypeRecord = 15
TypeRecordTXT TypeRecord = 16
TypeRecordRP TypeRecord = 17
TypeRecordAFSDB TypeRecord = 18
TypeRecordX25 TypeRecord = 19
TypeRecordISDN TypeRecord = 20
TypeRecordRT TypeRecord = 21
TypeRecordSIG TypeRecord = 24
TypeRecordKEY TypeRecord = 25
TypeRecordAAAA TypeRecord = 28
TypeRecordNXT TypeRecord = 30
TypeRecordSRV TypeRecord = 33
TypeRecordATMA TypeRecord = 34
TypeRecordNAPTR TypeRecord = 35
TypeRecordDNAME TypeRecord = 39
TypeRecordDS TypeRecord = 43
TypeRecordRRSIG TypeRecord = 46
TypeRecordNSEC TypeRecord = 47
TypeRecordDNSKEY TypeRecord = 48
TypeRecordDHCID TypeRecord = 49
TypeRecordNSEC3 TypeRecord = 50
TypeRecordNSEC3PARAM TypeRecord = 51
TypeRecordTLSA TypeRecord = 52
TypeRecordWINS TypeRecord = 65281
TypeRecordWINSR TypeRecord = 65282
)
func (o TypeRecord) String() string {
switch o {
case TypeRecordZERO:
return "TypeRecordZERO"
case TypeRecordA:
return "TypeRecordA"
case TypeRecordNS:
return "TypeRecordNS"
case TypeRecordMD:
return "TypeRecordMD"
case TypeRecordMF:
return "TypeRecordMF"
case TypeRecordCNAME:
return "TypeRecordCNAME"
case TypeRecordSOA:
return "TypeRecordSOA"
case TypeRecordMB:
return "TypeRecordMB"
case TypeRecordMG:
return "TypeRecordMG"
case TypeRecordMR:
return "TypeRecordMR"
case TypeRecordNULL:
return "TypeRecordNULL"
case TypeRecordWKS:
return "TypeRecordWKS"
case TypeRecordPTR:
return "TypeRecordPTR"
case TypeRecordHINFO:
return "TypeRecordHINFO"
case TypeRecordMINFO:
return "TypeRecordMINFO"
case TypeRecordMX:
return "TypeRecordMX"
case TypeRecordTXT:
return "TypeRecordTXT"
case TypeRecordRP:
return "TypeRecordRP"
case TypeRecordAFSDB:
return "TypeRecordAFSDB"
case TypeRecordX25:
return "TypeRecordX25"
case TypeRecordISDN:
return "TypeRecordISDN"
case TypeRecordRT:
return "TypeRecordRT"
case TypeRecordSIG:
return "TypeRecordSIG"
case TypeRecordKEY:
return "TypeRecordKEY"
case TypeRecordAAAA:
return "TypeRecordAAAA"
case TypeRecordNXT:
return "TypeRecordNXT"
case TypeRecordSRV:
return "TypeRecordSRV"
case TypeRecordATMA:
return "TypeRecordATMA"
case TypeRecordNAPTR:
return "TypeRecordNAPTR"
case TypeRecordDNAME:
return "TypeRecordDNAME"
case TypeRecordDS:
return "TypeRecordDS"
case TypeRecordRRSIG:
return "TypeRecordRRSIG"
case TypeRecordNSEC:
return "TypeRecordNSEC"
case TypeRecordDNSKEY:
return "TypeRecordDNSKEY"
case TypeRecordDHCID:
return "TypeRecordDHCID"
case TypeRecordNSEC3:
return "TypeRecordNSEC3"
case TypeRecordNSEC3PARAM:
return "TypeRecordNSEC3PARAM"
case TypeRecordTLSA:
return "TypeRecordTLSA"
case TypeRecordWINS:
return "TypeRecordWINS"
case TypeRecordWINSR:
return "TypeRecordWINSR"
}
return "Invalid"
}
// Record structure represents DNS_RPC_RECORD RPC structure.
//
// The DNS_RPC_RECORD structure is used to specify a single DNS record's parameters
// and data. This structure is returned by the DNS server in response to an R_DnssrvEnumRecords2
// (section 3.1.4.9) method call.
type Record struct {
// wDataLength: The total size of the variable buffer, in bytes. Note that the DNS_RPC_RECORD
// structure is always 4-byte aligned, which means there can be 0-3 bytes of padding
// at the end of the structure. The pad bytes are not included in the wDataLength count.
DataLength uint16 `idl:"name:wDataLength" json:"data_length"`
// wType: The type of the resource record, as specified in section 2.2.2.1.1 DNS_RECORD_TYPE.
Type TypeRecord `idl:"name:wType" json:"type"`
// dwFlags: Resource record properties. This field can contain one of the RANK* flags
// in the low-order bits and one of the DNS_RPC_FLAGS* in the high-order bits.
//
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | | |
// | VALUE | MEANING |
// | | |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_CACHE_BIT 0x00000001 | The record came from the cache. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_ROOT_HINT 0x00000008 | The record is a preconfigured root hint. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_OUTSIDE_GLUE 0x00000020 | This value is not used. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_CACHE_NA_ADDITIONAL 0x00000031 | The record was cached from the additional section of a non-authoritative |
// | | response. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_CACHE_NA_AUTHORITY 0x00000041 | The record was cached from the authority section of a non-authoritative |
// | | response. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_CACHE_A_ADDITIONAL 0x00000051 | The record was cached from the additional section of an authoritative response. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_CACHE_NA_ANSWER 0x00000061 | The record was cached from the answer section of a non-authoritative response. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_CACHE_A_AUTHORITY 0x00000071 | The record was cached from the authority section of an authoritative response. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_GLUE 0x00000080 | The record is a glue record in an authoritative zone. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_NS_GLUE 0x00000082 | The record is a delegation (type NS) record in an authoritative zone. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_CACHE_A_ANSWER 0x000000C1 | The record was cached from the answer section of an authoritative response. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | RANK_ZONE 0x000000F0 | The record comes from an authoritative zone. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | DNS_RPC_FLAG_ZONE_ROOT 0x40000000 | The record is at the root of a zone (not necessarily a zone hosted by this |
// | | server; the record could have come from the cache). |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | DNS_RPC_FLAG_AUTH_ZONE_ROOT 0x20000000 | The record is at the root of a zone that is locally hosted on this server. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | DNS_RPC_FLAG_CACHE_DATA 0x80000000 | The record came from the cache. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
// | DNS_RPC_FLAG_RECORD_WIRE_FORMAT 0x00100000 | The record SHOULD<25> be treated as a resource record of unknown type ([RFC3597] |
// | | section 2) by the DNS server. |
// +--------------------------------------------+----------------------------------------------------------------------------------+
Flags uint32 `idl:"name:dwFlags" json:"flags"`
// dwSerial: This MUST be set to 0x00000000 when sent by the client or server, and ignored
// on receipt by the server or client.
Serial uint32 `idl:"name:dwSerial" json:"serial"`
// dwTtlSeconds: The duration, in seconds, after which this record will expire.
TTLSeconds uint32 `idl:"name:dwTtlSeconds" json:"ttl_seconds"`
// dwTimeStamp: The time stamp, in hours, for the record when it received the last update.
Timestamp uint32 `idl:"name:dwTimeStamp" json:"timestamp"`
// dwReserved: This value MUST be set to 0x00000000 when sent by the client and ignored
// on receipt by the server.
_ uint32 `idl:"name:dwReserved"`
// Buffer: Record data in DNS_RPC_RECORD_DATA (section 2.2.2.2.4) format where type
// is specified by the value wType.<26>
//
// +----------------------------+--------------------------------+
// | | |
// | VALUE | MEANING |
// | | |
// +----------------------------+--------------------------------+
// +----------------------------+--------------------------------+
// | DNS_TYPE_ZERO 0x0000 | DNS_RPC_RECORD_TS |
// +----------------------------+--------------------------------+
// | DNS_TYPE_A 0x0001 | DNS_RPC_RECORD_A |
// +----------------------------+--------------------------------+
// | DNS_TYPE_NS 0x0002 | DNS_RPC_RECORD_NODE_NAME |
// +----------------------------+--------------------------------+
// | DNS_TYPE_MD 0x0003 | DNS_RPC_RECORD_NODE_NAME |
// +----------------------------+--------------------------------+
// | DNS_TYPE_MF 0x0004 | DNS_RPC_RECORD_NODE_NAME |
// +----------------------------+--------------------------------+
// | DNS_TYPE_CNAME 0x0005 | DNS_RPC_RECORD_NODE_NAME |
// +----------------------------+--------------------------------+
// | DNS_TYPE_SOA 0x0006 | DNS_RPC_RECORD_SOA |
// +----------------------------+--------------------------------+
// | DNS_TYPE_MB 0x0007 | DNS_RPC_RECORD_NODE_NAME |
// +----------------------------+--------------------------------+
// | DNS_TYPE_MG 0x0008 | DNS_RPC_RECORD_NODE_NAME |
// +----------------------------+--------------------------------+
// | DNS_TYPE_MR 0x0009 | DNS_RPC_RECORD_NODE_NAME |
// +----------------------------+--------------------------------+
// | DNS_TYPE_NULL 0x000A | DNS_RPC_RECORD_NULL |
// +----------------------------+--------------------------------+
// | DNS_TYPE_WKS 0x000B | DNS_RPC_RECORD_WKS |
// +----------------------------+--------------------------------+
// | DNS_TYPE_PTR 0x000C | DNS_RPC_RECORD_NODE_NAME |
// +----------------------------+--------------------------------+
// | DNS_TYPE_HINFO 0x000D | DNS_RPC_RECORD_STRING |
// +----------------------------+--------------------------------+
// | DNS_TYPE_MINFO 0x000E | DNS_RPC_RECORD_MAIL_ERROR |
// +----------------------------+--------------------------------+
// | DNS_TYPE_MX 0x000F | DNS_RPC_RECORD_NAME_PREFERENCE |
// +----------------------------+--------------------------------+
// | DNS_TYPE_TXT 0x0010 | DNS_RPC_RECORD_STRING |
// +----------------------------+--------------------------------+
// | DNS_TYPE_RP 0x0011 | DNS_RPC_RECORD_MAIL_ERROR |
// +----------------------------+--------------------------------+
// | DNS_TYPE_AFSDB 0x0012 | DNS_RPC_RECORD_NAME_PREFERENCE |
// +----------------------------+--------------------------------+
// | DNS_TYPE_X25 0x0013 | DNS_RPC_RECORD_STRING |
// +----------------------------+--------------------------------+
// | DNS_TYPE_ISDN 0x0014 | DNS_RPC_RECORD_STRING |
// +----------------------------+--------------------------------+
// | DNS_TYPE_RT 0x0015 | DNS_RPC_RECORD_NAME_PREFERENCE |
// +----------------------------+--------------------------------+
// | DNS_TYPE_SIG 0x0018 | DNS_RPC_RECORD_SIG |
// +----------------------------+--------------------------------+
// | DNS_TYPE_KEY 0x0019 | DNS_RPC_RECORD_KEY |
// +----------------------------+--------------------------------+
// | DNS_TYPE_AAAA 0x001C | DNS_RPC_RECORD_AAAA |
// +----------------------------+--------------------------------+
// | DNS_TYPE_NXT 0x001E | DNS_RPC_RECORD_NXT |
// +----------------------------+--------------------------------+
// | DNS_TYPE_SRV 0x0021 | DNS_RPC_RECORD_SRV |
// +----------------------------+--------------------------------+
// | DNS_TYPE_ATMA 0x0022 | DNS_RPC_RECORD_ATMA |
// +----------------------------+--------------------------------+
// | DNS_TYPE_NAPTR 0x0023 | DNS_RPC_RECORD_NAPTR |
// +----------------------------+--------------------------------+
// | DNS_TYPE_DNAME 0x0027 | DNS_RPC_RECORD_NODE_NAME |
// +----------------------------+--------------------------------+
// | DNS_TYPE_DS 0x002B | DNS_RPC_RECORD_DS |
// +----------------------------+--------------------------------+
// | DNS_TYPE_RRSIG 0x002E | DNS_RPC_RECORD_RRSIG |
// +----------------------------+--------------------------------+
// | DNS_TYPE_NSEC 0x002F | DNS_RPC_RECORD_NSEC |
// +----------------------------+--------------------------------+
// | DNS_TYPE_DNSKEY 0x0030 | DNS_RPC_RECORD_DNSKEY |
// +----------------------------+--------------------------------+
// | DNS_TYPE_DHCID 0x0031 | DNS_RPC_RECORD_DHCID |
// +----------------------------+--------------------------------+
// | DNS_TYPE_NSEC3 0x0032 | DNS_RPC_RECORD_NSEC3 |
// +----------------------------+--------------------------------+
// | DNS_TYPE_NSEC3PARAM 0x0033 | DNS_RPC_RECORD_NSEC3PARAM |
// +----------------------------+--------------------------------+
// | DNS_TYPE_TLSA 0x0034 | DNS_RPC_RECORD_TLSA |
// +----------------------------+--------------------------------+
// | DNS_TYPE_WINS 0xFF01 | DNS_RPC_RECORD_WINS |
// +----------------------------+--------------------------------+
// | DNS_TYPE_WINSR 0xFF02 | DNS_RPC_RECORD_WINSR |
// +----------------------------+--------------------------------+
Buffer []byte `idl:"name:Buffer;size_is:(wDataLength)" json:"buffer"`
Record *Record_Record `idl:"name:Record;switch_is:wType" json:"record"`
}
func (o *Record) xxx_PreparePayload(ctx context.Context) error {
if o.Buffer != nil && o.DataLength == 0 {
o.DataLength = uint16(len(o.Buffer))
}
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *Record) NDRSizeInfo() []uint64 {
dimSize1 := uint64(o.DataLength)
return []uint64{
dimSize1,
}
}
func (o *Record) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
sizeInfo, ok := ctx.Value(ndr.SizeInfo).([]uint64)
if !ok {
sizeInfo = o.NDRSizeInfo()
for sz1 := range sizeInfo {
if err := w.WriteSize(sizeInfo[sz1]); err != nil {
return err
}
}
ctx = context.WithValue(ctx, ndr.SizeInfo, sizeInfo)
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.DataLength); err != nil {
return err
}
if err := w.WriteData(uint16(o.Type)); err != nil {
return err
}
if err := w.WriteData(o.Flags); err != nil {
return err
}
if err := w.WriteData(o.Serial); err != nil {
return err
}
if err := w.WriteData(o.TTLSeconds); err != nil {
return err
}
if err := w.WriteData(o.Timestamp); err != nil {
return err
}
// reserved dwReserved
if err := w.WriteData(uint32(0)); err != nil {
return err
}
for i1 := range o.Buffer {
i1 := i1
if uint64(i1) >= sizeInfo[0] {
break
}
if err := w.WriteData(o.Buffer[i1]); err != nil {
return err
}
}
for i1 := len(o.Buffer); uint64(i1) < sizeInfo[0]; i1++ {
if err := w.WriteData(uint8(0)); err != nil {
return err
}
}
return nil
}
func (o *Record) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
sizeInfo, ok := ctx.Value(ndr.SizeInfo).([]uint64)
if !ok {
sizeInfo = o.NDRSizeInfo()
for i1 := range sizeInfo {
if err := w.ReadSize(&sizeInfo[i1]); err != nil {
return err
}
}
ctx = context.WithValue(ctx, ndr.SizeInfo, sizeInfo)
}
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.DataLength); err != nil {
return err
}
if err := w.ReadData((*uint16)(&o.Type)); err != nil {
return err
}
if err := w.ReadData(&o.Flags); err != nil {
return err
}
if err := w.ReadData(&o.Serial); err != nil {
return err
}
if err := w.ReadData(&o.TTLSeconds); err != nil {
return err
}
if err := w.ReadData(&o.Timestamp); err != nil {
return err
}
// reserved dwReserved
var _dwReserved uint32
if err := w.ReadData(&_dwReserved); err != nil {
return err
}
// XXX: for opaque unmarshaling
if o.DataLength > 0 && sizeInfo[0] == 0 {
sizeInfo[0] = uint64(o.DataLength)
}
if sizeInfo[0] > uint64(w.Len()) /* sanity-check */ {
return fmt.Errorf("buffer overflow for size %d of array o.Buffer", sizeInfo[0])
}
o.Buffer = make([]byte, sizeInfo[0])
for i1 := range o.Buffer {
i1 := i1
if err := w.ReadData(&o.Buffer[i1]); err != nil {
return err
}
}
_layout_Record := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
if o.Record == nil {
o.Record = &Record_Record{}
}
_swRecord := uint16(o.Type)
if err := o.Record.UnmarshalUnionNDR(ctx, w, _swRecord); err != nil {
return err
}
return nil
})
if len(o.Buffer) > 0 {
if err := w.WithBytes(o.Buffer).Unmarshal(ctx, _layout_Record); err != nil {
return err
}
}
return nil
}
// Record_Record structure represents DNS_RPC_RECORD union anonymous member.
//
// The DNS_RPC_RECORD structure is used to specify a single DNS record's parameters
// and data. This structure is returned by the DNS server in response to an R_DnssrvEnumRecords2
// (section 3.1.4.9) method call.
type Record_Record struct {
// Types that are assignable to Value
//
// *Record_ZERO
// *Record_A
// *Record_NS
// *Record_MD
// *Record_MF
// *Record_CNAME
// *Record_SOA
// *Record_MB
// *Record_MG
// *Record_MR
// *Record_NULL
// *Record_WKS
// *Record_PTR
// *Record_HINFO
// *Record_MINFO
// *Record_MX
// *Record_TXT
// *Record_RP
// *Record_AFSDB
// *Record_X25
// *Record_ISDN
// *Record_RT
// *Record_SIG
// *Record_KEY
// *Record_AAAA
// *Record_NXT
// *Record_SRV
// *Record_ATMA
// *Record_NAPTR
// *Record_DNAME
// *Record_DS
// *Record_RRSIG
// *Record_NSEC
// *Record_DNSKEY
// *Record_DHCID
// *Record_NSEC3
// *Record_NSEC3PARAM
// *Record_TLSA
// *Record_WINS
// *Record_WINSR
// *Record_Unknown
Value is_Record_Record `json:"value"`
}
func (o *Record_Record) GetValue() any {
if o == nil {
return nil
}
switch value := (interface{})(o.Value).(type) {
case *Record_ZERO:
if value != nil {
return value.RecordZERO
}
case *Record_A:
if value != nil {
return value.RecordA
}
case *Record_NS:
if value != nil {
return value.RecordNS
}
case *Record_MD:
if value != nil {
return value.RecordMD
}
case *Record_MF:
if value != nil {
return value.RecordMF
}
case *Record_CNAME:
if value != nil {
return value.RecordCNAME
}
case *Record_SOA:
if value != nil {
return value.RecordSOA
}
case *Record_MB:
if value != nil {
return value.RecordMB
}
case *Record_MG:
if value != nil {
return value.RecordMG
}
case *Record_MR:
if value != nil {
return value.RecordMR
}
case *Record_NULL:
if value != nil {
return value.RecordNULL
}
case *Record_WKS:
if value != nil {
return value.RecordWKS
}
case *Record_PTR:
if value != nil {
return value.RecordPTR
}
case *Record_HINFO:
if value != nil {
return value.RecordHINFO
}
case *Record_MINFO:
if value != nil {
return value.RecordMINFO
}
case *Record_MX:
if value != nil {
return value.RecordMX
}
case *Record_TXT:
if value != nil {
return value.RecordTXT
}
case *Record_RP:
if value != nil {
return value.RecordRP
}
case *Record_AFSDB:
if value != nil {
return value.RecordAFSDB
}
case *Record_X25:
if value != nil {
return value.RecordX25
}
case *Record_ISDN:
if value != nil {
return value.RecordISDN
}
case *Record_RT:
if value != nil {
return value.RecordRT
}
case *Record_SIG:
if value != nil {
return value.RecordSIG
}
case *Record_KEY:
if value != nil {
return value.RecordKEY
}
case *Record_AAAA:
if value != nil {
return value.RecordAAAA
}
case *Record_NXT:
if value != nil {
return value.RecordNXT
}
case *Record_SRV:
if value != nil {
return value.RecordSRV
}
case *Record_ATMA:
if value != nil {
return value.RecordATMA
}
case *Record_NAPTR:
if value != nil {
return value.RecordNAPTR
}
case *Record_DNAME:
if value != nil {
return value.RecordDNAME
}
case *Record_DS:
if value != nil {
return value.RecordDS
}
case *Record_RRSIG:
if value != nil {
return value.RecordRRSIG
}
case *Record_NSEC:
if value != nil {
return value.RecordNSEC
}
case *Record_DNSKEY:
if value != nil {
return value.RecordDNSKEY
}
case *Record_DHCID:
if value != nil {
return value.RecordDHCID
}
case *Record_NSEC3:
if value != nil {
return value.RecordNSEC3
}
case *Record_NSEC3PARAM:
if value != nil {
return value.RecordNSEC3PARAM
}
case *Record_TLSA:
if value != nil {
return value.RecordTLSA
}
case *Record_WINS:
if value != nil {
return value.RecordWINS
}
case *Record_WINSR:
if value != nil {
return value.RecordWINSR
}
case *Record_Unknown:
if value != nil {
return value.RecordUnknown
}
}
return nil
}
type is_Record_Record interface {
ndr.Marshaler
ndr.Unmarshaler
is_Record_Record()
}
func (o *Record_Record) NDRSwitchValue(sw uint16) uint16 {
if o == nil {
return uint16(0)
}
switch (interface{})(o.Value).(type) {
case *Record_ZERO:
return uint16(0)
case *Record_A:
return uint16(1)
case *Record_NS:
return uint16(2)
case *Record_MD:
return uint16(3)
case *Record_MF:
return uint16(4)
case *Record_CNAME:
return uint16(5)
case *Record_SOA:
return uint16(6)
case *Record_MB:
return uint16(7)
case *Record_MG:
return uint16(8)
case *Record_MR:
return uint16(9)
case *Record_NULL:
return uint16(10)
case *Record_WKS:
return uint16(11)
case *Record_PTR:
return uint16(12)
case *Record_HINFO:
return uint16(13)
case *Record_MINFO:
return uint16(14)
case *Record_MX:
return uint16(15)
case *Record_TXT:
return uint16(16)
case *Record_RP:
return uint16(17)
case *Record_AFSDB:
return uint16(18)
case *Record_X25:
return uint16(19)
case *Record_ISDN:
return uint16(20)
case *Record_RT:
return uint16(21)
case *Record_SIG:
return uint16(24)
case *Record_KEY:
return uint16(25)
case *Record_AAAA:
return uint16(28)
case *Record_NXT:
return uint16(30)
case *Record_SRV:
return uint16(33)
case *Record_ATMA:
return uint16(34)
case *Record_NAPTR:
return uint16(35)
case *Record_DNAME:
return uint16(39)
case *Record_DS:
return uint16(43)
case *Record_RRSIG:
return uint16(46)
case *Record_NSEC:
return uint16(47)
case *Record_DNSKEY:
return uint16(48)
case *Record_DHCID:
return uint16(49)
case *Record_NSEC3:
return uint16(50)
case *Record_NSEC3PARAM:
return uint16(51)
case *Record_TLSA:
return uint16(52)
case *Record_WINS:
return uint16(65281)
case *Record_WINSR:
return uint16(65282)
}
return uint16(0)
}
func (o *Record_Record) MarshalUnionNDR(ctx context.Context, w ndr.Writer, sw uint16) error {
if err := w.WriteSwitch(uint16(sw)); err != nil {
return err
}
switch sw {
case uint16(0):
_o, _ := o.Value.(*Record_ZERO)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_ZERO{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(1):
_o, _ := o.Value.(*Record_A)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_A{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(2):
_o, _ := o.Value.(*Record_NS)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_NS{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(3):
_o, _ := o.Value.(*Record_MD)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_MD{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(4):
_o, _ := o.Value.(*Record_MF)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_MF{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(5):
_o, _ := o.Value.(*Record_CNAME)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_CNAME{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(6):
_o, _ := o.Value.(*Record_SOA)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_SOA{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(7):
_o, _ := o.Value.(*Record_MB)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_MB{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(8):
_o, _ := o.Value.(*Record_MG)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_MG{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(9):
_o, _ := o.Value.(*Record_MR)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_MR{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(10):
_o, _ := o.Value.(*Record_NULL)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_NULL{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(11):
_o, _ := o.Value.(*Record_WKS)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_WKS{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(12):
_o, _ := o.Value.(*Record_PTR)
if _o != nil {
if err := _o.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Record_PTR{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
case uint16(13):