2 Unix SMB/CIFS implementation.
3 SMB request interface structures
4 Copyright (C) Andrew Tridgell 2003
5 Copyright (C) James J Myers 2003 <myersjj@samba.org>
6 Copyright (C) James Peach 2007
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef __LIBCLI_RAW_INTERFACES_H__
23 #define __LIBCLI_RAW_INTERFACES_H__
26 #include "librpc/gen_ndr/misc.h" /* for struct GUID */
28 /* this structure is just a wrapper for a string, the only reason we
29 bother with this is that it allows us to check the length provided
30 on the wire in testsuite test code to ensure that we are
31 terminating names in the same way that win2003 is. The *ONLY* time
32 you should ever look at the 'private_length' field in this
33 structure is inside compliance test code, in all other cases just
34 use the null terminated char* as the definitive definition of the
37 also note that this structure is only used in packets where there
38 is an explicit length provided on the wire (hence the name). That
39 length is placed in 'private_length'. For packets where the length
40 is always determined by NULL or packet termination a normal char*
41 is used in the structure definition.
43 struct smb_wire_string {
44 uint32_t private_length;
49 * SMB2 uses a 16Byte handle,
50 * (we can maybe use struct GUID later)
57 SMB2 lease structure (per MS-SMB2 2.2.13)
59 struct smb2_lease_key {
64 struct smb2_lease_key lease_key;
66 uint32_t lease_flags; /* should be 0 */
67 uint64_t lease_duration; /* should be 0 */
70 struct smb2_lease_break {
71 struct smb2_lease current_lease;
73 uint32_t new_lease_state;
74 uint32_t break_reason; /* should be 0 */
75 uint32_t access_mask_hint; /* should be 0 */
76 uint32_t share_mask_hint; /* should be 0 */
82 * a generic container for file handles or file pathes
83 * for qfileinfo/setfileinfo and qpathinfo/setpathinfo
85 union smb_handle_or_path {
88 * the qpathinfo and setpathinfo
93 * this is used as file handle in SMB
98 * this is used as file handle in SMB2
100 struct smb2_handle handle;
103 * this is used as generic file handle for the NTVFS layer
105 struct ntvfs_handle *ntvfs;
109 a generic container for file handles
113 * this is used as file handle in SMB
118 * this is used as file handle in SMB2
120 struct smb2_handle handle;
123 * this is used as generic file handle for the NTVFS layer
125 struct ntvfs_handle *ntvfs;
129 this header defines the structures and unions used between the SMB
130 parser and the backends.
133 /* struct used for SMBlseek call */
137 union smb_handle file;
139 int32_t offset; /* signed */
147 /* struct used in unlink() call */
158 /* struct used in chkpath() call */
167 enum smb_mkdir_level {RAW_MKDIR_GENERIC, RAW_MKDIR_MKDIR, RAW_MKDIR_T2MKDIR};
169 /* union used in mkdir() call */
173 enum smb_mkdir_level level;
177 enum smb_mkdir_level level;
184 enum smb_mkdir_level level;
188 struct ea_struct *eas;
193 /* struct used in rmdir() call */
200 /* struct used in rename() call */
201 enum smb_rename_level {RAW_RENAME_RENAME, RAW_RENAME_NTRENAME, RAW_RENAME_NTTRANS};
205 enum smb_rename_level level;
208 /* SMBrename interface */
210 enum smb_rename_level level;
213 const char *pattern1;
214 const char *pattern2;
220 /* SMBntrename interface */
222 enum smb_rename_level level;
226 uint16_t flags; /* see RENAME_FLAG_* */
227 uint32_t cluster_size;
228 const char *old_name;
229 const char *new_name;
233 /* NT TRANS rename interface */
235 enum smb_rename_level level;
238 union smb_handle file;
239 uint16_t flags;/* see RENAME_REPLACE_IF_EXISTS */
240 const char *new_name;
245 enum smb_tcon_level {
251 /* union used in tree connect call */
253 /* generic interface */
255 enum smb_tcon_level level;
258 /* SMBtcon interface */
260 enum smb_tcon_level level;
264 const char *password;
273 /* SMBtconX interface */
275 enum smb_tcon_level level;
291 /* SMB2 TreeConnect */
292 struct smb2_tree_connect {
293 enum smb_tcon_level level;
296 /* static body buffer 8 (0x08) bytes */
298 /* uint16_t path_ofs */
299 /* uint16_t path_size */
301 const char *path; /* as non-terminated UTF-16 on the wire */
304 /* static body buffer 16 (0x10) bytes */
305 /* uint16_t buffer_code; 0x10 */
309 uint32_t capabilities;
310 uint32_t access_mask;
312 /* extracted from the SMB2 header */
319 enum smb_sesssetup_level {
322 RAW_SESSSETUP_SPNEGO,
326 /* union used in session_setup call */
327 union smb_sesssetup {
328 /* the pre-NT1 interface */
330 enum smb_sesssetup_level level;
352 /* the NT1 interface */
354 enum smb_sesssetup_level level;
361 uint32_t capabilities;
379 /* the SPNEGO interface */
381 enum smb_sesssetup_level level;
388 uint32_t capabilities;
392 const char *workgroup;
404 /* SMB2 SessionSetup */
405 struct smb2_session_setup {
406 enum smb_sesssetup_level level;
409 /* static body 24 (0x18) bytes */
411 uint8_t security_mode;
412 uint32_t capabilities;
414 /* uint16_t secblob_ofs */
415 /* uint16_t secblob_size */
416 uint64_t previous_sessionid;
421 /* body buffer 8 (0x08) bytes */
422 uint16_t session_flags;
423 /* uint16_t secblob_ofs */
424 /* uint16_t secblob_size */
428 /* extracted from the SMB2 header */
434 /* Note that the specified enum values are identical to the actual info-levels used
437 enum smb_fileinfo_level {
438 RAW_FILEINFO_GENERIC = 0xF000,
439 RAW_FILEINFO_GETATTR, /* SMBgetatr */
440 RAW_FILEINFO_GETATTRE, /* SMBgetattrE */
441 RAW_FILEINFO_SEC_DESC, /* NT_TRANSACT_QUERY_SECURITY_DESC */
442 RAW_FILEINFO_STANDARD = SMB_QFILEINFO_STANDARD,
443 RAW_FILEINFO_EA_SIZE = SMB_QFILEINFO_EA_SIZE,
444 RAW_FILEINFO_EA_LIST = SMB_QFILEINFO_EA_LIST,
445 RAW_FILEINFO_ALL_EAS = SMB_QFILEINFO_ALL_EAS,
446 RAW_FILEINFO_IS_NAME_VALID = SMB_QFILEINFO_IS_NAME_VALID,
447 RAW_FILEINFO_BASIC_INFO = SMB_QFILEINFO_BASIC_INFO,
448 RAW_FILEINFO_STANDARD_INFO = SMB_QFILEINFO_STANDARD_INFO,
449 RAW_FILEINFO_EA_INFO = SMB_QFILEINFO_EA_INFO,
450 RAW_FILEINFO_NAME_INFO = SMB_QFILEINFO_NAME_INFO,
451 RAW_FILEINFO_ALL_INFO = SMB_QFILEINFO_ALL_INFO,
452 RAW_FILEINFO_ALT_NAME_INFO = SMB_QFILEINFO_ALT_NAME_INFO,
453 RAW_FILEINFO_STREAM_INFO = SMB_QFILEINFO_STREAM_INFO,
454 RAW_FILEINFO_COMPRESSION_INFO = SMB_QFILEINFO_COMPRESSION_INFO,
455 RAW_FILEINFO_UNIX_BASIC = SMB_QFILEINFO_UNIX_BASIC,
456 RAW_FILEINFO_UNIX_INFO2 = SMB_QFILEINFO_UNIX_INFO2,
457 RAW_FILEINFO_UNIX_LINK = SMB_QFILEINFO_UNIX_LINK,
458 RAW_FILEINFO_BASIC_INFORMATION = SMB_QFILEINFO_BASIC_INFORMATION,
459 RAW_FILEINFO_STANDARD_INFORMATION = SMB_QFILEINFO_STANDARD_INFORMATION,
460 RAW_FILEINFO_INTERNAL_INFORMATION = SMB_QFILEINFO_INTERNAL_INFORMATION,
461 RAW_FILEINFO_EA_INFORMATION = SMB_QFILEINFO_EA_INFORMATION,
462 RAW_FILEINFO_ACCESS_INFORMATION = SMB_QFILEINFO_ACCESS_INFORMATION,
463 RAW_FILEINFO_NAME_INFORMATION = SMB_QFILEINFO_NAME_INFORMATION,
464 RAW_FILEINFO_POSITION_INFORMATION = SMB_QFILEINFO_POSITION_INFORMATION,
465 RAW_FILEINFO_MODE_INFORMATION = SMB_QFILEINFO_MODE_INFORMATION,
466 RAW_FILEINFO_ALIGNMENT_INFORMATION = SMB_QFILEINFO_ALIGNMENT_INFORMATION,
467 RAW_FILEINFO_ALL_INFORMATION = SMB_QFILEINFO_ALL_INFORMATION,
468 RAW_FILEINFO_ALT_NAME_INFORMATION = SMB_QFILEINFO_ALT_NAME_INFORMATION,
469 RAW_FILEINFO_STREAM_INFORMATION = SMB_QFILEINFO_STREAM_INFORMATION,
470 RAW_FILEINFO_COMPRESSION_INFORMATION = SMB_QFILEINFO_COMPRESSION_INFORMATION,
471 RAW_FILEINFO_NETWORK_OPEN_INFORMATION = SMB_QFILEINFO_NETWORK_OPEN_INFORMATION,
472 RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION = SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION,
473 /* SMB2 specific levels */
474 RAW_FILEINFO_SMB2_ALL_EAS = 0x0f01,
475 RAW_FILEINFO_SMB2_ALL_INFORMATION = 0x1201
478 /* union used in qfileinfo() and qpathinfo() backend calls */
480 /* generic interface:
481 * matches RAW_FILEINFO_GENERIC */
483 enum smb_fileinfo_level level;
485 union smb_handle_or_path file;
493 struct smb_wire_string name;
503 struct smb_wire_string fname;
504 struct smb_wire_string alt_fname;
505 uint8_t delete_pending;
507 uint64_t compressed_size;
511 uint8_t cluster_shift;
513 uint32_t access_flags; /* seen 0x001f01ff from w2k3 */
516 uint32_t alignment_requirement;
517 uint32_t reparse_tag;
519 struct stream_struct {
522 struct smb_wire_string stream_name;
528 /* SMBgetatr interface:
529 * matches RAW_FILEINFO_GETATTR */
531 enum smb_fileinfo_level level;
533 union smb_handle_or_path file;
542 /* SMBgetattrE and RAW_FILEINFO_STANDARD interface */
544 enum smb_fileinfo_level level;
546 union smb_handle_or_path file;
556 } getattre, standard;
558 /* trans2 RAW_FILEINFO_EA_SIZE interface */
560 enum smb_fileinfo_level level;
562 union smb_handle_or_path file;
575 /* trans2 RAW_FILEINFO_EA_LIST interface */
577 enum smb_fileinfo_level level;
579 union smb_handle_or_path file;
582 struct smb_wire_string name;
588 struct ea_struct *eas;
592 /* trans2 RAW_FILEINFO_ALL_EAS and RAW_FILEINFO_FULL_EA_INFORMATION interfaces */
594 enum smb_fileinfo_level level;
596 union smb_handle_or_path file;
597 /* SMB2 only - SMB2_CONTINUE_FLAG_* */
598 uint8_t continue_flags;
600 struct smb_ea_list out;
603 /* trans2 qpathinfo RAW_FILEINFO_IS_NAME_VALID interface
604 only valid for a QPATHNAME call - no returned data */
606 enum smb_fileinfo_level level;
608 union smb_handle_or_path file;
612 /* RAW_FILEINFO_BASIC_INFO and RAW_FILEINFO_BASIC_INFORMATION interfaces */
614 enum smb_fileinfo_level level;
616 union smb_handle_or_path file;
628 /* RAW_FILEINFO_STANDARD_INFO and RAW_FILEINFO_STANDARD_INFORMATION interfaces */
630 enum smb_fileinfo_level level;
632 union smb_handle_or_path file;
643 /* RAW_FILEINFO_EA_INFO and RAW_FILEINFO_EA_INFORMATION interfaces */
645 enum smb_fileinfo_level level;
647 union smb_handle_or_path file;
654 /* RAW_FILEINFO_NAME_INFO and RAW_FILEINFO_NAME_INFORMATION interfaces */
656 enum smb_fileinfo_level level;
658 union smb_handle_or_path file;
661 struct smb_wire_string fname;
665 /* RAW_FILEINFO_ALL_INFO and RAW_FILEINFO_ALL_INFORMATION interfaces */
667 enum smb_fileinfo_level level;
669 union smb_handle_or_path file;
680 uint8_t delete_pending;
683 struct smb_wire_string fname;
687 /* RAW_FILEINFO_SMB2_ALL_INFORMATION interface */
689 enum smb_fileinfo_level level;
691 union smb_handle_or_path file;
703 uint8_t delete_pending;
708 uint32_t access_mask;
711 uint32_t alignment_requirement;
712 struct smb_wire_string fname;
716 /* RAW_FILEINFO_ALT_NAME_INFO and RAW_FILEINFO_ALT_NAME_INFORMATION interfaces */
718 enum smb_fileinfo_level level;
720 union smb_handle_or_path file;
723 struct smb_wire_string fname;
727 /* RAW_FILEINFO_STREAM_INFO and RAW_FILEINFO_STREAM_INFORMATION interfaces */
729 enum smb_fileinfo_level level;
731 union smb_handle_or_path file;
733 struct stream_information {
735 struct stream_struct *streams;
739 /* RAW_FILEINFO_COMPRESSION_INFO and RAW_FILEINFO_COMPRESSION_INFORMATION interfaces */
741 enum smb_fileinfo_level level;
743 union smb_handle_or_path file;
746 uint64_t compressed_size;
750 uint8_t cluster_shift;
754 /* RAW_FILEINFO_UNIX_BASIC interface */
756 enum smb_fileinfo_level level;
758 union smb_handle_or_path file;
761 uint64_t end_of_file;
763 NTTIME status_change_time;
772 uint64_t permissions;
777 /* RAW_FILEINFO_UNIX_INFO2 interface */
779 enum smb_fileinfo_level level;
781 union smb_handle_or_path file;
784 uint64_t end_of_file;
786 NTTIME status_change_time;
795 uint64_t permissions;
803 /* RAW_FILEINFO_UNIX_LINK interface */
805 enum smb_fileinfo_level level;
807 union smb_handle_or_path file;
810 struct smb_wire_string link_dest;
814 /* RAW_FILEINFO_INTERNAL_INFORMATION interface */
816 enum smb_fileinfo_level level;
818 union smb_handle_or_path file;
823 } internal_information;
825 /* RAW_FILEINFO_ACCESS_INFORMATION interface */
827 enum smb_fileinfo_level level;
829 union smb_handle_or_path file;
832 uint32_t access_flags;
834 } access_information;
836 /* RAW_FILEINFO_POSITION_INFORMATION interface */
838 enum smb_fileinfo_level level;
840 union smb_handle_or_path file;
845 } position_information;
847 /* RAW_FILEINFO_MODE_INFORMATION interface */
849 enum smb_fileinfo_level level;
851 union smb_handle_or_path file;
858 /* RAW_FILEINFO_ALIGNMENT_INFORMATION interface */
860 enum smb_fileinfo_level level;
862 union smb_handle_or_path file;
865 uint32_t alignment_requirement;
867 } alignment_information;
869 /* RAW_FILEINFO_NETWORK_OPEN_INFORMATION interface */
871 enum smb_fileinfo_level level;
873 union smb_handle_or_path file;
884 } network_open_information;
887 /* RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION interface */
889 enum smb_fileinfo_level level;
891 union smb_handle_or_path file;
895 uint32_t reparse_tag;
897 } attribute_tag_information;
899 /* RAW_FILEINFO_SEC_DESC */
901 enum smb_fileinfo_level level;
903 union smb_handle_or_path file;
904 uint32_t secinfo_flags;
907 struct security_descriptor *sd;
913 enum smb_setfileinfo_level {
914 RAW_SFILEINFO_GENERIC = 0xF000,
915 RAW_SFILEINFO_SETATTR, /* SMBsetatr */
916 RAW_SFILEINFO_SETATTRE, /* SMBsetattrE */
917 RAW_SFILEINFO_SEC_DESC, /* NT_TRANSACT_SET_SECURITY_DESC */
918 RAW_SFILEINFO_STANDARD = SMB_SFILEINFO_STANDARD,
919 RAW_SFILEINFO_EA_SET = SMB_SFILEINFO_EA_SET,
920 RAW_SFILEINFO_BASIC_INFO = SMB_SFILEINFO_BASIC_INFO,
921 RAW_SFILEINFO_DISPOSITION_INFO = SMB_SFILEINFO_DISPOSITION_INFO,
922 RAW_SFILEINFO_ALLOCATION_INFO = SMB_SFILEINFO_ALLOCATION_INFO,
923 RAW_SFILEINFO_END_OF_FILE_INFO = SMB_SFILEINFO_END_OF_FILE_INFO,
924 RAW_SFILEINFO_UNIX_BASIC = SMB_SFILEINFO_UNIX_BASIC,
925 RAW_SFILEINFO_UNIX_INFO2 = SMB_SFILEINFO_UNIX_INFO2,
926 RAW_SFILEINFO_UNIX_LINK = SMB_SFILEINFO_UNIX_LINK,
927 RAW_SFILEINFO_UNIX_HLINK = SMB_SFILEINFO_UNIX_HLINK,
928 RAW_SFILEINFO_BASIC_INFORMATION = SMB_SFILEINFO_BASIC_INFORMATION,
929 RAW_SFILEINFO_RENAME_INFORMATION = SMB_SFILEINFO_RENAME_INFORMATION,
930 RAW_SFILEINFO_LINK_INFORMATION = SMB_SFILEINFO_LINK_INFORMATION,
931 RAW_SFILEINFO_DISPOSITION_INFORMATION = SMB_SFILEINFO_DISPOSITION_INFORMATION,
932 RAW_SFILEINFO_POSITION_INFORMATION = SMB_SFILEINFO_POSITION_INFORMATION,
933 RAW_SFILEINFO_FULL_EA_INFORMATION = SMB_SFILEINFO_FULL_EA_INFORMATION,
934 RAW_SFILEINFO_MODE_INFORMATION = SMB_SFILEINFO_MODE_INFORMATION,
935 RAW_SFILEINFO_ALLOCATION_INFORMATION = SMB_SFILEINFO_ALLOCATION_INFORMATION,
936 RAW_SFILEINFO_END_OF_FILE_INFORMATION = SMB_SFILEINFO_END_OF_FILE_INFORMATION,
937 RAW_SFILEINFO_PIPE_INFORMATION = SMB_SFILEINFO_PIPE_INFORMATION,
938 RAW_SFILEINFO_VALID_DATA_INFORMATION = SMB_SFILEINFO_VALID_DATA_INFORMATION,
939 RAW_SFILEINFO_SHORT_NAME_INFORMATION = SMB_SFILEINFO_SHORT_NAME_INFORMATION,
940 RAW_SFILEINFO_1025 = SMB_SFILEINFO_1025,
941 RAW_SFILEINFO_1027 = SMB_SFILEINFO_1027,
942 RAW_SFILEINFO_1029 = SMB_SFILEINFO_1029,
943 RAW_SFILEINFO_1030 = SMB_SFILEINFO_1030,
944 RAW_SFILEINFO_1031 = SMB_SFILEINFO_1031,
945 RAW_SFILEINFO_1032 = SMB_SFILEINFO_1032,
946 RAW_SFILEINFO_1036 = SMB_SFILEINFO_1036,
947 RAW_SFILEINFO_1041 = SMB_SFILEINFO_1041,
948 RAW_SFILEINFO_1042 = SMB_SFILEINFO_1042,
949 RAW_SFILEINFO_1043 = SMB_SFILEINFO_1043,
950 RAW_SFILEINFO_1044 = SMB_SFILEINFO_1044,
952 /* cope with breakage in SMB2 */
953 RAW_SFILEINFO_RENAME_INFORMATION_SMB2 = SMB_SFILEINFO_RENAME_INFORMATION|0x80000000,
956 /* union used in setfileinfo() and setpathinfo() calls */
957 union smb_setfileinfo {
958 /* generic interface */
960 enum smb_setfileinfo_level level;
962 union smb_handle_or_path file;
966 /* RAW_SFILEINFO_SETATTR (SMBsetatr) interface - only via setpathinfo() */
968 enum smb_setfileinfo_level level;
970 union smb_handle_or_path file;
976 /* RAW_SFILEINFO_SETATTRE (SMBsetattrE) interface - only via setfileinfo()
977 also RAW_SFILEINFO_STANDARD */
979 enum smb_setfileinfo_level level;
981 union smb_handle_or_path file;
985 /* notice that size, alloc_size and attrib are not settable,
986 unlike the corresponding qfileinfo level */
988 } setattre, standard;
990 /* RAW_SFILEINFO_EA_SET interface */
992 enum smb_setfileinfo_level level;
994 union smb_handle_or_path file;
996 struct ea_struct *eas;
1000 /* RAW_SFILEINFO_BASIC_INFO and
1001 RAW_SFILEINFO_BASIC_INFORMATION interfaces */
1003 enum smb_setfileinfo_level level;
1005 union smb_handle_or_path file;
1015 /* RAW_SFILEINFO_DISPOSITION_INFO and
1016 RAW_SFILEINFO_DISPOSITION_INFORMATION interfaces */
1018 enum smb_setfileinfo_level level;
1020 union smb_handle_or_path file;
1021 bool delete_on_close;
1025 /* RAW_SFILEINFO_ALLOCATION_INFO and
1026 RAW_SFILEINFO_ALLOCATION_INFORMATION interfaces */
1028 enum smb_setfileinfo_level level;
1030 union smb_handle_or_path file;
1031 /* w2k3 rounds this up to nearest 4096 */
1032 uint64_t alloc_size;
1036 /* RAW_SFILEINFO_END_OF_FILE_INFO and
1037 RAW_SFILEINFO_END_OF_FILE_INFORMATION interfaces */
1039 enum smb_setfileinfo_level level;
1041 union smb_handle_or_path file;
1046 /* RAW_SFILEINFO_RENAME_INFORMATION interface */
1048 enum smb_setfileinfo_level level;
1050 union smb_handle_or_path file;
1053 const char *new_name;
1055 } rename_information;
1057 /* RAW_SFILEINFO_LINK_INFORMATION interface */
1059 enum smb_setfileinfo_level level;
1061 union smb_handle_or_path file;
1064 const char *new_name;
1068 /* RAW_SFILEINFO_POSITION_INFORMATION interface */
1070 enum smb_setfileinfo_level level;
1072 union smb_handle_or_path file;
1075 } position_information;
1077 /* RAW_SFILEINFO_MODE_INFORMATION interface */
1079 enum smb_setfileinfo_level level;
1081 union smb_handle_or_path file;
1082 /* valid values seem to be 0, 2, 4 and 6 */
1087 /* RAW_SFILEINFO_UNIX_BASIC interface */
1089 enum smb_setfileinfo_level level;
1091 union smb_handle_or_path file;
1092 uint32_t mode; /* yuck - this field remains to fix compile of libcli/clifile.c */
1093 uint64_t end_of_file;
1095 NTTIME status_change_time;
1104 uint64_t permissions;
1109 /* RAW_SFILEINFO_UNIX_INFO2 interface */
1111 enum smb_setfileinfo_level level;
1113 union smb_handle_or_path file;
1114 uint64_t end_of_file;
1116 NTTIME status_change_time;
1125 uint64_t permissions;
1128 uint32_t file_flags;
1129 uint32_t flags_mask;
1133 /* RAW_SFILEINFO_UNIX_LINK, RAW_SFILEINFO_UNIX_HLINK interface */
1135 enum smb_setfileinfo_level level;
1137 union smb_handle_or_path file;
1138 const char *link_dest;
1140 } unix_link, unix_hlink;
1142 /* RAW_FILEINFO_SET_SEC_DESC */
1144 enum smb_setfileinfo_level level;
1146 union smb_handle_or_path file;
1147 uint32_t secinfo_flags;
1148 struct security_descriptor *sd;
1152 /* RAW_SFILEINFO_FULL_EA_INFORMATION */
1154 enum smb_setfileinfo_level level;
1156 union smb_handle_or_path file;
1157 struct smb_ea_list eas;
1159 } full_ea_information;
1163 enum smb_fsinfo_level {
1164 RAW_QFS_GENERIC = 0xF000,
1165 RAW_QFS_DSKATTR, /* SMBdskattr */
1166 RAW_QFS_ALLOCATION = SMB_QFS_ALLOCATION,
1167 RAW_QFS_VOLUME = SMB_QFS_VOLUME,
1168 RAW_QFS_VOLUME_INFO = SMB_QFS_VOLUME_INFO,
1169 RAW_QFS_SIZE_INFO = SMB_QFS_SIZE_INFO,
1170 RAW_QFS_DEVICE_INFO = SMB_QFS_DEVICE_INFO,
1171 RAW_QFS_ATTRIBUTE_INFO = SMB_QFS_ATTRIBUTE_INFO,
1172 RAW_QFS_UNIX_INFO = SMB_QFS_UNIX_INFO,
1173 RAW_QFS_VOLUME_INFORMATION = SMB_QFS_VOLUME_INFORMATION,
1174 RAW_QFS_SIZE_INFORMATION = SMB_QFS_SIZE_INFORMATION,
1175 RAW_QFS_DEVICE_INFORMATION = SMB_QFS_DEVICE_INFORMATION,
1176 RAW_QFS_ATTRIBUTE_INFORMATION = SMB_QFS_ATTRIBUTE_INFORMATION,
1177 RAW_QFS_QUOTA_INFORMATION = SMB_QFS_QUOTA_INFORMATION,
1178 RAW_QFS_FULL_SIZE_INFORMATION = SMB_QFS_FULL_SIZE_INFORMATION,
1179 RAW_QFS_OBJECTID_INFORMATION = SMB_QFS_OBJECTID_INFORMATION};
1182 /* union for fsinfo() backend call. Note that there are no in
1183 structures, as this call only contains out parameters */
1185 /* generic interface */
1187 enum smb_fsinfo_level level;
1188 struct smb2_handle handle; /* only for smb2 */
1191 uint32_t block_size;
1192 uint64_t blocks_total;
1193 uint64_t blocks_free;
1196 uint32_t serial_number;
1198 uint32_t max_file_component_length;
1199 uint32_t device_type;
1200 uint32_t device_characteristics;
1201 uint64_t quota_soft;
1202 uint64_t quota_hard;
1203 uint64_t quota_flags;
1210 /* SMBdskattr interface */
1212 enum smb_fsinfo_level level;
1215 uint16_t units_total;
1216 uint16_t blocks_per_unit;
1217 uint16_t block_size;
1218 uint16_t units_free;
1222 /* trans2 RAW_QFS_ALLOCATION interface */
1224 enum smb_fsinfo_level level;
1228 uint32_t sectors_per_unit;
1229 uint32_t total_alloc_units;
1230 uint32_t avail_alloc_units;
1231 uint16_t bytes_per_sector;
1235 /* TRANS2 RAW_QFS_VOLUME interface */
1237 enum smb_fsinfo_level level;
1240 uint32_t serial_number;
1241 struct smb_wire_string volume_name;
1245 /* TRANS2 RAW_QFS_VOLUME_INFO and RAW_QFS_VOLUME_INFORMATION interfaces */
1247 enum smb_fsinfo_level level;
1248 struct smb2_handle handle; /* only for smb2 */
1252 uint32_t serial_number;
1253 struct smb_wire_string volume_name;
1257 /* trans2 RAW_QFS_SIZE_INFO and RAW_QFS_SIZE_INFORMATION interfaces */
1259 enum smb_fsinfo_level level;
1260 struct smb2_handle handle; /* only for smb2 */
1263 uint64_t total_alloc_units;
1264 uint64_t avail_alloc_units; /* maps to call_avail_alloc_units */
1265 uint32_t sectors_per_unit;
1266 uint32_t bytes_per_sector;
1270 /* TRANS2 RAW_QFS_DEVICE_INFO and RAW_QFS_DEVICE_INFORMATION interfaces */
1272 enum smb_fsinfo_level level;
1273 struct smb2_handle handle; /* only for smb2 */
1276 uint32_t device_type;
1277 uint32_t characteristics;
1282 /* TRANS2 RAW_QFS_ATTRIBUTE_INFO and RAW_QFS_ATTRIBUTE_INFORMATION interfaces */
1284 enum smb_fsinfo_level level;
1285 struct smb2_handle handle; /* only for smb2 */
1289 uint32_t max_file_component_length;
1290 struct smb_wire_string fs_type;
1295 /* TRANS2 RAW_QFS_UNIX_INFO interface */
1297 enum smb_fsinfo_level level;
1300 uint16_t major_version;
1301 uint16_t minor_version;
1302 uint64_t capability;
1306 /* trans2 RAW_QFS_QUOTA_INFORMATION interface */
1308 enum smb_fsinfo_level level;
1309 struct smb2_handle handle; /* only for smb2 */
1312 uint64_t unknown[3];
1313 uint64_t quota_soft;
1314 uint64_t quota_hard;
1315 uint64_t quota_flags;
1317 } quota_information;
1319 /* trans2 RAW_QFS_FULL_SIZE_INFORMATION interface */
1321 enum smb_fsinfo_level level;
1322 struct smb2_handle handle; /* only for smb2 */
1325 uint64_t total_alloc_units;
1326 uint64_t call_avail_alloc_units;
1327 uint64_t actual_avail_alloc_units;
1328 uint32_t sectors_per_unit;
1329 uint32_t bytes_per_sector;
1331 } full_size_information;
1333 /* trans2 RAW_QFS_OBJECTID_INFORMATION interface */
1335 enum smb_fsinfo_level level;
1336 struct smb2_handle handle; /* only for smb2 */
1340 uint64_t unknown[6];
1342 } objectid_information;
1347 enum smb_open_level {
1356 RAW_OPEN_NTTRANS_CREATE,
1357 RAW_OPEN_OPENX_READX,
1361 /* the generic interface is defined to be equal to the NTCREATEX interface */
1362 #define RAW_OPEN_GENERIC RAW_OPEN_NTCREATEX
1364 /* union for open() backend call */
1367 * because the *.out.file structs are not aligned to the same offset for each level
1368 * we provide a hepler macro that should be used to find the current smb_handle structure
1370 #define SMB_OPEN_OUT_FILE(op, file) do { \
1371 switch (op->generic.level) { \
1372 case RAW_OPEN_OPEN: \
1373 file = &op->openold.out.file; \
1375 case RAW_OPEN_OPENX: \
1376 file = &op->openx.out.file; \
1378 case RAW_OPEN_MKNEW: \
1379 file = &op->mknew.out.file; \
1381 case RAW_OPEN_CREATE: \
1382 file = &op->create.out.file; \
1384 case RAW_OPEN_CTEMP: \
1385 file = &op->ctemp.out.file; \
1387 case RAW_OPEN_SPLOPEN: \
1388 file = &op->splopen.out.file; \
1390 case RAW_OPEN_NTCREATEX: \
1391 file = &op->ntcreatex.out.file; \
1393 case RAW_OPEN_T2OPEN: \
1394 file = &op->t2open.out.file; \
1396 case RAW_OPEN_NTTRANS_CREATE: \
1397 file = &op->nttrans.out.file; \
1399 case RAW_OPEN_OPENX_READX: \
1400 file = &op->openxreadx.out.file; \
1402 case RAW_OPEN_SMB2: \
1403 file = &op->smb2.out.file; \
1406 /* this must be a programmer error */ \
1411 /* SMBNTCreateX, nttrans and generic interface */
1413 enum smb_open_level level;
1417 uint32_t access_mask;
1418 uint64_t alloc_size;
1420 uint32_t share_access;
1421 uint32_t open_disposition;
1422 uint32_t create_options;
1423 uint32_t impersonation;
1424 uint8_t security_flags;
1425 /* NOTE: fname can also be a pointer to a
1426 uint64_t file_id if create_options has the
1427 NTCREATEX_OPTIONS_OPEN_BY_FILE_ID flag set */
1430 /* these last 2 elements are only used in the
1431 NTTRANS varient of the call */
1432 struct security_descriptor *sec_desc;
1433 struct smb_ea_list *ea_list;
1435 /* some optional parameters from the SMB2 varient */
1436 bool query_maximal_access;
1439 union smb_handle file;
1440 uint8_t oplock_level;
1441 uint32_t create_action;
1447 uint64_t alloc_size;
1451 uint8_t is_directory;
1453 /* optional return values matching SMB2 tagged
1454 values in the call */
1455 uint32_t maximal_access;
1457 } ntcreatex, nttrans, generic;
1459 /* TRANS2_OPEN interface */
1461 enum smb_open_level level;
1465 uint16_t search_attrs;
1466 uint16_t file_attrs;
1473 struct ea_struct *eas;
1476 union smb_handle file;
1488 /* SMBopen interface */
1490 enum smb_open_level level;
1493 uint16_t search_attrs;
1497 union smb_handle file;
1505 /* SMBopenX interface */
1507 enum smb_open_level level;
1511 uint16_t search_attrs; /* not honoured by win2003 */
1512 uint16_t file_attrs;
1513 time_t write_time; /* not honoured by win2003 */
1515 uint32_t size; /* note that this sets the
1516 initial file size, not
1517 just allocation size */
1518 uint32_t timeout; /* not honoured by win2003 */
1522 union smb_handle file;
1530 uint32_t unique_fid;
1531 uint32_t access_mask;
1536 /* SMBmknew interface */
1538 enum smb_open_level level;
1545 union smb_handle file;
1549 /* SMBctemp interface */
1551 enum smb_open_level level;
1555 const char *directory;
1558 union smb_handle file;
1559 /* temp name, relative to directory */
1564 /* SMBsplopen interface */
1566 enum smb_open_level level;
1568 uint16_t setup_length;
1573 union smb_handle file;
1578 /* chained OpenX/ReadX interface */
1580 enum smb_open_level level;
1584 uint16_t search_attrs; /* not honoured by win2003 */
1585 uint16_t file_attrs;
1586 time_t write_time; /* not honoured by win2003 */
1588 uint32_t size; /* note that this sets the
1589 initial file size, not
1590 just allocation size */
1591 uint32_t timeout; /* not honoured by win2003 */
1601 union smb_handle file;
1609 uint32_t unique_fid;
1610 uint32_t access_mask;
1616 uint16_t compaction_mode;
1621 #define SMB2_CREATE_FLAG_REQUEST_OPLOCK 0x0100
1622 #define SMB2_CREATE_FLAG_REQUEST_EXCLUSIVE_OPLOCK 0x0800
1623 #define SMB2_CREATE_FLAG_GRANT_OPLOCK 0x0001
1624 #define SMB2_CREATE_FLAG_GRANT_EXCLUSIVE_OPLOCK 0x0080
1627 struct smb2_create {
1628 enum smb_open_level level;
1630 /* static body buffer 56 (0x38) bytes */
1631 uint8_t security_flags; /* SMB2_SECURITY_* */
1632 uint8_t oplock_level; /* SMB2_OPLOCK_LEVEL_* */
1633 uint32_t impersonation_level; /* SMB2_IMPERSONATION_* */
1634 uint64_t create_flags;
1636 uint32_t desired_access;
1637 uint32_t file_attributes;
1638 uint32_t share_access; /* NTCREATEX_SHARE_ACCESS_* */
1639 uint32_t create_disposition; /* NTCREATEX_DISP_* */
1640 uint32_t create_options; /* NTCREATEX_OPTIONS_* */
1642 /* uint16_t fname_ofs */
1643 /* uint16_t fname_size */
1644 /* uint32_t blob_ofs; */
1645 /* uint32_t blob_size; */
1650 /* now some optional parameters - encoded as tagged blobs */
1651 struct smb_ea_list eas;
1652 uint64_t alloc_size;
1653 struct security_descriptor *sec_desc;
1655 struct smb2_handle *durable_handle;
1656 bool query_maximal_access;
1658 bool query_on_disk_id;
1659 struct smb2_lease *lease_request;
1661 /* and any additional blobs the caller wants */
1662 struct smb2_create_blobs {
1664 struct smb2_create_blob {
1671 union smb_handle file;
1673 /* static body buffer 88 (0x58) bytes */
1674 /* uint16_t buffer_code; 0x59 = 0x58 + 1 */
1675 uint8_t oplock_level;
1677 uint32_t create_action;
1682 uint64_t alloc_size;
1686 /* struct smb2_handle handle;*/
1687 /* uint32_t blob_ofs; */
1688 /* uint32_t blob_size; */
1690 /* optional return values matching tagged values in the call */
1691 uint32_t maximal_access;
1692 uint8_t on_disk_id[32];
1693 struct smb2_lease lease_response;
1695 /* tagged blobs in the reply */
1696 struct smb2_create_blobs blobs;
1703 enum smb_read_level {
1711 #define RAW_READ_GENERIC RAW_READ_READX
1713 /* union for read() backend call
1715 note that .infoX.out.data will be allocated before the backend is
1716 called. It will be big enough to hold the maximum size asked for
1719 /* SMBreadX (and generic) interface */
1721 enum smb_read_level level;
1723 union smb_handle file;
1725 uint32_t mincnt; /* enforced on SMB2, 16 bit on SMB */
1728 bool read_for_execute;
1733 uint16_t compaction_mode;
1738 /* SMBreadbraw interface */
1740 enum smb_read_level level;
1742 union smb_handle file;
1755 /* SMBlockandread interface */
1757 enum smb_read_level level;
1759 union smb_handle file;
1770 /* SMBread interface */
1772 enum smb_read_level level;
1774 union smb_handle file;
1787 enum smb_read_level level;
1789 union smb_handle file;
1791 /* static body buffer 48 (0x30) bytes */
1792 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
1797 /* struct smb2_handle handle; */
1801 /* the docs give no indication of what
1802 these channel variables are for */
1803 uint16_t channel_offset;
1804 uint16_t channel_length;
1807 /* static body buffer 16 (0x10) bytes */
1808 /* uint16_t buffer_code; 0x11 = 0x10 + 1 */
1809 /* uint8_t data_ofs; */
1810 /* uint8_t reserved; */
1811 /* uint32_t data_size; */
1822 enum smb_write_level {
1823 RAW_WRITE_WRITEUNLOCK,
1826 RAW_WRITE_WRITECLOSE,
1831 #define RAW_WRITE_GENERIC RAW_WRITE_WRITEX
1833 /* union for write() backend call
1836 /* SMBwriteX interface */
1838 enum smb_write_level level;
1840 union smb_handle file;
1845 const uint8_t *data;
1853 /* SMBwriteunlock interface */
1855 enum smb_write_level level;
1857 union smb_handle file;
1861 const uint8_t *data;
1868 /* SMBwrite interface */
1870 enum smb_write_level level;
1872 union smb_handle file;
1876 const uint8_t *data;
1883 /* SMBwriteclose interface */
1885 enum smb_write_level level;
1887 union smb_handle file;
1891 const uint8_t *data;
1898 /* SMBsplwrite interface */
1900 enum smb_write_level level;
1902 union smb_handle file;
1904 const uint8_t *data;
1910 enum smb_write_level level;
1912 union smb_handle file;
1914 /* static body buffer 48 (0x30) bytes */
1915 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
1916 /* uint16_t data_ofs; */
1917 /* uint32_t data_size; */
1919 /* struct smb2_handle handle; */
1920 uint64_t unknown1; /* 0xFFFFFFFFFFFFFFFF */
1921 uint64_t unknown2; /* 0xFFFFFFFFFFFFFFFF */
1927 /* static body buffer 17 (0x11) bytes */
1928 /* uint16_t buffer_code; 0x11 = 0x10 + 1*/
1931 uint64_t unknown1; /* 0x0000000000000000 */
1937 enum smb_lock_level {
1945 #define RAW_LOCK_GENERIC RAW_LOCK_LOCKX
1947 /* union for lock() backend call
1950 /* SMBlockingX and generic interface */
1952 enum smb_lock_level level;
1954 union smb_handle file;
1959 struct smb_lock_entry {
1960 uint32_t pid; /* 16 bits in SMB1 */
1963 } *locks; /* unlocks are first in the arrray */
1967 /* SMBlock and SMBunlock interface */
1969 enum smb_lock_level level;
1971 union smb_handle file;
1979 enum smb_lock_level level;
1981 union smb_handle file;
1983 /* static body buffer 48 (0x30) bytes */
1984 /* uint16_t buffer_code; 0x30 */
1985 uint16_t lock_count;
1987 /* struct smb2_handle handle; */
1988 struct smb2_lock_element {
1991 /* these flags are the same as the SMB2 lock flags */
1992 #define SMB2_LOCK_FLAG_NONE 0x00000000
1993 #define SMB2_LOCK_FLAG_SHARED 0x00000001
1994 #define SMB2_LOCK_FLAG_EXCLUSIVE 0x00000002
1995 #define SMB2_LOCK_FLAG_UNLOCK 0x00000004
1996 #define SMB2_LOCK_FLAG_FAIL_IMMEDIATELY 0x00000010
1997 #define SMB2_LOCK_FLAG_ALL_MASK 0x00000017
2003 /* static body buffer 4 (0x04) bytes */
2004 /* uint16_t buffer_code; 0x04 */
2011 enum smb_lock_level level;
2013 union smb_handle file;
2015 /* static body buffer 24 (0x18) bytes */
2016 uint8_t oplock_level;
2019 /* struct smb2_handle handle; */
2023 /* SMB2 Lease Break Ack (same opcode as smb2_break) */
2024 struct smb2_lease_break_ack {
2027 struct smb2_lease lease;
2029 } smb2_lease_break_ack;
2033 enum smb_close_level {
2041 union for close() backend call
2044 /* generic interface */
2046 enum smb_close_level level;
2048 union smb_handle file;
2050 #define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
2051 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
2059 uint64_t alloc_size;
2065 /* SMBclose interface */
2067 enum smb_close_level level;
2069 union smb_handle file;
2074 /* SMBsplclose interface - empty! */
2076 enum smb_close_level level;
2078 union smb_handle file;
2084 enum smb_close_level level;
2086 union smb_handle file;
2088 /* static body buffer 24 (0x18) bytes */
2089 /* uint16_t buffer_code; 0x18 */
2090 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
2094 /* static body buffer 60 (0x3C) bytes */
2095 /* uint16_t buffer_code; 0x3C */
2102 uint64_t alloc_size;
2110 enum smb_lpq_level {RAW_LPQ_GENERIC, RAW_LPQ_RETQ};
2113 union for lpq() backend
2116 /* generic interface */
2118 enum smb_lpq_level level;
2123 /* SMBsplretq interface */
2125 enum smb_lpq_level level;
2133 uint16_t restart_idx;
2145 enum smb_ioctl_level {
2149 RAW_IOCTL_SMB2_NO_HANDLE
2153 union for ioctl() backend
2156 /* generic interface */
2158 enum smb_ioctl_level level;
2160 union smb_handle file;
2164 /* struct for SMBioctl */
2166 enum smb_ioctl_level level;
2168 union smb_handle file;
2177 /* struct for NT ioctl call */
2179 enum smb_ioctl_level level;
2181 union smb_handle file;
2195 enum smb_ioctl_level level;
2197 union smb_handle file;
2199 /* static body buffer 56 (0x38) bytes */
2200 /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
2203 /*struct smb2_handle handle;*/
2204 /* uint32_t out_ofs; */
2205 /* uint32_t out_size; */
2207 /* uint32_t in_ofs; */
2208 /* uint32_t in_size; */
2209 uint32_t max_response_size;
2217 union smb_handle file;
2219 /* static body buffer 48 (0x30) bytes */
2220 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
2223 /* struct smb2_handle handle; */
2224 /* uint32_t in_ofs; */
2225 /* uint32_t in_size; */
2226 /* uint32_t out_ofs; */
2227 /* uint32_t out_size; */
2238 enum smb_flush_level {
2245 /* struct for SMBflush */
2247 enum smb_flush_level level;
2249 union smb_handle file;
2253 /* SMBflush with 0xFFFF wildcard fnum */
2255 enum smb_flush_level level;
2260 enum smb_flush_level level;
2262 union smb_handle file;
2272 /* struct for SMBcopy */
2287 /* struct for transact/transact2 call */
2295 uint8_t setup_count;
2297 const char *trans_name; /* SMBtrans only */
2303 uint8_t setup_count;
2310 /* struct for nttransact2 call */
2311 struct smb_nttrans {
2316 uint8_t setup_count;
2324 uint8_t setup_count; /* in units of 16 bit words */
2331 enum smb_notify_level {
2337 /* struct for nttrans change notify call */
2339 enum smb_notify_level level;
2342 union smb_handle file;
2343 uint32_t buffer_size;
2344 uint32_t completion_filter;
2349 uint32_t num_changes;
2350 struct notify_changes {
2352 struct smb_wire_string name;
2357 struct smb2_notify {
2358 enum smb_notify_level level;
2361 union smb_handle file;
2362 /* static body buffer 32 (0x20) bytes */
2363 /* uint16_t buffer_code; 0x32 */
2365 uint32_t buffer_size;
2366 /*struct smb2_handle file;*/
2367 uint32_t completion_filter;
2372 /* static body buffer 8 (0x08) bytes */
2373 /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
2374 /* uint16_t blob_ofs; */
2375 /* uint16_t blob_size; */
2380 /* DATA_BLOB content */
2381 uint32_t num_changes;
2382 struct notify_changes *changes;
2387 enum smb_search_level {
2388 RAW_SEARCH_SEARCH, /* SMBsearch */
2389 RAW_SEARCH_FFIRST, /* SMBffirst */
2390 RAW_SEARCH_FUNIQUE, /* SMBfunique */
2391 RAW_SEARCH_TRANS2, /* SMBtrans2 */
2392 RAW_SEARCH_SMB2 /* SMB2 Find */
2395 enum smb_search_data_level {
2396 RAW_SEARCH_DATA_GENERIC = 0x10000, /* only used in the smbcli_ code */
2397 RAW_SEARCH_DATA_SEARCH,
2398 RAW_SEARCH_DATA_STANDARD = SMB_FIND_STANDARD,
2399 RAW_SEARCH_DATA_EA_SIZE = SMB_FIND_EA_SIZE,
2400 RAW_SEARCH_DATA_EA_LIST = SMB_FIND_EA_LIST,
2401 RAW_SEARCH_DATA_DIRECTORY_INFO = SMB_FIND_DIRECTORY_INFO,
2402 RAW_SEARCH_DATA_FULL_DIRECTORY_INFO = SMB_FIND_FULL_DIRECTORY_INFO,
2403 RAW_SEARCH_DATA_NAME_INFO = SMB_FIND_NAME_INFO,
2404 RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO = SMB_FIND_BOTH_DIRECTORY_INFO,
2405 RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO = SMB_FIND_ID_FULL_DIRECTORY_INFO,
2406 RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
2407 RAW_SEARCH_DATA_UNIX_INFO = SMB_FIND_UNIX_INFO,
2408 RAW_SEARCH_DATA_UNIX_INFO2 = SMB_FIND_UNIX_INFO2
2411 /* union for file search */
2412 union smb_search_first {
2414 enum smb_search_level level;
2415 enum smb_search_data_level data_level;
2418 /* search (old) findfirst interface.
2419 Also used for ffirst and funique. */
2421 enum smb_search_level level;
2422 enum smb_search_data_level data_level;
2426 uint16_t search_attrib;
2427 const char *pattern;
2434 /* trans2 findfirst interface */
2436 enum smb_search_level level;
2437 enum smb_search_data_level data_level;
2440 uint16_t search_attrib;
2443 uint32_t storage_type;
2444 const char *pattern;
2446 /* the ea names are only used for RAW_SEARCH_EA_LIST */
2448 struct ea_name *ea_names;
2453 uint16_t end_of_search;
2458 SMB2 uses different level numbers for the same old SMB trans2 search levels
2460 #define SMB2_FIND_DIRECTORY_INFO 0x01
2461 #define SMB2_FIND_FULL_DIRECTORY_INFO 0x02
2462 #define SMB2_FIND_BOTH_DIRECTORY_INFO 0x03
2463 #define SMB2_FIND_NAME_INFO 0x0C
2464 #define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25
2465 #define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26
2467 /* flags for SMB2 find */
2468 #define SMB2_CONTINUE_FLAG_RESTART 0x01
2469 #define SMB2_CONTINUE_FLAG_SINGLE 0x02
2470 #define SMB2_CONTINUE_FLAG_INDEX 0x04
2471 #define SMB2_CONTINUE_FLAG_REOPEN 0x10
2475 enum smb_search_level level;
2476 enum smb_search_data_level data_level;
2478 union smb_handle file;
2480 /* static body buffer 32 (0x20) bytes */
2481 /* uint16_t buffer_code; 0x21 = 0x20 + 1 */
2483 uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */
2484 uint32_t file_index;
2485 /* struct smb2_handle handle; */
2486 /* uint16_t pattern_ofs; */
2487 /* uint16_t pattern_size; */
2488 uint32_t max_response_size;
2491 const char *pattern;
2494 /* static body buffer 8 (0x08) bytes */
2495 /* uint16_t buffer_code; 0x08 */
2496 /* uint16_t blob_ofs; */
2497 /* uint32_t blob_size; */
2505 /* union for file search continue */
2506 union smb_search_next {
2508 enum smb_search_level level;
2509 enum smb_search_data_level data_level;
2512 /* search (old) findnext interface. Also used
2513 for ffirst when continuing */
2515 enum smb_search_level level;
2516 enum smb_search_data_level data_level;
2520 uint16_t search_attrib;
2521 struct smb_search_id {
2525 uint32_t server_cookie;
2526 uint32_t client_cookie;
2534 /* trans2 findnext interface */
2536 enum smb_search_level level;
2537 enum smb_search_data_level data_level;
2542 uint32_t resume_key;
2544 const char *last_name;
2546 /* the ea names are only used for RAW_SEARCH_EA_LIST */
2548 struct ea_name *ea_names;
2552 uint16_t end_of_search;
2557 struct smb2_find smb2;
2560 /* union for search reply file data */
2561 union smb_search_data {
2563 * search (old) findfirst
2564 * RAW_SEARCH_DATA_SEARCH
2570 struct smb_search_id id;
2574 /* trans2 findfirst RAW_SEARCH_DATA_STANDARD level */
2576 uint32_t resume_key;
2581 uint32_t alloc_size;
2583 struct smb_wire_string name;
2586 /* trans2 findfirst RAW_SEARCH_DATA_EA_SIZE level */
2588 uint32_t resume_key;
2593 uint32_t alloc_size;
2596 struct smb_wire_string name;
2599 /* trans2 findfirst RAW_SEARCH_DATA_EA_LIST level */
2601 uint32_t resume_key;
2606 uint32_t alloc_size;
2608 struct smb_ea_list eas;
2609 struct smb_wire_string name;
2612 /* RAW_SEARCH_DATA_DIRECTORY_INFO interface */
2614 uint32_t file_index;
2620 uint64_t alloc_size;
2622 struct smb_wire_string name;
2625 /* RAW_SEARCH_DATA_FULL_DIRECTORY_INFO interface */
2627 uint32_t file_index;
2633 uint64_t alloc_size;
2636 struct smb_wire_string name;
2637 } full_directory_info;
2639 /* RAW_SEARCH_DATA_NAME_INFO interface */
2641 uint32_t file_index;
2642 struct smb_wire_string name;
2645 /* RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO interface */
2647 uint32_t file_index;
2653 uint64_t alloc_size;
2656 struct smb_wire_string short_name;
2657 struct smb_wire_string name;
2658 } both_directory_info;
2660 /* RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO interface */
2662 uint32_t file_index;
2668 uint64_t alloc_size;
2672 struct smb_wire_string name;
2673 } id_full_directory_info;
2675 /* RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO interface */
2677 uint32_t file_index;
2683 uint64_t alloc_size;
2687 struct smb_wire_string short_name;
2688 struct smb_wire_string name;
2689 } id_both_directory_info;
2691 /* RAW_SEARCH_DATA_UNIX_INFO interface */
2693 uint32_t file_index;
2695 uint64_t alloc_size;
2696 NTTIME status_change_time;
2705 uint64_t permissions;
2710 /* RAW_SEARCH_DATA_UNIX_INFO2 interface */
2712 uint32_t file_index;
2713 uint64_t end_of_file;
2715 NTTIME status_change_time;
2724 uint64_t permissions;
2727 uint32_t file_flags;
2728 uint32_t flags_mask;
2729 struct smb_wire_string name;
2733 /* Callback function passed to the raw search interface. */
2734 typedef bool (*smbcli_search_callback)(void *private_data, const union smb_search_data *file);
2736 enum smb_search_close_level {RAW_FINDCLOSE_GENERIC, RAW_FINDCLOSE_FCLOSE, RAW_FINDCLOSE_FINDCLOSE};
2738 /* union for file search close */
2739 union smb_search_close {
2741 enum smb_search_close_level level;
2744 /* SMBfclose (old search) interface */
2746 enum smb_search_close_level level;
2749 /* max_count and search_attrib are not used, but are present */
2751 uint16_t search_attrib;
2752 struct smb_search_id id;
2756 /* SMBfindclose interface */
2758 enum smb_search_close_level level;
2768 struct for SMBecho call
2772 uint16_t repeat_count;
2778 uint16_t sequence_number;
2785 struct for shadow copy volumes
2787 struct smb_shadow_copy {
2789 union smb_handle file;
2793 uint32_t num_volumes;
2799 #endif /* __LIBCLI_RAW_INTERFACES_H__ */