2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /* static body buffer 38 (0x26) bytes */
27 /* uint16_t buffer_code; 0x24 (why?) */
28 uint16_t unknown1; /* 0x0001 */
29 uint8_t unknown2[32]; /* all zero */
30 uint16_t unknown3; /* 0x00000 */
33 /* static body buffer 64 (0x40) bytes */
34 /* uint16_t buffer_code; 0x41 = 0x40 + 1 */
36 uint32_t unknown2; /* 0x06 */
38 uint32_t unknown3; /* 0x0d */
39 uint16_t unknown4; /* 0x00 */
40 uint32_t unknown5; /* 0x01 */
41 uint32_t unknown6; /* 0x01 */
42 uint16_t unknown7; /* 0x01 */
45 /* uint16_t secblob_ofs */
46 /* uint16_t secblob_size */
47 uint32_t unknown9; /* 0x204d4c20 */
49 /* dynamic body buffer */
54 struct smb2_session_setup {
56 /* static body buffer 16 (0x10) bytes */
57 /* uint16_t buffer_code; 0x11 = 0x10 + 1 */
59 uint32_t unknown2; /* 0xF */
60 uint32_t unknown3; /* 0x00 */
61 /* uint16_t secblob_ofs */
62 /* uint16_t secblob_size */
68 /* static body buffer 8 (0x08) bytes */
69 /* uint16_t buffer_code; 0x09 = 0x08 +1 */
71 /* uint16_t secblob_ofs */
72 /* uint16_t secblob_size */
77 /* extracted from the SMB2 header */
82 struct smb2_tree_connect {
84 /* static body buffer 8 (0x08) bytes */
85 /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
86 uint16_t unknown1; /* 0x0000 */
87 /* uint16_t path_ofs */
88 /* uint16_t path_size */
91 const char *path; /* as non-terminated UTF-16 on the wire */
94 /* static body buffer 16 (0x10) bytes */
95 /* uint16_t buffer_code; 0x10 */
96 uint16_t unknown1; /* 0x02 */
97 uint32_t unknown2; /* 0x00 */
98 uint32_t unknown3; /* 0x00 */
101 /* extracted from the SMB2 header */
107 file handles in SMB2 are 16 bytes
114 #define SMB2_CREATE_FLAG_REQUEST_OPLOCK 0x0100
115 #define SMB2_CREATE_FLAG_REQUEST_EXCLUSIVE_OPLOCK 0x0800
116 #define SMB2_CREATE_FLAG_GRANT_OPLOCK 0x0001
117 #define SMB2_CREATE_FLAG_GRANT_EXCLUSIVE_OPLOCK 0x0080
121 /* static body buffer 56 (0x38) bytes */
122 /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
123 uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
125 uint32_t unknown3[4];
126 uint32_t access_mask;
129 uint32_t share_access;
130 uint32_t open_disposition;
131 uint32_t create_options;
133 /* uint16_t fname_ofs */
134 /* uint16_t fname_size */
135 /* uint32_t blob_ofs; */
136 /* uint32_t blob_size; */
145 /* static body buffer 88 (0x58) bytes */
146 /* uint16_t buffer_code; 0x59 = 0x58 + 1 */
147 uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
148 uint32_t create_action;
157 struct smb2_handle handle;
158 /* uint32_t blob_ofs; */
159 /* uint32_t blob_size; */
167 #define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
171 /* static body buffer 24 (0x18) bytes */
172 /* uint16_t buffer_code; 0x18 */
173 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
175 struct smb2_handle handle;
179 /* static body buffer 60 (0x3C) bytes */
180 /* uint16_t buffer_code; 0x3C */
193 /* fs information levels */
194 #define SMB2_GETINFO_FS_VOLUME_INFO 0x0102
195 #define SMB2_GETINFO_FS_SIZE_INFO 0x0302
196 #define SMB2_GETINFO_FS_DEVICE_INFO 0x0402
197 #define SMB2_GETINFO_FS_ATTRIBUTE_INFO 0x0502
198 #define SMB2_GETINFO_FS_QUOTA_INFO 0x0602
199 #define SMB2_GETINFO_FS_FULL_SIZE_INFO 0x0702
200 #define SMB2_GETINFO_FS_OBJECTID_INFO 0x0802
203 #define SMB2_GETINFO_SECURITY 0x0003
205 /* file information levels */
206 #define SMB2_GETINFO_FILE_BASIC_INFO 0x0401
207 #define SMB2_GETINFO_FILE_SIZE_INFO 0x0501
208 #define SMB2_GETINFO_FILE_ID 0x0601
209 #define SMB2_GETINFO_FILE_EA_SIZE 0x0701
210 #define SMB2_GETINFO_FILE_ACCESS_INFO 0x0801
211 #define SMB2_GETINFO_FILE_0E 0x0e01
212 #define SMB2_GETINFO_FILE_ALL_EAS 0x0f01
213 #define SMB2_GETINFO_FILE_10 0x1001
214 #define SMB2_GETINFO_FILE_11 0x1101
215 #define SMB2_GETINFO_FILE_ALL_INFO 0x1201
216 #define SMB2_GETINFO_FILE_SHORT_INFO 0x1501
217 #define SMB2_GETINFO_FILE_STREAM_INFO 0x1601
218 #define SMB2_GETINFO_FILE_EOF_INFO 0x1c01
219 #define SMB2_GETINFO_FILE_STANDARD_INFO 0x2201
220 #define SMB2_GETINFO_FILE_ATTRIB_INFO 0x2301
223 struct smb2_getinfo {
225 /* static body buffer 40 (0x28) bytes */
226 /* uint16_t buffer_code; 0x29 = 0x28 + 1 (why???) */
228 uint32_t max_response_size;
230 uint32_t flags; /* level specific */
233 struct smb2_handle handle;
237 /* static body buffer 8 (0x08) bytes */
238 /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
239 /* uint16_t blob_ofs; */
240 /* uint16_t blob_size; */
247 union smb2_fileinfo {
261 uint8_t delete_pending;
274 uint32_t access_mask;
282 struct smb_ea_list all_eas;
302 uint8_t delete_pending;
307 uint32_t access_mask;
314 const char *short_name;
317 struct stream_information stream_info;
341 struct security_descriptor *sd;
348 /* static body buffer 48 (0x30) bytes */
349 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
350 /* uint16_t data_ofs; */
351 /* uint32_t data_size; */
353 struct smb2_handle handle;
354 uint64_t unknown1; /* 0xFFFFFFFFFFFFFFFF */
355 uint64_t unknown2; /* 0xFFFFFFFFFFFFFFFF */
362 /* static body buffer 17 (0x11) bytes */
363 /* uint16_t buffer_code; 0x11 */
366 uint64_t unknown1; /* 0x0000000000000000 */
373 /* static body buffer 48 (0x30) bytes */
374 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
378 struct smb2_handle handle;
379 uint64_t unknown1; /* 0x0000000000000000 */
380 uint64_t unknown2; /* 0x0000000000000000 */
385 /* static body buffer 16 (0x10) bytes */
386 /* uint16_t buffer_code; 0x11 = 0x10 + 1 */
387 /* uint16_t data_ofs; */
388 /* uint32_t data_size; */
389 uint64_t unknown1; /* 0x0000000000000000 */