r14542: Remove librpc, libndr and libnbt from includes.h
[bbaumbach/samba-autobuild/.git] / source4 / libcli / smb2 / smb2_calls.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    SMB2 client calls 
5
6    Copyright (C) Andrew Tridgell 2005
7    
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.
12    
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.
17    
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.
21 */
22
23 #include "libcli/raw/interfaces.h"
24
25 struct smb2_negprot {
26         struct {
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 */
32         } in;
33         struct {
34                 /* static body buffer 64 (0x40) bytes */
35                 /* uint16_t buffer_code;  0x41 = 0x40 + 1 */
36                 uint16_t _pad;
37                 uint32_t unknown2; /* 0x06 */
38                 uint8_t  sessid[16];
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 */
44                 NTTIME   current_time;
45                 NTTIME   boot_time;
46                 /* uint16_t secblob_ofs */
47                 /* uint16_t secblob_size */
48                 uint32_t unknown9; /* 0x204d4c20 */
49
50                 /* dynamic body buffer */
51                 DATA_BLOB secblob;
52         } out;
53 };
54
55 struct smb2_session_setup {
56         struct {
57                 /* static body buffer 16 (0x10) bytes */
58                 /* uint16_t buffer_code;  0x11 = 0x10 + 1 */
59                 uint16_t _pad;
60                 uint32_t unknown2; /* 0xF */
61                 uint32_t unknown3; /* 0x00 */
62                 /* uint16_t secblob_ofs */
63                 /* uint16_t secblob_size */
64
65                 /* dynamic body */
66                 DATA_BLOB secblob;
67         } in;
68         struct {
69                 /* static body buffer 8 (0x08) bytes */
70                 /* uint16_t buffer_code; 0x09 = 0x08 +1 */
71                 uint16_t _pad;
72                 /* uint16_t secblob_ofs */
73                 /* uint16_t secblob_size */
74
75                 /* dynamic body */
76                 DATA_BLOB secblob;
77
78                 /* extracted from the SMB2 header */
79                 uint64_t uid;
80         } out;
81 };
82
83 struct smb2_tree_connect {
84         struct {
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 */
90
91                 /* dynamic body */
92                 const char *path; /* as non-terminated UTF-16 on the wire */
93         } in;
94         struct {
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;
101
102                 /* extracted from the SMB2 header */
103                 uint32_t tid;
104         } out;
105 };
106
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
111
112 struct smb2_create {
113         struct {
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;
120
121                 uint32_t file_attr;
122                 uint32_t share_access;
123                 uint32_t open_disposition;
124                 uint32_t create_options;
125
126                 /* uint16_t fname_ofs */
127                 /* uint16_t fname_size */
128                 /* uint32_t blob_ofs; */
129                 /* uint32_t blob_size; */
130
131                 /* dynamic body */
132                 const char *fname;
133
134                 /* optional list of extended attributes */
135                 struct smb_ea_list eas;
136         } in;
137
138         struct {
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;
143                 NTTIME   create_time;
144                 NTTIME   access_time;
145                 NTTIME   write_time;
146                 NTTIME   change_time;
147                 uint64_t alloc_size;
148                 uint64_t size;
149                 uint32_t file_attr;
150                 uint32_t _pad;
151                 struct smb2_handle handle;
152                 /* uint32_t blob_ofs; */
153                 /* uint32_t blob_size; */
154
155                 /* dynamic body */
156                 DATA_BLOB blob;
157         } out;
158 };
159
160
161 #define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
162
163 struct smb2_close {
164         struct {
165                 /* static body buffer 24 (0x18) bytes */
166                 /* uint16_t buffer_code;  0x18 */
167                 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
168                 uint32_t _pad;
169                 struct smb2_handle handle;
170         } in;
171
172         struct {
173                 /* static body buffer 60 (0x3C) bytes */
174                 /* uint16_t buffer_code;  0x3C */
175                 uint16_t flags;
176                 uint32_t _pad;
177                 NTTIME   create_time;
178                 NTTIME   access_time;
179                 NTTIME   write_time;
180                 NTTIME   change_time;
181                 uint64_t alloc_size;
182                 uint64_t size;
183                 uint32_t file_attr;
184         } out;
185 };
186
187 /* getinfo classes */
188 #define SMB2_GETINFO_FILE               0x01
189 #define SMB2_GETINFO_FS                 0x02
190 #define SMB2_GETINFO_SECURITY           0x03
191
192 /* flags for RAW_FILEINFO_SMB2_ALL_EAS */
193 #define SMB2_CONTINUE_FLAG_RESTART    0x01
194 #define SMB2_CONTINUE_FLAG_SINGLE     0x02
195
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 */
199
200 struct smb2_getinfo {
201         struct {
202                 /* static body buffer 40 (0x28) bytes */
203                 /* uint16_t buffer_code;  0x29 = 0x28 + 1 (why???) */
204                 uint16_t level;
205                 uint32_t max_response_size;
206                 uint32_t unknown1;
207                 uint32_t unknown2;
208                 uint32_t flags; /* level specific */
209                 uint32_t flags2; /* used by all_eas level */
210                 struct smb2_handle handle;
211         } in;
212
213         struct {
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; */
218
219                 /* dynamic body */
220                 DATA_BLOB blob;
221         } out;
222 };
223
224 struct smb2_setinfo {
225         struct {
226                 uint16_t level;
227                 uint32_t flags;
228                 struct smb2_handle handle;
229                 DATA_BLOB blob;
230         } in;
231 };
232
233 struct smb2_write {
234         struct {
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; */
239                 uint64_t offset;
240                 struct smb2_handle handle;
241                 uint64_t unknown1; /* 0xFFFFFFFFFFFFFFFF */
242                 uint64_t unknown2; /* 0xFFFFFFFFFFFFFFFF */
243
244                 /* dynamic body */
245                 DATA_BLOB data;
246         } in;
247
248         struct {
249                 /* static body buffer 17 (0x11) bytes */
250                 /* uint16_t buffer_code;  0x11 */
251                 uint16_t _pad;
252                 uint32_t nwritten;
253                 uint64_t unknown1; /* 0x0000000000000000 */
254                 uint8_t _bug;
255         } out;
256 };
257
258 struct smb2_read {
259         struct {
260                 /* static body buffer 48 (0x30) bytes */
261                 /* uint16_t buffer_code;  0x31 = 0x30 + 1 */
262                 uint16_t _pad;
263                 uint32_t length;
264                 uint64_t offset;
265                 struct smb2_handle handle;
266                 uint64_t unknown1; /* 0x0000000000000000 */
267                 uint64_t unknown2; /* 0x0000000000000000 */
268                 uint8_t _bug;
269         } in;
270
271         struct {
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 */
277
278                 /* dynamic body */
279                 DATA_BLOB data;
280         } out;
281 };
282
283 /*
284   SMB2 uses different level numbers for the same old SMB search levels
285 */
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
292
293 struct smb2_find {
294         struct {
295                 /* static body buffer 32 (0x20) bytes */
296                 /* uint16_t buffer_code;  0x21 = 0x20 + 1 */
297                 uint8_t level;
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;
304
305                 /* dynamic body */
306                 const char *pattern;
307         } in;
308
309         struct {
310                 /* static body buffer 8 (0x08) bytes */
311                 /* uint16_t buffer_code;  0x08 */
312                 /* uint16_t blob_ofs; */
313                 /* uint32_t blob_size; */
314
315                 /* dynamic body */
316                 DATA_BLOB blob;
317         } out;
318 };
319
320 struct smb2_ioctl {
321         struct {
322                 /* static body buffer 56 (0x38) bytes */
323                 /* uint16_t buffer_code;  0x39 = 0x38 + 1 */
324                 uint16_t _pad;
325                 uint32_t function;
326                 struct smb2_handle handle;
327                 /* uint32_t out_ofs; */
328                 /* uint32_t out_size; */
329                 uint32_t unknown2;
330                 /* uint32_t in_ofs; */
331                 /* uint32_t in_size; */
332                 uint32_t max_response_size;
333                 uint64_t flags;
334
335                 /* dynamic body */
336                 DATA_BLOB out;
337                 DATA_BLOB in;
338         } in;
339
340         struct {
341                 /* static body buffer 48 (0x30) bytes */
342                 /* uint16_t buffer_code;  0x31 = 0x30 + 1 */
343                 uint16_t _pad;
344                 uint32_t function;
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; */
350                 uint32_t unknown2;
351                 uint32_t unknown3;
352
353                 /* dynamic body */
354                 DATA_BLOB in;
355                 DATA_BLOB out;
356         } out;
357 };
358
359 struct smb2_flush {
360         struct {
361                 uint32_t unknown;
362                 struct smb2_handle handle;
363         } in;
364 };
365
366 struct cli_credentials;
367 struct event_context;
368 #include "libcli/smb2/smb2_proto.h"