smb2pdu.h 36 KB

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