2 Unix SMB/CIFS implementation.
4 server side dcerpc defines
6 Copyright (C) Andrew Tridgell 2003-2005
7 Copyright (C) Stefan (metze) Metzmacher 2004-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.
24 #ifndef SAMBA_DCERPC_SERVER_H
25 #define SAMBA_DCERPC_SERVER_H
28 #include "librpc/gen_ndr/misc.h"
29 #include "librpc/rpc/dcerpc.h"
30 #include "librpc/ndr/libndr.h"
32 /* modules can use the following to determine if the interface has changed
33 * please increment the version number after each interface change
34 * with a comment and maybe update struct dcesrv_critical_sizes.
36 /* version 1 - initial version - metze */
37 #define DCERPC_MODULE_VERSION 1
39 struct dcesrv_connection
;
40 struct dcesrv_call_state
;
42 struct dcesrv_connection_context
;
44 struct dcesrv_interface
{
46 struct dcerpc_syntax_id syntax_id
;
48 /* this function is called when the client binds to this interface */
49 NTSTATUS (*bind
)(struct dcesrv_call_state
*, const struct dcesrv_interface
*);
51 /* this function is called when the client disconnects the endpoint */
52 void (*unbind
)(struct dcesrv_connection_context
*, const struct dcesrv_interface
*);
54 /* the ndr_pull function for the chosen interface.
56 NTSTATUS (*ndr_pull
)(struct dcesrv_call_state
*, TALLOC_CTX
*, struct ndr_pull
*, void **);
58 /* the dispatch function for the chosen interface.
60 NTSTATUS (*dispatch
)(struct dcesrv_call_state
*, TALLOC_CTX
*, void *);
62 /* the reply function for the chosen interface.
64 NTSTATUS (*reply
)(struct dcesrv_call_state
*, TALLOC_CTX
*, void *);
66 /* the ndr_push function for the chosen interface.
68 NTSTATUS (*ndr_push
)(struct dcesrv_call_state
*, TALLOC_CTX
*, struct ndr_push
*, const void *);
70 /* for any private use by the interface code */
74 /* the state of an ongoing dcerpc call */
75 struct dcesrv_call_state
{
76 struct dcesrv_call_state
*next
, *prev
;
77 struct dcesrv_connection
*conn
;
78 struct dcesrv_connection_context
*context
;
79 struct ncacn_packet pkt
;
81 /* the backend can mark the call
82 * with DCESRV_CALL_STATE_FLAG_ASYNC
83 * that will cause the frontend to not touch r->out
86 * this is only allowed to the backend when DCESRV_CALL_STATE_FLAG_MAY_ASYNC
87 * is alerady set by the frontend
89 * the backend then needs to call dcesrv_reply() when it's
90 * ready to send the reply
92 #define DCESRV_CALL_STATE_FLAG_ASYNC (1<<0)
93 #define DCESRV_CALL_STATE_FLAG_MAY_ASYNC (1<<1)
96 /* the time the request arrived in the server */
99 /* the backend can use this event context for async replies */
100 struct event_context
*event_ctx
;
102 /* the message_context that will be used for async replies */
103 struct messaging_context
*msg_ctx
;
105 /* this is the pointer to the allocated function struct */
109 * that's the ndr pull context used in dcesrv_request()
110 * needed by dcesrv_reply() to carry over information
111 * for full pointer support.
113 struct ndr_pull
*ndr_pull
;
117 struct data_blob_list_item
*replies
;
119 /* this is used by the boilerplate code to generate DCERPC faults */
123 #define DCESRV_HANDLE_ANY 255
125 /* a dcerpc handle in internal format */
126 struct dcesrv_handle
{
127 struct dcesrv_handle
*next
, *prev
;
128 struct dcesrv_connection_context
*context
;
129 struct policy_handle wire_handle
;
133 /* hold the authentication state information */
135 struct dcerpc_auth
*auth_info
;
136 struct gensec_security
*gensec_security
;
137 struct auth_session_info
*session_info
;
138 NTSTATUS (*session_key
)(struct dcesrv_connection
*, DATA_BLOB
*session_key
);
141 struct dcesrv_connection_context
{
142 struct dcesrv_connection_context
*next
, *prev
;
145 /* the connection this is on */
146 struct dcesrv_connection
*conn
;
148 /* the ndr function table for the chosen interface */
149 const struct dcesrv_interface
*iface
;
151 /* private data for the interface implementation */
154 /* current rpc handles - this is really the wrong scope for
155 them, but it will do for now */
156 struct dcesrv_handle
*handles
;
160 /* the state associated with a dcerpc server connection */
161 struct dcesrv_connection
{
162 /* the top level context for this server */
163 struct dcesrv_context
*dce_ctx
;
165 /* the endpoint that was opened */
166 const struct dcesrv_endpoint
*endpoint
;
168 /* a list of established context_ids */
169 struct dcesrv_connection_context
*contexts
;
171 /* the state of the current calls */
172 struct dcesrv_call_state
*call_list
;
174 /* the state of the async pending calls */
175 struct dcesrv_call_state
*pending_call_list
;
177 /* the maximum size the client wants to receive */
178 uint32_t cli_max_recv_frag
;
180 DATA_BLOB partial_input
;
182 /* the current authentication state */
183 struct dcesrv_auth auth_state
;
185 /* the event_context that will be used for this connection */
186 struct event_context
*event_ctx
;
188 /* the message_context that will be used for this connection */
189 struct messaging_context
*msg_ctx
;
191 /* the server_id that will be used for this connection */
194 /* the transport level session key */
195 DATA_BLOB transport_session_key
;
199 /* this is the default state_flags for dcesrv_call_state structs */
200 uint32_t state_flags
;
204 void (*report_output_data
)(struct dcesrv_connection
*);
205 struct socket_address
*(*get_my_addr
)(struct dcesrv_connection
*, TALLOC_CTX
*mem_ctx
);
206 struct socket_address
*(*get_peer_addr
)(struct dcesrv_connection
*, TALLOC_CTX
*mem_ctx
);
211 struct dcesrv_endpoint_server
{
212 /* this is the name of the endpoint server */
215 /* this function should register endpoints and some other setup stuff,
216 * it is called when the dcesrv_context gets initialized.
218 NTSTATUS (*init_server
)(struct dcesrv_context
*, const struct dcesrv_endpoint_server
*);
220 /* this function can be used by other endpoint servers to
221 * ask for a dcesrv_interface implementation
222 * - iface must be reference to an already existing struct !
224 BOOL (*interface_by_uuid
)(struct dcesrv_interface
*iface
, const struct GUID
*, uint32_t);
226 /* this function can be used by other endpoint servers to
227 * ask for a dcesrv_interface implementation
228 * - iface must be reference to an already existeng struct !
230 BOOL (*interface_by_name
)(struct dcesrv_interface
*iface
, const char *);
234 /* server-wide context information for the dcerpc server */
235 struct dcesrv_context
{
236 /* the list of endpoints that have registered
237 * by the configured endpoint servers
239 struct dcesrv_endpoint
{
240 struct dcesrv_endpoint
*next
, *prev
;
241 /* the type and location of the endpoint */
242 struct dcerpc_binding
*ep_description
;
243 /* the security descriptor for smb named pipes */
244 struct security_descriptor
*sd
;
245 /* the list of interfaces available on this endpoint */
246 struct dcesrv_if_list
{
247 struct dcesrv_if_list
*next
, *prev
;
248 struct dcesrv_interface iface
;
253 /* this structure is used by modules to determine the size of some critical types */
254 struct dcesrv_critical_sizes
{
255 int interface_version
;
256 int sizeof_dcesrv_context
;
257 int sizeof_dcesrv_endpoint
;
258 int sizeof_dcesrv_endpoint_server
;
259 int sizeof_dcesrv_interface
;
260 int sizeof_dcesrv_if_list
;
261 int sizeof_dcesrv_connection
;
262 int sizeof_dcesrv_call_state
;
263 int sizeof_dcesrv_auth
;
264 int sizeof_dcesrv_handle
;
269 #include "rpc_server/dcerpc_server_proto.h"
271 #endif /* SAMBA_DCERPC_SERVER_H */