-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathraiw.go
2284 lines (2231 loc) · 73.8 KB
/
raiw.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 raiw package implements the RAIW client protocol.
//
// # Introduction
//
// This is a specification of the Remote Administrative Interface: WINS protocol. This
// protocol defines remote procedure call (RPC) interfaces that provide methods for
// remotely accessing and administering a server for the Windows Internet Name Service
// (WINS). This protocol is a client/server protocol that is based on RPC and is used
// in the configuration, management, and monitoring of a WINS server.
//
// An application implementing this protocol can remotely perform service monitoring
// of a WINS server as well as creating, updating, querying, or deleting database records,
// performing database scavenging, and replicating the database records with other WINS
// servers.
//
// # Overview
//
// The Remote Administrative Interface: WINS protocol is a client/server protocol that
// is used to remotely configure, manage, and monitor the WINS server. This protocol
// allows a client to view and update the server configuration settings as well as to
// create, modify, and delete WINS database records. It also allows clients to trigger
// scavenging and replicating operations and to query the database.
//
// The Remote Administrative Interface: WINS protocol is stateless 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 an input to another call, but the protocol does
// not provide methods for locking the WINS server con figuration or state data across
// method calls. For example, a client can pull a range of records from the database
// and delete some of them using another RPC call. However, the protocol does not guarantee
// that the specified record has not been modified by another client between the two
// method calls.
//
// +---------------------------------------+
// | REMOTE ADMINISTRATIVE INTERFACE: |
// | WINS |
// +---------------------------------------+
// +---------------------------------------+
// | Remote Procedure Call (RPC) |
// +---------------------------------------+
// |
// +---------------------------------------+
package raiw
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 = "raiw"
)
// MaxNoReplicationPullPartners represents the WINSINTF_MAX_NO_RPL_PNRS RPC constant
var MaxNoReplicationPullPartners = 25
// VersNo structure represents WINSINTF_VERS_NO_T RPC structure.
type VersNo dtyp.LargeInteger
func (o *VersNo) LargeInteger() *dtyp.LargeInteger { return (*dtyp.LargeInteger)(o) }
func (o *VersNo) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *VersNo) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(8); err != nil {
return err
}
if err := w.WriteData(o.QuadPart); err != nil {
return err
}
return nil
}
func (o *VersNo) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(8); err != nil {
return err
}
if err := w.ReadData(&o.QuadPart); err != nil {
return err
}
return nil
}
// Addr structure represents WINSINTF_ADDR_T RPC structure.
type Addr struct {
Type uint8 `idl:"name:Type" json:"type"`
Length uint32 `idl:"name:Len" json:"length"`
IPAddr uint32 `idl:"name:IPAddr" json:"ip_addr"`
}
func (o *Addr) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *Addr) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.Type); err != nil {
return err
}
if err := w.WriteData(o.Length); err != nil {
return err
}
if err := w.WriteData(o.IPAddr); err != nil {
return err
}
return nil
}
func (o *Addr) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.Type); err != nil {
return err
}
if err := w.ReadData(&o.Length); err != nil {
return err
}
if err := w.ReadData(&o.IPAddr); err != nil {
return err
}
return nil
}
// PriorityClass type represents WINSINTF_PRIORITY_CLASS_E RPC enumeration.
//
// The WINSINTF_PRIORITY_CLASS_E enumeration defines the priority class of a WINS process.
// It is used by the RPC method R_WinsSetPriorityClass.
type PriorityClass uint16
var (
// WINSINTF_E_NORMAL: WINS process is assigned normal priority class.
PriorityClassNormal PriorityClass = 0
// WINSINTF_E_HIGH: WINS process is assigned high priority class.
PriorityClassHigh PriorityClass = 1
)
func (o PriorityClass) String() string {
switch o {
case PriorityClassNormal:
return "PriorityClassNormal"
case PriorityClassHigh:
return "PriorityClassHigh"
}
return "Invalid"
}
// Action type represents WINSINTF_ACT_E RPC enumeration.
//
// The WINSINTF_ACT_E enumeration indicates an action type requested by the RPC method
// R_WinsRecordAction for a record contained in the WINSINTF_RECORD_ACTION_T structure.
type Action uint16
var (
// WINSINTF_E_INSERT: Insert a record into the WINS database.
ActionInsert Action = 0
// WINSINTF_E_DELETE: Delete a matching record from the WINS database.
ActionDelete Action = 1
// WINSINTF_E_RELEASE: Release a matching record from the WINS database.
ActionRelease Action = 2
// WINSINTF_E_MODIFY: Modify the attributes of the matching record.
ActionModify Action = 3
// WINSINTF_E_QUERY: Query the database for a given name.
ActionQuery Action = 4
)
func (o Action) String() string {
switch o {
case ActionInsert:
return "ActionInsert"
case ActionDelete:
return "ActionDelete"
case ActionRelease:
return "ActionRelease"
case ActionModify:
return "ActionModify"
case ActionQuery:
return "ActionQuery"
}
return "Invalid"
}
// TriggerTypeE type represents WINSINTF_TRIG_TYPE_E RPC enumeration.
//
// The WINSINTF_TRIG_TYPE_E enumeration defines the type of replication to be done.
// It is used by the RPC method R_WinsTrigger.
type TriggerTypeE uint16
var (
// WINSINTF_E_PULL: The target WINS server performs pull replication with the specified
// WINS server.
TriggerTypeEPull TriggerTypeE = 0
// WINSINTF_E_PUSH: The target WINS server performs push replication with the specified
// WINS server.
TriggerTypeEPush TriggerTypeE = 1
// WINSINTF_E_PUSH_PROP: The target WINS server performs propagating push replication
// with the specified WINS server.
TriggerTypeEPushProperty TriggerTypeE = 2
)
func (o TriggerTypeE) String() string {
switch o {
case TriggerTypeEPull:
return "TriggerTypeEPull"
case TriggerTypeEPush:
return "TriggerTypeEPush"
case TriggerTypeEPushProperty:
return "TriggerTypeEPushProperty"
}
return "Invalid"
}
// RecordAction structure represents WINSINTF_RECORD_ACTION_T RPC structure.
//
// The WINSINTF_RECORD_ACTION_T structure defines a WINS database record and the action
// to be performed on it. The structure WINSINTF_RECS_T (section 2.2.2.8) and the RPC
// method R_WinsRecordAction (section 3.1.4.1) both use this structure.
type RecordAction struct {
// Cmd_e: A WINSINTF_ACT_E enumeration (section 2.2.1.4) value that specifies the action
// to be performed on the specified record.
Cmd Action `idl:"name:Cmd_e" json:"cmd"`
// pName: A pointer to a NULL-terminated string that contains the NetBIOS name and
// optionally the NetBIOS scope name of the record. The NetBIOS scope name, if present,
// is appended to the NetBIOS name with a dot character ".".
Name []byte `idl:"name:pName;size_is:((NameLen+1))" json:"name"`
// NameLen: The length of the string that pName points to. It has the following possible
// values:
//
// +------------+----------------------------------------------------------------------------------+
// | | |
// | VALUE | MEANING |
// | | |
// +------------+----------------------------------------------------------------------------------+
// +------------+----------------------------------------------------------------------------------+
// | 16 | The pName value points to a string that contains only the NetBIOS name of the |
// | | record. The NameLen value does not include the terminating NULL character. |
// +------------+----------------------------------------------------------------------------------+
// | 18 < value | The pName value points to a string that contains the NetBIOS name, a dot |
// | | character ".", and the NULL-terminated NetBIOS scope name of the record. The |
// | | NameLen value includes the terminating NULL character. If the NameLen value is |
// | | greater than 255, the pName string SHOULD be truncated to 254 characters plus a |
// | | terminating NULL character. |
// +------------+----------------------------------------------------------------------------------+
NameLength uint32 `idl:"name:NameLen" json:"name_length"`
// TypOfRec_e: The record type. Only the two least-significant bits of the member value
// are considered valid. All other bits are masked with zero. The following values are
// allowed.
//
// +-------+-------------------------+
// | | |
// | VALUE | MEANING |
// | | |
// +-------+-------------------------+
// +-------+-------------------------+
// | 0 | Unique name |
// +-------+-------------------------+
// | 1 | Normal group name |
// +-------+-------------------------+
// | 2 | Special group name |
// +-------+-------------------------+
// | 3 | Multihomed machine name |
// +-------+-------------------------+
TypeOfRecord uint32 `idl:"name:TypOfRec_e" json:"type_of_record"`
NumberOfAddrs uint32 `idl:"name:NoOfAddrs" json:"number_of_addrs"`
Addrs []*Addr `idl:"name:pAddrs;size_is:(NoOfAddrs);pointer:unique" json:"addrs"`
Addr *Addr `idl:"name:Addr" json:"addr"`
// VersNo: The version number of the record.
VersNo *dtyp.LargeInteger `idl:"name:VersNo" json:"vers_no"`
// NodeTyp: The NetBT node type. Only the two least-significant bits of the member
// value are considered valid. All other bits are masked with zero. This member MUST
// have one of the following values:
//
// +-------+---------+
// | | |
// | VALUE | MEANING |
// | | |
// +-------+---------+
// +-------+---------+
// | 0 | B-node |
// +-------+---------+
// | 1 | P-node |
// +-------+---------+
// | 2 | M-node |
// +-------+---------+
// | 3 | H-node |
// +-------+---------+
NodeType uint8 `idl:"name:NodeTyp" json:"node_type"`
// OwnerId: The owner IP address of the record, in little-endian byte order.
OwnerID uint32 `idl:"name:OwnerId" json:"owner_id"`
// State_e: The state of the record. Only the two least-significant bits of the member
// value are considered valid. All other bits are masked with zero. This member MUST
// have one of the following values:
//
// +-------+-------------------+
// | | |
// | VALUE | MEANING |
// | | |
// +-------+-------------------+
// +-------+-------------------+
// | 0 | Active record |
// +-------+-------------------+
// | 1 | Released record |
// +-------+-------------------+
// | 2 | Tombstoned record |
// +-------+-------------------+
// | 3 | Deleted record |
// +-------+-------------------+
State uint32 `idl:"name:State_e" json:"state"`
// fStatic: A value that indicates whether the record is static or dynamic. A value
// of 0 indicates a dynamic record, and 1 indicates a static record. Only the least-significant
// bit is considered valid. All other bits are masked with zero.
Static uint32 `idl:"name:fStatic" json:"static"`
// TimeStamp: The time stamp [ISO-8601] of the record.
Timestamp uint64 `idl:"name:TimeStamp" json:"timestamp"`
}
func (o *RecordAction) xxx_PreparePayload(ctx context.Context) error {
if o.Name != nil && o.NameLength == 0 {
o.NameLength = uint32((len(o.Name) - 1))
if len(o.Name) < 1 {
o.NameLength = uint32(0)
}
}
if o.Addrs != nil && o.NumberOfAddrs == 0 {
o.NumberOfAddrs = uint32(len(o.Addrs))
}
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *RecordAction) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(8); err != nil {
return err
}
if err := w.WriteData(uint16(o.Cmd)); err != nil {
return err
}
if o.Name != nil || (o.NameLength+1) > 0 {
_ptr_pName := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
dimSize1 := uint64((o.NameLength + 1))
if err := w.WriteSize(dimSize1); err != nil {
return err
}
sizeInfo := []uint64{
dimSize1,
}
for i1 := range o.Name {
i1 := i1
if uint64(i1) >= sizeInfo[0] {
break
}
if err := w.WriteData(o.Name[i1]); err != nil {
return err
}
}
for i1 := len(o.Name); uint64(i1) < sizeInfo[0]; i1++ {
if err := w.WriteData(uint8(0)); err != nil {
return err
}
}
return nil
})
if err := w.WritePointer(&o.Name, _ptr_pName); err != nil {
return err
}
} else {
if err := w.WritePointer(nil); err != nil {
return err
}
}
if err := w.WriteData(o.NameLength); err != nil {
return err
}
if err := w.WriteData(o.TypeOfRecord); err != nil {
return err
}
if err := w.WriteData(o.NumberOfAddrs); err != nil {
return err
}
if o.Addrs != nil || o.NumberOfAddrs > 0 {
_ptr_pAddrs := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
dimSize1 := uint64(o.NumberOfAddrs)
if err := w.WriteSize(dimSize1); err != nil {
return err
}
sizeInfo := []uint64{
dimSize1,
}
for i1 := range o.Addrs {
i1 := i1
if uint64(i1) >= sizeInfo[0] {
break
}
if o.Addrs[i1] != nil {
if err := o.Addrs[i1].MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Addr{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
}
for i1 := len(o.Addrs); uint64(i1) < sizeInfo[0]; i1++ {
if err := (&Addr{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
return nil
})
if err := w.WritePointer(&o.Addrs, _ptr_pAddrs); err != nil {
return err
}
} else {
if err := w.WritePointer(nil); err != nil {
return err
}
}
if o.Addr != nil {
if err := o.Addr.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Addr{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
if o.VersNo != nil {
if err := o.VersNo.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&dtyp.LargeInteger{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
if err := w.WriteData(o.NodeType); err != nil {
return err
}
if err := w.WriteData(o.OwnerID); err != nil {
return err
}
if err := w.WriteData(o.State); err != nil {
return err
}
if err := w.WriteData(o.Static); err != nil {
return err
}
if err := w.WriteData(ndr.Uint3264(o.Timestamp)); err != nil {
return err
}
return nil
}
func (o *RecordAction) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(8); err != nil {
return err
}
if err := w.ReadData((*uint16)(&o.Cmd)); err != nil {
return err
}
_ptr_pName := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
sizeInfo := []uint64{
0,
}
for sz1 := range sizeInfo {
if err := w.ReadSize(&sizeInfo[sz1]); err != nil {
return err
}
}
// XXX: for opaque unmarshaling
if (o.NameLength+1) > 0 && sizeInfo[0] == 0 {
sizeInfo[0] = uint64((o.NameLength + 1))
}
if sizeInfo[0] > uint64(w.Len()) /* sanity-check */ {
return fmt.Errorf("buffer overflow for size %d of array o.Name", sizeInfo[0])
}
o.Name = make([]byte, sizeInfo[0])
for i1 := range o.Name {
i1 := i1
if err := w.ReadData(&o.Name[i1]); err != nil {
return err
}
}
return nil
})
_s_pName := func(ptr interface{}) { o.Name = *ptr.(*[]byte) }
if err := w.ReadPointer(&o.Name, _s_pName, _ptr_pName); err != nil {
return err
}
if err := w.ReadData(&o.NameLength); err != nil {
return err
}
if err := w.ReadData(&o.TypeOfRecord); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfAddrs); err != nil {
return err
}
_ptr_pAddrs := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
sizeInfo := []uint64{
0,
}
for sz1 := range sizeInfo {
if err := w.ReadSize(&sizeInfo[sz1]); err != nil {
return err
}
}
// XXX: for opaque unmarshaling
if o.NumberOfAddrs > 0 && sizeInfo[0] == 0 {
sizeInfo[0] = uint64(o.NumberOfAddrs)
}
if sizeInfo[0] > uint64(w.Len()) /* sanity-check */ {
return fmt.Errorf("buffer overflow for size %d of array o.Addrs", sizeInfo[0])
}
o.Addrs = make([]*Addr, sizeInfo[0])
for i1 := range o.Addrs {
i1 := i1
if o.Addrs[i1] == nil {
o.Addrs[i1] = &Addr{}
}
if err := o.Addrs[i1].UnmarshalNDR(ctx, w); err != nil {
return err
}
}
return nil
})
_s_pAddrs := func(ptr interface{}) { o.Addrs = *ptr.(*[]*Addr) }
if err := w.ReadPointer(&o.Addrs, _s_pAddrs, _ptr_pAddrs); err != nil {
return err
}
if o.Addr == nil {
o.Addr = &Addr{}
}
if err := o.Addr.UnmarshalNDR(ctx, w); err != nil {
return err
}
if o.VersNo == nil {
o.VersNo = &dtyp.LargeInteger{}
}
if err := o.VersNo.UnmarshalNDR(ctx, w); err != nil {
return err
}
if err := w.ReadData(&o.NodeType); err != nil {
return err
}
if err := w.ReadData(&o.OwnerID); err != nil {
return err
}
if err := w.ReadData(&o.State); err != nil {
return err
}
if err := w.ReadData(&o.Static); err != nil {
return err
}
if err := w.ReadData((*ndr.Uint3264)(&o.Timestamp)); err != nil {
return err
}
return nil
}
// ReplicationCounters structure represents WINSINTF_RPL_COUNTERS_T RPC structure.
//
// The WINSINTF_RPL_COUNTERS_T structure defines counters that contain the number of
// successful pull replications and the number of communication failures for a given
// replication partner. It is used in the structure WINSINTF_STAT_T.
type ReplicationCounters struct {
Addr *Addr `idl:"name:Addr" json:"addr"`
// NoOfRpls: The number of successful pull replications that have been performed with
// the replication partner. The target WINS server stores the replication partner's
// IP address in the Add member.
NumberOfRpls uint32 `idl:"name:NoOfRpls" json:"number_of_rpls"`
// NoOfCommFails: The number of communication failures that have occurred in pull replications
// between the WINS server whose IP address is given in Add and the target WINS server.
NumberOfCommFails uint32 `idl:"name:NoOfCommFails" json:"number_of_comm_fails"`
}
func (o *ReplicationCounters) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *ReplicationCounters) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(4); err != nil {
return err
}
if o.Addr != nil {
if err := o.Addr.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Addr{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
if err := w.WriteData(o.NumberOfRpls); err != nil {
return err
}
if err := w.WriteData(o.NumberOfCommFails); err != nil {
return err
}
return nil
}
func (o *ReplicationCounters) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if o.Addr == nil {
o.Addr = &Addr{}
}
if err := o.Addr.UnmarshalNDR(ctx, w); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfRpls); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfCommFails); err != nil {
return err
}
return nil
}
// Stat structure represents WINSINTF_STAT_T RPC structure.
//
// The WINSINTF_STAT_T structure defines counters, configured timestamps, the pull replication
// statistics for a given WINS server. This structure is used by the structure WINSINTF_RESULTS_T
// (section 2.2.2.7).
type Stat struct {
// Counters: A structure that contains 32-bit unsigned integer counters, which measure
// various statistics on a WINS server.
Counters *Stat_Counters `idl:"name:Counters" json:"counters"`
// TimeStamps: A structure that contains data in SYSTEMTIME structures ([MS-DTYP]
// section 2.3.13), which reflect the local time zone of the target WINS server.
Timestamps *Stat_Timestamps `idl:"name:TimeStamps" json:"timestamps"`
// NoOfPnrs: The number of pull partners configured for the target WINS server.
NumberOfPullPartners uint32 `idl:"name:NoOfPnrs" json:"number_of_pull_partners"`
// pRplPnrs: A pointer to structures that contain the details of successful and failed
// replication counters of configured pull partners at the target WINS server, since
// the time service was started; or, the time at which the last reset happened by a
// call to the method R_WinsResetCounters (section 3.1.4.12). The number of structures
// is specified by NoOfPnrs.
PeriodicReplicationPullPartners []*ReplicationCounters `idl:"name:pRplPnrs;size_is:(NoOfPnrs);pointer:unique" json:"periodic_replication_pull_partners"`
}
func (o *Stat) xxx_PreparePayload(ctx context.Context) error {
if o.PeriodicReplicationPullPartners != nil && o.NumberOfPullPartners == 0 {
o.NumberOfPullPartners = uint32(len(o.PeriodicReplicationPullPartners))
}
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *Stat) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(9); err != nil {
return err
}
if o.Counters != nil {
if err := o.Counters.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Stat_Counters{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
if o.Timestamps != nil {
if err := o.Timestamps.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&Stat_Timestamps{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
if err := w.WriteData(o.NumberOfPullPartners); err != nil {
return err
}
if o.PeriodicReplicationPullPartners != nil || o.NumberOfPullPartners > 0 {
_ptr_pRplPnrs := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
dimSize1 := uint64(o.NumberOfPullPartners)
if err := w.WriteSize(dimSize1); err != nil {
return err
}
sizeInfo := []uint64{
dimSize1,
}
for i1 := range o.PeriodicReplicationPullPartners {
i1 := i1
if uint64(i1) >= sizeInfo[0] {
break
}
if o.PeriodicReplicationPullPartners[i1] != nil {
if err := o.PeriodicReplicationPullPartners[i1].MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&ReplicationCounters{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
}
for i1 := len(o.PeriodicReplicationPullPartners); uint64(i1) < sizeInfo[0]; i1++ {
if err := (&ReplicationCounters{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
return nil
})
if err := w.WritePointer(&o.PeriodicReplicationPullPartners, _ptr_pRplPnrs); err != nil {
return err
}
} else {
if err := w.WritePointer(nil); err != nil {
return err
}
}
return nil
}
func (o *Stat) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(9); err != nil {
return err
}
if o.Counters == nil {
o.Counters = &Stat_Counters{}
}
if err := o.Counters.UnmarshalNDR(ctx, w); err != nil {
return err
}
if o.Timestamps == nil {
o.Timestamps = &Stat_Timestamps{}
}
if err := o.Timestamps.UnmarshalNDR(ctx, w); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfPullPartners); err != nil {
return err
}
_ptr_pRplPnrs := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
sizeInfo := []uint64{
0,
}
for sz1 := range sizeInfo {
if err := w.ReadSize(&sizeInfo[sz1]); err != nil {
return err
}
}
// XXX: for opaque unmarshaling
if o.NumberOfPullPartners > 0 && sizeInfo[0] == 0 {
sizeInfo[0] = uint64(o.NumberOfPullPartners)
}
if sizeInfo[0] > uint64(w.Len()) /* sanity-check */ {
return fmt.Errorf("buffer overflow for size %d of array o.PeriodicReplicationPullPartners", sizeInfo[0])
}
o.PeriodicReplicationPullPartners = make([]*ReplicationCounters, sizeInfo[0])
for i1 := range o.PeriodicReplicationPullPartners {
i1 := i1
if o.PeriodicReplicationPullPartners[i1] == nil {
o.PeriodicReplicationPullPartners[i1] = &ReplicationCounters{}
}
if err := o.PeriodicReplicationPullPartners[i1].UnmarshalNDR(ctx, w); err != nil {
return err
}
}
return nil
})
_s_pRplPnrs := func(ptr interface{}) { o.PeriodicReplicationPullPartners = *ptr.(*[]*ReplicationCounters) }
if err := w.ReadPointer(&o.PeriodicReplicationPullPartners, _s_pRplPnrs, _ptr_pRplPnrs); err != nil {
return err
}
return nil
}
// Stat_Counters structure represents WINSINTF_STAT_T structure anonymous member.
//
// The WINSINTF_STAT_T structure defines counters, configured timestamps, the pull replication
// statistics for a given WINS server. This structure is used by the structure WINSINTF_RESULTS_T
// (section 2.2.2.7).
type Stat_Counters struct {
// NoOfUniqueReg: The number of unique registrations on the target WINS server since
// the service was started.
NumberOfUniqueReg uint32 `idl:"name:NoOfUniqueReg" json:"number_of_unique_reg"`
// NoOfGroupReg: The number of group registrations at the target WINS server since
// the service was started.
NumberOfGroupReg uint32 `idl:"name:NoOfGroupReg" json:"number_of_group_reg"`
// NoOfQueries: The number of queries that clients have performed on the target WINS
// server to resolve NetBIOS names since the service was started. This value is the
// sum of the values maintained in NoOfSuccQueries and NoOfFailQueries.
NumberOfQueries uint32 `idl:"name:NoOfQueries" json:"number_of_queries"`
// NoOfSuccQueries: The number of successful name resolution queries on the target
// WINS server since the service was started.
NumberOfSuccessQueries uint32 `idl:"name:NoOfSuccQueries" json:"number_of_success_queries"`
// NoOfFailQueries: The number of failed name resolution queries on the target WINS
// server since the service was started.
NumberOfFailQueries uint32 `idl:"name:NoOfFailQueries" json:"number_of_fail_queries"`
// NoOfUniqueRef: The number of unique name refreshes on the target WINS server since
// the service was started.
NumberOfUniqueReference uint32 `idl:"name:NoOfUniqueRef" json:"number_of_unique_reference"`
// NoOfGroupRef: The number of group name refreshes on the target WINS server since
// the service was started.
NumberOfGroupReference uint32 `idl:"name:NoOfGroupRef" json:"number_of_group_reference"`
// NoOfRel: The number of name releases on the target WINS server since the service
// was started. This value is the sum of the values maintained in NoOfSuccRel and NoOfFailRel.
NumberOfRelation uint32 `idl:"name:NoOfRel" json:"number_of_relation"`
// NoOfSuccRel: The number of successful name releases on the target WINS server since
// the service was started.
NumberOfSuccessRelation uint32 `idl:"name:NoOfSuccRel" json:"number_of_success_relation"`
// NoOfFailRel: The number of failed name releases on the target WINS server since
// the service was started.
NumberOfFailRelation uint32 `idl:"name:NoOfFailRel" json:"number_of_fail_relation"`
// NoOfUniqueCnf: The number of unique name conflicts on the target WINS server since
// the service was started. Unique name conflicts can occur in the following cases:
//
// § The server is registering or refreshing unique name requests from clients.
NumberOfUniqueConflict uint32 `idl:"name:NoOfUniqueCnf" json:"number_of_unique_conflict"`
// NoOfGroupCnf: The number of group name conflicts on the target WINS server since
// the service was started. Group name conflicts can occur in the following cases:
//
// § The server is registering or refreshing unique name requests from clients.
NumberOfGroupConflict uint32 `idl:"name:NoOfGroupCnf" json:"number_of_group_conflict"`
}
func (o *Stat_Counters) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *Stat_Counters) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.NumberOfUniqueReg); err != nil {
return err
}
if err := w.WriteData(o.NumberOfGroupReg); err != nil {
return err
}
if err := w.WriteData(o.NumberOfQueries); err != nil {
return err
}
if err := w.WriteData(o.NumberOfSuccessQueries); err != nil {
return err
}
if err := w.WriteData(o.NumberOfFailQueries); err != nil {
return err
}
if err := w.WriteData(o.NumberOfUniqueReference); err != nil {
return err
}
if err := w.WriteData(o.NumberOfGroupReference); err != nil {
return err
}
if err := w.WriteData(o.NumberOfRelation); err != nil {
return err
}
if err := w.WriteData(o.NumberOfSuccessRelation); err != nil {
return err
}
if err := w.WriteData(o.NumberOfFailRelation); err != nil {
return err
}
if err := w.WriteData(o.NumberOfUniqueConflict); err != nil {
return err
}
if err := w.WriteData(o.NumberOfGroupConflict); err != nil {
return err
}
return nil
}
func (o *Stat_Counters) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfUniqueReg); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfGroupReg); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfQueries); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfSuccessQueries); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfFailQueries); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfUniqueReference); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfGroupReference); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfRelation); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfSuccessRelation); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfFailRelation); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfUniqueConflict); err != nil {
return err
}
if err := w.ReadData(&o.NumberOfGroupConflict); err != nil {
return err
}
return nil
}
// Stat_Timestamps structure represents WINSINTF_STAT_T structure anonymous member.
//
// The WINSINTF_STAT_T structure defines counters, configured timestamps, the pull replication
// statistics for a given WINS server. This structure is used by the structure WINSINTF_RESULTS_T
// (section 2.2.2.7).
type Stat_Timestamps struct {
// WINSStartTime: The time at which the WINS service was started on the target WINS
// server.
WINSStartTime *dtyp.SystemTime `idl:"name:WINSStartTime" json:"wins_start_time"`
// LastPScvTime: The time at which the last periodic scavenging operation was done
// on the target WINS server.
LastPeriodicScavengingTime *dtyp.SystemTime `idl:"name:LastPScvTime" json:"last_periodic_scavenging_time"`
// LastATScvTime: The time at which the last administrator-triggered scavenging operation
// was done on the target WINS server.
LastATScavengingTime *dtyp.SystemTime `idl:"name:LastATScvTime" json:"last_at_scavenging_time"`
// LastTombScvTime: The time at which the last scavenging operation was done for the
// replicated tombstone records on the target WINS server.
LastTombScavengingTime *dtyp.SystemTime `idl:"name:LastTombScvTime" json:"last_tomb_scavenging_time"`
// LastVerifyScvTime: The time at which the last verification scavenging operation
// was done for the replicated active records on the target WINS server.
LastVerifyScavengingTime *dtyp.SystemTime `idl:"name:LastVerifyScvTime" json:"last_verify_scavenging_time"`
// LastPRplTime: The time at which the last periodic pull replication was done on the
// target WINS server.
LastPeriodicReplicationTime *dtyp.SystemTime `idl:"name:LastPRplTime" json:"last_periodic_replication_time"`
// LastATRplTime: The time at which the last administrator-triggered pull replication
// was done on the target WINS server.
LastATReplicationTime *dtyp.SystemTime `idl:"name:LastATRplTime" json:"last_at_replication_time"`
// LastNTRplTime: This member is not set and MUST be ignored on receipt.
LastNTReplicationTime *dtyp.SystemTime `idl:"name:LastNTRplTime" json:"last_nt_replication_time"`
// LastACTRplTime: This member is not set and MUST be ignored on receipt.