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 | /*
|
---|
27 | * A bunch of stuff that was put into smb.h
|
---|
28 | * in the NTDOM branch - it didn't belong there.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #define prs_init_empty( _ps_, _ctx_, _io_ ) (void) prs_init((_ps_), 0, (_ctx_), (_io_))
|
---|
32 |
|
---|
33 | typedef struct _prs_struct {
|
---|
34 | bool io; /* parsing in or out of data stream */
|
---|
35 | /*
|
---|
36 | * If the (incoming) data is big-endian. On output we are
|
---|
37 | * always little-endian.
|
---|
38 | */
|
---|
39 | bool bigendian_data;
|
---|
40 | uint8 align; /* data alignment */
|
---|
41 | bool is_dynamic; /* Do we own this memory or not ? */
|
---|
42 | uint32 data_offset; /* Current working offset into data. */
|
---|
43 | uint32 buffer_size; /* Current allocated size of the buffer. */
|
---|
44 | uint32 grow_size; /* size requested via prs_grow() calls */
|
---|
45 | char *data_p; /* The buffer itself. */
|
---|
46 | TALLOC_CTX *mem_ctx; /* When unmarshalling, use this.... */
|
---|
47 | const char *sess_key; /* If we have to do encrypt/decrypt on the fly. */
|
---|
48 | } prs_struct;
|
---|
49 |
|
---|
50 | /*
|
---|
51 | * Defines for io member of prs_struct.
|
---|
52 | */
|
---|
53 |
|
---|
54 | #define MARSHALL 0
|
---|
55 | #define UNMARSHALL 1
|
---|
56 |
|
---|
57 | #define MARSHALLING(ps) (!(ps)->io)
|
---|
58 | #define UNMARSHALLING(ps) ((ps)->io)
|
---|
59 |
|
---|
60 | #define RPC_BIG_ENDIAN 1
|
---|
61 | #define RPC_LITTLE_ENDIAN 0
|
---|
62 |
|
---|
63 | #define RPC_PARSE_ALIGN 4
|
---|
64 |
|
---|
65 | typedef struct _output_data {
|
---|
66 | /*
|
---|
67 | * Raw RPC output data. This does not include RPC headers or footers.
|
---|
68 | */
|
---|
69 | prs_struct rdata;
|
---|
70 |
|
---|
71 | /* The amount of data sent from the current rdata struct. */
|
---|
72 | uint32 data_sent_length;
|
---|
73 |
|
---|
74 | /*
|
---|
75 | * The current fragment being returned. This inclues
|
---|
76 | * headers, data and authentication footer.
|
---|
77 | */
|
---|
78 | prs_struct frag;
|
---|
79 |
|
---|
80 | /* The amount of data sent from the current PDU. */
|
---|
81 | uint32 current_pdu_sent;
|
---|
82 | } output_data;
|
---|
83 |
|
---|
84 | typedef struct _input_data {
|
---|
85 | /*
|
---|
86 | * This is the current incoming pdu. The data here
|
---|
87 | * is collected via multiple writes until a complete
|
---|
88 | * pdu is seen, then the data is copied into the in_data
|
---|
89 | * structure. The maximum size of this is 0x1630 (RPC_MAX_PDU_FRAG_LEN).
|
---|
90 | */
|
---|
91 | uint8_t *current_in_pdu;
|
---|
92 |
|
---|
93 | /*
|
---|
94 | * The amount of data needed to complete the in_pdu.
|
---|
95 | * If this is zero, then we are at the start of a new
|
---|
96 | * pdu.
|
---|
97 | */
|
---|
98 | uint32 pdu_needed_len;
|
---|
99 |
|
---|
100 | /*
|
---|
101 | * The amount of data received so far in the in_pdu.
|
---|
102 | * If this is zero, then we are at the start of a new
|
---|
103 | * pdu.
|
---|
104 | */
|
---|
105 | uint32 pdu_received_len;
|
---|
106 |
|
---|
107 | /*
|
---|
108 | * This is the collection of input data with all
|
---|
109 | * the rpc headers and auth footers removed.
|
---|
110 | * The maximum length of this (1Mb) is strictly enforced.
|
---|
111 | */
|
---|
112 | prs_struct data;
|
---|
113 | } input_data;
|
---|
114 |
|
---|
115 | struct handle_list;
|
---|
116 |
|
---|
117 | typedef struct pipe_rpc_fns {
|
---|
118 |
|
---|
119 | struct pipe_rpc_fns *next, *prev;
|
---|
120 |
|
---|
121 | /* RPC function table associated with the current rpc_bind (associated by context) */
|
---|
122 |
|
---|
123 | const struct api_struct *cmds;
|
---|
124 | int n_cmds;
|
---|
125 | uint32 context_id;
|
---|
126 |
|
---|
127 | } PIPE_RPC_FNS;
|
---|
128 |
|
---|
129 | /*
|
---|
130 | * Different auth types we support.
|
---|
131 | * Can't keep in sync with wire values as spnego wraps different auth methods.
|
---|
132 | */
|
---|
133 |
|
---|
134 | enum pipe_auth_type { PIPE_AUTH_TYPE_NONE = 0, PIPE_AUTH_TYPE_NTLMSSP, PIPE_AUTH_TYPE_SCHANNEL,
|
---|
135 | PIPE_AUTH_TYPE_SPNEGO_NTLMSSP, PIPE_AUTH_TYPE_KRB5, PIPE_AUTH_TYPE_SPNEGO_KRB5 };
|
---|
136 |
|
---|
137 | /* auth state for krb5. */
|
---|
138 | struct kerberos_auth_struct {
|
---|
139 | const char *service_principal;
|
---|
140 | DATA_BLOB session_key;
|
---|
141 | };
|
---|
142 |
|
---|
143 | /* auth state for schannel. */
|
---|
144 | struct schannel_auth_struct {
|
---|
145 | unsigned char sess_key[16];
|
---|
146 | uint32 seq_num;
|
---|
147 | };
|
---|
148 |
|
---|
149 | /* auth state for all bind types. */
|
---|
150 |
|
---|
151 | struct pipe_auth_data {
|
---|
152 | enum pipe_auth_type auth_type; /* switch for union below. */
|
---|
153 | enum dcerpc_AuthLevel auth_level;
|
---|
154 | union {
|
---|
155 | struct schannel_state *schannel_auth;
|
---|
156 | AUTH_NTLMSSP_STATE *auth_ntlmssp_state;
|
---|
157 | /* struct kerberos_auth_struct *kerberos_auth; TO BE ADDED... */
|
---|
158 | } a_u;
|
---|
159 | void (*auth_data_free_func)(struct pipe_auth_data *);
|
---|
160 | };
|
---|
161 |
|
---|
162 | /*
|
---|
163 | * DCE/RPC-specific samba-internal-specific handling of data on
|
---|
164 | * NamedPipes.
|
---|
165 | */
|
---|
166 |
|
---|
167 | typedef struct pipes_struct {
|
---|
168 | struct pipes_struct *next, *prev;
|
---|
169 |
|
---|
170 | char client_address[INET6_ADDRSTRLEN];
|
---|
171 |
|
---|
172 | struct auth_serversupplied_info *server_info;
|
---|
173 |
|
---|
174 | struct ndr_syntax_id syntax;
|
---|
175 |
|
---|
176 | /* linked list of rpc dispatch tables associated
|
---|
177 | with the open rpc contexts */
|
---|
178 |
|
---|
179 | PIPE_RPC_FNS *contexts;
|
---|
180 |
|
---|
181 | RPC_HDR hdr; /* Incoming RPC header. */
|
---|
182 | RPC_HDR_REQ hdr_req; /* Incoming request header. */
|
---|
183 |
|
---|
184 | struct pipe_auth_data auth;
|
---|
185 |
|
---|
186 | /*
|
---|
187 | * Set to true when an RPC bind has been done on this pipe.
|
---|
188 | */
|
---|
189 |
|
---|
190 | bool pipe_bound;
|
---|
191 |
|
---|
192 | /*
|
---|
193 | * Set to true when we should return fault PDU's for everything.
|
---|
194 | */
|
---|
195 |
|
---|
196 | bool fault_state;
|
---|
197 |
|
---|
198 | /*
|
---|
199 | * Set to true when we should return fault PDU's for a bad handle.
|
---|
200 | */
|
---|
201 |
|
---|
202 | bool bad_handle_fault_state;
|
---|
203 |
|
---|
204 | /*
|
---|
205 | * Set to true when the backend does not support a call.
|
---|
206 | */
|
---|
207 |
|
---|
208 | bool rng_fault_state;
|
---|
209 |
|
---|
210 | /*
|
---|
211 | * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's
|
---|
212 | */
|
---|
213 |
|
---|
214 | bool endian;
|
---|
215 |
|
---|
216 | /*
|
---|
217 | * Struct to deal with multiple pdu inputs.
|
---|
218 | */
|
---|
219 |
|
---|
220 | input_data in_data;
|
---|
221 |
|
---|
222 | /*
|
---|
223 | * Struct to deal with multiple pdu outputs.
|
---|
224 | */
|
---|
225 |
|
---|
226 | output_data out_data;
|
---|
227 |
|
---|
228 | /* This context is used for PDU data and is freed between each pdu.
|
---|
229 | Don't use for pipe state storage. */
|
---|
230 | TALLOC_CTX *mem_ctx;
|
---|
231 |
|
---|
232 | /* handle database to use on this pipe. */
|
---|
233 | struct handle_list *pipe_handles;
|
---|
234 |
|
---|
235 | /* private data for the interface implementation */
|
---|
236 | void *private_data;
|
---|
237 |
|
---|
238 | } pipes_struct;
|
---|
239 |
|
---|
240 | struct api_struct {
|
---|
241 | const char *name;
|
---|
242 | uint8 opnum;
|
---|
243 | bool (*fn) (pipes_struct *);
|
---|
244 | };
|
---|
245 |
|
---|
246 | #endif /* _NT_DOMAIN_H */
|
---|