-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.go
159 lines (147 loc) · 5.5 KB
/
server.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
package ienumvariant
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"
iunknown "github.com/oiweiwei/go-msrpc/msrpc/dcom/iunknown/v0"
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)
_ = iunknown.GoPackage
)
// IEnumVARIANT server interface.
type EnumVariantServer interface {
// IUnknown base class.
iunknown.UnknownServer
// The IEnumVARIANT::Next method returns up to the number of requested items that occur
// next in the enumeration sequence.
//
// Return Values: The method MUST return the information in an HRESULT data structure,
// which is defined in [MS-ERREF] section 2.1. The severity bit in the structure identifies
// the following conditions:
//
// * If the severity bit is set to 0, the method completed successfully.
//
// * If the severity bit is set to 1, the method failed and encountered a fatal error.
//
// A static or semistatic IEnumVARIANT server MUST retrieve the next celt elements from
// the sequence and fill in rgVar up to the celt elements or up to the remaining number
// of elements that are not yet enumerated.
//
// A dynamic server MUST use its server-specific state to retrieve the next elements.
//
// In all cases, the server MUST:
//
// * Set pCeltFetched with the number retrieved.
//
// * Update the current position in the sequence.
//
// * Return a status of 1 (S_FALSE) if pCeltFetched is not equal to celt.
Next(context.Context, *NextRequest) (*NextResponse, error)
// The IEnumVARIANT::Skip method skips over the requested number of elements in the
// enumeration sequence.
//
// Return Values: The method MUST return information in an HRESULT data structure, defined
// in [MS-ERREF] section 2.1. The severity bit in the structure identifies the following
// conditions:
//
// * If the severity bit is set to 0, the method completed successfully.
//
// * If the severity bit is set to 1, the method failed and encountered a fatal error.
//
// A static or semi-static IEnumVARIANT server MUST update the current position in the
// sequence by either celt elements, or the number of elements remaining, whichever
// is smaller.
//
// A dynamic server MUST use its server-specific state to affect the dynamic collection
// it manages, and MUST update the current position in the sequence by either celt elements,
// or the number of elements remaining, whichever is smaller.
//
// In all cases, the server MUST return 1 (S_FALSE), if the current position was updated
// by less than celt elements.
Skip(context.Context, *SkipRequest) (*SkipResponse, error)
// The IEnumVARIANT::Reset method resets the enumeration sequence to the beginning.
//
// This method has no parameters.
//
// Return Values: The method MUST return information in an HRESULT data structure, defined
// in [MS-ERREF] section 2.1. The severity bit in the structure identifies the following
// conditions:
//
// * If the severity bit is set to 0, the method completed successfully.
//
// * If the severity bit is set to 1, the method failed and encountered a fatal error.
//
// A static server MUST reset its current position in the sequence.
//
// A semi-static or dynamic server MUST update the sequence of elements it maintains
// and MUST reset the current position in the sequence to the beginning.
Reset(context.Context, *ResetRequest) (*ResetResponse, error)
// The IEnumVARIANT::Clone method creates a copy of the current state of the enumeration.
//
// Return Values: The method MUST return information in an HRESULT data structure, defined
// in [MS-ERREF] section 2.1. The severity bit in the structure identifies the following
// conditions:
//
// * If the severity bit is set to 0, the method completed successfully.
//
// * If the severity bit is set to 1, the method failed and encountered a fatal error.
Clone(context.Context, *CloneRequest) (*CloneResponse, error)
}
func RegisterEnumVariantServer(conn dcerpc.Conn, o EnumVariantServer, opts ...dcerpc.Option) {
conn.RegisterServer(NewEnumVariantServerHandle(o), append(opts, dcerpc.WithAbstractSyntax(EnumVariantSyntaxV0_0))...)
}
func NewEnumVariantServerHandle(o EnumVariantServer) dcerpc.ServerHandle {
return func(ctx context.Context, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
return EnumVariantServerHandle(ctx, o, opNum, r)
}
}
func EnumVariantServerHandle(ctx context.Context, o EnumVariantServer, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
if opNum < 3 {
// IUnknown base method.
return iunknown.UnknownServerHandle(ctx, o, opNum, r)
}
switch opNum {
case 3: // Next
in := &NextRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.Next(ctx, in)
return resp.xxx_ToOp(ctx), err
case 4: // Skip
in := &SkipRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.Skip(ctx, in)
return resp.xxx_ToOp(ctx), err
case 5: // Reset
in := &ResetRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.Reset(ctx, in)
return resp.xxx_ToOp(ctx), err
case 6: // Clone
in := &CloneRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.Clone(ctx, in)
return resp.xxx_ToOp(ctx), err
}
return nil, nil
}