-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.go
130 lines (119 loc) · 5.45 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
package faxclient
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)
)
// faxclient server interface.
type FaxclientServer interface {
// The FAX_OpenConnection (Opnum 0) method returns the context handle that is supplied
// by the FAX_StartServerNotification family of calls. This is done to provide a security
// layer, by verifying that the notifications are coming from an expected source.
//
// Exceptions Thrown: No exceptions are thrown except those thrown by the underlying
// RPC protocol, [MS-RPCE].
//
// The returned PRPC_FAX_HANDLE is the Context parameter cast to a HANDLE.
//
// The FAX_OpenConnection method returns the context handle supplied by the FAX_StartServerNotification
// family of calls. This is done to provide a security layer, by verifying that the
// notifications are coming from an expected source.
OpenConnection(context.Context, *OpenConnectionRequest) (*OpenConnectionResponse, error)
// The FAX_ClientEventQueue (Opnum 1) method is called by the fax server (acting as
// an RPC client for this call) when it needs to deliver a legacy fax event to the fax
// client (acting as an RPC server for this call). The fax client registers for notifications
// of legacy events with the fax server by calling FAX_StartServerNotification (section
// 3.1.4.1.100) or FAX_StartServerNotificationEx (section 3.1.4.1.101). In this call,
// the fax client MUST pass a fax client notification context, which the fax server
// MUST pass back to the fax client when it sends an event. This is done to provide
// a security layer, by verifying that the notifications are coming from an expected
// source.
//
// Exceptions Thrown: No exceptions are thrown except those that are thrown by the underlying
// RPC protocol, [MS-RPCE].
ClientEventQueue(context.Context, *ClientEventQueueRequest) (*ClientEventQueueResponse, error)
// The FAX_CloseConnection (Opnum 2) method is called by the fax server (acting as an
// RPC client for this call) when it needs to release the connection to the fax client
// (acting as an RPC server for this call). When the fax client calls FAX_EndServerNotification
// (section 3.1.4.1.17), the fax server MUST release the RPC connection to the fax client
// through this call.
//
// Exceptions Thrown: No exceptions are thrown except those that are thrown by the underlying
// RPC protocol, [MS-RPCE].
CloseConnection(context.Context, *CloseConnectionRequest) (*CloseConnectionResponse, error)
// The FAX_ClientEventQueueEx (Opnum 3) method is called by the fax server (acting as
// an RPC client for this call) when it needs to deliver an extended fax event to the
// fax client (acting as an RPC server for this call). The fax client registers for
// notifications with the fax server by calling either FAX_StartServerNotificationEx
// (section 3.1.4.1.101) or FAX_StartServerNotificationEx2 (section 3.1.4.1.102). In
// this call, the fax client MUST pass a fax client notification context, which the
// fax server MUST pass back to the fax client when it sends an event. This is done
// to provide a security layer, by verifying that the notifications are coming from
// an expected source.
//
// Data in FAX_ClientEventQueueEx is serialized. Pointers to variable-size data (such
// as strings) are replaced with offsets from the beginning of the buffer.
//
// Exceptions Thrown: No exceptions are thrown except those that are thrown by the underlying
// RPC protocol, [MS-RPCE].
//
// Data in FAX_ClientEventQueueEx is serialized. Pointers to variable size data (such
// as strings) are replaced with offsets from the beginning of the buffer.
ClientEventQueueEx(context.Context, *ClientEventQueueExRequest) (*ClientEventQueueExResponse, error)
}
func RegisterFaxclientServer(conn dcerpc.Conn, o FaxclientServer, opts ...dcerpc.Option) {
conn.RegisterServer(NewFaxclientServerHandle(o), append(opts, dcerpc.WithAbstractSyntax(FaxclientSyntaxV3_0))...)
}
func NewFaxclientServerHandle(o FaxclientServer) dcerpc.ServerHandle {
return func(ctx context.Context, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
return FaxclientServerHandle(ctx, o, opNum, r)
}
}
func FaxclientServerHandle(ctx context.Context, o FaxclientServer, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
switch opNum {
case 0: // FAX_OpenConnection
in := &OpenConnectionRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.OpenConnection(ctx, in)
return resp.xxx_ToOp(ctx), err
case 1: // FAX_ClientEventQueue
in := &ClientEventQueueRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ClientEventQueue(ctx, in)
return resp.xxx_ToOp(ctx), err
case 2: // FAX_CloseConnection
in := &CloseConnectionRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.CloseConnection(ctx, in)
return resp.xxx_ToOp(ctx), err
case 3: // FAX_ClientEventQueueEx
in := &ClientEventQueueExRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ClientEventQueueEx(ctx, in)
return resp.xxx_ToOp(ctx), err
}
return nil, nil
}