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.
25 #include "smbd/process_model.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) */
110 /* the NTVFS context - see source/ntvfs/ for details */
111 struct ntvfs_context *ntvfs_ctx;
113 /* the reported filesystem type */
116 /* the reported device type */
119 /* some stuff to support share level security */
121 /* in share level security we need to fake up a session */
122 struct smbsrv_session *session;
125 /* some stuff to support share level security */
127 /* in SMB2 a tcon always belongs to one session */
128 struct smbsrv_session *session;
131 /* some statictics for the management tools */
133 struct timeval connect_time;
137 /* a set of flags to control handling of request structures */
138 #define REQ_CONTROL_LARGE (1<<1) /* allow replies larger than max_xmit */
140 /* the context for a single SMB request. This is passed to any request-context
142 struct smbsrv_request {
143 /* the smbsrv_connection needs a list of requests queued for send */
144 struct smbsrv_request *next, *prev;
146 /* the server_context contains all context specific to this SMB socket */
147 struct smbsrv_connection *smb_conn;
149 /* conn is only set for operations that have a valid TID */
150 struct smbsrv_tcon *tcon;
152 /* the session context is derived from the vuid */
153 struct smbsrv_session *session;
155 /* a set of flags to control usage of the request. See REQ_CONTROL_* */
156 unsigned control_flags;
158 /* the smb pid is needed for locking contexts */
161 /* the flags from the SMB request, in raw form (host byte order) */
162 uint16_t flags, flags2;
164 /* the system time when the request arrived */
165 struct timeval request_time;
167 /* this can contain a fnum from an earlier part of a chained
168 * message (such as an SMBOpenX), or -1 */
171 /* how far through the chain of SMB commands have we gone? */
172 unsigned chain_count;
174 /* the sequence number for signing */
177 /* ntvfs per request async states */
178 struct ntvfs_async_state *async_states;
180 struct request_buffer in;
181 struct request_buffer out;
184 /* this contains variables that should be used in % substitutions for
185 * smb.conf parameters */
186 struct substitute_context {
189 /* our local netbios name, as give to us by the client */
192 /* the remote netbios name, as give to us by the client */
193 char *remote_machine;
195 /* the select remote protocol */
198 /* the name of the client as should be displayed in
199 * smbstatus. Can be an IP or a netbios name */
202 /* the username for %U */
206 /* Remote architectures we know about. */
207 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_WIN2K, RA_WINXP, RA_SAMBA};
209 /* smb server context structure. This should contain all the state
210 * information associated with a SMB server connection
212 struct smbsrv_connection {
213 /* context that has been negotiated between the client and server */
215 /* have we already done the NBT session establishment? */
216 BOOL done_nbt_session;
218 /* only one negprot per connection is allowed */
221 /* multiple session setups are allowed, but some parameters are
222 ignored in any but the first */
226 * Size of data we can send to client. Set
227 * by the client for all protocols above CORE.
228 * Set by us for CORE protocol.
230 unsigned max_send; /* init to BUFFER_SIZE */
233 * Size of the data we can receive. Set by us.
234 * Can be modified by the max xmit parameter.
236 unsigned max_recv; /* init to BUFFER_SIZE */
238 /* a guess at the remote architecture. Try not to rely on this - in almost
239 all cases using these values is the wrong thing to do */
240 enum remote_arch_types ra_type;
242 /* the negotiatiated protocol */
243 enum protocol_types protocol;
245 /* authentication context for multi-part negprot */
246 struct auth_context *auth_context;
248 /* reference to the kerberos keytab, or machine trust account */
249 struct cli_credentials *server_credentials;
251 /* did we tell the client we support encrypted passwords? */
252 BOOL encrypted_passwords;
254 /* did we send an extended security negprot reply? */
255 BOOL spnego_negotiated;
257 /* client capabilities */
258 uint32_t client_caps;
260 /* the timezone we sent to the client */
263 /* NBT names only set when done_nbt_session is true */
264 struct nbt_name *called_name;
265 struct nbt_name *calling_name;
268 /* the context associated with open tree connects on a smb socket */
269 struct smbsrv_tcons_context smb_tcons;
271 /* context associated with currently valid session setups */
272 struct smbsrv_sessions_context sessions;
274 /* the server_context holds a linked list of pending requests,
275 * this is used for blocking locks and requests blocked due to oplock
277 struct _smbsrv_pending_request {
278 struct _smbsrv_pending_request *next, *prev;
280 /* the request itself - needs to be freed */
281 struct smbsrv_request *request;
284 struct smb_signing_context signing;
286 struct stream_connection *connection;
288 /* this holds a partially received request */
289 struct packet_context *packet;
291 /* a list of partially received transaction requests */
292 struct smbsrv_trans_partial {
293 struct smbsrv_trans_partial *next, *prev;
294 struct smbsrv_request *req;
295 struct smb_trans2 *trans;
299 /* configuration parameters */
301 enum security_types security;
302 BOOL nt_status_support;
306 #include "smb_server/smb_server_proto.h"
307 #include "smb_server/smb/smb_proto.h"