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 3 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, see <http://www.gnu.org/licenses/>.
23 #ifndef SAMBA_DCERPC_SERVER_H
24 #define SAMBA_DCERPC_SERVER_H
27 #include "librpc/gen_ndr/misc.h"
28 #include "librpc/rpc/dcerpc.h"
29 #include "librpc/ndr/libndr.h"
31 /* modules can use the following to determine if the interface has changed
32 * please increment the version number after each interface change
33 * with a comment and maybe update struct dcesrv_critical_sizes.
35 /* version 1 - initial version - metze */
36 #define DCERPC_MODULE_VERSION 1
38 struct dcesrv_connection;
39 struct dcesrv_call_state;
41 struct dcesrv_connection_context;
43 struct dcesrv_interface {
45 struct ndr_syntax_id syntax_id;
47 /* this function is called when the client binds to this interface */
48 NTSTATUS (*bind)(struct dcesrv_call_state *, const struct dcesrv_interface *);
50 /* this function is called when the client disconnects the endpoint */
51 void (*unbind)(struct dcesrv_connection_context *, const struct dcesrv_interface *);
53 /* the ndr_pull function for the chosen interface.
55 NTSTATUS (*ndr_pull)(struct dcesrv_call_state *, TALLOC_CTX *, struct ndr_pull *, void **);
57 /* the dispatch function for the chosen interface.
59 NTSTATUS (*dispatch)(struct dcesrv_call_state *, TALLOC_CTX *, void *);
61 /* the reply function for the chosen interface.
63 NTSTATUS (*reply)(struct dcesrv_call_state *, TALLOC_CTX *, void *);
65 /* the ndr_push function for the chosen interface.
67 NTSTATUS (*ndr_push)(struct dcesrv_call_state *, TALLOC_CTX *, struct ndr_push *, const void *);
69 /* for any private use by the interface code */
73 enum dcesrv_call_list {
75 DCESRV_LIST_CALL_LIST,
76 DCESRV_LIST_FRAGMENTED_CALL_LIST,
77 DCESRV_LIST_PENDING_CALL_LIST
80 /* the state of an ongoing dcerpc call */
81 struct dcesrv_call_state {
82 struct dcesrv_call_state *next, *prev;
83 struct dcesrv_connection *conn;
84 struct dcesrv_connection_context *context;
85 struct ncacn_packet pkt;
88 which list this request is in, if any
90 enum dcesrv_call_list list;
92 /* the backend can mark the call
93 * with DCESRV_CALL_STATE_FLAG_ASYNC
94 * that will cause the frontend to not touch r->out
97 * this is only allowed to the backend when DCESRV_CALL_STATE_FLAG_MAY_ASYNC
98 * is alerady set by the frontend
100 * the backend then needs to call dcesrv_reply() when it's
101 * ready to send the reply
103 #define DCESRV_CALL_STATE_FLAG_ASYNC (1<<0)
104 #define DCESRV_CALL_STATE_FLAG_MAY_ASYNC (1<<1)
105 uint32_t state_flags;
107 /* the time the request arrived in the server */
110 /* the backend can use this event context for async replies */
111 struct event_context *event_ctx;
113 /* the message_context that will be used for async replies */
114 struct messaging_context *msg_ctx;
116 /* this is the pointer to the allocated function struct */
120 * that's the ndr pull context used in dcesrv_request()
121 * needed by dcesrv_reply() to carry over information
122 * for full pointer support.
124 struct ndr_pull *ndr_pull;
128 struct data_blob_list_item *replies;
130 /* this is used by the boilerplate code to generate DCERPC faults */
134 #define DCESRV_HANDLE_ANY 255
136 /* a dcerpc handle in internal format */
137 struct dcesrv_handle {
138 struct dcesrv_handle *next, *prev;
139 struct dcesrv_connection_context *context;
140 struct policy_handle wire_handle;
144 /* hold the authentication state information */
146 struct dcerpc_auth *auth_info;
147 struct gensec_security *gensec_security;
148 struct auth_session_info *session_info;
149 NTSTATUS (*session_key)(struct dcesrv_connection *, DATA_BLOB *session_key);
152 struct dcesrv_connection_context {
153 struct dcesrv_connection_context *next, *prev;
156 /* the connection this is on */
157 struct dcesrv_connection *conn;
159 /* the ndr function table for the chosen interface */
160 const struct dcesrv_interface *iface;
162 /* private data for the interface implementation */
165 /* current rpc handles - this is really the wrong scope for
166 them, but it will do for now */
167 struct dcesrv_handle *handles;
171 /* the state associated with a dcerpc server connection */
172 struct dcesrv_connection {
173 /* the top level context for this server */
174 struct dcesrv_context *dce_ctx;
176 /* the endpoint that was opened */
177 const struct dcesrv_endpoint *endpoint;
179 /* a list of established context_ids */
180 struct dcesrv_connection_context *contexts;
182 /* the state of the current incoming call fragments */
183 struct dcesrv_call_state *incoming_fragmented_call_list;
185 /* the state of the async pending calls */
186 struct dcesrv_call_state *pending_call_list;
188 /* the state of the current outgoing calls */
189 struct dcesrv_call_state *call_list;
191 /* the maximum size the client wants to receive */
192 uint32_t cli_max_recv_frag;
194 DATA_BLOB partial_input;
196 /* the current authentication state */
197 struct dcesrv_auth auth_state;
199 /* the event_context that will be used for this connection */
200 struct event_context *event_ctx;
202 /* the message_context that will be used for this connection */
203 struct messaging_context *msg_ctx;
205 /* the server_id that will be used for this connection */
206 struct server_id server_id;
208 /* the transport level session key */
209 DATA_BLOB transport_session_key;
213 /* this is the default state_flags for dcesrv_call_state structs */
214 uint32_t state_flags;
218 void (*report_output_data)(struct dcesrv_connection *);
219 struct socket_address *(*get_my_addr)(struct dcesrv_connection *, TALLOC_CTX *mem_ctx);
220 struct socket_address *(*get_peer_addr)(struct dcesrv_connection *, TALLOC_CTX *mem_ctx);
225 struct dcesrv_endpoint_server {
226 /* this is the name of the endpoint server */
229 /* this function should register endpoints and some other setup stuff,
230 * it is called when the dcesrv_context gets initialized.
232 NTSTATUS (*init_server)(struct dcesrv_context *, const struct dcesrv_endpoint_server *);
234 /* this function can be used by other endpoint servers to
235 * ask for a dcesrv_interface implementation
236 * - iface must be reference to an already existing struct !
238 bool (*interface_by_uuid)(struct dcesrv_interface *iface, const struct GUID *, uint32_t);
240 /* this function can be used by other endpoint servers to
241 * ask for a dcesrv_interface implementation
242 * - iface must be reference to an already existeng struct !
244 bool (*interface_by_name)(struct dcesrv_interface *iface, const char *);
248 /* server-wide context information for the dcerpc server */
249 struct dcesrv_context {
250 /* the list of endpoints that have registered
251 * by the configured endpoint servers
253 struct dcesrv_endpoint {
254 struct dcesrv_endpoint *next, *prev;
255 /* the type and location of the endpoint */
256 struct dcerpc_binding *ep_description;
257 /* the security descriptor for smb named pipes */
258 struct security_descriptor *sd;
259 /* the list of interfaces available on this endpoint */
260 struct dcesrv_if_list {
261 struct dcesrv_if_list *next, *prev;
262 struct dcesrv_interface iface;
267 /* this structure is used by modules to determine the size of some critical types */
268 struct dcesrv_critical_sizes {
269 int interface_version;
270 int sizeof_dcesrv_context;
271 int sizeof_dcesrv_endpoint;
272 int sizeof_dcesrv_endpoint_server;
273 int sizeof_dcesrv_interface;
274 int sizeof_dcesrv_if_list;
275 int sizeof_dcesrv_connection;
276 int sizeof_dcesrv_call_state;
277 int sizeof_dcesrv_auth;
278 int sizeof_dcesrv_handle;
283 #include "rpc_server/dcerpc_server_proto.h"
285 #endif /* SAMBA_DCERPC_SERVER_H */