r23792: convert Samba4 to GPLv3
[metze/samba/wip.git] / source4 / libcli / raw / trans2.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB transaction2 handling
4    Copyright (C) Jeremy Allison 1994-2002.
5    Copyright (C) Andrew Tridgell 1995-2003.
6    Copyright (C) James Peach 2007
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 3 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, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef _TRANS2_H_
23 #define _TRANS2_H_
24
25 /* These are the TRANS2 sub commands */
26 #define TRANSACT2_OPEN                        0
27 #define TRANSACT2_FINDFIRST                   1
28 #define TRANSACT2_FINDNEXT                    2
29 #define TRANSACT2_QFSINFO                     3
30 #define TRANSACT2_SETFSINFO                   4
31 #define TRANSACT2_QPATHINFO                   5
32 #define TRANSACT2_SETPATHINFO                 6
33 #define TRANSACT2_QFILEINFO                   7
34 #define TRANSACT2_SETFILEINFO                 8
35 #define TRANSACT2_FSCTL                       9
36 #define TRANSACT2_IOCTL                     0xA
37 #define TRANSACT2_FINDNOTIFYFIRST           0xB
38 #define TRANSACT2_FINDNOTIFYNEXT            0xC
39 #define TRANSACT2_MKDIR                     0xD
40 #define TRANSACT2_SESSION_SETUP             0xE
41 #define TRANSACT2_GET_DFS_REFERRAL         0x10
42 #define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
43
44
45 /* trans2 Query FS info levels */
46 /*
47 w2k3 TRANS2ALIASES:
48 Checking for QFSINFO aliases
49         Found level    1 (0x001) of size 18 (0x12)
50         Found level    2 (0x002) of size 12 (0x0c)
51         Found level  258 (0x102) of size 26 (0x1a)
52         Found level  259 (0x103) of size 24 (0x18)
53         Found level  260 (0x104) of size  8 (0x08)
54         Found level  261 (0x105) of size 20 (0x14)
55         Found level 1001 (0x3e9) of size 26 (0x1a)
56         Found level 1003 (0x3eb) of size 24 (0x18)
57         Found level 1004 (0x3ec) of size  8 (0x08)
58         Found level 1005 (0x3ed) of size 20 (0x14)
59         Found level 1006 (0x3ee) of size 48 (0x30)
60         Found level 1007 (0x3ef) of size 32 (0x20)
61         Found level 1008 (0x3f0) of size 64 (0x40)
62 Found 13 levels with success status
63         Level 261 (0x105) and level 1005 (0x3ed) are possible aliases
64         Level 260 (0x104) and level 1004 (0x3ec) are possible aliases
65         Level 259 (0x103) and level 1003 (0x3eb) are possible aliases
66         Level 258 (0x102) and level 1001 (0x3e9) are possible aliases
67 Found 4 aliased levels
68 */
69 #define SMB_QFS_ALLOCATION                                 1
70 #define SMB_QFS_VOLUME                                     2
71 #define SMB_QFS_VOLUME_INFO                            0x102
72 #define SMB_QFS_SIZE_INFO                              0x103
73 #define SMB_QFS_DEVICE_INFO                            0x104
74 #define SMB_QFS_ATTRIBUTE_INFO                         0x105
75 #define SMB_QFS_UNIX_INFO                              0x200
76 #define SMB_QFS_POSIX_INFO                             0x201
77 #define SMB_QFS_POSIX_WHOAMI                           0x202
78 #define SMB_QFS_VOLUME_INFORMATION                      1001
79 #define SMB_QFS_SIZE_INFORMATION                        1003
80 #define SMB_QFS_DEVICE_INFORMATION                      1004
81 #define SMB_QFS_ATTRIBUTE_INFORMATION                   1005
82 #define SMB_QFS_QUOTA_INFORMATION                       1006
83 #define SMB_QFS_FULL_SIZE_INFORMATION                   1007
84 #define SMB_QFS_OBJECTID_INFORMATION                    1008
85
86
87 /* trans2 qfileinfo/qpathinfo */
88 /* w2k3 TRANS2ALIASES:
89 Checking for QPATHINFO aliases
90 setting up complex file \qpathinfo_aliases.txt
91         Found level    1 (0x001) of size  22 (0x16)
92         Found level    2 (0x002) of size  26 (0x1a)
93         Found level    4 (0x004) of size  41 (0x29)
94         Found level    6 (0x006) of size   0 (0x00)
95         Found level  257 (0x101) of size  40 (0x28)
96         Found level  258 (0x102) of size  24 (0x18)
97         Found level  259 (0x103) of size   4 (0x04)
98         Found level  260 (0x104) of size  48 (0x30)
99         Found level  263 (0x107) of size 126 (0x7e)
100         Found level  264 (0x108) of size  28 (0x1c)
101         Found level  265 (0x109) of size  38 (0x26)
102         Found level  267 (0x10b) of size  16 (0x10)
103         Found level 1004 (0x3ec) of size  40 (0x28)
104         Found level 1005 (0x3ed) of size  24 (0x18)
105         Found level 1006 (0x3ee) of size   8 (0x08)
106         Found level 1007 (0x3ef) of size   4 (0x04)
107         Found level 1008 (0x3f0) of size   4 (0x04)
108         Found level 1009 (0x3f1) of size  48 (0x30)
109         Found level 1014 (0x3f6) of size   8 (0x08)
110         Found level 1016 (0x3f8) of size   4 (0x04)
111         Found level 1017 (0x3f9) of size   4 (0x04)
112         Found level 1018 (0x3fa) of size 126 (0x7e)
113         Found level 1021 (0x3fd) of size  28 (0x1c)
114         Found level 1022 (0x3fe) of size  38 (0x26)
115         Found level 1028 (0x404) of size  16 (0x10)
116         Found level 1034 (0x40a) of size  56 (0x38)
117         Found level 1035 (0x40b) of size   8 (0x08)
118 Found 27 levels with success status
119         Level 267 (0x10b) and level 1028 (0x404) are possible aliases
120         Level 265 (0x109) and level 1022 (0x3fe) are possible aliases
121         Level 264 (0x108) and level 1021 (0x3fd) are possible aliases
122         Level 263 (0x107) and level 1018 (0x3fa) are possible aliases
123         Level 260 (0x104) and level 1009 (0x3f1) are possible aliases
124         Level 259 (0x103) and level 1007 (0x3ef) are possible aliases
125         Level 258 (0x102) and level 1005 (0x3ed) are possible aliases
126         Level 257 (0x101) and level 1004 (0x3ec) are possible aliases
127 Found 8 aliased levels
128 */
129 #define SMB_QFILEINFO_STANDARD                             1
130 #define SMB_QFILEINFO_EA_SIZE                              2
131 #define SMB_QFILEINFO_EA_LIST                              3
132 #define SMB_QFILEINFO_ALL_EAS                              4
133 #define SMB_QFILEINFO_IS_NAME_VALID                        6  /* only for QPATHINFO */
134 #define SMB_QFILEINFO_BASIC_INFO                       0x101
135 #define SMB_QFILEINFO_STANDARD_INFO                    0x102
136 #define SMB_QFILEINFO_EA_INFO                          0x103
137 #define SMB_QFILEINFO_NAME_INFO                        0x104
138 #define SMB_QFILEINFO_ALL_INFO                         0x107
139 #define SMB_QFILEINFO_ALT_NAME_INFO                    0x108
140 #define SMB_QFILEINFO_STREAM_INFO                      0x109
141 #define SMB_QFILEINFO_COMPRESSION_INFO                 0x10b
142 #define SMB_QFILEINFO_UNIX_BASIC                       0x200
143 #define SMB_QFILEINFO_UNIX_LINK                        0x201
144 #define SMB_QFILEINFO_UNIX_INFO2                       0x20b
145 #define SMB_QFILEINFO_BASIC_INFORMATION                 1004
146 #define SMB_QFILEINFO_STANDARD_INFORMATION              1005
147 #define SMB_QFILEINFO_INTERNAL_INFORMATION              1006
148 #define SMB_QFILEINFO_EA_INFORMATION                    1007
149 #define SMB_QFILEINFO_ACCESS_INFORMATION                1008
150 #define SMB_QFILEINFO_NAME_INFORMATION                  1009
151 #define SMB_QFILEINFO_POSITION_INFORMATION              1014
152 #define SMB_QFILEINFO_MODE_INFORMATION                  1016
153 #define SMB_QFILEINFO_ALIGNMENT_INFORMATION             1017
154 #define SMB_QFILEINFO_ALL_INFORMATION                   1018
155 #define SMB_QFILEINFO_ALT_NAME_INFORMATION              1021
156 #define SMB_QFILEINFO_STREAM_INFORMATION                1022
157 #define SMB_QFILEINFO_COMPRESSION_INFORMATION           1028
158 #define SMB_QFILEINFO_NETWORK_OPEN_INFORMATION          1034
159 #define SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION         1035
160
161
162
163 /* trans2 setfileinfo/setpathinfo levels */
164 /*
165 w2k3 TRANS2ALIASES
166 Checking for SETFILEINFO aliases
167 setting up complex file \setfileinfo_aliases.txt
168         Found level    1 (0x001) of size   2 (0x02)
169         Found level    2 (0x002) of size   2 (0x02)
170         Found level  257 (0x101) of size  40 (0x28)
171         Found level  258 (0x102) of size   2 (0x02)
172         Found level  259 (0x103) of size   8 (0x08)
173         Found level  260 (0x104) of size   8 (0x08)
174         Found level 1004 (0x3ec) of size  40 (0x28)
175         Found level 1010 (0x3f2) of size   2 (0x02)
176         Found level 1013 (0x3f5) of size   2 (0x02)
177         Found level 1014 (0x3f6) of size   8 (0x08)
178         Found level 1016 (0x3f8) of size   4 (0x04)
179         Found level 1019 (0x3fb) of size   8 (0x08)
180         Found level 1020 (0x3fc) of size   8 (0x08)
181         Found level 1023 (0x3ff) of size   8 (0x08)
182         Found level 1025 (0x401) of size  16 (0x10)
183         Found level 1029 (0x405) of size  72 (0x48)
184         Found level 1032 (0x408) of size  56 (0x38)
185         Found level 1039 (0x40f) of size   8 (0x08)
186         Found level 1040 (0x410) of size   8 (0x08)
187 Found 19 valid levels
188
189 Checking for SETPATHINFO aliases
190         Found level 1004 (0x3ec) of size  40 (0x28)
191         Found level 1010 (0x3f2) of size   2 (0x02)
192         Found level 1013 (0x3f5) of size   2 (0x02)
193         Found level 1014 (0x3f6) of size   8 (0x08)
194         Found level 1016 (0x3f8) of size   4 (0x04)
195         Found level 1019 (0x3fb) of size   8 (0x08)
196         Found level 1020 (0x3fc) of size   8 (0x08)
197         Found level 1023 (0x3ff) of size   8 (0x08)
198         Found level 1025 (0x401) of size  16 (0x10)
199         Found level 1029 (0x405) of size  72 (0x48)
200         Found level 1032 (0x408) of size  56 (0x38)
201         Found level 1039 (0x40f) of size   8 (0x08)
202         Found level 1040 (0x410) of size   8 (0x08)
203 Found 13 valid levels
204 */
205 #define SMB_SFILEINFO_STANDARD                             1
206 #define SMB_SFILEINFO_EA_SET                               2
207 #define SMB_SFILEINFO_BASIC_INFO                       0x101
208 #define SMB_SFILEINFO_DISPOSITION_INFO                 0x102
209 #define SMB_SFILEINFO_ALLOCATION_INFO                  0x103
210 #define SMB_SFILEINFO_END_OF_FILE_INFO                 0x104
211 #define SMB_SFILEINFO_UNIX_BASIC                       0x200
212 #define SMB_SFILEINFO_UNIX_LINK                        0x201
213 #define SMB_SPATHINFO_UNIX_HLINK                       0x203
214 #define SMB_SPATHINFO_POSIX_ACL                        0x204
215 #define SMB_SPATHINFO_XATTR                            0x205
216 #define SMB_SFILEINFO_ATTR_FLAGS                       0x206    
217 #define SMB_SFILEINFO_UNIX_INFO2                       0x20b
218 #define SMB_SFILEINFO_BASIC_INFORMATION                 1004
219 #define SMB_SFILEINFO_RENAME_INFORMATION                1010
220 #define SMB_SFILEINFO_DISPOSITION_INFORMATION           1013
221 #define SMB_SFILEINFO_POSITION_INFORMATION              1014
222 #define SMB_SFILEINFO_MODE_INFORMATION                  1016
223 #define SMB_SFILEINFO_ALLOCATION_INFORMATION            1019
224 #define SMB_SFILEINFO_END_OF_FILE_INFORMATION           1020
225
226 /* filemon shows FilePipeInformation */
227 #define SMB_SFILEINFO_1023                              1023
228
229 /* filemon shows FilePipeRemoteInformation */
230 #define SMB_SFILEINFO_1025                              1025
231
232 /* filemon shows CopyOnWriteInformation */
233 #define SMB_SFILEINFO_1029                              1029
234
235 /* filemon shows OleClassIdInformation */
236 #define SMB_SFILEINFO_1032                              1032
237
238 /* seems to be the file size - perhaps valid data size? 
239    filemon shows 'InheritContentIndexInfo'
240 */
241 #define SMB_SFILEINFO_1039                              1039
242
243 /* OLE_INFORMATION? */
244 #define SMB_SFILEINFO_1040                              1040
245
246
247 /* trans2 findfirst levels */
248 /*
249 w2k3 TRANS2ALIASES:
250 Checking for FINDFIRST aliases
251         Found level    1 (0x001) of size  68 (0x44)
252         Found level    2 (0x002) of size  70 (0x46)
253         Found level  257 (0x101) of size 108 (0x6c)
254         Found level  258 (0x102) of size 116 (0x74)
255         Found level  259 (0x103) of size  60 (0x3c)
256         Found level  260 (0x104) of size 140 (0x8c)
257         Found level  261 (0x105) of size 124 (0x7c)
258         Found level  262 (0x106) of size 148 (0x94)
259 Found 8 levels with success status
260 Found 0 aliased levels
261 */
262 #define SMB_FIND_STANDARD                   1
263 #define SMB_FIND_EA_SIZE                    2
264 #define SMB_FIND_EA_LIST                    3
265 #define SMB_FIND_DIRECTORY_INFO         0x101
266 #define SMB_FIND_FULL_DIRECTORY_INFO    0x102
267 #define SMB_FIND_NAME_INFO              0x103
268 #define SMB_FIND_BOTH_DIRECTORY_INFO    0x104
269 #define SMB_FIND_ID_FULL_DIRECTORY_INFO 0x105
270 #define SMB_FIND_ID_BOTH_DIRECTORY_INFO 0x106
271 #define SMB_FIND_UNIX_INFO              0x202
272 #define SMB_FIND_UNIX_INFO2             0x20b
273
274 /* flags on trans2 findfirst/findnext that control search */
275 #define FLAG_TRANS2_FIND_CLOSE          0x1
276 #define FLAG_TRANS2_FIND_CLOSE_IF_END   0x2
277 #define FLAG_TRANS2_FIND_REQUIRE_RESUME 0x4
278 #define FLAG_TRANS2_FIND_CONTINUE       0x8
279 #define FLAG_TRANS2_FIND_BACKUP_INTENT  0x10
280
281 /*
282  * DeviceType and Characteristics returned in a
283  * SMB_QFS_DEVICE_INFO call.
284  */
285 #define QFS_DEVICETYPE_CD_ROM                   0x2
286 #define QFS_DEVICETYPE_CD_ROM_FILE_SYSTEM       0x3
287 #define QFS_DEVICETYPE_DISK                     0x7
288 #define QFS_DEVICETYPE_DISK_FILE_SYSTEM         0x8
289 #define QFS_DEVICETYPE_FILE_SYSTEM              0x9
290
291 /* Characteristics. */
292 #define QFS_TYPE_REMOVABLE_MEDIA                0x1
293 #define QFS_TYPE_READ_ONLY_DEVICE               0x2
294 #define QFS_TYPE_FLOPPY                         0x4
295 #define QFS_TYPE_WORM                           0x8
296 #define QFS_TYPE_REMOTE                         0x10
297 #define QFS_TYPE_MOUNTED                        0x20
298 #define QFS_TYPE_VIRTUAL                        0x40
299
300
301 /*
302  * Thursby MAC extensions....
303  */
304
305 /*
306  * MAC CIFS Extensions have the range 0x300 - 0x2FF reserved.
307  * Supposedly Microsoft have agreed to this.
308  */
309
310 #define MIN_MAC_INFO_LEVEL                      0x300
311 #define MAX_MAC_INFO_LEVEL                      0x3FF
312 #define SMB_QFS_MAC_FS_INFO                     0x301
313
314
315
316 /* UNIX CIFS Extensions - created by HP */
317 /*
318  * UNIX CIFS Extensions have the range 0x200 - 0x2FF reserved.
319  * Supposedly Microsoft have agreed to this.
320  */
321
322 #define MIN_UNIX_INFO_LEVEL 0x200
323 #define MAX_UNIX_INFO_LEVEL 0x2FF
324
325 #define INFO_LEVEL_IS_UNIX(level) (((level) >= MIN_UNIX_INFO_LEVEL) && ((level) <= MAX_UNIX_INFO_LEVEL))
326
327 #define SMB_MODE_NO_CHANGE                 0xFFFFFFFF     /* file mode value which */
328                                               /* means "don't change it" */
329 #define SMB_UID_NO_CHANGE                  0xFFFFFFFF
330 #define SMB_GID_NO_CHANGE                  0xFFFFFFFF
331
332 #define SMB_SIZE_NO_CHANGE_LO              0xFFFFFFFF
333 #define SMB_SIZE_NO_CHANGE_HI              0xFFFFFFFF
334  
335 #define SMB_TIME_NO_CHANGE_LO              0xFFFFFFFF
336 #define SMB_TIME_NO_CHANGE_HI              0xFFFFFFFF
337
338 /*
339 UNIX_BASIC  info level:
340
341 Offset Size         Name
342 0      LARGE_INTEGER EndOfFile                File size
343 8      LARGE_INTEGER Blocks                   Number of bytes used on disk (st_blocks).
344 16     LARGE_INTEGER CreationTime             Creation time
345 24     LARGE_INTEGER LastAccessTime           Last access time
346 32     LARGE_INTEGER LastModificationTime     Last modification time
347 40     LARGE_INTEGER Uid                      Numeric user id for the owner
348 48     LARGE_INTEGER Gid                      Numeric group id of owner
349 56     ULONG Type                             Enumeration specifying the pathname type:
350                                               0 -- File
351                                               1 -- Directory
352                                               2 -- Symbolic link
353                                               3 -- Character device
354                                               4 -- Block device
355                                               5 -- FIFO (named pipe)
356                                               6 -- Unix domain socket
357
358 60     LARGE_INTEGER devmajor                 Major device number if type is device
359 68     LARGE_INTEGER devminor                 Minor device number if type is device
360 76     LARGE_INTEGER uniqueid                 This is a server-assigned unique id for the file. The client
361                                               will typically map this onto an inode number. The scope of
362                                               uniqueness is the share.
363 84     LARGE_INTEGER permissions              Standard UNIX file permissions  - see below.
364 92     LARGE_INTEGER nlinks                   The number of directory entries that map to this entry
365                                               (number of hard links)
366
367 100 - end.
368 */
369
370 /*
371 SMB_QUERY_FILE_UNIX_INFO2 is SMB_QUERY_FILE_UNIX_BASIC with create
372 time and file flags appended. The corresponding info level for
373 findfirst/findnext is SMB_FIND_FILE_UNIX_UNIX2.
374
375 Size    Offset  Value
376 ---------------------
377 0      LARGE_INTEGER EndOfFile          File size
378 8      LARGE_INTEGER Blocks             Number of blocks used on disk
379 16     LARGE_INTEGER ChangeTime         Attribute change time
380 24     LARGE_INTEGER LastAccessTime           Last access time
381 32     LARGE_INTEGER LastModificationTime     Last modification time
382 40     LARGE_INTEGER Uid                Numeric user id for the owner
383 48     LARGE_INTEGER Gid                Numeric group id of owner
384 56     ULONG Type                       Enumeration specifying the file type
385 60     LARGE_INTEGER devmajor           Major device number if type is device
386 68     LARGE_INTEGER devminor           Minor device number if type is device
387 76     LARGE_INTEGER uniqueid           This is a server-assigned unique id
388 84     LARGE_INTEGER permissions        Standard UNIX permissions
389 92     LARGE_INTEGER nlinks             Number of hard link)
390 100    LARGE_INTEGER CreationTime       Create/birth time
391 108    ULONG FileFlags                  File flags enumeration
392 112    ULONG FileFlagsMask              Mask of valid flags
393 */
394
395 /* UNIX filetype mappings. */
396
397 #define UNIX_TYPE_FILE      0
398 #define UNIX_TYPE_DIR       1
399 #define UNIX_TYPE_SYMLINK   2
400 #define UNIX_TYPE_CHARDEV   3
401 #define UNIX_TYPE_BLKDEV    4
402 #define UNIX_TYPE_FIFO      5
403 #define UNIX_TYPE_SOCKET    6
404 #define UNIX_TYPE_UNKNOWN   0xFFFFFFFF
405
406 /*
407  * Oh this is fun. "Standard UNIX permissions" has no
408  * meaning in POSIX. We need to define the mapping onto
409  * and off the wire as this was not done in the original HP
410  * spec. JRA.
411  */
412
413 #define UNIX_X_OTH                      0000001
414 #define UNIX_W_OTH                      0000002
415 #define UNIX_R_OTH                      0000004
416 #define UNIX_X_GRP                      0000010
417 #define UNIX_W_GRP                      0000020
418 #define UNIX_R_GRP                      0000040
419 #define UNIX_X_USR                      0000100
420 #define UNIX_W_USR                      0000200
421 #define UNIX_R_USR                      0000400
422 #define UNIX_STICKY                     0001000
423 #define UNIX_SET_GID                    0002000
424 #define UNIX_SET_UID                    0004000
425
426 /* Masks for the above */
427 #define UNIX_OTH_MASK                   0000007
428 #define UNIX_GRP_MASK                   0000070
429 #define UNIX_USR_MASK                   0000700
430 #define UNIX_PERM_MASK                  0000777
431 #define UNIX_EXTRA_MASK                 0007000
432 #define UNIX_ALL_MASK                   0007777
433
434 /* Flags for the file_flags field in UNIX_INFO2: */
435 #define EXT_SECURE_DELETE               0x00000001
436 #define EXT_ENABLE_UNDELETE             0x00000002
437 #define EXT_SYNCHRONOUS                 0x00000004
438 #define EXT_IMMUTABLE                   0x00000008
439 #define EXT_OPEN_APPEND_ONLY            0x00000010
440 #define EXT_DO_NOT_BACKUP               0x00000020
441 #define EXT_NO_UPDATE_ATIME             0x00000040
442 #define EXT_HIDDEN                      0x00000080
443
444 #define SMB_QFILEINFO_UNIX_LINK         0x201
445 #define SMB_SFILEINFO_UNIX_LINK         0x201
446 #define SMB_SFILEINFO_UNIX_HLINK        0x203
447
448 /*
449  Info level for QVOLINFO - returns version of CIFS UNIX extensions, plus
450  64-bits worth of capability fun :-).
451 */
452
453 #define SMB_QUERY_CIFS_UNIX_INFO      0x200
454
455 /* Returns the following.
456
457   UINT16             major version number
458   UINT16             minor version number
459   LARGE_INTEGER      capability bitfield
460
461 */
462
463 #define CIFS_UNIX_MAJOR_VERSION 1
464 #define CIFS_UNIX_MINOR_VERSION 0
465
466 #define CIFS_UNIX_FCNTL_LOCKS_CAP           0x1
467 #define CIFS_UNIX_POSIX_ACLS_CAP            0x2
468
469 /* ... more as we think of them :-). */
470
471 #endif