2 Unix SMB/CIFS implementation.
4 SMB2 client library header
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 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 __LIBCLI_SMB2_SMB2_CONSTANTS_H__
23 #define __LIBCLI_SMB2_SMB2_CONSTANTS_H__
25 /* offsets into header elements for a sync SMB2 request */
26 #define SMB2_HDR_PROTOCOL_ID 0x00
27 #define SMB2_HDR_LENGTH 0x04
28 #define SMB2_HDR_EPOCH 0x06
29 #define SMB2_HDR_STATUS 0x08
30 #define SMB2_HDR_OPCODE 0x0c
31 #define SMB2_HDR_CREDIT 0x0e
32 #define SMB2_HDR_FLAGS 0x10
33 #define SMB2_HDR_NEXT_COMMAND 0x14
34 #define SMB2_HDR_MESSAGE_ID 0x18
35 #define SMB2_HDR_PID 0x20
36 #define SMB2_HDR_TID 0x24
37 #define SMB2_HDR_SESSION_ID 0x28
38 #define SMB2_HDR_SIGNATURE 0x30 /* 16 bytes */
39 #define SMB2_HDR_BODY 0x40
42 #define SMB2_HDR_FLAG_REDIRECT 0x01
43 #define SMB2_HDR_FLAG_ASYNC 0x02
44 #define SMB2_HDR_FLAG_CHAINED 0x04
45 #define SMB2_HDR_FLAG_SIGNED 0x08
46 #define SMB2_HDR_FLAG_DFS 0x10000000
49 #define SMB2_OP_NEGPROT 0x00
50 #define SMB2_OP_SESSSETUP 0x01
51 #define SMB2_OP_LOGOFF 0x02
52 #define SMB2_OP_TCON 0x03
53 #define SMB2_OP_TDIS 0x04
54 #define SMB2_OP_CREATE 0x05
55 #define SMB2_OP_CLOSE 0x06
56 #define SMB2_OP_FLUSH 0x07
57 #define SMB2_OP_READ 0x08
58 #define SMB2_OP_WRITE 0x09
59 #define SMB2_OP_LOCK 0x0a
60 #define SMB2_OP_IOCTL 0x0b
61 #define SMB2_OP_CANCEL 0x0c
62 #define SMB2_OP_KEEPALIVE 0x0d
63 #define SMB2_OP_FIND 0x0e
64 #define SMB2_OP_NOTIFY 0x0f
65 #define SMB2_OP_GETINFO 0x10
66 #define SMB2_OP_SETINFO 0x11
67 #define SMB2_OP_BREAK 0x12
69 #define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */
71 /* the dialects we support */
72 #define SMB2_DIALECT_REVISION 0x202
73 #define SMB21_DIALECT_REVISION 0x210
74 #define SMB2_LONGHORN_BETA_DIALECT_REVISION 0x0 /* early beta dialect */
76 /* SMB2 negotiate security_mode */
77 #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x01
78 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x02
80 /* SMB2 capabilities - only 1 so far. I'm sure more will be added */
81 #define SMB2_CAP_DFS 0x00000001
82 /* so we can spot new caps as added */
83 #define SMB2_CAP_ALL SMB2_CAP_DFS
85 /* SMB2 share flags */
86 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x0000
87 #define SMB2_SHAREFLAG_AUTO_CACHING 0x0010
88 #define SMB2_SHAREFLAG_VDO_CACHING 0x0020
89 #define SMB2_SHAREFLAG_NO_CACHING 0x0030
90 #define SMB2_SHAREFLAG_DFS 0x0001
91 #define SMB2_SHAREFLAG_DFS_ROOT 0x0002
92 #define SMB2_SHAREFLAG_RESTRICT_EXCLUSIVE_OPENS 0x0100
93 #define SMB2_SHAREFLAG_FORCE_SHARED_DELETE 0x0200
94 #define SMB2_SHAREFLAG_ALLOW_NAMESPACE_CACHING 0x0400
95 #define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM 0x0800
96 #define SMB2_SHAREFLAG_ALL 0x0F33
98 /* SMB2 create security flags */
99 #define SMB2_SECURITY_DYNAMIC_TRACKING 0x01
100 #define SMB2_SECURITY_EFFECTIVE_ONLY 0x02
102 /* SMB2 requested oplock levels */
103 #define SMB2_OPLOCK_LEVEL_NONE 0x00
104 #define SMB2_OPLOCK_LEVEL_II 0x01
105 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
106 #define SMB2_OPLOCK_LEVEL_BATCH 0x09
107 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
109 /* SMB2 lease bits */
110 #define SMB2_LEASE_NONE 0x00
111 #define SMB2_LEASE_READ 0x01
112 #define SMB2_LEASE_HANDLE 0x02
113 #define SMB2_LEASE_WRITE 0x04
115 /* SMB2 lease break flags */
116 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED 0x01
118 /* SMB2 impersonation levels */
119 #define SMB2_IMPERSONATION_ANONYMOUS 0x00
120 #define SMB2_IMPERSONATION_IDENTIFICATION 0x01
121 #define SMB2_IMPERSONATION_IMPERSONATION 0x02
122 #define SMB2_IMPERSONATION_DELEGATE 0x03
124 /* SMB2 create tags */
125 #define SMB2_CREATE_TAG_EXTA "ExtA"
126 #define SMB2_CREATE_TAG_MXAC "MxAc"
127 #define SMB2_CREATE_TAG_SECD "SecD"
128 #define SMB2_CREATE_TAG_DHNQ "DHnQ"
129 #define SMB2_CREATE_TAG_DHNC "DHnC"
130 #define SMB2_CREATE_TAG_ALSI "AlSi"
131 #define SMB2_CREATE_TAG_TWRP "TWrp"
132 #define SMB2_CREATE_TAG_QFID "QFid"
133 #define SMB2_CREATE_TAG_RQLS "RqLs"
135 /* SMB2 Create ignore some more create_options */
136 #define SMB2_CREATE_OPTIONS_NOT_SUPPORTED_MASK (NTCREATEX_OPTIONS_TREE_CONNECTION | \
137 NTCREATEX_OPTIONS_OPFILTER)