2 Unix SMB/Netbios implementation.
4 Copyright (C) Andrew Tridgell 1992-1997
5 Copyright (C) Luke Kenneth Casson Leighton 1996-1997
6 Copyright (C) Paul Ashton 1997
7 Copyright (C) Jeremy Allison 2000-2004
8 Copyright (C) Simo Sorce 2010-2011
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.
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.
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/>.
27 #include "librpc/rpc/dcerpc.h"
29 typedef struct _output_data
{
31 * Raw RPC output data. This does not include RPC headers or footers.
35 /* The amount of data sent from the current rdata struct. */
36 uint32_t data_sent_length
;
39 * The current fragment being returned. This inclues
40 * headers, data and authentication footer.
44 /* The amount of data sent from the current PDU. */
45 uint32_t current_pdu_sent
;
48 typedef struct _input_data
{
50 * This is the current incoming pdu. The data here
51 * is collected via multiple writes until a complete
52 * pdu is seen, then the data is copied into the in_data
53 * structure. The maximum size of this is 0x1630 (RPC_MAX_PDU_FRAG_LEN).
54 * If length is zero, then we are at the start of a new
60 * The amount of data needed to complete the in_pdu.
61 * If this is zero, then we are at the start of a new
64 uint32_t pdu_needed_len
;
67 * This is the collection of input data with all
68 * the rpc headers and auth footers removed.
69 * The maximum length of this (1Mb) is strictly enforced.
75 struct dcesrv_ep_entry_list
;
76 struct tsocket_address
;
83 bool (*fn
) (struct pipes_struct
*);
88 struct pipe_rpc_fns
*next
, *prev
;
90 /* RPC function table associated with the current rpc_bind (associated by context) */
92 const struct api_struct
*cmds
;
95 struct ndr_syntax_id syntax
;
98 * shall we allow "connect" auth level for this interface ?
103 * minimal required auth level
105 enum dcerpc_AuthLevel min_auth_level
;
109 * DCE/RPC-specific samba-internal-specific handling of data on
112 struct pipes_struct
{
113 struct pipes_struct
*next
, *prev
;
115 const struct tsocket_address
*local_address
;
116 const struct tsocket_address
*remote_address
;
118 enum dcerpc_transport_t transport
;
120 struct auth_session_info
*session_info
;
121 struct messaging_context
*msg_ctx
;
123 struct dcesrv_ep_entry_list
*ep_entries
;
125 /* linked list of rpc dispatch tables associated
126 with the open rpc contexts */
128 struct pipe_rpc_fns
*contexts
;
130 struct pipe_auth_data auth
;
133 * Set to true when an RPC bind has been done on this pipe.
139 * States we can be in.
146 * Set the DCERPC_FAULT to return.
151 * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's
157 * Struct to deal with multiple pdu inputs.
163 * Struct to deal with multiple pdu outputs.
166 output_data out_data
;
168 /* This context is used for PDU data and is freed between each pdu.
169 Don't use for pipe state storage. */
172 /* handle database to use on this pipe. */
173 struct handle_list
*pipe_handles
;
175 /* call id retrieved from the pdu header */
178 /* operation number retrieved from the rpc header */
181 /* rpc header information to check fragments for consistency */
182 struct dcerpc_sec_vt_header2 header2
;
184 /* private data for the interface implementation */
189 int make_base_pipes_struct(TALLOC_CTX
*mem_ctx
,
190 struct messaging_context
*msg_ctx
,
191 const char *pipe_name
,
192 enum dcerpc_transport_t transport
,
194 const struct tsocket_address
*remote_address
,
195 const struct tsocket_address
*local_address
,
196 struct pipes_struct
**_p
);
197 bool check_open_pipes(void);
198 int close_internal_rpc_pipe_hnd(struct pipes_struct
*p
);
200 size_t num_pipe_handles(struct pipes_struct
*p
);
201 bool init_pipe_handles(struct pipes_struct
*p
, const struct ndr_syntax_id
*syntax
);
202 bool create_policy_hnd(struct pipes_struct
*p
, struct policy_handle
*hnd
, void *data_ptr
);
203 bool find_policy_by_hnd(struct pipes_struct
*p
, const struct policy_handle
*hnd
,
205 bool close_policy_hnd(struct pipes_struct
*p
, struct policy_handle
*hnd
);
206 void close_policy_by_pipe(struct pipes_struct
*p
);
207 bool pipe_access_check(struct pipes_struct
*p
);
209 void *_policy_handle_create(struct pipes_struct
*p
, struct policy_handle
*hnd
,
210 uint32_t access_granted
, size_t data_size
,
211 const char *type
, NTSTATUS
*pstatus
);
212 #define policy_handle_create(_p, _hnd, _access, _type, _pstatus) \
213 (_type *)_policy_handle_create((_p), (_hnd), (_access), sizeof(_type), #_type, \
216 void *_policy_handle_find(struct pipes_struct
*p
,
217 const struct policy_handle
*hnd
,
218 uint32_t access_required
, uint32_t *paccess_granted
,
219 const char *name
, const char *location
,
221 #define policy_handle_find(_p, _hnd, _access_required, _access_granted, _type, _pstatus) \
222 (_type *)_policy_handle_find((_p), (_hnd), (_access_required), \
223 (_access_granted), #_type, __location__, (_pstatus))
225 #endif /* _RPC_PIPES_H_ */