drivers/rtc/interface.c: return -EBUSY, not -EACCES when device is busy
[linux/fpc-iii.git] / fs / cifs / smb2pdu.h
blob4cb4ced258cb333d326e9fc5ccd353313ec0c8d4
1 /*
2 * fs/cifs/smb2pdu.h
4 * Copyright (c) International Business Machines Corp., 2009, 2010
5 * Etersoft, 2012
6 * Author(s): Steve French (sfrench@us.ibm.com)
7 * Pavel Shilovsky (pshilovsky@samba.org) 2012
9 * This library is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published
11 * by the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifndef _SMB2PDU_H
25 #define _SMB2PDU_H
27 #include <net/sock.h>
30 * Note that, due to trying to use names similar to the protocol specifications,
31 * there are many mixed case field names in the structures below. Although
32 * this does not match typical Linux kernel style, it is necessary to be
33 * be able to match against the protocol specfication.
35 * SMB2 commands
36 * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
37 * (ie no useful data other than the SMB error code itself) and are marked such.
38 * Knowing this helps avoid response buffer allocations and copy in some cases.
41 /* List of commands in host endian */
42 #define SMB2_NEGOTIATE_HE 0x0000
43 #define SMB2_SESSION_SETUP_HE 0x0001
44 #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */
45 #define SMB2_TREE_CONNECT_HE 0x0003
46 #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */
47 #define SMB2_CREATE_HE 0x0005
48 #define SMB2_CLOSE_HE 0x0006
49 #define SMB2_FLUSH_HE 0x0007 /* trivial resp */
50 #define SMB2_READ_HE 0x0008
51 #define SMB2_WRITE_HE 0x0009
52 #define SMB2_LOCK_HE 0x000A
53 #define SMB2_IOCTL_HE 0x000B
54 #define SMB2_CANCEL_HE 0x000C
55 #define SMB2_ECHO_HE 0x000D
56 #define SMB2_QUERY_DIRECTORY_HE 0x000E
57 #define SMB2_CHANGE_NOTIFY_HE 0x000F
58 #define SMB2_QUERY_INFO_HE 0x0010
59 #define SMB2_SET_INFO_HE 0x0011
60 #define SMB2_OPLOCK_BREAK_HE 0x0012
62 /* The same list in little endian */
63 #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE)
64 #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE)
65 #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE)
66 #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE)
67 #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
68 #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE)
69 #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE)
70 #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE)
71 #define SMB2_READ cpu_to_le16(SMB2_READ_HE)
72 #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE)
73 #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE)
74 #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE)
75 #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE)
76 #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE)
77 #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
78 #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
79 #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE)
80 #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE)
81 #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
83 #define NUMBER_OF_SMB2_COMMANDS 0x0013
85 /* BB FIXME - analyze following length BB */
86 #define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */
88 #define SMB2_PROTO_NUMBER __constant_cpu_to_le32(0x424d53fe)
91 * SMB2 Header Definition
93 * "MBZ" : Must be Zero
94 * "BB" : BugBug, Something to check/review/analyze later
95 * "PDU" : "Protocol Data Unit" (ie a network "frame")
99 #define SMB2_HEADER_STRUCTURE_SIZE __constant_cpu_to_le16(64)
101 struct smb2_hdr {
102 __be32 smb2_buf_length; /* big endian on wire */
103 /* length is only two or three bytes - with
104 one or two byte type preceding it that MBZ */
105 __u8 ProtocolId[4]; /* 0xFE 'S' 'M' 'B' */
106 __le16 StructureSize; /* 64 */
107 __le16 CreditCharge; /* MBZ */
108 __le32 Status; /* Error from server */
109 __le16 Command;
110 __le16 CreditRequest; /* CreditResponse */
111 __le32 Flags;
112 __le32 NextCommand;
113 __u64 MessageId; /* opaque - so can stay little endian */
114 __le32 ProcessId;
115 __u32 TreeId; /* opaque - so do not make little endian */
116 __u64 SessionId; /* opaque - so do not make little endian */
117 __u8 Signature[16];
118 } __packed;
120 struct smb2_pdu {
121 struct smb2_hdr hdr;
122 __le16 StructureSize2; /* size of wct area (varies, request specific) */
123 } __packed;
126 * SMB2 flag definitions
128 #define SMB2_FLAGS_SERVER_TO_REDIR __constant_cpu_to_le32(0x00000001)
129 #define SMB2_FLAGS_ASYNC_COMMAND __constant_cpu_to_le32(0x00000002)
130 #define SMB2_FLAGS_RELATED_OPERATIONS __constant_cpu_to_le32(0x00000004)
131 #define SMB2_FLAGS_SIGNED __constant_cpu_to_le32(0x00000008)
132 #define SMB2_FLAGS_DFS_OPERATIONS __constant_cpu_to_le32(0x10000000)
135 * Definitions for SMB2 Protocol Data Units (network frames)
137 * See MS-SMB2.PDF specification for protocol details.
138 * The Naming convention is the lower case version of the SMB2
139 * command code name for the struct. Note that structures must be packed.
143 #define SMB2_ERROR_STRUCTURE_SIZE2 __constant_cpu_to_le16(9)
145 struct smb2_err_rsp {
146 struct smb2_hdr hdr;
147 __le16 StructureSize;
148 __le16 Reserved; /* MBZ */
149 __le32 ByteCount; /* even if zero, at least one byte follows */
150 __u8 ErrorData[1]; /* variable length */
151 } __packed;
153 #define SMB2_CLIENT_GUID_SIZE 16
155 extern __u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];
157 struct smb2_negotiate_req {
158 struct smb2_hdr hdr;
159 __le16 StructureSize; /* Must be 36 */
160 __le16 DialectCount;
161 __le16 SecurityMode;
162 __le16 Reserved; /* MBZ */
163 __le32 Capabilities;
164 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
165 __le64 ClientStartTime; /* MBZ */
166 __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
167 } __packed;
169 /* Dialects */
170 #define SMB20_PROT_ID 0x0202
171 #define SMB21_PROT_ID 0x0210
172 #define SMB30_PROT_ID 0x0300
173 #define BAD_PROT_ID 0xFFFF
175 /* SecurityMode flags */
176 #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
177 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
178 /* Capabilities flags */
179 #define SMB2_GLOBAL_CAP_DFS 0x00000001
180 #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
181 #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
182 #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
183 #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
184 #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
185 #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
186 /* Internal types */
187 #define SMB2_NT_FIND 0x00100000
188 #define SMB2_LARGE_FILES 0x00200000
190 struct smb2_negotiate_rsp {
191 struct smb2_hdr hdr;
192 __le16 StructureSize; /* Must be 65 */
193 __le16 SecurityMode;
194 __le16 DialectRevision;
195 __le16 Reserved; /* MBZ */
196 __u8 ServerGUID[16];
197 __le32 Capabilities;
198 __le32 MaxTransactSize;
199 __le32 MaxReadSize;
200 __le32 MaxWriteSize;
201 __le64 SystemTime; /* MBZ */
202 __le64 ServerStartTime;
203 __le16 SecurityBufferOffset;
204 __le16 SecurityBufferLength;
205 __le32 Reserved2; /* may be any value, ignore */
206 __u8 Buffer[1]; /* variable length GSS security buffer */
207 } __packed;
209 struct smb2_sess_setup_req {
210 struct smb2_hdr hdr;
211 __le16 StructureSize; /* Must be 25 */
212 __u8 VcNumber;
213 __u8 SecurityMode;
214 __le32 Capabilities;
215 __le32 Channel;
216 __le16 SecurityBufferOffset;
217 __le16 SecurityBufferLength;
218 __le64 PreviousSessionId;
219 __u8 Buffer[1]; /* variable length GSS security buffer */
220 } __packed;
222 /* Currently defined SessionFlags */
223 #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
224 #define SMB2_SESSION_FLAG_IS_NULL 0x0002
225 struct smb2_sess_setup_rsp {
226 struct smb2_hdr hdr;
227 __le16 StructureSize; /* Must be 9 */
228 __le16 SessionFlags;
229 __le16 SecurityBufferOffset;
230 __le16 SecurityBufferLength;
231 __u8 Buffer[1]; /* variable length GSS security buffer */
232 } __packed;
234 struct smb2_logoff_req {
235 struct smb2_hdr hdr;
236 __le16 StructureSize; /* Must be 4 */
237 __le16 Reserved;
238 } __packed;
240 struct smb2_logoff_rsp {
241 struct smb2_hdr hdr;
242 __le16 StructureSize; /* Must be 4 */
243 __le16 Reserved;
244 } __packed;
246 struct smb2_tree_connect_req {
247 struct smb2_hdr hdr;
248 __le16 StructureSize; /* Must be 9 */
249 __le16 Reserved;
250 __le16 PathOffset;
251 __le16 PathLength;
252 __u8 Buffer[1]; /* variable length */
253 } __packed;
255 struct smb2_tree_connect_rsp {
256 struct smb2_hdr hdr;
257 __le16 StructureSize; /* Must be 16 */
258 __u8 ShareType; /* see below */
259 __u8 Reserved;
260 __le32 ShareFlags; /* see below */
261 __le32 Capabilities; /* see below */
262 __le32 MaximalAccess;
263 } __packed;
265 /* Possible ShareType values */
266 #define SMB2_SHARE_TYPE_DISK 0x01
267 #define SMB2_SHARE_TYPE_PIPE 0x02
268 #define SMB2_SHARE_TYPE_PRINT 0x03
271 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
272 * must be set (any of the remaining, SHI1005, flags may be set individually
273 * or in combination.
275 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
276 #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
277 #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
278 #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
279 #define SHI1005_FLAGS_DFS 0x00000001
280 #define SHI1005_FLAGS_DFS_ROOT 0x00000002
281 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
282 #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
283 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
284 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
285 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
286 #define SHI1005_FLAGS_ENABLE_HASH 0x00002000
288 /* Possible share capabilities */
289 #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008)
291 struct smb2_tree_disconnect_req {
292 struct smb2_hdr hdr;
293 __le16 StructureSize; /* Must be 4 */
294 __le16 Reserved;
295 } __packed;
297 struct smb2_tree_disconnect_rsp {
298 struct smb2_hdr hdr;
299 __le16 StructureSize; /* Must be 4 */
300 __le16 Reserved;
301 } __packed;
303 /* File Attrubutes */
304 #define FILE_ATTRIBUTE_READONLY 0x00000001
305 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
306 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
307 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
308 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
309 #define FILE_ATTRIBUTE_NORMAL 0x00000080
310 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
311 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
312 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
313 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
314 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
315 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
316 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
318 /* Oplock levels */
319 #define SMB2_OPLOCK_LEVEL_NONE 0x00
320 #define SMB2_OPLOCK_LEVEL_II 0x01
321 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
322 #define SMB2_OPLOCK_LEVEL_BATCH 0x09
323 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
324 /* Non-spec internal type */
325 #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
327 /* Desired Access Flags */
328 #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
329 #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
330 #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
331 #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
332 #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
333 #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
334 #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
335 #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
336 #define FILE_DELETE_LE cpu_to_le32(0x00010000)
337 #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
338 #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
339 #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
340 #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
341 #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
342 #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
343 #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
344 #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
345 #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
346 #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
348 /* ShareAccess Flags */
349 #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
350 #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
351 #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
352 #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
354 /* CreateDisposition Flags */
355 #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
356 #define FILE_OPEN_LE cpu_to_le32(0x00000001)
357 #define FILE_CREATE_LE cpu_to_le32(0x00000002)
358 #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
359 #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
360 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
362 /* CreateOptions Flags */
363 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
364 /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
365 #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
366 #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
367 #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
368 #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
369 #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
370 #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
371 #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
372 #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
373 #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
374 #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
375 #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
376 #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
377 #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
378 #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
379 #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
380 #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
381 #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
383 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
384 | FILE_READ_ATTRIBUTES_LE)
385 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
386 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
387 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
389 /* Impersonation Levels */
390 #define IL_ANONYMOUS cpu_to_le32(0x00000000)
391 #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
392 #define IL_IMPERSONATION cpu_to_le32(0x00000002)
393 #define IL_DELEGATE cpu_to_le32(0x00000003)
395 /* Create Context Values */
396 #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
397 #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
398 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
399 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
400 #define SMB2_CREATE_ALLOCATION_SIZE "AlSi"
401 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
402 #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
403 #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
404 #define SMB2_CREATE_REQUEST_LEASE "RqLs"
406 struct smb2_create_req {
407 struct smb2_hdr hdr;
408 __le16 StructureSize; /* Must be 57 */
409 __u8 SecurityFlags;
410 __u8 RequestedOplockLevel;
411 __le32 ImpersonationLevel;
412 __le64 SmbCreateFlags;
413 __le64 Reserved;
414 __le32 DesiredAccess;
415 __le32 FileAttributes;
416 __le32 ShareAccess;
417 __le32 CreateDisposition;
418 __le32 CreateOptions;
419 __le16 NameOffset;
420 __le16 NameLength;
421 __le32 CreateContextsOffset;
422 __le32 CreateContextsLength;
423 __u8 Buffer[8];
424 } __packed;
426 struct smb2_create_rsp {
427 struct smb2_hdr hdr;
428 __le16 StructureSize; /* Must be 89 */
429 __u8 OplockLevel;
430 __u8 Reserved;
431 __le32 CreateAction;
432 __le64 CreationTime;
433 __le64 LastAccessTime;
434 __le64 LastWriteTime;
435 __le64 ChangeTime;
436 __le64 AllocationSize;
437 __le64 EndofFile;
438 __le32 FileAttributes;
439 __le32 Reserved2;
440 __u64 PersistentFileId; /* opaque endianness */
441 __u64 VolatileFileId; /* opaque endianness */
442 __le32 CreateContextsOffset;
443 __le32 CreateContextsLength;
444 __u8 Buffer[1];
445 } __packed;
447 struct create_context {
448 __le32 Next;
449 __le16 NameOffset;
450 __le16 NameLength;
451 __le16 Reserved;
452 __le16 DataOffset;
453 __le32 DataLength;
454 __u8 Buffer[0];
455 } __packed;
457 #define SMB2_LEASE_NONE __constant_cpu_to_le32(0x00)
458 #define SMB2_LEASE_READ_CACHING __constant_cpu_to_le32(0x01)
459 #define SMB2_LEASE_HANDLE_CACHING __constant_cpu_to_le32(0x02)
460 #define SMB2_LEASE_WRITE_CACHING __constant_cpu_to_le32(0x04)
462 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS __constant_cpu_to_le32(0x02)
464 #define SMB2_LEASE_KEY_SIZE 16
466 struct lease_context {
467 __le64 LeaseKeyLow;
468 __le64 LeaseKeyHigh;
469 __le32 LeaseState;
470 __le32 LeaseFlags;
471 __le64 LeaseDuration;
472 } __packed;
474 struct create_lease {
475 struct create_context ccontext;
476 __u8 Name[8];
477 struct lease_context lcontext;
478 } __packed;
480 /* Currently defined values for close flags */
481 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
482 struct smb2_close_req {
483 struct smb2_hdr hdr;
484 __le16 StructureSize; /* Must be 24 */
485 __le16 Flags;
486 __le32 Reserved;
487 __u64 PersistentFileId; /* opaque endianness */
488 __u64 VolatileFileId; /* opaque endianness */
489 } __packed;
491 struct smb2_close_rsp {
492 struct smb2_hdr hdr;
493 __le16 StructureSize; /* 60 */
494 __le16 Flags;
495 __le32 Reserved;
496 __le64 CreationTime;
497 __le64 LastAccessTime;
498 __le64 LastWriteTime;
499 __le64 ChangeTime;
500 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
501 __le64 EndOfFile;
502 __le32 Attributes;
503 } __packed;
505 struct smb2_flush_req {
506 struct smb2_hdr hdr;
507 __le16 StructureSize; /* Must be 24 */
508 __le16 Reserved1;
509 __le32 Reserved2;
510 __u64 PersistentFileId; /* opaque endianness */
511 __u64 VolatileFileId; /* opaque endianness */
512 } __packed;
514 struct smb2_flush_rsp {
515 struct smb2_hdr hdr;
516 __le16 StructureSize;
517 __le16 Reserved;
518 } __packed;
520 struct smb2_read_req {
521 struct smb2_hdr hdr;
522 __le16 StructureSize; /* Must be 49 */
523 __u8 Padding; /* offset from start of SMB2 header to place read */
524 __u8 Reserved;
525 __le32 Length;
526 __le64 Offset;
527 __u64 PersistentFileId; /* opaque endianness */
528 __u64 VolatileFileId; /* opaque endianness */
529 __le32 MinimumCount;
530 __le32 Channel; /* Reserved MBZ */
531 __le32 RemainingBytes;
532 __le16 ReadChannelInfoOffset; /* Reserved MBZ */
533 __le16 ReadChannelInfoLength; /* Reserved MBZ */
534 __u8 Buffer[1];
535 } __packed;
537 struct smb2_read_rsp {
538 struct smb2_hdr hdr;
539 __le16 StructureSize; /* Must be 17 */
540 __u8 DataOffset;
541 __u8 Reserved;
542 __le32 DataLength;
543 __le32 DataRemaining;
544 __u32 Reserved2;
545 __u8 Buffer[1];
546 } __packed;
548 /* For write request Flags field below the following flag is defined: */
549 #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001
551 struct smb2_write_req {
552 struct smb2_hdr hdr;
553 __le16 StructureSize; /* Must be 49 */
554 __le16 DataOffset; /* offset from start of SMB2 header to write data */
555 __le32 Length;
556 __le64 Offset;
557 __u64 PersistentFileId; /* opaque endianness */
558 __u64 VolatileFileId; /* opaque endianness */
559 __le32 Channel; /* Reserved MBZ */
560 __le32 RemainingBytes;
561 __le16 WriteChannelInfoOffset; /* Reserved MBZ */
562 __le16 WriteChannelInfoLength; /* Reserved MBZ */
563 __le32 Flags;
564 __u8 Buffer[1];
565 } __packed;
567 struct smb2_write_rsp {
568 struct smb2_hdr hdr;
569 __le16 StructureSize; /* Must be 17 */
570 __u8 DataOffset;
571 __u8 Reserved;
572 __le32 DataLength;
573 __le32 DataRemaining;
574 __u32 Reserved2;
575 __u8 Buffer[1];
576 } __packed;
578 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
579 #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
580 #define SMB2_LOCKFLAG_UNLOCK 0x0004
581 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
583 struct smb2_lock_element {
584 __le64 Offset;
585 __le64 Length;
586 __le32 Flags;
587 __le32 Reserved;
588 } __packed;
590 struct smb2_lock_req {
591 struct smb2_hdr hdr;
592 __le16 StructureSize; /* Must be 48 */
593 __le16 LockCount;
594 __le32 Reserved;
595 __u64 PersistentFileId; /* opaque endianness */
596 __u64 VolatileFileId; /* opaque endianness */
597 /* Followed by at least one */
598 struct smb2_lock_element locks[1];
599 } __packed;
601 struct smb2_lock_rsp {
602 struct smb2_hdr hdr;
603 __le16 StructureSize; /* Must be 4 */
604 __le16 Reserved;
605 } __packed;
607 struct smb2_echo_req {
608 struct smb2_hdr hdr;
609 __le16 StructureSize; /* Must be 4 */
610 __u16 Reserved;
611 } __packed;
613 struct smb2_echo_rsp {
614 struct smb2_hdr hdr;
615 __le16 StructureSize; /* Must be 4 */
616 __u16 Reserved;
617 } __packed;
619 /* search (query_directory) Flags field */
620 #define SMB2_RESTART_SCANS 0x01
621 #define SMB2_RETURN_SINGLE_ENTRY 0x02
622 #define SMB2_INDEX_SPECIFIED 0x04
623 #define SMB2_REOPEN 0x10
625 struct smb2_query_directory_req {
626 struct smb2_hdr hdr;
627 __le16 StructureSize; /* Must be 33 */
628 __u8 FileInformationClass;
629 __u8 Flags;
630 __le32 FileIndex;
631 __u64 PersistentFileId; /* opaque endianness */
632 __u64 VolatileFileId; /* opaque endianness */
633 __le16 FileNameOffset;
634 __le16 FileNameLength;
635 __le32 OutputBufferLength;
636 __u8 Buffer[1];
637 } __packed;
639 struct smb2_query_directory_rsp {
640 struct smb2_hdr hdr;
641 __le16 StructureSize; /* Must be 9 */
642 __le16 OutputBufferOffset;
643 __le32 OutputBufferLength;
644 __u8 Buffer[1];
645 } __packed;
647 /* Possible InfoType values */
648 #define SMB2_O_INFO_FILE 0x01
649 #define SMB2_O_INFO_FILESYSTEM 0x02
650 #define SMB2_O_INFO_SECURITY 0x03
651 #define SMB2_O_INFO_QUOTA 0x04
653 struct smb2_query_info_req {
654 struct smb2_hdr hdr;
655 __le16 StructureSize; /* Must be 41 */
656 __u8 InfoType;
657 __u8 FileInfoClass;
658 __le32 OutputBufferLength;
659 __le16 InputBufferOffset;
660 __u16 Reserved;
661 __le32 InputBufferLength;
662 __le32 AdditionalInformation;
663 __le32 Flags;
664 __u64 PersistentFileId; /* opaque endianness */
665 __u64 VolatileFileId; /* opaque endianness */
666 __u8 Buffer[1];
667 } __packed;
669 struct smb2_query_info_rsp {
670 struct smb2_hdr hdr;
671 __le16 StructureSize; /* Must be 9 */
672 __le16 OutputBufferOffset;
673 __le32 OutputBufferLength;
674 __u8 Buffer[1];
675 } __packed;
677 struct smb2_set_info_req {
678 struct smb2_hdr hdr;
679 __le16 StructureSize; /* Must be 33 */
680 __u8 InfoType;
681 __u8 FileInfoClass;
682 __le32 BufferLength;
683 __le16 BufferOffset;
684 __u16 Reserved;
685 __le32 AdditionalInformation;
686 __u64 PersistentFileId; /* opaque endianness */
687 __u64 VolatileFileId; /* opaque endianness */
688 __u8 Buffer[1];
689 } __packed;
691 struct smb2_set_info_rsp {
692 struct smb2_hdr hdr;
693 __le16 StructureSize; /* Must be 2 */
694 } __packed;
696 struct smb2_oplock_break {
697 struct smb2_hdr hdr;
698 __le16 StructureSize; /* Must be 24 */
699 __u8 OplockLevel;
700 __u8 Reserved;
701 __le32 Reserved2;
702 __u64 PersistentFid;
703 __u64 VolatileFid;
704 } __packed;
706 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
708 struct smb2_lease_break {
709 struct smb2_hdr hdr;
710 __le16 StructureSize; /* Must be 44 */
711 __le16 Reserved;
712 __le32 Flags;
713 __u8 LeaseKey[16];
714 __le32 CurrentLeaseState;
715 __le32 NewLeaseState;
716 __le32 BreakReason;
717 __le32 AccessMaskHint;
718 __le32 ShareMaskHint;
719 } __packed;
721 struct smb2_lease_ack {
722 struct smb2_hdr hdr;
723 __le16 StructureSize; /* Must be 36 */
724 __le16 Reserved;
725 __le32 Flags;
726 __u8 LeaseKey[16];
727 __le32 LeaseState;
728 __le64 LeaseDuration;
729 } __packed;
732 * PDU infolevel structure definitions
733 * BB consider moving to a different header
736 /* File System Information Classes */
737 #define FS_VOLUME_INFORMATION 1 /* Query */
738 #define FS_LABEL_INFORMATION 2 /* Set */
739 #define FS_SIZE_INFORMATION 3 /* Query */
740 #define FS_DEVICE_INFORMATION 4 /* Query */
741 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
742 #define FS_CONTROL_INFORMATION 6 /* Query, Set */
743 #define FS_FULL_SIZE_INFORMATION 7 /* Query */
744 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
745 #define FS_DRIVER_PATH_INFORMATION 9 /* Query */
747 struct smb2_fs_full_size_info {
748 __le64 TotalAllocationUnits;
749 __le64 CallerAvailableAllocationUnits;
750 __le64 ActualAvailableAllocationUnits;
751 __le32 SectorsPerAllocationUnit;
752 __le32 BytesPerSector;
753 } __packed;
755 /* partial list of QUERY INFO levels */
756 #define FILE_DIRECTORY_INFORMATION 1
757 #define FILE_FULL_DIRECTORY_INFORMATION 2
758 #define FILE_BOTH_DIRECTORY_INFORMATION 3
759 #define FILE_BASIC_INFORMATION 4
760 #define FILE_STANDARD_INFORMATION 5
761 #define FILE_INTERNAL_INFORMATION 6
762 #define FILE_EA_INFORMATION 7
763 #define FILE_ACCESS_INFORMATION 8
764 #define FILE_NAME_INFORMATION 9
765 #define FILE_RENAME_INFORMATION 10
766 #define FILE_LINK_INFORMATION 11
767 #define FILE_NAMES_INFORMATION 12
768 #define FILE_DISPOSITION_INFORMATION 13
769 #define FILE_POSITION_INFORMATION 14
770 #define FILE_FULL_EA_INFORMATION 15
771 #define FILE_MODE_INFORMATION 16
772 #define FILE_ALIGNMENT_INFORMATION 17
773 #define FILE_ALL_INFORMATION 18
774 #define FILE_ALLOCATION_INFORMATION 19
775 #define FILE_END_OF_FILE_INFORMATION 20
776 #define FILE_ALTERNATE_NAME_INFORMATION 21
777 #define FILE_STREAM_INFORMATION 22
778 #define FILE_PIPE_INFORMATION 23
779 #define FILE_PIPE_LOCAL_INFORMATION 24
780 #define FILE_PIPE_REMOTE_INFORMATION 25
781 #define FILE_MAILSLOT_QUERY_INFORMATION 26
782 #define FILE_MAILSLOT_SET_INFORMATION 27
783 #define FILE_COMPRESSION_INFORMATION 28
784 #define FILE_OBJECT_ID_INFORMATION 29
785 /* Number 30 not defined in documents */
786 #define FILE_MOVE_CLUSTER_INFORMATION 31
787 #define FILE_QUOTA_INFORMATION 32
788 #define FILE_REPARSE_POINT_INFORMATION 33
789 #define FILE_NETWORK_OPEN_INFORMATION 34
790 #define FILE_ATTRIBUTE_TAG_INFORMATION 35
791 #define FILE_TRACKING_INFORMATION 36
792 #define FILEID_BOTH_DIRECTORY_INFORMATION 37
793 #define FILEID_FULL_DIRECTORY_INFORMATION 38
794 #define FILE_VALID_DATA_LENGTH_INFORMATION 39
795 #define FILE_SHORT_NAME_INFORMATION 40
796 #define FILE_SFIO_RESERVE_INFORMATION 44
797 #define FILE_SFIO_VOLUME_INFORMATION 45
798 #define FILE_HARD_LINK_INFORMATION 46
799 #define FILE_NORMALIZED_NAME_INFORMATION 48
800 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
801 #define FILE_STANDARD_LINK_INFORMATION 54
803 struct smb2_file_internal_info {
804 __le64 IndexNumber;
805 } __packed; /* level 6 Query */
807 struct smb2_file_rename_info { /* encoding of request for level 10 */
808 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
809 /* 0 = fail if target already exists */
810 __u8 Reserved[7];
811 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
812 __le32 FileNameLength;
813 char FileName[0]; /* New name to be assigned */
814 } __packed; /* level 10 Set */
816 struct smb2_file_link_info { /* encoding of request for level 11 */
817 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
818 /* 0 = fail if link already exists */
819 __u8 Reserved[7];
820 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
821 __le32 FileNameLength;
822 char FileName[0]; /* Name to be assigned to new link */
823 } __packed; /* level 11 Set */
826 * This level 18, although with struct with same name is different from cifs
827 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
828 * CurrentByteOffset.
830 struct smb2_file_all_info { /* data block encoding of response to level 18 */
831 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
832 __le64 LastAccessTime;
833 __le64 LastWriteTime;
834 __le64 ChangeTime;
835 __le32 Attributes;
836 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
837 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
838 __le64 EndOfFile; /* size ie offset to first free byte in file */
839 __le32 NumberOfLinks; /* hard links */
840 __u8 DeletePending;
841 __u8 Directory;
842 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
843 __le64 IndexNumber;
844 __le32 EASize;
845 __le32 AccessFlags;
846 __le64 CurrentByteOffset;
847 __le32 Mode;
848 __le32 AlignmentRequirement;
849 __le32 FileNameLength;
850 char FileName[1];
851 } __packed; /* level 18 Query */
853 struct smb2_file_eof_info { /* encoding of request for level 10 */
854 __le64 EndOfFile; /* new end of file value */
855 } __packed; /* level 20 Set */
857 #endif /* _SMB2PDU_H */