-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathoxcrpc.go
156 lines (146 loc) · 4.3 KB
/
oxcrpc.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
// The oxcrpc package implements the OXCRPC client protocol.
//
// # Introduction
//
// The Wire Format Protocol is used by a client to communicate with a server to access
// personal messaging data by using remote procedure call (RPC) interfaces. The Wire
// Format Protocol uses the EMSMDB and AsyncEMSMDB protocol interfaces between a client
// and server. This protocol extends DCE 1.1: Remote Procedure Call, as described in
// [C706].
//
// # Overview
//
// The Wire Format Protocol enables a client to communicate with a server to access
// personal messaging data. Communications with the server are divided into three major
// functional areas: (1) initiating and establishing connection with the server, (2)
// issuing remote operations (ROPs) to the server for mailbox data, and (3) terminating
// communications with the server. This functionality is contained in the EMSMDB interface,
// as described in section 3.1 and section 3.2. If events are pending on the server
// that require client action, the client gets notification of those pending events
// by using the functionality contained in the AsyncEMSMDB interface, as described in
// section 3.3 and section 3.4.
//
// The following figure shows a simplified overview of client and server communications.
package oxcrpc
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"
dcetypes "github.com/oiweiwei/go-msrpc/msrpc/dcetypes"
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)
_ = dcetypes.GoPackage
_ = dtyp.GoPackage
)
var (
// import guard
GoPackage = "oxcrpc"
)
// Session structure represents CXH RPC structure.
type Session dcetypes.ContextHandle
func (o *Session) ContextHandle() *dcetypes.ContextHandle { return (*dcetypes.ContextHandle)(o) }
func (o *Session) 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 *Session) 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.Attributes); err != nil {
return err
}
if o.UUID != nil {
if err := o.UUID.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&dtyp.GUID{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
return nil
}
func (o *Session) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.Attributes); err != nil {
return err
}
if o.UUID == nil {
o.UUID = &dtyp.GUID{}
}
if err := o.UUID.UnmarshalNDR(ctx, w); err != nil {
return err
}
return nil
}
// AsyncSession structure represents ACXH RPC structure.
type AsyncSession dcetypes.ContextHandle
func (o *AsyncSession) ContextHandle() *dcetypes.ContextHandle { return (*dcetypes.ContextHandle)(o) }
func (o *AsyncSession) 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 *AsyncSession) 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.Attributes); err != nil {
return err
}
if o.UUID != nil {
if err := o.UUID.MarshalNDR(ctx, w); err != nil {
return err
}
} else {
if err := (&dtyp.GUID{}).MarshalNDR(ctx, w); err != nil {
return err
}
}
return nil
}
func (o *AsyncSession) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.Attributes); err != nil {
return err
}
if o.UUID == nil {
o.UUID = &dtyp.GUID{}
}
if err := o.UUID.UnmarshalNDR(ctx, w); err != nil {
return err
}
return nil
}