1 /*
2    Unix SMB/CIFS implementation.
3 
4    server side dcerpc defines
5 
6    Copyright (C) Andrew Tridgell 2003-2005
7    Copyright (C) Stefan (metze) Metzmacher 2004-2005
8    Copyright (C) Samuel Cabrero <scabrero@samba.org> 2019
9 
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 3 of the License, or
13    (at your option) any later version.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef _LIBRPC_RPC_DCESRV_CORE_H_
25 #define _LIBRPC_RPC_DCESRV_CORE_H_
26 
27 #include "librpc/rpc/rpc_common.h"
28 #include "librpc/ndr/libndr.h"
29 
30 /* modules can use the following to determine if the interface has changed
31  * please increment the version number after each interface change
32  * with a comment and maybe update struct dcesrv_critical_sizes.
33  */
34 /* version 1 - initial version - metze */
35 #define DCERPC_MODULE_VERSION 1
36 
37 struct dcesrv_connection;
38 struct dcesrv_call_state;
39 struct dcesrv_auth;
40 struct dcesrv_connection_context;
41 struct dcesrv_iface_state;
42 struct cli_credentials;
43 
44 struct dcesrv_interface {
45 	const char *name;
46 	struct ndr_syntax_id syntax_id;
endpoints_match(const struct dcerpc_binding * ep1,const struct dcerpc_binding * ep2)47 
48 	/* this function is called when the client binds to this interface  */
49 	NTSTATUS (*bind)(struct dcesrv_connection_context *, const struct dcesrv_interface *);
50 
51 	/* this function is called when the client disconnects the endpoint */
52 	void (*unbind)(struct dcesrv_connection_context *, const struct dcesrv_interface *);
53 
54 	/* the ndr_pull function for the chosen interface.
55 	 */
56 	NTSTATUS (*ndr_pull)(struct dcesrv_call_state *, TALLOC_CTX *, struct ndr_pull *, void **);
57 
58 	/* the dispatch function for the chosen interface.
59 	 */
60 	NTSTATUS (*dispatch)(struct dcesrv_call_state *, TALLOC_CTX *, void *);
61 
62 	/* the reply function for the chosen interface.
63 	 */
64 	NTSTATUS (*reply)(struct dcesrv_call_state *, TALLOC_CTX *, void *);
65 
66 	/* the ndr_push function for the chosen interface.
67 	 */
68 	NTSTATUS (*ndr_push)(struct dcesrv_call_state *, TALLOC_CTX *, struct ndr_push *, const void *);
69 
70 	/* for any private use by the interface code */
71 	const void *private_data;
72 
73 	uint64_t flags;
74 };
75 
76 #define DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED 0x00000001
77 
78 enum dcesrv_call_list {
dcesrv_find_endpoint(struct dcesrv_context * dce_ctx,const struct dcerpc_binding * ep_description,struct dcesrv_endpoint ** _out)79 	DCESRV_LIST_NONE,
80 	DCESRV_LIST_CALL_LIST,
81 	DCESRV_LIST_FRAGMENTED_CALL_LIST,
82 	DCESRV_LIST_PENDING_CALL_LIST
83 };
84 
85 struct data_blob_list_item {
86 	struct data_blob_list_item *prev,*next;
87 	DATA_BLOB blob;
88 };
89 
90 /* the state of an ongoing dcerpc call */
91 struct dcesrv_call_state {
92 	struct dcesrv_call_state *next, *prev;
93 	struct dcesrv_auth *auth_state;
94 	struct dcesrv_connection *conn;
95 	struct dcesrv_connection_context *context;
dcesrv_find_context(struct dcesrv_connection * conn,uint16_t context_id)96 	struct ncacn_packet pkt;
97 
98 	/*
99 	 * Used during async bind/alter_context.
100 	 */
101 	struct ncacn_packet ack_pkt;
102 
103 	/*
104 	  which list this request is in, if any
105 	 */
106 	enum dcesrv_call_list list;
107 
108 	/* the backend can mark the call
interface_match(const struct dcesrv_interface * if1,const struct dcesrv_interface * if2)109 	 * with DCESRV_CALL_STATE_FLAG_ASYNC
110 	 * that will cause the frontend to not touch r->out
111 	 * and skip the reply
112 	 *
113 	 * this is only allowed to the backend when DCESRV_CALL_STATE_FLAG_MAY_ASYNC
114 	 * is alerady set by the frontend
115 	 *
116 	 * the backend then needs to call dcesrv_reply() when it's
117 	 * ready to send the reply
118 	 */
119 #define DCESRV_CALL_STATE_FLAG_ASYNC (1<<0)
120 #define DCESRV_CALL_STATE_FLAG_MAY_ASYNC (1<<1)
121 #define DCESRV_CALL_STATE_FLAG_MULTIPLEXED (1<<3)
122 #define DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL (1<<4)
123 	uint32_t state_flags;
124 
125 	/* the time the request arrived in the server */
126 	struct timeval time;
127 
128 	/* the backend can use this event context for async replies */
129 	struct tevent_context *event_ctx;
130 
131 	/* this is the pointer to the allocated function struct */
132 	void *r;
133 
134 	/*
135 	 * that's the ndr pull context used in dcesrv_request()
136 	 * needed by dcesrv_reply() to carry over information
137 	 * for full pointer support.
138 	 */
139 	struct ndr_pull *ndr_pull;
interface_match_by_uuid(const struct dcesrv_interface * iface,const struct GUID * uuid,uint32_t if_version)140 
141 	DATA_BLOB input;
142 
143 	struct data_blob_list_item *replies;
144 
145 	/* this is used by the boilerplate code to generate DCERPC faults */
146 	uint32_t fault_code;
147 
148 	/* the reason why we terminate the connection after sending a response */
149 	const char *terminate_reason;
find_interface_by_uuid(const struct dcesrv_endpoint * endpoint,const struct GUID * uuid,uint32_t if_version)150 
151 	/* temporary auth_info fields */
152 	struct dcerpc_auth in_auth_info;
153 	struct dcerpc_auth _out_auth_info;
154 	struct dcerpc_auth *out_auth_info;
155 };
156 
157 /*
158 * DCERPC Handles
159 * --------------
160 * The various handles that are used in the RPC servers should be
161 * created and fetch using the dcesrv_handle_* functions.
162 *
163 * Use
164 * dcesrv_handle_create(struct dcesrv_call_state \*, uint8 handle_type)
dcesrv_find_fragmented_call(struct dcesrv_connection * dce_conn,uint32_t call_id)165 * to obtain a new handle of the specified type. Handle types are
166 * unique within each pipe.
167 *
168 * The handle can later be fetched again using:
169 *
170 * struct dcesrv_handle *dcesrv_handle_lookup(
171 *         struct dcesrv_call_state *dce_call,
172 *         struct policy_handle *p,
173 *         uint8 handle_type)
174 *
175 * and destroyed by:
176 *
177 * 	TALLOC_FREE(struct dcesrv_handle *).
178 *
179 * User data should be stored in the 'data' member of the dcesrv_handle
180 * struct.
181 */
182 
183 #define DCESRV_HANDLE_ANY 255
184 
185 /* a dcerpc handle in internal format */
186 struct dcesrv_handle {
187 	struct dcesrv_handle *next, *prev;
188 	struct dcesrv_assoc_group *assoc_group;
189 	struct policy_handle wire_handle;
190 	struct dom_sid *sid;
191 	enum dcerpc_AuthLevel min_auth_level;
192 	const struct dcesrv_interface *iface;
193 	void *data;
194 };
195 
196 /* hold the authentication state information */
197 struct dcesrv_auth {
198 	struct dcesrv_auth *prev, *next;
199 	enum dcerpc_AuthType auth_type;
200 	enum dcerpc_AuthLevel auth_level;
201 	uint32_t auth_context_id;
202 	struct gensec_security *gensec_security;
203 	struct auth_session_info *session_info;
204 	NTSTATUS (*session_key_fn)(struct dcesrv_auth *, DATA_BLOB *session_key);
205 	bool auth_started;
206 	bool auth_finished;
207 	bool auth_audited;
208 	bool auth_invalid;
209 };
210 
211 struct dcesrv_connection_context {
212 	struct dcesrv_connection_context *next, *prev;
213 	uint16_t context_id;
214 
215 	/* the connection this is on */
216 	struct dcesrv_connection *conn;
217 
218 	/* the ndr function table for the chosen interface */
219 	const struct dcesrv_interface *iface;
220 
221 	/*
222 	 * the minimum required auth level for this interface
223 	 */
224 	enum dcerpc_AuthLevel min_auth_level;
225 	bool allow_connect;
226 
227 	/* the negotiated transfer syntax */
228 	struct ndr_syntax_id transfer_syntax;
229 };
230 
231 
232 /* the state associated with a dcerpc server connection */
233 struct dcesrv_connection {
234 	/* for the broken_connections DLIST */
235 	struct dcesrv_connection *prev, *next;
236 
237 	/* the top level context for this server */
238 	struct dcesrv_context *dce_ctx;
239 
240 	/* the endpoint that was opened */
241 	const struct dcesrv_endpoint *endpoint;
242 
243 	/* a list of established context_ids */
244 	struct dcesrv_connection_context *contexts;
245 
246 	/* the state of the current incoming call fragments */
247 	struct dcesrv_call_state *incoming_fragmented_call_list;
248 
249 	/* the state of the async pending calls */
250 	struct dcesrv_call_state *pending_call_list;
251 
252 	/* the state of the current outgoing calls */
253 	struct dcesrv_call_state *call_list;
254 
255 	/* the maximum size the client wants to receive */
256 	uint16_t max_recv_frag;
257 	uint16_t max_xmit_frag;
258 
259 	DATA_BLOB partial_input;
260 
261 	/* the event_context that will be used for this connection */
262 	struct tevent_context *event_ctx;
263 
264 	/* is this connection pending termination?  If so, why? */
265 	const char *terminate;
266 
267 	const char *packet_log_dir;
268 
269 	/* this is the default state_flags for dcesrv_call_state structs */
270 	uint32_t state_flags;
271 
272 	struct {
273 		void *private_data;
274 		void (*report_output_data)(struct dcesrv_connection *);
275 		void (*terminate_connection)(struct dcesrv_connection *,
276 					     const char *);
277 	} transport;
278 
279 	struct tstream_context *stream;
280 	struct tevent_queue *send_queue;
281 
282 	const struct tsocket_address *local_address;
283 	const struct tsocket_address *remote_address;
284 
285 	/* the current authentication state */
286 	struct dcesrv_auth *default_auth_state;
287 	size_t max_auth_states;
288 	struct dcesrv_auth *auth_states;
289 	bool got_explicit_auth_level_connect;
290 	struct dcesrv_auth *default_auth_level_connect;
291 	bool client_hdr_signing;
292 	bool support_hdr_signing;
293 	bool negotiated_hdr_signing;
294 
295 	/*
296 	 * remember which pdu types are allowed
297 	 */
298 	bool allow_bind;
299 	bool allow_alter;
300 
301 	/* the association group the connection belongs to */
302 	struct dcesrv_assoc_group *assoc_group;
303 
304 	/* The maximum total payload of reassembled request pdus */
305 	size_t max_total_request_size;
306 
307 	/*
308 	 * Our preferred transfer syntax.
309 	 */
310 	const struct ndr_syntax_id *preferred_transfer;
311 
312 	/*
313 	 * This is used to block the connection during
314 	 * pending authentication.
315 	 */
316 	struct tevent_req *(*wait_send)(TALLOC_CTX *mem_ctx,
317 					struct tevent_context *ev,
318 					void *private_data);
319 	NTSTATUS (*wait_recv)(struct tevent_req *req);
320 	void *wait_private;
321 };
322 
323 
324 struct dcesrv_endpoint_server {
325 	/* this is the name of the endpoint server */
326 	const char *name;
327 
328 	/* true if the endpoint server has been initialized */
329 	bool initialized;
330 
331 	/* this function should register endpoints and some other setup stuff,
332 	 * it is called when the dcesrv_context gets initialized.
333 	 */
334 	NTSTATUS (*init_server)(struct dcesrv_context *, const struct dcesrv_endpoint_server *);
335 
336 	/* this function should cleanup endpoint server state and unregister
337 	 * the endpoint server from dcesrv_context */
338 	NTSTATUS (*shutdown_server)(struct dcesrv_context *, const struct dcesrv_endpoint_server *);
339 
340 	/* this function can be used by other endpoint servers to
341 	 * ask for a dcesrv_interface implementation
342 	 * - iface must be reference to an already existing struct !
343 	 */
344 	bool (*interface_by_uuid)(struct dcesrv_interface *iface, const struct GUID *, uint32_t);
345 
346 	/* this function can be used by other endpoint servers to
347 	 * ask for a dcesrv_interface implementation
348 	 * - iface must be reference to an already existeng struct !
349 	 */
350 	bool (*interface_by_name)(struct dcesrv_interface *iface, const char *);
351 };
352 
353 
354 /* one association groups */
355 struct dcesrv_assoc_group {
356 	/* the wire id */
357 	uint32_t id;
358 
359 	/* The transport this is valid on */
360 	enum dcerpc_transport_t transport;
361 
362 	/* list of handles in this association group */
363 	struct dcesrv_handle *handles;
364 
365 	/*
366 	 * list of iface states per assoc/conn
367 	 */
368 	struct dcesrv_iface_state *iface_states;
369 
370 	/* parent context */
371 	struct dcesrv_context *dce_ctx;
372 
373 	/* the negotiated bind time features */
374 	uint16_t bind_time_features;
375 };
376 
377 struct dcesrv_context_callbacks {
378 	struct {
379 		void (*successful_authz)(struct dcesrv_call_state *);
380 	} log;
381 	struct {
382 		NTSTATUS (*gensec_prepare)(TALLOC_CTX *mem_ctx,
383 					struct dcesrv_call_state *call,
384 					struct gensec_security **out);
385 	} auth;
386 	struct {
387 		NTSTATUS (*find)(struct dcesrv_call_state *);
388 	} assoc_group;
389 };
390 
391 /* server-wide context information for the dcerpc server */
392 struct dcesrv_context {
393 	/*
394 	 * The euid at startup time.
395 	 *
396 	 * This is required for DCERPC_AUTH_TYPE_NCALRPC_AS_SYSTEM
397 	 */
398 	uid_t initial_euid;
399 
400 	/* the list of endpoints that have registered
401 	 * by the configured endpoint servers
402 	 */
403 	struct dcesrv_endpoint {
404 		struct dcesrv_endpoint *next, *prev;
405 		/* the type and location of the endpoint */
406 		struct dcerpc_binding *ep_description;
407 		/* the secondary endpoint description for the BIND_ACK */
408 		struct dcerpc_binding *ep_2nd_description;
409 		/* the security descriptor for smb named pipes */
410 		struct security_descriptor *sd;
411 		/* the list of interfaces available on this endpoint */
412 		struct dcesrv_if_list {
413 			struct dcesrv_if_list *next, *prev;
414 			struct dcesrv_interface *iface;
415 		} *interface_list;
416 
dcesrv_session_info_session_key(struct dcesrv_auth * auth,DATA_BLOB * session_key)417 		/*
418 		 * Should this service be run in a single process (so far only
419 		 * NETLOGON is not run in a single process)
420 		 */
421 		bool use_single_process;
422 	} *endpoint_list;
423 
424 	/* loadparm context to use for this connection */
425 	struct loadparm_context *lp_ctx;
426 
427 	struct idr_context *assoc_groups_idr;
428 
429 	struct dcesrv_connection *broken_connections;
430 
431 	struct dcesrv_context_callbacks callbacks;
dcesrv_remote_session_key(struct dcesrv_auth * auth,DATA_BLOB * session_key)432 };
433 
434 /* this structure is used by modules to determine the size of some critical types */
435 struct dcesrv_critical_sizes {
436 	int interface_version;
437 	int sizeof_dcesrv_context;
438 	int sizeof_dcesrv_endpoint;
439 	int sizeof_dcesrv_endpoint_server;
440 	int sizeof_dcesrv_interface;
441 	int sizeof_dcesrv_if_list;
dcesrv_local_fixed_session_key(struct dcesrv_auth * auth,DATA_BLOB * session_key)442 	int sizeof_dcesrv_connection;
443 	int sizeof_dcesrv_call_state;
444 	int sizeof_dcesrv_auth;
445 	int sizeof_dcesrv_handle;
446 };
447 
448 NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
449 				   const char *ep_name,
450 				   const char *ncacn_np_secondary_endpoint,
451 				   const struct dcesrv_interface *iface,
452 				   const struct security_descriptor *sd);
453 NTSTATUS dcerpc_register_ep_server(const struct dcesrv_endpoint_server *ep_server);
dcesrv_auth_session_key(struct dcesrv_call_state * call,DATA_BLOB * session_key)454 NTSTATUS dcesrv_init_ep_servers(struct dcesrv_context *dce_ctx,
455 				const char **ep_servers);
456 NTSTATUS dcesrv_init_registered_ep_servers(struct dcesrv_context *dce_ctx);
457 NTSTATUS dcesrv_shutdown_registered_ep_servers(struct dcesrv_context *dce_ctx);
458 NTSTATUS dcesrv_init_ep_server(struct dcesrv_context *dce_ctx,
459 			       const char *ep_server_name);
460 NTSTATUS dcesrv_shutdown_ep_server(struct dcesrv_context *dce_ctx,
461 				   const char *name);
462 const struct dcesrv_endpoint_server *dcesrv_ep_server_byname(const char *name);
463 
464 NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
465 			     struct loadparm_context *lp_ctx,
466 			     struct dcesrv_context_callbacks *cb,
467 			     struct dcesrv_context **_dce_ctx);
468 NTSTATUS dcesrv_reinit_context(struct dcesrv_context *dce_ctx);
dcesrv_transport_session_key(struct dcesrv_call_state * call,DATA_BLOB * session_key)469 
470 NTSTATUS dcesrv_reply(struct dcesrv_call_state *call);
471 struct dcesrv_handle *dcesrv_handle_create(struct dcesrv_call_state *call,
472 					   uint8_t handle_type);
473 
474 struct dcesrv_handle *dcesrv_handle_lookup(struct dcesrv_call_state *call,
475 					   const struct policy_handle *p,
476 					   uint8_t handle_type);
477 
478 const struct tsocket_address *dcesrv_connection_get_local_address(struct dcesrv_connection *conn);
479 const struct tsocket_address *dcesrv_connection_get_remote_address(struct dcesrv_connection *conn);
480 
481 /*
482  * Fetch the authentication session key if available.
483  *
484  * This is the key generated by a gensec authentication.
485  */
486 NTSTATUS dcesrv_auth_session_key(struct dcesrv_call_state *call,
487 				 DATA_BLOB *session_key);
488 
489 /*
490  * Fetch the transport session key if available.
dcesrv_auth_create(struct dcesrv_connection * conn)491  * Typically this is the SMB session key
492  * or a fixed key for local transports.
493  *
494  * The key is always truncated to 16 bytes.
495 */
496 NTSTATUS dcesrv_transport_session_key(struct dcesrv_call_state *call,
497 				      DATA_BLOB *session_key);
498 
499 /* a useful macro for generating a RPC fault in the backend code */
500 #define DCESRV_FAULT(code) do { \
501 	dce_call->fault_code = code; \
502 	return r->out.result; \
503 } while(0)
504 
505 /* a useful macro for generating a RPC fault in the backend code */
506 #define DCESRV_FAULT_VOID(code) do { \
507 	dce_call->fault_code = code; \
508 	return; \
509 } while(0)
510 
511 /* a useful macro for checking the validity of a dcerpc policy handle
512    and giving the right fault code if invalid */
513 #define DCESRV_CHECK_HANDLE(h) do {if (!(h)) DCESRV_FAULT(DCERPC_FAULT_CONTEXT_MISMATCH); } while (0)
514 
515 /* this checks for a valid policy handle, and gives a fault if an
516    invalid handle or retval if the handle is of the
517    wrong type */
518 #define DCESRV_PULL_HANDLE_RETVAL(h, inhandle, t, retval) do { \
519 	(h) = dcesrv_handle_lookup(dce_call, (inhandle), DCESRV_HANDLE_ANY); \
520 	DCESRV_CHECK_HANDLE(h); \
521 	if ((t) != DCESRV_HANDLE_ANY && (h)->wire_handle.handle_type != (t)) { \
522 		return retval; \
523 	} \
524 } while (0)
dcesrv_endpoint_connect(struct dcesrv_context * dce_ctx,TALLOC_CTX * mem_ctx,const struct dcesrv_endpoint * ep,struct auth_session_info * session_info,struct tevent_context * event_ctx,uint32_t state_flags,struct dcesrv_connection ** _p)525 
526 /* this checks for a valid policy handle and gives a dcerpc fault
527    if its the wrong type of handle */
528 #define DCESRV_PULL_HANDLE_FAULT(h, inhandle, t) do { \
529 	(h) = dcesrv_handle_lookup(dce_call, (inhandle), t); \
530 	DCESRV_CHECK_HANDLE(h); \
531 } while (0)
532 
533 #define DCESRV_PULL_HANDLE(h, inhandle, t) DCESRV_PULL_HANDLE_RETVAL(h, inhandle, t, NT_STATUS_INVALID_HANDLE)
534 #define DCESRV_PULL_HANDLE_WERR(h, inhandle, t) DCESRV_PULL_HANDLE_RETVAL(h, inhandle, t, WERR_INVALID_HANDLE)
535 
536 /**
537  * retrieve credentials from a dce_call
538  */
539 _PUBLIC_ struct cli_credentials *dcesrv_call_credentials(struct dcesrv_call_state *dce_call);
540 
541 /**
542  * returns true if this is an authenticated call
543  */
544 _PUBLIC_ bool dcesrv_call_authenticated(struct dcesrv_call_state *dce_call);
545 
546 /**
547  * retrieve account_name for a dce_call
548  */
549 _PUBLIC_ const char *dcesrv_call_account_name(struct dcesrv_call_state *dce_call);
550 
551 /**
552  * retrieve session_info from a dce_call
553  */
554 _PUBLIC_ struct auth_session_info *dcesrv_call_session_info(struct dcesrv_call_state *dce_call);
555 
556 /**
557  * retrieve auth type/level from a dce_call
558  */
559 _PUBLIC_ void dcesrv_call_auth_info(struct dcesrv_call_state *dce_call,
560 				    enum dcerpc_AuthType *auth_type,
561 				    enum dcerpc_AuthLevel *auth_level);
562 
563 _PUBLIC_ NTSTATUS dcesrv_interface_bind_require_integrity(struct dcesrv_connection_context *context,
564 							  const struct dcesrv_interface *iface);
565 _PUBLIC_ NTSTATUS dcesrv_interface_bind_require_privacy(struct dcesrv_connection_context *context,
566 						        const struct dcesrv_interface *iface);
567 _PUBLIC_ NTSTATUS dcesrv_interface_bind_reject_connect(struct dcesrv_connection_context *context,
568 						       const struct dcesrv_interface *iface);
569 _PUBLIC_ NTSTATUS dcesrv_interface_bind_allow_connect(struct dcesrv_connection_context *context,
570 						      const struct dcesrv_interface *iface);
571 
572 _PUBLIC_ NTSTATUS _dcesrv_iface_state_store_assoc(
573 		struct dcesrv_call_state *call,
574 		uint64_t magic,
575 		void *ptr,
576 		const char *location);
577 #define dcesrv_iface_state_store_assoc(call, magic, ptr) \
578 	_dcesrv_iface_state_store_assoc((call), (magic), (ptr), \
579 					__location__)
580 _PUBLIC_ void *_dcesrv_iface_state_find_assoc(
581 		struct dcesrv_call_state *call,
582 		uint64_t magic);
583 #define dcesrv_iface_state_find_assoc(call, magic, _type) \
584 	talloc_get_type( \
585 		_dcesrv_iface_state_find_assoc((call), (magic)), \
586 		_type)
587 
588 _PUBLIC_ NTSTATUS _dcesrv_iface_state_store_conn(
589 		struct dcesrv_call_state *call,
590 		uint64_t magic,
591 		void *_pptr,
592 		const char *location);
593 #define dcesrv_iface_state_store_conn(call, magic, ptr) \
594 	_dcesrv_iface_state_store_conn((call), (magic), (ptr), \
dcesrv_call_set_list(struct dcesrv_call_state * call,enum dcesrv_call_list list)595 					__location__)
596 _PUBLIC_ void *_dcesrv_iface_state_find_conn(
597 		struct dcesrv_call_state *call,
598 		uint64_t magic);
599 #define dcesrv_iface_state_find_conn(call, magic, _type) \
600 	talloc_get_type( \
601 		_dcesrv_iface_state_find_conn((call), (magic)), \
602 		_type)
603 
604 _PUBLIC_ void dcesrv_cleanup_broken_connections(struct dcesrv_context *dce_ctx);
605 
606 _PUBLIC_ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
607 				TALLOC_CTX *mem_ctx,
608 				const struct dcesrv_endpoint *ep,
609 				struct auth_session_info *session_info,
610 				struct tevent_context *event_ctx,
611 				uint32_t state_flags,
612 				struct dcesrv_connection **_p);
613 _PUBLIC_ NTSTATUS dcesrv_find_endpoint(struct dcesrv_context *dce_ctx,
614 				const struct dcerpc_binding *ep_description,
615 				struct dcesrv_endpoint **_out);
616 
617 _PUBLIC_ void dcesrv_terminate_connection(struct dcesrv_connection *dce_conn,
618 					  const char *reason);
619 _PUBLIC_ void dcesrv_sock_report_output_data(struct dcesrv_connection *dce_conn);
620 
621 _PUBLIC_ NTSTATUS dcesrv_connection_loop_start(struct dcesrv_connection *conn);
622 
623 
624 void _dcesrv_save_ndr_fuzz_seed(DATA_BLOB call_blob,
625 				struct dcesrv_call_state *call,
626 				int flags);
dcesrv_call_disconnect_after(struct dcesrv_call_state * call,const char * reason)627 
628 #if DEVELOPER
629 #define  dcesrv_save_ndr_fuzz_seed(stub, call, flags) \
630 	_dcesrv_save_ndr_fuzz_seed(stub, call, flags)
631 #else
632 #define  dcesrv_save_ndr_fuzz_seed(stub, call, flags) \
633         /* */
634 #endif
635 
636 
637 #endif /* _LIBRPC_RPC_DCESRV_CORE_H_ */
638