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
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.
24 #include "smbd/process_model.h"
27 this header declares the core context structures associated with smb
28 sockets, tree connects, requests etc
30 the idea is that we will eventually get rid of all our global
31 variables and instead store our state from structures hanging off
35 /* the current user context for a request */
36 struct smbsrv_session {
37 struct smbsrv_session *prev, *next;
39 struct smbsrv_connection *smb_conn;
41 /* the vuid is used to specify the security context for this
42 request. Note that this may not be the same vuid as we
43 received on the wire (for example, for share mode or guest
47 struct gensec_security *gensec_ctx;
49 struct auth_session_info *session_info;
51 /* Distinguish between a VUID allocated for the multi-pass
52 * extended secrity session setup and one that is finished */
53 BOOL finished_sesssetup;
55 struct timeval connect_time;
58 /* we need a forward declaration of the ntvfs_ops strucutre to prevent
63 struct smbsrv_tcon *next, *prev;
65 /* the server context that this was created on */
66 struct smbsrv_connection *smb_conn;
68 uint16_t tid; /* an index passed over the wire (the TID) */
74 /* the NTVFS context - see source/ntvfs/ for details */
75 struct ntvfs_context *ntvfs_ctx;
77 /* the reported filesystem type */
80 /* the reported device type */
84 /* a set of flags to control handling of request structures */
85 #define REQ_CONTROL_LARGE (1<<1) /* allow replies larger than max_xmit */
87 /* the context for a single SMB request. This is passed to any request-context
89 struct smbsrv_request {
90 /* the smbsrv_connection needs a list of requests queued for send */
91 struct smbsrv_request *next, *prev;
93 /* the server_context contains all context specific to this SMB socket */
94 struct smbsrv_connection *smb_conn;
96 /* conn is only set for operations that have a valid TID */
97 struct smbsrv_tcon *tcon;
99 /* the session context is derived from the vuid */
100 struct smbsrv_session *session;
102 /* a set of flags to control usage of the request. See REQ_CONTROL_* */
103 unsigned control_flags;
105 /* the smb pid is needed for locking contexts */
108 /* the flags from the SMB request, in raw form (host byte order) */
109 uint16_t flags, flags2;
111 /* the system time when the request arrived */
112 struct timeval request_time;
114 /* this can contain a fnum from an earlier part of a chained
115 * message (such as an SMBOpenX), or -1 */
118 /* how far through the chain of SMB commands have we gone? */
119 unsigned chain_count;
121 /* the sequence number for signing */
124 /* ntvfs per request async states */
125 struct ntvfs_async_state *async_states;
127 struct request_buffer in;
128 struct request_buffer out;
131 /* this contains variables that should be used in % substitutions for
132 * smb.conf parameters */
133 struct substitute_context {
136 /* our local netbios name, as give to us by the client */
139 /* the remote netbios name, as give to us by the client */
140 char *remote_machine;
142 /* the select remote protocol */
145 /* the name of the client as should be displayed in
146 * smbstatus. Can be an IP or a netbios name */
149 /* the username for %U */
153 /* smb server context structure. This should contain all the state
154 * information associated with a SMB server connection
156 struct smbsrv_connection {
157 /* context that has been negotiated between the client and server */
159 /* have we already done the NBT session establishment? */
160 BOOL done_nbt_session;
162 /* only one negprot per connection is allowed */
165 /* multiple session setups are allowed, but some parameters are
166 ignored in any but the first */
170 * Size of data we can send to client. Set
171 * by the client for all protocols above CORE.
172 * Set by us for CORE protocol.
174 unsigned max_send; /* init to BUFFER_SIZE */
177 * Size of the data we can receive. Set by us.
178 * Can be modified by the max xmit parameter.
180 unsigned max_recv; /* init to BUFFER_SIZE */
182 /* a guess at the remote architecture. Try not to rely on this - in almost
183 all cases using these values is the wrong thing to do */
184 enum remote_arch_types ra_type;
186 /* the negotiatiated protocol */
187 enum protocol_types protocol;
189 /* authentication context for multi-part negprot */
190 struct auth_context *auth_context;
192 /* state of NTLMSSP auth */
193 struct auth_ntlmssp_state *ntlmssp_state;
195 /* did we tell the client we support encrypted passwords? */
196 BOOL encrypted_passwords;
198 /* did we send an extended security negprot reply? */
199 BOOL spnego_negotiated;
201 /* client capabilities */
202 uint32_t client_caps;
204 /* the timezone we sent to the client */
207 /* NBT names only set when done_nbt_session is true */
208 struct nbt_name *called_name;
209 struct nbt_name *calling_name;
212 /* the context associated with open tree connects on a smb socket */
214 /* list of open tree connects */
215 struct smbsrv_tcon *tcons;
217 /* an id tree used to allocate tids */
218 struct idr_context *idtree_tid;
221 /* context associated with currently valid session setups */
223 int num_validated_vuids;
225 /* an id tree used to allocate vuids */
226 /* this holds info on session vuids that are already
227 * validated for this VC */
228 struct idr_context *idtree_vuid;
230 /* also kept as a link list so it can be enumerated by
231 the management code */
232 struct smbsrv_session *list;
235 /* the server_context holds a linked list of pending requests,
236 * this is used for blocking locks and requests blocked due to oplock
238 struct _smbsrv_pending_request {
239 struct _smbsrv_pending_request *next, *prev;
241 /* the request itself - needs to be freed */
242 struct smbsrv_request *request;
245 struct smb_signing_context signing;
247 struct stream_connection *connection;
249 /* this holds a partially received request */
250 struct smbsrv_request *partial_req;
252 /* this holds list of replies that are waiting to be sent
254 struct smbsrv_request *pending_send;
256 /* a list of partially received transaction requests */
257 struct smbsrv_trans_partial {
258 struct smbsrv_trans_partial *next, *prev;
259 struct smbsrv_request *req;
260 struct smb_trans2 *trans;