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
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
29 /* miscellaneous structures / defines */
32 #include "rpc_creds.h"
37 * A bunch of stuff that was put into smb.h
38 * in the NTDOM branch - it didn't belong there.
41 typedef struct _prs_struct
43 BOOL io; /* parsing in or out of data stream */
45 * If the (incoming) data is big-endian. On output we are
46 * always little-endian.
49 uint8 align; /* data alignment */
50 BOOL is_dynamic; /* Do we own this memory or not ? */
51 uint32 data_offset; /* Current working offset into data. */
52 uint32 buffer_size; /* Current allocated size of the buffer. */
53 uint32 grow_size; /* size requested via prs_grow() calls */
54 char *data_p; /* The buffer itself. */
55 TALLOC_CTX *mem_ctx; /* When unmarshalling, use this.... */
59 * Defines for io member of prs_struct.
65 #define MARSHALLING(ps) (!(ps)->io)
66 #define UNMARSHALLING(ps) ((ps)->io)
68 #define RPC_BIG_ENDIAN 1
69 #define RPC_LITTLE_ENDIAN 0
71 #define RPC_PARSE_ALIGN 4
73 typedef struct _output_data {
75 * Raw RPC output data. This does not include RPC headers or footers.
79 /* The amount of data sent from the current rdata struct. */
80 uint32 data_sent_length;
83 * The current PDU being returned. This inclues
84 * headers, data and authentication footer.
86 unsigned char current_pdu[MAX_PDU_FRAG_LEN];
88 /* The amount of data in the current_pdu buffer. */
89 uint32 current_pdu_len;
91 /* The amount of data sent from the current PDU. */
92 uint32 current_pdu_sent;
95 typedef struct _input_data {
97 * This is the current incoming pdu. The data here
98 * is collected via multiple writes until a complete
99 * pdu is seen, then the data is copied into the in_data
100 * structure. The maximum size of this is 0x1630 (MAX_PDU_FRAG_LEN).
102 unsigned char current_in_pdu[MAX_PDU_FRAG_LEN];
105 * The amount of data needed to complete the in_pdu.
106 * If this is zero, then we are at the start of a new
109 uint32 pdu_needed_len;
112 * The amount of data received so far in the in_pdu.
113 * If this is zero, then we are at the start of a new
116 uint32 pdu_received_len;
119 * This is the collection of input data with all
120 * the rpc headers and auth footers removed.
121 * The maximum length of this (1Mb) is strictly enforced.
127 * Handle database - stored per pipe.
132 struct policy *next, *prev;
137 void (*free_fn)(void *);
142 struct policy *Policy; /* List of policies. */
143 size_t count; /* Current number of handles. */
144 size_t pipe_ref_count; /* Number of pipe handles referring to this list. */
147 /* Domain controller authentication protocol info */
150 DOM_CHAL clnt_chal; /* Initial challenge received from client */
151 DOM_CHAL srv_chal; /* Initial server challenge */
152 DOM_CRED clnt_cred; /* Last client credential */
153 DOM_CRED srv_cred; /* Last server credential */
155 uchar sess_key[8]; /* Session key */
156 uchar md4pw[16]; /* md4(machine password) */
158 fstring mach_acct; /* Machine name we've authenticated. */
160 fstring remote_machine; /* Machine name we've authenticated. */
163 BOOL got_session_key;
168 typedef struct pipe_rpc_fns {
170 struct pipe_rpc_fns *next, *prev;
172 /* RPC function table associated with the current rpc_bind (associated by context) */
174 struct api_struct *cmds;
181 * DCE/RPC-specific samba-internal-specific handling of data on
185 typedef struct pipes_struct
187 struct pipes_struct *next, *prev;
189 connection_struct *conn;
190 uint16 vuid; /* points to the unauthenticated user that opened this pipe. */
193 fstring pipe_srv_name;
195 /* linked list of rpc dispatch tables associated
196 with the open rpc contexts */
198 PIPE_RPC_FNS *contexts;
200 RPC_HDR hdr; /* Incoming RPC header. */
201 RPC_HDR_REQ hdr_req; /* Incoming request header. */
203 uint32 ntlmssp_chal_flags; /* Client challenge flags. */
204 BOOL ntlmssp_auth_requested; /* If the client wanted authenticated rpc. */
205 BOOL ntlmssp_auth_validated; /* If the client *got* authenticated rpc. */
206 unsigned char challenge[8];
207 unsigned char ntlmssp_hash[258];
208 uint32 ntlmssp_seq_num;
209 struct dcinfo dc; /* Keeps the creds data. */
211 /* Hmm. In my understanding the authentication happens
212 implicitly later, so there are no two stages for
215 BOOL netsec_auth_validated;
216 struct netsec_auth_struct netsec_auth;
226 * Unix user name and credentials.
229 fstring pipe_user_name;
230 struct current_user pipe_user;
232 uint8 session_key[16];
235 * Set to true when an RPC bind has been done on this pipe.
241 * Set to true when we should return fault PDU's for everything.
247 * Set to true when we should return fault PDU's for a bad handle.
250 BOOL bad_handle_fault_state;
253 * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's
259 * Struct to deal with multiple pdu inputs.
265 * Struct to deal with multiple pdu outputs.
268 output_data out_data;
270 /* talloc context to use when allocating memory on this pipe. */
273 /* handle database to use on this pipe. */
274 struct handle_list *pipe_handles;
278 typedef struct smb_np_struct
280 struct smb_np_struct *next, *prev;
282 connection_struct *conn;
283 uint16 vuid; /* points to the unauthenticated user that opened this pipe. */
284 BOOL open; /* open connection */
289 /* When replying to an SMBtrans, this is the maximum amount of
290 data that can be sent in the initial reply. */
294 * NamedPipe state information.
296 * (e.g. typecast a np_struct, above).
301 * NamedPipe functions, to be called to perform
302 * Named Pipe transactions on request from an
306 /* call to create a named pipe connection.
307 * returns: state information representing the connection.
308 * is stored in np_state, above.
310 void * (*namedpipe_create)(char *pipe_name,
311 connection_struct *conn, uint16 vuid);
313 /* call to perform a write / read namedpipe transaction.
314 * TransactNamedPipe is weird: it returns whether there
315 * is more data outstanding to be read, and the
316 * caller is expected to take note and follow up with
319 ssize_t (*namedpipe_transact)(void *np_state,
321 char *rdata, int rlen,
322 BOOL *pipe_outstanding);
324 /* call to perform a write namedpipe operation
326 ssize_t (*namedpipe_write)(void * np_state,
327 char *data, size_t n);
329 /* call to perform a read namedpipe operation.
331 * NOTE: the only reason that the pipe_outstanding
332 * argument is here is because samba does not use
333 * the namedpipe_transact function yet: instead,
334 * it performs the same as what namedpipe_transact
335 * does - a write, followed by a read.
337 * when samba is modified to use namedpipe_transact,
338 * the pipe_outstanding argument may be removed.
340 ssize_t (*namedpipe_read)(void * np_state,
341 char *data, size_t max_len,
342 BOOL *pipe_outstanding);
344 /* call to close a namedpipe.
345 * function is expected to perform all cleanups
346 * necessary, free all memory etc.
348 * returns True if cleanup was successful (not that
349 * we particularly care).
351 BOOL (*namedpipe_close)(void * np_state);
359 BOOL (*fn) (pipes_struct *);
371 fstring acct_name; /* account name */
372 fstring acct_desc; /* account name */
373 uint32 rid; /* domain-relative RID */
377 * higher order functions for use with msrpc client code
380 #define PRINT_INFO_FN(fn)\
381 void (*fn)(const char*, uint32, uint32, void *const *const)
382 #define JOB_INFO_FN(fn)\
383 void (*fn)(const char*, const char*, uint32, uint32, void *const *const)
385 /* end higher order functions */
388 /* security descriptor structures */
389 #include "rpc_secdes.h"
392 #include "authdata.h"
394 /* different dce/rpc pipes */
396 #include "rpc_netlogon.h"
398 #include "rpc_samr.h"
399 #include "rpc_srvsvc.h"
400 #include "rpc_wkssvc.h"
401 #include "rpc_spoolss.h"
404 #include "rpc_echo.h"
406 #endif /* _NT_DOMAIN_H */