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
|
/*
Unix SMB/CIFS implementation.
DCERPC interface structures
Copyright (C) Tim Potter 2003
Copyright (C) Andrew Tridgell 2003
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
enum dcerpc_transport_t {NCACN_NP, NCACN_IP_TCP};
/*
this defines a generic security context for signed/sealed dcerpc pipes.
*/
struct dcerpc_pipe;
struct dcerpc_security {
struct dcerpc_auth *auth_info;
struct gensec_security *generic_state;
/* get the session key */
NTSTATUS (*session_key)(struct dcerpc_pipe *, DATA_BLOB *);
};
struct dcerpc_pipe {
int reference_count;
uint32_t call_id;
uint32_t srv_max_xmit_frag;
uint32_t srv_max_recv_frag;
uint_t flags;
struct dcerpc_security security_state;
const char *binding_string;
struct dcerpc_syntax_id syntax;
struct dcerpc_syntax_id transfer_syntax;
struct dcerpc_transport {
enum dcerpc_transport_t transport;
void *private;
NTSTATUS (*shutdown_pipe)(struct dcerpc_pipe *);
const char *(*peer_name)(struct dcerpc_pipe *);
/* send a request to the server */
NTSTATUS (*send_request)(struct dcerpc_pipe *, DATA_BLOB *, BOOL trigger_read);
/* send a read request to the server */
NTSTATUS (*send_read)(struct dcerpc_pipe *);
/* get an event context for the connection */
struct event_context *(*event_context)(struct dcerpc_pipe *);
/* a callback to the dcerpc code when a full fragment
has been received */
void (*recv_data)(struct dcerpc_pipe *, DATA_BLOB *, NTSTATUS status);
} transport;
/* the last fault code from a DCERPC fault */
uint32_t last_fault_code;
/* pending requests */
struct rpc_request *pending;
/* private pointer for pending full requests */
void *full_request_private;
};
/* dcerpc pipe flags */
#define DCERPC_DEBUG_PRINT_IN (1<<0)
#define DCERPC_DEBUG_PRINT_OUT (1<<1)
#define DCERPC_DEBUG_PRINT_BOTH (DCERPC_DEBUG_PRINT_IN | DCERPC_DEBUG_PRINT_OUT)
#define DCERPC_DEBUG_VALIDATE_IN (1<<2)
#define DCERPC_DEBUG_VALIDATE_OUT (1<<3)
#define DCERPC_DEBUG_VALIDATE_BOTH (DCERPC_DEBUG_VALIDATE_IN | DCERPC_DEBUG_VALIDATE_OUT)
#define DCERPC_CONNECT (1<<4)
#define DCERPC_SIGN (1<<5)
#define DCERPC_SEAL (1<<6)
#define DCERPC_PUSH_BIGENDIAN (1<<7)
#define DCERPC_PULL_BIGENDIAN (1<<8)
#define DCERPC_SCHANNEL_BDC (1<<9)
#define DCERPC_SCHANNEL_WORKSTATION (1<<10)
#define DCERPC_SCHANNEL_DOMAIN (1<<11)
#define DCERPC_SCHANNEL_ANY (DCERPC_SCHANNEL_BDC| \
DCERPC_SCHANNEL_DOMAIN| \
DCERPC_SCHANNEL_WORKSTATION)
/* use a 128 bit session key */
#define DCERPC_SCHANNEL_128 (1<<12)
#define DCERPC_AUTH_OPTIONS (DCERPC_SEAL|DCERPC_SIGN|DCERPC_SCHANNEL_ANY)
/* check incoming pad bytes */
#define DCERPC_DEBUG_PAD_CHECK (1<<13)
/* set LIBNDR_FLAG_REF_ALLOC flag when decoding NDR */
#define DCERPC_NDR_REF_ALLOC (1<<14)
/*
this is used to find pointers to calls
*/
struct dcerpc_interface_call {
const char *name;
size_t struct_size;
NTSTATUS (*ndr_push)(struct ndr_push *, int , void *);
NTSTATUS (*ndr_pull)(struct ndr_pull *, int , void *);
void (*ndr_print)(struct ndr_print *, const char *, int, void *);
};
struct dcerpc_endpoint_list {
uint32_t count;
const char * const *names;
};
struct dcerpc_interface_table {
const char *name;
const char *uuid;
uint32_t if_version;
const char *helpstring;
uint32_t num_calls;
const struct dcerpc_interface_call *calls;
const struct dcerpc_endpoint_list *endpoints;
};
/* this describes a binding to a particular transport/pipe */
struct dcerpc_binding {
enum dcerpc_transport_t transport;
const char *host;
const char **options;
uint32_t flags;
};
enum rpc_request_state {
RPC_REQUEST_PENDING,
RPC_REQUEST_DONE
};
/*
handle for an async dcerpc request
*/
struct rpc_request {
struct rpc_request *next, *prev;
struct dcerpc_pipe *p;
NTSTATUS status;
uint32_t call_id;
enum rpc_request_state state;
DATA_BLOB payload;
uint_t flags;
uint32_t fault_code;
/* use by the ndr level async recv call */
struct rpc_request_ndr {
NTSTATUS (*ndr_push)(struct ndr_push *, int, void *);
NTSTATUS (*ndr_pull)(struct ndr_pull *, int, void *);
void *struct_ptr;
size_t struct_size;
TALLOC_CTX *mem_ctx;
} ndr;
struct {
void (*callback)(struct rpc_request *);
void *private;
} async;
};
|