]>
Commit | Line | Data |
---|---|---|
ddfbefbd SF |
1 | /* |
2 | * fs/cifs/smb2pdu.h | |
3 | * | |
be7457d3 | 4 | * Copyright (c) International Business Machines Corp., 2009, 2013 |
ddfbefbd SF |
5 | * Etersoft, 2012 |
6 | * Author(s): Steve French ([email protected]) | |
7 | * Pavel Shilovsky ([email protected]) 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 | ||
2dc7e1c0 PS |
29 | /* |
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 | ||
093b2bda PS |
88 | #define SMB2_PROTO_NUMBER __constant_cpu_to_le32(0x424d53fe) |
89 | ||
ddfbefbd SF |
90 | /* |
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 | */ | |
74112860 | 98 | |
b2ede58e | 99 | #define SMB2_HEADER_STRUCTURE_SIZE __constant_cpu_to_le16(64) |
74112860 | 100 | |
ddfbefbd SF |
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 | ||
093b2bda PS |
120 | struct smb2_pdu { |
121 | struct smb2_hdr hdr; | |
122 | __le16 StructureSize2; /* size of wct area (varies, request specific) */ | |
123 | } __packed; | |
124 | ||
0cbaa53c SF |
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' */ | |
130 | __u8 Signature[16]; | |
131 | __u8 Nonce[11]; | |
132 | __u8 Reserved[5]; | |
133 | __le32 OriginalMessageSize; | |
134 | __u16 Reserved1; | |
135 | __le16 EncryptionAlgorithm; | |
136 | __u64 SessionId; | |
137 | } __packed; | |
138 | ||
139 | /* Encryption Algorithms */ | |
140 | #define SMB2_ENCRYPTION_AES128_CCM __constant_cpu_to_le16(0x0001) | |
141 | ||
093b2bda PS |
142 | /* |
143 | * SMB2 flag definitions | |
144 | */ | |
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) | |
150 | ||
151 | /* | |
152 | * Definitions for SMB2 Protocol Data Units (network frames) | |
153 | * | |
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. | |
157 | * | |
158 | */ | |
74112860 | 159 | |
b2ede58e | 160 | #define SMB2_ERROR_STRUCTURE_SIZE2 __constant_cpu_to_le16(9) |
74112860 | 161 | |
093b2bda PS |
162 | struct smb2_err_rsp { |
163 | struct smb2_hdr hdr; | |
164 | __le16 StructureSize; | |
165 | __le16 Reserved; /* MBZ */ | |
166 | __le32 ByteCount; /* even if zero, at least one byte follows */ | |
167 | __u8 ErrorData[1]; /* variable length */ | |
168 | } __packed; | |
169 | ||
b42bf888 PS |
170 | struct smb2_symlink_err_rsp { |
171 | __le32 SymLinkLength; | |
172 | __le32 SymLinkErrorTag; | |
173 | __le32 ReparseTag; | |
174 | __le16 ReparseDataLength; | |
175 | __le16 UnparsedPathLength; | |
176 | __le16 SubstituteNameOffset; | |
177 | __le16 SubstituteNameLength; | |
178 | __le16 PrintNameOffset; | |
179 | __le16 PrintNameLength; | |
180 | __le32 Flags; | |
181 | __u8 PathBuffer[0]; | |
182 | } __packed; | |
183 | ||
b8c32dbb PS |
184 | #define SMB2_CLIENT_GUID_SIZE 16 |
185 | ||
ec2e4523 PS |
186 | struct smb2_negotiate_req { |
187 | struct smb2_hdr hdr; | |
188 | __le16 StructureSize; /* Must be 36 */ | |
189 | __le16 DialectCount; | |
190 | __le16 SecurityMode; | |
191 | __le16 Reserved; /* MBZ */ | |
192 | __le32 Capabilities; | |
b8c32dbb | 193 | __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE]; |
ec2e4523 | 194 | __le64 ClientStartTime; /* MBZ */ |
e4aa25e7 | 195 | __le16 Dialects[1]; /* One dialect (vers=) at a time for now */ |
ec2e4523 PS |
196 | } __packed; |
197 | ||
e4aa25e7 SF |
198 | /* Dialects */ |
199 | #define SMB20_PROT_ID 0x0202 | |
200 | #define SMB21_PROT_ID 0x0210 | |
201 | #define SMB30_PROT_ID 0x0300 | |
20b6d8b4 | 202 | #define SMB302_PROT_ID 0x0302 |
e4aa25e7 SF |
203 | #define BAD_PROT_ID 0xFFFF |
204 | ||
ec2e4523 PS |
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 */ | |
e4aa25e7 SF |
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 */ | |
29e20f9c PS |
216 | /* Internal types */ |
217 | #define SMB2_NT_FIND 0x00100000 | |
218 | #define SMB2_LARGE_FILES 0x00200000 | |
ec2e4523 PS |
219 | |
220 | struct smb2_negotiate_rsp { | |
221 | struct smb2_hdr hdr; | |
222 | __le16 StructureSize; /* Must be 65 */ | |
223 | __le16 SecurityMode; | |
224 | __le16 DialectRevision; | |
225 | __le16 Reserved; /* MBZ */ | |
226 | __u8 ServerGUID[16]; | |
227 | __le32 Capabilities; | |
228 | __le32 MaxTransactSize; | |
229 | __le32 MaxReadSize; | |
230 | __le32 MaxWriteSize; | |
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 */ | |
237 | } __packed; | |
238 | ||
5478f9ba PS |
239 | struct smb2_sess_setup_req { |
240 | struct smb2_hdr hdr; | |
241 | __le16 StructureSize; /* Must be 25 */ | |
242 | __u8 VcNumber; | |
243 | __u8 SecurityMode; | |
244 | __le32 Capabilities; | |
245 | __le32 Channel; | |
246 | __le16 SecurityBufferOffset; | |
247 | __le16 SecurityBufferLength; | |
248 | __le64 PreviousSessionId; | |
249 | __u8 Buffer[1]; /* variable length GSS security buffer */ | |
250 | } __packed; | |
251 | ||
252 | /* Currently defined SessionFlags */ | |
253 | #define SMB2_SESSION_FLAG_IS_GUEST 0x0001 | |
254 | #define SMB2_SESSION_FLAG_IS_NULL 0x0002 | |
0cbaa53c | 255 | #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 |
5478f9ba PS |
256 | struct smb2_sess_setup_rsp { |
257 | struct smb2_hdr hdr; | |
258 | __le16 StructureSize; /* Must be 9 */ | |
259 | __le16 SessionFlags; | |
260 | __le16 SecurityBufferOffset; | |
261 | __le16 SecurityBufferLength; | |
262 | __u8 Buffer[1]; /* variable length GSS security buffer */ | |
263 | } __packed; | |
264 | ||
265 | struct smb2_logoff_req { | |
266 | struct smb2_hdr hdr; | |
267 | __le16 StructureSize; /* Must be 4 */ | |
268 | __le16 Reserved; | |
269 | } __packed; | |
270 | ||
271 | struct smb2_logoff_rsp { | |
272 | struct smb2_hdr hdr; | |
273 | __le16 StructureSize; /* Must be 4 */ | |
274 | __le16 Reserved; | |
275 | } __packed; | |
276 | ||
faaf946a PS |
277 | struct smb2_tree_connect_req { |
278 | struct smb2_hdr hdr; | |
279 | __le16 StructureSize; /* Must be 9 */ | |
280 | __le16 Reserved; | |
281 | __le16 PathOffset; | |
282 | __le16 PathLength; | |
283 | __u8 Buffer[1]; /* variable length */ | |
284 | } __packed; | |
285 | ||
286 | struct smb2_tree_connect_rsp { | |
287 | struct smb2_hdr hdr; | |
288 | __le16 StructureSize; /* Must be 16 */ | |
289 | __u8 ShareType; /* see below */ | |
290 | __u8 Reserved; | |
291 | __le32 ShareFlags; /* see below */ | |
292 | __le32 Capabilities; /* see below */ | |
293 | __le32 MaximalAccess; | |
294 | } __packed; | |
295 | ||
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 | |
300 | ||
301 | /* | |
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 | |
304 | * or in combination. | |
305 | */ | |
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 | |
c8664730 SF |
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 | |
faaf946a PS |
321 | |
322 | /* Possible share capabilities */ | |
2b5dc286 SF |
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 */ | |
faaf946a PS |
328 | |
329 | struct smb2_tree_disconnect_req { | |
330 | struct smb2_hdr hdr; | |
331 | __le16 StructureSize; /* Must be 4 */ | |
332 | __le16 Reserved; | |
333 | } __packed; | |
334 | ||
335 | struct smb2_tree_disconnect_rsp { | |
336 | struct smb2_hdr hdr; | |
337 | __le16 StructureSize; /* Must be 4 */ | |
338 | __le16 Reserved; | |
339 | } __packed; | |
340 | ||
2503a0db PS |
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 | |
355 | ||
356 | /* Oplock levels */ | |
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 | |
b8c32dbb PS |
362 | /* Non-spec internal type */ |
363 | #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 | |
2503a0db PS |
364 | |
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) | |
385 | ||
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) | |
391 | ||
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) | |
399 | ||
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) | |
420 | ||
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) | |
426 | ||
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) | |
432 | ||
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" | |
12197a7f | 438 | #define SMB2_CREATE_ALLOCATION_SIZE "AISi" |
2503a0db PS |
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" | |
12197a7f SF |
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 | |
2503a0db PS |
447 | |
448 | struct smb2_create_req { | |
449 | struct smb2_hdr hdr; | |
450 | __le16 StructureSize; /* Must be 57 */ | |
451 | __u8 SecurityFlags; | |
452 | __u8 RequestedOplockLevel; | |
453 | __le32 ImpersonationLevel; | |
454 | __le64 SmbCreateFlags; | |
455 | __le64 Reserved; | |
456 | __le32 DesiredAccess; | |
457 | __le32 FileAttributes; | |
458 | __le32 ShareAccess; | |
459 | __le32 CreateDisposition; | |
460 | __le32 CreateOptions; | |
461 | __le16 NameOffset; | |
462 | __le16 NameLength; | |
463 | __le32 CreateContextsOffset; | |
464 | __le32 CreateContextsLength; | |
59aa3718 | 465 | __u8 Buffer[0]; |
2503a0db PS |
466 | } __packed; |
467 | ||
468 | struct smb2_create_rsp { | |
469 | struct smb2_hdr hdr; | |
470 | __le16 StructureSize; /* Must be 89 */ | |
471 | __u8 OplockLevel; | |
472 | __u8 Reserved; | |
473 | __le32 CreateAction; | |
474 | __le64 CreationTime; | |
475 | __le64 LastAccessTime; | |
476 | __le64 LastWriteTime; | |
477 | __le64 ChangeTime; | |
478 | __le64 AllocationSize; | |
479 | __le64 EndofFile; | |
480 | __le32 FileAttributes; | |
481 | __le32 Reserved2; | |
482 | __u64 PersistentFileId; /* opaque endianness */ | |
483 | __u64 VolatileFileId; /* opaque endianness */ | |
484 | __le32 CreateContextsOffset; | |
485 | __le32 CreateContextsLength; | |
486 | __u8 Buffer[1]; | |
487 | } __packed; | |
488 | ||
b8c32dbb PS |
489 | struct create_context { |
490 | __le32 Next; | |
491 | __le16 NameOffset; | |
492 | __le16 NameLength; | |
493 | __le16 Reserved; | |
494 | __le16 DataOffset; | |
495 | __le32 DataLength; | |
496 | __u8 Buffer[0]; | |
497 | } __packed; | |
498 | ||
53ef1016 PS |
499 | #define SMB2_LEASE_READ_CACHING_HE 0x01 |
500 | #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 | |
501 | #define SMB2_LEASE_WRITE_CACHING_HE 0x04 | |
502 | ||
b8c32dbb PS |
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) | |
507 | ||
508 | #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS __constant_cpu_to_le32(0x02) | |
509 | ||
510 | #define SMB2_LEASE_KEY_SIZE 16 | |
511 | ||
512 | struct lease_context { | |
513 | __le64 LeaseKeyLow; | |
514 | __le64 LeaseKeyHigh; | |
515 | __le32 LeaseState; | |
516 | __le32 LeaseFlags; | |
517 | __le64 LeaseDuration; | |
518 | } __packed; | |
519 | ||
f047390a PS |
520 | struct lease_context_v2 { |
521 | __le64 LeaseKeyLow; | |
522 | __le64 LeaseKeyHigh; | |
523 | __le32 LeaseState; | |
524 | __le32 LeaseFlags; | |
525 | __le64 LeaseDuration; | |
526 | __le64 ParentLeaseKeyLow; | |
527 | __le64 ParentLeaseKeyHigh; | |
528 | __le16 Epoch; | |
529 | __le16 Reserved; | |
530 | } __packed; | |
531 | ||
b8c32dbb PS |
532 | struct create_lease { |
533 | struct create_context ccontext; | |
534 | __u8 Name[8]; | |
535 | struct lease_context lcontext; | |
536 | } __packed; | |
537 | ||
f047390a PS |
538 | struct create_lease_v2 { |
539 | struct create_context ccontext; | |
540 | __u8 Name[8]; | |
541 | struct lease_context_v2 lcontext; | |
542 | __u8 Pad[4]; | |
543 | } __packed; | |
544 | ||
63eb3def PS |
545 | struct create_durable { |
546 | struct create_context ccontext; | |
547 | __u8 Name[8]; | |
9cbc0b73 PS |
548 | union { |
549 | __u8 Reserved[16]; | |
550 | struct { | |
551 | __u64 PersistentFileId; | |
552 | __u64 VolatileFileId; | |
553 | } Fid; | |
554 | } Data; | |
63eb3def PS |
555 | } __packed; |
556 | ||
41c1358e SF |
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 */ | |
562 | } __packed; | |
563 | ||
be7457d3 SF |
564 | /* this goes in the ioctl buffer when doing a copychunk request */ |
565 | struct copychunk_ioctl { | |
41c1358e | 566 | char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; |
be7457d3 SF |
567 | __le32 ChunkCount; /* we are only sending 1 */ |
568 | __le32 Reserved; | |
569 | /* array will only be one chunk long for us */ | |
570 | __le64 SourceOffset; | |
571 | __le64 TargetOffset; | |
c8664730 | 572 | __le32 Length; /* how many bytes to copy */ |
be7457d3 SF |
573 | __u32 Reserved2; |
574 | } __packed; | |
575 | ||
41c1358e SF |
576 | struct copychunk_ioctl_rsp { |
577 | __le32 ChunksWritten; | |
578 | __le32 ChunkBytesWritten; | |
579 | __le32 TotalBytesWritten; | |
580 | } __packed; | |
581 | ||
ff1c038a | 582 | struct validate_negotiate_info_req { |
4a72dafa SF |
583 | __le32 Capabilities; |
584 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; | |
585 | __le16 SecurityMode; | |
586 | __le16 DialectCount; | |
ff1c038a SF |
587 | __le16 Dialects[1]; /* dialect (someday maybe list) client asked for */ |
588 | } __packed; | |
589 | ||
590 | struct validate_negotiate_info_rsp { | |
591 | __le32 Capabilities; | |
592 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; | |
593 | __le16 SecurityMode; | |
594 | __le16 Dialect; /* Dialect in use for the connection */ | |
4a72dafa SF |
595 | } __packed; |
596 | ||
597 | #define RSS_CAPABLE 0x00000001 | |
598 | #define RDMA_CAPABLE 0x00000002 | |
599 | ||
600 | struct network_interface_info_ioctl_rsp { | |
601 | __le32 Next; /* next interface. zero if this is last one */ | |
602 | __le32 IfIndex; | |
603 | __le32 Capability; /* RSS or RDMA Capable */ | |
604 | __le32 Reserved; | |
605 | __le64 LinkSpeed; | |
606 | char SockAddr_Storage[128]; | |
607 | } __packed; | |
608 | ||
609 | #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ | |
610 | ||
64a5cfa6 | 611 | struct compress_ioctl { |
c7f508a9 | 612 | __le16 CompressionState; /* See cifspdu.h for possible flag values */ |
64a5cfa6 SF |
613 | } __packed; |
614 | ||
be7457d3 SF |
615 | struct smb2_ioctl_req { |
616 | struct smb2_hdr hdr; | |
617 | __le16 StructureSize; /* Must be 57 */ | |
618 | __u16 Reserved; | |
619 | __le32 CtlCode; | |
620 | __u64 PersistentFileId; /* opaque endianness */ | |
621 | __u64 VolatileFileId; /* opaque endianness */ | |
622 | __le32 InputOffset; | |
623 | __le32 InputCount; | |
624 | __le32 MaxInputResponse; | |
625 | __le32 OutputOffset; | |
626 | __le32 OutputCount; | |
627 | __le32 MaxOutputResponse; | |
628 | __le32 Flags; | |
629 | __u32 Reserved2; | |
64a5cfa6 | 630 | __u8 Buffer[0]; |
be7457d3 SF |
631 | } __packed; |
632 | ||
633 | struct smb2_ioctl_rsp { | |
634 | struct smb2_hdr hdr; | |
635 | __le16 StructureSize; /* Must be 57 */ | |
636 | __u16 Reserved; | |
637 | __le32 CtlCode; | |
638 | __u64 PersistentFileId; /* opaque endianness */ | |
639 | __u64 VolatileFileId; /* opaque endianness */ | |
640 | __le32 InputOffset; | |
641 | __le32 InputCount; | |
642 | __le32 OutputOffset; | |
643 | __le32 OutputCount; | |
644 | __le32 Flags; | |
645 | __u32 Reserved2; | |
646 | /* char * buffer[] */ | |
647 | } __packed; | |
648 | ||
2503a0db PS |
649 | /* Currently defined values for close flags */ |
650 | #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) | |
651 | struct smb2_close_req { | |
652 | struct smb2_hdr hdr; | |
653 | __le16 StructureSize; /* Must be 24 */ | |
654 | __le16 Flags; | |
655 | __le32 Reserved; | |
656 | __u64 PersistentFileId; /* opaque endianness */ | |
657 | __u64 VolatileFileId; /* opaque endianness */ | |
658 | } __packed; | |
659 | ||
660 | struct smb2_close_rsp { | |
661 | struct smb2_hdr hdr; | |
662 | __le16 StructureSize; /* 60 */ | |
663 | __le16 Flags; | |
664 | __le32 Reserved; | |
665 | __le64 CreationTime; | |
666 | __le64 LastAccessTime; | |
667 | __le64 LastWriteTime; | |
668 | __le64 ChangeTime; | |
669 | __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ | |
670 | __le64 EndOfFile; | |
671 | __le32 Attributes; | |
672 | } __packed; | |
673 | ||
7a5cfb19 PS |
674 | struct smb2_flush_req { |
675 | struct smb2_hdr hdr; | |
676 | __le16 StructureSize; /* Must be 24 */ | |
677 | __le16 Reserved1; | |
678 | __le32 Reserved2; | |
679 | __u64 PersistentFileId; /* opaque endianness */ | |
680 | __u64 VolatileFileId; /* opaque endianness */ | |
681 | } __packed; | |
682 | ||
683 | struct smb2_flush_rsp { | |
684 | struct smb2_hdr hdr; | |
685 | __le16 StructureSize; | |
686 | __le16 Reserved; | |
687 | } __packed; | |
688 | ||
2b5dc286 SF |
689 | /* For read request Flags field below, following flag is defined for SMB3.02 */ |
690 | #define SMB2_READFLAG_READ_UNBUFFERED 0x01 | |
691 | ||
692 | /* Channel field for read and write: exactly one of following flags can be set*/ | |
693 | #define SMB2_CHANNEL_NONE 0x00000000 | |
694 | #define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */ | |
695 | #define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */ | |
696 | ||
09a4707e PS |
697 | struct smb2_read_req { |
698 | struct smb2_hdr hdr; | |
699 | __le16 StructureSize; /* Must be 49 */ | |
700 | __u8 Padding; /* offset from start of SMB2 header to place read */ | |
2b5dc286 | 701 | __u8 Flags; /* MBZ unless SMB3.02 or later */ |
09a4707e PS |
702 | __le32 Length; |
703 | __le64 Offset; | |
704 | __u64 PersistentFileId; /* opaque endianness */ | |
705 | __u64 VolatileFileId; /* opaque endianness */ | |
706 | __le32 MinimumCount; | |
2b5dc286 | 707 | __le32 Channel; /* MBZ except for SMB3 or later */ |
09a4707e PS |
708 | __le32 RemainingBytes; |
709 | __le16 ReadChannelInfoOffset; /* Reserved MBZ */ | |
710 | __le16 ReadChannelInfoLength; /* Reserved MBZ */ | |
711 | __u8 Buffer[1]; | |
712 | } __packed; | |
713 | ||
714 | struct smb2_read_rsp { | |
715 | struct smb2_hdr hdr; | |
716 | __le16 StructureSize; /* Must be 17 */ | |
717 | __u8 DataOffset; | |
33319141 PS |
718 | __u8 Reserved; |
719 | __le32 DataLength; | |
720 | __le32 DataRemaining; | |
721 | __u32 Reserved2; | |
722 | __u8 Buffer[1]; | |
723 | } __packed; | |
724 | ||
2b5dc286 SF |
725 | /* For write request Flags field below the following flags are defined: */ |
726 | #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */ | |
727 | #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ | |
33319141 PS |
728 | |
729 | struct smb2_write_req { | |
730 | struct smb2_hdr hdr; | |
731 | __le16 StructureSize; /* Must be 49 */ | |
732 | __le16 DataOffset; /* offset from start of SMB2 header to write data */ | |
733 | __le32 Length; | |
734 | __le64 Offset; | |
735 | __u64 PersistentFileId; /* opaque endianness */ | |
736 | __u64 VolatileFileId; /* opaque endianness */ | |
737 | __le32 Channel; /* Reserved MBZ */ | |
738 | __le32 RemainingBytes; | |
739 | __le16 WriteChannelInfoOffset; /* Reserved MBZ */ | |
740 | __le16 WriteChannelInfoLength; /* Reserved MBZ */ | |
741 | __le32 Flags; | |
742 | __u8 Buffer[1]; | |
743 | } __packed; | |
744 | ||
745 | struct smb2_write_rsp { | |
746 | struct smb2_hdr hdr; | |
747 | __le16 StructureSize; /* Must be 17 */ | |
748 | __u8 DataOffset; | |
09a4707e PS |
749 | __u8 Reserved; |
750 | __le32 DataLength; | |
751 | __le32 DataRemaining; | |
752 | __u32 Reserved2; | |
753 | __u8 Buffer[1]; | |
754 | } __packed; | |
755 | ||
027e8eec PS |
756 | #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001 |
757 | #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002 | |
758 | #define SMB2_LOCKFLAG_UNLOCK 0x0004 | |
759 | #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010 | |
760 | ||
f7ba7fe6 PS |
761 | struct smb2_lock_element { |
762 | __le64 Offset; | |
763 | __le64 Length; | |
764 | __le32 Flags; | |
765 | __le32 Reserved; | |
766 | } __packed; | |
767 | ||
768 | struct smb2_lock_req { | |
769 | struct smb2_hdr hdr; | |
770 | __le16 StructureSize; /* Must be 48 */ | |
771 | __le16 LockCount; | |
772 | __le32 Reserved; | |
773 | __u64 PersistentFileId; /* opaque endianness */ | |
774 | __u64 VolatileFileId; /* opaque endianness */ | |
775 | /* Followed by at least one */ | |
776 | struct smb2_lock_element locks[1]; | |
777 | } __packed; | |
778 | ||
779 | struct smb2_lock_rsp { | |
780 | struct smb2_hdr hdr; | |
781 | __le16 StructureSize; /* Must be 4 */ | |
782 | __le16 Reserved; | |
783 | } __packed; | |
784 | ||
9094fad1 PS |
785 | struct smb2_echo_req { |
786 | struct smb2_hdr hdr; | |
787 | __le16 StructureSize; /* Must be 4 */ | |
788 | __u16 Reserved; | |
789 | } __packed; | |
790 | ||
791 | struct smb2_echo_rsp { | |
792 | struct smb2_hdr hdr; | |
793 | __le16 StructureSize; /* Must be 4 */ | |
794 | __u16 Reserved; | |
795 | } __packed; | |
796 | ||
d324f08d PS |
797 | /* search (query_directory) Flags field */ |
798 | #define SMB2_RESTART_SCANS 0x01 | |
799 | #define SMB2_RETURN_SINGLE_ENTRY 0x02 | |
800 | #define SMB2_INDEX_SPECIFIED 0x04 | |
801 | #define SMB2_REOPEN 0x10 | |
802 | ||
803 | struct smb2_query_directory_req { | |
804 | struct smb2_hdr hdr; | |
805 | __le16 StructureSize; /* Must be 33 */ | |
806 | __u8 FileInformationClass; | |
807 | __u8 Flags; | |
808 | __le32 FileIndex; | |
809 | __u64 PersistentFileId; /* opaque endianness */ | |
810 | __u64 VolatileFileId; /* opaque endianness */ | |
811 | __le16 FileNameOffset; | |
812 | __le16 FileNameLength; | |
813 | __le32 OutputBufferLength; | |
814 | __u8 Buffer[1]; | |
815 | } __packed; | |
816 | ||
817 | struct smb2_query_directory_rsp { | |
818 | struct smb2_hdr hdr; | |
819 | __le16 StructureSize; /* Must be 9 */ | |
820 | __le16 OutputBufferOffset; | |
821 | __le32 OutputBufferLength; | |
822 | __u8 Buffer[1]; | |
823 | } __packed; | |
824 | ||
be4cb9e3 PS |
825 | /* Possible InfoType values */ |
826 | #define SMB2_O_INFO_FILE 0x01 | |
827 | #define SMB2_O_INFO_FILESYSTEM 0x02 | |
828 | #define SMB2_O_INFO_SECURITY 0x03 | |
829 | #define SMB2_O_INFO_QUOTA 0x04 | |
830 | ||
831 | struct smb2_query_info_req { | |
832 | struct smb2_hdr hdr; | |
833 | __le16 StructureSize; /* Must be 41 */ | |
834 | __u8 InfoType; | |
835 | __u8 FileInfoClass; | |
836 | __le32 OutputBufferLength; | |
837 | __le16 InputBufferOffset; | |
838 | __u16 Reserved; | |
839 | __le32 InputBufferLength; | |
840 | __le32 AdditionalInformation; | |
841 | __le32 Flags; | |
842 | __u64 PersistentFileId; /* opaque endianness */ | |
843 | __u64 VolatileFileId; /* opaque endianness */ | |
844 | __u8 Buffer[1]; | |
845 | } __packed; | |
846 | ||
847 | struct smb2_query_info_rsp { | |
848 | struct smb2_hdr hdr; | |
849 | __le16 StructureSize; /* Must be 9 */ | |
850 | __le16 OutputBufferOffset; | |
851 | __le32 OutputBufferLength; | |
852 | __u8 Buffer[1]; | |
853 | } __packed; | |
854 | ||
35143eb5 PS |
855 | struct smb2_set_info_req { |
856 | struct smb2_hdr hdr; | |
857 | __le16 StructureSize; /* Must be 33 */ | |
858 | __u8 InfoType; | |
859 | __u8 FileInfoClass; | |
860 | __le32 BufferLength; | |
861 | __le16 BufferOffset; | |
862 | __u16 Reserved; | |
863 | __le32 AdditionalInformation; | |
864 | __u64 PersistentFileId; /* opaque endianness */ | |
865 | __u64 VolatileFileId; /* opaque endianness */ | |
866 | __u8 Buffer[1]; | |
867 | } __packed; | |
868 | ||
869 | struct smb2_set_info_rsp { | |
870 | struct smb2_hdr hdr; | |
871 | __le16 StructureSize; /* Must be 2 */ | |
872 | } __packed; | |
873 | ||
983c88a4 PS |
874 | struct smb2_oplock_break { |
875 | struct smb2_hdr hdr; | |
876 | __le16 StructureSize; /* Must be 24 */ | |
877 | __u8 OplockLevel; | |
878 | __u8 Reserved; | |
879 | __le32 Reserved2; | |
880 | __u64 PersistentFid; | |
881 | __u64 VolatileFid; | |
882 | } __packed; | |
883 | ||
0822f514 PS |
884 | #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) |
885 | ||
886 | struct smb2_lease_break { | |
887 | struct smb2_hdr hdr; | |
888 | __le16 StructureSize; /* Must be 44 */ | |
889 | __le16 Reserved; | |
890 | __le32 Flags; | |
891 | __u8 LeaseKey[16]; | |
892 | __le32 CurrentLeaseState; | |
893 | __le32 NewLeaseState; | |
894 | __le32 BreakReason; | |
895 | __le32 AccessMaskHint; | |
896 | __le32 ShareMaskHint; | |
897 | } __packed; | |
898 | ||
899 | struct smb2_lease_ack { | |
900 | struct smb2_hdr hdr; | |
901 | __le16 StructureSize; /* Must be 36 */ | |
902 | __le16 Reserved; | |
903 | __le32 Flags; | |
904 | __u8 LeaseKey[16]; | |
905 | __le32 LeaseState; | |
906 | __le64 LeaseDuration; | |
907 | } __packed; | |
908 | ||
be4cb9e3 PS |
909 | /* |
910 | * PDU infolevel structure definitions | |
911 | * BB consider moving to a different header | |
912 | */ | |
913 | ||
6fc05c25 PS |
914 | /* File System Information Classes */ |
915 | #define FS_VOLUME_INFORMATION 1 /* Query */ | |
af6a12ea | 916 | #define FS_LABEL_INFORMATION 2 /* Local only */ |
6fc05c25 PS |
917 | #define FS_SIZE_INFORMATION 3 /* Query */ |
918 | #define FS_DEVICE_INFORMATION 4 /* Query */ | |
919 | #define FS_ATTRIBUTE_INFORMATION 5 /* Query */ | |
920 | #define FS_CONTROL_INFORMATION 6 /* Query, Set */ | |
921 | #define FS_FULL_SIZE_INFORMATION 7 /* Query */ | |
922 | #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ | |
af6a12ea SF |
923 | #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */ |
924 | #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */ | |
925 | #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ | |
6fc05c25 PS |
926 | |
927 | struct smb2_fs_full_size_info { | |
928 | __le64 TotalAllocationUnits; | |
929 | __le64 CallerAvailableAllocationUnits; | |
930 | __le64 ActualAvailableAllocationUnits; | |
931 | __le32 SectorsPerAllocationUnit; | |
932 | __le32 BytesPerSector; | |
933 | } __packed; | |
934 | ||
af6a12ea SF |
935 | #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 |
936 | #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 | |
937 | #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 | |
938 | #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 | |
939 | ||
940 | /* sector size info struct */ | |
941 | struct smb3_fs_ss_info { | |
942 | __le32 LogicalBytesPerSector; | |
943 | __le32 PhysicalBytesPerSectorForAtomicity; | |
944 | __le32 PhysicalBytesPerSectorForPerf; | |
945 | __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity; | |
946 | __le32 Flags; | |
947 | __le32 ByteOffsetForSectorAlignment; | |
948 | __le32 ByteOffsetForPartitionAlignment; | |
949 | } __packed; | |
950 | ||
be4cb9e3 PS |
951 | /* partial list of QUERY INFO levels */ |
952 | #define FILE_DIRECTORY_INFORMATION 1 | |
953 | #define FILE_FULL_DIRECTORY_INFORMATION 2 | |
954 | #define FILE_BOTH_DIRECTORY_INFORMATION 3 | |
955 | #define FILE_BASIC_INFORMATION 4 | |
956 | #define FILE_STANDARD_INFORMATION 5 | |
957 | #define FILE_INTERNAL_INFORMATION 6 | |
958 | #define FILE_EA_INFORMATION 7 | |
959 | #define FILE_ACCESS_INFORMATION 8 | |
960 | #define FILE_NAME_INFORMATION 9 | |
961 | #define FILE_RENAME_INFORMATION 10 | |
962 | #define FILE_LINK_INFORMATION 11 | |
963 | #define FILE_NAMES_INFORMATION 12 | |
964 | #define FILE_DISPOSITION_INFORMATION 13 | |
965 | #define FILE_POSITION_INFORMATION 14 | |
966 | #define FILE_FULL_EA_INFORMATION 15 | |
967 | #define FILE_MODE_INFORMATION 16 | |
968 | #define FILE_ALIGNMENT_INFORMATION 17 | |
969 | #define FILE_ALL_INFORMATION 18 | |
970 | #define FILE_ALLOCATION_INFORMATION 19 | |
971 | #define FILE_END_OF_FILE_INFORMATION 20 | |
972 | #define FILE_ALTERNATE_NAME_INFORMATION 21 | |
973 | #define FILE_STREAM_INFORMATION 22 | |
974 | #define FILE_PIPE_INFORMATION 23 | |
975 | #define FILE_PIPE_LOCAL_INFORMATION 24 | |
976 | #define FILE_PIPE_REMOTE_INFORMATION 25 | |
977 | #define FILE_MAILSLOT_QUERY_INFORMATION 26 | |
978 | #define FILE_MAILSLOT_SET_INFORMATION 27 | |
979 | #define FILE_COMPRESSION_INFORMATION 28 | |
980 | #define FILE_OBJECT_ID_INFORMATION 29 | |
981 | /* Number 30 not defined in documents */ | |
982 | #define FILE_MOVE_CLUSTER_INFORMATION 31 | |
983 | #define FILE_QUOTA_INFORMATION 32 | |
984 | #define FILE_REPARSE_POINT_INFORMATION 33 | |
985 | #define FILE_NETWORK_OPEN_INFORMATION 34 | |
986 | #define FILE_ATTRIBUTE_TAG_INFORMATION 35 | |
987 | #define FILE_TRACKING_INFORMATION 36 | |
988 | #define FILEID_BOTH_DIRECTORY_INFORMATION 37 | |
989 | #define FILEID_FULL_DIRECTORY_INFORMATION 38 | |
990 | #define FILE_VALID_DATA_LENGTH_INFORMATION 39 | |
991 | #define FILE_SHORT_NAME_INFORMATION 40 | |
992 | #define FILE_SFIO_RESERVE_INFORMATION 44 | |
993 | #define FILE_SFIO_VOLUME_INFORMATION 45 | |
994 | #define FILE_HARD_LINK_INFORMATION 46 | |
995 | #define FILE_NORMALIZED_NAME_INFORMATION 48 | |
996 | #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 | |
997 | #define FILE_STANDARD_LINK_INFORMATION 54 | |
998 | ||
f0df737e PS |
999 | struct smb2_file_internal_info { |
1000 | __le64 IndexNumber; | |
1001 | } __packed; /* level 6 Query */ | |
1002 | ||
35143eb5 PS |
1003 | struct smb2_file_rename_info { /* encoding of request for level 10 */ |
1004 | __u8 ReplaceIfExists; /* 1 = replace existing target with new */ | |
1005 | /* 0 = fail if target already exists */ | |
1006 | __u8 Reserved[7]; | |
1007 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ | |
1008 | __le32 FileNameLength; | |
1009 | char FileName[0]; /* New name to be assigned */ | |
1010 | } __packed; /* level 10 Set */ | |
1011 | ||
568798cc PS |
1012 | struct smb2_file_link_info { /* encoding of request for level 11 */ |
1013 | __u8 ReplaceIfExists; /* 1 = replace existing link with new */ | |
1014 | /* 0 = fail if link already exists */ | |
1015 | __u8 Reserved[7]; | |
1016 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ | |
1017 | __le32 FileNameLength; | |
1018 | char FileName[0]; /* Name to be assigned to new link */ | |
1019 | } __packed; /* level 11 Set */ | |
1020 | ||
be4cb9e3 PS |
1021 | /* |
1022 | * This level 18, although with struct with same name is different from cifs | |
1023 | * level 0x107. Level 0x107 has an extra u64 between AccessFlags and | |
1024 | * CurrentByteOffset. | |
1025 | */ | |
1026 | struct smb2_file_all_info { /* data block encoding of response to level 18 */ | |
1027 | __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ | |
1028 | __le64 LastAccessTime; | |
1029 | __le64 LastWriteTime; | |
1030 | __le64 ChangeTime; | |
1031 | __le32 Attributes; | |
1032 | __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ | |
1033 | __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ | |
1034 | __le64 EndOfFile; /* size ie offset to first free byte in file */ | |
1035 | __le32 NumberOfLinks; /* hard links */ | |
1036 | __u8 DeletePending; | |
1037 | __u8 Directory; | |
1038 | __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ | |
1039 | __le64 IndexNumber; | |
1040 | __le32 EASize; | |
1041 | __le32 AccessFlags; | |
1042 | __le64 CurrentByteOffset; | |
1043 | __le32 Mode; | |
1044 | __le32 AlignmentRequirement; | |
1045 | __le32 FileNameLength; | |
1046 | char FileName[1]; | |
1047 | } __packed; /* level 18 Query */ | |
1048 | ||
c839ff24 PS |
1049 | struct smb2_file_eof_info { /* encoding of request for level 10 */ |
1050 | __le64 EndOfFile; /* new end of file value */ | |
1051 | } __packed; /* level 20 Set */ | |
1052 | ||
ddfbefbd | 1053 | #endif /* _SMB2PDU_H */ |