r14488: Install more headers.
[kai/samba.git] / source4 / librpc / rpc / dcerpc.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    DCERPC client side interface structures
5
6    Copyright (C) Tim Potter 2003
7    Copyright (C) Andrew Tridgell 2003-2005
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #ifndef __DCERPC_H__
25 #define __DCERPC_H__
26
27 #include "core.h"
28 #include "librpc/gen_ndr/dcerpc.h"
29
30 enum dcerpc_transport_t {
31         NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC, NCACN_VNS_SPP, 
32         NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM, NCADG_UNIX_DGRAM,
33         NCACN_HTTP, NCADG_IPX, NCACN_SPX };
34
35 /*
36   this defines a generic security context for signed/sealed dcerpc pipes.
37 */
38 struct dcerpc_connection;
39 struct dcerpc_security {
40         struct dcerpc_auth *auth_info;
41         struct gensec_security *generic_state;
42
43         /* get the session key */
44         NTSTATUS (*session_key)(struct dcerpc_connection *, DATA_BLOB *);
45 };
46
47 /*
48   this holds the information that is not specific to a particular rpc context_id
49 */
50 struct dcerpc_connection {
51         uint32_t call_id;
52         uint32_t srv_max_xmit_frag;
53         uint32_t srv_max_recv_frag;
54         uint32_t flags;
55         struct dcerpc_security security_state;
56         const char *binding_string;
57         struct event_context *event_ctx;
58
59         struct dcerpc_transport {
60                 enum dcerpc_transport_t transport;
61                 void *private;
62
63                 NTSTATUS (*shutdown_pipe)(struct dcerpc_connection *);
64
65                 const char *(*peer_name)(struct dcerpc_connection *);
66
67                 /* send a request to the server */
68                 NTSTATUS (*send_request)(struct dcerpc_connection *, DATA_BLOB *, BOOL trigger_read);
69
70                 /* send a read request to the server */
71                 NTSTATUS (*send_read)(struct dcerpc_connection *);
72
73                 /* a callback to the dcerpc code when a full fragment
74                    has been received */
75                 void (*recv_data)(struct dcerpc_connection *, DATA_BLOB *, NTSTATUS status);
76         } transport;
77
78         /* Requests that have been sent, waiting for a reply */
79         struct rpc_request *pending;
80
81         /* Sync requests waiting to be shipped */
82         struct rpc_request *request_queue;
83
84         /* private pointer for pending binds */
85         void *bind_private;
86
87         /* private pointer for pending alter context requests */
88         void *alter_private;
89
90         /* the next context_id to be assigned */
91         uint32_t next_context_id;
92 };
93
94 /*
95   this encapsulates a full dcerpc client side pipe 
96 */
97 struct dcerpc_pipe {
98         uint32_t context_id;
99
100         struct dcerpc_syntax_id syntax;
101         struct dcerpc_syntax_id transfer_syntax;
102
103         struct dcerpc_connection *conn;
104         struct dcerpc_binding *binding;
105
106         /* the last fault code from a DCERPC fault */
107         uint32_t last_fault_code;
108
109         /* timeout for individual rpc requests, in seconds */
110         uint32_t request_timeout;
111 };
112
113 /* default timeout for all rpc requests, in seconds */
114 #define DCERPC_REQUEST_TIMEOUT 60
115
116
117 /* dcerpc pipe flags */
118 #define DCERPC_DEBUG_PRINT_IN          (1<<0)
119 #define DCERPC_DEBUG_PRINT_OUT         (1<<1)
120 #define DCERPC_DEBUG_PRINT_BOTH (DCERPC_DEBUG_PRINT_IN | DCERPC_DEBUG_PRINT_OUT)
121
122 #define DCERPC_DEBUG_VALIDATE_IN       (1<<2)
123 #define DCERPC_DEBUG_VALIDATE_OUT      (1<<3)
124 #define DCERPC_DEBUG_VALIDATE_BOTH (DCERPC_DEBUG_VALIDATE_IN | DCERPC_DEBUG_VALIDATE_OUT)
125
126 #define DCERPC_CONNECT                 (1<<4)
127 #define DCERPC_SIGN                    (1<<5)
128 #define DCERPC_SEAL                    (1<<6)
129
130 #define DCERPC_PUSH_BIGENDIAN          (1<<7)
131 #define DCERPC_PULL_BIGENDIAN          (1<<8)
132
133 #define DCERPC_SCHANNEL                (1<<9)
134
135 /* use a 128 bit session key */
136 #define DCERPC_SCHANNEL_128            (1<<12)
137
138 /* check incoming pad bytes */
139 #define DCERPC_DEBUG_PAD_CHECK         (1<<13)
140
141 /* set LIBNDR_FLAG_REF_ALLOC flag when decoding NDR */
142 #define DCERPC_NDR_REF_ALLOC           (1<<14)
143
144 #define DCERPC_AUTH_OPTIONS    (DCERPC_SEAL|DCERPC_SIGN|DCERPC_SCHANNEL|DCERPC_AUTH_SPNEGO|DCERPC_AUTH_KRB5)
145
146 /* enable spnego auth */
147 #define DCERPC_AUTH_SPNEGO             (1<<15)
148
149 /* enable krb5 auth */
150 #define DCERPC_AUTH_KRB5               (1<<16)
151
152 #define DCERPC_SMB2                    (1<<17)
153
154 /*
155   this is used to find pointers to calls
156 */
157 struct dcerpc_interface_call {
158         const char *name;
159         size_t struct_size;
160         ndr_push_flags_fn_t ndr_push;
161         ndr_pull_flags_fn_t ndr_pull;
162         ndr_print_function_t ndr_print;
163         BOOL async;
164 };
165
166 struct dcerpc_endpoint_list {
167         uint32_t count;
168         const char * const *names;
169 };
170
171 struct dcerpc_authservice_list {
172         uint32_t count;
173         const char * const *names;
174 };
175
176 struct dcerpc_interface_table {
177         const char *name;
178         struct GUID uuid;
179         uint32_t if_version;
180         const char *helpstring;
181         uint32_t num_calls;
182         const struct dcerpc_interface_call *calls;
183         const struct dcerpc_endpoint_list *endpoints;
184         const struct dcerpc_authservice_list *authservices;
185 };
186
187 struct dcerpc_interface_list {
188         struct dcerpc_interface_list *prev, *next;
189         const struct dcerpc_interface_table *table;
190 };
191
192 /* this describes a binding to a particular transport/pipe */
193 struct dcerpc_binding {
194         enum dcerpc_transport_t transport;
195         struct GUID object;
196         uint16_t object_version;
197         const char *host;
198         const char *endpoint;
199         const char **options;
200         uint32_t flags;
201 };
202
203
204 struct dcerpc_pipe_connect {
205         struct dcerpc_pipe *pipe;
206         struct dcerpc_binding *binding;
207         const char *pipe_name;
208         const struct dcerpc_interface_table *interface;
209         struct cli_credentials *creds;
210 };
211
212
213 enum rpc_request_state {
214         RPC_REQUEST_PENDING,
215         RPC_REQUEST_DONE
216 };
217
218 /*
219   handle for an async dcerpc request
220 */
221 struct rpc_request {
222         struct rpc_request *next, *prev;
223         struct dcerpc_pipe *p;
224         NTSTATUS status;
225         uint32_t call_id;
226         enum rpc_request_state state;
227         DATA_BLOB payload;
228         uint32_t flags;
229         uint32_t fault_code;
230
231         const struct GUID *object;
232         uint16_t opnum;
233         DATA_BLOB request_data;
234         BOOL async_call;
235
236         /* use by the ndr level async recv call */
237         struct {
238                 const struct dcerpc_interface_table *table;
239                 uint32_t opnum;
240                 void *struct_ptr;
241                 TALLOC_CTX *mem_ctx;
242         } ndr;
243
244         struct {
245                 void (*callback)(struct rpc_request *);
246                 void *private;
247         } async;
248 };
249
250 struct epm_tower;
251 struct epm_floor;
252
253 struct smbcli_tree;
254 struct smb2_tree;
255 struct socket_address;
256
257 #include "librpc/rpc/dcerpc_proto.h"
258
259 #endif /* __DCERPC_H__ */