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.
23 #include "libcli/raw/interfaces.h"
27 /* static body buffer 38 (0x26) bytes */
28 /* uint16_t buffer_code; 0x24 (why?) */
29 uint16_t unknown1; /* 0x0001 */
30 uint8_t unknown2[32]; /* all zero */
31 uint16_t unknown3; /* 0x00000 */
34 /* static body buffer 64 (0x40) bytes */
35 /* uint16_t buffer_code; 0x41 = 0x40 + 1 */
37 uint32_t unknown2; /* 0x06 */
39 uint32_t unknown3; /* 0x0d */
40 uint16_t unknown4; /* 0x00 */
41 uint32_t unknown5; /* 0x01 */
42 uint32_t unknown6; /* 0x01 */
43 uint16_t unknown7; /* 0x01 */
46 /* uint16_t secblob_ofs */
47 /* uint16_t secblob_size */
48 uint32_t unknown9; /* 0x204d4c20 */
50 /* dynamic body buffer */
55 struct smb2_session_setup {
57 /* static body buffer 16 (0x10) bytes */
58 /* uint16_t buffer_code; 0x11 = 0x10 + 1 */
60 uint32_t unknown2; /* 0xF */
61 uint32_t unknown3; /* 0x00 */
62 /* uint16_t secblob_ofs */
63 /* uint16_t secblob_size */
69 /* static body buffer 8 (0x08) bytes */
70 /* uint16_t buffer_code; 0x09 = 0x08 +1 */
72 /* uint16_t secblob_ofs */
73 /* uint16_t secblob_size */
78 /* extracted from the SMB2 header */
83 struct smb2_tree_connect {
85 /* static body buffer 8 (0x08) bytes */
86 /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
87 uint16_t unknown1; /* 0x0000 */
88 /* uint16_t path_ofs */
89 /* uint16_t path_size */
92 const char *path; /* as non-terminated UTF-16 on the wire */
95 /* static body buffer 16 (0x10) bytes */
96 /* uint16_t buffer_code; 0x10 */
97 uint16_t unknown1; /* 0x02 */
98 uint32_t unknown2; /* 0x00 */
99 uint32_t unknown3; /* 0x00 */
100 uint32_t access_mask;
102 /* extracted from the SMB2 header */
107 #define SMB2_CREATE_FLAG_REQUEST_OPLOCK 0x0100
108 #define SMB2_CREATE_FLAG_REQUEST_EXCLUSIVE_OPLOCK 0x0800
109 #define SMB2_CREATE_FLAG_GRANT_OPLOCK 0x0001
110 #define SMB2_CREATE_FLAG_GRANT_EXCLUSIVE_OPLOCK 0x0080
114 /* static body buffer 56 (0x38) bytes */
115 /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
116 uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
117 uint32_t impersonation;
118 uint32_t unknown3[4];
119 uint32_t access_mask;
122 uint32_t share_access;
123 uint32_t open_disposition;
124 uint32_t create_options;
126 /* uint16_t fname_ofs */
127 /* uint16_t fname_size */
128 /* uint32_t blob_ofs; */
129 /* uint32_t blob_size; */
134 /* optional list of extended attributes */
135 struct smb_ea_list eas;
139 /* static body buffer 88 (0x58) bytes */
140 /* uint16_t buffer_code; 0x59 = 0x58 + 1 */
141 uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
142 uint32_t create_action;
151 struct smb2_handle handle;
152 /* uint32_t blob_ofs; */
153 /* uint32_t blob_size; */
161 #define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
165 /* static body buffer 24 (0x18) bytes */
166 /* uint16_t buffer_code; 0x18 */
167 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
169 struct smb2_handle handle;
173 /* static body buffer 60 (0x3C) bytes */
174 /* uint16_t buffer_code; 0x3C */
187 /* getinfo classes */
188 #define SMB2_GETINFO_FILE 0x01
189 #define SMB2_GETINFO_FS 0x02
190 #define SMB2_GETINFO_SECURITY 0x03
192 /* flags for RAW_FILEINFO_SMB2_ALL_EAS */
193 #define SMB2_CONTINUE_FLAG_RESTART 0x01
194 #define SMB2_CONTINUE_FLAG_SINGLE 0x02
196 /* NOTE! the getinfo fs and file levels exactly match up with the
197 'passthru' SMB levels, which are levels >= 1000. The SMB2 client
198 lib uses the names from the libcli/raw/ library */
200 struct smb2_getinfo {
202 /* static body buffer 40 (0x28) bytes */
203 /* uint16_t buffer_code; 0x29 = 0x28 + 1 (why???) */
205 uint32_t max_response_size;
208 uint32_t flags; /* level specific */
209 uint32_t flags2; /* used by all_eas level */
210 struct smb2_handle handle;
214 /* static body buffer 8 (0x08) bytes */
215 /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
216 /* uint16_t blob_ofs; */
217 /* uint16_t blob_size; */
224 struct smb2_setinfo {
228 struct smb2_handle handle;
235 /* static body buffer 48 (0x30) bytes */
236 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
237 /* uint16_t data_ofs; */
238 /* uint32_t data_size; */
240 struct smb2_handle handle;
241 uint64_t unknown1; /* 0xFFFFFFFFFFFFFFFF */
242 uint64_t unknown2; /* 0xFFFFFFFFFFFFFFFF */
249 /* static body buffer 17 (0x11) bytes */
250 /* uint16_t buffer_code; 0x11 */
253 uint64_t unknown1; /* 0x0000000000000000 */
260 /* static body buffer 48 (0x30) bytes */
261 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
265 struct smb2_handle handle;
266 uint64_t unknown1; /* 0x0000000000000000 */
267 uint64_t unknown2; /* 0x0000000000000000 */
272 /* static body buffer 16 (0x10) bytes */
273 /* uint16_t buffer_code; 0x11 = 0x10 + 1 */
274 /* uint16_t data_ofs; */
275 /* uint32_t data_size; */
276 uint64_t unknown1; /* 0x0000000000000000 */
284 SMB2 uses different level numbers for the same old SMB search levels
286 #define SMB2_FIND_DIRECTORY_INFO 0x01
287 #define SMB2_FIND_FULL_DIRECTORY_INFO 0x02
288 #define SMB2_FIND_BOTH_DIRECTORY_INFO 0x03
289 #define SMB2_FIND_NAME_INFO 0x0C
290 #define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25
291 #define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26
295 /* static body buffer 32 (0x20) bytes */
296 /* uint16_t buffer_code; 0x21 = 0x20 + 1 */
298 uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */
299 uint32_t unknown; /* perhaps a continue token? */
300 struct smb2_handle handle;
301 /* uint16_t pattern_ofs; */
302 /* uint32_t pattern_size; */
303 uint32_t max_response_size;
310 /* static body buffer 8 (0x08) bytes */
311 /* uint16_t buffer_code; 0x08 */
312 /* uint16_t blob_ofs; */
313 /* uint32_t blob_size; */
322 /* static body buffer 56 (0x38) bytes */
323 /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
326 struct smb2_handle handle;
327 /* uint32_t out_ofs; */
328 /* uint32_t out_size; */
330 /* uint32_t in_ofs; */
331 /* uint32_t in_size; */
332 uint32_t max_response_size;
341 /* static body buffer 48 (0x30) bytes */
342 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
345 struct smb2_handle handle;
346 /* uint32_t in_ofs; */
347 /* uint32_t in_size; */
348 /* uint32_t out_ofs; */
349 /* uint32_t out_size; */
362 struct smb2_handle handle;
366 struct cli_credentials;
367 struct event_context;
368 #include "libcli/smb2/smb2_proto.h"