libcli/smb: add IO_REPARSE_TAG_RESERVED_ZERO
[Samba.git] / libcli / smb / smb_constants.h
blobead047d924fcdb90923a924be811b58fe7b4ae8e
1 /*
2 Unix SMB/CIFS implementation.
4 SMB parameters and setup, plus a whole lot more.
6 Copyright (C) Andrew Tridgell 2011
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.
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, see <http://www.gnu.org/licenses/>.
22 #ifndef _SMB_CONSTANTS_H
23 #define _SMB_CONSTANTS_H
26 * Netbios over TCP (rfc 1002)
28 #define NBSSmessage 0x00 /* session message */
29 #define NBSSrequest 0x81 /* session request */
30 #define NBSSpositive 0x82 /* positive session response */
31 #define NBSSnegative 0x83 /* negative session response */
32 #define NBSSretarget 0x84 /* retarget session response */
33 #define NBSSkeepalive 0x85 /* keepalive */
35 #define SMB_MAGIC 0x424D53FF /* 0xFF 'S' 'M' 'B' */
37 /* the basic packet size, assuming no words or bytes. Does not include the NBT header */
38 #define MIN_SMB_SIZE 35
40 /* when using NBT encapsulation every packet has a 4 byte header */
41 #define NBT_HDR_SIZE 4
43 /* offsets into message header for common items - NOTE: These have
44 changed from being offsets from the base of the NBT packet to the base of the SMB packet.
45 this has reduced all these values by 4
47 #define HDR_COM 4
48 #define HDR_RCLS 5
49 #define HDR_REH 6
50 #define HDR_ERR 7
51 #define HDR_FLG 9
52 #define HDR_FLG2 10
53 #define HDR_PIDHIGH 12
54 #define HDR_SS_FIELD 14
55 #define HDR_TID 24
56 #define HDR_PID 26
57 #define HDR_UID 28
58 #define HDR_MID 30
59 #define HDR_WCT 32
60 #define HDR_VWV 33
62 /* Macros for accessing SMB protocol elements */
63 #define VWV(vwv) ((vwv)*2)
65 #define smb_len_nbt(buf) (RIVAL(buf, 0) & 0x1FFFF)
66 #define _smb_setlen_nbt(buf,len) RSIVAL(buf, 0, (len) & 0x1FFFF)
67 #define smb_setlen_nbt(buf, len) do { \
68 _smb_setlen_nbt(buf, len); \
69 SIVAL(buf, 4, SMB_MAGIC); \
70 } while (0)
72 #define smb_len_tcp(buf) (RIVAL(buf, 0) & 0xFFFFFF)
73 #define _smb_setlen_tcp(buf,len) RSIVAL(buf, 0, (len) & 0xFFFFFF)
74 #define smb_setlen_tcp(buf, len) do { \
75 _smb_setlen_tcp(buf, len); \
76 SIVAL(buf, 4, SMB_MAGIC); \
77 } while (0)
79 /* protocol types. It assumes that higher protocols include lower protocols
80 as subsets. */
81 enum protocol_types {
82 PROTOCOL_DEFAULT=-1,
83 PROTOCOL_NONE=0,
84 PROTOCOL_CORE,
85 PROTOCOL_COREPLUS,
86 PROTOCOL_LANMAN1,
87 PROTOCOL_LANMAN2,
88 PROTOCOL_NT1,
89 PROTOCOL_SMB2_02,
90 PROTOCOL_SMB2_10,
91 PROTOCOL_SMB3_00,
92 PROTOCOL_SMB3_02,
93 PROTOCOL_SMB3_11
95 #define PROTOCOL_LATEST PROTOCOL_SMB3_11
97 enum smb_signing_setting {
98 SMB_SIGNING_IPC_DEFAULT = -2, /* Only used in C code */
99 SMB_SIGNING_DEFAULT = -1,
100 SMB_SIGNING_OFF = 0,
101 SMB_SIGNING_IF_REQUIRED = 1,
102 SMB_SIGNING_DESIRED = 2,
103 SMB_SIGNING_REQUIRED = 3,
106 /* This MUST align with 'enum smb_signing_setting' */
107 enum smb_encryption_setting {
108 SMB_ENCRYPTION_DEFAULT = SMB_SIGNING_DEFAULT,
109 SMB_ENCRYPTION_OFF = SMB_SIGNING_OFF,
110 SMB_ENCRYPTION_IF_REQUIRED = SMB_SIGNING_IF_REQUIRED,
111 SMB_ENCRYPTION_DESIRED = SMB_SIGNING_DESIRED,
112 SMB_ENCRYPTION_REQUIRED = SMB_SIGNING_REQUIRED,
115 /* types of buffers in core SMB protocol */
116 #define SMB_DATA_BLOCK 0x1
117 #define SMB_ASCII4 0x4
119 /* flag defines. CIFS spec 3.1.1 */
120 #define FLAG_SUPPORT_LOCKREAD 0x01
121 #define FLAG_CLIENT_BUF_AVAIL 0x02
122 #define FLAG_RESERVED 0x04
123 #define FLAG_CASELESS_PATHNAMES 0x08
124 #define FLAG_CANONICAL_PATHNAMES 0x10
125 #define FLAG_REQUEST_OPLOCK 0x20
126 #define FLAG_REQUEST_BATCH_OPLOCK 0x40
127 #define FLAG_REPLY 0x80
129 /* the complete */
130 #define SMBmkdir 0x00 /* create directory */
131 #define SMBrmdir 0x01 /* delete directory */
132 #define SMBopen 0x02 /* open file */
133 #define SMBcreate 0x03 /* create file */
134 #define SMBclose 0x04 /* close file */
135 #define SMBflush 0x05 /* flush file */
136 #define SMBunlink 0x06 /* delete file */
137 #define SMBmv 0x07 /* rename file */
138 #define SMBgetatr 0x08 /* get file attributes */
139 #define SMBsetatr 0x09 /* set file attributes */
140 #define SMBread 0x0A /* read from file */
141 #define SMBwrite 0x0B /* write to file */
142 #define SMBlock 0x0C /* lock byte range */
143 #define SMBunlock 0x0D /* unlock byte range */
144 #define SMBctemp 0x0E /* create temporary file */
145 #define SMBmknew 0x0F /* make new file */
146 #define SMBcheckpath 0x10 /* check directory path */
147 #define SMBexit 0x11 /* process exit */
148 #define SMBlseek 0x12 /* seek */
149 #define SMBtcon 0x70 /* tree connect */
150 #define SMBtconX 0x75 /* tree connect and X*/
151 #define SMBtdis 0x71 /* tree disconnect */
152 #define SMBnegprot 0x72 /* negotiate protocol */
153 #define SMBdskattr 0x80 /* get disk attributes */
154 #define SMBsearch 0x81 /* search directory */
155 #define SMBsplopen 0xC0 /* open print spool file */
156 #define SMBsplwr 0xC1 /* write to print spool file */
157 #define SMBsplclose 0xC2 /* close print spool file */
158 #define SMBsplretq 0xC3 /* return print queue */
159 #define SMBsends 0xD0 /* send single block message */
160 #define SMBsendb 0xD1 /* send broadcast message */
161 #define SMBfwdname 0xD2 /* forward user name */
162 #define SMBcancelf 0xD3 /* cancel forward */
163 #define SMBgetmac 0xD4 /* get machine name */
164 #define SMBsendstrt 0xD5 /* send start of multi-block message */
165 #define SMBsendend 0xD6 /* send end of multi-block message */
166 #define SMBsendtxt 0xD7 /* send text of multi-block message */
168 /* Core+ protocol */
169 #define SMBlockread 0x13 /* Lock a range and read */
170 #define SMBwriteunlock 0x14 /* Unlock a range then write */
171 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
172 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
173 #define SMBwritec 0x20 /* secondary write request */
174 #define SMBwriteclose 0x2c /* write a file then close it */
176 /* dos extended protocol */
177 #define SMBreadBraw 0x1A /* read block raw */
178 #define SMBreadBmpx 0x1B /* read block multiplexed */
179 #define SMBreadBs 0x1C /* read block (secondary response) */
180 #define SMBwriteBraw 0x1D /* write block raw */
181 #define SMBwriteBmpx 0x1E /* write block multiplexed */
182 #define SMBwriteBs 0x1F /* write block (secondary request) */
183 #define SMBwriteC 0x20 /* write complete response */
184 #define SMBsetattrE 0x22 /* set file attributes expanded */
185 #define SMBgetattrE 0x23 /* get file attributes expanded */
186 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
187 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
188 #define SMBtranss 0x26 /* transaction (secondary request/response) */
189 #define SMBioctl 0x27 /* IOCTL */
190 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
191 #define SMBcopy 0x29 /* copy */
192 #define SMBmove 0x2A /* move */
193 #define SMBecho 0x2B /* echo */
194 #define SMBopenX 0x2D /* open and X */
195 #define SMBreadX 0x2E /* read and X */
196 #define SMBwriteX 0x2F /* write and X */
197 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
198 #define SMBffirst 0x82 /* find first */
199 #define SMBfunique 0x83 /* find unique */
200 #define SMBfclose 0x84 /* find close */
201 #define SMBinvalid 0xFE /* invalid command */
203 /* Extended 2.0 protocol */
204 #define SMBtrans2 0x32 /* TRANS2 protocol set */
205 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
206 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
207 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
208 #define SMBulogoffX 0x74 /* user logoff */
210 /* NT SMB extensions. */
211 #define SMBnttrans 0xA0 /* NT transact */
212 #define SMBnttranss 0xA1 /* NT transact secondary */
213 #define SMBntcreateX 0xA2 /* NT create and X */
214 #define SMBntcancel 0xA4 /* NT cancel */
215 #define SMBntrename 0xA5 /* NT rename */
217 /* used to indicate end of chain */
218 #define SMB_CHAIN_NONE 0xFF
220 /* Sercurity mode bits. */
221 #define NEGOTIATE_SECURITY_USER_LEVEL 0x01
222 #define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE 0x02
223 #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
224 #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
227 * The negotiated buffer size for non LARGE_READX/WRITEX
228 * should be limited to uint16_t and has to be at least
229 * 500, which is the default for MinClientBufferSize on Windows.
231 #define SMB_BUFFER_SIZE_MIN 500
232 #define SMB_BUFFER_SIZE_MAX 65535
234 /* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
236 #define CAP_RAW_MODE 0x00000001
237 #define CAP_MPX_MODE 0x00000002
238 #define CAP_UNICODE 0x00000004
239 #define CAP_LARGE_FILES 0x00000008
240 #define CAP_NT_SMBS 0x00000010
241 #define CAP_RPC_REMOTE_APIS 0x00000020
242 #define CAP_STATUS32 0x00000040
243 #define CAP_LEVEL_II_OPLOCKS 0x00000080
244 #define CAP_LOCK_AND_READ 0x00000100
245 #define CAP_NT_FIND 0x00000200
246 #define CAP_DFS 0x00001000
247 #define CAP_W2K_SMBS 0x00002000
248 #define CAP_LARGE_READX 0x00004000
249 #define CAP_LARGE_WRITEX 0x00008000
250 #define CAP_LWIO 0x00010000
251 #define CAP_UNIX 0x00800000 /* Capabilities for UNIX extensions. Created by HP. */
252 #define CAP_DYNAMIC_REAUTH 0x20000000
253 #define CAP_EXTENDED_SECURITY 0x80000000
255 #define SMB_CAP_BOTH_MASK ( \
256 CAP_UNICODE | \
257 CAP_NT_SMBS | \
258 CAP_STATUS32 | \
259 CAP_LEVEL_II_OPLOCKS | \
260 CAP_EXTENDED_SECURITY | \
262 #define SMB_CAP_SERVER_MASK ( \
263 CAP_RAW_MODE | \
264 CAP_MPX_MODE | \
265 CAP_LARGE_FILES | \
266 CAP_RPC_REMOTE_APIS | \
267 CAP_LOCK_AND_READ | \
268 CAP_NT_FIND | \
269 CAP_DFS | \
270 CAP_W2K_SMBS | \
271 CAP_LARGE_READX | \
272 CAP_LARGE_WRITEX | \
273 CAP_LWIO | \
274 CAP_UNIX | \
276 #define SMB_CAP_CLIENT_MASK ( \
277 CAP_DYNAMIC_REAUTH | \
280 * Older Samba releases (<= 3.6.x)
281 * expect the client to send CAP_LARGE_READX
282 * in order to let the client use large reads.
284 #define SMB_CAP_LEGACY_CLIENT_MASK ( \
285 SMB_CAP_CLIENT_MASK | \
286 CAP_LARGE_READX | \
287 CAP_LARGE_WRITEX | \
291 * The action flags in the SMB session setup response
293 #define SMB_SETUP_GUEST 0x0001
294 #define SMB_SETUP_USE_LANMAN_KEY 0x0002
296 /* Client-side offline caching policy types */
297 enum csc_policy {
298 CSC_POLICY_MANUAL=0,
299 CSC_POLICY_DOCUMENTS=1,
300 CSC_POLICY_PROGRAMS=2,
301 CSC_POLICY_DISABLE=3
304 /* TCONX Flag (smb_vwv2). [MS-SMB] 2.2.4.7.1 */
305 #define TCONX_FLAG_DISCONNECT_TID 0x0001
306 #define TCONX_FLAG_EXTENDED_SIGNATURES 0x0004
307 #define TCONX_FLAG_EXTENDED_RESPONSE 0x0008
309 /* this is used on a TConX. [MS-SMB] 2.2.4.7.2 */
310 #define SMB_SUPPORT_SEARCH_BITS 0x0001
311 #define SMB_SHARE_IN_DFS 0x0002
312 #define SMB_CSC_MASK 0x000C
313 #define SMB_CSC_POLICY_SHIFT 2
314 #define SMB_UNIQUE_FILE_NAME 0x0010
315 #define SMB_EXTENDED_SIGNATURES 0x0020
317 /* NT Flags2 bits - cifs6.txt section 3.1.2 */
318 #define FLAGS2_LONG_PATH_COMPONENTS 0x0001
319 #define FLAGS2_EXTENDED_ATTRIBUTES 0x0002
320 #define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
321 #define FLAGS2_COMPRESSED 0x0008 /* MS-SMB */
322 #define FLAGS2_SMB_SECURITY_SIGNATURES_REQUIRED 0x0010
323 #define FLAGS2_IS_LONG_NAME 0x0040
324 #define FLAGS2_REPARSE_PATH 0x0400 /* MS-SMB @GMT- path. */
325 #define FLAGS2_EXTENDED_SECURITY 0x0800
326 #define FLAGS2_DFS_PATHNAMES 0x1000
327 #define FLAGS2_READ_PERMIT_EXECUTE 0x2000
328 #define FLAGS2_32_BIT_ERROR_CODES 0x4000
329 #define FLAGS2_UNICODE_STRINGS 0x8000
331 /* FileAttributes (search attributes) field */
332 #define FILE_ATTRIBUTES_INVALID 0x0000L
333 #define FILE_ATTRIBUTE_READONLY 0x0001L
334 #define FILE_ATTRIBUTE_HIDDEN 0x0002L
335 #define FILE_ATTRIBUTE_SYSTEM 0x0004L
336 #define FILE_ATTRIBUTE_VOLUME 0x0008L
337 #define FILE_ATTRIBUTE_DIRECTORY 0x0010L
338 #define FILE_ATTRIBUTE_ARCHIVE 0x0020L
339 #define FILE_ATTRIBUTE_DEVICE 0x0040L
340 #define FILE_ATTRIBUTE_NORMAL 0x0080L
341 #define FILE_ATTRIBUTE_TEMPORARY 0x0100L
342 #define FILE_ATTRIBUTE_SPARSE 0x0200L
343 #define FILE_ATTRIBUTE_REPARSE_POINT 0x0400L
344 #define FILE_ATTRIBUTE_COMPRESSED 0x0800L
345 #define FILE_ATTRIBUTE_OFFLINE 0x1000L
346 #define FILE_ATTRIBUTE_NONINDEXED 0x2000L
347 #define FILE_ATTRIBUTE_ENCRYPTED 0x4000L
348 #define FILE_ATTRIBUTE_ALL_MASK 0x7FFFL
350 #define SAMBA_ATTRIBUTES_MASK (FILE_ATTRIBUTE_READONLY|\
351 FILE_ATTRIBUTE_HIDDEN|\
352 FILE_ATTRIBUTE_SYSTEM|\
353 FILE_ATTRIBUTE_DIRECTORY|\
354 FILE_ATTRIBUTE_ARCHIVE|\
355 FILE_ATTRIBUTE_OFFLINE)
357 /* File type flags */
358 #define FILE_TYPE_DISK 0
359 #define FILE_TYPE_BYTE_MODE_PIPE 1
360 #define FILE_TYPE_MESSAGE_MODE_PIPE 2
361 #define FILE_TYPE_PRINTER 3
362 #define FILE_TYPE_COMM_DEVICE 4
363 #define FILE_TYPE_UNKNOWN 0xFFFF
365 /* Lock types. */
366 #define LOCKING_ANDX_EXCLUSIVE_LOCK 0x00
367 #define LOCKING_ANDX_SHARED_LOCK 0x01
368 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
369 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
370 #define LOCKING_ANDX_CANCEL_LOCK 0x08
371 #define LOCKING_ANDX_LARGE_FILES 0x10
374 * Bits we test with.
377 #define OPLOCK_NONE 0
378 #define OPLOCK_EXCLUSIVE 1
379 #define OPLOCK_BATCH 2
380 #define OPLOCK_LEVEL_II 4
382 #define CORE_OPLOCK_GRANTED (1<<5)
383 #define EXTENDED_OPLOCK_GRANTED (1<<15)
386 * Return values for oplock types.
389 #define NO_OPLOCK_RETURN 0
390 #define EXCLUSIVE_OPLOCK_RETURN 1
391 #define BATCH_OPLOCK_RETURN 2
392 #define LEVEL_II_OPLOCK_RETURN 3
394 /* oplock levels sent in oplock break */
395 #define OPLOCK_BREAK_TO_NONE 0
396 #define OPLOCK_BREAK_TO_LEVEL_II 1
398 /* Filesystem Attributes. */
399 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
400 #define FILE_CASE_PRESERVED_NAMES 0x00000002
401 #define FILE_UNICODE_ON_DISK 0x00000004
402 /* According to cifs9f, this is 4, not 8 */
403 /* According to testing, this actually sets the security attribute! */
404 #define FILE_PERSISTENT_ACLS 0x00000008
405 #define FILE_FILE_COMPRESSION 0x00000010
406 #define FILE_VOLUME_QUOTAS 0x00000020
407 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
408 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
409 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
410 #define FS_LFN_APIS 0x00004000
411 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
412 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
413 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
414 #define FILE_NAMED_STREAMS 0x00040000
415 #define FILE_READ_ONLY_VOLUME 0x00080000
416 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
418 /* ShareAccess field. */
419 #define FILE_SHARE_NONE 0 /* Cannot be used in bitmask. */
420 #define FILE_SHARE_READ 1
421 #define FILE_SHARE_WRITE 2
422 #define FILE_SHARE_DELETE 4
424 /* Flags - combined with attributes. */
425 #define FILE_FLAG_WRITE_THROUGH 0x80000000L
426 #define FILE_FLAG_NO_BUFFERING 0x20000000L
427 #define FILE_FLAG_RANDOM_ACCESS 0x10000000L
428 #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000L
429 #define FILE_FLAG_DELETE_ON_CLOSE 0x04000000L
430 #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000L
431 #define FILE_FLAG_POSIX_SEMANTICS 0x01000000L
433 /* CreateDisposition field. */
434 #define FILE_SUPERSEDE 0 /* File exists overwrite/supersede. File not exist create. */
435 #define FILE_OPEN 1 /* File exists open. File not exist fail. */
436 #define FILE_CREATE 2 /* File exists fail. File not exist create. */
437 #define FILE_OPEN_IF 3 /* File exists open. File not exist create. */
438 #define FILE_OVERWRITE 4 /* File exists overwrite. File not exist fail. */
439 #define FILE_OVERWRITE_IF 5 /* File exists overwrite. File not exist create. */
441 /* CreateOptions field. */
442 #define FILE_DIRECTORY_FILE 0x0001
443 #define FILE_WRITE_THROUGH 0x0002
444 #define FILE_SEQUENTIAL_ONLY 0x0004
445 #define FILE_NO_INTERMEDIATE_BUFFERING 0x0008
446 #define FILE_SYNCHRONOUS_IO_ALERT 0x0010 /* may be ignored */
447 #define FILE_SYNCHRONOUS_IO_NONALERT 0x0020 /* may be ignored */
448 #define FILE_NON_DIRECTORY_FILE 0x0040
449 #define FILE_CREATE_TREE_CONNECTION 0x0080 /* ignore, should be zero */
450 #define FILE_COMPLETE_IF_OPLOCKED 0x0100 /* ignore, should be zero */
451 #define FILE_NO_EA_KNOWLEDGE 0x0200
452 #define FILE_EIGHT_DOT_THREE_ONLY 0x0400 /* aka OPEN_FOR_RECOVERY: ignore, should be zero */
453 #define FILE_RANDOM_ACCESS 0x0800
454 #define FILE_DELETE_ON_CLOSE 0x1000
455 #define FILE_OPEN_BY_FILE_ID 0x2000
456 #define FILE_OPEN_FOR_BACKUP_INTENT 0x4000
457 #define FILE_NO_COMPRESSION 0x8000
458 #define FILE_RESERVER_OPFILTER 0x00100000 /* ignore, should be zero */
459 #define FILE_OPEN_REPARSE_POINT 0x00200000
460 #define FILE_OPEN_NO_RECALL 0x00400000
461 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 /* ignore should be zero */
463 /* Responses when opening a file. */
464 #define FILE_WAS_SUPERSEDED 0
465 #define FILE_WAS_OPENED 1
466 #define FILE_WAS_CREATED 2
467 #define FILE_WAS_OVERWRITTEN 3
469 /* These are the trans subcommands */
470 #define TRANSACT_SETNAMEDPIPEHANDLESTATE 0x01
471 #define TRANSACT_DCERPCCMD 0x26
472 #define TRANSACT_WAITNAMEDPIPEHANDLESTATE 0x53
474 /* These are the TRANS2 sub commands */
475 #define TRANSACT2_OPEN 0
476 #define TRANSACT2_FINDFIRST 1
477 #define TRANSACT2_FINDNEXT 2
478 #define TRANSACT2_QFSINFO 3
479 #define TRANSACT2_SETFSINFO 4
480 #define TRANSACT2_QPATHINFO 5
481 #define TRANSACT2_SETPATHINFO 6
482 #define TRANSACT2_QFILEINFO 7
483 #define TRANSACT2_SETFILEINFO 8
484 #define TRANSACT2_FSCTL 9
485 #define TRANSACT2_IOCTL 0xA
486 #define TRANSACT2_FINDNOTIFYFIRST 0xB
487 #define TRANSACT2_FINDNOTIFYNEXT 0xC
488 #define TRANSACT2_MKDIR 0xD
489 #define TRANSACT2_SESSION_SETUP 0xE
490 #define TRANSACT2_GET_DFS_REFERRAL 0x10
491 #define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
493 /* These are the NT transact sub commands. */
494 #define NT_TRANSACT_CREATE 1
495 #define NT_TRANSACT_IOCTL 2
496 #define NT_TRANSACT_SET_SECURITY_DESC 3
497 #define NT_TRANSACT_NOTIFY_CHANGE 4
498 #define NT_TRANSACT_RENAME 5
499 #define NT_TRANSACT_QUERY_SECURITY_DESC 6
500 #define NT_TRANSACT_GET_USER_QUOTA 7
501 #define NT_TRANSACT_SET_USER_QUOTA 8
503 /* ioctl codes */
504 #define IOCTL_QUERY_JOB_INFO 0x530060
506 /* filesystem control codes */
507 #define FSCTL_METHOD_BUFFERED 0x00000000
508 #define FSCTL_METHOD_IN_DIRECT 0x00000001
509 #define FSCTL_METHOD_OUT_DIRECT 0x00000002
510 #define FSCTL_METHOD_NEITHER 0x00000003
512 #define FSCTL_ACCESS_ANY 0x00000000
513 #define FSCTL_ACCESS_READ 0x00004000
514 #define FSCTL_ACCESS_WRITE 0x00008000
516 #define IOCTL_DEV_TYPE_MASK 0xFFFF0000
518 #define FSCTL_DFS 0x00060000
519 #define FSCTL_DFS_GET_REFERRALS (FSCTL_DFS | FSCTL_ACCESS_ANY | 0x0194 | FSCTL_METHOD_BUFFERED)
520 #define FSCTL_DFS_GET_REFERRALS_EX (FSCTL_DFS | FSCTL_ACCESS_ANY | 0x01B0 | FSCTL_METHOD_BUFFERED)
522 #define FSCTL_FILESYSTEM 0x00090000
523 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0000 | FSCTL_METHOD_BUFFERED)
524 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0004 | FSCTL_METHOD_BUFFERED)
525 #define FSCTL_REQUEST_BATCH_OPLOCK (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0008 | FSCTL_METHOD_BUFFERED)
526 #define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x000C | FSCTL_METHOD_BUFFERED)
527 #define FSCTL_OPBATCH_ACK_CLOSE_PENDING (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0010 | FSCTL_METHOD_BUFFERED)
528 #define FSCTL_OPLOCK_BREAK_NOTIFY (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0014 | FSCTL_METHOD_BUFFERED)
529 #define FSCTL_GET_COMPRESSION (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x003C | FSCTL_METHOD_BUFFERED)
530 #define FSCTL_SET_COMPRESSION (FSCTL_FILESYSTEM | FSCTL_ACCESS_READ \
531 | FSCTL_ACCESS_WRITE | 0x0040 | FSCTL_METHOD_BUFFERED)
532 #define FSCTL_FILESYS_GET_STATISTICS (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0060 | FSCTL_METHOD_BUFFERED)
533 #define FSCTL_GET_NTFS_VOLUME_DATA (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0064 | FSCTL_METHOD_BUFFERED)
534 #define FSCTL_IS_VOLUME_DIRTY (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0078 | FSCTL_METHOD_BUFFERED)
535 #define FSCTL_FIND_FILES_BY_SID (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x008C | FSCTL_METHOD_NEITHER)
536 #define FSCTL_SET_OBJECT_ID (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0098 | FSCTL_METHOD_BUFFERED)
537 #define FSCTL_GET_OBJECT_ID (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x009C | FSCTL_METHOD_BUFFERED)
538 #define FSCTL_DELETE_OBJECT_ID (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00A0 | FSCTL_METHOD_BUFFERED)
539 #define FSCTL_SET_REPARSE_POINT (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00A4 | FSCTL_METHOD_BUFFERED)
540 #define FSCTL_GET_REPARSE_POINT (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00A8 | FSCTL_METHOD_BUFFERED)
541 #define FSCTL_DELETE_REPARSE_POINT (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00AC | FSCTL_METHOD_BUFFERED)
542 #define FSCTL_SET_OBJECT_ID_EXTENDED (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00BC | FSCTL_METHOD_BUFFERED)
543 #define FSCTL_CREATE_OR_GET_OBJECT_ID (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00C0 | FSCTL_METHOD_BUFFERED)
544 #define FSCTL_SET_SPARSE (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00C4 | FSCTL_METHOD_BUFFERED)
545 #define FSCTL_SET_ZERO_DATA (FSCTL_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x00C8 | FSCTL_METHOD_BUFFERED)
546 #define FSCTL_SET_ZERO_ON_DEALLOCATION (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0194 | FSCTL_METHOD_BUFFERED)
547 #define FSCTL_READ_FILE_USN_DATA (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00EB | FSCTL_METHOD_BUFFERED)
548 #define FSCTL_WRITE_USN_CLOSE_RECORD (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00EF | FSCTL_METHOD_BUFFERED)
549 #define FSCTL_QUERY_ALLOCATED_RANGES (FSCTL_FILESYSTEM | FSCTL_ACCESS_READ | 0x00CC | FSCTL_METHOD_NEITHER)
550 #define FSCTL_QUERY_ON_DISK_VOLUME_INFO (FSCTL_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x013C | FSCTL_METHOD_BUFFERED)
551 #define FSCTL_QUERY_SPARING_INFO (FSCTL_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x0138 | FSCTL_METHOD_BUFFERED)
552 #define FSCTL_FILE_LEVEL_TRIM (FSCTL_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x0208 | FSCTL_METHOD_BUFFERED)
553 #define FSCTL_OFFLOAD_READ (FSCTL_FILESYSTEM | FSCTL_ACCESS_READ | 0x0264 | FSCTL_METHOD_BUFFERED)
554 #define FSCTL_OFFLOAD_WRITE (FSCTL_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x0268 | FSCTL_METHOD_BUFFERED)
555 #define FSCTL_SET_INTEGRITY_INFORMATION (FSCTL_FILESYSTEM | FSCTL_ACCESS_READ \
556 | FSCTL_ACCESS_WRITE | 0x0280 | FSCTL_METHOD_BUFFERED)
557 /* this one is really FSCTL_DUPLICATE_EXTENTS_TO_FILE in the MS docs: */
558 #define FSCTL_DUP_EXTENTS_TO_FILE (FSCTL_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x0344 | FSCTL_METHOD_BUFFERED)
559 #define FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX (FSCTL_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x03E8 | FSCTL_METHOD_BUFFERED)
560 #define FSCTL_STORAGE_QOS_CONTROL (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0350 | FSCTL_METHOD_BUFFERED)
561 #define FSCTL_SVHDX_SYNC_TUNNEL_REQUEST (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0304 | FSCTL_METHOD_BUFFERED)
562 #define FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT (FSCTL_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0300 | FSCTL_METHOD_BUFFERED)
564 #define FSCTL_NAMED_PIPE 0x00110000
565 #define FSCTL_PIPE_PEEK (FSCTL_NAMED_PIPE | FSCTL_ACCESS_READ | 0x000C | FSCTL_METHOD_BUFFERED)
566 #define FSCTL_NAMED_PIPE_READ_WRITE (FSCTL_NAMED_PIPE | FSCTL_ACCESS_READ \
567 | FSCTL_ACCESS_WRITE | 0x0014 | FSCTL_METHOD_NEITHER)
568 #define FSCTL_PIPE_TRANSCEIVE FSCTL_NAMED_PIPE_READ_WRITE /* SMB2 function name */
569 #define FSCTL_PIPE_WAIT (FSCTL_NAMED_PIPE | FSCTL_ACCESS_ANY | 0x0018 | FSCTL_METHOD_BUFFERED)
571 #define FSCTL_NETWORK_FILESYSTEM 0x00140000
572 #define FSCTL_GET_SHADOW_COPY_DATA (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_READ | 0x0064 | FSCTL_METHOD_BUFFERED)
573 #define FSCTL_SRV_ENUM_SNAPS FSCTL_GET_SHADOW_COPY_DATA /* SMB2 function name */
574 #define FSCTL_SRV_REQUEST_RESUME_KEY (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0078 | FSCTL_METHOD_BUFFERED)
575 #define FSCTL_SRV_COPYCHUNK (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_READ | 0x00F0 | FSCTL_METHOD_OUT_DIRECT)
576 #define FSCTL_SRV_COPYCHUNK_WRITE (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x00F0 | FSCTL_METHOD_OUT_DIRECT)
577 #define FSCTL_SRV_READ_HASH (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_READ| 0x01B8 | FSCTL_METHOD_NEITHER)
578 #define FSCTL_LMR_REQ_RESILIENCY (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_ANY | 0x01D4 | FSCTL_METHOD_BUFFERED)
579 #define FSCTL_LMR_SET_LINK_TRACKING_INFORMATION \
580 (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_ANY | 0x00EC | FSCTL_METHOD_BUFFERED)
581 #define FSCTL_QUERY_NETWORK_INTERFACE_INFO \
582 (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_ANY | 0x01FC | FSCTL_METHOD_BUFFERED)
585 * FSCTL_VALIDATE_NEGOTIATE_INFO_224 was used used in
586 * Windows 8 server beta with SMB 2.24
588 #define FSCTL_VALIDATE_NEGOTIATE_INFO_224 \
589 (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0200 | FSCTL_METHOD_BUFFERED)
590 #define FSCTL_VALIDATE_NEGOTIATE_INFO (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0204 | FSCTL_METHOD_BUFFERED)
593 * For testing various details we use special codes via
594 * smbtorture in order to test failures
596 #define FSCTL_SMBTORTURE 0x83840000
597 #define FSCTL_SMBTORTURE_FORCE_UNACKED_TIMEOUT \
598 (FSCTL_SMBTORTURE | FSCTL_ACCESS_WRITE | 0x0000 | FSCTL_METHOD_NEITHER)
599 #define FSCTL_SMBTORTURE_IOCTL_RESPONSE_BODY_PADDING8 \
600 (FSCTL_SMBTORTURE | FSCTL_ACCESS_WRITE | 0x0010 | FSCTL_METHOD_NEITHER)
601 #define FSCTL_SMBTORTURE_GLOBAL_READ_RESPONSE_BODY_PADDING8 \
602 (FSCTL_SMBTORTURE | FSCTL_ACCESS_WRITE | 0x0020 | FSCTL_METHOD_NEITHER)
603 #define FSCTL_SMBTORTURE_FSP_ASYNC_SLEEP \
604 (FSCTL_SMBTORTURE | FSCTL_ACCESS_WRITE | 0x0040 | FSCTL_METHOD_NEITHER)
607 * A few values from [MS-FSCC] 2.1.2.1 Reparse Tags
610 #define IO_REPARSE_TAG_RESERVED_ZERO 0x00000000
611 #define IO_REPARSE_TAG_SYMLINK 0xA000000C
612 #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
613 #define IO_REPARSE_TAG_HSM 0xC0000004
614 #define IO_REPARSE_TAG_SIS 0x80000007
615 #define IO_REPARSE_TAG_DFS 0x8000000A
616 #define IO_REPARSE_TAG_NFS 0x80000014
619 * Sub-types for IO_REPARSE_TAG_NFS from [MS-FSCC] 2.1.2.6 Network
620 * File System (NFS) Reparse Data Buffer
622 #define NFS_SPECFILE_LNK 0x00000000014B4E4C
623 #define NFS_SPECFILE_CHR 0x0000000000524843
624 #define NFS_SPECFILE_BLK 0x00000000004B4C42
625 #define NFS_SPECFILE_FIFO 0x000000004F464946
626 #define NFS_SPECFILE_SOCK 0x000000004B434F53
629 * Flag from [MS-FSCC] 2.1.2.4 Symbolic Link Reparse Data Buffer
631 #define SYMLINK_FLAG_RELATIVE 0x00000001
634 * Symlink error tag from [MS-SMB2] 2.2.2.2.1 Symbolic Link Error Response
636 #define SYMLINK_ERROR_TAG 0x4C4D5953
639 * Flags according to answer from Dochelp:
640 * https://lists.samba.org/archive/cifs-protocol/2022-November/003909.html
642 #define SYMLINK_ADMIN 0x20000000 /* The symlink creator is an admin */
643 #define SYMLINK_UNTRUSTED 0x10000000 /* The symlink creator is untrusted */
644 #define SYMLINK_TRUST_UNKNOWN 0x00000000 /* The symlink creator is unknown/legacy */
646 #define SYMLINK_TRUST_MASK 0x30000000 /* Encodes the redirection trust level (maps to REDIRECTION_TRUST_LEVEL) */
647 #define SYMLINK_TRUST_SHIFT 28 /* Bits to shift to convert to/from REDIRECTION_TRUST_LEVEL */
649 #endif /* _SMB_CONSTANTS_H */