docs: Remove mention of auth methods in TOSHARG-Passdb
[Samba/gebeck_regimport.git] / source4 / ntvfs / ntvfs.h
blob02dc191f10dc767a7951af1084d629855a7d9f9f
1 /*
2 Unix SMB/CIFS implementation.
3 NTVFS structures and defines
4 Copyright (C) Andrew Tridgell 2003
5 Copyright (C) Stefan Metzmacher 2004
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef _NTVFS_H_
22 #define _NTVFS_H_
24 #include "libcli/raw/interfaces.h"
25 #include "param/share.h"
26 #include "librpc/gen_ndr/security.h"
27 #include "librpc/gen_ndr/server_id.h"
29 /* modules can use the following to determine if the interface has changed */
30 /* version 1 -> 0 - make module stacking easier -- metze */
31 #define NTVFS_INTERFACE_VERSION 0
33 struct ntvfs_module_context;
34 struct ntvfs_request;
36 /* each backend has to be one one of the following 3 basic types. In
37 earlier versions of Samba backends needed to handle all types, now
38 we implement them separately.
39 The values 1..3 match the SMB2 SMB2_SHARE_TYPE_* values
41 enum ntvfs_type {NTVFS_DISK=1, NTVFS_IPC=2, NTVFS_PRINT=3};
43 /* the ntvfs operations structure - contains function pointers to
44 the backend implementations of each operation */
45 struct ntvfs_ops {
46 const char *name;
47 enum ntvfs_type type;
49 /* initial setup */
50 NTSTATUS (*connect_fn)(struct ntvfs_module_context *ntvfs,
51 struct ntvfs_request *req,
52 union smb_tcon *tcon);
53 NTSTATUS (*disconnect_fn)(struct ntvfs_module_context *ntvfs);
55 /* async_setup - called when a backend is processing a async request */
56 NTSTATUS (*async_setup_fn)(struct ntvfs_module_context *ntvfs,
57 struct ntvfs_request *req,
58 void *private_data);
60 /* filesystem operations */
61 NTSTATUS (*fsinfo_fn)(struct ntvfs_module_context *ntvfs,
62 struct ntvfs_request *req,
63 union smb_fsinfo *fs);
65 /* path operations */
66 NTSTATUS (*unlink_fn)(struct ntvfs_module_context *ntvfs,
67 struct ntvfs_request *req,
68 union smb_unlink *unl);
69 NTSTATUS (*chkpath_fn)(struct ntvfs_module_context *ntvfs,
70 struct ntvfs_request *req,
71 union smb_chkpath *cp);
72 NTSTATUS (*qpathinfo_fn)(struct ntvfs_module_context *ntvfs,
73 struct ntvfs_request *req,
74 union smb_fileinfo *st);
75 NTSTATUS (*setpathinfo_fn)(struct ntvfs_module_context *ntvfs,
76 struct ntvfs_request *req,
77 union smb_setfileinfo *st);
78 NTSTATUS (*mkdir_fn)(struct ntvfs_module_context *ntvfs,
79 struct ntvfs_request *req,
80 union smb_mkdir *md);
81 NTSTATUS (*rmdir_fn)(struct ntvfs_module_context *ntvfs,
82 struct ntvfs_request *req,
83 struct smb_rmdir *rd);
84 NTSTATUS (*rename_fn)(struct ntvfs_module_context *ntvfs,
85 struct ntvfs_request *req,
86 union smb_rename *ren);
87 NTSTATUS (*copy_fn)(struct ntvfs_module_context *ntvfs,
88 struct ntvfs_request *req,
89 struct smb_copy *cp);
90 NTSTATUS (*open_fn)(struct ntvfs_module_context *ntvfs,
91 struct ntvfs_request *req,
92 union smb_open *oi);
94 /* directory search */
95 NTSTATUS (*search_first_fn)(struct ntvfs_module_context *ntvfs,
96 struct ntvfs_request *req,
97 union smb_search_first *io, void *private_data,
98 bool (*callback_fn)(void *private_data, const union smb_search_data *file));
99 NTSTATUS (*search_next_fn)(struct ntvfs_module_context *ntvfs,
100 struct ntvfs_request *req,
101 union smb_search_next *io, void *private_data,
102 bool (*callback_fn)(void *private_data, const union smb_search_data *file));
103 NTSTATUS (*search_close_fn)(struct ntvfs_module_context *ntvfs,
104 struct ntvfs_request *req,
105 union smb_search_close *io);
107 /* operations on open files */
108 NTSTATUS (*ioctl_fn)(struct ntvfs_module_context *ntvfs,
109 struct ntvfs_request *req,
110 union smb_ioctl *io);
111 NTSTATUS (*read_fn)(struct ntvfs_module_context *ntvfs,
112 struct ntvfs_request *req,
113 union smb_read *io);
114 NTSTATUS (*write_fn)(struct ntvfs_module_context *ntvfs,
115 struct ntvfs_request *req,
116 union smb_write *io);
117 NTSTATUS (*seek_fn)(struct ntvfs_module_context *ntvfs,
118 struct ntvfs_request *req,
119 union smb_seek *io);
120 NTSTATUS (*flush_fn)(struct ntvfs_module_context *ntvfs,
121 struct ntvfs_request *req,
122 union smb_flush *flush);
123 NTSTATUS (*lock_fn)(struct ntvfs_module_context *ntvfs,
124 struct ntvfs_request *req,
125 union smb_lock *lck);
126 NTSTATUS (*qfileinfo_fn)(struct ntvfs_module_context *ntvfs,
127 struct ntvfs_request *req,
128 union smb_fileinfo *info);
129 NTSTATUS (*setfileinfo_fn)(struct ntvfs_module_context *ntvfs,
130 struct ntvfs_request *req,
131 union smb_setfileinfo *info);
132 NTSTATUS (*close_fn)(struct ntvfs_module_context *ntvfs,
133 struct ntvfs_request *req,
134 union smb_close *io);
136 /* trans interface - used by IPC backend for pipes and RAP calls */
137 NTSTATUS (*trans_fn)(struct ntvfs_module_context *ntvfs,
138 struct ntvfs_request *req,
139 struct smb_trans2 *trans);
141 /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
142 NTSTATUS (*trans2_fn)(struct ntvfs_module_context *ntvfs,
143 struct ntvfs_request *req,
144 struct smb_trans2 *trans2);
146 /* change notify request */
147 NTSTATUS (*notify_fn)(struct ntvfs_module_context *ntvfs,
148 struct ntvfs_request *req,
149 union smb_notify *info);
151 /* cancel - cancels any pending async request */
152 NTSTATUS (*cancel_fn)(struct ntvfs_module_context *ntvfs,
153 struct ntvfs_request *req);
155 /* printing specific operations */
156 NTSTATUS (*lpq_fn)(struct ntvfs_module_context *ntvfs,
157 struct ntvfs_request *req,
158 union smb_lpq *lpq);
160 /* logoff - called when a vuid is closed */
161 NTSTATUS (*logoff_fn)(struct ntvfs_module_context *ntvfs,
162 struct ntvfs_request *req);
163 NTSTATUS (*exit_fn)(struct ntvfs_module_context *ntvfs,
164 struct ntvfs_request *req);
167 struct ntvfs_module_context {
168 struct ntvfs_module_context *prev, *next;
169 struct ntvfs_context *ctx;
170 int depth;
171 const struct ntvfs_ops *ops;
172 void *private_data;
175 struct ntvfs_context {
176 enum ntvfs_type type;
178 /* the reported filesystem type */
179 char *fs_type;
181 /* the reported device type */
182 char *dev_type;
184 enum protocol_types protocol;
187 * client capabilities
188 * this field doesn't use protocol specific
189 * values!
191 #define NTVFS_CLIENT_CAP_LEVEL_II_OPLOCKS 0x0000000000000001LLU
192 uint64_t client_caps;
195 * linked list of module contexts
197 struct ntvfs_module_context *modules;
199 struct share_config *config;
201 struct server_id server_id;
202 struct loadparm_context *lp_ctx;
203 struct tevent_context *event_ctx;
204 struct imessaging_context *msg_ctx;
206 struct {
207 void *private_data;
208 NTSTATUS (*handler)(void *private_data, struct ntvfs_handle *handle, uint8_t level);
209 } oplock;
211 struct {
212 const struct tsocket_address *local_address;
213 const struct tsocket_address *remote_address;
214 } client;
216 struct {
217 void *private_data;
218 NTSTATUS (*create_new)(void *private_data, struct ntvfs_request *req, struct ntvfs_handle **h);
219 NTSTATUS (*make_valid)(void *private_data, struct ntvfs_handle *h);
220 void (*destroy)(void *private_data, struct ntvfs_handle *h);
221 struct ntvfs_handle *(*search_by_wire_key)(void *private_data, struct ntvfs_request *req, const DATA_BLOB *key);
222 DATA_BLOB (*get_wire_key)(void *private_data, struct ntvfs_handle *handle, TALLOC_CTX *mem_ctx);
223 } handles;
226 /* a set of flags to control handling of request structures */
227 #define NTVFS_ASYNC_STATE_ASYNC (1<<1) /* the backend will answer this one later */
228 #define NTVFS_ASYNC_STATE_MAY_ASYNC (1<<2) /* the backend is allowed to answer async */
229 #define NTVFS_ASYNC_STATE_CLOSE (1<<3) /* the backend session should be closed */
231 /* the ntvfs_async_state structure allows backend functions to
232 delay replying to requests. To use this, the front end must
233 set send_fn to a function to be called by the backend
234 when the reply is finally ready to be sent. The backend
235 must set status to the status it wants in the
236 reply. The backend must set the NTVFS_ASYNC_STATE_ASYNC
237 control_flag on the request to indicate that it wishes to
238 delay the reply
240 If NTVFS_ASYNC_STATE_MAY_ASYNC is not set then the backend cannot
241 ask for a delayed reply for this request
243 note that the private_data pointer is private to the layer which alloced this struct
245 struct ntvfs_async_state {
246 struct ntvfs_async_state *prev, *next;
247 /* the async handling infos */
248 unsigned int state;
249 void *private_data;
250 void (*send_fn)(struct ntvfs_request *);
251 NTSTATUS status;
253 /* the passthru module's per session private data */
254 struct ntvfs_module_context *ntvfs;
257 struct ntvfs_request {
258 /* the ntvfs_context this requests belongs to */
259 struct ntvfs_context *ctx;
261 /* ntvfs per request async states */
262 struct ntvfs_async_state *async_states;
264 /* the session_info, with security_token and maybe delegated credentials */
265 struct auth_session_info *session_info;
267 /* the smb pid is needed for locking contexts */
268 uint32_t smbpid;
271 * client capabilities
272 * this field doesn't use protocol specific
273 * values!
274 * see NTVFS_CLIENT_CAP_*
276 uint64_t client_caps;
278 /* some statictics for the management tools */
279 struct {
280 /* the system time when the request arrived */
281 struct timeval request_time;
282 } statistics;
284 struct {
285 void *private_data;
286 } frontend_data;
289 struct ntvfs_handle {
290 struct ntvfs_context *ctx;
292 struct auth_session_info *session_info;
294 uint16_t smbpid;
296 struct ntvfs_handle_data {
297 struct ntvfs_handle_data *prev, *next;
298 struct ntvfs_module_context *owner;
299 void *private_data;/* this must be a valid talloc pointer */
300 } *backend_data;
302 struct {
303 void *private_data;
304 } frontend_data;
307 /* this structure is used by backends to determine the size of some critical types */
308 struct ntvfs_critical_sizes {
309 int interface_version;
310 int sizeof_ntvfs_critical_sizes;
311 int sizeof_ntvfs_context;
312 int sizeof_ntvfs_module_context;
313 int sizeof_ntvfs_ops;
314 int sizeof_ntvfs_async_state;
315 int sizeof_ntvfs_request;
316 int sizeof_ntvfs_handle;
317 int sizeof_ntvfs_handle_data;
320 #define NTVFS_CURRENT_CRITICAL_SIZES(c) \
321 struct ntvfs_critical_sizes c = { \
322 .interface_version = NTVFS_INTERFACE_VERSION, \
323 .sizeof_ntvfs_critical_sizes = sizeof(struct ntvfs_critical_sizes), \
324 .sizeof_ntvfs_context = sizeof(struct ntvfs_context), \
325 .sizeof_ntvfs_module_context = sizeof(struct ntvfs_module_context), \
326 .sizeof_ntvfs_ops = sizeof(struct ntvfs_ops), \
327 .sizeof_ntvfs_async_state = sizeof(struct ntvfs_async_state), \
328 .sizeof_ntvfs_request = sizeof(struct ntvfs_request), \
329 .sizeof_ntvfs_handle = sizeof(struct ntvfs_handle), \
330 .sizeof_ntvfs_handle_data = sizeof(struct ntvfs_handle_data), \
333 struct imessaging_context;
334 #include "librpc/gen_ndr/security.h"
335 #include "librpc/gen_ndr/notify.h"
336 #include "ntvfs/ntvfs_proto.h"
338 #endif /* _NTVFS_H_ */