2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 2003
5 Copyright (C) James J Myers 2003 <myersjj@samba.org>
6 Copyright (C) Stefan Metzmacher 2004-2005
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 #include "libcli/raw/request.h"
24 #include "smbd/process_model.h"
25 #include "libcli/raw/interfaces.h"
28 this header declares the core context structures associated with smb
29 sockets, tree connects, requests etc
31 the idea is that we will eventually get rid of all our global
32 variables and instead store our state from structures hanging off
36 struct smbsrv_tcons_context {
37 /* an id tree used to allocate tids */
38 struct idr_context *idtree_tid;
40 /* this is the limit of vuid values for this connection */
41 uint32_t idtree_limit;
43 /* list of open tree connects */
44 struct smbsrv_tcon *list;
47 struct smbsrv_sessions_context {
48 /* an id tree used to allocate vuids */
49 /* this holds info on session vuids that are already
50 * validated for this VC */
51 struct idr_context *idtree_vuid;
53 /* this is the limit of vuid values for this connection */
54 uint64_t idtree_limit;
56 /* also kept as a link list so it can be enumerated by
57 the management code */
58 struct smbsrv_session *list;
61 /* the current user context for a request */
62 struct smbsrv_session {
63 struct smbsrv_session *prev, *next;
65 struct smbsrv_connection *smb_conn;
67 struct smbsrv_tcons_context smb2_tcons;
70 * an index passed over the wire:
76 struct gensec_security *gensec_ctx;
78 struct auth_session_info *session_info;
80 /* some statictics for the management tools */
82 /* the time when the session setup started */
83 struct timeval connect_time;
84 /* the time when the session setup was finished */
85 struct timeval auth_time;
89 /* we need a forward declaration of the ntvfs_ops strucutre to prevent
94 struct smbsrv_tcon *next, *prev;
96 /* the server context that this was created on */
97 struct smbsrv_connection *smb_conn;
100 * an index passed over the wire:
104 uint32_t tid; /* an index passed over the wire (the TID) */
107 const char *share_name;
109 /* the NTVFS context - see source/ntvfs/ for details */
110 struct ntvfs_context *ntvfs;
112 /* some stuff to support share level security */
114 /* in share level security we need to fake up a session */
115 struct smbsrv_session *session;
118 /* some stuff to support share level security */
120 /* in SMB2 a tcon always belongs to one session */
121 struct smbsrv_session *session;
124 /* some statictics for the management tools */
126 struct timeval connect_time;
130 /* a set of flags to control handling of request structures */
131 #define REQ_CONTROL_LARGE (1<<1) /* allow replies larger than max_xmit */
133 /* the context for a single SMB request. This is passed to any request-context
135 struct smbsrv_request {
136 /* the smbsrv_connection needs a list of requests queued for send */
137 struct smbsrv_request *next, *prev;
139 /* the server_context contains all context specific to this SMB socket */
140 struct smbsrv_connection *smb_conn;
142 /* conn is only set for operations that have a valid TID */
143 struct smbsrv_tcon *tcon;
145 /* the session context is derived from the vuid */
146 struct smbsrv_session *session;
148 /* a set of flags to control usage of the request. See REQ_CONTROL_* */
149 unsigned control_flags;
151 /* the flags from the SMB request, in raw form (host byte order) */
154 /* the system time when the request arrived */
155 struct timeval request_time;
157 /* this can contain a fnum from an earlier part of a chained
158 * message (such as an SMBOpenX), or -1 */
161 /* how far through the chain of SMB commands have we gone? */
162 unsigned chain_count;
164 /* the sequence number for signing */
167 struct request_buffer in;
168 struct request_buffer out;
171 * the following elemets will be part of a future ntvfs_request struct
174 /* the ntvfs_context this requests belongs to */
175 struct ntvfs_context *ctx;
177 /* ntvfs per request async states */
178 struct ntvfs_async_state *async_states;
180 /* the session_info, with security_token and maybe delegated credentials */
181 struct auth_session_info *session_info;
183 /* the smb pid is needed for locking contexts */
188 /* some statictics for the management tools */
190 /* the system time when the request arrived */
191 struct timeval request_time;
195 /* this contains variables that should be used in % substitutions for
196 * smb.conf parameters */
197 struct substitute_context {
200 /* our local netbios name, as give to us by the client */
203 /* the remote netbios name, as give to us by the client */
204 char *remote_machine;
206 /* the select remote protocol */
209 /* the name of the client as should be displayed in
210 * smbstatus. Can be an IP or a netbios name */
213 /* the username for %U */
217 /* Remote architectures we know about. */
218 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_WIN2K, RA_WINXP, RA_SAMBA};
220 enum security_types {SEC_SHARE,SEC_USER} security;
222 /* smb server context structure. This should contain all the state
223 * information associated with a SMB server connection
225 struct smbsrv_connection {
226 /* context that has been negotiated between the client and server */
228 /* have we already done the NBT session establishment? */
229 BOOL done_nbt_session;
231 /* only one negprot per connection is allowed */
234 /* multiple session setups are allowed, but some parameters are
235 ignored in any but the first */
239 * Size of data we can send to client. Set
240 * by the client for all protocols above CORE.
241 * Set by us for CORE protocol.
243 unsigned max_send; /* init to BUFFER_SIZE */
246 * Size of the data we can receive. Set by us.
247 * Can be modified by the max xmit parameter.
249 unsigned max_recv; /* init to BUFFER_SIZE */
251 /* a guess at the remote architecture. Try not to rely on this - in almost
252 all cases using these values is the wrong thing to do */
253 enum remote_arch_types ra_type;
255 /* the negotiatiated protocol */
256 enum protocol_types protocol;
258 /* authentication context for multi-part negprot */
259 struct auth_context *auth_context;
261 /* reference to the kerberos keytab, or machine trust account */
262 struct cli_credentials *server_credentials;
264 /* did we tell the client we support encrypted passwords? */
265 BOOL encrypted_passwords;
267 /* Did we choose SPNEGO, or perhaps raw NTLMSSP, or even no extended security at all? */
270 /* client capabilities */
271 uint32_t client_caps;
273 /* the timezone we sent to the client */
276 /* NBT names only set when done_nbt_session is true */
277 struct nbt_name *called_name;
278 struct nbt_name *calling_name;
281 /* the context associated with open tree connects on a smb socket */
282 struct smbsrv_tcons_context smb_tcons;
284 /* context associated with currently valid session setups */
285 struct smbsrv_sessions_context sessions;
287 /* the server_context holds a linked list of pending requests,
288 * this is used for blocking locks and requests blocked due to oplock
290 struct _smbsrv_pending_request {
291 struct _smbsrv_pending_request *next, *prev;
293 /* the request itself - needs to be freed */
294 struct smbsrv_request *request;
297 struct smb_signing_context signing;
299 struct stream_connection *connection;
301 /* this holds a partially received request */
302 struct packet_context *packet;
304 /* a list of partially received transaction requests */
305 struct smbsrv_trans_partial {
306 struct smbsrv_trans_partial *next, *prev;
307 struct smbsrv_request *req;
308 struct smb_trans2 *trans;
312 /* configuration parameters */
314 enum security_types security;
315 BOOL nt_status_support;
319 #include "smb_server/smb_server_proto.h"
320 #include "smb_server/smb/smb_proto.h"