Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * fs/cifs/smb2pdu.h |
| 3 | * |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 4 | * Copyright (c) International Business Machines Corp., 2009, 2013 |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 5 | * Etersoft, 2012 |
| 6 | * Author(s): Steve French (sfrench@us.ibm.com) |
| 7 | * Pavel Shilovsky (pshilovsky@samba.org) 2012 |
| 8 | * |
| 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. |
| 13 | * |
| 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. |
| 18 | * |
| 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 |
| 22 | */ |
| 23 | |
| 24 | #ifndef _SMB2PDU_H |
| 25 | #define _SMB2PDU_H |
| 26 | |
| 27 | #include <net/sock.h> |
| 28 | |
| 29 | /* |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 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. |
| 34 | * |
| 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. |
| 39 | */ |
| 40 | |
| 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 |
| 61 | |
| 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) |
| 82 | |
| 83 | #define NUMBER_OF_SMB2_COMMANDS 0x0013 |
| 84 | |
| 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 */ |
| 87 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 88 | #define SMB2_PROTO_NUMBER __constant_cpu_to_le32(0x424d53fe) |
| 89 | |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 90 | /* |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 91 | * SMB2 Header Definition |
| 92 | * |
| 93 | * "MBZ" : Must be Zero |
| 94 | * "BB" : BugBug, Something to check/review/analyze later |
| 95 | * "PDU" : "Protocol Data Unit" (ie a network "frame") |
| 96 | * |
| 97 | */ |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 98 | |
Pavel Shilovsky | b2ede58 | 2012-09-04 15:49:31 +0400 | [diff] [blame] | 99 | #define SMB2_HEADER_STRUCTURE_SIZE __constant_cpu_to_le16(64) |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 100 | |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 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; |
| 119 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 120 | struct smb2_pdu { |
| 121 | struct smb2_hdr hdr; |
| 122 | __le16 StructureSize2; /* size of wct area (varies, request specific) */ |
| 123 | } __packed; |
| 124 | |
| 125 | /* |
| 126 | * SMB2 flag definitions |
| 127 | */ |
| 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) |
| 133 | |
| 134 | /* |
| 135 | * Definitions for SMB2 Protocol Data Units (network frames) |
| 136 | * |
| 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. |
| 140 | * |
| 141 | */ |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 142 | |
Pavel Shilovsky | b2ede58 | 2012-09-04 15:49:31 +0400 | [diff] [blame] | 143 | #define SMB2_ERROR_STRUCTURE_SIZE2 __constant_cpu_to_le16(9) |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 144 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 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; |
| 152 | |
Pavel Shilovsky | b42bf88 | 2013-08-14 19:25:21 +0400 | [diff] [blame] | 153 | struct smb2_symlink_err_rsp { |
| 154 | __le32 SymLinkLength; |
| 155 | __le32 SymLinkErrorTag; |
| 156 | __le32 ReparseTag; |
| 157 | __le16 ReparseDataLength; |
| 158 | __le16 UnparsedPathLength; |
| 159 | __le16 SubstituteNameOffset; |
| 160 | __le16 SubstituteNameLength; |
| 161 | __le16 PrintNameOffset; |
| 162 | __le16 PrintNameLength; |
| 163 | __le32 Flags; |
| 164 | __u8 PathBuffer[0]; |
| 165 | } __packed; |
| 166 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 167 | #define SMB2_CLIENT_GUID_SIZE 16 |
| 168 | |
| 169 | extern __u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE]; |
| 170 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 171 | struct smb2_negotiate_req { |
| 172 | struct smb2_hdr hdr; |
| 173 | __le16 StructureSize; /* Must be 36 */ |
| 174 | __le16 DialectCount; |
| 175 | __le16 SecurityMode; |
| 176 | __le16 Reserved; /* MBZ */ |
| 177 | __le32 Capabilities; |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 178 | __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE]; |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 179 | __le64 ClientStartTime; /* MBZ */ |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 180 | __le16 Dialects[1]; /* One dialect (vers=) at a time for now */ |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 181 | } __packed; |
| 182 | |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 183 | /* Dialects */ |
| 184 | #define SMB20_PROT_ID 0x0202 |
| 185 | #define SMB21_PROT_ID 0x0210 |
| 186 | #define SMB30_PROT_ID 0x0300 |
Steve French | 20b6d8b | 2013-06-12 22:48:41 -0500 | [diff] [blame] | 187 | #define SMB302_PROT_ID 0x0302 |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 188 | #define BAD_PROT_ID 0xFFFF |
| 189 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 190 | /* SecurityMode flags */ |
| 191 | #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001 |
| 192 | #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002 |
| 193 | /* Capabilities flags */ |
| 194 | #define SMB2_GLOBAL_CAP_DFS 0x00000001 |
| 195 | #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */ |
| 196 | #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */ |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 197 | #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */ |
| 198 | #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */ |
| 199 | #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */ |
| 200 | #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */ |
Pavel Shilovsky | 29e20f9 | 2012-07-13 13:58:14 +0400 | [diff] [blame] | 201 | /* Internal types */ |
| 202 | #define SMB2_NT_FIND 0x00100000 |
| 203 | #define SMB2_LARGE_FILES 0x00200000 |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 204 | |
| 205 | struct smb2_negotiate_rsp { |
| 206 | struct smb2_hdr hdr; |
| 207 | __le16 StructureSize; /* Must be 65 */ |
| 208 | __le16 SecurityMode; |
| 209 | __le16 DialectRevision; |
| 210 | __le16 Reserved; /* MBZ */ |
| 211 | __u8 ServerGUID[16]; |
| 212 | __le32 Capabilities; |
| 213 | __le32 MaxTransactSize; |
| 214 | __le32 MaxReadSize; |
| 215 | __le32 MaxWriteSize; |
| 216 | __le64 SystemTime; /* MBZ */ |
| 217 | __le64 ServerStartTime; |
| 218 | __le16 SecurityBufferOffset; |
| 219 | __le16 SecurityBufferLength; |
| 220 | __le32 Reserved2; /* may be any value, ignore */ |
| 221 | __u8 Buffer[1]; /* variable length GSS security buffer */ |
| 222 | } __packed; |
| 223 | |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 224 | struct smb2_sess_setup_req { |
| 225 | struct smb2_hdr hdr; |
| 226 | __le16 StructureSize; /* Must be 25 */ |
| 227 | __u8 VcNumber; |
| 228 | __u8 SecurityMode; |
| 229 | __le32 Capabilities; |
| 230 | __le32 Channel; |
| 231 | __le16 SecurityBufferOffset; |
| 232 | __le16 SecurityBufferLength; |
| 233 | __le64 PreviousSessionId; |
| 234 | __u8 Buffer[1]; /* variable length GSS security buffer */ |
| 235 | } __packed; |
| 236 | |
| 237 | /* Currently defined SessionFlags */ |
| 238 | #define SMB2_SESSION_FLAG_IS_GUEST 0x0001 |
| 239 | #define SMB2_SESSION_FLAG_IS_NULL 0x0002 |
| 240 | struct smb2_sess_setup_rsp { |
| 241 | struct smb2_hdr hdr; |
| 242 | __le16 StructureSize; /* Must be 9 */ |
| 243 | __le16 SessionFlags; |
| 244 | __le16 SecurityBufferOffset; |
| 245 | __le16 SecurityBufferLength; |
| 246 | __u8 Buffer[1]; /* variable length GSS security buffer */ |
| 247 | } __packed; |
| 248 | |
| 249 | struct smb2_logoff_req { |
| 250 | struct smb2_hdr hdr; |
| 251 | __le16 StructureSize; /* Must be 4 */ |
| 252 | __le16 Reserved; |
| 253 | } __packed; |
| 254 | |
| 255 | struct smb2_logoff_rsp { |
| 256 | struct smb2_hdr hdr; |
| 257 | __le16 StructureSize; /* Must be 4 */ |
| 258 | __le16 Reserved; |
| 259 | } __packed; |
| 260 | |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 261 | struct smb2_tree_connect_req { |
| 262 | struct smb2_hdr hdr; |
| 263 | __le16 StructureSize; /* Must be 9 */ |
| 264 | __le16 Reserved; |
| 265 | __le16 PathOffset; |
| 266 | __le16 PathLength; |
| 267 | __u8 Buffer[1]; /* variable length */ |
| 268 | } __packed; |
| 269 | |
| 270 | struct smb2_tree_connect_rsp { |
| 271 | struct smb2_hdr hdr; |
| 272 | __le16 StructureSize; /* Must be 16 */ |
| 273 | __u8 ShareType; /* see below */ |
| 274 | __u8 Reserved; |
| 275 | __le32 ShareFlags; /* see below */ |
| 276 | __le32 Capabilities; /* see below */ |
| 277 | __le32 MaximalAccess; |
| 278 | } __packed; |
| 279 | |
| 280 | /* Possible ShareType values */ |
| 281 | #define SMB2_SHARE_TYPE_DISK 0x01 |
| 282 | #define SMB2_SHARE_TYPE_PIPE 0x02 |
| 283 | #define SMB2_SHARE_TYPE_PRINT 0x03 |
| 284 | |
| 285 | /* |
| 286 | * Possible ShareFlags - exactly one and only one of the first 4 caching flags |
| 287 | * must be set (any of the remaining, SHI1005, flags may be set individually |
| 288 | * or in combination. |
| 289 | */ |
| 290 | #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000 |
| 291 | #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010 |
| 292 | #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020 |
| 293 | #define SMB2_SHAREFLAG_NO_CACHING 0x00000030 |
| 294 | #define SHI1005_FLAGS_DFS 0x00000001 |
| 295 | #define SHI1005_FLAGS_DFS_ROOT 0x00000002 |
| 296 | #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100 |
| 297 | #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200 |
| 298 | #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400 |
| 299 | #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800 |
| 300 | #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000 |
Steve French | c866473 | 2013-06-21 15:35:45 -0500 | [diff] [blame] | 301 | #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000 |
| 302 | #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000 |
| 303 | #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000 |
| 304 | #define SHI1005_FLAGS_ALL 0x0000FF33 |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 305 | |
| 306 | /* Possible share capabilities */ |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 307 | #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */ |
| 308 | #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */ |
| 309 | #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */ |
| 310 | #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */ |
| 311 | #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */ |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 312 | |
| 313 | struct smb2_tree_disconnect_req { |
| 314 | struct smb2_hdr hdr; |
| 315 | __le16 StructureSize; /* Must be 4 */ |
| 316 | __le16 Reserved; |
| 317 | } __packed; |
| 318 | |
| 319 | struct smb2_tree_disconnect_rsp { |
| 320 | struct smb2_hdr hdr; |
| 321 | __le16 StructureSize; /* Must be 4 */ |
| 322 | __le16 Reserved; |
| 323 | } __packed; |
| 324 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 325 | /* File Attrubutes */ |
| 326 | #define FILE_ATTRIBUTE_READONLY 0x00000001 |
| 327 | #define FILE_ATTRIBUTE_HIDDEN 0x00000002 |
| 328 | #define FILE_ATTRIBUTE_SYSTEM 0x00000004 |
| 329 | #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 |
| 330 | #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 |
| 331 | #define FILE_ATTRIBUTE_NORMAL 0x00000080 |
| 332 | #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 |
| 333 | #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 |
| 334 | #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 |
| 335 | #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 |
| 336 | #define FILE_ATTRIBUTE_OFFLINE 0x00001000 |
| 337 | #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 |
| 338 | #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 |
| 339 | |
| 340 | /* Oplock levels */ |
| 341 | #define SMB2_OPLOCK_LEVEL_NONE 0x00 |
| 342 | #define SMB2_OPLOCK_LEVEL_II 0x01 |
| 343 | #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 |
| 344 | #define SMB2_OPLOCK_LEVEL_BATCH 0x09 |
| 345 | #define SMB2_OPLOCK_LEVEL_LEASE 0xFF |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 346 | /* Non-spec internal type */ |
| 347 | #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 348 | |
| 349 | /* Desired Access Flags */ |
| 350 | #define FILE_READ_DATA_LE cpu_to_le32(0x00000001) |
| 351 | #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002) |
| 352 | #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004) |
| 353 | #define FILE_READ_EA_LE cpu_to_le32(0x00000008) |
| 354 | #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010) |
| 355 | #define FILE_EXECUTE_LE cpu_to_le32(0x00000020) |
| 356 | #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080) |
| 357 | #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100) |
| 358 | #define FILE_DELETE_LE cpu_to_le32(0x00010000) |
| 359 | #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000) |
| 360 | #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000) |
| 361 | #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000) |
| 362 | #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000) |
| 363 | #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000) |
| 364 | #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000) |
| 365 | #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000) |
| 366 | #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000) |
| 367 | #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000) |
| 368 | #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000) |
| 369 | |
| 370 | /* ShareAccess Flags */ |
| 371 | #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001) |
| 372 | #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002) |
| 373 | #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004) |
| 374 | #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007) |
| 375 | |
| 376 | /* CreateDisposition Flags */ |
| 377 | #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000) |
| 378 | #define FILE_OPEN_LE cpu_to_le32(0x00000001) |
| 379 | #define FILE_CREATE_LE cpu_to_le32(0x00000002) |
| 380 | #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003) |
| 381 | #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004) |
| 382 | #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) |
| 383 | |
| 384 | /* CreateOptions Flags */ |
| 385 | #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) |
| 386 | /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ |
| 387 | #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002) |
| 388 | #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004) |
| 389 | #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008) |
| 390 | #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010) |
| 391 | #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020) |
| 392 | #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040) |
| 393 | #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100) |
| 394 | #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200) |
| 395 | #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800) |
| 396 | #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000) |
| 397 | #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000) |
| 398 | #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000) |
| 399 | #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000) |
| 400 | #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000) |
| 401 | #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000) |
| 402 | #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000) |
| 403 | #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000) |
| 404 | |
| 405 | #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \ |
| 406 | | FILE_READ_ATTRIBUTES_LE) |
| 407 | #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \ |
| 408 | | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE) |
| 409 | #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE) |
| 410 | |
| 411 | /* Impersonation Levels */ |
| 412 | #define IL_ANONYMOUS cpu_to_le32(0x00000000) |
| 413 | #define IL_IDENTIFICATION cpu_to_le32(0x00000001) |
| 414 | #define IL_IMPERSONATION cpu_to_le32(0x00000002) |
| 415 | #define IL_DELEGATE cpu_to_le32(0x00000003) |
| 416 | |
| 417 | /* Create Context Values */ |
| 418 | #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */ |
| 419 | #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */ |
| 420 | #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ" |
| 421 | #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" |
| 422 | #define SMB2_CREATE_ALLOCATION_SIZE "AlSi" |
| 423 | #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc" |
| 424 | #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp" |
| 425 | #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid" |
| 426 | #define SMB2_CREATE_REQUEST_LEASE "RqLs" |
| 427 | |
| 428 | struct smb2_create_req { |
| 429 | struct smb2_hdr hdr; |
| 430 | __le16 StructureSize; /* Must be 57 */ |
| 431 | __u8 SecurityFlags; |
| 432 | __u8 RequestedOplockLevel; |
| 433 | __le32 ImpersonationLevel; |
| 434 | __le64 SmbCreateFlags; |
| 435 | __le64 Reserved; |
| 436 | __le32 DesiredAccess; |
| 437 | __le32 FileAttributes; |
| 438 | __le32 ShareAccess; |
| 439 | __le32 CreateDisposition; |
| 440 | __le32 CreateOptions; |
| 441 | __le16 NameOffset; |
| 442 | __le16 NameLength; |
| 443 | __le32 CreateContextsOffset; |
| 444 | __le32 CreateContextsLength; |
Pavel Shilovsky | 59aa371 | 2013-07-04 19:41:24 +0400 | [diff] [blame] | 445 | __u8 Buffer[0]; |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 446 | } __packed; |
| 447 | |
| 448 | struct smb2_create_rsp { |
| 449 | struct smb2_hdr hdr; |
| 450 | __le16 StructureSize; /* Must be 89 */ |
| 451 | __u8 OplockLevel; |
| 452 | __u8 Reserved; |
| 453 | __le32 CreateAction; |
| 454 | __le64 CreationTime; |
| 455 | __le64 LastAccessTime; |
| 456 | __le64 LastWriteTime; |
| 457 | __le64 ChangeTime; |
| 458 | __le64 AllocationSize; |
| 459 | __le64 EndofFile; |
| 460 | __le32 FileAttributes; |
| 461 | __le32 Reserved2; |
| 462 | __u64 PersistentFileId; /* opaque endianness */ |
| 463 | __u64 VolatileFileId; /* opaque endianness */ |
| 464 | __le32 CreateContextsOffset; |
| 465 | __le32 CreateContextsLength; |
| 466 | __u8 Buffer[1]; |
| 467 | } __packed; |
| 468 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 469 | struct create_context { |
| 470 | __le32 Next; |
| 471 | __le16 NameOffset; |
| 472 | __le16 NameLength; |
| 473 | __le16 Reserved; |
| 474 | __le16 DataOffset; |
| 475 | __le32 DataLength; |
| 476 | __u8 Buffer[0]; |
| 477 | } __packed; |
| 478 | |
Pavel Shilovsky | 53ef101 | 2013-09-05 16:11:28 +0400 | [diff] [blame] | 479 | #define SMB2_LEASE_READ_CACHING_HE 0x01 |
| 480 | #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 |
| 481 | #define SMB2_LEASE_WRITE_CACHING_HE 0x04 |
| 482 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 483 | #define SMB2_LEASE_NONE __constant_cpu_to_le32(0x00) |
| 484 | #define SMB2_LEASE_READ_CACHING __constant_cpu_to_le32(0x01) |
| 485 | #define SMB2_LEASE_HANDLE_CACHING __constant_cpu_to_le32(0x02) |
| 486 | #define SMB2_LEASE_WRITE_CACHING __constant_cpu_to_le32(0x04) |
| 487 | |
| 488 | #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS __constant_cpu_to_le32(0x02) |
| 489 | |
| 490 | #define SMB2_LEASE_KEY_SIZE 16 |
| 491 | |
| 492 | struct lease_context { |
| 493 | __le64 LeaseKeyLow; |
| 494 | __le64 LeaseKeyHigh; |
| 495 | __le32 LeaseState; |
| 496 | __le32 LeaseFlags; |
| 497 | __le64 LeaseDuration; |
| 498 | } __packed; |
| 499 | |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 500 | struct lease_context_v2 { |
| 501 | __le64 LeaseKeyLow; |
| 502 | __le64 LeaseKeyHigh; |
| 503 | __le32 LeaseState; |
| 504 | __le32 LeaseFlags; |
| 505 | __le64 LeaseDuration; |
| 506 | __le64 ParentLeaseKeyLow; |
| 507 | __le64 ParentLeaseKeyHigh; |
| 508 | __le16 Epoch; |
| 509 | __le16 Reserved; |
| 510 | } __packed; |
| 511 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 512 | struct create_lease { |
| 513 | struct create_context ccontext; |
| 514 | __u8 Name[8]; |
| 515 | struct lease_context lcontext; |
| 516 | } __packed; |
| 517 | |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 518 | struct create_lease_v2 { |
| 519 | struct create_context ccontext; |
| 520 | __u8 Name[8]; |
| 521 | struct lease_context_v2 lcontext; |
| 522 | __u8 Pad[4]; |
| 523 | } __packed; |
| 524 | |
Pavel Shilovsky | 63eb3de | 2013-07-04 18:41:09 +0400 | [diff] [blame] | 525 | struct create_durable { |
| 526 | struct create_context ccontext; |
| 527 | __u8 Name[8]; |
Pavel Shilovsky | 9cbc0b7 | 2013-07-09 18:40:58 +0400 | [diff] [blame] | 528 | union { |
| 529 | __u8 Reserved[16]; |
| 530 | struct { |
| 531 | __u64 PersistentFileId; |
| 532 | __u64 VolatileFileId; |
| 533 | } Fid; |
| 534 | } Data; |
Pavel Shilovsky | 63eb3de | 2013-07-04 18:41:09 +0400 | [diff] [blame] | 535 | } __packed; |
| 536 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 537 | /* this goes in the ioctl buffer when doing a copychunk request */ |
| 538 | struct copychunk_ioctl { |
| 539 | char SourceKey[24]; |
| 540 | __le32 ChunkCount; /* we are only sending 1 */ |
| 541 | __le32 Reserved; |
| 542 | /* array will only be one chunk long for us */ |
| 543 | __le64 SourceOffset; |
| 544 | __le64 TargetOffset; |
Steve French | c866473 | 2013-06-21 15:35:45 -0500 | [diff] [blame] | 545 | __le32 Length; /* how many bytes to copy */ |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 546 | __u32 Reserved2; |
| 547 | } __packed; |
| 548 | |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 549 | /* Response and Request are the same format */ |
| 550 | struct validate_negotiate_info { |
| 551 | __le32 Capabilities; |
| 552 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; |
| 553 | __le16 SecurityMode; |
| 554 | __le16 DialectCount; |
| 555 | __le16 Dialect[1]; |
| 556 | } __packed; |
| 557 | |
| 558 | #define RSS_CAPABLE 0x00000001 |
| 559 | #define RDMA_CAPABLE 0x00000002 |
| 560 | |
| 561 | struct network_interface_info_ioctl_rsp { |
| 562 | __le32 Next; /* next interface. zero if this is last one */ |
| 563 | __le32 IfIndex; |
| 564 | __le32 Capability; /* RSS or RDMA Capable */ |
| 565 | __le32 Reserved; |
| 566 | __le64 LinkSpeed; |
| 567 | char SockAddr_Storage[128]; |
| 568 | } __packed; |
| 569 | |
| 570 | #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ |
| 571 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 572 | struct smb2_ioctl_req { |
| 573 | struct smb2_hdr hdr; |
| 574 | __le16 StructureSize; /* Must be 57 */ |
| 575 | __u16 Reserved; |
| 576 | __le32 CtlCode; |
| 577 | __u64 PersistentFileId; /* opaque endianness */ |
| 578 | __u64 VolatileFileId; /* opaque endianness */ |
| 579 | __le32 InputOffset; |
| 580 | __le32 InputCount; |
| 581 | __le32 MaxInputResponse; |
| 582 | __le32 OutputOffset; |
| 583 | __le32 OutputCount; |
| 584 | __le32 MaxOutputResponse; |
| 585 | __le32 Flags; |
| 586 | __u32 Reserved2; |
| 587 | char Buffer[0]; |
| 588 | } __packed; |
| 589 | |
| 590 | struct smb2_ioctl_rsp { |
| 591 | struct smb2_hdr hdr; |
| 592 | __le16 StructureSize; /* Must be 57 */ |
| 593 | __u16 Reserved; |
| 594 | __le32 CtlCode; |
| 595 | __u64 PersistentFileId; /* opaque endianness */ |
| 596 | __u64 VolatileFileId; /* opaque endianness */ |
| 597 | __le32 InputOffset; |
| 598 | __le32 InputCount; |
| 599 | __le32 OutputOffset; |
| 600 | __le32 OutputCount; |
| 601 | __le32 Flags; |
| 602 | __u32 Reserved2; |
| 603 | /* char * buffer[] */ |
| 604 | } __packed; |
| 605 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 606 | /* Currently defined values for close flags */ |
| 607 | #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) |
| 608 | struct smb2_close_req { |
| 609 | struct smb2_hdr hdr; |
| 610 | __le16 StructureSize; /* Must be 24 */ |
| 611 | __le16 Flags; |
| 612 | __le32 Reserved; |
| 613 | __u64 PersistentFileId; /* opaque endianness */ |
| 614 | __u64 VolatileFileId; /* opaque endianness */ |
| 615 | } __packed; |
| 616 | |
| 617 | struct smb2_close_rsp { |
| 618 | struct smb2_hdr hdr; |
| 619 | __le16 StructureSize; /* 60 */ |
| 620 | __le16 Flags; |
| 621 | __le32 Reserved; |
| 622 | __le64 CreationTime; |
| 623 | __le64 LastAccessTime; |
| 624 | __le64 LastWriteTime; |
| 625 | __le64 ChangeTime; |
| 626 | __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ |
| 627 | __le64 EndOfFile; |
| 628 | __le32 Attributes; |
| 629 | } __packed; |
| 630 | |
Pavel Shilovsky | 7a5cfb1 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 631 | struct smb2_flush_req { |
| 632 | struct smb2_hdr hdr; |
| 633 | __le16 StructureSize; /* Must be 24 */ |
| 634 | __le16 Reserved1; |
| 635 | __le32 Reserved2; |
| 636 | __u64 PersistentFileId; /* opaque endianness */ |
| 637 | __u64 VolatileFileId; /* opaque endianness */ |
| 638 | } __packed; |
| 639 | |
| 640 | struct smb2_flush_rsp { |
| 641 | struct smb2_hdr hdr; |
| 642 | __le16 StructureSize; |
| 643 | __le16 Reserved; |
| 644 | } __packed; |
| 645 | |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 646 | /* For read request Flags field below, following flag is defined for SMB3.02 */ |
| 647 | #define SMB2_READFLAG_READ_UNBUFFERED 0x01 |
| 648 | |
| 649 | /* Channel field for read and write: exactly one of following flags can be set*/ |
| 650 | #define SMB2_CHANNEL_NONE 0x00000000 |
| 651 | #define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */ |
| 652 | #define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */ |
| 653 | |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 654 | struct smb2_read_req { |
| 655 | struct smb2_hdr hdr; |
| 656 | __le16 StructureSize; /* Must be 49 */ |
| 657 | __u8 Padding; /* offset from start of SMB2 header to place read */ |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 658 | __u8 Flags; /* MBZ unless SMB3.02 or later */ |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 659 | __le32 Length; |
| 660 | __le64 Offset; |
| 661 | __u64 PersistentFileId; /* opaque endianness */ |
| 662 | __u64 VolatileFileId; /* opaque endianness */ |
| 663 | __le32 MinimumCount; |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 664 | __le32 Channel; /* MBZ except for SMB3 or later */ |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 665 | __le32 RemainingBytes; |
| 666 | __le16 ReadChannelInfoOffset; /* Reserved MBZ */ |
| 667 | __le16 ReadChannelInfoLength; /* Reserved MBZ */ |
| 668 | __u8 Buffer[1]; |
| 669 | } __packed; |
| 670 | |
| 671 | struct smb2_read_rsp { |
| 672 | struct smb2_hdr hdr; |
| 673 | __le16 StructureSize; /* Must be 17 */ |
| 674 | __u8 DataOffset; |
| 675 | __u8 Reserved; |
| 676 | __le32 DataLength; |
| 677 | __le32 DataRemaining; |
| 678 | __u32 Reserved2; |
| 679 | __u8 Buffer[1]; |
| 680 | } __packed; |
| 681 | |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 682 | /* For write request Flags field below the following flags are defined: */ |
| 683 | #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */ |
| 684 | #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ |
Pavel Shilovsky | 3331914 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 685 | |
| 686 | struct smb2_write_req { |
| 687 | struct smb2_hdr hdr; |
| 688 | __le16 StructureSize; /* Must be 49 */ |
| 689 | __le16 DataOffset; /* offset from start of SMB2 header to write data */ |
| 690 | __le32 Length; |
| 691 | __le64 Offset; |
| 692 | __u64 PersistentFileId; /* opaque endianness */ |
| 693 | __u64 VolatileFileId; /* opaque endianness */ |
| 694 | __le32 Channel; /* Reserved MBZ */ |
| 695 | __le32 RemainingBytes; |
| 696 | __le16 WriteChannelInfoOffset; /* Reserved MBZ */ |
| 697 | __le16 WriteChannelInfoLength; /* Reserved MBZ */ |
| 698 | __le32 Flags; |
| 699 | __u8 Buffer[1]; |
| 700 | } __packed; |
| 701 | |
| 702 | struct smb2_write_rsp { |
| 703 | struct smb2_hdr hdr; |
| 704 | __le16 StructureSize; /* Must be 17 */ |
| 705 | __u8 DataOffset; |
| 706 | __u8 Reserved; |
| 707 | __le32 DataLength; |
| 708 | __le32 DataRemaining; |
| 709 | __u32 Reserved2; |
| 710 | __u8 Buffer[1]; |
| 711 | } __packed; |
| 712 | |
Pavel Shilovsky | 027e8ee | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 713 | #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001 |
| 714 | #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002 |
| 715 | #define SMB2_LOCKFLAG_UNLOCK 0x0004 |
| 716 | #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010 |
| 717 | |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 718 | struct smb2_lock_element { |
| 719 | __le64 Offset; |
| 720 | __le64 Length; |
| 721 | __le32 Flags; |
| 722 | __le32 Reserved; |
| 723 | } __packed; |
| 724 | |
| 725 | struct smb2_lock_req { |
| 726 | struct smb2_hdr hdr; |
| 727 | __le16 StructureSize; /* Must be 48 */ |
| 728 | __le16 LockCount; |
| 729 | __le32 Reserved; |
| 730 | __u64 PersistentFileId; /* opaque endianness */ |
| 731 | __u64 VolatileFileId; /* opaque endianness */ |
| 732 | /* Followed by at least one */ |
| 733 | struct smb2_lock_element locks[1]; |
| 734 | } __packed; |
| 735 | |
| 736 | struct smb2_lock_rsp { |
| 737 | struct smb2_hdr hdr; |
| 738 | __le16 StructureSize; /* Must be 4 */ |
| 739 | __le16 Reserved; |
| 740 | } __packed; |
| 741 | |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 742 | struct smb2_echo_req { |
| 743 | struct smb2_hdr hdr; |
| 744 | __le16 StructureSize; /* Must be 4 */ |
| 745 | __u16 Reserved; |
| 746 | } __packed; |
| 747 | |
| 748 | struct smb2_echo_rsp { |
| 749 | struct smb2_hdr hdr; |
| 750 | __le16 StructureSize; /* Must be 4 */ |
| 751 | __u16 Reserved; |
| 752 | } __packed; |
| 753 | |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 754 | /* search (query_directory) Flags field */ |
| 755 | #define SMB2_RESTART_SCANS 0x01 |
| 756 | #define SMB2_RETURN_SINGLE_ENTRY 0x02 |
| 757 | #define SMB2_INDEX_SPECIFIED 0x04 |
| 758 | #define SMB2_REOPEN 0x10 |
| 759 | |
| 760 | struct smb2_query_directory_req { |
| 761 | struct smb2_hdr hdr; |
| 762 | __le16 StructureSize; /* Must be 33 */ |
| 763 | __u8 FileInformationClass; |
| 764 | __u8 Flags; |
| 765 | __le32 FileIndex; |
| 766 | __u64 PersistentFileId; /* opaque endianness */ |
| 767 | __u64 VolatileFileId; /* opaque endianness */ |
| 768 | __le16 FileNameOffset; |
| 769 | __le16 FileNameLength; |
| 770 | __le32 OutputBufferLength; |
| 771 | __u8 Buffer[1]; |
| 772 | } __packed; |
| 773 | |
| 774 | struct smb2_query_directory_rsp { |
| 775 | struct smb2_hdr hdr; |
| 776 | __le16 StructureSize; /* Must be 9 */ |
| 777 | __le16 OutputBufferOffset; |
| 778 | __le32 OutputBufferLength; |
| 779 | __u8 Buffer[1]; |
| 780 | } __packed; |
| 781 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 782 | /* Possible InfoType values */ |
| 783 | #define SMB2_O_INFO_FILE 0x01 |
| 784 | #define SMB2_O_INFO_FILESYSTEM 0x02 |
| 785 | #define SMB2_O_INFO_SECURITY 0x03 |
| 786 | #define SMB2_O_INFO_QUOTA 0x04 |
| 787 | |
| 788 | struct smb2_query_info_req { |
| 789 | struct smb2_hdr hdr; |
| 790 | __le16 StructureSize; /* Must be 41 */ |
| 791 | __u8 InfoType; |
| 792 | __u8 FileInfoClass; |
| 793 | __le32 OutputBufferLength; |
| 794 | __le16 InputBufferOffset; |
| 795 | __u16 Reserved; |
| 796 | __le32 InputBufferLength; |
| 797 | __le32 AdditionalInformation; |
| 798 | __le32 Flags; |
| 799 | __u64 PersistentFileId; /* opaque endianness */ |
| 800 | __u64 VolatileFileId; /* opaque endianness */ |
| 801 | __u8 Buffer[1]; |
| 802 | } __packed; |
| 803 | |
| 804 | struct smb2_query_info_rsp { |
| 805 | struct smb2_hdr hdr; |
| 806 | __le16 StructureSize; /* Must be 9 */ |
| 807 | __le16 OutputBufferOffset; |
| 808 | __le32 OutputBufferLength; |
| 809 | __u8 Buffer[1]; |
| 810 | } __packed; |
| 811 | |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 812 | struct smb2_set_info_req { |
| 813 | struct smb2_hdr hdr; |
| 814 | __le16 StructureSize; /* Must be 33 */ |
| 815 | __u8 InfoType; |
| 816 | __u8 FileInfoClass; |
| 817 | __le32 BufferLength; |
| 818 | __le16 BufferOffset; |
| 819 | __u16 Reserved; |
| 820 | __le32 AdditionalInformation; |
| 821 | __u64 PersistentFileId; /* opaque endianness */ |
| 822 | __u64 VolatileFileId; /* opaque endianness */ |
| 823 | __u8 Buffer[1]; |
| 824 | } __packed; |
| 825 | |
| 826 | struct smb2_set_info_rsp { |
| 827 | struct smb2_hdr hdr; |
| 828 | __le16 StructureSize; /* Must be 2 */ |
| 829 | } __packed; |
| 830 | |
Pavel Shilovsky | 983c88a | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 831 | struct smb2_oplock_break { |
| 832 | struct smb2_hdr hdr; |
| 833 | __le16 StructureSize; /* Must be 24 */ |
| 834 | __u8 OplockLevel; |
| 835 | __u8 Reserved; |
| 836 | __le32 Reserved2; |
| 837 | __u64 PersistentFid; |
| 838 | __u64 VolatileFid; |
| 839 | } __packed; |
| 840 | |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 841 | #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) |
| 842 | |
| 843 | struct smb2_lease_break { |
| 844 | struct smb2_hdr hdr; |
| 845 | __le16 StructureSize; /* Must be 44 */ |
| 846 | __le16 Reserved; |
| 847 | __le32 Flags; |
| 848 | __u8 LeaseKey[16]; |
| 849 | __le32 CurrentLeaseState; |
| 850 | __le32 NewLeaseState; |
| 851 | __le32 BreakReason; |
| 852 | __le32 AccessMaskHint; |
| 853 | __le32 ShareMaskHint; |
| 854 | } __packed; |
| 855 | |
| 856 | struct smb2_lease_ack { |
| 857 | struct smb2_hdr hdr; |
| 858 | __le16 StructureSize; /* Must be 36 */ |
| 859 | __le16 Reserved; |
| 860 | __le32 Flags; |
| 861 | __u8 LeaseKey[16]; |
| 862 | __le32 LeaseState; |
| 863 | __le64 LeaseDuration; |
| 864 | } __packed; |
| 865 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 866 | /* |
| 867 | * PDU infolevel structure definitions |
| 868 | * BB consider moving to a different header |
| 869 | */ |
| 870 | |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 871 | /* File System Information Classes */ |
| 872 | #define FS_VOLUME_INFORMATION 1 /* Query */ |
| 873 | #define FS_LABEL_INFORMATION 2 /* Set */ |
| 874 | #define FS_SIZE_INFORMATION 3 /* Query */ |
| 875 | #define FS_DEVICE_INFORMATION 4 /* Query */ |
| 876 | #define FS_ATTRIBUTE_INFORMATION 5 /* Query */ |
| 877 | #define FS_CONTROL_INFORMATION 6 /* Query, Set */ |
| 878 | #define FS_FULL_SIZE_INFORMATION 7 /* Query */ |
| 879 | #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ |
| 880 | #define FS_DRIVER_PATH_INFORMATION 9 /* Query */ |
| 881 | |
| 882 | struct smb2_fs_full_size_info { |
| 883 | __le64 TotalAllocationUnits; |
| 884 | __le64 CallerAvailableAllocationUnits; |
| 885 | __le64 ActualAvailableAllocationUnits; |
| 886 | __le32 SectorsPerAllocationUnit; |
| 887 | __le32 BytesPerSector; |
| 888 | } __packed; |
| 889 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 890 | /* partial list of QUERY INFO levels */ |
| 891 | #define FILE_DIRECTORY_INFORMATION 1 |
| 892 | #define FILE_FULL_DIRECTORY_INFORMATION 2 |
| 893 | #define FILE_BOTH_DIRECTORY_INFORMATION 3 |
| 894 | #define FILE_BASIC_INFORMATION 4 |
| 895 | #define FILE_STANDARD_INFORMATION 5 |
| 896 | #define FILE_INTERNAL_INFORMATION 6 |
| 897 | #define FILE_EA_INFORMATION 7 |
| 898 | #define FILE_ACCESS_INFORMATION 8 |
| 899 | #define FILE_NAME_INFORMATION 9 |
| 900 | #define FILE_RENAME_INFORMATION 10 |
| 901 | #define FILE_LINK_INFORMATION 11 |
| 902 | #define FILE_NAMES_INFORMATION 12 |
| 903 | #define FILE_DISPOSITION_INFORMATION 13 |
| 904 | #define FILE_POSITION_INFORMATION 14 |
| 905 | #define FILE_FULL_EA_INFORMATION 15 |
| 906 | #define FILE_MODE_INFORMATION 16 |
| 907 | #define FILE_ALIGNMENT_INFORMATION 17 |
| 908 | #define FILE_ALL_INFORMATION 18 |
| 909 | #define FILE_ALLOCATION_INFORMATION 19 |
| 910 | #define FILE_END_OF_FILE_INFORMATION 20 |
| 911 | #define FILE_ALTERNATE_NAME_INFORMATION 21 |
| 912 | #define FILE_STREAM_INFORMATION 22 |
| 913 | #define FILE_PIPE_INFORMATION 23 |
| 914 | #define FILE_PIPE_LOCAL_INFORMATION 24 |
| 915 | #define FILE_PIPE_REMOTE_INFORMATION 25 |
| 916 | #define FILE_MAILSLOT_QUERY_INFORMATION 26 |
| 917 | #define FILE_MAILSLOT_SET_INFORMATION 27 |
| 918 | #define FILE_COMPRESSION_INFORMATION 28 |
| 919 | #define FILE_OBJECT_ID_INFORMATION 29 |
| 920 | /* Number 30 not defined in documents */ |
| 921 | #define FILE_MOVE_CLUSTER_INFORMATION 31 |
| 922 | #define FILE_QUOTA_INFORMATION 32 |
| 923 | #define FILE_REPARSE_POINT_INFORMATION 33 |
| 924 | #define FILE_NETWORK_OPEN_INFORMATION 34 |
| 925 | #define FILE_ATTRIBUTE_TAG_INFORMATION 35 |
| 926 | #define FILE_TRACKING_INFORMATION 36 |
| 927 | #define FILEID_BOTH_DIRECTORY_INFORMATION 37 |
| 928 | #define FILEID_FULL_DIRECTORY_INFORMATION 38 |
| 929 | #define FILE_VALID_DATA_LENGTH_INFORMATION 39 |
| 930 | #define FILE_SHORT_NAME_INFORMATION 40 |
| 931 | #define FILE_SFIO_RESERVE_INFORMATION 44 |
| 932 | #define FILE_SFIO_VOLUME_INFORMATION 45 |
| 933 | #define FILE_HARD_LINK_INFORMATION 46 |
| 934 | #define FILE_NORMALIZED_NAME_INFORMATION 48 |
| 935 | #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 |
| 936 | #define FILE_STANDARD_LINK_INFORMATION 54 |
| 937 | |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 938 | struct smb2_file_internal_info { |
| 939 | __le64 IndexNumber; |
| 940 | } __packed; /* level 6 Query */ |
| 941 | |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 942 | struct smb2_file_rename_info { /* encoding of request for level 10 */ |
| 943 | __u8 ReplaceIfExists; /* 1 = replace existing target with new */ |
| 944 | /* 0 = fail if target already exists */ |
| 945 | __u8 Reserved[7]; |
| 946 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ |
| 947 | __le32 FileNameLength; |
| 948 | char FileName[0]; /* New name to be assigned */ |
| 949 | } __packed; /* level 10 Set */ |
| 950 | |
Pavel Shilovsky | 568798c | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 951 | struct smb2_file_link_info { /* encoding of request for level 11 */ |
| 952 | __u8 ReplaceIfExists; /* 1 = replace existing link with new */ |
| 953 | /* 0 = fail if link already exists */ |
| 954 | __u8 Reserved[7]; |
| 955 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ |
| 956 | __le32 FileNameLength; |
| 957 | char FileName[0]; /* Name to be assigned to new link */ |
| 958 | } __packed; /* level 11 Set */ |
| 959 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 960 | /* |
| 961 | * This level 18, although with struct with same name is different from cifs |
| 962 | * level 0x107. Level 0x107 has an extra u64 between AccessFlags and |
| 963 | * CurrentByteOffset. |
| 964 | */ |
| 965 | struct smb2_file_all_info { /* data block encoding of response to level 18 */ |
| 966 | __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ |
| 967 | __le64 LastAccessTime; |
| 968 | __le64 LastWriteTime; |
| 969 | __le64 ChangeTime; |
| 970 | __le32 Attributes; |
| 971 | __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ |
| 972 | __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ |
| 973 | __le64 EndOfFile; /* size ie offset to first free byte in file */ |
| 974 | __le32 NumberOfLinks; /* hard links */ |
| 975 | __u8 DeletePending; |
| 976 | __u8 Directory; |
| 977 | __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ |
| 978 | __le64 IndexNumber; |
| 979 | __le32 EASize; |
| 980 | __le32 AccessFlags; |
| 981 | __le64 CurrentByteOffset; |
| 982 | __le32 Mode; |
| 983 | __le32 AlignmentRequirement; |
| 984 | __le32 FileNameLength; |
| 985 | char FileName[1]; |
| 986 | } __packed; /* level 18 Query */ |
| 987 | |
Pavel Shilovsky | c839ff2 | 2012-09-18 16:20:32 -0700 | [diff] [blame] | 988 | struct smb2_file_eof_info { /* encoding of request for level 10 */ |
| 989 | __le64 EndOfFile; /* new end of file value */ |
| 990 | } __packed; /* level 20 Set */ |
| 991 | |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 992 | #endif /* _SMB2PDU_H */ |