]>
Commit | Line | Data |
---|---|---|
929be906 | 1 | /* SPDX-License-Identifier: LGPL-2.1 */ |
ddfbefbd | 2 | /* |
ddfbefbd | 3 | * |
be7457d3 | 4 | * Copyright (c) International Business Machines Corp., 2009, 2013 |
ddfbefbd SF |
5 | * Etersoft, 2012 |
6 | * Author(s): Steve French (sfrench@us.ibm.com) | |
7 | * Pavel Shilovsky (pshilovsky@samba.org) 2012 | |
8 | * | |
ddfbefbd SF |
9 | */ |
10 | ||
11 | #ifndef _SMB2PDU_H | |
12 | #define _SMB2PDU_H | |
13 | ||
14 | #include <net/sock.h> | |
90810c25 | 15 | #include "cifsacl.h" |
ddfbefbd | 16 | |
58d15ed1 | 17 | /* 52 transform hdr + 64 hdr + 88 create rsp */ |
c4627e66 | 18 | #define SMB2_TRANSFORM_HEADER_SIZE 52 |
58d15ed1 | 19 | #define MAX_SMB2_HDR_SIZE 204 |
2dc7e1c0 | 20 | |
f7950cb0 | 21 | /* The total header size for SMB2 read and write */ |
0d35e382 | 22 | #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_hdr)) |
8f233431 | 23 | |
3984bdc0 SF |
24 | /* See MS-SMB2 2.2.43 */ |
25 | struct smb2_rdma_transform { | |
26 | __le16 RdmaDescriptorOffset; | |
27 | __le16 RdmaDescriptorLength; | |
28 | __le32 Channel; /* for values see channel description in smb2 read above */ | |
29 | __le16 TransformCount; | |
30 | __le16 Reserved1; | |
31 | __le32 Reserved2; | |
32 | } __packed; | |
33 | ||
bb9cad1b SF |
34 | /* TransformType */ |
35 | #define SMB2_RDMA_TRANSFORM_TYPE_ENCRYPTION 0x0001 | |
36 | #define SMB2_RDMA_TRANSFORM_TYPE_SIGNING 0x0002 | |
37 | ||
38 | struct smb2_rdma_crypto_transform { | |
3984bdc0 SF |
39 | __le16 TransformType; |
40 | __le16 SignatureLength; | |
41 | __le16 NonceLength; | |
42 | __u16 Reserved; | |
43 | __u8 Signature[]; /* variable length */ | |
44 | /* u8 Nonce[] */ | |
45 | /* followed by padding */ | |
46 | } __packed; | |
47 | ||
093b2bda PS |
48 | /* |
49 | * Definitions for SMB2 Protocol Data Units (network frames) | |
50 | * | |
51 | * See MS-SMB2.PDF specification for protocol details. | |
52 | * The Naming convention is the lower case version of the SMB2 | |
53 | * command code name for the struct. Note that structures must be packed. | |
54 | * | |
55 | */ | |
74112860 | 56 | |
730928c8 RS |
57 | #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL |
58 | ||
df070afd RS |
59 | #define SYMLINK_ERROR_TAG 0x4c4d5953 |
60 | ||
b42bf888 PS |
61 | struct smb2_symlink_err_rsp { |
62 | __le32 SymLinkLength; | |
63 | __le32 SymLinkErrorTag; | |
64 | __le32 ReparseTag; | |
65 | __le16 ReparseDataLength; | |
66 | __le16 UnparsedPathLength; | |
67 | __le16 SubstituteNameOffset; | |
68 | __le16 SubstituteNameLength; | |
69 | __le16 PrintNameOffset; | |
70 | __le16 PrintNameLength; | |
71 | __le32 Flags; | |
cff2def5 | 72 | __u8 PathBuffer[]; |
b42bf888 PS |
73 | } __packed; |
74 | ||
5f60a564 SF |
75 | /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */ |
76 | struct smb2_error_context_rsp { | |
77 | __le32 ErrorDataLength; | |
78 | __le32 ErrorId; | |
79 | __u8 ErrorContextData; /* ErrorDataLength long array */ | |
80 | } __packed; | |
81 | ||
8895c66f SF |
82 | /* ErrorId values */ |
83 | #define SMB2_ERROR_ID_DEFAULT 0x00000000 | |
84 | #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */ | |
85 | ||
5f60a564 SF |
86 | /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */ |
87 | #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001) | |
88 | #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002) | |
89 | ||
90 | struct move_dst_ipaddr { | |
91 | __le32 Type; | |
92 | __u32 Reserved; | |
93 | __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */ | |
94 | } __packed; | |
95 | ||
96 | struct share_redirect_error_context_rsp { | |
97 | __le32 StructureSize; | |
98 | __le32 NotificationType; | |
99 | __le32 ResourceNameOffset; | |
100 | __le32 ResourceNameLength; | |
2438c0bd | 101 | __le16 Reserved; |
5f60a564 SF |
102 | __le16 TargetType; |
103 | __le32 IPAddrCount; | |
cff2def5 | 104 | struct move_dst_ipaddr IpAddrMoveList[]; |
5f60a564 SF |
105 | /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */ |
106 | } __packed; | |
107 | ||
4d8dfafc RS |
108 | /* |
109 | * Maximum number of iovs we need for an open/create request. | |
110 | * [0] : struct smb2_create_req | |
111 | * [1] : path | |
112 | * [2] : lease context | |
113 | * [3] : durable context | |
114 | * [4] : posix context | |
115 | * [5] : time warp context | |
ff2a09e9 SF |
116 | * [6] : query id context |
117 | * [7] : compound padding | |
4d8dfafc | 118 | */ |
ff2a09e9 | 119 | #define SMB2_CREATE_IOV_SIZE 8 |
4d8dfafc | 120 | |
c4627e66 RS |
121 | /* |
122 | * Maximum size of a SMB2_CREATE response is 64 (smb2 header) + | |
ff2a09e9 | 123 | * 88 (fixed part of create response) + 520 (path) + 208 (contexts) + |
c4627e66 RS |
124 | * 2 bytes of padding. |
125 | */ | |
ff2a09e9 | 126 | #define MAX_SMB2_CREATE_RESPONSE_SIZE 880 |
c4627e66 | 127 | |
53ef1016 PS |
128 | #define SMB2_LEASE_READ_CACHING_HE 0x01 |
129 | #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 | |
130 | #define SMB2_LEASE_WRITE_CACHING_HE 0x04 | |
131 | ||
63eb3def PS |
132 | struct create_durable { |
133 | struct create_context ccontext; | |
134 | __u8 Name[8]; | |
9cbc0b73 PS |
135 | union { |
136 | __u8 Reserved[16]; | |
137 | struct { | |
138 | __u64 PersistentFileId; | |
139 | __u64 VolatileFileId; | |
140 | } Fid; | |
141 | } Data; | |
63eb3def PS |
142 | } __packed; |
143 | ||
b56eae4d SF |
144 | /* See MS-SMB2 2.2.13.2.11 */ |
145 | /* Flags */ | |
146 | #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 | |
147 | struct durable_context_v2 { | |
148 | __le32 Timeout; | |
149 | __le32 Flags; | |
150 | __u64 Reserved; | |
151 | __u8 CreateGuid[16]; | |
152 | } __packed; | |
153 | ||
154 | struct create_durable_v2 { | |
155 | struct create_context ccontext; | |
156 | __u8 Name[8]; | |
157 | struct durable_context_v2 dcontext; | |
158 | } __packed; | |
159 | ||
160 | /* See MS-SMB2 2.2.13.2.12 */ | |
161 | struct durable_reconnect_context_v2 { | |
162 | struct { | |
163 | __u64 PersistentFileId; | |
164 | __u64 VolatileFileId; | |
165 | } Fid; | |
166 | __u8 CreateGuid[16]; | |
167 | __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ | |
168 | } __packed; | |
169 | ||
e7348e35 | 170 | /* See MS-SMB2 2.2.14.2.9 */ |
89a5bfa3 SF |
171 | struct create_on_disk_id { |
172 | struct create_context ccontext; | |
173 | __u8 Name[8]; | |
e7348e35 SF |
174 | __le64 DiskFileId; |
175 | __le64 VolumeId; | |
ff2a09e9 | 176 | __u32 Reserved[4]; |
e7348e35 SF |
177 | } __packed; |
178 | ||
b56eae4d SF |
179 | /* See MS-SMB2 2.2.14.2.12 */ |
180 | struct durable_reconnect_context_v2_rsp { | |
181 | __le32 Timeout; | |
182 | __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ | |
183 | } __packed; | |
184 | ||
185 | struct create_durable_handle_reconnect_v2 { | |
186 | struct create_context ccontext; | |
187 | __u8 Name[8]; | |
188 | struct durable_reconnect_context_v2 dcontext; | |
d243af7a | 189 | __u8 Pad[4]; |
b56eae4d SF |
190 | } __packed; |
191 | ||
cdeaf9d0 SF |
192 | /* See MS-SMB2 2.2.13.2.5 */ |
193 | struct crt_twarp_ctxt { | |
194 | struct create_context ccontext; | |
195 | __u8 Name[8]; | |
196 | __le64 Timestamp; | |
197 | ||
198 | } __packed; | |
199 | ||
ff2a09e9 SF |
200 | /* See MS-SMB2 2.2.13.2.9 */ |
201 | struct crt_query_id_ctxt { | |
202 | struct create_context ccontext; | |
203 | __u8 Name[8]; | |
204 | } __packed; | |
205 | ||
fdef665b SF |
206 | struct crt_sd_ctxt { |
207 | struct create_context ccontext; | |
208 | __u8 Name[8]; | |
209 | struct smb3_sd sd; | |
fdef665b SF |
210 | } __packed; |
211 | ||
212 | ||
41c1358e SF |
213 | #define COPY_CHUNK_RES_KEY_SIZE 24 |
214 | struct resume_key_req { | |
215 | char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; | |
216 | __le32 ContextLength; /* MBZ */ | |
cff2def5 | 217 | char Context[]; /* ignored, Windows sets to 4 bytes of zero */ |
41c1358e SF |
218 | } __packed; |
219 | ||
be7457d3 SF |
220 | /* this goes in the ioctl buffer when doing a copychunk request */ |
221 | struct copychunk_ioctl { | |
41c1358e | 222 | char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; |
be7457d3 SF |
223 | __le32 ChunkCount; /* we are only sending 1 */ |
224 | __le32 Reserved; | |
225 | /* array will only be one chunk long for us */ | |
226 | __le64 SourceOffset; | |
227 | __le64 TargetOffset; | |
c8664730 | 228 | __le32 Length; /* how many bytes to copy */ |
be7457d3 SF |
229 | __u32 Reserved2; |
230 | } __packed; | |
231 | ||
41c1358e SF |
232 | struct copychunk_ioctl_rsp { |
233 | __le32 ChunksWritten; | |
234 | __le32 ChunkBytesWritten; | |
235 | __le32 TotalBytesWritten; | |
236 | } __packed; | |
237 | ||
7d03ae4d SF |
238 | /* See MS-FSCC 2.3.29 and 2.3.30 */ |
239 | struct get_retrieval_pointer_count_req { | |
240 | __le64 StartingVcn; /* virtual cluster number (signed) */ | |
241 | } __packed; | |
242 | ||
243 | struct get_retrieval_pointer_count_rsp { | |
244 | __le32 ExtentCount; | |
245 | } __packed; | |
246 | ||
247 | /* | |
248 | * See MS-FSCC 2.3.33 and 2.3.34 | |
249 | * request is the same as get_retrieval_point_count_req struct above | |
250 | */ | |
251 | struct smb3_extents { | |
252 | __le64 NextVcn; | |
253 | __le64 Lcn; /* logical cluster number */ | |
254 | } __packed; | |
255 | ||
256 | struct get_retrieval_pointers_refcount_rsp { | |
257 | __le32 ExtentCount; | |
258 | __u32 Reserved; | |
259 | __le64 StartingVcn; | |
260 | struct smb3_extents extents[]; | |
261 | } __packed; | |
262 | ||
9d49640a AA |
263 | /* See MS-DFSC 2.2.2 */ |
264 | struct fsctl_get_dfs_referral_req { | |
265 | __le16 MaxReferralLevel; | |
266 | __u8 RequestFileName[]; | |
267 | } __packed; | |
268 | ||
269 | /* DFS response is struct get_dfs_refer_rsp */ | |
270 | ||
b56eae4d SF |
271 | /* See MS-SMB2 2.2.31.3 */ |
272 | struct network_resiliency_req { | |
273 | __le32 Timeout; | |
274 | __le32 Reserved; | |
275 | } __packed; | |
276 | /* There is no buffer for the response ie no struct network_resiliency_rsp */ | |
277 | ||
bead042c AA |
278 | #define RSS_CAPABLE cpu_to_le32(0x00000001) |
279 | #define RDMA_CAPABLE cpu_to_le32(0x00000002) | |
280 | ||
281 | #define INTERNETWORK cpu_to_le16(0x0002) | |
282 | #define INTERNETWORKV6 cpu_to_le16(0x0017) | |
4a72dafa SF |
283 | |
284 | struct network_interface_info_ioctl_rsp { | |
285 | __le32 Next; /* next interface. zero if this is last one */ | |
286 | __le32 IfIndex; | |
287 | __le32 Capability; /* RSS or RDMA Capable */ | |
288 | __le32 Reserved; | |
289 | __le64 LinkSpeed; | |
bead042c AA |
290 | __le16 Family; |
291 | __u8 Buffer[126]; | |
292 | } __packed; | |
293 | ||
294 | struct iface_info_ipv4 { | |
295 | __be16 Port; | |
296 | __be32 IPv4Address; | |
297 | __be64 Reserved; | |
298 | } __packed; | |
299 | ||
300 | struct iface_info_ipv6 { | |
301 | __be16 Port; | |
302 | __be32 FlowInfo; | |
303 | __u8 IPv6Address[16]; | |
304 | __be32 ScopeId; | |
4a72dafa SF |
305 | } __packed; |
306 | ||
307 | #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ | |
308 | ||
64a5cfa6 | 309 | struct compress_ioctl { |
c7f508a9 | 310 | __le16 CompressionState; /* See cifspdu.h for possible flag values */ |
64a5cfa6 SF |
311 | } __packed; |
312 | ||
72c419d9 RS |
313 | /* |
314 | * Maximum number of iovs we need for an ioctl request. | |
315 | * [0] : struct smb2_ioctl_req | |
316 | * [1] : in_data | |
317 | */ | |
318 | #define SMB2_IOCTL_IOV_SIZE 2 | |
319 | ||
be4cb9e3 | 320 | /* |
be135000 | 321 | * PDU query infolevel structure definitions |
be4cb9e3 PS |
322 | * BB consider moving to a different header |
323 | */ | |
324 | ||
95907fea RS |
325 | struct smb2_file_full_ea_info { /* encoding of response for level 15 */ |
326 | __le32 next_entry_offset; | |
327 | __u8 flags; | |
328 | __u8 ea_name_length; | |
329 | __le16 ea_value_length; | |
cff2def5 | 330 | char ea_data[]; /* \0 terminated name plus value */ |
95907fea RS |
331 | } __packed; /* level 15 Set */ |
332 | ||
2e4564b3 SF |
333 | struct smb2_file_reparse_point_info { |
334 | __le64 IndexNumber; | |
335 | __le32 Tag; | |
336 | } __packed; | |
337 | ||
43f8a6a7 SF |
338 | struct smb2_file_network_open_info { |
339 | __le64 CreationTime; | |
340 | __le64 LastAccessTime; | |
341 | __le64 LastWriteTime; | |
342 | __le64 ChangeTime; | |
343 | __le64 AllocationSize; | |
344 | __le64 EndOfFile; | |
345 | __le32 Attributes; | |
346 | __le32 Reserved; | |
347 | } __packed; /* level 34 Query also similar returned in close rsp and open rsp */ | |
348 | ||
2438c0bd | 349 | /* See MS-FSCC 2.4.21 */ |
51d92d69 SF |
350 | struct smb2_file_id_information { |
351 | __le64 VolumeSerialNumber; | |
352 | __u64 PersistentFileId; /* opaque endianness */ | |
353 | __u64 VolatileFileId; /* opaque endianness */ | |
354 | } __packed; /* level 59 */ | |
355 | ||
2438c0bd SF |
356 | /* See MS-FSCC 2.4.18 */ |
357 | struct smb2_file_id_extd_directory_info { | |
358 | __le32 NextEntryOffset; | |
359 | __u32 FileIndex; | |
360 | __le64 CreationTime; | |
361 | __le64 LastAccessTime; | |
362 | __le64 LastWriteTime; | |
363 | __le64 ChangeTime; | |
364 | __le64 EndOfFile; | |
365 | __le64 AllocationSize; | |
366 | __le32 FileAttributes; | |
367 | __le32 FileNameLength; | |
368 | __le32 EaSize; /* EA size */ | |
369 | __le32 ReparsePointTag; /* valid if FILE_ATTR_REPARSE_POINT set in FileAttributes */ | |
370 | __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit */ | |
371 | char FileName[1]; | |
372 | } __packed; /* level 60 */ | |
373 | ||
730928c8 RS |
374 | extern char smb2_padding[7]; |
375 | ||
ab3459d8 | 376 | /* equivalent of the contents of SMB3.1.1 POSIX open context response */ |
2e8af978 | 377 | struct create_posix_rsp { |
69dda305 AA |
378 | u32 nlink; |
379 | u32 reparse_tag; | |
380 | u32 mode; | |
381 | struct cifs_sid owner; /* var-sized on the wire */ | |
382 | struct cifs_sid group; /* var-sized on the wire */ | |
2e8af978 | 383 | } __packed; |
349e13ad | 384 | |
be135000 SF |
385 | #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2 |
386 | ||
349e13ad | 387 | /* |
6a5f6592 | 388 | * SMB2-only POSIX info level for query dir |
349e13ad AA |
389 | * |
390 | * See posix_info_sid_size(), posix_info_extra_size() and | |
391 | * posix_info_parse() to help with the handling of this struct. | |
392 | */ | |
393 | struct smb2_posix_info { | |
394 | __le32 NextEntryOffset; | |
395 | __u32 Ignored; | |
396 | __le64 CreationTime; | |
397 | __le64 LastAccessTime; | |
398 | __le64 LastWriteTime; | |
399 | __le64 ChangeTime; | |
400 | __le64 EndOfFile; | |
401 | __le64 AllocationSize; | |
402 | __le32 DosAttributes; | |
403 | __le64 Inode; | |
404 | __le32 DeviceId; | |
405 | __le32 Zero; | |
406 | /* beginning of POSIX Create Context Response */ | |
407 | __le32 HardLinks; | |
408 | __le32 ReparseTag; | |
409 | __le32 Mode; | |
410 | /* | |
411 | * var sized owner SID | |
412 | * var sized group SID | |
413 | * le32 filenamelength | |
414 | * u8 filename[] | |
415 | */ | |
416 | } __packed; | |
417 | ||
418 | /* | |
419 | * Parsed version of the above struct. Allows direct access to the | |
420 | * variable length fields | |
421 | */ | |
422 | struct smb2_posix_info_parsed { | |
423 | const struct smb2_posix_info *base; | |
424 | size_t size; | |
425 | struct cifs_sid owner; | |
426 | struct cifs_sid group; | |
427 | int name_len; | |
428 | const u8 *name; | |
ab3459d8 | 429 | }; |
349e13ad | 430 | |
ddfbefbd | 431 | #endif /* _SMB2PDU_H */ |