s4:libcli/smb2: add support for SMB2 LEASES v2
[Samba/gebeck_regimport.git] / source4 / libcli / raw / interfaces.h
blobfb73f26a42611144df1fce414b13524368bc0dac
1 /*
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__
25 #include "source4/libcli/raw/smb.h"
26 #include "../libcli/smb/smb_common.h"
27 #include "librpc/gen_ndr/misc.h" /* for struct GUID */
29 /* this structure is just a wrapper for a string, the only reason we
30 bother with this is that it allows us to check the length provided
31 on the wire in testsuite test code to ensure that we are
32 terminating names in the same way that win2003 is. The *ONLY* time
33 you should ever look at the 'private_length' field in this
34 structure is inside compliance test code, in all other cases just
35 use the null terminated char* as the definitive definition of the
36 string
38 also note that this structure is only used in packets where there
39 is an explicit length provided on the wire (hence the name). That
40 length is placed in 'private_length'. For packets where the length
41 is always determined by NULL or packet termination a normal char*
42 is used in the structure definition.
44 struct smb_wire_string {
45 uint32_t private_length;
46 const char *s;
50 * SMB2 uses a 16Byte handle,
51 * (we can maybe use struct GUID later)
53 struct smb2_handle {
54 uint64_t data[2];
58 SMB2 lease structure (per MS-SMB2 2.2.13)
60 struct smb2_lease_key {
61 uint64_t data[2];
64 struct smb2_lease {
65 struct smb2_lease_key lease_key;
66 uint32_t lease_state;
67 uint32_t lease_flags;
68 uint64_t lease_duration; /* should be 0 */
69 /* only for v2 */
70 struct smb2_lease_key parent_lease_key;
71 uint16_t lease_epoch;
74 struct smb2_lease_break {
75 struct smb2_lease current_lease;
76 uint32_t break_flags;
77 uint32_t new_lease_state;
78 uint32_t break_reason; /* should be 0 */
79 uint32_t access_mask_hint; /* should be 0 */
80 uint32_t share_mask_hint; /* should be 0 */
83 struct ntvfs_handle;
86 * a generic container for file handles or file pathes
87 * for qfileinfo/setfileinfo and qpathinfo/setpathinfo
89 union smb_handle_or_path {
91 * this is used for
92 * the qpathinfo and setpathinfo
93 * calls
95 const char *path;
97 * this is used as file handle in SMB
99 uint16_t fnum;
102 * this is used as file handle in SMB2
104 struct smb2_handle handle;
107 * this is used as generic file handle for the NTVFS layer
109 struct ntvfs_handle *ntvfs;
113 a generic container for file handles
115 union smb_handle {
117 * this is used as file handle in SMB
119 uint16_t fnum;
122 * this is used as file handle in SMB2
124 struct smb2_handle handle;
127 * this is used as generic file handle for the NTVFS layer
129 struct ntvfs_handle *ntvfs;
133 this header defines the structures and unions used between the SMB
134 parser and the backends.
137 /* struct used for SMBlseek call */
138 union smb_seek {
139 struct {
140 struct {
141 union smb_handle file;
142 uint16_t mode;
143 int32_t offset; /* signed */
144 } in;
145 struct {
146 int32_t offset;
147 } out;
148 } lseek, generic;
151 /* struct used in unlink() call */
152 union smb_unlink {
153 struct {
154 struct {
155 const char *pattern;
156 uint16_t attrib;
157 } in;
158 } unlink;
162 /* struct used in chkpath() call */
163 union smb_chkpath {
164 struct {
165 struct {
166 const char *path;
167 } in;
168 } chkpath;
171 enum smb_mkdir_level {RAW_MKDIR_GENERIC, RAW_MKDIR_MKDIR, RAW_MKDIR_T2MKDIR};
173 /* union used in mkdir() call */
174 union smb_mkdir {
175 /* generic level */
176 struct {
177 enum smb_mkdir_level level;
178 } generic;
180 struct {
181 enum smb_mkdir_level level;
182 struct {
183 const char *path;
184 } in;
185 } mkdir;
187 struct {
188 enum smb_mkdir_level level;
189 struct {
190 const char *path;
191 unsigned int num_eas;
192 struct ea_struct *eas;
193 } in;
194 } t2mkdir;
197 /* struct used in rmdir() call */
198 struct smb_rmdir {
199 struct {
200 const char *path;
201 } in;
204 /* struct used in rename() call */
205 enum smb_rename_level {RAW_RENAME_RENAME, RAW_RENAME_NTRENAME, RAW_RENAME_NTTRANS};
207 union smb_rename {
208 struct {
209 enum smb_rename_level level;
210 } generic;
212 /* SMBrename interface */
213 struct {
214 enum smb_rename_level level;
216 struct {
217 const char *pattern1;
218 const char *pattern2;
219 uint16_t attrib;
220 } in;
221 } rename;
224 /* SMBntrename interface */
225 struct {
226 enum smb_rename_level level;
228 struct {
229 uint16_t attrib;
230 uint16_t flags; /* see RENAME_FLAG_* */
231 uint32_t cluster_size;
232 const char *old_name;
233 const char *new_name;
234 } in;
235 } ntrename;
237 /* NT TRANS rename interface */
238 struct {
239 enum smb_rename_level level;
241 struct {
242 union smb_handle file;
243 uint16_t flags;/* see RENAME_REPLACE_IF_EXISTS */
244 const char *new_name;
245 } in;
246 } nttrans;
249 enum smb_tcon_level {
250 RAW_TCON_TCON,
251 RAW_TCON_TCONX,
252 RAW_TCON_SMB2
255 /* union used in tree connect call */
256 union smb_tcon {
257 /* generic interface */
258 struct {
259 enum smb_tcon_level level;
260 } generic;
262 /* SMBtcon interface */
263 struct {
264 enum smb_tcon_level level;
266 struct {
267 const char *service;
268 const char *password;
269 const char *dev;
270 } in;
271 struct {
272 uint16_t max_xmit;
273 uint16_t tid;
274 } out;
275 } tcon;
277 /* SMBtconX interface */
278 struct {
279 enum smb_tcon_level level;
281 struct {
282 uint16_t flags;
283 DATA_BLOB password;
284 const char *path;
285 const char *device;
286 } in;
287 struct {
288 uint16_t options;
289 uint32_t max_access;
290 uint32_t guest_max_access;
291 char *dev_type;
292 char *fs_type;
293 uint16_t tid;
294 } out;
295 } tconx;
297 /* SMB2 TreeConnect */
298 struct smb2_tree_connect {
299 enum smb_tcon_level level;
301 struct {
302 /* static body buffer 8 (0x08) bytes */
303 uint16_t reserved;
304 /* uint16_t path_ofs */
305 /* uint16_t path_size */
306 /* dynamic body */
307 const char *path; /* as non-terminated UTF-16 on the wire */
308 } in;
309 struct {
310 /* static body buffer 16 (0x10) bytes */
311 /* uint16_t buffer_code; 0x10 */
312 uint8_t share_type;
313 uint8_t reserved;
314 uint32_t flags;
315 uint32_t capabilities;
316 uint32_t access_mask;
318 /* extracted from the SMB2 header */
319 uint32_t tid;
320 } out;
321 } smb2;
325 enum smb_sesssetup_level {
326 RAW_SESSSETUP_OLD,
327 RAW_SESSSETUP_NT1,
328 RAW_SESSSETUP_SPNEGO,
329 RAW_SESSSETUP_SMB2
332 /* union used in session_setup call */
333 union smb_sesssetup {
334 /* the pre-NT1 interface */
335 struct {
336 enum smb_sesssetup_level level;
338 struct {
339 uint16_t bufsize;
340 uint16_t mpx_max;
341 uint16_t vc_num;
342 uint32_t sesskey;
343 DATA_BLOB password;
344 const char *user;
345 const char *domain;
346 const char *os;
347 const char *lanman;
348 } in;
349 struct {
350 uint16_t action;
351 uint16_t vuid;
352 char *os;
353 char *lanman;
354 char *domain;
355 } out;
356 } old;
358 /* the NT1 interface */
359 struct {
360 enum smb_sesssetup_level level;
362 struct {
363 uint16_t bufsize;
364 uint16_t mpx_max;
365 uint16_t vc_num;
366 uint32_t sesskey;
367 uint32_t capabilities;
368 DATA_BLOB password1;
369 DATA_BLOB password2;
370 const char *user;
371 const char *domain;
372 const char *os;
373 const char *lanman;
374 } in;
375 struct {
376 uint16_t action;
377 uint16_t vuid;
378 char *os;
379 char *lanman;
380 char *domain;
381 } out;
382 } nt1;
385 /* the SPNEGO interface */
386 struct {
387 enum smb_sesssetup_level level;
389 struct {
390 uint16_t bufsize;
391 uint16_t mpx_max;
392 uint16_t vc_num;
393 uint32_t sesskey;
394 uint32_t capabilities;
395 DATA_BLOB secblob;
396 const char *os;
397 const char *lanman;
398 const char *workgroup;
399 } in;
400 struct {
401 uint16_t action;
402 DATA_BLOB secblob;
403 char *os;
404 char *lanman;
405 char *workgroup;
406 uint16_t vuid;
407 } out;
408 } spnego;
410 /* SMB2 SessionSetup */
411 struct smb2_session_setup {
412 enum smb_sesssetup_level level;
414 struct {
415 /* static body 24 (0x18) bytes */
416 uint8_t vc_number;
417 uint8_t security_mode;
418 uint32_t capabilities;
419 uint32_t channel;
420 /* uint16_t secblob_ofs */
421 /* uint16_t secblob_size */
422 uint64_t previous_sessionid;
423 /* dynamic body */
424 DATA_BLOB secblob;
425 } in;
426 struct {
427 /* body buffer 8 (0x08) bytes */
428 uint16_t session_flags;
429 /* uint16_t secblob_ofs */
430 /* uint16_t secblob_size */
431 /* dynamic body */
432 DATA_BLOB secblob;
434 /* extracted from the SMB2 header */
435 uint64_t uid;
436 } out;
437 } smb2;
440 /* Note that the specified enum values are identical to the actual info-levels used
441 * on the wire.
443 enum smb_fileinfo_level {
444 RAW_FILEINFO_GENERIC = 0xF000,
445 RAW_FILEINFO_GETATTR, /* SMBgetatr */
446 RAW_FILEINFO_GETATTRE, /* SMBgetattrE */
447 RAW_FILEINFO_SEC_DESC, /* NT_TRANSACT_QUERY_SECURITY_DESC */
448 RAW_FILEINFO_STANDARD = SMB_QFILEINFO_STANDARD,
449 RAW_FILEINFO_EA_SIZE = SMB_QFILEINFO_EA_SIZE,
450 RAW_FILEINFO_EA_LIST = SMB_QFILEINFO_EA_LIST,
451 RAW_FILEINFO_ALL_EAS = SMB_QFILEINFO_ALL_EAS,
452 RAW_FILEINFO_IS_NAME_VALID = SMB_QFILEINFO_IS_NAME_VALID,
453 RAW_FILEINFO_BASIC_INFO = SMB_QFILEINFO_BASIC_INFO,
454 RAW_FILEINFO_STANDARD_INFO = SMB_QFILEINFO_STANDARD_INFO,
455 RAW_FILEINFO_EA_INFO = SMB_QFILEINFO_EA_INFO,
456 RAW_FILEINFO_NAME_INFO = SMB_QFILEINFO_NAME_INFO,
457 RAW_FILEINFO_ALL_INFO = SMB_QFILEINFO_ALL_INFO,
458 RAW_FILEINFO_ALT_NAME_INFO = SMB_QFILEINFO_ALT_NAME_INFO,
459 RAW_FILEINFO_STREAM_INFO = SMB_QFILEINFO_STREAM_INFO,
460 RAW_FILEINFO_COMPRESSION_INFO = SMB_QFILEINFO_COMPRESSION_INFO,
461 RAW_FILEINFO_UNIX_BASIC = SMB_QFILEINFO_UNIX_BASIC,
462 RAW_FILEINFO_UNIX_INFO2 = SMB_QFILEINFO_UNIX_INFO2,
463 RAW_FILEINFO_UNIX_LINK = SMB_QFILEINFO_UNIX_LINK,
464 RAW_FILEINFO_BASIC_INFORMATION = SMB_QFILEINFO_BASIC_INFORMATION,
465 RAW_FILEINFO_STANDARD_INFORMATION = SMB_QFILEINFO_STANDARD_INFORMATION,
466 RAW_FILEINFO_INTERNAL_INFORMATION = SMB_QFILEINFO_INTERNAL_INFORMATION,
467 RAW_FILEINFO_EA_INFORMATION = SMB_QFILEINFO_EA_INFORMATION,
468 RAW_FILEINFO_ACCESS_INFORMATION = SMB_QFILEINFO_ACCESS_INFORMATION,
469 RAW_FILEINFO_NAME_INFORMATION = SMB_QFILEINFO_NAME_INFORMATION,
470 RAW_FILEINFO_POSITION_INFORMATION = SMB_QFILEINFO_POSITION_INFORMATION,
471 RAW_FILEINFO_MODE_INFORMATION = SMB_QFILEINFO_MODE_INFORMATION,
472 RAW_FILEINFO_ALIGNMENT_INFORMATION = SMB_QFILEINFO_ALIGNMENT_INFORMATION,
473 RAW_FILEINFO_ALL_INFORMATION = SMB_QFILEINFO_ALL_INFORMATION,
474 RAW_FILEINFO_ALT_NAME_INFORMATION = SMB_QFILEINFO_ALT_NAME_INFORMATION,
475 RAW_FILEINFO_STREAM_INFORMATION = SMB_QFILEINFO_STREAM_INFORMATION,
476 RAW_FILEINFO_COMPRESSION_INFORMATION = SMB_QFILEINFO_COMPRESSION_INFORMATION,
477 RAW_FILEINFO_NETWORK_OPEN_INFORMATION = SMB_QFILEINFO_NETWORK_OPEN_INFORMATION,
478 RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION = SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION,
479 /* SMB2 specific levels */
480 RAW_FILEINFO_SMB2_ALL_EAS = 0x0f01,
481 RAW_FILEINFO_SMB2_ALL_INFORMATION = 0x1201
484 /* union used in qfileinfo() and qpathinfo() backend calls */
485 union smb_fileinfo {
486 /* generic interface:
487 * matches RAW_FILEINFO_GENERIC */
488 struct {
489 enum smb_fileinfo_level level;
490 struct {
491 union smb_handle_or_path file;
492 } in;
493 struct {
494 uint32_t attrib;
495 uint32_t ea_size;
496 unsigned int num_eas;
497 struct ea_struct {
498 uint8_t flags;
499 struct smb_wire_string name;
500 DATA_BLOB value;
501 } *eas;
502 NTTIME create_time;
503 NTTIME access_time;
504 NTTIME write_time;
505 NTTIME change_time;
506 uint64_t alloc_size;
507 uint64_t size;
508 uint32_t nlink;
509 struct smb_wire_string fname;
510 struct smb_wire_string alt_fname;
511 uint8_t delete_pending;
512 uint8_t directory;
513 uint64_t compressed_size;
514 uint16_t format;
515 uint8_t unit_shift;
516 uint8_t chunk_shift;
517 uint8_t cluster_shift;
518 uint64_t file_id;
519 uint32_t access_flags; /* seen 0x001f01ff from w2k3 */
520 uint64_t position;
521 uint32_t mode;
522 uint32_t alignment_requirement;
523 uint32_t reparse_tag;
524 unsigned int num_streams;
525 struct stream_struct {
526 uint64_t size;
527 uint64_t alloc_size;
528 struct smb_wire_string stream_name;
529 } *streams;
530 } out;
531 } generic;
534 /* SMBgetatr interface:
535 * matches RAW_FILEINFO_GETATTR */
536 struct {
537 enum smb_fileinfo_level level;
538 struct {
539 union smb_handle_or_path file;
540 } in;
541 struct {
542 uint16_t attrib;
543 uint32_t size;
544 time_t write_time;
545 } out;
546 } getattr;
548 /* SMBgetattrE and RAW_FILEINFO_STANDARD interface */
549 struct {
550 enum smb_fileinfo_level level;
551 struct {
552 union smb_handle_or_path file;
553 } in;
554 struct {
555 time_t create_time;
556 time_t access_time;
557 time_t write_time;
558 uint32_t size;
559 uint32_t alloc_size;
560 uint16_t attrib;
561 } out;
562 } getattre, standard;
564 /* trans2 RAW_FILEINFO_EA_SIZE interface */
565 struct {
566 enum smb_fileinfo_level level;
567 struct {
568 union smb_handle_or_path file;
569 } in;
570 struct {
571 time_t create_time;
572 time_t access_time;
573 time_t write_time;
574 uint32_t size;
575 uint32_t alloc_size;
576 uint16_t attrib;
577 uint32_t ea_size;
578 } out;
579 } ea_size;
581 /* trans2 RAW_FILEINFO_EA_LIST interface */
582 struct {
583 enum smb_fileinfo_level level;
584 struct {
585 union smb_handle_or_path file;
586 unsigned int num_names;
587 struct ea_name {
588 struct smb_wire_string name;
589 } *ea_names;
590 } in;
592 struct smb_ea_list {
593 unsigned int num_eas;
594 struct ea_struct *eas;
595 } out;
596 } ea_list;
598 /* trans2 RAW_FILEINFO_ALL_EAS and RAW_FILEINFO_FULL_EA_INFORMATION interfaces */
599 struct {
600 enum smb_fileinfo_level level;
601 struct {
602 union smb_handle_or_path file;
603 /* SMB2 only - SMB2_CONTINUE_FLAG_* */
604 uint8_t continue_flags;
605 } in;
606 struct smb_ea_list out;
607 } all_eas;
609 /* trans2 qpathinfo RAW_FILEINFO_IS_NAME_VALID interface
610 only valid for a QPATHNAME call - no returned data */
611 struct {
612 enum smb_fileinfo_level level;
613 struct {
614 union smb_handle_or_path file;
615 } in;
616 } is_name_valid;
618 /* RAW_FILEINFO_BASIC_INFO and RAW_FILEINFO_BASIC_INFORMATION interfaces */
619 struct {
620 enum smb_fileinfo_level level;
621 struct {
622 union smb_handle_or_path file;
623 } in;
624 struct {
625 NTTIME create_time;
626 NTTIME access_time;
627 NTTIME write_time;
628 NTTIME change_time;
629 uint32_t attrib;
630 } out;
631 } basic_info;
634 /* RAW_FILEINFO_STANDARD_INFO and RAW_FILEINFO_STANDARD_INFORMATION interfaces */
635 struct {
636 enum smb_fileinfo_level level;
637 struct {
638 union smb_handle_or_path file;
639 } in;
640 struct {
641 uint64_t alloc_size;
642 uint64_t size;
643 uint32_t nlink;
644 bool delete_pending;
645 bool directory;
646 } out;
647 } standard_info;
649 /* RAW_FILEINFO_EA_INFO and RAW_FILEINFO_EA_INFORMATION interfaces */
650 struct {
651 enum smb_fileinfo_level level;
652 struct {
653 union smb_handle_or_path file;
654 } in;
655 struct {
656 uint32_t ea_size;
657 } out;
658 } ea_info;
660 /* RAW_FILEINFO_NAME_INFO and RAW_FILEINFO_NAME_INFORMATION interfaces */
661 struct {
662 enum smb_fileinfo_level level;
663 struct {
664 union smb_handle_or_path file;
665 } in;
666 struct {
667 struct smb_wire_string fname;
668 } out;
669 } name_info;
671 /* RAW_FILEINFO_ALL_INFO and RAW_FILEINFO_ALL_INFORMATION interfaces */
672 struct {
673 enum smb_fileinfo_level level;
674 struct {
675 union smb_handle_or_path file;
676 } in;
677 struct {
678 NTTIME create_time;
679 NTTIME access_time;
680 NTTIME write_time;
681 NTTIME change_time;
682 uint32_t attrib;
683 uint64_t alloc_size;
684 uint64_t size;
685 uint32_t nlink;
686 uint8_t delete_pending;
687 uint8_t directory;
688 uint32_t ea_size;
689 struct smb_wire_string fname;
690 } out;
691 } all_info;
693 /* RAW_FILEINFO_SMB2_ALL_INFORMATION interface */
694 struct {
695 enum smb_fileinfo_level level;
696 struct {
697 union smb_handle_or_path file;
698 } in;
699 struct {
700 NTTIME create_time;
701 NTTIME access_time;
702 NTTIME write_time;
703 NTTIME change_time;
704 uint32_t attrib;
705 uint32_t unknown1;
706 uint64_t alloc_size;
707 uint64_t size;
708 uint32_t nlink;
709 uint8_t delete_pending;
710 uint8_t directory;
711 /* uint16_t _pad; */
712 uint64_t file_id;
713 uint32_t ea_size;
714 uint32_t access_mask;
715 uint64_t position;
716 uint32_t mode;
717 uint32_t alignment_requirement;
718 struct smb_wire_string fname;
719 } out;
720 } all_info2;
722 /* RAW_FILEINFO_ALT_NAME_INFO and RAW_FILEINFO_ALT_NAME_INFORMATION interfaces */
723 struct {
724 enum smb_fileinfo_level level;
725 struct {
726 union smb_handle_or_path file;
727 } in;
728 struct {
729 struct smb_wire_string fname;
730 } out;
731 } alt_name_info;
733 /* RAW_FILEINFO_STREAM_INFO and RAW_FILEINFO_STREAM_INFORMATION interfaces */
734 struct {
735 enum smb_fileinfo_level level;
736 struct {
737 union smb_handle_or_path file;
738 } in;
739 struct stream_information {
740 unsigned int num_streams;
741 struct stream_struct *streams;
742 } out;
743 } stream_info;
745 /* RAW_FILEINFO_COMPRESSION_INFO and RAW_FILEINFO_COMPRESSION_INFORMATION interfaces */
746 struct {
747 enum smb_fileinfo_level level;
748 struct {
749 union smb_handle_or_path file;
750 } in;
751 struct {
752 uint64_t compressed_size;
753 uint16_t format;
754 uint8_t unit_shift;
755 uint8_t chunk_shift;
756 uint8_t cluster_shift;
757 } out;
758 } compression_info;
760 /* RAW_FILEINFO_UNIX_BASIC interface */
761 struct {
762 enum smb_fileinfo_level level;
763 struct {
764 union smb_handle_or_path file;
765 } in;
766 struct {
767 uint64_t end_of_file;
768 uint64_t num_bytes;
769 NTTIME status_change_time;
770 NTTIME access_time;
771 NTTIME change_time;
772 uint64_t uid;
773 uint64_t gid;
774 uint32_t file_type;
775 uint64_t dev_major;
776 uint64_t dev_minor;
777 uint64_t unique_id;
778 uint64_t permissions;
779 uint64_t nlink;
780 } out;
781 } unix_basic_info;
783 /* RAW_FILEINFO_UNIX_INFO2 interface */
784 struct {
785 enum smb_fileinfo_level level;
786 struct {
787 union smb_handle_or_path file;
788 } in;
789 struct {
790 uint64_t end_of_file;
791 uint64_t num_bytes;
792 NTTIME status_change_time;
793 NTTIME access_time;
794 NTTIME change_time;
795 uint64_t uid;
796 uint64_t gid;
797 uint32_t file_type;
798 uint64_t dev_major;
799 uint64_t dev_minor;
800 uint64_t unique_id;
801 uint64_t permissions;
802 uint64_t nlink;
803 NTTIME create_time;
804 uint32_t file_flags;
805 uint32_t flags_mask;
806 } out;
807 } unix_info2;
809 /* RAW_FILEINFO_UNIX_LINK interface */
810 struct {
811 enum smb_fileinfo_level level;
812 struct {
813 union smb_handle_or_path file;
814 } in;
815 struct {
816 struct smb_wire_string link_dest;
817 } out;
818 } unix_link_info;
820 /* RAW_FILEINFO_INTERNAL_INFORMATION interface */
821 struct {
822 enum smb_fileinfo_level level;
823 struct {
824 union smb_handle_or_path file;
825 } in;
826 struct {
827 uint64_t file_id;
828 } out;
829 } internal_information;
831 /* RAW_FILEINFO_ACCESS_INFORMATION interface */
832 struct {
833 enum smb_fileinfo_level level;
834 struct {
835 union smb_handle_or_path file;
836 } in;
837 struct {
838 uint32_t access_flags;
839 } out;
840 } access_information;
842 /* RAW_FILEINFO_POSITION_INFORMATION interface */
843 struct {
844 enum smb_fileinfo_level level;
845 struct {
846 union smb_handle_or_path file;
847 } in;
848 struct {
849 uint64_t position;
850 } out;
851 } position_information;
853 /* RAW_FILEINFO_MODE_INFORMATION interface */
854 struct {
855 enum smb_fileinfo_level level;
856 struct {
857 union smb_handle_or_path file;
858 } in;
859 struct {
860 uint32_t mode;
861 } out;
862 } mode_information;
864 /* RAW_FILEINFO_ALIGNMENT_INFORMATION interface */
865 struct {
866 enum smb_fileinfo_level level;
867 struct {
868 union smb_handle_or_path file;
869 } in;
870 struct {
871 uint32_t alignment_requirement;
872 } out;
873 } alignment_information;
875 /* RAW_FILEINFO_NETWORK_OPEN_INFORMATION interface */
876 struct {
877 enum smb_fileinfo_level level;
878 struct {
879 union smb_handle_or_path file;
880 } in;
881 struct {
882 NTTIME create_time;
883 NTTIME access_time;
884 NTTIME write_time;
885 NTTIME change_time;
886 uint64_t alloc_size;
887 uint64_t size;
888 uint32_t attrib;
889 } out;
890 } network_open_information;
893 /* RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION interface */
894 struct {
895 enum smb_fileinfo_level level;
896 struct {
897 union smb_handle_or_path file;
898 } in;
899 struct {
900 uint32_t attrib;
901 uint32_t reparse_tag;
902 } out;
903 } attribute_tag_information;
905 /* RAW_FILEINFO_SEC_DESC */
906 struct {
907 enum smb_fileinfo_level level;
908 struct {
909 union smb_handle_or_path file;
910 uint32_t secinfo_flags;
911 } in;
912 struct {
913 struct security_descriptor *sd;
914 } out;
915 } query_secdesc;
919 enum smb_setfileinfo_level {
920 RAW_SFILEINFO_GENERIC = 0xF000,
921 RAW_SFILEINFO_SETATTR, /* SMBsetatr */
922 RAW_SFILEINFO_SETATTRE, /* SMBsetattrE */
923 RAW_SFILEINFO_SEC_DESC, /* NT_TRANSACT_SET_SECURITY_DESC */
924 RAW_SFILEINFO_STANDARD = SMB_SFILEINFO_STANDARD,
925 RAW_SFILEINFO_EA_SET = SMB_SFILEINFO_EA_SET,
926 RAW_SFILEINFO_BASIC_INFO = SMB_SFILEINFO_BASIC_INFO,
927 RAW_SFILEINFO_DISPOSITION_INFO = SMB_SFILEINFO_DISPOSITION_INFO,
928 RAW_SFILEINFO_ALLOCATION_INFO = SMB_SFILEINFO_ALLOCATION_INFO,
929 RAW_SFILEINFO_END_OF_FILE_INFO = SMB_SFILEINFO_END_OF_FILE_INFO,
930 RAW_SFILEINFO_UNIX_BASIC = SMB_SFILEINFO_UNIX_BASIC,
931 RAW_SFILEINFO_UNIX_INFO2 = SMB_SFILEINFO_UNIX_INFO2,
932 RAW_SFILEINFO_UNIX_LINK = SMB_SET_FILE_UNIX_LINK,
933 RAW_SFILEINFO_UNIX_HLINK = SMB_SET_FILE_UNIX_HLINK,
934 RAW_SFILEINFO_BASIC_INFORMATION = SMB_SFILEINFO_BASIC_INFORMATION,
935 RAW_SFILEINFO_RENAME_INFORMATION = SMB_SFILEINFO_RENAME_INFORMATION,
936 RAW_SFILEINFO_LINK_INFORMATION = SMB_SFILEINFO_LINK_INFORMATION,
937 RAW_SFILEINFO_DISPOSITION_INFORMATION = SMB_SFILEINFO_DISPOSITION_INFORMATION,
938 RAW_SFILEINFO_POSITION_INFORMATION = SMB_SFILEINFO_POSITION_INFORMATION,
939 RAW_SFILEINFO_FULL_EA_INFORMATION = SMB_SFILEINFO_FULL_EA_INFORMATION,
940 RAW_SFILEINFO_MODE_INFORMATION = SMB_SFILEINFO_MODE_INFORMATION,
941 RAW_SFILEINFO_ALLOCATION_INFORMATION = SMB_SFILEINFO_ALLOCATION_INFORMATION,
942 RAW_SFILEINFO_END_OF_FILE_INFORMATION = SMB_SFILEINFO_END_OF_FILE_INFORMATION,
943 RAW_SFILEINFO_PIPE_INFORMATION = SMB_SFILEINFO_PIPE_INFORMATION,
944 RAW_SFILEINFO_VALID_DATA_INFORMATION = SMB_SFILEINFO_VALID_DATA_INFORMATION,
945 RAW_SFILEINFO_SHORT_NAME_INFORMATION = SMB_SFILEINFO_SHORT_NAME_INFORMATION,
946 RAW_SFILEINFO_1025 = SMB_SFILEINFO_1025,
947 RAW_SFILEINFO_1027 = SMB_SFILEINFO_1027,
948 RAW_SFILEINFO_1029 = SMB_SFILEINFO_1029,
949 RAW_SFILEINFO_1030 = SMB_SFILEINFO_1030,
950 RAW_SFILEINFO_1031 = SMB_SFILEINFO_1031,
951 RAW_SFILEINFO_1032 = SMB_SFILEINFO_1032,
952 RAW_SFILEINFO_1036 = SMB_SFILEINFO_1036,
953 RAW_SFILEINFO_1041 = SMB_SFILEINFO_1041,
954 RAW_SFILEINFO_1042 = SMB_SFILEINFO_1042,
955 RAW_SFILEINFO_1043 = SMB_SFILEINFO_1043,
956 RAW_SFILEINFO_1044 = SMB_SFILEINFO_1044,
958 /* cope with breakage in SMB2 */
959 RAW_SFILEINFO_RENAME_INFORMATION_SMB2 = SMB_SFILEINFO_RENAME_INFORMATION|0x80000000,
962 /* union used in setfileinfo() and setpathinfo() calls */
963 union smb_setfileinfo {
964 /* generic interface */
965 struct {
966 enum smb_setfileinfo_level level;
967 struct {
968 union smb_handle_or_path file;
969 } in;
970 } generic;
972 /* RAW_SFILEINFO_SETATTR (SMBsetatr) interface - only via setpathinfo() */
973 struct {
974 enum smb_setfileinfo_level level;
975 struct {
976 union smb_handle_or_path file;
977 uint16_t attrib;
978 time_t write_time;
979 } in;
980 } setattr;
982 /* RAW_SFILEINFO_SETATTRE (SMBsetattrE) interface - only via setfileinfo()
983 also RAW_SFILEINFO_STANDARD */
984 struct {
985 enum smb_setfileinfo_level level;
986 struct {
987 union smb_handle_or_path file;
988 time_t create_time;
989 time_t access_time;
990 time_t write_time;
991 /* notice that size, alloc_size and attrib are not settable,
992 unlike the corresponding qfileinfo level */
993 } in;
994 } setattre, standard;
996 /* RAW_SFILEINFO_EA_SET interface */
997 struct {
998 enum smb_setfileinfo_level level;
999 struct {
1000 union smb_handle_or_path file;
1001 unsigned int num_eas;
1002 struct ea_struct *eas;
1003 } in;
1004 } ea_set;
1006 /* RAW_SFILEINFO_BASIC_INFO and
1007 RAW_SFILEINFO_BASIC_INFORMATION interfaces */
1008 struct {
1009 enum smb_setfileinfo_level level;
1010 struct {
1011 union smb_handle_or_path file;
1012 NTTIME create_time;
1013 NTTIME access_time;
1014 NTTIME write_time;
1015 NTTIME change_time;
1016 uint32_t attrib;
1017 uint32_t reserved;
1018 } in;
1019 } basic_info;
1021 /* RAW_SFILEINFO_DISPOSITION_INFO and
1022 RAW_SFILEINFO_DISPOSITION_INFORMATION interfaces */
1023 struct {
1024 enum smb_setfileinfo_level level;
1025 struct {
1026 union smb_handle_or_path file;
1027 bool delete_on_close;
1028 } in;
1029 } disposition_info;
1031 /* RAW_SFILEINFO_ALLOCATION_INFO and
1032 RAW_SFILEINFO_ALLOCATION_INFORMATION interfaces */
1033 struct {
1034 enum smb_setfileinfo_level level;
1035 struct {
1036 union smb_handle_or_path file;
1037 /* w2k3 rounds this up to nearest 4096 */
1038 uint64_t alloc_size;
1039 } in;
1040 } allocation_info;
1042 /* RAW_SFILEINFO_END_OF_FILE_INFO and
1043 RAW_SFILEINFO_END_OF_FILE_INFORMATION interfaces */
1044 struct {
1045 enum smb_setfileinfo_level level;
1046 struct {
1047 union smb_handle_or_path file;
1048 uint64_t size;
1049 } in;
1050 } end_of_file_info;
1052 /* RAW_SFILEINFO_RENAME_INFORMATION interface */
1053 struct {
1054 enum smb_setfileinfo_level level;
1055 struct {
1056 union smb_handle_or_path file;
1057 uint8_t overwrite;
1058 uint64_t root_fid;
1059 const char *new_name;
1060 } in;
1061 } rename_information;
1063 /* RAW_SFILEINFO_LINK_INFORMATION interface */
1064 struct {
1065 enum smb_setfileinfo_level level;
1066 struct {
1067 union smb_handle_or_path file;
1068 uint8_t overwrite;
1069 uint64_t root_fid;
1070 const char *new_name;
1071 } in;
1072 } link_information;
1074 /* RAW_SFILEINFO_POSITION_INFORMATION interface */
1075 struct {
1076 enum smb_setfileinfo_level level;
1077 struct {
1078 union smb_handle_or_path file;
1079 uint64_t position;
1080 } in;
1081 } position_information;
1083 /* RAW_SFILEINFO_MODE_INFORMATION interface */
1084 struct {
1085 enum smb_setfileinfo_level level;
1086 struct {
1087 union smb_handle_or_path file;
1088 /* valid values seem to be 0, 2, 4 and 6 */
1089 uint32_t mode;
1090 } in;
1091 } mode_information;
1093 /* RAW_SFILEINFO_UNIX_BASIC interface */
1094 struct {
1095 enum smb_setfileinfo_level level;
1096 struct {
1097 union smb_handle_or_path file;
1098 uint32_t mode; /* yuck - this field remains to fix compile of libcli/clifile.c */
1099 uint64_t end_of_file;
1100 uint64_t num_bytes;
1101 NTTIME status_change_time;
1102 NTTIME access_time;
1103 NTTIME change_time;
1104 uint64_t uid;
1105 uint64_t gid;
1106 uint32_t file_type;
1107 uint64_t dev_major;
1108 uint64_t dev_minor;
1109 uint64_t unique_id;
1110 uint64_t permissions;
1111 uint64_t nlink;
1112 } in;
1113 } unix_basic;
1115 /* RAW_SFILEINFO_UNIX_INFO2 interface */
1116 struct {
1117 enum smb_setfileinfo_level level;
1118 struct {
1119 union smb_handle_or_path file;
1120 uint64_t end_of_file;
1121 uint64_t num_bytes;
1122 NTTIME status_change_time;
1123 NTTIME access_time;
1124 NTTIME change_time;
1125 uint64_t uid;
1126 uint64_t gid;
1127 uint32_t file_type;
1128 uint64_t dev_major;
1129 uint64_t dev_minor;
1130 uint64_t unique_id;
1131 uint64_t permissions;
1132 uint64_t nlink;
1133 NTTIME create_time;
1134 uint32_t file_flags;
1135 uint32_t flags_mask;
1136 } in;
1137 } unix_info2;
1139 /* RAW_SFILEINFO_UNIX_LINK, RAW_SFILEINFO_UNIX_HLINK interface */
1140 struct {
1141 enum smb_setfileinfo_level level;
1142 struct {
1143 union smb_handle_or_path file;
1144 const char *link_dest;
1145 } in;
1146 } unix_link, unix_hlink;
1148 /* RAW_SFILEINFO_SEC_DESC */
1149 struct {
1150 enum smb_setfileinfo_level level;
1151 struct {
1152 union smb_handle_or_path file;
1153 uint32_t secinfo_flags;
1154 struct security_descriptor *sd;
1155 } in;
1156 } set_secdesc;
1158 /* RAW_SFILEINFO_FULL_EA_INFORMATION */
1159 struct {
1160 enum smb_setfileinfo_level level;
1161 struct {
1162 union smb_handle_or_path file;
1163 struct smb_ea_list eas;
1164 } in;
1165 } full_ea_information;
1169 enum smb_fsinfo_level {
1170 RAW_QFS_GENERIC = 0xF000,
1171 RAW_QFS_DSKATTR, /* SMBdskattr */
1172 RAW_QFS_ALLOCATION = SMB_QFS_ALLOCATION,
1173 RAW_QFS_VOLUME = SMB_QFS_VOLUME,
1174 RAW_QFS_VOLUME_INFO = SMB_QFS_VOLUME_INFO,
1175 RAW_QFS_SIZE_INFO = SMB_QFS_SIZE_INFO,
1176 RAW_QFS_DEVICE_INFO = SMB_QFS_DEVICE_INFO,
1177 RAW_QFS_ATTRIBUTE_INFO = SMB_QFS_ATTRIBUTE_INFO,
1178 RAW_QFS_UNIX_INFO = SMB_QFS_UNIX_INFO,
1179 RAW_QFS_VOLUME_INFORMATION = SMB_QFS_VOLUME_INFORMATION,
1180 RAW_QFS_SIZE_INFORMATION = SMB_QFS_SIZE_INFORMATION,
1181 RAW_QFS_DEVICE_INFORMATION = SMB_QFS_DEVICE_INFORMATION,
1182 RAW_QFS_ATTRIBUTE_INFORMATION = SMB_QFS_ATTRIBUTE_INFORMATION,
1183 RAW_QFS_QUOTA_INFORMATION = SMB_QFS_QUOTA_INFORMATION,
1184 RAW_QFS_FULL_SIZE_INFORMATION = SMB_QFS_FULL_SIZE_INFORMATION,
1185 RAW_QFS_OBJECTID_INFORMATION = SMB_QFS_OBJECTID_INFORMATION};
1188 /* union for fsinfo() backend call. Note that there are no in
1189 structures, as this call only contains out parameters */
1190 union smb_fsinfo {
1191 /* generic interface */
1192 struct {
1193 enum smb_fsinfo_level level;
1194 struct smb2_handle handle; /* only for smb2 */
1196 struct {
1197 uint32_t block_size;
1198 uint64_t blocks_total;
1199 uint64_t blocks_free;
1200 uint32_t fs_id;
1201 NTTIME create_time;
1202 uint32_t serial_number;
1203 uint32_t fs_attr;
1204 uint32_t max_file_component_length;
1205 uint32_t device_type;
1206 uint32_t device_characteristics;
1207 uint64_t quota_soft;
1208 uint64_t quota_hard;
1209 uint64_t quota_flags;
1210 struct GUID guid;
1211 char *volume_name;
1212 char *fs_type;
1213 } out;
1214 } generic;
1216 /* SMBdskattr interface */
1217 struct {
1218 enum smb_fsinfo_level level;
1220 struct {
1221 uint16_t units_total;
1222 uint16_t blocks_per_unit;
1223 uint16_t block_size;
1224 uint16_t units_free;
1225 } out;
1226 } dskattr;
1228 /* trans2 RAW_QFS_ALLOCATION interface */
1229 struct {
1230 enum smb_fsinfo_level level;
1232 struct {
1233 uint32_t fs_id;
1234 uint32_t sectors_per_unit;
1235 uint32_t total_alloc_units;
1236 uint32_t avail_alloc_units;
1237 uint16_t bytes_per_sector;
1238 } out;
1239 } allocation;
1241 /* TRANS2 RAW_QFS_VOLUME interface */
1242 struct {
1243 enum smb_fsinfo_level level;
1245 struct {
1246 uint32_t serial_number;
1247 struct smb_wire_string volume_name;
1248 } out;
1249 } volume;
1251 /* TRANS2 RAW_QFS_VOLUME_INFO and RAW_QFS_VOLUME_INFORMATION interfaces */
1252 struct {
1253 enum smb_fsinfo_level level;
1254 struct smb2_handle handle; /* only for smb2 */
1256 struct {
1257 NTTIME create_time;
1258 uint32_t serial_number;
1259 struct smb_wire_string volume_name;
1260 } out;
1261 } volume_info;
1263 /* trans2 RAW_QFS_SIZE_INFO and RAW_QFS_SIZE_INFORMATION interfaces */
1264 struct {
1265 enum smb_fsinfo_level level;
1266 struct smb2_handle handle; /* only for smb2 */
1268 struct {
1269 uint64_t total_alloc_units;
1270 uint64_t avail_alloc_units; /* maps to call_avail_alloc_units */
1271 uint32_t sectors_per_unit;
1272 uint32_t bytes_per_sector;
1273 } out;
1274 } size_info;
1276 /* TRANS2 RAW_QFS_DEVICE_INFO and RAW_QFS_DEVICE_INFORMATION interfaces */
1277 struct {
1278 enum smb_fsinfo_level level;
1279 struct smb2_handle handle; /* only for smb2 */
1281 struct {
1282 uint32_t device_type;
1283 uint32_t characteristics;
1284 } out;
1285 } device_info;
1288 /* TRANS2 RAW_QFS_ATTRIBUTE_INFO and RAW_QFS_ATTRIBUTE_INFORMATION interfaces */
1289 struct {
1290 enum smb_fsinfo_level level;
1291 struct smb2_handle handle; /* only for smb2 */
1293 struct {
1294 uint32_t fs_attr;
1295 uint32_t max_file_component_length;
1296 struct smb_wire_string fs_type;
1297 } out;
1298 } attribute_info;
1301 /* TRANS2 RAW_QFS_UNIX_INFO interface */
1302 struct {
1303 enum smb_fsinfo_level level;
1305 struct {
1306 uint16_t major_version;
1307 uint16_t minor_version;
1308 uint64_t capability;
1309 } out;
1310 } unix_info;
1312 /* trans2 RAW_QFS_QUOTA_INFORMATION interface */
1313 struct {
1314 enum smb_fsinfo_level level;
1315 struct smb2_handle handle; /* only for smb2 */
1317 struct {
1318 uint64_t unknown[3];
1319 uint64_t quota_soft;
1320 uint64_t quota_hard;
1321 uint64_t quota_flags;
1322 } out;
1323 } quota_information;
1325 /* trans2 RAW_QFS_FULL_SIZE_INFORMATION interface */
1326 struct {
1327 enum smb_fsinfo_level level;
1328 struct smb2_handle handle; /* only for smb2 */
1330 struct {
1331 uint64_t total_alloc_units;
1332 uint64_t call_avail_alloc_units;
1333 uint64_t actual_avail_alloc_units;
1334 uint32_t sectors_per_unit;
1335 uint32_t bytes_per_sector;
1336 } out;
1337 } full_size_information;
1339 /* trans2 RAW_QFS_OBJECTID_INFORMATION interface */
1340 struct {
1341 enum smb_fsinfo_level level;
1342 struct smb2_handle handle; /* only for smb2 */
1344 struct {
1345 struct GUID guid;
1346 uint64_t unknown[6];
1347 } out;
1348 } objectid_information;
1352 enum smb_setfsinfo_level {
1353 RAW_SETFS_UNIX_INFO = SMB_SET_CIFS_UNIX_INFO};
1355 union smb_setfsinfo {
1356 /* generic interface */
1357 struct {
1358 enum smb_fsinfo_level level;
1359 } generic;
1361 /* TRANS2 RAW_QFS_UNIX_INFO interface */
1362 struct {
1363 enum smb_fsinfo_level level;
1365 struct {
1366 uint16_t major_version;
1367 uint16_t minor_version;
1368 uint64_t capability;
1369 } in;
1370 } unix_info;
1373 enum smb_open_level {
1374 RAW_OPEN_OPEN,
1375 RAW_OPEN_OPENX,
1376 RAW_OPEN_MKNEW,
1377 RAW_OPEN_CREATE,
1378 RAW_OPEN_CTEMP,
1379 RAW_OPEN_SPLOPEN,
1380 RAW_OPEN_NTCREATEX,
1381 RAW_OPEN_T2OPEN,
1382 RAW_OPEN_NTTRANS_CREATE,
1383 RAW_OPEN_OPENX_READX,
1384 RAW_OPEN_NTCREATEX_READX,
1385 RAW_OPEN_SMB2
1388 /* the generic interface is defined to be equal to the NTCREATEX interface */
1389 #define RAW_OPEN_GENERIC RAW_OPEN_NTCREATEX
1391 /* union for open() backend call */
1392 union smb_open {
1394 * because the *.out.file structs are not aligned to the same offset for each level
1395 * we provide a hepler macro that should be used to find the current smb_handle structure
1397 #define SMB_OPEN_OUT_FILE(op, file) do { \
1398 switch (op->generic.level) { \
1399 case RAW_OPEN_OPEN: \
1400 file = &op->openold.out.file; \
1401 break; \
1402 case RAW_OPEN_OPENX: \
1403 file = &op->openx.out.file; \
1404 break; \
1405 case RAW_OPEN_MKNEW: \
1406 file = &op->mknew.out.file; \
1407 break; \
1408 case RAW_OPEN_CREATE: \
1409 file = &op->create.out.file; \
1410 break; \
1411 case RAW_OPEN_CTEMP: \
1412 file = &op->ctemp.out.file; \
1413 break; \
1414 case RAW_OPEN_SPLOPEN: \
1415 file = &op->splopen.out.file; \
1416 break; \
1417 case RAW_OPEN_NTCREATEX: \
1418 file = &op->ntcreatex.out.file; \
1419 break; \
1420 case RAW_OPEN_T2OPEN: \
1421 file = &op->t2open.out.file; \
1422 break; \
1423 case RAW_OPEN_NTTRANS_CREATE: \
1424 file = &op->nttrans.out.file; \
1425 break; \
1426 case RAW_OPEN_OPENX_READX: \
1427 file = &op->openxreadx.out.file; \
1428 break; \
1429 case RAW_OPEN_NTCREATEX_READX: \
1430 file = &op->ntcreatexreadx.out.file; \
1431 break; \
1432 case RAW_OPEN_SMB2: \
1433 file = &op->smb2.out.file; \
1434 break; \
1435 default: \
1436 /* this must be a programmer error */ \
1437 file = NULL; \
1438 break; \
1440 } while (0)
1441 /* SMBNTCreateX, nttrans and generic interface */
1442 struct {
1443 enum smb_open_level level;
1444 struct {
1445 uint32_t flags;
1446 union smb_handle root_fid;
1447 uint32_t access_mask;
1448 uint64_t alloc_size;
1449 uint32_t file_attr;
1450 uint32_t share_access;
1451 uint32_t open_disposition;
1452 uint32_t create_options;
1453 uint32_t impersonation;
1454 uint8_t security_flags;
1455 /* NOTE: fname can also be a pointer to a
1456 uint64_t file_id if create_options has the
1457 NTCREATEX_OPTIONS_OPEN_BY_FILE_ID flag set */
1458 const char *fname;
1460 /* these last 2 elements are only used in the
1461 NTTRANS varient of the call */
1462 struct security_descriptor *sec_desc;
1463 struct smb_ea_list *ea_list;
1465 /* some optional parameters from the SMB2 varient */
1466 bool query_maximal_access;
1468 /* private flags for internal use only */
1469 uint8_t private_flags;
1470 } in;
1471 struct {
1472 union smb_handle file;
1473 uint8_t oplock_level;
1474 uint32_t create_action;
1475 NTTIME create_time;
1476 NTTIME access_time;
1477 NTTIME write_time;
1478 NTTIME change_time;
1479 uint32_t attrib;
1480 uint64_t alloc_size;
1481 uint64_t size;
1482 uint16_t file_type;
1483 uint16_t ipc_state;
1484 uint8_t is_directory;
1486 /* optional return values matching SMB2 tagged
1487 values in the call */
1488 uint32_t maximal_access;
1489 } out;
1490 } ntcreatex, nttrans, generic;
1492 /* TRANS2_OPEN interface */
1493 struct {
1494 enum smb_open_level level;
1495 struct {
1496 uint16_t flags;
1497 uint16_t open_mode;
1498 uint16_t search_attrs;
1499 uint16_t file_attrs;
1500 time_t write_time;
1501 uint16_t open_func;
1502 uint32_t size;
1503 uint32_t timeout;
1504 const char *fname;
1505 unsigned int num_eas;
1506 struct ea_struct *eas;
1507 } in;
1508 struct {
1509 union smb_handle file;
1510 uint16_t attrib;
1511 time_t write_time;
1512 uint32_t size;
1513 uint16_t access;
1514 uint16_t ftype;
1515 uint16_t devstate;
1516 uint16_t action;
1517 uint32_t file_id;
1518 } out;
1519 } t2open;
1521 /* SMBopen interface */
1522 struct {
1523 enum smb_open_level level;
1524 struct {
1525 uint16_t open_mode;
1526 uint16_t search_attrs;
1527 const char *fname;
1528 } in;
1529 struct {
1530 union smb_handle file;
1531 uint16_t attrib;
1532 time_t write_time;
1533 uint32_t size;
1534 uint16_t rmode;
1535 } out;
1536 } openold;
1538 /* SMBopenX interface */
1539 struct {
1540 enum smb_open_level level;
1541 struct {
1542 uint16_t flags;
1543 uint16_t open_mode;
1544 uint16_t search_attrs; /* not honoured by win2003 */
1545 uint16_t file_attrs;
1546 time_t write_time; /* not honoured by win2003 */
1547 uint16_t open_func;
1548 uint32_t size; /* note that this sets the
1549 initial file size, not
1550 just allocation size */
1551 uint32_t timeout; /* not honoured by win2003 */
1552 const char *fname;
1553 } in;
1554 struct {
1555 union smb_handle file;
1556 uint16_t attrib;
1557 time_t write_time;
1558 uint32_t size;
1559 uint16_t access;
1560 uint16_t ftype;
1561 uint16_t devstate;
1562 uint16_t action;
1563 uint32_t unique_fid;
1564 uint32_t access_mask;
1565 uint32_t unknown;
1566 } out;
1567 } openx;
1569 /* SMBmknew interface */
1570 struct {
1571 enum smb_open_level level;
1572 struct {
1573 uint16_t attrib;
1574 time_t write_time;
1575 const char *fname;
1576 } in;
1577 struct {
1578 union smb_handle file;
1579 } out;
1580 } mknew, create;
1582 /* SMBctemp interface */
1583 struct {
1584 enum smb_open_level level;
1585 struct {
1586 uint16_t attrib;
1587 time_t write_time;
1588 const char *directory;
1589 } in;
1590 struct {
1591 union smb_handle file;
1592 /* temp name, relative to directory */
1593 char *name;
1594 } out;
1595 } ctemp;
1597 /* SMBsplopen interface */
1598 struct {
1599 enum smb_open_level level;
1600 struct {
1601 uint16_t setup_length;
1602 uint16_t mode;
1603 const char *ident;
1604 } in;
1605 struct {
1606 union smb_handle file;
1607 } out;
1608 } splopen;
1611 /* chained OpenX/ReadX interface */
1612 struct {
1613 enum smb_open_level level;
1614 struct {
1615 uint16_t flags;
1616 uint16_t open_mode;
1617 uint16_t search_attrs; /* not honoured by win2003 */
1618 uint16_t file_attrs;
1619 time_t write_time; /* not honoured by win2003 */
1620 uint16_t open_func;
1621 uint32_t size; /* note that this sets the
1622 initial file size, not
1623 just allocation size */
1624 uint32_t timeout; /* not honoured by win2003 */
1625 const char *fname;
1627 /* readx part */
1628 uint64_t offset;
1629 uint16_t mincnt;
1630 uint32_t maxcnt;
1631 uint16_t remaining;
1632 } in;
1633 struct {
1634 union smb_handle file;
1635 uint16_t attrib;
1636 time_t write_time;
1637 uint32_t size;
1638 uint16_t access;
1639 uint16_t ftype;
1640 uint16_t devstate;
1641 uint16_t action;
1642 uint32_t unique_fid;
1643 uint32_t access_mask;
1644 uint32_t unknown;
1646 /* readx part */
1647 uint8_t *data;
1648 uint16_t remaining;
1649 uint16_t compaction_mode;
1650 uint16_t nread;
1651 } out;
1652 } openxreadx;
1654 /* chained NTCreateX/ReadX interface */
1655 struct {
1656 enum smb_open_level level;
1657 struct {
1658 uint32_t flags;
1659 union smb_handle root_fid;
1660 uint32_t access_mask;
1661 uint64_t alloc_size;
1662 uint32_t file_attr;
1663 uint32_t share_access;
1664 uint32_t open_disposition;
1665 uint32_t create_options;
1666 uint32_t impersonation;
1667 uint8_t security_flags;
1668 /* NOTE: fname can also be a pointer to a
1669 uint64_t file_id if create_options has the
1670 NTCREATEX_OPTIONS_OPEN_BY_FILE_ID flag set */
1671 const char *fname;
1673 /* readx part */
1674 uint64_t offset;
1675 uint16_t mincnt;
1676 uint32_t maxcnt;
1677 uint16_t remaining;
1678 } in;
1679 struct {
1680 union smb_handle file;
1681 uint8_t oplock_level;
1682 uint32_t create_action;
1683 NTTIME create_time;
1684 NTTIME access_time;
1685 NTTIME write_time;
1686 NTTIME change_time;
1687 uint32_t attrib;
1688 uint64_t alloc_size;
1689 uint64_t size;
1690 uint16_t file_type;
1691 uint16_t ipc_state;
1692 uint8_t is_directory;
1694 /* readx part */
1695 uint8_t *data;
1696 uint16_t remaining;
1697 uint16_t compaction_mode;
1698 uint16_t nread;
1699 } out;
1700 } ntcreatexreadx;
1702 #define SMB2_CREATE_FLAG_REQUEST_OPLOCK 0x0100
1703 #define SMB2_CREATE_FLAG_REQUEST_EXCLUSIVE_OPLOCK 0x0800
1704 #define SMB2_CREATE_FLAG_GRANT_OPLOCK 0x0001
1705 #define SMB2_CREATE_FLAG_GRANT_EXCLUSIVE_OPLOCK 0x0080
1707 /* SMB2 Create */
1708 struct smb2_create {
1709 enum smb_open_level level;
1710 struct {
1711 /* static body buffer 56 (0x38) bytes */
1712 uint8_t security_flags; /* SMB2_SECURITY_* */
1713 uint8_t oplock_level; /* SMB2_OPLOCK_LEVEL_* */
1714 uint32_t impersonation_level; /* SMB2_IMPERSONATION_* */
1715 uint64_t create_flags;
1716 uint64_t reserved;
1717 uint32_t desired_access;
1718 uint32_t file_attributes;
1719 uint32_t share_access; /* NTCREATEX_SHARE_ACCESS_* */
1720 uint32_t create_disposition; /* NTCREATEX_DISP_* */
1721 uint32_t create_options; /* NTCREATEX_OPTIONS_* */
1723 /* uint16_t fname_ofs */
1724 /* uint16_t fname_size */
1725 /* uint32_t blob_ofs; */
1726 /* uint32_t blob_size; */
1728 /* dynamic body */
1729 const char *fname;
1731 /* now some optional parameters - encoded as tagged blobs */
1732 struct smb_ea_list eas;
1733 uint64_t alloc_size;
1734 struct security_descriptor *sec_desc;
1735 bool durable_open;
1736 struct smb2_handle *durable_handle;
1738 /* data for durable handle v2 */
1739 bool durable_open_v2;
1740 struct GUID create_guid;
1741 bool persistent_open;
1742 uint32_t timeout;
1743 struct smb2_handle *durable_handle_v2;
1745 bool query_maximal_access;
1746 NTTIME timewarp;
1747 bool query_on_disk_id;
1748 struct smb2_lease *lease_request;
1749 struct smb2_lease *lease_request_v2;
1751 struct GUID *app_instance_id;
1753 /* and any additional blobs the caller wants */
1754 struct smb2_create_blobs blobs;
1755 } in;
1756 struct {
1757 union smb_handle file;
1759 /* static body buffer 88 (0x58) bytes */
1760 /* uint16_t buffer_code; 0x59 = 0x58 + 1 */
1761 uint8_t oplock_level;
1762 uint8_t reserved;
1763 uint32_t create_action;
1764 NTTIME create_time;
1765 NTTIME access_time;
1766 NTTIME write_time;
1767 NTTIME change_time;
1768 uint64_t alloc_size;
1769 uint64_t size;
1770 uint32_t file_attr;
1771 uint32_t reserved2;
1772 /* struct smb2_handle handle;*/
1773 /* uint32_t blob_ofs; */
1774 /* uint32_t blob_size; */
1776 /* optional return values matching tagged values in the call */
1777 uint32_t maximal_access;
1778 uint8_t on_disk_id[32];
1779 struct smb2_lease lease_response;
1780 struct smb2_lease lease_response_v2;
1781 bool durable_open;
1783 /* durable handle v2 */
1784 bool durable_open_v2;
1785 bool persistent_open;
1786 uint32_t timeout;
1788 /* tagged blobs in the reply */
1789 struct smb2_create_blobs blobs;
1790 } out;
1791 } smb2;
1796 enum smb_read_level {
1797 RAW_READ_READBRAW,
1798 RAW_READ_LOCKREAD,
1799 RAW_READ_READ,
1800 RAW_READ_READX,
1801 RAW_READ_SMB2
1804 #define RAW_READ_GENERIC RAW_READ_READX
1806 /* union for read() backend call
1808 note that .infoX.out.data will be allocated before the backend is
1809 called. It will be big enough to hold the maximum size asked for
1811 union smb_read {
1812 /* SMBreadX (and generic) interface */
1813 struct {
1814 enum smb_read_level level;
1815 struct {
1816 union smb_handle file;
1817 uint64_t offset;
1818 uint32_t mincnt; /* enforced on SMB2, 16 bit on SMB */
1819 uint32_t maxcnt;
1820 uint16_t remaining;
1821 bool read_for_execute;
1822 } in;
1823 struct {
1824 uint8_t *data;
1825 uint16_t remaining;
1826 uint16_t compaction_mode;
1827 uint32_t nread;
1828 } out;
1829 } readx, generic;
1831 /* SMBreadbraw interface */
1832 struct {
1833 enum smb_read_level level;
1834 struct {
1835 union smb_handle file;
1836 uint64_t offset;
1837 uint16_t maxcnt;
1838 uint16_t mincnt;
1839 uint32_t timeout;
1840 } in;
1841 struct {
1842 uint8_t *data;
1843 uint32_t nread;
1844 } out;
1845 } readbraw;
1848 /* SMBlockandread interface */
1849 struct {
1850 enum smb_read_level level;
1851 struct {
1852 union smb_handle file;
1853 uint16_t count;
1854 uint32_t offset;
1855 uint16_t remaining;
1856 } in;
1857 struct {
1858 uint8_t *data;
1859 uint16_t nread;
1860 } out;
1861 } lockread;
1863 /* SMBread interface */
1864 struct {
1865 enum smb_read_level level;
1866 struct {
1867 union smb_handle file;
1868 uint16_t count;
1869 uint32_t offset;
1870 uint16_t remaining;
1871 } in;
1872 struct {
1873 uint8_t *data;
1874 uint16_t nread;
1875 } out;
1876 } read;
1878 /* SMB2 Read */
1879 struct smb2_read {
1880 enum smb_read_level level;
1881 struct {
1882 union smb_handle file;
1884 /* static body buffer 48 (0x30) bytes */
1885 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
1886 uint8_t _pad;
1887 uint8_t reserved;
1888 uint32_t length;
1889 uint64_t offset;
1890 /* struct smb2_handle handle; */
1891 uint32_t min_count;
1892 uint32_t channel;
1893 uint32_t remaining;
1894 /* the docs give no indication of what
1895 these channel variables are for */
1896 uint16_t channel_offset;
1897 uint16_t channel_length;
1898 } in;
1899 struct {
1900 /* static body buffer 16 (0x10) bytes */
1901 /* uint16_t buffer_code; 0x11 = 0x10 + 1 */
1902 /* uint8_t data_ofs; */
1903 /* uint8_t reserved; */
1904 /* uint32_t data_size; */
1905 uint32_t remaining;
1906 uint32_t reserved;
1908 /* dynamic body */
1909 DATA_BLOB data;
1910 } out;
1911 } smb2;
1915 enum smb_write_level {
1916 RAW_WRITE_WRITEUNLOCK,
1917 RAW_WRITE_WRITE,
1918 RAW_WRITE_WRITEX,
1919 RAW_WRITE_WRITECLOSE,
1920 RAW_WRITE_SPLWRITE,
1921 RAW_WRITE_SMB2
1924 #define RAW_WRITE_GENERIC RAW_WRITE_WRITEX
1926 /* union for write() backend call
1928 union smb_write {
1929 /* SMBwriteX interface */
1930 struct {
1931 enum smb_write_level level;
1932 struct {
1933 union smb_handle file;
1934 uint64_t offset;
1935 uint16_t wmode;
1936 uint16_t remaining;
1937 uint32_t count;
1938 const uint8_t *data;
1939 } in;
1940 struct {
1941 uint32_t nwritten;
1942 uint16_t remaining;
1943 } out;
1944 } writex, generic;
1946 /* SMBwriteunlock interface */
1947 struct {
1948 enum smb_write_level level;
1949 struct {
1950 union smb_handle file;
1951 uint16_t count;
1952 uint32_t offset;
1953 uint16_t remaining;
1954 const uint8_t *data;
1955 } in;
1956 struct {
1957 uint32_t nwritten;
1958 } out;
1959 } writeunlock;
1961 /* SMBwrite interface */
1962 struct {
1963 enum smb_write_level level;
1964 struct {
1965 union smb_handle file;
1966 uint16_t count;
1967 uint32_t offset;
1968 uint16_t remaining;
1969 const uint8_t *data;
1970 } in;
1971 struct {
1972 uint16_t nwritten;
1973 } out;
1974 } write;
1976 /* SMBwriteclose interface */
1977 struct {
1978 enum smb_write_level level;
1979 struct {
1980 union smb_handle file;
1981 uint16_t count;
1982 uint32_t offset;
1983 time_t mtime;
1984 const uint8_t *data;
1985 } in;
1986 struct {
1987 uint16_t nwritten;
1988 } out;
1989 } writeclose;
1991 /* SMBsplwrite interface */
1992 struct {
1993 enum smb_write_level level;
1994 struct {
1995 union smb_handle file;
1996 uint16_t count;
1997 const uint8_t *data;
1998 } in;
1999 } splwrite;
2001 /* SMB2 Write */
2002 struct smb2_write {
2003 enum smb_write_level level;
2004 struct {
2005 union smb_handle file;
2007 /* static body buffer 48 (0x30) bytes */
2008 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
2009 /* uint16_t data_ofs; */
2010 /* uint32_t data_size; */
2011 uint64_t offset;
2012 /* struct smb2_handle handle; */
2013 uint64_t unknown1; /* 0xFFFFFFFFFFFFFFFF */
2014 uint64_t unknown2; /* 0xFFFFFFFFFFFFFFFF */
2016 /* dynamic body */
2017 DATA_BLOB data;
2018 } in;
2019 struct {
2020 /* static body buffer 17 (0x11) bytes */
2021 /* uint16_t buffer_code; 0x11 = 0x10 + 1*/
2022 uint16_t _pad;
2023 uint32_t nwritten;
2024 uint64_t unknown1; /* 0x0000000000000000 */
2025 } out;
2026 } smb2;
2030 enum smb_lock_level {
2031 RAW_LOCK_LOCK,
2032 RAW_LOCK_UNLOCK,
2033 RAW_LOCK_LOCKX,
2034 RAW_LOCK_SMB2,
2035 RAW_LOCK_SMB2_BREAK
2038 #define RAW_LOCK_GENERIC RAW_LOCK_LOCKX
2040 /* union for lock() backend call
2042 union smb_lock {
2043 /* SMBlockingX and generic interface */
2044 struct {
2045 enum smb_lock_level level;
2046 struct {
2047 union smb_handle file;
2048 uint16_t mode;
2049 uint32_t timeout;
2050 uint16_t ulock_cnt;
2051 uint16_t lock_cnt;
2052 struct smb_lock_entry {
2053 uint32_t pid; /* 16 bits in SMB1 */
2054 uint64_t offset;
2055 uint64_t count;
2056 } *locks; /* unlocks are first in the arrray */
2057 } in;
2058 } generic, lockx;
2060 /* SMBlock and SMBunlock interface */
2061 struct {
2062 enum smb_lock_level level;
2063 struct {
2064 union smb_handle file;
2065 uint32_t count;
2066 uint32_t offset;
2067 } in;
2068 } lock, unlock;
2070 /* SMB2 Lock */
2071 struct smb2_lock {
2072 enum smb_lock_level level;
2073 struct {
2074 union smb_handle file;
2076 /* static body buffer 48 (0x30) bytes */
2077 /* uint16_t buffer_code; 0x30 */
2078 uint16_t lock_count;
2079 uint32_t lock_sequence;
2080 /* struct smb2_handle handle; */
2081 struct smb2_lock_element {
2082 uint64_t offset;
2083 uint64_t length;
2084 uint32_t flags;
2085 uint32_t reserved;
2086 } *locks;
2087 } in;
2088 struct {
2089 /* static body buffer 4 (0x04) bytes */
2090 /* uint16_t buffer_code; 0x04 */
2091 uint16_t reserved;
2092 } out;
2093 } smb2;
2095 /* SMB2 Break */
2096 struct smb2_break {
2097 enum smb_lock_level level;
2098 struct {
2099 union smb_handle file;
2101 /* static body buffer 24 (0x18) bytes */
2102 uint8_t oplock_level;
2103 uint8_t reserved;
2104 uint32_t reserved2;
2105 /* struct smb2_handle handle; */
2106 } in, out;
2107 } smb2_break;
2109 /* SMB2 Lease Break Ack (same opcode as smb2_break) */
2110 struct smb2_lease_break_ack {
2111 struct {
2112 uint32_t reserved;
2113 struct smb2_lease lease;
2114 } in, out;
2115 } smb2_lease_break_ack;
2119 enum smb_close_level {
2120 RAW_CLOSE_CLOSE,
2121 RAW_CLOSE_SPLCLOSE,
2122 RAW_CLOSE_SMB2,
2123 RAW_CLOSE_GENERIC,
2127 union for close() backend call
2129 union smb_close {
2130 /* generic interface */
2131 struct {
2132 enum smb_close_level level;
2133 struct {
2134 union smb_handle file;
2135 time_t write_time;
2136 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
2137 } in;
2138 struct {
2139 uint16_t flags;
2140 NTTIME create_time;
2141 NTTIME access_time;
2142 NTTIME write_time;
2143 NTTIME change_time;
2144 uint64_t alloc_size;
2145 uint64_t size;
2146 uint32_t file_attr;
2147 } out;
2148 } generic;
2150 /* SMBclose interface */
2151 struct {
2152 enum smb_close_level level;
2153 struct {
2154 union smb_handle file;
2155 time_t write_time;
2156 } in;
2157 } close;
2159 /* SMBsplclose interface - empty! */
2160 struct {
2161 enum smb_close_level level;
2162 struct {
2163 union smb_handle file;
2164 } in;
2165 } splclose;
2167 /* SMB2 Close */
2168 struct smb2_close {
2169 enum smb_close_level level;
2170 struct {
2171 union smb_handle file;
2173 /* static body buffer 24 (0x18) bytes */
2174 /* uint16_t buffer_code; 0x18 */
2175 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
2176 uint32_t _pad;
2177 } in;
2178 struct {
2179 /* static body buffer 60 (0x3C) bytes */
2180 /* uint16_t buffer_code; 0x3C */
2181 uint16_t flags;
2182 uint32_t _pad;
2183 NTTIME create_time;
2184 NTTIME access_time;
2185 NTTIME write_time;
2186 NTTIME change_time;
2187 uint64_t alloc_size;
2188 uint64_t size;
2189 uint32_t file_attr;
2190 } out;
2191 } smb2;
2195 enum smb_lpq_level {RAW_LPQ_GENERIC, RAW_LPQ_RETQ};
2198 union for lpq() backend
2200 union smb_lpq {
2201 /* generic interface */
2202 struct {
2203 enum smb_lpq_level level;
2205 } generic;
2208 /* SMBsplretq interface */
2209 struct {
2210 enum smb_lpq_level level;
2212 struct {
2213 uint16_t maxcount;
2214 uint16_t startidx;
2215 } in;
2216 struct {
2217 uint16_t count;
2218 uint16_t restart_idx;
2219 struct {
2220 time_t time;
2221 uint8_t status;
2222 uint16_t job;
2223 uint32_t size;
2224 char *user;
2225 } *queue;
2226 } out;
2227 } retq;
2230 enum smb_ioctl_level {
2231 RAW_IOCTL_IOCTL,
2232 RAW_IOCTL_NTIOCTL,
2233 RAW_IOCTL_SMB2,
2234 RAW_IOCTL_SMB2_NO_HANDLE
2238 union for ioctl() backend
2240 union smb_ioctl {
2241 /* generic interface */
2242 struct {
2243 enum smb_ioctl_level level;
2244 struct {
2245 union smb_handle file;
2246 } in;
2247 } generic;
2249 /* struct for SMBioctl */
2250 struct {
2251 enum smb_ioctl_level level;
2252 struct {
2253 union smb_handle file;
2254 uint32_t request;
2255 } in;
2256 struct {
2257 DATA_BLOB blob;
2258 } out;
2259 } ioctl;
2262 /* struct for NT ioctl call */
2263 struct {
2264 enum smb_ioctl_level level;
2265 struct {
2266 union smb_handle file;
2267 uint32_t function;
2268 bool fsctl;
2269 uint8_t filter;
2270 uint32_t max_data;
2271 DATA_BLOB blob;
2272 } in;
2273 struct {
2274 DATA_BLOB blob;
2275 } out;
2276 } ntioctl;
2278 /* SMB2 Ioctl */
2279 struct smb2_ioctl {
2280 enum smb_ioctl_level level;
2281 struct {
2282 union smb_handle file;
2284 /* static body buffer 56 (0x38) bytes */
2285 /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
2286 uint16_t _pad;
2287 uint32_t function;
2288 /*struct smb2_handle handle;*/
2289 /* uint32_t out_ofs; */
2290 /* uint32_t out_size; */
2291 uint32_t unknown2;
2292 /* uint32_t in_ofs; */
2293 /* uint32_t in_size; */
2294 uint32_t max_response_size;
2295 uint64_t flags;
2297 /* dynamic body */
2298 DATA_BLOB out;
2299 DATA_BLOB in;
2300 } in;
2301 struct {
2302 union smb_handle file;
2304 /* static body buffer 48 (0x30) bytes */
2305 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
2306 uint16_t _pad;
2307 uint32_t function;
2308 /* struct smb2_handle handle; */
2309 /* uint32_t in_ofs; */
2310 /* uint32_t in_size; */
2311 /* uint32_t out_ofs; */
2312 /* uint32_t out_size; */
2313 uint32_t unknown2;
2314 uint32_t unknown3;
2316 /* dynamic body */
2317 DATA_BLOB in;
2318 DATA_BLOB out;
2319 } out;
2320 } smb2;
2323 enum smb_flush_level {
2324 RAW_FLUSH_FLUSH,
2325 RAW_FLUSH_ALL,
2326 RAW_FLUSH_SMB2
2329 union smb_flush {
2330 /* struct for SMBflush */
2331 struct {
2332 enum smb_flush_level level;
2333 struct {
2334 union smb_handle file;
2335 } in;
2336 } flush, generic;
2338 /* SMBflush with 0xFFFF wildcard fnum */
2339 struct {
2340 enum smb_flush_level level;
2341 } flush_all;
2343 /* SMB2 Flush */
2344 struct smb2_flush {
2345 enum smb_flush_level level;
2346 struct {
2347 union smb_handle file;
2348 uint16_t reserved1;
2349 uint32_t reserved2;
2350 } in;
2351 struct {
2352 uint16_t reserved;
2353 } out;
2354 } smb2;
2357 /* struct for SMBcopy */
2358 struct smb_copy {
2359 struct {
2360 uint16_t tid2;
2361 uint16_t ofun;
2362 uint16_t flags;
2363 const char *path1;
2364 const char *path2;
2365 } in;
2366 struct {
2367 uint16_t count;
2368 } out;
2372 /* struct for transact/transact2 call */
2373 struct smb_trans2 {
2374 struct {
2375 uint16_t max_param;
2376 uint16_t max_data;
2377 uint8_t max_setup;
2378 uint16_t flags;
2379 uint32_t timeout;
2380 uint8_t setup_count;
2381 uint16_t *setup;
2382 const char *trans_name; /* SMBtrans only */
2383 DATA_BLOB params;
2384 DATA_BLOB data;
2385 } in;
2387 struct {
2388 uint8_t setup_count;
2389 uint16_t *setup;
2390 DATA_BLOB params;
2391 DATA_BLOB data;
2392 } out;
2395 /* struct for nttransact2 call */
2396 struct smb_nttrans {
2397 struct {
2398 uint8_t max_setup;
2399 uint32_t max_param;
2400 uint32_t max_data;
2401 uint8_t setup_count;
2402 uint16_t function;
2403 uint8_t *setup;
2404 DATA_BLOB params;
2405 DATA_BLOB data;
2406 } in;
2408 struct {
2409 uint8_t setup_count; /* in units of 16 bit words */
2410 uint8_t *setup;
2411 DATA_BLOB params;
2412 DATA_BLOB data;
2413 } out;
2416 enum smb_notify_level {
2417 RAW_NOTIFY_NTTRANS,
2418 RAW_NOTIFY_SMB2
2421 union smb_notify {
2422 /* struct for nttrans change notify call */
2423 struct {
2424 enum smb_notify_level level;
2426 struct {
2427 union smb_handle file;
2428 uint32_t buffer_size;
2429 uint32_t completion_filter;
2430 bool recursive;
2431 } in;
2433 struct {
2434 uint32_t num_changes;
2435 struct notify_changes {
2436 uint32_t action;
2437 struct smb_wire_string name;
2438 } *changes;
2439 } out;
2440 } nttrans;
2442 struct smb2_notify {
2443 enum smb_notify_level level;
2445 struct {
2446 union smb_handle file;
2447 /* static body buffer 32 (0x20) bytes */
2448 /* uint16_t buffer_code; 0x32 */
2449 uint16_t recursive;
2450 uint32_t buffer_size;
2451 /*struct smb2_handle file;*/
2452 uint32_t completion_filter;
2453 uint32_t unknown;
2454 } in;
2456 struct {
2457 /* static body buffer 8 (0x08) bytes */
2458 /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
2459 /* uint16_t blob_ofs; */
2460 /* uint16_t blob_size; */
2462 /* dynamic body */
2463 /*DATA_BLOB blob;*/
2465 /* DATA_BLOB content */
2466 uint32_t num_changes;
2467 struct notify_changes *changes;
2468 } out;
2469 } smb2;
2472 enum smb_search_level {
2473 RAW_SEARCH_SEARCH, /* SMBsearch */
2474 RAW_SEARCH_FFIRST, /* SMBffirst */
2475 RAW_SEARCH_FUNIQUE, /* SMBfunique */
2476 RAW_SEARCH_TRANS2, /* SMBtrans2 */
2477 RAW_SEARCH_SMB2 /* SMB2 Find */
2480 enum smb_search_data_level {
2481 RAW_SEARCH_DATA_GENERIC = 0x10000, /* only used in the smbcli_ code */
2482 RAW_SEARCH_DATA_SEARCH,
2483 RAW_SEARCH_DATA_STANDARD = SMB_FIND_STANDARD,
2484 RAW_SEARCH_DATA_EA_SIZE = SMB_FIND_EA_SIZE,
2485 RAW_SEARCH_DATA_EA_LIST = SMB_FIND_EA_LIST,
2486 RAW_SEARCH_DATA_DIRECTORY_INFO = SMB_FIND_DIRECTORY_INFO,
2487 RAW_SEARCH_DATA_FULL_DIRECTORY_INFO = SMB_FIND_FULL_DIRECTORY_INFO,
2488 RAW_SEARCH_DATA_NAME_INFO = SMB_FIND_NAME_INFO,
2489 RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO = SMB_FIND_BOTH_DIRECTORY_INFO,
2490 RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO = SMB_FIND_ID_FULL_DIRECTORY_INFO,
2491 RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
2492 RAW_SEARCH_DATA_UNIX_INFO = SMB_FIND_UNIX_INFO,
2493 RAW_SEARCH_DATA_UNIX_INFO2 = SMB_FIND_UNIX_INFO2
2496 /* union for file search */
2497 union smb_search_first {
2498 struct {
2499 enum smb_search_level level;
2500 enum smb_search_data_level data_level;
2501 } generic;
2503 /* search (old) findfirst interface.
2504 Also used for ffirst and funique. */
2505 struct {
2506 enum smb_search_level level;
2507 enum smb_search_data_level data_level;
2509 struct {
2510 uint16_t max_count;
2511 uint16_t search_attrib;
2512 const char *pattern;
2513 } in;
2514 struct {
2515 int16_t count;
2516 } out;
2517 } search_first;
2519 /* trans2 findfirst interface */
2520 struct {
2521 enum smb_search_level level;
2522 enum smb_search_data_level data_level;
2524 struct {
2525 uint16_t search_attrib;
2526 uint16_t max_count;
2527 uint16_t flags;
2528 uint32_t storage_type;
2529 const char *pattern;
2531 /* the ea names are only used for RAW_SEARCH_EA_LIST */
2532 unsigned int num_names;
2533 struct ea_name *ea_names;
2534 } in;
2535 struct {
2536 uint16_t handle;
2537 uint16_t count;
2538 uint16_t end_of_search;
2539 } out;
2540 } t2ffirst;
2542 /* SMB2 Find */
2543 struct smb2_find {
2544 enum smb_search_level level;
2545 enum smb_search_data_level data_level;
2546 struct {
2547 union smb_handle file;
2549 /* static body buffer 32 (0x20) bytes */
2550 /* uint16_t buffer_code; 0x21 = 0x20 + 1 */
2551 uint8_t level;
2552 uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */
2553 uint32_t file_index;
2554 /* struct smb2_handle handle; */
2555 /* uint16_t pattern_ofs; */
2556 /* uint16_t pattern_size; */
2557 uint32_t max_response_size;
2559 /* dynamic body */
2560 const char *pattern;
2561 } in;
2562 struct {
2563 /* static body buffer 8 (0x08) bytes */
2564 /* uint16_t buffer_code; 0x08 */
2565 /* uint16_t blob_ofs; */
2566 /* uint32_t blob_size; */
2568 /* dynamic body */
2569 DATA_BLOB blob;
2570 } out;
2571 } smb2;
2574 /* union for file search continue */
2575 union smb_search_next {
2576 struct {
2577 enum smb_search_level level;
2578 enum smb_search_data_level data_level;
2579 } generic;
2581 /* search (old) findnext interface. Also used
2582 for ffirst when continuing */
2583 struct {
2584 enum smb_search_level level;
2585 enum smb_search_data_level data_level;
2587 struct {
2588 uint16_t max_count;
2589 uint16_t search_attrib;
2590 struct smb_search_id {
2591 uint8_t reserved;
2592 char name[11];
2593 uint8_t handle;
2594 uint32_t server_cookie;
2595 uint32_t client_cookie;
2596 } id;
2597 } in;
2598 struct {
2599 uint16_t count;
2600 } out;
2601 } search_next;
2603 /* trans2 findnext interface */
2604 struct {
2605 enum smb_search_level level;
2606 enum smb_search_data_level data_level;
2608 struct {
2609 uint16_t handle;
2610 uint16_t max_count;
2611 uint32_t resume_key;
2612 uint16_t flags;
2613 const char *last_name;
2615 /* the ea names are only used for RAW_SEARCH_EA_LIST */
2616 unsigned int num_names;
2617 struct ea_name *ea_names;
2618 } in;
2619 struct {
2620 uint16_t count;
2621 uint16_t end_of_search;
2622 } out;
2623 } t2fnext;
2625 /* SMB2 Find */
2626 struct smb2_find smb2;
2629 /* union for search reply file data */
2630 union smb_search_data {
2632 * search (old) findfirst
2633 * RAW_SEARCH_DATA_SEARCH
2635 struct {
2636 uint16_t attrib;
2637 time_t write_time;
2638 uint32_t size;
2639 struct smb_search_id id;
2640 const char *name;
2641 } search;
2643 /* trans2 findfirst RAW_SEARCH_DATA_STANDARD level */
2644 struct {
2645 uint32_t resume_key;
2646 time_t create_time;
2647 time_t access_time;
2648 time_t write_time;
2649 uint32_t size;
2650 uint32_t alloc_size;
2651 uint16_t attrib;
2652 struct smb_wire_string name;
2653 } standard;
2655 /* trans2 findfirst RAW_SEARCH_DATA_EA_SIZE level */
2656 struct {
2657 uint32_t resume_key;
2658 time_t create_time;
2659 time_t access_time;
2660 time_t write_time;
2661 uint32_t size;
2662 uint32_t alloc_size;
2663 uint16_t attrib;
2664 uint32_t ea_size;
2665 struct smb_wire_string name;
2666 } ea_size;
2668 /* trans2 findfirst RAW_SEARCH_DATA_EA_LIST level */
2669 struct {
2670 uint32_t resume_key;
2671 time_t create_time;
2672 time_t access_time;
2673 time_t write_time;
2674 uint32_t size;
2675 uint32_t alloc_size;
2676 uint16_t attrib;
2677 struct smb_ea_list eas;
2678 struct smb_wire_string name;
2679 } ea_list;
2681 /* RAW_SEARCH_DATA_DIRECTORY_INFO interface */
2682 struct {
2683 uint32_t file_index;
2684 NTTIME create_time;
2685 NTTIME access_time;
2686 NTTIME write_time;
2687 NTTIME change_time;
2688 uint64_t size;
2689 uint64_t alloc_size;
2690 uint32_t attrib;
2691 struct smb_wire_string name;
2692 } directory_info;
2694 /* RAW_SEARCH_DATA_FULL_DIRECTORY_INFO interface */
2695 struct {
2696 uint32_t file_index;
2697 NTTIME create_time;
2698 NTTIME access_time;
2699 NTTIME write_time;
2700 NTTIME change_time;
2701 uint64_t size;
2702 uint64_t alloc_size;
2703 uint32_t attrib;
2704 uint32_t ea_size;
2705 struct smb_wire_string name;
2706 } full_directory_info;
2708 /* RAW_SEARCH_DATA_NAME_INFO interface */
2709 struct {
2710 uint32_t file_index;
2711 struct smb_wire_string name;
2712 } name_info;
2714 /* RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO interface */
2715 struct {
2716 uint32_t file_index;
2717 NTTIME create_time;
2718 NTTIME access_time;
2719 NTTIME write_time;
2720 NTTIME change_time;
2721 uint64_t size;
2722 uint64_t alloc_size;
2723 uint32_t attrib;
2724 uint32_t ea_size;
2725 struct smb_wire_string short_name;
2726 struct smb_wire_string name;
2727 } both_directory_info;
2729 /* RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO interface */
2730 struct {
2731 uint32_t file_index;
2732 NTTIME create_time;
2733 NTTIME access_time;
2734 NTTIME write_time;
2735 NTTIME change_time;
2736 uint64_t size;
2737 uint64_t alloc_size;
2738 uint32_t attrib;
2739 uint32_t ea_size;
2740 uint64_t file_id;
2741 struct smb_wire_string name;
2742 } id_full_directory_info;
2744 /* RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO interface */
2745 struct {
2746 uint32_t file_index;
2747 NTTIME create_time;
2748 NTTIME access_time;
2749 NTTIME write_time;
2750 NTTIME change_time;
2751 uint64_t size;
2752 uint64_t alloc_size;
2753 uint32_t attrib;
2754 uint32_t ea_size;
2755 uint64_t file_id;
2756 struct smb_wire_string short_name;
2757 struct smb_wire_string name;
2758 } id_both_directory_info;
2760 /* RAW_SEARCH_DATA_UNIX_INFO interface */
2761 struct {
2762 uint32_t file_index;
2763 uint64_t size;
2764 uint64_t alloc_size;
2765 NTTIME status_change_time;
2766 NTTIME access_time;
2767 NTTIME change_time;
2768 uint64_t uid;
2769 uint64_t gid;
2770 uint32_t file_type;
2771 uint64_t dev_major;
2772 uint64_t dev_minor;
2773 uint64_t unique_id;
2774 uint64_t permissions;
2775 uint64_t nlink;
2776 const char *name;
2777 } unix_info;
2779 /* RAW_SEARCH_DATA_UNIX_INFO2 interface */
2780 struct {
2781 uint32_t file_index;
2782 uint64_t end_of_file;
2783 uint64_t num_bytes;
2784 NTTIME status_change_time;
2785 NTTIME access_time;
2786 NTTIME change_time;
2787 uint64_t uid;
2788 uint64_t gid;
2789 uint32_t file_type;
2790 uint64_t dev_major;
2791 uint64_t dev_minor;
2792 uint64_t unique_id;
2793 uint64_t permissions;
2794 uint64_t nlink;
2795 NTTIME create_time;
2796 uint32_t file_flags;
2797 uint32_t flags_mask;
2798 struct smb_wire_string name;
2799 } unix_info2;
2802 /* Callback function passed to the raw search interface. */
2803 typedef bool (*smbcli_search_callback)(void *private_data, const union smb_search_data *file);
2805 enum smb_search_close_level {RAW_FINDCLOSE_GENERIC, RAW_FINDCLOSE_FCLOSE, RAW_FINDCLOSE_FINDCLOSE};
2807 /* union for file search close */
2808 union smb_search_close {
2809 struct {
2810 enum smb_search_close_level level;
2811 } generic;
2813 /* SMBfclose (old search) interface */
2814 struct {
2815 enum smb_search_close_level level;
2817 struct {
2818 /* max_count and search_attrib are not used, but are present */
2819 uint16_t max_count;
2820 uint16_t search_attrib;
2821 struct smb_search_id id;
2822 } in;
2823 } fclose;
2825 /* SMBfindclose interface */
2826 struct {
2827 enum smb_search_close_level level;
2829 struct {
2830 uint16_t handle;
2831 } in;
2832 } findclose;
2837 struct for SMBecho call
2839 struct smb_echo {
2840 struct {
2841 uint16_t repeat_count;
2842 uint16_t size;
2843 uint8_t *data;
2844 } in;
2845 struct {
2846 uint16_t count;
2847 uint16_t sequence_number;
2848 uint16_t size;
2849 uint8_t *data;
2850 } out;
2854 struct for shadow copy volumes
2856 struct smb_shadow_copy {
2857 struct {
2858 union smb_handle file;
2859 uint32_t max_data;
2860 } in;
2861 struct {
2862 uint32_t num_volumes;
2863 uint32_t num_names;
2864 const char **names;
2865 } out;
2868 #endif /* __LIBCLI_RAW_INTERFACES_H__ */