smb2pdu.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. /*
  2. * fs/cifs/smb2pdu.h
  3. *
  4. * Copyright (c) International Business Machines Corp., 2009, 2010
  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. /* BB FIXME - analyze following length BB */
  79. #define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */
  80. #define SMB2_PROTO_NUMBER __constant_cpu_to_le32(0x424d53fe)
  81. #define SMB2_HEADER_SIZE __constant_le16_to_cpu(64)
  82. #define SMB2_ERROR_STRUCTURE_SIZE2 __constant_le16_to_cpu(9)
  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. struct smb2_hdr {
  92. __be32 smb2_buf_length; /* big endian on wire */
  93. /* length is only two or three bytes - with
  94. one or two byte type preceding it that MBZ */
  95. __u8 ProtocolId[4]; /* 0xFE 'S' 'M' 'B' */
  96. __le16 StructureSize; /* 64 */
  97. __le16 CreditCharge; /* MBZ */
  98. __le32 Status; /* Error from server */
  99. __le16 Command;
  100. __le16 CreditRequest; /* CreditResponse */
  101. __le32 Flags;
  102. __le32 NextCommand;
  103. __u64 MessageId; /* opaque - so can stay little endian */
  104. __le32 ProcessId;
  105. __u32 TreeId; /* opaque - so do not make little endian */
  106. __u64 SessionId; /* opaque - so do not make little endian */
  107. __u8 Signature[16];
  108. } __packed;
  109. struct smb2_pdu {
  110. struct smb2_hdr hdr;
  111. __le16 StructureSize2; /* size of wct area (varies, request specific) */
  112. } __packed;
  113. /*
  114. * SMB2 flag definitions
  115. */
  116. #define SMB2_FLAGS_SERVER_TO_REDIR __constant_cpu_to_le32(0x00000001)
  117. #define SMB2_FLAGS_ASYNC_COMMAND __constant_cpu_to_le32(0x00000002)
  118. #define SMB2_FLAGS_RELATED_OPERATIONS __constant_cpu_to_le32(0x00000004)
  119. #define SMB2_FLAGS_SIGNED __constant_cpu_to_le32(0x00000008)
  120. #define SMB2_FLAGS_DFS_OPERATIONS __constant_cpu_to_le32(0x10000000)
  121. /*
  122. * Definitions for SMB2 Protocol Data Units (network frames)
  123. *
  124. * See MS-SMB2.PDF specification for protocol details.
  125. * The Naming convention is the lower case version of the SMB2
  126. * command code name for the struct. Note that structures must be packed.
  127. *
  128. */
  129. struct smb2_err_rsp {
  130. struct smb2_hdr hdr;
  131. __le16 StructureSize;
  132. __le16 Reserved; /* MBZ */
  133. __le32 ByteCount; /* even if zero, at least one byte follows */
  134. __u8 ErrorData[1]; /* variable length */
  135. } __packed;
  136. struct smb2_negotiate_req {
  137. struct smb2_hdr hdr;
  138. __le16 StructureSize; /* Must be 36 */
  139. __le16 DialectCount;
  140. __le16 SecurityMode;
  141. __le16 Reserved; /* MBZ */
  142. __le32 Capabilities;
  143. __u8 ClientGUID[16]; /* MBZ */
  144. __le64 ClientStartTime; /* MBZ */
  145. __le16 Dialects[2]; /* variable length */
  146. } __packed;
  147. /* SecurityMode flags */
  148. #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
  149. #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
  150. /* Capabilities flags */
  151. #define SMB2_GLOBAL_CAP_DFS 0x00000001
  152. #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
  153. #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
  154. /* Internal types */
  155. #define SMB2_NT_FIND 0x00100000
  156. #define SMB2_LARGE_FILES 0x00200000
  157. struct smb2_negotiate_rsp {
  158. struct smb2_hdr hdr;
  159. __le16 StructureSize; /* Must be 65 */
  160. __le16 SecurityMode;
  161. __le16 DialectRevision;
  162. __le16 Reserved; /* MBZ */
  163. __u8 ServerGUID[16];
  164. __le32 Capabilities;
  165. __le32 MaxTransactSize;
  166. __le32 MaxReadSize;
  167. __le32 MaxWriteSize;
  168. __le64 SystemTime; /* MBZ */
  169. __le64 ServerStartTime;
  170. __le16 SecurityBufferOffset;
  171. __le16 SecurityBufferLength;
  172. __le32 Reserved2; /* may be any value, ignore */
  173. __u8 Buffer[1]; /* variable length GSS security buffer */
  174. } __packed;
  175. struct smb2_sess_setup_req {
  176. struct smb2_hdr hdr;
  177. __le16 StructureSize; /* Must be 25 */
  178. __u8 VcNumber;
  179. __u8 SecurityMode;
  180. __le32 Capabilities;
  181. __le32 Channel;
  182. __le16 SecurityBufferOffset;
  183. __le16 SecurityBufferLength;
  184. __le64 PreviousSessionId;
  185. __u8 Buffer[1]; /* variable length GSS security buffer */
  186. } __packed;
  187. /* Currently defined SessionFlags */
  188. #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
  189. #define SMB2_SESSION_FLAG_IS_NULL 0x0002
  190. struct smb2_sess_setup_rsp {
  191. struct smb2_hdr hdr;
  192. __le16 StructureSize; /* Must be 9 */
  193. __le16 SessionFlags;
  194. __le16 SecurityBufferOffset;
  195. __le16 SecurityBufferLength;
  196. __u8 Buffer[1]; /* variable length GSS security buffer */
  197. } __packed;
  198. struct smb2_logoff_req {
  199. struct smb2_hdr hdr;
  200. __le16 StructureSize; /* Must be 4 */
  201. __le16 Reserved;
  202. } __packed;
  203. struct smb2_logoff_rsp {
  204. struct smb2_hdr hdr;
  205. __le16 StructureSize; /* Must be 4 */
  206. __le16 Reserved;
  207. } __packed;
  208. struct smb2_tree_connect_req {
  209. struct smb2_hdr hdr;
  210. __le16 StructureSize; /* Must be 9 */
  211. __le16 Reserved;
  212. __le16 PathOffset;
  213. __le16 PathLength;
  214. __u8 Buffer[1]; /* variable length */
  215. } __packed;
  216. struct smb2_tree_connect_rsp {
  217. struct smb2_hdr hdr;
  218. __le16 StructureSize; /* Must be 16 */
  219. __u8 ShareType; /* see below */
  220. __u8 Reserved;
  221. __le32 ShareFlags; /* see below */
  222. __le32 Capabilities; /* see below */
  223. __le32 MaximalAccess;
  224. } __packed;
  225. /* Possible ShareType values */
  226. #define SMB2_SHARE_TYPE_DISK 0x01
  227. #define SMB2_SHARE_TYPE_PIPE 0x02
  228. #define SMB2_SHARE_TYPE_PRINT 0x03
  229. /*
  230. * Possible ShareFlags - exactly one and only one of the first 4 caching flags
  231. * must be set (any of the remaining, SHI1005, flags may be set individually
  232. * or in combination.
  233. */
  234. #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
  235. #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
  236. #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
  237. #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
  238. #define SHI1005_FLAGS_DFS 0x00000001
  239. #define SHI1005_FLAGS_DFS_ROOT 0x00000002
  240. #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
  241. #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
  242. #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
  243. #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
  244. #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
  245. #define SHI1005_FLAGS_ENABLE_HASH 0x00002000
  246. /* Possible share capabilities */
  247. #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008)
  248. struct smb2_tree_disconnect_req {
  249. struct smb2_hdr hdr;
  250. __le16 StructureSize; /* Must be 4 */
  251. __le16 Reserved;
  252. } __packed;
  253. struct smb2_tree_disconnect_rsp {
  254. struct smb2_hdr hdr;
  255. __le16 StructureSize; /* Must be 4 */
  256. __le16 Reserved;
  257. } __packed;
  258. /* File Attrubutes */
  259. #define FILE_ATTRIBUTE_READONLY 0x00000001
  260. #define FILE_ATTRIBUTE_HIDDEN 0x00000002
  261. #define FILE_ATTRIBUTE_SYSTEM 0x00000004
  262. #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
  263. #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
  264. #define FILE_ATTRIBUTE_NORMAL 0x00000080
  265. #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
  266. #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
  267. #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
  268. #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
  269. #define FILE_ATTRIBUTE_OFFLINE 0x00001000
  270. #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
  271. #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
  272. /* Oplock levels */
  273. #define SMB2_OPLOCK_LEVEL_NONE 0x00
  274. #define SMB2_OPLOCK_LEVEL_II 0x01
  275. #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
  276. #define SMB2_OPLOCK_LEVEL_BATCH 0x09
  277. #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
  278. /* Desired Access Flags */
  279. #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
  280. #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
  281. #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
  282. #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
  283. #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
  284. #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
  285. #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
  286. #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
  287. #define FILE_DELETE_LE cpu_to_le32(0x00010000)
  288. #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
  289. #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
  290. #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
  291. #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
  292. #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
  293. #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
  294. #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
  295. #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
  296. #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
  297. #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
  298. /* ShareAccess Flags */
  299. #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
  300. #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
  301. #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
  302. #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
  303. /* CreateDisposition Flags */
  304. #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
  305. #define FILE_OPEN_LE cpu_to_le32(0x00000001)
  306. #define FILE_CREATE_LE cpu_to_le32(0x00000002)
  307. #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
  308. #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
  309. #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
  310. /* CreateOptions Flags */
  311. #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
  312. /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
  313. #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
  314. #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
  315. #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
  316. #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
  317. #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
  318. #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
  319. #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
  320. #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
  321. #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
  322. #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
  323. #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
  324. #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
  325. #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
  326. #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
  327. #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
  328. #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
  329. #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
  330. #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
  331. | FILE_READ_ATTRIBUTES_LE)
  332. #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
  333. | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
  334. #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
  335. /* Impersonation Levels */
  336. #define IL_ANONYMOUS cpu_to_le32(0x00000000)
  337. #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
  338. #define IL_IMPERSONATION cpu_to_le32(0x00000002)
  339. #define IL_DELEGATE cpu_to_le32(0x00000003)
  340. /* Create Context Values */
  341. #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
  342. #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
  343. #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
  344. #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
  345. #define SMB2_CREATE_ALLOCATION_SIZE "AlSi"
  346. #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
  347. #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
  348. #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
  349. #define SMB2_CREATE_REQUEST_LEASE "RqLs"
  350. struct smb2_create_req {
  351. struct smb2_hdr hdr;
  352. __le16 StructureSize; /* Must be 57 */
  353. __u8 SecurityFlags;
  354. __u8 RequestedOplockLevel;
  355. __le32 ImpersonationLevel;
  356. __le64 SmbCreateFlags;
  357. __le64 Reserved;
  358. __le32 DesiredAccess;
  359. __le32 FileAttributes;
  360. __le32 ShareAccess;
  361. __le32 CreateDisposition;
  362. __le32 CreateOptions;
  363. __le16 NameOffset;
  364. __le16 NameLength;
  365. __le32 CreateContextsOffset;
  366. __le32 CreateContextsLength;
  367. __u8 Buffer[1];
  368. } __packed;
  369. struct smb2_create_rsp {
  370. struct smb2_hdr hdr;
  371. __le16 StructureSize; /* Must be 89 */
  372. __u8 OplockLevel;
  373. __u8 Reserved;
  374. __le32 CreateAction;
  375. __le64 CreationTime;
  376. __le64 LastAccessTime;
  377. __le64 LastWriteTime;
  378. __le64 ChangeTime;
  379. __le64 AllocationSize;
  380. __le64 EndofFile;
  381. __le32 FileAttributes;
  382. __le32 Reserved2;
  383. __u64 PersistentFileId; /* opaque endianness */
  384. __u64 VolatileFileId; /* opaque endianness */
  385. __le32 CreateContextsOffset;
  386. __le32 CreateContextsLength;
  387. __u8 Buffer[1];
  388. } __packed;
  389. /* Currently defined values for close flags */
  390. #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
  391. struct smb2_close_req {
  392. struct smb2_hdr hdr;
  393. __le16 StructureSize; /* Must be 24 */
  394. __le16 Flags;
  395. __le32 Reserved;
  396. __u64 PersistentFileId; /* opaque endianness */
  397. __u64 VolatileFileId; /* opaque endianness */
  398. } __packed;
  399. struct smb2_close_rsp {
  400. struct smb2_hdr hdr;
  401. __le16 StructureSize; /* 60 */
  402. __le16 Flags;
  403. __le32 Reserved;
  404. __le64 CreationTime;
  405. __le64 LastAccessTime;
  406. __le64 LastWriteTime;
  407. __le64 ChangeTime;
  408. __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
  409. __le64 EndOfFile;
  410. __le32 Attributes;
  411. } __packed;
  412. struct smb2_echo_req {
  413. struct smb2_hdr hdr;
  414. __le16 StructureSize; /* Must be 4 */
  415. __u16 Reserved;
  416. } __packed;
  417. struct smb2_echo_rsp {
  418. struct smb2_hdr hdr;
  419. __le16 StructureSize; /* Must be 4 */
  420. __u16 Reserved;
  421. } __packed;
  422. /* Possible InfoType values */
  423. #define SMB2_O_INFO_FILE 0x01
  424. #define SMB2_O_INFO_FILESYSTEM 0x02
  425. #define SMB2_O_INFO_SECURITY 0x03
  426. #define SMB2_O_INFO_QUOTA 0x04
  427. struct smb2_query_info_req {
  428. struct smb2_hdr hdr;
  429. __le16 StructureSize; /* Must be 41 */
  430. __u8 InfoType;
  431. __u8 FileInfoClass;
  432. __le32 OutputBufferLength;
  433. __le16 InputBufferOffset;
  434. __u16 Reserved;
  435. __le32 InputBufferLength;
  436. __le32 AdditionalInformation;
  437. __le32 Flags;
  438. __u64 PersistentFileId; /* opaque endianness */
  439. __u64 VolatileFileId; /* opaque endianness */
  440. __u8 Buffer[1];
  441. } __packed;
  442. struct smb2_query_info_rsp {
  443. struct smb2_hdr hdr;
  444. __le16 StructureSize; /* Must be 9 */
  445. __le16 OutputBufferOffset;
  446. __le32 OutputBufferLength;
  447. __u8 Buffer[1];
  448. } __packed;
  449. /*
  450. * PDU infolevel structure definitions
  451. * BB consider moving to a different header
  452. */
  453. /* partial list of QUERY INFO levels */
  454. #define FILE_DIRECTORY_INFORMATION 1
  455. #define FILE_FULL_DIRECTORY_INFORMATION 2
  456. #define FILE_BOTH_DIRECTORY_INFORMATION 3
  457. #define FILE_BASIC_INFORMATION 4
  458. #define FILE_STANDARD_INFORMATION 5
  459. #define FILE_INTERNAL_INFORMATION 6
  460. #define FILE_EA_INFORMATION 7
  461. #define FILE_ACCESS_INFORMATION 8
  462. #define FILE_NAME_INFORMATION 9
  463. #define FILE_RENAME_INFORMATION 10
  464. #define FILE_LINK_INFORMATION 11
  465. #define FILE_NAMES_INFORMATION 12
  466. #define FILE_DISPOSITION_INFORMATION 13
  467. #define FILE_POSITION_INFORMATION 14
  468. #define FILE_FULL_EA_INFORMATION 15
  469. #define FILE_MODE_INFORMATION 16
  470. #define FILE_ALIGNMENT_INFORMATION 17
  471. #define FILE_ALL_INFORMATION 18
  472. #define FILE_ALLOCATION_INFORMATION 19
  473. #define FILE_END_OF_FILE_INFORMATION 20
  474. #define FILE_ALTERNATE_NAME_INFORMATION 21
  475. #define FILE_STREAM_INFORMATION 22
  476. #define FILE_PIPE_INFORMATION 23
  477. #define FILE_PIPE_LOCAL_INFORMATION 24
  478. #define FILE_PIPE_REMOTE_INFORMATION 25
  479. #define FILE_MAILSLOT_QUERY_INFORMATION 26
  480. #define FILE_MAILSLOT_SET_INFORMATION 27
  481. #define FILE_COMPRESSION_INFORMATION 28
  482. #define FILE_OBJECT_ID_INFORMATION 29
  483. /* Number 30 not defined in documents */
  484. #define FILE_MOVE_CLUSTER_INFORMATION 31
  485. #define FILE_QUOTA_INFORMATION 32
  486. #define FILE_REPARSE_POINT_INFORMATION 33
  487. #define FILE_NETWORK_OPEN_INFORMATION 34
  488. #define FILE_ATTRIBUTE_TAG_INFORMATION 35
  489. #define FILE_TRACKING_INFORMATION 36
  490. #define FILEID_BOTH_DIRECTORY_INFORMATION 37
  491. #define FILEID_FULL_DIRECTORY_INFORMATION 38
  492. #define FILE_VALID_DATA_LENGTH_INFORMATION 39
  493. #define FILE_SHORT_NAME_INFORMATION 40
  494. #define FILE_SFIO_RESERVE_INFORMATION 44
  495. #define FILE_SFIO_VOLUME_INFORMATION 45
  496. #define FILE_HARD_LINK_INFORMATION 46
  497. #define FILE_NORMALIZED_NAME_INFORMATION 48
  498. #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
  499. #define FILE_STANDARD_LINK_INFORMATION 54
  500. /*
  501. * This level 18, although with struct with same name is different from cifs
  502. * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
  503. * CurrentByteOffset.
  504. */
  505. struct smb2_file_all_info { /* data block encoding of response to level 18 */
  506. __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
  507. __le64 LastAccessTime;
  508. __le64 LastWriteTime;
  509. __le64 ChangeTime;
  510. __le32 Attributes;
  511. __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
  512. __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
  513. __le64 EndOfFile; /* size ie offset to first free byte in file */
  514. __le32 NumberOfLinks; /* hard links */
  515. __u8 DeletePending;
  516. __u8 Directory;
  517. __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
  518. __le64 IndexNumber;
  519. __le32 EASize;
  520. __le32 AccessFlags;
  521. __le64 CurrentByteOffset;
  522. __le32 Mode;
  523. __le32 AlignmentRequirement;
  524. __le32 FileNameLength;
  525. char FileName[1];
  526. } __packed; /* level 18 Query */
  527. #endif /* _SMB2PDU_H */