smb2pdu.h 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. /*
  2. * fs/cifs/smb2pdu.h
  3. *
  4. * Copyright (c) International Business Machines Corp., 2009, 2013
  5. * Etersoft, 2012
  6. * Author(s): Steve French (sfrench@us.ibm.com)
  7. * Pavel Shilovsky (pshilovsky@samba.org) 2012
  8. *
  9. * This library is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as published
  11. * by the Free Software Foundation; either version 2.1 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  17. * the GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #ifndef _SMB2PDU_H
  24. #define _SMB2PDU_H
  25. #include <net/sock.h>
  26. /*
  27. * Note that, due to trying to use names similar to the protocol specifications,
  28. * there are many mixed case field names in the structures below. Although
  29. * this does not match typical Linux kernel style, it is necessary to be
  30. * be able to match against the protocol specfication.
  31. *
  32. * SMB2 commands
  33. * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
  34. * (ie no useful data other than the SMB error code itself) and are marked such.
  35. * Knowing this helps avoid response buffer allocations and copy in some cases.
  36. */
  37. /* List of commands in host endian */
  38. #define SMB2_NEGOTIATE_HE 0x0000
  39. #define SMB2_SESSION_SETUP_HE 0x0001
  40. #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */
  41. #define SMB2_TREE_CONNECT_HE 0x0003
  42. #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */
  43. #define SMB2_CREATE_HE 0x0005
  44. #define SMB2_CLOSE_HE 0x0006
  45. #define SMB2_FLUSH_HE 0x0007 /* trivial resp */
  46. #define SMB2_READ_HE 0x0008
  47. #define SMB2_WRITE_HE 0x0009
  48. #define SMB2_LOCK_HE 0x000A
  49. #define SMB2_IOCTL_HE 0x000B
  50. #define SMB2_CANCEL_HE 0x000C
  51. #define SMB2_ECHO_HE 0x000D
  52. #define SMB2_QUERY_DIRECTORY_HE 0x000E
  53. #define SMB2_CHANGE_NOTIFY_HE 0x000F
  54. #define SMB2_QUERY_INFO_HE 0x0010
  55. #define SMB2_SET_INFO_HE 0x0011
  56. #define SMB2_OPLOCK_BREAK_HE 0x0012
  57. /* The same list in little endian */
  58. #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE)
  59. #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE)
  60. #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE)
  61. #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE)
  62. #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
  63. #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE)
  64. #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE)
  65. #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE)
  66. #define SMB2_READ cpu_to_le16(SMB2_READ_HE)
  67. #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE)
  68. #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE)
  69. #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE)
  70. #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE)
  71. #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE)
  72. #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
  73. #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
  74. #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE)
  75. #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE)
  76. #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
  77. #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF)
  78. #define NUMBER_OF_SMB2_COMMANDS 0x0013
  79. /* 4 len + 52 transform hdr + 64 hdr + 56 create rsp */
  80. #define MAX_SMB2_HDR_SIZE 0x00b0
  81. #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
  82. #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
  83. /*
  84. * SMB2 Header Definition
  85. *
  86. * "MBZ" : Must be Zero
  87. * "BB" : BugBug, Something to check/review/analyze later
  88. * "PDU" : "Protocol Data Unit" (ie a network "frame")
  89. *
  90. */
  91. #define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64)
  92. struct smb2_hdr {
  93. __be32 smb2_buf_length; /* big endian on wire */
  94. /* length is only two or three bytes - with
  95. one or two byte type preceding it that MBZ */
  96. __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */
  97. __le16 StructureSize; /* 64 */
  98. __le16 CreditCharge; /* MBZ */
  99. __le32 Status; /* Error from server */
  100. __le16 Command;
  101. __le16 CreditRequest; /* CreditResponse */
  102. __le32 Flags;
  103. __le32 NextCommand;
  104. __le64 MessageId;
  105. __le32 ProcessId;
  106. __u32 TreeId; /* opaque - so do not make little endian */
  107. __u64 SessionId; /* opaque - so do not make little endian */
  108. __u8 Signature[16];
  109. } __packed;
  110. struct smb2_pdu {
  111. struct smb2_hdr hdr;
  112. __le16 StructureSize2; /* size of wct area (varies, request specific) */
  113. } __packed;
  114. struct smb2_transform_hdr {
  115. __be32 smb2_buf_length; /* big endian on wire */
  116. /* length is only two or three bytes - with
  117. one or two byte type preceding it that MBZ */
  118. __u8 ProtocolId[4]; /* 0xFD 'S' 'M' 'B' */
  119. __u8 Signature[16];
  120. __u8 Nonce[16];
  121. __le32 OriginalMessageSize;
  122. __u16 Reserved1;
  123. __le16 Flags; /* EncryptionAlgorithm */
  124. __u64 SessionId;
  125. } __packed;
  126. /*
  127. * SMB2 flag definitions
  128. */
  129. #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001)
  130. #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
  131. #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
  132. #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
  133. #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
  134. /*
  135. * Definitions for SMB2 Protocol Data Units (network frames)
  136. *
  137. * See MS-SMB2.PDF specification for protocol details.
  138. * The Naming convention is the lower case version of the SMB2
  139. * command code name for the struct. Note that structures must be packed.
  140. *
  141. */
  142. #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
  143. struct smb2_err_rsp {
  144. struct smb2_hdr hdr;
  145. __le16 StructureSize;
  146. __le16 Reserved; /* MBZ */
  147. __le32 ByteCount; /* even if zero, at least one byte follows */
  148. __u8 ErrorData[1]; /* variable length */
  149. } __packed;
  150. struct smb2_symlink_err_rsp {
  151. __le32 SymLinkLength;
  152. __le32 SymLinkErrorTag;
  153. __le32 ReparseTag;
  154. __le16 ReparseDataLength;
  155. __le16 UnparsedPathLength;
  156. __le16 SubstituteNameOffset;
  157. __le16 SubstituteNameLength;
  158. __le16 PrintNameOffset;
  159. __le16 PrintNameLength;
  160. __le32 Flags;
  161. __u8 PathBuffer[0];
  162. } __packed;
  163. #define SMB2_CLIENT_GUID_SIZE 16
  164. struct smb2_negotiate_req {
  165. struct smb2_hdr hdr;
  166. __le16 StructureSize; /* Must be 36 */
  167. __le16 DialectCount;
  168. __le16 SecurityMode;
  169. __le16 Reserved; /* MBZ */
  170. __le32 Capabilities;
  171. __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
  172. /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
  173. __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
  174. __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
  175. __le16 Reserved2;
  176. __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
  177. } __packed;
  178. /* Dialects */
  179. #define SMB20_PROT_ID 0x0202
  180. #define SMB21_PROT_ID 0x0210
  181. #define SMB30_PROT_ID 0x0300
  182. #define SMB302_PROT_ID 0x0302
  183. #define SMB311_PROT_ID 0x0311
  184. #define BAD_PROT_ID 0xFFFF
  185. /* SecurityMode flags */
  186. #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
  187. #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
  188. /* Capabilities flags */
  189. #define SMB2_GLOBAL_CAP_DFS 0x00000001
  190. #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
  191. #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
  192. #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
  193. #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
  194. #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
  195. #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
  196. /* Internal types */
  197. #define SMB2_NT_FIND 0x00100000
  198. #define SMB2_LARGE_FILES 0x00200000
  199. #define SMB311_SALT_SIZE 32
  200. /* Hash Algorithm Types */
  201. #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
  202. struct smb2_preauth_neg_context {
  203. __le16 ContextType; /* 1 */
  204. __le16 DataLength;
  205. __le32 Reserved;
  206. __le16 HashAlgorithmCount; /* 1 */
  207. __le16 SaltLength;
  208. __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
  209. __u8 Salt[SMB311_SALT_SIZE];
  210. } __packed;
  211. /* Encryption Algorithms Ciphers */
  212. #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
  213. #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
  214. struct smb2_encryption_neg_context {
  215. __le16 ContextType; /* 2 */
  216. __le16 DataLength;
  217. __le32 Reserved;
  218. __le16 CipherCount; /* AES-128-GCM and AES-128-CCM */
  219. __le16 Ciphers[2]; /* Ciphers[0] since only one used now */
  220. } __packed;
  221. struct smb2_negotiate_rsp {
  222. struct smb2_hdr hdr;
  223. __le16 StructureSize; /* Must be 65 */
  224. __le16 SecurityMode;
  225. __le16 DialectRevision;
  226. __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
  227. __u8 ServerGUID[16];
  228. __le32 Capabilities;
  229. __le32 MaxTransactSize;
  230. __le32 MaxReadSize;
  231. __le32 MaxWriteSize;
  232. __le64 SystemTime; /* MBZ */
  233. __le64 ServerStartTime;
  234. __le16 SecurityBufferOffset;
  235. __le16 SecurityBufferLength;
  236. __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
  237. __u8 Buffer[1]; /* variable length GSS security buffer */
  238. } __packed;
  239. /* Flags */
  240. #define SMB2_SESSION_REQ_FLAG_BINDING 0x01
  241. #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
  242. struct smb2_sess_setup_req {
  243. struct smb2_hdr hdr;
  244. __le16 StructureSize; /* Must be 25 */
  245. __u8 Flags;
  246. __u8 SecurityMode;
  247. __le32 Capabilities;
  248. __le32 Channel;
  249. __le16 SecurityBufferOffset;
  250. __le16 SecurityBufferLength;
  251. __u64 PreviousSessionId;
  252. __u8 Buffer[1]; /* variable length GSS security buffer */
  253. } __packed;
  254. /* Currently defined SessionFlags */
  255. #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
  256. #define SMB2_SESSION_FLAG_IS_NULL 0x0002
  257. #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
  258. struct smb2_sess_setup_rsp {
  259. struct smb2_hdr hdr;
  260. __le16 StructureSize; /* Must be 9 */
  261. __le16 SessionFlags;
  262. __le16 SecurityBufferOffset;
  263. __le16 SecurityBufferLength;
  264. __u8 Buffer[1]; /* variable length GSS security buffer */
  265. } __packed;
  266. struct smb2_logoff_req {
  267. struct smb2_hdr hdr;
  268. __le16 StructureSize; /* Must be 4 */
  269. __le16 Reserved;
  270. } __packed;
  271. struct smb2_logoff_rsp {
  272. struct smb2_hdr hdr;
  273. __le16 StructureSize; /* Must be 4 */
  274. __le16 Reserved;
  275. } __packed;
  276. /* Flags/Reserved for SMB3.1.1 */
  277. #define SMB2_SHAREFLAG_CLUSTER_RECONNECT 0x0001
  278. struct smb2_tree_connect_req {
  279. struct smb2_hdr hdr;
  280. __le16 StructureSize; /* Must be 9 */
  281. __le16 Reserved; /* Flags in SMB3.1.1 */
  282. __le16 PathOffset;
  283. __le16 PathLength;
  284. __u8 Buffer[1]; /* variable length */
  285. } __packed;
  286. struct smb2_tree_connect_rsp {
  287. struct smb2_hdr hdr;
  288. __le16 StructureSize; /* Must be 16 */
  289. __u8 ShareType; /* see below */
  290. __u8 Reserved;
  291. __le32 ShareFlags; /* see below */
  292. __le32 Capabilities; /* see below */
  293. __le32 MaximalAccess;
  294. } __packed;
  295. /* Possible ShareType values */
  296. #define SMB2_SHARE_TYPE_DISK 0x01
  297. #define SMB2_SHARE_TYPE_PIPE 0x02
  298. #define SMB2_SHARE_TYPE_PRINT 0x03
  299. /*
  300. * Possible ShareFlags - exactly one and only one of the first 4 caching flags
  301. * must be set (any of the remaining, SHI1005, flags may be set individually
  302. * or in combination.
  303. */
  304. #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
  305. #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
  306. #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
  307. #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
  308. #define SHI1005_FLAGS_DFS 0x00000001
  309. #define SHI1005_FLAGS_DFS_ROOT 0x00000002
  310. #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
  311. #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
  312. #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
  313. #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
  314. #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
  315. #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
  316. #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
  317. #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
  318. #define SHI1005_FLAGS_ALL 0x0000FF33
  319. /* Possible share capabilities */
  320. #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
  321. #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
  322. #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
  323. #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
  324. #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
  325. struct smb2_tree_disconnect_req {
  326. struct smb2_hdr hdr;
  327. __le16 StructureSize; /* Must be 4 */
  328. __le16 Reserved;
  329. } __packed;
  330. struct smb2_tree_disconnect_rsp {
  331. struct smb2_hdr hdr;
  332. __le16 StructureSize; /* Must be 4 */
  333. __le16 Reserved;
  334. } __packed;
  335. /* File Attrubutes */
  336. #define FILE_ATTRIBUTE_READONLY 0x00000001
  337. #define FILE_ATTRIBUTE_HIDDEN 0x00000002
  338. #define FILE_ATTRIBUTE_SYSTEM 0x00000004
  339. #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
  340. #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
  341. #define FILE_ATTRIBUTE_NORMAL 0x00000080
  342. #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
  343. #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
  344. #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
  345. #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
  346. #define FILE_ATTRIBUTE_OFFLINE 0x00001000
  347. #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
  348. #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
  349. #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
  350. #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
  351. /* Oplock levels */
  352. #define SMB2_OPLOCK_LEVEL_NONE 0x00
  353. #define SMB2_OPLOCK_LEVEL_II 0x01
  354. #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
  355. #define SMB2_OPLOCK_LEVEL_BATCH 0x09
  356. #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
  357. /* Non-spec internal type */
  358. #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
  359. /* Desired Access Flags */
  360. #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
  361. #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
  362. #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
  363. #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
  364. #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
  365. #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
  366. #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
  367. #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
  368. #define FILE_DELETE_LE cpu_to_le32(0x00010000)
  369. #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
  370. #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
  371. #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
  372. #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
  373. #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
  374. #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
  375. #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
  376. #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
  377. #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
  378. #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
  379. /* ShareAccess Flags */
  380. #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
  381. #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
  382. #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
  383. #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
  384. /* CreateDisposition Flags */
  385. #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
  386. #define FILE_OPEN_LE cpu_to_le32(0x00000001)
  387. #define FILE_CREATE_LE cpu_to_le32(0x00000002)
  388. #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
  389. #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
  390. #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
  391. /* CreateOptions Flags */
  392. #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
  393. /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
  394. #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
  395. #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
  396. #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
  397. #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
  398. #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
  399. #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
  400. #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
  401. #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
  402. #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
  403. #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
  404. #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
  405. #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
  406. #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
  407. #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
  408. #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
  409. #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
  410. #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
  411. #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
  412. | FILE_READ_ATTRIBUTES_LE)
  413. #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
  414. | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
  415. #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
  416. /* Impersonation Levels */
  417. #define IL_ANONYMOUS cpu_to_le32(0x00000000)
  418. #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
  419. #define IL_IMPERSONATION cpu_to_le32(0x00000002)
  420. #define IL_DELEGATE cpu_to_le32(0x00000003)
  421. /* Create Context Values */
  422. #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
  423. #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
  424. #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
  425. #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
  426. #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
  427. #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
  428. #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
  429. #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
  430. #define SMB2_CREATE_REQUEST_LEASE "RqLs"
  431. #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
  432. #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
  433. #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
  434. #define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9
  435. struct smb2_create_req {
  436. struct smb2_hdr hdr;
  437. __le16 StructureSize; /* Must be 57 */
  438. __u8 SecurityFlags;
  439. __u8 RequestedOplockLevel;
  440. __le32 ImpersonationLevel;
  441. __le64 SmbCreateFlags;
  442. __le64 Reserved;
  443. __le32 DesiredAccess;
  444. __le32 FileAttributes;
  445. __le32 ShareAccess;
  446. __le32 CreateDisposition;
  447. __le32 CreateOptions;
  448. __le16 NameOffset;
  449. __le16 NameLength;
  450. __le32 CreateContextsOffset;
  451. __le32 CreateContextsLength;
  452. __u8 Buffer[0];
  453. } __packed;
  454. struct smb2_create_rsp {
  455. struct smb2_hdr hdr;
  456. __le16 StructureSize; /* Must be 89 */
  457. __u8 OplockLevel;
  458. __u8 Reserved;
  459. __le32 CreateAction;
  460. __le64 CreationTime;
  461. __le64 LastAccessTime;
  462. __le64 LastWriteTime;
  463. __le64 ChangeTime;
  464. __le64 AllocationSize;
  465. __le64 EndofFile;
  466. __le32 FileAttributes;
  467. __le32 Reserved2;
  468. __u64 PersistentFileId; /* opaque endianness */
  469. __u64 VolatileFileId; /* opaque endianness */
  470. __le32 CreateContextsOffset;
  471. __le32 CreateContextsLength;
  472. __u8 Buffer[1];
  473. } __packed;
  474. struct create_context {
  475. __le32 Next;
  476. __le16 NameOffset;
  477. __le16 NameLength;
  478. __le16 Reserved;
  479. __le16 DataOffset;
  480. __le32 DataLength;
  481. __u8 Buffer[0];
  482. } __packed;
  483. #define SMB2_LEASE_READ_CACHING_HE 0x01
  484. #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
  485. #define SMB2_LEASE_WRITE_CACHING_HE 0x04
  486. #define SMB2_LEASE_NONE cpu_to_le32(0x00)
  487. #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
  488. #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
  489. #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
  490. #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x02)
  491. #define SMB2_LEASE_KEY_SIZE 16
  492. struct lease_context {
  493. __le64 LeaseKeyLow;
  494. __le64 LeaseKeyHigh;
  495. __le32 LeaseState;
  496. __le32 LeaseFlags;
  497. __le64 LeaseDuration;
  498. } __packed;
  499. struct lease_context_v2 {
  500. __le64 LeaseKeyLow;
  501. __le64 LeaseKeyHigh;
  502. __le32 LeaseState;
  503. __le32 LeaseFlags;
  504. __le64 LeaseDuration;
  505. __le64 ParentLeaseKeyLow;
  506. __le64 ParentLeaseKeyHigh;
  507. __le16 Epoch;
  508. __le16 Reserved;
  509. } __packed;
  510. struct create_lease {
  511. struct create_context ccontext;
  512. __u8 Name[8];
  513. struct lease_context lcontext;
  514. } __packed;
  515. struct create_lease_v2 {
  516. struct create_context ccontext;
  517. __u8 Name[8];
  518. struct lease_context_v2 lcontext;
  519. __u8 Pad[4];
  520. } __packed;
  521. struct create_durable {
  522. struct create_context ccontext;
  523. __u8 Name[8];
  524. union {
  525. __u8 Reserved[16];
  526. struct {
  527. __u64 PersistentFileId;
  528. __u64 VolatileFileId;
  529. } Fid;
  530. } Data;
  531. } __packed;
  532. /* See MS-SMB2 2.2.13.2.11 */
  533. /* Flags */
  534. #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
  535. struct durable_context_v2 {
  536. __le32 Timeout;
  537. __le32 Flags;
  538. __u64 Reserved;
  539. __u8 CreateGuid[16];
  540. } __packed;
  541. struct create_durable_v2 {
  542. struct create_context ccontext;
  543. __u8 Name[8];
  544. struct durable_context_v2 dcontext;
  545. } __packed;
  546. /* See MS-SMB2 2.2.13.2.12 */
  547. struct durable_reconnect_context_v2 {
  548. struct {
  549. __u64 PersistentFileId;
  550. __u64 VolatileFileId;
  551. } Fid;
  552. __u8 CreateGuid[16];
  553. __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
  554. } __packed;
  555. /* See MS-SMB2 2.2.14.2.12 */
  556. struct durable_reconnect_context_v2_rsp {
  557. __le32 Timeout;
  558. __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
  559. } __packed;
  560. struct create_durable_handle_reconnect_v2 {
  561. struct create_context ccontext;
  562. __u8 Name[8];
  563. struct durable_reconnect_context_v2 dcontext;
  564. } __packed;
  565. #define COPY_CHUNK_RES_KEY_SIZE 24
  566. struct resume_key_req {
  567. char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
  568. __le32 ContextLength; /* MBZ */
  569. char Context[0]; /* ignored, Windows sets to 4 bytes of zero */
  570. } __packed;
  571. /* this goes in the ioctl buffer when doing a copychunk request */
  572. struct copychunk_ioctl {
  573. char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
  574. __le32 ChunkCount; /* we are only sending 1 */
  575. __le32 Reserved;
  576. /* array will only be one chunk long for us */
  577. __le64 SourceOffset;
  578. __le64 TargetOffset;
  579. __le32 Length; /* how many bytes to copy */
  580. __u32 Reserved2;
  581. } __packed;
  582. /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
  583. struct file_zero_data_information {
  584. __le64 FileOffset;
  585. __le64 BeyondFinalZero;
  586. } __packed;
  587. struct copychunk_ioctl_rsp {
  588. __le32 ChunksWritten;
  589. __le32 ChunkBytesWritten;
  590. __le32 TotalBytesWritten;
  591. } __packed;
  592. struct fsctl_set_integrity_information_req {
  593. __le16 ChecksumAlgorithm;
  594. __le16 Reserved;
  595. __le32 Flags;
  596. } __packed;
  597. struct fsctl_get_integrity_information_rsp {
  598. __le16 ChecksumAlgorithm;
  599. __le16 Reserved;
  600. __le32 Flags;
  601. __le32 ChecksumChunkSizeInBytes;
  602. __le32 ClusterSizeInBytes;
  603. } __packed;
  604. /* Integrity ChecksumAlgorithm choices for above */
  605. #define CHECKSUM_TYPE_NONE 0x0000
  606. #define CHECKSUM_TYPE_CRC64 0x0002
  607. #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
  608. /* Integrity flags for above */
  609. #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
  610. /* See MS-SMB2 2.2.31.3 */
  611. struct network_resiliency_req {
  612. __le32 Timeout;
  613. __le32 Reserved;
  614. } __packed;
  615. /* There is no buffer for the response ie no struct network_resiliency_rsp */
  616. struct validate_negotiate_info_req {
  617. __le32 Capabilities;
  618. __u8 Guid[SMB2_CLIENT_GUID_SIZE];
  619. __le16 SecurityMode;
  620. __le16 DialectCount;
  621. __le16 Dialects[1]; /* dialect (someday maybe list) client asked for */
  622. } __packed;
  623. struct validate_negotiate_info_rsp {
  624. __le32 Capabilities;
  625. __u8 Guid[SMB2_CLIENT_GUID_SIZE];
  626. __le16 SecurityMode;
  627. __le16 Dialect; /* Dialect in use for the connection */
  628. } __packed;
  629. #define RSS_CAPABLE 0x00000001
  630. #define RDMA_CAPABLE 0x00000002
  631. struct network_interface_info_ioctl_rsp {
  632. __le32 Next; /* next interface. zero if this is last one */
  633. __le32 IfIndex;
  634. __le32 Capability; /* RSS or RDMA Capable */
  635. __le32 Reserved;
  636. __le64 LinkSpeed;
  637. char SockAddr_Storage[128];
  638. } __packed;
  639. #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
  640. struct compress_ioctl {
  641. __le16 CompressionState; /* See cifspdu.h for possible flag values */
  642. } __packed;
  643. struct duplicate_extents_to_file {
  644. __u64 PersistentFileHandle; /* source file handle, opaque endianness */
  645. __u64 VolatileFileHandle;
  646. __le64 SourceFileOffset;
  647. __le64 TargetFileOffset;
  648. __le64 ByteCount; /* Bytes to be copied */
  649. } __packed;
  650. struct smb2_ioctl_req {
  651. struct smb2_hdr hdr;
  652. __le16 StructureSize; /* Must be 57 */
  653. __u16 Reserved;
  654. __le32 CtlCode;
  655. __u64 PersistentFileId; /* opaque endianness */
  656. __u64 VolatileFileId; /* opaque endianness */
  657. __le32 InputOffset;
  658. __le32 InputCount;
  659. __le32 MaxInputResponse;
  660. __le32 OutputOffset;
  661. __le32 OutputCount;
  662. __le32 MaxOutputResponse;
  663. __le32 Flags;
  664. __u32 Reserved2;
  665. __u8 Buffer[0];
  666. } __packed;
  667. struct smb2_ioctl_rsp {
  668. struct smb2_hdr hdr;
  669. __le16 StructureSize; /* Must be 57 */
  670. __u16 Reserved;
  671. __le32 CtlCode;
  672. __u64 PersistentFileId; /* opaque endianness */
  673. __u64 VolatileFileId; /* opaque endianness */
  674. __le32 InputOffset;
  675. __le32 InputCount;
  676. __le32 OutputOffset;
  677. __le32 OutputCount;
  678. __le32 Flags;
  679. __u32 Reserved2;
  680. /* char * buffer[] */
  681. } __packed;
  682. /* Currently defined values for close flags */
  683. #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
  684. struct smb2_close_req {
  685. struct smb2_hdr hdr;
  686. __le16 StructureSize; /* Must be 24 */
  687. __le16 Flags;
  688. __le32 Reserved;
  689. __u64 PersistentFileId; /* opaque endianness */
  690. __u64 VolatileFileId; /* opaque endianness */
  691. } __packed;
  692. struct smb2_close_rsp {
  693. struct smb2_hdr hdr;
  694. __le16 StructureSize; /* 60 */
  695. __le16 Flags;
  696. __le32 Reserved;
  697. __le64 CreationTime;
  698. __le64 LastAccessTime;
  699. __le64 LastWriteTime;
  700. __le64 ChangeTime;
  701. __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
  702. __le64 EndOfFile;
  703. __le32 Attributes;
  704. } __packed;
  705. struct smb2_flush_req {
  706. struct smb2_hdr hdr;
  707. __le16 StructureSize; /* Must be 24 */
  708. __le16 Reserved1;
  709. __le32 Reserved2;
  710. __u64 PersistentFileId; /* opaque endianness */
  711. __u64 VolatileFileId; /* opaque endianness */
  712. } __packed;
  713. struct smb2_flush_rsp {
  714. struct smb2_hdr hdr;
  715. __le16 StructureSize;
  716. __le16 Reserved;
  717. } __packed;
  718. /* For read request Flags field below, following flag is defined for SMB3.02 */
  719. #define SMB2_READFLAG_READ_UNBUFFERED 0x01
  720. /* Channel field for read and write: exactly one of following flags can be set*/
  721. #define SMB2_CHANNEL_NONE 0x00000000
  722. #define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */
  723. #define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */
  724. struct smb2_read_req {
  725. struct smb2_hdr hdr;
  726. __le16 StructureSize; /* Must be 49 */
  727. __u8 Padding; /* offset from start of SMB2 header to place read */
  728. __u8 Flags; /* MBZ unless SMB3.02 or later */
  729. __le32 Length;
  730. __le64 Offset;
  731. __u64 PersistentFileId; /* opaque endianness */
  732. __u64 VolatileFileId; /* opaque endianness */
  733. __le32 MinimumCount;
  734. __le32 Channel; /* MBZ except for SMB3 or later */
  735. __le32 RemainingBytes;
  736. __le16 ReadChannelInfoOffset; /* Reserved MBZ */
  737. __le16 ReadChannelInfoLength; /* Reserved MBZ */
  738. __u8 Buffer[1];
  739. } __packed;
  740. struct smb2_read_rsp {
  741. struct smb2_hdr hdr;
  742. __le16 StructureSize; /* Must be 17 */
  743. __u8 DataOffset;
  744. __u8 Reserved;
  745. __le32 DataLength;
  746. __le32 DataRemaining;
  747. __u32 Reserved2;
  748. __u8 Buffer[1];
  749. } __packed;
  750. /* For write request Flags field below the following flags are defined: */
  751. #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
  752. #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
  753. struct smb2_write_req {
  754. struct smb2_hdr hdr;
  755. __le16 StructureSize; /* Must be 49 */
  756. __le16 DataOffset; /* offset from start of SMB2 header to write data */
  757. __le32 Length;
  758. __le64 Offset;
  759. __u64 PersistentFileId; /* opaque endianness */
  760. __u64 VolatileFileId; /* opaque endianness */
  761. __le32 Channel; /* Reserved MBZ */
  762. __le32 RemainingBytes;
  763. __le16 WriteChannelInfoOffset; /* Reserved MBZ */
  764. __le16 WriteChannelInfoLength; /* Reserved MBZ */
  765. __le32 Flags;
  766. __u8 Buffer[1];
  767. } __packed;
  768. struct smb2_write_rsp {
  769. struct smb2_hdr hdr;
  770. __le16 StructureSize; /* Must be 17 */
  771. __u8 DataOffset;
  772. __u8 Reserved;
  773. __le32 DataLength;
  774. __le32 DataRemaining;
  775. __u32 Reserved2;
  776. __u8 Buffer[1];
  777. } __packed;
  778. #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
  779. #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
  780. #define SMB2_LOCKFLAG_UNLOCK 0x0004
  781. #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
  782. struct smb2_lock_element {
  783. __le64 Offset;
  784. __le64 Length;
  785. __le32 Flags;
  786. __le32 Reserved;
  787. } __packed;
  788. struct smb2_lock_req {
  789. struct smb2_hdr hdr;
  790. __le16 StructureSize; /* Must be 48 */
  791. __le16 LockCount;
  792. __le32 Reserved;
  793. __u64 PersistentFileId; /* opaque endianness */
  794. __u64 VolatileFileId; /* opaque endianness */
  795. /* Followed by at least one */
  796. struct smb2_lock_element locks[1];
  797. } __packed;
  798. struct smb2_lock_rsp {
  799. struct smb2_hdr hdr;
  800. __le16 StructureSize; /* Must be 4 */
  801. __le16 Reserved;
  802. } __packed;
  803. struct smb2_echo_req {
  804. struct smb2_hdr hdr;
  805. __le16 StructureSize; /* Must be 4 */
  806. __u16 Reserved;
  807. } __packed;
  808. struct smb2_echo_rsp {
  809. struct smb2_hdr hdr;
  810. __le16 StructureSize; /* Must be 4 */
  811. __u16 Reserved;
  812. } __packed;
  813. /* search (query_directory) Flags field */
  814. #define SMB2_RESTART_SCANS 0x01
  815. #define SMB2_RETURN_SINGLE_ENTRY 0x02
  816. #define SMB2_INDEX_SPECIFIED 0x04
  817. #define SMB2_REOPEN 0x10
  818. struct smb2_query_directory_req {
  819. struct smb2_hdr hdr;
  820. __le16 StructureSize; /* Must be 33 */
  821. __u8 FileInformationClass;
  822. __u8 Flags;
  823. __le32 FileIndex;
  824. __u64 PersistentFileId; /* opaque endianness */
  825. __u64 VolatileFileId; /* opaque endianness */
  826. __le16 FileNameOffset;
  827. __le16 FileNameLength;
  828. __le32 OutputBufferLength;
  829. __u8 Buffer[1];
  830. } __packed;
  831. struct smb2_query_directory_rsp {
  832. struct smb2_hdr hdr;
  833. __le16 StructureSize; /* Must be 9 */
  834. __le16 OutputBufferOffset;
  835. __le32 OutputBufferLength;
  836. __u8 Buffer[1];
  837. } __packed;
  838. /* Possible InfoType values */
  839. #define SMB2_O_INFO_FILE 0x01
  840. #define SMB2_O_INFO_FILESYSTEM 0x02
  841. #define SMB2_O_INFO_SECURITY 0x03
  842. #define SMB2_O_INFO_QUOTA 0x04
  843. /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
  844. #define OWNER_SECINFO 0x00000001
  845. #define GROUP_SECINFO 0x00000002
  846. #define DACL_SECINFO 0x00000004
  847. #define SACL_SECINFO 0x00000008
  848. #define LABEL_SECINFO 0x00000010
  849. #define ATTRIBUTE_SECINFO 0x00000020
  850. #define SCOPE_SECINFO 0x00000040
  851. #define BACKUP_SECINFO 0x00010000
  852. #define UNPROTECTED_SACL_SECINFO 0x10000000
  853. #define UNPROTECTED_DACL_SECINFO 0x20000000
  854. #define PROTECTED_SACL_SECINFO 0x40000000
  855. #define PROTECTED_DACL_SECINFO 0x80000000
  856. /* Flags used for FileFullEAinfo */
  857. #define SL_RESTART_SCAN 0x00000001
  858. #define SL_RETURN_SINGLE_ENTRY 0x00000002
  859. #define SL_INDEX_SPECIFIED 0x00000004
  860. struct smb2_query_info_req {
  861. struct smb2_hdr hdr;
  862. __le16 StructureSize; /* Must be 41 */
  863. __u8 InfoType;
  864. __u8 FileInfoClass;
  865. __le32 OutputBufferLength;
  866. __le16 InputBufferOffset;
  867. __u16 Reserved;
  868. __le32 InputBufferLength;
  869. __le32 AdditionalInformation;
  870. __le32 Flags;
  871. __u64 PersistentFileId; /* opaque endianness */
  872. __u64 VolatileFileId; /* opaque endianness */
  873. __u8 Buffer[1];
  874. } __packed;
  875. struct smb2_query_info_rsp {
  876. struct smb2_hdr hdr;
  877. __le16 StructureSize; /* Must be 9 */
  878. __le16 OutputBufferOffset;
  879. __le32 OutputBufferLength;
  880. __u8 Buffer[1];
  881. } __packed;
  882. struct smb2_set_info_req {
  883. struct smb2_hdr hdr;
  884. __le16 StructureSize; /* Must be 33 */
  885. __u8 InfoType;
  886. __u8 FileInfoClass;
  887. __le32 BufferLength;
  888. __le16 BufferOffset;
  889. __u16 Reserved;
  890. __le32 AdditionalInformation;
  891. __u64 PersistentFileId; /* opaque endianness */
  892. __u64 VolatileFileId; /* opaque endianness */
  893. __u8 Buffer[1];
  894. } __packed;
  895. struct smb2_set_info_rsp {
  896. struct smb2_hdr hdr;
  897. __le16 StructureSize; /* Must be 2 */
  898. } __packed;
  899. struct smb2_oplock_break {
  900. struct smb2_hdr hdr;
  901. __le16 StructureSize; /* Must be 24 */
  902. __u8 OplockLevel;
  903. __u8 Reserved;
  904. __le32 Reserved2;
  905. __u64 PersistentFid;
  906. __u64 VolatileFid;
  907. } __packed;
  908. #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
  909. struct smb2_lease_break {
  910. struct smb2_hdr hdr;
  911. __le16 StructureSize; /* Must be 44 */
  912. __le16 Reserved;
  913. __le32 Flags;
  914. __u8 LeaseKey[16];
  915. __le32 CurrentLeaseState;
  916. __le32 NewLeaseState;
  917. __le32 BreakReason;
  918. __le32 AccessMaskHint;
  919. __le32 ShareMaskHint;
  920. } __packed;
  921. struct smb2_lease_ack {
  922. struct smb2_hdr hdr;
  923. __le16 StructureSize; /* Must be 36 */
  924. __le16 Reserved;
  925. __le32 Flags;
  926. __u8 LeaseKey[16];
  927. __le32 LeaseState;
  928. __le64 LeaseDuration;
  929. } __packed;
  930. /*
  931. * PDU infolevel structure definitions
  932. * BB consider moving to a different header
  933. */
  934. /* File System Information Classes */
  935. #define FS_VOLUME_INFORMATION 1 /* Query */
  936. #define FS_LABEL_INFORMATION 2 /* Local only */
  937. #define FS_SIZE_INFORMATION 3 /* Query */
  938. #define FS_DEVICE_INFORMATION 4 /* Query */
  939. #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
  940. #define FS_CONTROL_INFORMATION 6 /* Query, Set */
  941. #define FS_FULL_SIZE_INFORMATION 7 /* Query */
  942. #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
  943. #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
  944. #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
  945. #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
  946. struct smb2_fs_full_size_info {
  947. __le64 TotalAllocationUnits;
  948. __le64 CallerAvailableAllocationUnits;
  949. __le64 ActualAvailableAllocationUnits;
  950. __le32 SectorsPerAllocationUnit;
  951. __le32 BytesPerSector;
  952. } __packed;
  953. #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
  954. #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
  955. #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
  956. #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
  957. /* sector size info struct */
  958. struct smb3_fs_ss_info {
  959. __le32 LogicalBytesPerSector;
  960. __le32 PhysicalBytesPerSectorForAtomicity;
  961. __le32 PhysicalBytesPerSectorForPerf;
  962. __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
  963. __le32 Flags;
  964. __le32 ByteOffsetForSectorAlignment;
  965. __le32 ByteOffsetForPartitionAlignment;
  966. } __packed;
  967. /* partial list of QUERY INFO levels */
  968. #define FILE_DIRECTORY_INFORMATION 1
  969. #define FILE_FULL_DIRECTORY_INFORMATION 2
  970. #define FILE_BOTH_DIRECTORY_INFORMATION 3
  971. #define FILE_BASIC_INFORMATION 4
  972. #define FILE_STANDARD_INFORMATION 5
  973. #define FILE_INTERNAL_INFORMATION 6
  974. #define FILE_EA_INFORMATION 7
  975. #define FILE_ACCESS_INFORMATION 8
  976. #define FILE_NAME_INFORMATION 9
  977. #define FILE_RENAME_INFORMATION 10
  978. #define FILE_LINK_INFORMATION 11
  979. #define FILE_NAMES_INFORMATION 12
  980. #define FILE_DISPOSITION_INFORMATION 13
  981. #define FILE_POSITION_INFORMATION 14
  982. #define FILE_FULL_EA_INFORMATION 15
  983. #define FILE_MODE_INFORMATION 16
  984. #define FILE_ALIGNMENT_INFORMATION 17
  985. #define FILE_ALL_INFORMATION 18
  986. #define FILE_ALLOCATION_INFORMATION 19
  987. #define FILE_END_OF_FILE_INFORMATION 20
  988. #define FILE_ALTERNATE_NAME_INFORMATION 21
  989. #define FILE_STREAM_INFORMATION 22
  990. #define FILE_PIPE_INFORMATION 23
  991. #define FILE_PIPE_LOCAL_INFORMATION 24
  992. #define FILE_PIPE_REMOTE_INFORMATION 25
  993. #define FILE_MAILSLOT_QUERY_INFORMATION 26
  994. #define FILE_MAILSLOT_SET_INFORMATION 27
  995. #define FILE_COMPRESSION_INFORMATION 28
  996. #define FILE_OBJECT_ID_INFORMATION 29
  997. /* Number 30 not defined in documents */
  998. #define FILE_MOVE_CLUSTER_INFORMATION 31
  999. #define FILE_QUOTA_INFORMATION 32
  1000. #define FILE_REPARSE_POINT_INFORMATION 33
  1001. #define FILE_NETWORK_OPEN_INFORMATION 34
  1002. #define FILE_ATTRIBUTE_TAG_INFORMATION 35
  1003. #define FILE_TRACKING_INFORMATION 36
  1004. #define FILEID_BOTH_DIRECTORY_INFORMATION 37
  1005. #define FILEID_FULL_DIRECTORY_INFORMATION 38
  1006. #define FILE_VALID_DATA_LENGTH_INFORMATION 39
  1007. #define FILE_SHORT_NAME_INFORMATION 40
  1008. #define FILE_SFIO_RESERVE_INFORMATION 44
  1009. #define FILE_SFIO_VOLUME_INFORMATION 45
  1010. #define FILE_HARD_LINK_INFORMATION 46
  1011. #define FILE_NORMALIZED_NAME_INFORMATION 48
  1012. #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
  1013. #define FILE_STANDARD_LINK_INFORMATION 54
  1014. struct smb2_file_internal_info {
  1015. __le64 IndexNumber;
  1016. } __packed; /* level 6 Query */
  1017. struct smb2_file_rename_info { /* encoding of request for level 10 */
  1018. __u8 ReplaceIfExists; /* 1 = replace existing target with new */
  1019. /* 0 = fail if target already exists */
  1020. __u8 Reserved[7];
  1021. __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
  1022. __le32 FileNameLength;
  1023. char FileName[0]; /* New name to be assigned */
  1024. } __packed; /* level 10 Set */
  1025. struct smb2_file_link_info { /* encoding of request for level 11 */
  1026. __u8 ReplaceIfExists; /* 1 = replace existing link with new */
  1027. /* 0 = fail if link already exists */
  1028. __u8 Reserved[7];
  1029. __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
  1030. __le32 FileNameLength;
  1031. char FileName[0]; /* Name to be assigned to new link */
  1032. } __packed; /* level 11 Set */
  1033. /*
  1034. * This level 18, although with struct with same name is different from cifs
  1035. * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
  1036. * CurrentByteOffset.
  1037. */
  1038. struct smb2_file_all_info { /* data block encoding of response to level 18 */
  1039. __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
  1040. __le64 LastAccessTime;
  1041. __le64 LastWriteTime;
  1042. __le64 ChangeTime;
  1043. __le32 Attributes;
  1044. __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
  1045. __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
  1046. __le64 EndOfFile; /* size ie offset to first free byte in file */
  1047. __le32 NumberOfLinks; /* hard links */
  1048. __u8 DeletePending;
  1049. __u8 Directory;
  1050. __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
  1051. __le64 IndexNumber;
  1052. __le32 EASize;
  1053. __le32 AccessFlags;
  1054. __le64 CurrentByteOffset;
  1055. __le32 Mode;
  1056. __le32 AlignmentRequirement;
  1057. __le32 FileNameLength;
  1058. char FileName[1];
  1059. } __packed; /* level 18 Query */
  1060. struct smb2_file_eof_info { /* encoding of request for level 10 */
  1061. __le64 EndOfFile; /* new end of file value */
  1062. } __packed; /* level 20 Set */
  1063. #endif /* _SMB2PDU_H */