-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.go
143 lines (132 loc) · 5.93 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
package qmcomm2
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"
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)
)
// qmcomm2 server interface.
type Qmcomm2Server interface {
// A client invokes QMSendMessageInternalEx if the server returns STATUS_RETRY (0xc000022d)
// from a prior call to rpc_ACSendMessageEx. Implementations of this protocol SHOULD
// NOT return STATUS_RETRY from rpc_ACSendMessageEx, rendering this method unnecessary.
// Such implementations MUST take no action when QMSendMessageInternalEx is invoked
// and return MQ_ERROR_ILLEGAL_OPERATION (0xc00e0064).
//
// Return Values: On success, this method MUST return MQ_OK (0x00000000); otherwise,
// the server MUST return a failure HRESULT,<67> and the client MUST treat all failure
// HRESULTs identically. Additionally, if a failure HRESULT is returned, the client
// MUST disregard all out-parameter values.
//
// Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying
// RPC protocol, as specified in [MS-RPCE].
//
// This method is invoked at the dynamically assigned endpoint returned by the R_QMGetRTQMServerPort
// method when IP_HANDSHAKE (0x00000000) or IPX_HANDSHAKE (0x00000002) is the interface
// specified by the fIP parameter.
QMSendMessageInternalEx(context.Context, *QMSendMessageInternalExRequest) (*QMSendMessageInternalExResponse, error)
// A client calls the rpc_ACSendMessageEx method to place a message into a message queue
// for delivery.
//
// Return Values: On success, this method MUST return MQ_OK (0x00000000); otherwise,
// the server MUST return a failure HRESULT,<72> and the client MUST treat all failure
// HRESULTs identically. Additionally, if a failure HRESULT is returned, the client
// MUST disregard all out-parameter values.
//
// Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying
// RPC protocol, as specified in [MS-RPCE].
//
// This method is invoked at the dynamically assigned endpoint returned by the R_QMGetRTQMServerPort
// (section 3.1.4.24) method when IP_HANDSHAKE (0x00000000) or IPX_HANDSHAKE (0x00000002)
// is the interface specified by the fIP parameter.
//
// Security Considerations: The caller can request that the server perform security
// related operations such as signing and encrypting the message. These operations are
// requested by setting members of the ptb.CACTransferBufferOld structure.
SendMessageEx(context.Context, *SendMessageExRequest) (*SendMessageExResponse, error)
// A client calls rpc_ACReceiveMessageEx to peek or receive a message from a message
// queue.
//
// Return Values: On success, this method MUST return MQ_OK (0x00000000); otherwise,
// the server MUST return a failure HRESULT,<73><74> and the client MUST treat all failure
// HRESULTs identically. Additionally, if a failure HRESULT is returned, the client
// MUST disregard all out-parameter values.
//
// Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying
// RPC protocol, as specified in [MS-RPCE].
//
// This method is invoked at the dynamically assigned endpoint returned by the R_QMGetRTQMServerPort
// method when IP_HANDSHAKE (0x00000000) or IPX_HANDSHAKE (0x00000002) is the interface
// specified by the fIP parameter.
ReceiveMessageEx(context.Context, *ReceiveMessageExRequest) (*ReceiveMessageExResponse, error)
// A client calls rpc_ACCreateCursorEx to create a cursor for use when peeking and receiving
// from a message queue.
//
// Return Values: On success, this method MUST return MQ_OK (0x00000000); otherwise,
// the server MUST return a failure HRESULT,<75> and the client MUST treat all failure
// HRESULTs identically. Additionally, if a failure HRESULT is returned, the client
// MUST disregard all out-parameter values.
//
// Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying
// RPC protocol, as specified in [MS-RPCE].
//
// This method is invoked at the dynamically assigned endpoint returned by the R_QMGetRTQMServerPort
// (section 3.1.4.24) method when IP_HANDSHAKE (0x00000000) or IPX_HANDSHAKE (0x00000002)
// is the interface specified by the fIP parameter.
CreateCursorEx(context.Context, *CreateCursorExRequest) (*CreateCursorExResponse, error)
}
func RegisterQmcomm2Server(conn dcerpc.Conn, o Qmcomm2Server, opts ...dcerpc.Option) {
conn.RegisterServer(NewQmcomm2ServerHandle(o), append(opts, dcerpc.WithAbstractSyntax(Qmcomm2SyntaxV1_0))...)
}
func NewQmcomm2ServerHandle(o Qmcomm2Server) dcerpc.ServerHandle {
return func(ctx context.Context, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
return Qmcomm2ServerHandle(ctx, o, opNum, r)
}
}
func Qmcomm2ServerHandle(ctx context.Context, o Qmcomm2Server, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
switch opNum {
case 0: // QMSendMessageInternalEx
in := &QMSendMessageInternalExRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.QMSendMessageInternalEx(ctx, in)
return resp.xxx_ToOp(ctx), err
case 1: // rpc_ACSendMessageEx
in := &SendMessageExRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.SendMessageEx(ctx, in)
return resp.xxx_ToOp(ctx), err
case 2: // rpc_ACReceiveMessageEx
in := &ReceiveMessageExRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ReceiveMessageEx(ctx, in)
return resp.xxx_ToOp(ctx), err
case 3: // rpc_ACCreateCursorEx
in := &CreateCursorExRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.CreateCursorEx(ctx, in)
return resp.xxx_ToOp(ctx), err
}
return nil, nil
}