| 1 | /* | 
|---|
| 2 | Unix SMB/CIFS implementation. | 
|---|
| 3 | SMB parameters and setup | 
|---|
| 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 |  | 
|---|
| 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. | 
|---|
| 13 |  | 
|---|
| 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. | 
|---|
| 18 |  | 
|---|
| 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/>. | 
|---|
| 21 | */ | 
|---|
| 22 |  | 
|---|
| 23 | #ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */ | 
|---|
| 24 | #define _NT_DOMAIN_H | 
|---|
| 25 |  | 
|---|
| 26 | #include "librpc/rpc/dcerpc.h" | 
|---|
| 27 |  | 
|---|
| 28 | /* | 
|---|
| 29 | * A bunch of stuff that was put into smb.h | 
|---|
| 30 | * in the NTDOM branch - it didn't belong there. | 
|---|
| 31 | */ | 
|---|
| 32 |  | 
|---|
| 33 | typedef struct _output_data { | 
|---|
| 34 | /* | 
|---|
| 35 | * Raw RPC output data. This does not include RPC headers or footers. | 
|---|
| 36 | */ | 
|---|
| 37 | DATA_BLOB rdata; | 
|---|
| 38 |  | 
|---|
| 39 | /* The amount of data sent from the current rdata struct. */ | 
|---|
| 40 | uint32 data_sent_length; | 
|---|
| 41 |  | 
|---|
| 42 | /* | 
|---|
| 43 | * The current fragment being returned. This inclues | 
|---|
| 44 | * headers, data and authentication footer. | 
|---|
| 45 | */ | 
|---|
| 46 | DATA_BLOB frag; | 
|---|
| 47 |  | 
|---|
| 48 | /* The amount of data sent from the current PDU. */ | 
|---|
| 49 | uint32 current_pdu_sent; | 
|---|
| 50 | } output_data; | 
|---|
| 51 |  | 
|---|
| 52 | typedef struct _input_data { | 
|---|
| 53 | /* | 
|---|
| 54 | * This is the current incoming pdu. The data here | 
|---|
| 55 | * is collected via multiple writes until a complete | 
|---|
| 56 | * pdu is seen, then the data is copied into the in_data | 
|---|
| 57 | * structure. The maximum size of this is 0x1630 (RPC_MAX_PDU_FRAG_LEN). | 
|---|
| 58 | * If length is zero, then we are at the start of a new | 
|---|
| 59 | * pdu. | 
|---|
| 60 | */ | 
|---|
| 61 | DATA_BLOB pdu; | 
|---|
| 62 |  | 
|---|
| 63 | /* | 
|---|
| 64 | * The amount of data needed to complete the in_pdu. | 
|---|
| 65 | * If this is zero, then we are at the start of a new | 
|---|
| 66 | * pdu. | 
|---|
| 67 | */ | 
|---|
| 68 | uint32 pdu_needed_len; | 
|---|
| 69 |  | 
|---|
| 70 | /* | 
|---|
| 71 | * This is the collection of input data with all | 
|---|
| 72 | * the rpc headers and auth footers removed. | 
|---|
| 73 | * The maximum length of this (1Mb) is strictly enforced. | 
|---|
| 74 | */ | 
|---|
| 75 | DATA_BLOB data; | 
|---|
| 76 |  | 
|---|
| 77 | } input_data; | 
|---|
| 78 |  | 
|---|
| 79 | struct handle_list; | 
|---|
| 80 |  | 
|---|
| 81 | typedef struct pipe_rpc_fns { | 
|---|
| 82 |  | 
|---|
| 83 | struct pipe_rpc_fns *next, *prev; | 
|---|
| 84 |  | 
|---|
| 85 | /* RPC function table associated with the current rpc_bind (associated by context) */ | 
|---|
| 86 |  | 
|---|
| 87 | const struct api_struct *cmds; | 
|---|
| 88 | int n_cmds; | 
|---|
| 89 | uint32 context_id; | 
|---|
| 90 | struct ndr_syntax_id syntax; | 
|---|
| 91 |  | 
|---|
| 92 | /* | 
|---|
| 93 | * shall we allow "connect" auth level for this interface ? | 
|---|
| 94 | */ | 
|---|
| 95 | bool allow_connect; | 
|---|
| 96 | } PIPE_RPC_FNS; | 
|---|
| 97 |  | 
|---|
| 98 | /* | 
|---|
| 99 | * Different auth types we support. | 
|---|
| 100 | * Can't keep in sync with wire values as spnego wraps different auth methods. | 
|---|
| 101 | */ | 
|---|
| 102 |  | 
|---|
| 103 | struct gse_context; | 
|---|
| 104 |  | 
|---|
| 105 | struct dcesrv_ep_entry_list; | 
|---|
| 106 |  | 
|---|
| 107 | /* | 
|---|
| 108 | * DCE/RPC-specific samba-internal-specific handling of data on | 
|---|
| 109 | * NamedPipes. | 
|---|
| 110 | */ | 
|---|
| 111 |  | 
|---|
| 112 | struct pipes_struct { | 
|---|
| 113 | struct pipes_struct *next, *prev; | 
|---|
| 114 |  | 
|---|
| 115 | struct client_address *client_id; | 
|---|
| 116 | struct client_address *server_id; | 
|---|
| 117 |  | 
|---|
| 118 | enum dcerpc_transport_t transport; | 
|---|
| 119 |  | 
|---|
| 120 | struct auth_serversupplied_info *session_info; | 
|---|
| 121 | struct messaging_context *msg_ctx; | 
|---|
| 122 |  | 
|---|
| 123 | struct ndr_syntax_id syntax; | 
|---|
| 124 | struct dcesrv_ep_entry_list *ep_entries; | 
|---|
| 125 |  | 
|---|
| 126 | /* linked list of rpc dispatch tables associated | 
|---|
| 127 | with the open rpc contexts */ | 
|---|
| 128 |  | 
|---|
| 129 | PIPE_RPC_FNS *contexts; | 
|---|
| 130 |  | 
|---|
| 131 | struct pipe_auth_data auth; | 
|---|
| 132 |  | 
|---|
| 133 | bool ncalrpc_as_system; | 
|---|
| 134 |  | 
|---|
| 135 | /* | 
|---|
| 136 | * Set to true when an RPC bind has been done on this pipe. | 
|---|
| 137 | */ | 
|---|
| 138 |  | 
|---|
| 139 | bool pipe_bound; | 
|---|
| 140 |  | 
|---|
| 141 | /* | 
|---|
| 142 | * States we can be in. | 
|---|
| 143 | */ | 
|---|
| 144 | bool allow_alter; | 
|---|
| 145 | bool allow_bind; | 
|---|
| 146 | bool allow_auth3; | 
|---|
| 147 |  | 
|---|
| 148 | /* | 
|---|
| 149 | * Set the DCERPC_FAULT to return. | 
|---|
| 150 | */ | 
|---|
| 151 |  | 
|---|
| 152 | int fault_state; | 
|---|
| 153 |  | 
|---|
| 154 | /* | 
|---|
| 155 | * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's | 
|---|
| 156 | */ | 
|---|
| 157 |  | 
|---|
| 158 | bool endian; | 
|---|
| 159 |  | 
|---|
| 160 | /* | 
|---|
| 161 | * Struct to deal with multiple pdu inputs. | 
|---|
| 162 | */ | 
|---|
| 163 |  | 
|---|
| 164 | input_data in_data; | 
|---|
| 165 |  | 
|---|
| 166 | /* | 
|---|
| 167 | * Struct to deal with multiple pdu outputs. | 
|---|
| 168 | */ | 
|---|
| 169 |  | 
|---|
| 170 | output_data out_data; | 
|---|
| 171 |  | 
|---|
| 172 | /* This context is used for PDU data and is freed between each pdu. | 
|---|
| 173 | Don't use for pipe state storage. */ | 
|---|
| 174 | TALLOC_CTX *mem_ctx; | 
|---|
| 175 |  | 
|---|
| 176 | /* handle database to use on this pipe. */ | 
|---|
| 177 | struct handle_list *pipe_handles; | 
|---|
| 178 |  | 
|---|
| 179 | /* call id retrieved from the pdu header */ | 
|---|
| 180 | uint32_t call_id; | 
|---|
| 181 |  | 
|---|
| 182 | /* operation number retrieved from the rpc header */ | 
|---|
| 183 | uint16_t opnum; | 
|---|
| 184 |  | 
|---|
| 185 | /* private data for the interface implementation */ | 
|---|
| 186 | void *private_data; | 
|---|
| 187 |  | 
|---|
| 188 | }; | 
|---|
| 189 |  | 
|---|
| 190 | struct api_struct { | 
|---|
| 191 | const char *name; | 
|---|
| 192 | uint8 opnum; | 
|---|
| 193 | bool (*fn) (struct pipes_struct *); | 
|---|
| 194 | }; | 
|---|
| 195 |  | 
|---|
| 196 | /* The following definitions come from rpc_server/rpc_handles.c  */ | 
|---|
| 197 |  | 
|---|
| 198 | size_t num_pipe_handles(struct pipes_struct *p); | 
|---|
| 199 | bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *syntax); | 
|---|
| 200 | bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd, void *data_ptr); | 
|---|
| 201 | bool find_policy_by_hnd(struct pipes_struct *p, const struct policy_handle *hnd, | 
|---|
| 202 | void **data_p); | 
|---|
| 203 | bool close_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd); | 
|---|
| 204 | void close_policy_by_pipe(struct pipes_struct *p); | 
|---|
| 205 | bool pipe_access_check(struct pipes_struct *p); | 
|---|
| 206 |  | 
|---|
| 207 | void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd, | 
|---|
| 208 | uint32_t access_granted, size_t data_size, | 
|---|
| 209 | const char *type, NTSTATUS *pstatus); | 
|---|
| 210 | #define policy_handle_create(_p, _hnd, _access, _type, _pstatus) \ | 
|---|
| 211 | (_type *)_policy_handle_create((_p), (_hnd), (_access), sizeof(_type), #_type, \ | 
|---|
| 212 | (_pstatus)) | 
|---|
| 213 |  | 
|---|
| 214 | void *_policy_handle_find(struct pipes_struct *p, | 
|---|
| 215 | const struct policy_handle *hnd, | 
|---|
| 216 | uint32_t access_required, uint32_t *paccess_granted, | 
|---|
| 217 | const char *name, const char *location, | 
|---|
| 218 | NTSTATUS *pstatus); | 
|---|
| 219 | #define policy_handle_find(_p, _hnd, _access_required, _access_granted, _type, _pstatus) \ | 
|---|
| 220 | (_type *)_policy_handle_find((_p), (_hnd), (_access_required), \ | 
|---|
| 221 | (_access_granted), #_type, __location__, (_pstatus)) | 
|---|
| 222 |  | 
|---|
| 223 | #include "rpc_server/srv_pipe_register.h" | 
|---|
| 224 |  | 
|---|
| 225 | #endif /* _NT_DOMAIN_H */ | 
|---|