4 * Copyright (c) International Business Machines Corp., 2009, 2013
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
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.
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)
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 */
110 __le16 CreditRequest
; /* CreditResponse */
113 __u64 MessageId
; /* opaque - so can stay little endian */
115 __u32 TreeId
; /* opaque - so do not make little endian */
116 __u64 SessionId
; /* opaque - so do not make little endian */
122 __le16 StructureSize2
; /* size of wct area (varies, request specific) */
125 struct smb2_transform_hdr
{
126 __be32 smb2_buf_length
; /* big endian on wire */
127 /* length is only two or three bytes - with
128 one or two byte type preceding it that MBZ */
129 __u8 ProtocolId
[4]; /* 0xFD 'S' 'M' 'B' */
133 __le32 OriginalMessageSize
;
135 __le16 EncryptionAlgorithm
;
139 /* Encryption Algorithms */
140 #define SMB2_ENCRYPTION_AES128_CCM __constant_cpu_to_le16(0x0001)
143 * SMB2 flag definitions
145 #define SMB2_FLAGS_SERVER_TO_REDIR __constant_cpu_to_le32(0x00000001)
146 #define SMB2_FLAGS_ASYNC_COMMAND __constant_cpu_to_le32(0x00000002)
147 #define SMB2_FLAGS_RELATED_OPERATIONS __constant_cpu_to_le32(0x00000004)
148 #define SMB2_FLAGS_SIGNED __constant_cpu_to_le32(0x00000008)
149 #define SMB2_FLAGS_DFS_OPERATIONS __constant_cpu_to_le32(0x10000000)
152 * Definitions for SMB2 Protocol Data Units (network frames)
154 * See MS-SMB2.PDF specification for protocol details.
155 * The Naming convention is the lower case version of the SMB2
156 * command code name for the struct. Note that structures must be packed.
160 #define SMB2_ERROR_STRUCTURE_SIZE2 __constant_cpu_to_le16(9)
162 struct smb2_err_rsp
{
164 __le16 StructureSize
;
165 __le16 Reserved
; /* MBZ */
166 __le32 ByteCount
; /* even if zero, at least one byte follows */
167 __u8 ErrorData
[1]; /* variable length */
170 struct smb2_symlink_err_rsp
{
171 __le32 SymLinkLength
;
172 __le32 SymLinkErrorTag
;
174 __le16 ReparseDataLength
;
175 __le16 UnparsedPathLength
;
176 __le16 SubstituteNameOffset
;
177 __le16 SubstituteNameLength
;
178 __le16 PrintNameOffset
;
179 __le16 PrintNameLength
;
184 #define SMB2_CLIENT_GUID_SIZE 16
186 struct smb2_negotiate_req
{
188 __le16 StructureSize
; /* Must be 36 */
191 __le16 Reserved
; /* MBZ */
193 __u8 ClientGUID
[SMB2_CLIENT_GUID_SIZE
];
194 __le64 ClientStartTime
; /* MBZ */
195 __le16 Dialects
[1]; /* One dialect (vers=) at a time for now */
199 #define SMB20_PROT_ID 0x0202
200 #define SMB21_PROT_ID 0x0210
201 #define SMB30_PROT_ID 0x0300
202 #define SMB302_PROT_ID 0x0302
203 #define BAD_PROT_ID 0xFFFF
205 /* SecurityMode flags */
206 #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
207 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
208 /* Capabilities flags */
209 #define SMB2_GLOBAL_CAP_DFS 0x00000001
210 #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
211 #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
212 #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
213 #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
214 #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
215 #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
217 #define SMB2_NT_FIND 0x00100000
218 #define SMB2_LARGE_FILES 0x00200000
220 struct smb2_negotiate_rsp
{
222 __le16 StructureSize
; /* Must be 65 */
224 __le16 DialectRevision
;
225 __le16 Reserved
; /* MBZ */
228 __le32 MaxTransactSize
;
231 __le64 SystemTime
; /* MBZ */
232 __le64 ServerStartTime
;
233 __le16 SecurityBufferOffset
;
234 __le16 SecurityBufferLength
;
235 __le32 Reserved2
; /* may be any value, ignore */
236 __u8 Buffer
[1]; /* variable length GSS security buffer */
239 struct smb2_sess_setup_req
{
241 __le16 StructureSize
; /* Must be 25 */
246 __le16 SecurityBufferOffset
;
247 __le16 SecurityBufferLength
;
248 __le64 PreviousSessionId
;
249 __u8 Buffer
[1]; /* variable length GSS security buffer */
252 /* Currently defined SessionFlags */
253 #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
254 #define SMB2_SESSION_FLAG_IS_NULL 0x0002
255 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
256 struct smb2_sess_setup_rsp
{
258 __le16 StructureSize
; /* Must be 9 */
260 __le16 SecurityBufferOffset
;
261 __le16 SecurityBufferLength
;
262 __u8 Buffer
[1]; /* variable length GSS security buffer */
265 struct smb2_logoff_req
{
267 __le16 StructureSize
; /* Must be 4 */
271 struct smb2_logoff_rsp
{
273 __le16 StructureSize
; /* Must be 4 */
277 struct smb2_tree_connect_req
{
279 __le16 StructureSize
; /* Must be 9 */
283 __u8 Buffer
[1]; /* variable length */
286 struct smb2_tree_connect_rsp
{
288 __le16 StructureSize
; /* Must be 16 */
289 __u8 ShareType
; /* see below */
291 __le32 ShareFlags
; /* see below */
292 __le32 Capabilities
; /* see below */
293 __le32 MaximalAccess
;
296 /* Possible ShareType values */
297 #define SMB2_SHARE_TYPE_DISK 0x01
298 #define SMB2_SHARE_TYPE_PIPE 0x02
299 #define SMB2_SHARE_TYPE_PRINT 0x03
302 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
303 * must be set (any of the remaining, SHI1005, flags may be set individually
306 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
307 #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
308 #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
309 #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
310 #define SHI1005_FLAGS_DFS 0x00000001
311 #define SHI1005_FLAGS_DFS_ROOT 0x00000002
312 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
313 #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
314 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
315 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
316 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
317 #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
318 #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
319 #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
320 #define SHI1005_FLAGS_ALL 0x0000FF33
322 /* Possible share capabilities */
323 #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
324 #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
325 #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
326 #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
327 #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
329 struct smb2_tree_disconnect_req
{
331 __le16 StructureSize
; /* Must be 4 */
335 struct smb2_tree_disconnect_rsp
{
337 __le16 StructureSize
; /* Must be 4 */
341 /* File Attrubutes */
342 #define FILE_ATTRIBUTE_READONLY 0x00000001
343 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
344 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
345 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
346 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
347 #define FILE_ATTRIBUTE_NORMAL 0x00000080
348 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
349 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
350 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
351 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
352 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
353 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
354 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
357 #define SMB2_OPLOCK_LEVEL_NONE 0x00
358 #define SMB2_OPLOCK_LEVEL_II 0x01
359 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
360 #define SMB2_OPLOCK_LEVEL_BATCH 0x09
361 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
362 /* Non-spec internal type */
363 #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
365 /* Desired Access Flags */
366 #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
367 #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
368 #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
369 #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
370 #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
371 #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
372 #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
373 #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
374 #define FILE_DELETE_LE cpu_to_le32(0x00010000)
375 #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
376 #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
377 #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
378 #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
379 #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
380 #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
381 #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
382 #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
383 #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
384 #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
386 /* ShareAccess Flags */
387 #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
388 #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
389 #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
390 #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
392 /* CreateDisposition Flags */
393 #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
394 #define FILE_OPEN_LE cpu_to_le32(0x00000001)
395 #define FILE_CREATE_LE cpu_to_le32(0x00000002)
396 #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
397 #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
398 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
400 /* CreateOptions Flags */
401 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
402 /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
403 #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
404 #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
405 #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
406 #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
407 #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
408 #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
409 #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
410 #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
411 #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
412 #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
413 #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
414 #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
415 #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
416 #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
417 #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
418 #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
419 #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
421 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
422 | FILE_READ_ATTRIBUTES_LE)
423 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
424 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
425 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
427 /* Impersonation Levels */
428 #define IL_ANONYMOUS cpu_to_le32(0x00000000)
429 #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
430 #define IL_IMPERSONATION cpu_to_le32(0x00000002)
431 #define IL_DELEGATE cpu_to_le32(0x00000003)
433 /* Create Context Values */
434 #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
435 #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
436 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
437 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
438 #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
439 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
440 #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
441 #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
442 #define SMB2_CREATE_REQUEST_LEASE "RqLs"
443 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
444 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
445 #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
446 #define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9
448 struct smb2_create_req
{
450 __le16 StructureSize
; /* Must be 57 */
452 __u8 RequestedOplockLevel
;
453 __le32 ImpersonationLevel
;
454 __le64 SmbCreateFlags
;
456 __le32 DesiredAccess
;
457 __le32 FileAttributes
;
459 __le32 CreateDisposition
;
460 __le32 CreateOptions
;
463 __le32 CreateContextsOffset
;
464 __le32 CreateContextsLength
;
468 struct smb2_create_rsp
{
470 __le16 StructureSize
; /* Must be 89 */
475 __le64 LastAccessTime
;
476 __le64 LastWriteTime
;
478 __le64 AllocationSize
;
480 __le32 FileAttributes
;
482 __u64 PersistentFileId
; /* opaque endianness */
483 __u64 VolatileFileId
; /* opaque endianness */
484 __le32 CreateContextsOffset
;
485 __le32 CreateContextsLength
;
489 struct create_context
{
499 #define SMB2_LEASE_READ_CACHING_HE 0x01
500 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
501 #define SMB2_LEASE_WRITE_CACHING_HE 0x04
503 #define SMB2_LEASE_NONE __constant_cpu_to_le32(0x00)
504 #define SMB2_LEASE_READ_CACHING __constant_cpu_to_le32(0x01)
505 #define SMB2_LEASE_HANDLE_CACHING __constant_cpu_to_le32(0x02)
506 #define SMB2_LEASE_WRITE_CACHING __constant_cpu_to_le32(0x04)
508 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS __constant_cpu_to_le32(0x02)
510 #define SMB2_LEASE_KEY_SIZE 16
512 struct lease_context
{
517 __le64 LeaseDuration
;
520 struct lease_context_v2
{
525 __le64 LeaseDuration
;
526 __le64 ParentLeaseKeyLow
;
527 __le64 ParentLeaseKeyHigh
;
532 struct create_lease
{
533 struct create_context ccontext
;
535 struct lease_context lcontext
;
538 struct create_lease_v2
{
539 struct create_context ccontext
;
541 struct lease_context_v2 lcontext
;
545 struct create_durable
{
546 struct create_context ccontext
;
551 __u64 PersistentFileId
;
552 __u64 VolatileFileId
;
557 #define COPY_CHUNK_RES_KEY_SIZE 24
558 struct resume_key_req
{
559 char ResumeKey
[COPY_CHUNK_RES_KEY_SIZE
];
560 __le32 ContextLength
; /* MBZ */
561 char Context
[0]; /* ignored, Windows sets to 4 bytes of zero */
564 /* this goes in the ioctl buffer when doing a copychunk request */
565 struct copychunk_ioctl
{
566 char SourceKey
[COPY_CHUNK_RES_KEY_SIZE
];
567 __le32 ChunkCount
; /* we are only sending 1 */
569 /* array will only be one chunk long for us */
572 __le32 Length
; /* how many bytes to copy */
576 /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
577 struct file_zero_data_information
{
579 __le64 BeyondFinalZero
;
582 struct copychunk_ioctl_rsp
{
583 __le32 ChunksWritten
;
584 __le32 ChunkBytesWritten
;
585 __le32 TotalBytesWritten
;
588 struct validate_negotiate_info_req
{
590 __u8 Guid
[SMB2_CLIENT_GUID_SIZE
];
593 __le16 Dialects
[1]; /* dialect (someday maybe list) client asked for */
596 struct validate_negotiate_info_rsp
{
598 __u8 Guid
[SMB2_CLIENT_GUID_SIZE
];
600 __le16 Dialect
; /* Dialect in use for the connection */
603 #define RSS_CAPABLE 0x00000001
604 #define RDMA_CAPABLE 0x00000002
606 struct network_interface_info_ioctl_rsp
{
607 __le32 Next
; /* next interface. zero if this is last one */
609 __le32 Capability
; /* RSS or RDMA Capable */
612 char SockAddr_Storage
[128];
615 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
617 struct compress_ioctl
{
618 __le16 CompressionState
; /* See cifspdu.h for possible flag values */
621 struct smb2_ioctl_req
{
623 __le16 StructureSize
; /* Must be 57 */
626 __u64 PersistentFileId
; /* opaque endianness */
627 __u64 VolatileFileId
; /* opaque endianness */
630 __le32 MaxInputResponse
;
633 __le32 MaxOutputResponse
;
639 struct smb2_ioctl_rsp
{
641 __le16 StructureSize
; /* Must be 57 */
644 __u64 PersistentFileId
; /* opaque endianness */
645 __u64 VolatileFileId
; /* opaque endianness */
652 /* char * buffer[] */
655 /* Currently defined values for close flags */
656 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
657 struct smb2_close_req
{
659 __le16 StructureSize
; /* Must be 24 */
662 __u64 PersistentFileId
; /* opaque endianness */
663 __u64 VolatileFileId
; /* opaque endianness */
666 struct smb2_close_rsp
{
668 __le16 StructureSize
; /* 60 */
672 __le64 LastAccessTime
;
673 __le64 LastWriteTime
;
675 __le64 AllocationSize
; /* Beginning of FILE_STANDARD_INFO equivalent */
680 struct smb2_flush_req
{
682 __le16 StructureSize
; /* Must be 24 */
685 __u64 PersistentFileId
; /* opaque endianness */
686 __u64 VolatileFileId
; /* opaque endianness */
689 struct smb2_flush_rsp
{
691 __le16 StructureSize
;
695 /* For read request Flags field below, following flag is defined for SMB3.02 */
696 #define SMB2_READFLAG_READ_UNBUFFERED 0x01
698 /* Channel field for read and write: exactly one of following flags can be set*/
699 #define SMB2_CHANNEL_NONE 0x00000000
700 #define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */
701 #define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */
703 struct smb2_read_req
{
705 __le16 StructureSize
; /* Must be 49 */
706 __u8 Padding
; /* offset from start of SMB2 header to place read */
707 __u8 Flags
; /* MBZ unless SMB3.02 or later */
710 __u64 PersistentFileId
; /* opaque endianness */
711 __u64 VolatileFileId
; /* opaque endianness */
713 __le32 Channel
; /* MBZ except for SMB3 or later */
714 __le32 RemainingBytes
;
715 __le16 ReadChannelInfoOffset
; /* Reserved MBZ */
716 __le16 ReadChannelInfoLength
; /* Reserved MBZ */
720 struct smb2_read_rsp
{
722 __le16 StructureSize
; /* Must be 17 */
726 __le32 DataRemaining
;
731 /* For write request Flags field below the following flags are defined: */
732 #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
733 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
735 struct smb2_write_req
{
737 __le16 StructureSize
; /* Must be 49 */
738 __le16 DataOffset
; /* offset from start of SMB2 header to write data */
741 __u64 PersistentFileId
; /* opaque endianness */
742 __u64 VolatileFileId
; /* opaque endianness */
743 __le32 Channel
; /* Reserved MBZ */
744 __le32 RemainingBytes
;
745 __le16 WriteChannelInfoOffset
; /* Reserved MBZ */
746 __le16 WriteChannelInfoLength
; /* Reserved MBZ */
751 struct smb2_write_rsp
{
753 __le16 StructureSize
; /* Must be 17 */
757 __le32 DataRemaining
;
762 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
763 #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
764 #define SMB2_LOCKFLAG_UNLOCK 0x0004
765 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
767 struct smb2_lock_element
{
774 struct smb2_lock_req
{
776 __le16 StructureSize
; /* Must be 48 */
779 __u64 PersistentFileId
; /* opaque endianness */
780 __u64 VolatileFileId
; /* opaque endianness */
781 /* Followed by at least one */
782 struct smb2_lock_element locks
[1];
785 struct smb2_lock_rsp
{
787 __le16 StructureSize
; /* Must be 4 */
791 struct smb2_echo_req
{
793 __le16 StructureSize
; /* Must be 4 */
797 struct smb2_echo_rsp
{
799 __le16 StructureSize
; /* Must be 4 */
803 /* search (query_directory) Flags field */
804 #define SMB2_RESTART_SCANS 0x01
805 #define SMB2_RETURN_SINGLE_ENTRY 0x02
806 #define SMB2_INDEX_SPECIFIED 0x04
807 #define SMB2_REOPEN 0x10
809 struct smb2_query_directory_req
{
811 __le16 StructureSize
; /* Must be 33 */
812 __u8 FileInformationClass
;
815 __u64 PersistentFileId
; /* opaque endianness */
816 __u64 VolatileFileId
; /* opaque endianness */
817 __le16 FileNameOffset
;
818 __le16 FileNameLength
;
819 __le32 OutputBufferLength
;
823 struct smb2_query_directory_rsp
{
825 __le16 StructureSize
; /* Must be 9 */
826 __le16 OutputBufferOffset
;
827 __le32 OutputBufferLength
;
831 /* Possible InfoType values */
832 #define SMB2_O_INFO_FILE 0x01
833 #define SMB2_O_INFO_FILESYSTEM 0x02
834 #define SMB2_O_INFO_SECURITY 0x03
835 #define SMB2_O_INFO_QUOTA 0x04
837 struct smb2_query_info_req
{
839 __le16 StructureSize
; /* Must be 41 */
842 __le32 OutputBufferLength
;
843 __le16 InputBufferOffset
;
845 __le32 InputBufferLength
;
846 __le32 AdditionalInformation
;
848 __u64 PersistentFileId
; /* opaque endianness */
849 __u64 VolatileFileId
; /* opaque endianness */
853 struct smb2_query_info_rsp
{
855 __le16 StructureSize
; /* Must be 9 */
856 __le16 OutputBufferOffset
;
857 __le32 OutputBufferLength
;
861 struct smb2_set_info_req
{
863 __le16 StructureSize
; /* Must be 33 */
869 __le32 AdditionalInformation
;
870 __u64 PersistentFileId
; /* opaque endianness */
871 __u64 VolatileFileId
; /* opaque endianness */
875 struct smb2_set_info_rsp
{
877 __le16 StructureSize
; /* Must be 2 */
880 struct smb2_oplock_break
{
882 __le16 StructureSize
; /* Must be 24 */
890 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
892 struct smb2_lease_break
{
894 __le16 StructureSize
; /* Must be 44 */
898 __le32 CurrentLeaseState
;
899 __le32 NewLeaseState
;
901 __le32 AccessMaskHint
;
902 __le32 ShareMaskHint
;
905 struct smb2_lease_ack
{
907 __le16 StructureSize
; /* Must be 36 */
912 __le64 LeaseDuration
;
916 * PDU infolevel structure definitions
917 * BB consider moving to a different header
920 /* File System Information Classes */
921 #define FS_VOLUME_INFORMATION 1 /* Query */
922 #define FS_LABEL_INFORMATION 2 /* Local only */
923 #define FS_SIZE_INFORMATION 3 /* Query */
924 #define FS_DEVICE_INFORMATION 4 /* Query */
925 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
926 #define FS_CONTROL_INFORMATION 6 /* Query, Set */
927 #define FS_FULL_SIZE_INFORMATION 7 /* Query */
928 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
929 #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
930 #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
931 #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
933 struct smb2_fs_full_size_info
{
934 __le64 TotalAllocationUnits
;
935 __le64 CallerAvailableAllocationUnits
;
936 __le64 ActualAvailableAllocationUnits
;
937 __le32 SectorsPerAllocationUnit
;
938 __le32 BytesPerSector
;
941 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
942 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
943 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
944 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
946 /* sector size info struct */
947 struct smb3_fs_ss_info
{
948 __le32 LogicalBytesPerSector
;
949 __le32 PhysicalBytesPerSectorForAtomicity
;
950 __le32 PhysicalBytesPerSectorForPerf
;
951 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity
;
953 __le32 ByteOffsetForSectorAlignment
;
954 __le32 ByteOffsetForPartitionAlignment
;
957 /* partial list of QUERY INFO levels */
958 #define FILE_DIRECTORY_INFORMATION 1
959 #define FILE_FULL_DIRECTORY_INFORMATION 2
960 #define FILE_BOTH_DIRECTORY_INFORMATION 3
961 #define FILE_BASIC_INFORMATION 4
962 #define FILE_STANDARD_INFORMATION 5
963 #define FILE_INTERNAL_INFORMATION 6
964 #define FILE_EA_INFORMATION 7
965 #define FILE_ACCESS_INFORMATION 8
966 #define FILE_NAME_INFORMATION 9
967 #define FILE_RENAME_INFORMATION 10
968 #define FILE_LINK_INFORMATION 11
969 #define FILE_NAMES_INFORMATION 12
970 #define FILE_DISPOSITION_INFORMATION 13
971 #define FILE_POSITION_INFORMATION 14
972 #define FILE_FULL_EA_INFORMATION 15
973 #define FILE_MODE_INFORMATION 16
974 #define FILE_ALIGNMENT_INFORMATION 17
975 #define FILE_ALL_INFORMATION 18
976 #define FILE_ALLOCATION_INFORMATION 19
977 #define FILE_END_OF_FILE_INFORMATION 20
978 #define FILE_ALTERNATE_NAME_INFORMATION 21
979 #define FILE_STREAM_INFORMATION 22
980 #define FILE_PIPE_INFORMATION 23
981 #define FILE_PIPE_LOCAL_INFORMATION 24
982 #define FILE_PIPE_REMOTE_INFORMATION 25
983 #define FILE_MAILSLOT_QUERY_INFORMATION 26
984 #define FILE_MAILSLOT_SET_INFORMATION 27
985 #define FILE_COMPRESSION_INFORMATION 28
986 #define FILE_OBJECT_ID_INFORMATION 29
987 /* Number 30 not defined in documents */
988 #define FILE_MOVE_CLUSTER_INFORMATION 31
989 #define FILE_QUOTA_INFORMATION 32
990 #define FILE_REPARSE_POINT_INFORMATION 33
991 #define FILE_NETWORK_OPEN_INFORMATION 34
992 #define FILE_ATTRIBUTE_TAG_INFORMATION 35
993 #define FILE_TRACKING_INFORMATION 36
994 #define FILEID_BOTH_DIRECTORY_INFORMATION 37
995 #define FILEID_FULL_DIRECTORY_INFORMATION 38
996 #define FILE_VALID_DATA_LENGTH_INFORMATION 39
997 #define FILE_SHORT_NAME_INFORMATION 40
998 #define FILE_SFIO_RESERVE_INFORMATION 44
999 #define FILE_SFIO_VOLUME_INFORMATION 45
1000 #define FILE_HARD_LINK_INFORMATION 46
1001 #define FILE_NORMALIZED_NAME_INFORMATION 48
1002 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1003 #define FILE_STANDARD_LINK_INFORMATION 54
1005 struct smb2_file_internal_info
{
1007 } __packed
; /* level 6 Query */
1009 struct smb2_file_rename_info
{ /* encoding of request for level 10 */
1010 __u8 ReplaceIfExists
; /* 1 = replace existing target with new */
1011 /* 0 = fail if target already exists */
1013 __u64 RootDirectory
; /* MBZ for network operations (why says spec?) */
1014 __le32 FileNameLength
;
1015 char FileName
[0]; /* New name to be assigned */
1016 } __packed
; /* level 10 Set */
1018 struct smb2_file_link_info
{ /* encoding of request for level 11 */
1019 __u8 ReplaceIfExists
; /* 1 = replace existing link with new */
1020 /* 0 = fail if link already exists */
1022 __u64 RootDirectory
; /* MBZ for network operations (why says spec?) */
1023 __le32 FileNameLength
;
1024 char FileName
[0]; /* Name to be assigned to new link */
1025 } __packed
; /* level 11 Set */
1028 * This level 18, although with struct with same name is different from cifs
1029 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1030 * CurrentByteOffset.
1032 struct smb2_file_all_info
{ /* data block encoding of response to level 18 */
1033 __le64 CreationTime
; /* Beginning of FILE_BASIC_INFO equivalent */
1034 __le64 LastAccessTime
;
1035 __le64 LastWriteTime
;
1038 __u32 Pad1
; /* End of FILE_BASIC_INFO_INFO equivalent */
1039 __le64 AllocationSize
; /* Beginning of FILE_STANDARD_INFO equivalent */
1040 __le64 EndOfFile
; /* size ie offset to first free byte in file */
1041 __le32 NumberOfLinks
; /* hard links */
1044 __u16 Pad2
; /* End of FILE_STANDARD_INFO equivalent */
1048 __le64 CurrentByteOffset
;
1050 __le32 AlignmentRequirement
;
1051 __le32 FileNameLength
;
1053 } __packed
; /* level 18 Query */
1055 struct smb2_file_eof_info
{ /* encoding of request for level 10 */
1056 __le64 EndOfFile
; /* new end of file value */
1057 } __packed
; /* level 20 Set */
1059 #endif /* _SMB2PDU_H */