2 Unix SMB/CIFS implementation.
4 DCERPC client side interface structures
6 Copyright (C) Tim Potter 2003
7 Copyright (C) Andrew Tridgell 2003-2005
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.
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.
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.
28 #include "librpc/gen_ndr/dcerpc.h"
29 #include "librpc/ndr/libndr.h"
31 enum dcerpc_transport_t {
32 NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC, NCACN_VNS_SPP,
33 NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM, NCADG_UNIX_DGRAM,
34 NCACN_HTTP, NCADG_IPX, NCACN_SPX };
37 this defines a generic security context for signed/sealed dcerpc pipes.
39 struct dcerpc_connection;
40 struct dcerpc_security {
41 struct dcerpc_auth *auth_info;
42 struct gensec_security *generic_state;
44 /* get the session key */
45 NTSTATUS (*session_key)(struct dcerpc_connection *, DATA_BLOB *);
49 this holds the information that is not specific to a particular rpc context_id
51 struct dcerpc_connection {
53 uint32_t srv_max_xmit_frag;
54 uint32_t srv_max_recv_frag;
56 struct dcerpc_security security_state;
57 const char *binding_string;
58 struct event_context *event_ctx;
60 struct dcerpc_transport {
61 enum dcerpc_transport_t transport;
64 NTSTATUS (*shutdown_pipe)(struct dcerpc_connection *);
66 const char *(*peer_name)(struct dcerpc_connection *);
68 const char *(*target_hostname)(struct dcerpc_connection *);
70 /* send a request to the server */
71 NTSTATUS (*send_request)(struct dcerpc_connection *, DATA_BLOB *, BOOL trigger_read);
73 /* send a read request to the server */
74 NTSTATUS (*send_read)(struct dcerpc_connection *);
76 /* a callback to the dcerpc code when a full fragment
78 void (*recv_data)(struct dcerpc_connection *, DATA_BLOB *, NTSTATUS status);
81 /* Requests that have been sent, waiting for a reply */
82 struct rpc_request *pending;
84 /* Sync requests waiting to be shipped */
85 struct rpc_request *request_queue;
87 /* the next context_id to be assigned */
88 uint32_t next_context_id;
92 this encapsulates a full dcerpc client side pipe
97 struct dcerpc_syntax_id syntax;
98 struct dcerpc_syntax_id transfer_syntax;
100 struct dcerpc_connection *conn;
101 struct dcerpc_binding *binding;
103 /* the last fault code from a DCERPC fault */
104 uint32_t last_fault_code;
106 /* timeout for individual rpc requests, in seconds */
107 uint32_t request_timeout;
110 /* default timeout for all rpc requests, in seconds */
111 #define DCERPC_REQUEST_TIMEOUT 60
114 /* dcerpc pipe flags */
115 #define DCERPC_DEBUG_PRINT_IN (1<<0)
116 #define DCERPC_DEBUG_PRINT_OUT (1<<1)
117 #define DCERPC_DEBUG_PRINT_BOTH (DCERPC_DEBUG_PRINT_IN | DCERPC_DEBUG_PRINT_OUT)
119 #define DCERPC_DEBUG_VALIDATE_IN (1<<2)
120 #define DCERPC_DEBUG_VALIDATE_OUT (1<<3)
121 #define DCERPC_DEBUG_VALIDATE_BOTH (DCERPC_DEBUG_VALIDATE_IN | DCERPC_DEBUG_VALIDATE_OUT)
123 #define DCERPC_CONNECT (1<<4)
124 #define DCERPC_SIGN (1<<5)
125 #define DCERPC_SEAL (1<<6)
127 #define DCERPC_PUSH_BIGENDIAN (1<<7)
128 #define DCERPC_PULL_BIGENDIAN (1<<8)
130 #define DCERPC_SCHANNEL (1<<9)
132 /* use a 128 bit session key */
133 #define DCERPC_SCHANNEL_128 (1<<12)
135 /* check incoming pad bytes */
136 #define DCERPC_DEBUG_PAD_CHECK (1<<13)
138 /* set LIBNDR_FLAG_REF_ALLOC flag when decoding NDR */
139 #define DCERPC_NDR_REF_ALLOC (1<<14)
141 #define DCERPC_AUTH_OPTIONS (DCERPC_SEAL|DCERPC_SIGN|DCERPC_SCHANNEL|DCERPC_AUTH_SPNEGO|DCERPC_AUTH_KRB5|DCERPC_AUTH_NTLM)
143 /* select spnego auth */
144 #define DCERPC_AUTH_SPNEGO (1<<15)
146 /* select krb5 auth */
147 #define DCERPC_AUTH_KRB5 (1<<16)
149 #define DCERPC_SMB2 (1<<17)
151 /* select NTLM auth */
152 #define DCERPC_AUTH_NTLM (1<<18)
155 this is used to find pointers to calls
157 struct dcerpc_interface_call {
160 ndr_push_flags_fn_t ndr_push;
161 ndr_pull_flags_fn_t ndr_pull;
162 ndr_print_function_t ndr_print;
166 struct dcerpc_endpoint_list {
168 const char * const *names;
171 struct dcerpc_authservice_list {
173 const char * const *names;
176 struct dcerpc_interface_table {
178 struct dcerpc_syntax_id syntax_id;
179 const char *helpstring;
181 const struct dcerpc_interface_call *calls;
182 const struct dcerpc_endpoint_list *endpoints;
183 const struct dcerpc_authservice_list *authservices;
186 struct dcerpc_interface_list {
187 struct dcerpc_interface_list *prev, *next;
188 const struct dcerpc_interface_table *table;
191 /* this describes a binding to a particular transport/pipe */
192 struct dcerpc_binding {
193 enum dcerpc_transport_t transport;
194 struct dcerpc_syntax_id object;
196 const char *target_hostname;
197 const char *endpoint;
198 const char **options;
203 struct dcerpc_pipe_connect {
204 struct dcerpc_pipe *pipe;
205 struct dcerpc_binding *binding;
206 const char *pipe_name;
207 const struct dcerpc_interface_table *interface;
208 struct cli_credentials *creds;
212 enum rpc_request_state {
218 handle for an async dcerpc request
221 struct rpc_request *next, *prev;
222 struct dcerpc_pipe *p;
225 enum rpc_request_state state;
230 /* this is used to distinguish bind and alter_context requests
231 from normal requests */
232 void (*recv_handler)(struct rpc_request *conn,
233 DATA_BLOB *blob, struct ncacn_packet *pkt);
235 const struct GUID *object;
237 DATA_BLOB request_data;
240 /* use by the ndr level async recv call */
242 const struct dcerpc_interface_table *table;
249 void (*callback)(struct rpc_request *);
259 struct socket_address;
261 #include "librpc/rpc/dcerpc_proto.h"
263 #endif /* __DCERPC_H__ */