r11700: added structure definitions for many of the getinfo structures
[samba.git] / source / 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
24 struct smb2_negprot {
25         struct {
26                 uint32_t unknown1;    /* 0x00010024 */
27                 uint16_t unknown2;    /* 0x00 */
28                 uint8_t  unknown3[32]; /* all zero */
29         } in;
30         struct {
31                 uint16_t buffer_code;
32                 uint16_t _pad;
33                 uint32_t unknown2; /* 0x06 */
34                 uint8_t  sessid[16];
35                 uint32_t unknown3; /* 0x0d */
36                 uint16_t unknown4; /* 0x00 */
37                 uint32_t unknown5; /* 0x01 */
38                 uint32_t unknown6; /* 0x01 */
39                 uint16_t unknown7; /* 0x01 */
40                 NTTIME   current_time;
41                 NTTIME   boot_time;
42                 uint16_t unknown8; /* 0x80 */
43                 /* uint16_t secblob size here */
44                 uint32_t unknown9; /* 0x204d4c20 */
45                 DATA_BLOB secblob;
46         } out;
47 };
48
49 struct smb2_session_setup {
50         struct {
51                 uint32_t unknown1; /* 0x11 */
52                 uint32_t unknown2; /* 0xF */
53                 uint32_t unknown3; /* 0x00 */
54                 /* uint16_t secblob ofs/size here */
55                 DATA_BLOB secblob;
56         } in;
57         struct {
58                 uint16_t buffer_code;
59                 uint16_t _pad;
60                 /* uint16_t secblob ofs/size here */
61                 DATA_BLOB secblob;
62                 uint64_t uid; /* returned in header */
63         } out;
64 };
65
66 struct smb2_tree_connect {
67         struct {
68                 uint32_t unknown1; /* 0x09 */
69                 const char *path;
70         } in;
71         struct {
72                 uint16_t buffer_code;
73                 uint16_t unknown1; /* 0x02 */
74                 uint32_t unknown2; /* 0x00 */
75                 uint32_t unknown3; /* 0x00 */
76                 uint32_t access_mask;
77                 uint32_t tid;
78         } out;
79 };
80
81 /*
82   file handles in SMB2 are 16 bytes
83 */
84 struct smb2_handle {
85         uint64_t data[2];
86 };
87
88
89 #define SMB2_CREATE_FLAG_REQUEST_OPLOCK           0x0100
90 #define SMB2_CREATE_FLAG_REQUEST_EXCLUSIVE_OPLOCK 0x0800
91 #define SMB2_CREATE_FLAG_GRANT_OPLOCK             0x0001
92 #define SMB2_CREATE_FLAG_GRANT_EXCLUSIVE_OPLOCK   0x0080
93
94 struct smb2_create {
95         struct {
96                 uint16_t buffer_code; /* 0x39 */
97                 uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
98                 uint32_t unknown2;
99                 uint32_t unknown3[4];
100                 uint32_t access_mask;
101                 uint32_t file_attr;
102                 uint32_t share_access;
103                 uint32_t open_disposition;
104                 uint32_t create_options;
105                 /* ofs/len of name here, 16 bits */
106                 uint32_t unknown6;
107                 const char *fname;
108                 uint32_t unknown7;
109                 uint32_t unknown8;
110                 uint32_t unknown9;
111                 uint32_t unknown10;
112                 uint64_t unknown11;
113         } in;
114
115         struct {
116                 uint16_t buffer_code; /* 0x59 */
117                 uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
118                 uint32_t create_action;
119                 NTTIME   create_time;
120                 NTTIME   access_time;
121                 NTTIME   write_time;
122                 NTTIME   change_time;
123                 uint64_t alloc_size;
124                 uint64_t size;
125                 uint32_t file_attr;
126                 uint32_t _pad;
127                 struct smb2_handle handle;
128                 uint32_t unknown4;
129                 uint32_t unknown5;
130         } out;
131 };
132
133
134 #define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
135
136 struct smb2_close {
137         struct {
138                 uint16_t buffer_code;
139                 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
140                 uint32_t _pad;
141                 struct smb2_handle handle;
142         } in;
143
144         struct {
145                 uint16_t buffer_code;
146                 uint16_t flags;
147                 uint32_t _pad;
148                 NTTIME   create_time;
149                 NTTIME   access_time;
150                 NTTIME   write_time;
151                 NTTIME   change_time;
152                 uint64_t alloc_size;
153                 uint64_t size;
154                 uint32_t file_attr;
155         } out;
156 };
157
158 /* fs information levels */
159 #define SMB2_GETINFO_FS_01            0x0102
160 #define SMB2_GETINFO_FS_03            0x0302
161 #define SMB2_GETINFO_FS_04            0x0402
162 #define SMB2_GETINFO_FS_ATTRIB_INFO   0x0502
163 #define SMB2_GETINFO_FS_06            0x0602
164 #define SMB2_GETINFO_FS_07            0x0702
165 #define SMB2_GETINFO_FS_08            0x0802
166
167 /* class 3 levels */
168 #define SMB2_GETINFO_3_00            0x0003
169
170 /* file information levels */
171 #define SMB2_GETINFO_FILE_BASIC_INFO    0x0401
172 #define SMB2_GETINFO_FILE_SIZE_INFO     0x0501
173 #define SMB2_GETINFO_FILE_06            0x0601
174 #define SMB2_GETINFO_FILE_EA_SIZE       0x0701
175 #define SMB2_GETINFO_FILE_ACCESS_INFO   0x0801
176 #define SMB2_GETINFO_FILE_0E            0x0e01
177 #define SMB2_GETINFO_FILE_EA_INFO       0x0f01
178 #define SMB2_GETINFO_FILE_10            0x1001
179 #define SMB2_GETINFO_FILE_11            0x1101
180 #define SMB2_GETINFO_FILE_ALL_INFO      0x1201
181 #define SMB2_GETINFO_FILE_SHORT_INFO    0x1501
182 #define SMB2_GETINFO_FILE_STREAM_INFO   0x1601
183 #define SMB2_GETINFO_FILE_EOF_INFO      0x1c01
184 #define SMB2_GETINFO_FILE_STANDARD_INFO 0x2201
185 #define SMB2_GETINFO_FILE_ATTRIB_INFO   0x2301
186
187
188 struct smb2_getinfo {
189         struct {
190                 uint16_t buffer_code;
191                 uint16_t level;
192                 uint32_t max_response_size;
193                 uint32_t unknown1;
194                 uint32_t unknown2;
195                 uint32_t unknown3;
196                 uint32_t unknown4;
197                 struct smb2_handle handle;
198         } in;
199
200         struct {
201                 uint16_t buffer_code;
202                 DATA_BLOB blob;
203         } out;
204 };
205
206 union smb2_fileinfo {
207         struct {
208                 NTTIME   create_time;
209                 NTTIME   access_time;
210                 NTTIME   write_time;
211                 NTTIME   change_time;
212                 uint32_t file_attr;
213                 uint32_t unknown;
214         } basic_info;
215
216         struct {
217                 uint64_t alloc_size;
218                 uint64_t size;
219                 uint32_t nlink;
220                 uint32_t unknown;
221         } size_info;
222
223         struct {
224                 uint32_t unknown1;
225                 uint32_t unknown2;
226         } unknown06;
227
228         struct {
229                 uint32_t ea_size;
230         } ea_info;
231
232         struct {
233                 uint32_t access_mask;
234         } access_info;
235
236         struct {
237                 uint32_t unknown1;
238                 uint32_t unknown2;
239         } unknown0e;
240
241         struct {
242                 struct smb_ea_list all_eas;
243         } all_ea_info;
244
245         struct {
246                 uint32_t unknown; /* 2 */
247         } unknown10;
248
249         struct {
250                 uint32_t unknown;
251         } unknown11;
252
253         struct {
254                 NTTIME   create_time;
255                 NTTIME   access_time;
256                 NTTIME   write_time;
257                 NTTIME   change_time;
258                 uint32_t file_attr;
259                 uint32_t unknown1;
260                 uint64_t alloc_size;
261                 uint64_t size;
262                 uint32_t nlink;
263                 uint32_t unknown2;
264                 uint32_t unknown3;
265                 uint32_t unknown4;
266                 uint32_t ea_size;
267                 uint32_t access_mask;
268                 uint64_t unknown5;
269                 uint64_t unknown6;
270                 const char *fname;
271         } all_info;
272
273         struct {
274                 const char *short_name;
275         } short_info;
276
277         struct {
278                 uint32_t unknown;
279                 uint64_t size;
280                 uint64_t alloc_size;
281                 const char *stream_name;
282         } stream_info;
283
284         struct {
285                 uint64_t size;
286                 uint64_t unknown;
287         } eof_info;
288
289         struct {
290                 NTTIME   create_time;
291                 NTTIME   access_time;
292                 NTTIME   write_time;
293                 NTTIME   change_time;
294                 uint64_t alloc_size;
295                 uint64_t size;
296                 uint32_t file_attr;
297                 uint32_t unknown;
298         } standard_info;
299
300         struct {
301                 uint32_t file_attr;
302                 uint32_t unknown;
303         } attrib_info;
304 };