Add SMB_QFS_PROXY_INFO to identify WAFS proxy capabilities
[Samba/vfs_proxy.git] / source4 / libcli / raw / interfaces.h
bloba505dfe9f3ebb08c76a7c2882717573909ea2174
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 "smb.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
35 string
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;
45 const char *s;
49 * SMB2 uses a 16Byte handle,
50 * (we can maybe use struct GUID later)
52 struct smb2_handle {
53 uint64_t data[2];
56 struct ntvfs_handle;
59 * a generic container for file handles or file pathes
60 * for qfileinfo/setfileinfo and qpathinfo/setpathinfo
62 union smb_handle_or_path {
64 * this is used for
65 * the qpathinfo and setpathinfo
66 * calls
68 const char *path;
70 * this is used as file handle in SMB
72 uint16_t fnum;
75 * this is used as file handle in SMB2
77 struct smb2_handle handle;
80 * this is used as generic file handle for the NTVFS layer
82 struct ntvfs_handle *ntvfs;
86 a generic container for file handles
88 union smb_handle {
90 * this is used as file handle in SMB
92 uint16_t fnum;
95 * this is used as file handle in SMB2
97 struct smb2_handle handle;
100 * this is used as generic file handle for the NTVFS layer
102 struct ntvfs_handle *ntvfs;
106 this header defines the structures and unions used between the SMB
107 parser and the backends.
110 /* struct used for SMBlseek call */
111 union smb_seek {
112 struct {
113 struct {
114 union smb_handle file;
115 uint16_t mode;
116 int32_t offset; /* signed */
117 } in;
118 struct {
119 int32_t offset;
120 } out;
121 } lseek, generic;
124 /* struct used in unlink() call */
125 union smb_unlink {
126 struct {
127 struct {
128 const char *pattern;
129 uint16_t attrib;
130 } in;
131 } unlink;
135 /* struct used in chkpath() call */
136 union smb_chkpath {
137 struct {
138 struct {
139 const char *path;
140 } in;
141 } chkpath;
144 enum smb_mkdir_level {RAW_MKDIR_GENERIC, RAW_MKDIR_MKDIR, RAW_MKDIR_T2MKDIR};
146 /* union used in mkdir() call */
147 union smb_mkdir {
148 /* generic level */
149 struct {
150 enum smb_mkdir_level level;
151 } generic;
153 struct {
154 enum smb_mkdir_level level;
155 struct {
156 const char *path;
157 } in;
158 } mkdir;
160 struct {
161 enum smb_mkdir_level level;
162 struct {
163 const char *path;
164 uint_t num_eas;
165 struct ea_struct *eas;
166 } in;
167 } t2mkdir;
170 /* struct used in rmdir() call */
171 struct smb_rmdir {
172 struct {
173 const char *path;
174 } in;
177 /* struct used in rename() call */
178 enum smb_rename_level {RAW_RENAME_RENAME, RAW_RENAME_NTRENAME, RAW_RENAME_NTTRANS};
180 union smb_rename {
181 struct {
182 enum smb_rename_level level;
183 } generic;
185 /* SMBrename interface */
186 struct {
187 enum smb_rename_level level;
189 struct {
190 const char *pattern1;
191 const char *pattern2;
192 uint16_t attrib;
193 } in;
194 } rename;
197 /* SMBntrename interface */
198 struct {
199 enum smb_rename_level level;
201 struct {
202 uint16_t attrib;
203 uint16_t flags; /* see RENAME_FLAG_* */
204 uint32_t cluster_size;
205 const char *old_name;
206 const char *new_name;
207 } in;
208 } ntrename;
210 /* NT TRANS rename interface */
211 struct {
212 enum smb_rename_level level;
214 struct {
215 union smb_handle file;
216 uint16_t flags;/* see RENAME_REPLACE_IF_EXISTS */
217 const char *new_name;
218 } in;
219 } nttrans;
222 enum smb_tcon_level {
223 RAW_TCON_TCON,
224 RAW_TCON_TCONX,
225 RAW_TCON_SMB2
228 /* union used in tree connect call */
229 union smb_tcon {
230 /* generic interface */
231 struct {
232 enum smb_tcon_level level;
233 } generic;
235 /* SMBtcon interface */
236 struct {
237 enum smb_tcon_level level;
239 struct {
240 const char *service;
241 const char *password;
242 const char *dev;
243 } in;
244 struct {
245 uint16_t max_xmit;
246 uint16_t tid;
247 } out;
248 } tcon;
250 /* SMBtconX interface */
251 struct {
252 enum smb_tcon_level level;
254 struct {
255 uint16_t flags;
256 DATA_BLOB password;
257 const char *path;
258 const char *device;
259 } in;
260 struct {
261 uint16_t options;
262 char *dev_type;
263 char *fs_type;
264 uint16_t tid;
265 } out;
266 } tconx;
268 /* SMB2 TreeConnect */
269 struct smb2_tree_connect {
270 enum smb_tcon_level level;
272 struct {
273 /* static body buffer 8 (0x08) bytes */
274 uint16_t reserved;
275 /* uint16_t path_ofs */
276 /* uint16_t path_size */
277 /* dynamic body */
278 const char *path; /* as non-terminated UTF-16 on the wire */
279 } in;
280 struct {
281 /* static body buffer 16 (0x10) bytes */
282 /* uint16_t buffer_code; 0x10 */
283 uint8_t share_type;
284 uint8_t reserved;
285 uint32_t flags;
286 uint32_t capabilities;
287 uint32_t access_mask;
289 /* extracted from the SMB2 header */
290 uint32_t tid;
291 } out;
292 } smb2;
296 enum smb_sesssetup_level {
297 RAW_SESSSETUP_OLD,
298 RAW_SESSSETUP_NT1,
299 RAW_SESSSETUP_SPNEGO,
300 RAW_SESSSETUP_SMB2
303 /* union used in session_setup call */
304 union smb_sesssetup {
305 /* the pre-NT1 interface */
306 struct {
307 enum smb_sesssetup_level level;
309 struct {
310 uint16_t bufsize;
311 uint16_t mpx_max;
312 uint16_t vc_num;
313 uint32_t sesskey;
314 DATA_BLOB password;
315 const char *user;
316 const char *domain;
317 const char *os;
318 const char *lanman;
319 } in;
320 struct {
321 uint16_t action;
322 uint16_t vuid;
323 char *os;
324 char *lanman;
325 char *domain;
326 } out;
327 } old;
329 /* the NT1 interface */
330 struct {
331 enum smb_sesssetup_level level;
333 struct {
334 uint16_t bufsize;
335 uint16_t mpx_max;
336 uint16_t vc_num;
337 uint32_t sesskey;
338 uint32_t capabilities;
339 DATA_BLOB password1;
340 DATA_BLOB password2;
341 const char *user;
342 const char *domain;
343 const char *os;
344 const char *lanman;
345 } in;
346 struct {
347 uint16_t action;
348 uint16_t vuid;
349 char *os;
350 char *lanman;
351 char *domain;
352 } out;
353 } nt1;
356 /* the SPNEGO interface */
357 struct {
358 enum smb_sesssetup_level level;
360 struct {
361 uint16_t bufsize;
362 uint16_t mpx_max;
363 uint16_t vc_num;
364 uint32_t sesskey;
365 uint32_t capabilities;
366 DATA_BLOB secblob;
367 const char *os;
368 const char *lanman;
369 const char *workgroup;
370 } in;
371 struct {
372 uint16_t action;
373 DATA_BLOB secblob;
374 char *os;
375 char *lanman;
376 char *workgroup;
377 uint16_t vuid;
378 } out;
379 } spnego;
381 /* SMB2 SessionSetup */
382 struct smb2_session_setup {
383 enum smb_sesssetup_level level;
385 struct {
386 /* static body 24 (0x18) bytes */
387 uint8_t vc_number;
388 uint8_t security_mode;
389 uint32_t capabilities;
390 uint32_t channel;
391 /* uint16_t secblob_ofs */
392 /* uint16_t secblob_size */
393 uint64_t previous_sessionid;
394 /* dynamic body */
395 DATA_BLOB secblob;
396 } in;
397 struct {
398 /* body buffer 8 (0x08) bytes */
399 uint16_t session_flags;
400 /* uint16_t secblob_ofs */
401 /* uint16_t secblob_size */
402 /* dynamic body */
403 DATA_BLOB secblob;
405 /* extracted from the SMB2 header */
406 uint64_t uid;
407 } out;
408 } smb2;
411 /* Note that the specified enum values are identical to the actual info-levels used
412 * on the wire.
414 enum smb_fileinfo_level {
415 RAW_FILEINFO_GENERIC = 0xF000,
416 RAW_FILEINFO_GETATTR, /* SMBgetatr */
417 RAW_FILEINFO_GETATTRE, /* SMBgetattrE */
418 RAW_FILEINFO_SEC_DESC, /* NT_TRANSACT_QUERY_SECURITY_DESC */
419 RAW_FILEINFO_STANDARD = SMB_QFILEINFO_STANDARD,
420 RAW_FILEINFO_EA_SIZE = SMB_QFILEINFO_EA_SIZE,
421 RAW_FILEINFO_EA_LIST = SMB_QFILEINFO_EA_LIST,
422 RAW_FILEINFO_ALL_EAS = SMB_QFILEINFO_ALL_EAS,
423 RAW_FILEINFO_IS_NAME_VALID = SMB_QFILEINFO_IS_NAME_VALID,
424 RAW_FILEINFO_BASIC_INFO = SMB_QFILEINFO_BASIC_INFO,
425 RAW_FILEINFO_STANDARD_INFO = SMB_QFILEINFO_STANDARD_INFO,
426 RAW_FILEINFO_EA_INFO = SMB_QFILEINFO_EA_INFO,
427 RAW_FILEINFO_NAME_INFO = SMB_QFILEINFO_NAME_INFO,
428 RAW_FILEINFO_ALL_INFO = SMB_QFILEINFO_ALL_INFO,
429 RAW_FILEINFO_ALT_NAME_INFO = SMB_QFILEINFO_ALT_NAME_INFO,
430 RAW_FILEINFO_STREAM_INFO = SMB_QFILEINFO_STREAM_INFO,
431 RAW_FILEINFO_COMPRESSION_INFO = SMB_QFILEINFO_COMPRESSION_INFO,
432 RAW_FILEINFO_UNIX_BASIC = SMB_QFILEINFO_UNIX_BASIC,
433 RAW_FILEINFO_UNIX_INFO2 = SMB_QFILEINFO_UNIX_INFO2,
434 RAW_FILEINFO_UNIX_LINK = SMB_QFILEINFO_UNIX_LINK,
435 RAW_FILEINFO_BASIC_INFORMATION = SMB_QFILEINFO_BASIC_INFORMATION,
436 RAW_FILEINFO_STANDARD_INFORMATION = SMB_QFILEINFO_STANDARD_INFORMATION,
437 RAW_FILEINFO_INTERNAL_INFORMATION = SMB_QFILEINFO_INTERNAL_INFORMATION,
438 RAW_FILEINFO_EA_INFORMATION = SMB_QFILEINFO_EA_INFORMATION,
439 RAW_FILEINFO_ACCESS_INFORMATION = SMB_QFILEINFO_ACCESS_INFORMATION,
440 RAW_FILEINFO_NAME_INFORMATION = SMB_QFILEINFO_NAME_INFORMATION,
441 RAW_FILEINFO_POSITION_INFORMATION = SMB_QFILEINFO_POSITION_INFORMATION,
442 RAW_FILEINFO_MODE_INFORMATION = SMB_QFILEINFO_MODE_INFORMATION,
443 RAW_FILEINFO_ALIGNMENT_INFORMATION = SMB_QFILEINFO_ALIGNMENT_INFORMATION,
444 RAW_FILEINFO_ALL_INFORMATION = SMB_QFILEINFO_ALL_INFORMATION,
445 RAW_FILEINFO_ALT_NAME_INFORMATION = SMB_QFILEINFO_ALT_NAME_INFORMATION,
446 RAW_FILEINFO_STREAM_INFORMATION = SMB_QFILEINFO_STREAM_INFORMATION,
447 RAW_FILEINFO_COMPRESSION_INFORMATION = SMB_QFILEINFO_COMPRESSION_INFORMATION,
448 RAW_FILEINFO_NETWORK_OPEN_INFORMATION = SMB_QFILEINFO_NETWORK_OPEN_INFORMATION,
449 RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION = SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION,
450 /* SMB2 specific levels */
451 RAW_FILEINFO_SMB2_ALL_EAS = 0x0f01,
452 RAW_FILEINFO_SMB2_ALL_INFORMATION = 0x1201
455 /* union used in qfileinfo() and qpathinfo() backend calls */
456 union smb_fileinfo {
457 /* generic interface:
458 * matches RAW_FILEINFO_GENERIC */
459 struct {
460 enum smb_fileinfo_level level;
461 struct {
462 union smb_handle_or_path file;
463 } in;
464 struct {
465 uint32_t attrib;
466 uint32_t ea_size;
467 uint_t num_eas;
468 struct ea_struct {
469 uint8_t flags;
470 struct smb_wire_string name;
471 DATA_BLOB value;
472 } *eas;
473 NTTIME create_time;
474 NTTIME access_time;
475 NTTIME write_time;
476 NTTIME change_time;
477 uint64_t alloc_size;
478 uint64_t size;
479 uint32_t nlink;
480 struct smb_wire_string fname;
481 struct smb_wire_string alt_fname;
482 uint8_t delete_pending;
483 uint8_t directory;
484 uint64_t compressed_size;
485 uint16_t format;
486 uint8_t unit_shift;
487 uint8_t chunk_shift;
488 uint8_t cluster_shift;
489 uint64_t file_id;
490 uint32_t access_flags; /* seen 0x001f01ff from w2k3 */
491 uint64_t position;
492 uint32_t mode;
493 uint32_t alignment_requirement;
494 uint32_t reparse_tag;
495 uint_t num_streams;
496 struct stream_struct {
497 uint64_t size;
498 uint64_t alloc_size;
499 struct smb_wire_string stream_name;
500 } *streams;
501 } out;
502 } generic;
505 /* SMBgetatr interface:
506 * matches RAW_FILEINFO_GETATTR */
507 struct {
508 enum smb_fileinfo_level level;
509 struct {
510 union smb_handle_or_path file;
511 } in;
512 struct {
513 uint16_t attrib;
514 uint32_t size;
515 time_t write_time;
516 } out;
517 } getattr;
519 /* SMBgetattrE and RAW_FILEINFO_STANDARD interface */
520 struct {
521 enum smb_fileinfo_level level;
522 struct {
523 union smb_handle_or_path file;
524 } in;
525 struct {
526 time_t create_time;
527 time_t access_time;
528 time_t write_time;
529 uint32_t size;
530 uint32_t alloc_size;
531 uint16_t attrib;
532 } out;
533 } getattre, standard;
535 /* trans2 RAW_FILEINFO_EA_SIZE interface */
536 struct {
537 enum smb_fileinfo_level level;
538 struct {
539 union smb_handle_or_path file;
540 } in;
541 struct {
542 time_t create_time;
543 time_t access_time;
544 time_t write_time;
545 uint32_t size;
546 uint32_t alloc_size;
547 uint16_t attrib;
548 uint32_t ea_size;
549 } out;
550 } ea_size;
552 /* trans2 RAW_FILEINFO_EA_LIST interface */
553 struct {
554 enum smb_fileinfo_level level;
555 struct {
556 union smb_handle_or_path file;
557 uint_t num_names;
558 struct ea_name {
559 struct smb_wire_string name;
560 } *ea_names;
561 } in;
563 struct smb_ea_list {
564 uint_t num_eas;
565 struct ea_struct *eas;
566 } out;
567 } ea_list;
569 /* trans2 RAW_FILEINFO_ALL_EAS and RAW_FILEINFO_FULL_EA_INFORMATION interfaces */
570 struct {
571 enum smb_fileinfo_level level;
572 struct {
573 union smb_handle_or_path file;
574 /* SMB2 only - SMB2_CONTINUE_FLAG_* */
575 uint8_t continue_flags;
576 } in;
577 struct smb_ea_list out;
578 } all_eas;
580 /* trans2 qpathinfo RAW_FILEINFO_IS_NAME_VALID interface
581 only valid for a QPATHNAME call - no returned data */
582 struct {
583 enum smb_fileinfo_level level;
584 struct {
585 union smb_handle_or_path file;
586 } in;
587 } is_name_valid;
589 /* RAW_FILEINFO_BASIC_INFO and RAW_FILEINFO_BASIC_INFORMATION interfaces */
590 struct {
591 enum smb_fileinfo_level level;
592 struct {
593 union smb_handle_or_path file;
594 } in;
595 struct {
596 NTTIME create_time;
597 NTTIME access_time;
598 NTTIME write_time;
599 NTTIME change_time;
600 uint32_t attrib;
601 } out;
602 } basic_info;
605 /* RAW_FILEINFO_STANDARD_INFO and RAW_FILEINFO_STANDARD_INFORMATION interfaces */
606 struct {
607 enum smb_fileinfo_level level;
608 struct {
609 union smb_handle_or_path file;
610 } in;
611 struct {
612 uint64_t alloc_size;
613 uint64_t size;
614 uint32_t nlink;
615 bool delete_pending;
616 bool directory;
617 } out;
618 } standard_info;
620 /* RAW_FILEINFO_EA_INFO and RAW_FILEINFO_EA_INFORMATION interfaces */
621 struct {
622 enum smb_fileinfo_level level;
623 struct {
624 union smb_handle_or_path file;
625 } in;
626 struct {
627 uint32_t ea_size;
628 } out;
629 } ea_info;
631 /* RAW_FILEINFO_NAME_INFO and RAW_FILEINFO_NAME_INFORMATION interfaces */
632 struct {
633 enum smb_fileinfo_level level;
634 struct {
635 union smb_handle_or_path file;
636 } in;
637 struct {
638 struct smb_wire_string fname;
639 } out;
640 } name_info;
642 /* RAW_FILEINFO_ALL_INFO and RAW_FILEINFO_ALL_INFORMATION interfaces */
643 struct {
644 enum smb_fileinfo_level level;
645 struct {
646 union smb_handle_or_path file;
647 } in;
648 struct {
649 NTTIME create_time;
650 NTTIME access_time;
651 NTTIME write_time;
652 NTTIME change_time;
653 uint32_t attrib;
654 uint64_t alloc_size;
655 uint64_t size;
656 uint32_t nlink;
657 uint8_t delete_pending;
658 uint8_t directory;
659 uint32_t ea_size;
660 struct smb_wire_string fname;
661 } out;
662 } all_info;
664 /* RAW_FILEINFO_SMB2_ALL_INFORMATION interface */
665 struct {
666 enum smb_fileinfo_level level;
667 struct {
668 union smb_handle_or_path file;
669 } in;
670 struct {
671 NTTIME create_time;
672 NTTIME access_time;
673 NTTIME write_time;
674 NTTIME change_time;
675 uint32_t attrib;
676 uint32_t unknown1;
677 uint64_t alloc_size;
678 uint64_t size;
679 uint32_t nlink;
680 uint8_t delete_pending;
681 uint8_t directory;
682 /* uint16_t _pad; */
683 uint64_t file_id;
684 uint32_t ea_size;
685 uint32_t access_mask;
686 uint64_t position;
687 uint32_t mode;
688 uint32_t alignment_requirement;
689 struct smb_wire_string fname;
690 } out;
691 } all_info2;
693 /* RAW_FILEINFO_ALT_NAME_INFO and RAW_FILEINFO_ALT_NAME_INFORMATION interfaces */
694 struct {
695 enum smb_fileinfo_level level;
696 struct {
697 union smb_handle_or_path file;
698 } in;
699 struct {
700 struct smb_wire_string fname;
701 } out;
702 } alt_name_info;
704 /* RAW_FILEINFO_STREAM_INFO and RAW_FILEINFO_STREAM_INFORMATION interfaces */
705 struct {
706 enum smb_fileinfo_level level;
707 struct {
708 union smb_handle_or_path file;
709 } in;
710 struct stream_information {
711 uint_t num_streams;
712 struct stream_struct *streams;
713 } out;
714 } stream_info;
716 /* RAW_FILEINFO_COMPRESSION_INFO and RAW_FILEINFO_COMPRESSION_INFORMATION interfaces */
717 struct {
718 enum smb_fileinfo_level level;
719 struct {
720 union smb_handle_or_path file;
721 } in;
722 struct {
723 uint64_t compressed_size;
724 uint16_t format;
725 uint8_t unit_shift;
726 uint8_t chunk_shift;
727 uint8_t cluster_shift;
728 } out;
729 } compression_info;
731 /* RAW_FILEINFO_UNIX_BASIC interface */
732 struct {
733 enum smb_fileinfo_level level;
734 struct {
735 union smb_handle_or_path file;
736 } in;
737 struct {
738 uint64_t end_of_file;
739 uint64_t num_bytes;
740 NTTIME status_change_time;
741 NTTIME access_time;
742 NTTIME change_time;
743 uint64_t uid;
744 uint64_t gid;
745 uint32_t file_type;
746 uint64_t dev_major;
747 uint64_t dev_minor;
748 uint64_t unique_id;
749 uint64_t permissions;
750 uint64_t nlink;
751 } out;
752 } unix_basic_info;
754 /* RAW_FILEINFO_UNIX_INFO2 interface */
755 struct {
756 enum smb_fileinfo_level level;
757 struct {
758 union smb_handle_or_path file;
759 } in;
760 struct {
761 uint64_t end_of_file;
762 uint64_t num_bytes;
763 NTTIME status_change_time;
764 NTTIME access_time;
765 NTTIME change_time;
766 uint64_t uid;
767 uint64_t gid;
768 uint32_t file_type;
769 uint64_t dev_major;
770 uint64_t dev_minor;
771 uint64_t unique_id;
772 uint64_t permissions;
773 uint64_t nlink;
774 NTTIME create_time;
775 uint32_t file_flags;
776 uint32_t flags_mask;
777 } out;
778 } unix_info2;
780 /* RAW_FILEINFO_UNIX_LINK interface */
781 struct {
782 enum smb_fileinfo_level level;
783 struct {
784 union smb_handle_or_path file;
785 } in;
786 struct {
787 struct smb_wire_string link_dest;
788 } out;
789 } unix_link_info;
791 /* RAW_FILEINFO_INTERNAL_INFORMATION interface */
792 struct {
793 enum smb_fileinfo_level level;
794 struct {
795 union smb_handle_or_path file;
796 } in;
797 struct {
798 uint64_t file_id;
799 } out;
800 } internal_information;
802 /* RAW_FILEINFO_ACCESS_INFORMATION interface */
803 struct {
804 enum smb_fileinfo_level level;
805 struct {
806 union smb_handle_or_path file;
807 } in;
808 struct {
809 uint32_t access_flags;
810 } out;
811 } access_information;
813 /* RAW_FILEINFO_POSITION_INFORMATION interface */
814 struct {
815 enum smb_fileinfo_level level;
816 struct {
817 union smb_handle_or_path file;
818 } in;
819 struct {
820 uint64_t position;
821 } out;
822 } position_information;
824 /* RAW_FILEINFO_MODE_INFORMATION interface */
825 struct {
826 enum smb_fileinfo_level level;
827 struct {
828 union smb_handle_or_path file;
829 } in;
830 struct {
831 uint32_t mode;
832 } out;
833 } mode_information;
835 /* RAW_FILEINFO_ALIGNMENT_INFORMATION interface */
836 struct {
837 enum smb_fileinfo_level level;
838 struct {
839 union smb_handle_or_path file;
840 } in;
841 struct {
842 uint32_t alignment_requirement;
843 } out;
844 } alignment_information;
846 /* RAW_FILEINFO_NETWORK_OPEN_INFORMATION interface */
847 struct {
848 enum smb_fileinfo_level level;
849 struct {
850 union smb_handle_or_path file;
851 } in;
852 struct {
853 NTTIME create_time;
854 NTTIME access_time;
855 NTTIME write_time;
856 NTTIME change_time;
857 uint64_t alloc_size;
858 uint64_t size;
859 uint32_t attrib;
860 } out;
861 } network_open_information;
864 /* RAW_FILEINFO_ATTRIBUTE_TAG_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 attrib;
872 uint32_t reparse_tag;
873 } out;
874 } attribute_tag_information;
876 /* RAW_FILEINFO_SEC_DESC */
877 struct {
878 enum smb_fileinfo_level level;
879 struct {
880 union smb_handle_or_path file;
881 uint32_t secinfo_flags;
882 } in;
883 struct {
884 struct security_descriptor *sd;
885 } out;
886 } query_secdesc;
890 enum smb_setfileinfo_level {
891 RAW_SFILEINFO_GENERIC = 0xF000,
892 RAW_SFILEINFO_SETATTR, /* SMBsetatr */
893 RAW_SFILEINFO_SETATTRE, /* SMBsetattrE */
894 RAW_SFILEINFO_SEC_DESC, /* NT_TRANSACT_SET_SECURITY_DESC */
895 RAW_SFILEINFO_STANDARD = SMB_SFILEINFO_STANDARD,
896 RAW_SFILEINFO_EA_SET = SMB_SFILEINFO_EA_SET,
897 RAW_SFILEINFO_BASIC_INFO = SMB_SFILEINFO_BASIC_INFO,
898 RAW_SFILEINFO_DISPOSITION_INFO = SMB_SFILEINFO_DISPOSITION_INFO,
899 RAW_SFILEINFO_ALLOCATION_INFO = SMB_SFILEINFO_ALLOCATION_INFO,
900 RAW_SFILEINFO_END_OF_FILE_INFO = SMB_SFILEINFO_END_OF_FILE_INFO,
901 RAW_SFILEINFO_UNIX_BASIC = SMB_SFILEINFO_UNIX_BASIC,
902 RAW_SFILEINFO_UNIX_INFO2 = SMB_SFILEINFO_UNIX_INFO2,
903 RAW_SFILEINFO_UNIX_LINK = SMB_SFILEINFO_UNIX_LINK,
904 RAW_SFILEINFO_UNIX_HLINK = SMB_SFILEINFO_UNIX_HLINK,
905 RAW_SFILEINFO_BASIC_INFORMATION = SMB_SFILEINFO_BASIC_INFORMATION,
906 RAW_SFILEINFO_RENAME_INFORMATION = SMB_SFILEINFO_RENAME_INFORMATION,
907 RAW_SFILEINFO_LINK_INFORMATION = SMB_SFILEINFO_LINK_INFORMATION,
908 RAW_SFILEINFO_DISPOSITION_INFORMATION = SMB_SFILEINFO_DISPOSITION_INFORMATION,
909 RAW_SFILEINFO_POSITION_INFORMATION = SMB_SFILEINFO_POSITION_INFORMATION,
910 RAW_SFILEINFO_FULL_EA_INFORMATION = SMB_SFILEINFO_FULL_EA_INFORMATION,
911 RAW_SFILEINFO_MODE_INFORMATION = SMB_SFILEINFO_MODE_INFORMATION,
912 RAW_SFILEINFO_ALLOCATION_INFORMATION = SMB_SFILEINFO_ALLOCATION_INFORMATION,
913 RAW_SFILEINFO_END_OF_FILE_INFORMATION = SMB_SFILEINFO_END_OF_FILE_INFORMATION,
914 RAW_SFILEINFO_PIPE_INFORMATION = SMB_SFILEINFO_PIPE_INFORMATION,
915 RAW_SFILEINFO_VALID_DATA_INFORMATION = SMB_SFILEINFO_VALID_DATA_INFORMATION,
916 RAW_SFILEINFO_SHORT_NAME_INFORMATION = SMB_SFILEINFO_SHORT_NAME_INFORMATION,
917 RAW_SFILEINFO_1025 = SMB_SFILEINFO_1025,
918 RAW_SFILEINFO_1027 = SMB_SFILEINFO_1027,
919 RAW_SFILEINFO_1029 = SMB_SFILEINFO_1029,
920 RAW_SFILEINFO_1030 = SMB_SFILEINFO_1030,
921 RAW_SFILEINFO_1031 = SMB_SFILEINFO_1031,
922 RAW_SFILEINFO_1032 = SMB_SFILEINFO_1032,
923 RAW_SFILEINFO_1036 = SMB_SFILEINFO_1036,
924 RAW_SFILEINFO_1041 = SMB_SFILEINFO_1041,
925 RAW_SFILEINFO_1042 = SMB_SFILEINFO_1042,
926 RAW_SFILEINFO_1043 = SMB_SFILEINFO_1043,
927 RAW_SFILEINFO_1044 = SMB_SFILEINFO_1044,
929 /* cope with breakage in SMB2 */
930 RAW_SFILEINFO_RENAME_INFORMATION_SMB2 = SMB_SFILEINFO_RENAME_INFORMATION|0x80000000,
933 /* union used in setfileinfo() and setpathinfo() calls */
934 union smb_setfileinfo {
935 /* generic interface */
936 struct {
937 enum smb_setfileinfo_level level;
938 struct {
939 union smb_handle_or_path file;
940 } in;
941 } generic;
943 /* RAW_SFILEINFO_SETATTR (SMBsetatr) interface - only via setpathinfo() */
944 struct {
945 enum smb_setfileinfo_level level;
946 struct {
947 union smb_handle_or_path file;
948 uint16_t attrib;
949 time_t write_time;
950 } in;
951 } setattr;
953 /* RAW_SFILEINFO_SETATTRE (SMBsetattrE) interface - only via setfileinfo()
954 also RAW_SFILEINFO_STANDARD */
955 struct {
956 enum smb_setfileinfo_level level;
957 struct {
958 union smb_handle_or_path file;
959 time_t create_time;
960 time_t access_time;
961 time_t write_time;
962 /* notice that size, alloc_size and attrib are not settable,
963 unlike the corresponding qfileinfo level */
964 } in;
965 } setattre, standard;
967 /* RAW_SFILEINFO_EA_SET interface */
968 struct {
969 enum smb_setfileinfo_level level;
970 struct {
971 union smb_handle_or_path file;
972 uint_t num_eas;
973 struct ea_struct *eas;
974 } in;
975 } ea_set;
977 /* RAW_SFILEINFO_BASIC_INFO and
978 RAW_SFILEINFO_BASIC_INFORMATION interfaces */
979 struct {
980 enum smb_setfileinfo_level level;
981 struct {
982 union smb_handle_or_path file;
983 NTTIME create_time;
984 NTTIME access_time;
985 NTTIME write_time;
986 NTTIME change_time;
987 uint32_t attrib;
988 uint32_t reserved;
989 } in;
990 } basic_info;
992 /* RAW_SFILEINFO_DISPOSITION_INFO and
993 RAW_SFILEINFO_DISPOSITION_INFORMATION interfaces */
994 struct {
995 enum smb_setfileinfo_level level;
996 struct {
997 union smb_handle_or_path file;
998 bool delete_on_close;
999 } in;
1000 } disposition_info;
1002 /* RAW_SFILEINFO_ALLOCATION_INFO and
1003 RAW_SFILEINFO_ALLOCATION_INFORMATION interfaces */
1004 struct {
1005 enum smb_setfileinfo_level level;
1006 struct {
1007 union smb_handle_or_path file;
1008 /* w2k3 rounds this up to nearest 4096 */
1009 uint64_t alloc_size;
1010 } in;
1011 } allocation_info;
1013 /* RAW_SFILEINFO_END_OF_FILE_INFO and
1014 RAW_SFILEINFO_END_OF_FILE_INFORMATION interfaces */
1015 struct {
1016 enum smb_setfileinfo_level level;
1017 struct {
1018 union smb_handle_or_path file;
1019 uint64_t size;
1020 } in;
1021 } end_of_file_info;
1023 /* RAW_SFILEINFO_RENAME_INFORMATION interface */
1024 struct {
1025 enum smb_setfileinfo_level level;
1026 struct {
1027 union smb_handle_or_path file;
1028 uint8_t overwrite;
1029 uint64_t root_fid;
1030 const char *new_name;
1031 } in;
1032 } rename_information;
1034 /* RAW_SFILEINFO_LINK_INFORMATION interface */
1035 struct {
1036 enum smb_setfileinfo_level level;
1037 struct {
1038 union smb_handle_or_path file;
1039 uint8_t overwrite;
1040 uint64_t root_fid;
1041 const char *new_name;
1042 } in;
1043 } link_information;
1045 /* RAW_SFILEINFO_POSITION_INFORMATION interface */
1046 struct {
1047 enum smb_setfileinfo_level level;
1048 struct {
1049 union smb_handle_or_path file;
1050 uint64_t position;
1051 } in;
1052 } position_information;
1054 /* RAW_SFILEINFO_MODE_INFORMATION interface */
1055 struct {
1056 enum smb_setfileinfo_level level;
1057 struct {
1058 union smb_handle_or_path file;
1059 /* valid values seem to be 0, 2, 4 and 6 */
1060 uint32_t mode;
1061 } in;
1062 } mode_information;
1064 /* RAW_SFILEINFO_UNIX_BASIC interface */
1065 struct {
1066 enum smb_setfileinfo_level level;
1067 struct {
1068 union smb_handle_or_path file;
1069 uint32_t mode; /* yuck - this field remains to fix compile of libcli/clifile.c */
1070 uint64_t end_of_file;
1071 uint64_t num_bytes;
1072 NTTIME status_change_time;
1073 NTTIME access_time;
1074 NTTIME change_time;
1075 uint64_t uid;
1076 uint64_t gid;
1077 uint32_t file_type;
1078 uint64_t dev_major;
1079 uint64_t dev_minor;
1080 uint64_t unique_id;
1081 uint64_t permissions;
1082 uint64_t nlink;
1083 } in;
1084 } unix_basic;
1086 /* RAW_SFILEINFO_UNIX_INFO2 interface */
1087 struct {
1088 enum smb_setfileinfo_level level;
1089 struct {
1090 union smb_handle_or_path file;
1091 uint64_t end_of_file;
1092 uint64_t num_bytes;
1093 NTTIME status_change_time;
1094 NTTIME access_time;
1095 NTTIME change_time;
1096 uint64_t uid;
1097 uint64_t gid;
1098 uint32_t file_type;
1099 uint64_t dev_major;
1100 uint64_t dev_minor;
1101 uint64_t unique_id;
1102 uint64_t permissions;
1103 uint64_t nlink;
1104 NTTIME create_time;
1105 uint32_t file_flags;
1106 uint32_t flags_mask;
1107 } in;
1108 } unix_info2;
1110 /* RAW_SFILEINFO_UNIX_LINK, RAW_SFILEINFO_UNIX_HLINK interface */
1111 struct {
1112 enum smb_setfileinfo_level level;
1113 struct {
1114 union smb_handle_or_path file;
1115 const char *link_dest;
1116 } in;
1117 } unix_link, unix_hlink;
1119 /* RAW_FILEINFO_SET_SEC_DESC */
1120 struct {
1121 enum smb_setfileinfo_level level;
1122 struct {
1123 union smb_handle_or_path file;
1124 uint32_t secinfo_flags;
1125 struct security_descriptor *sd;
1126 } in;
1127 } set_secdesc;
1129 /* RAW_SFILEINFO_FULL_EA_INFORMATION */
1130 struct {
1131 enum smb_setfileinfo_level level;
1132 struct {
1133 union smb_handle_or_path file;
1134 struct smb_ea_list eas;
1135 } in;
1136 } full_ea_information;
1140 enum smb_fsinfo_level {
1141 RAW_QFS_GENERIC = 0xF000,
1142 RAW_QFS_DSKATTR, /* SMBdskattr */
1143 RAW_QFS_ALLOCATION = SMB_QFS_ALLOCATION,
1144 RAW_QFS_VOLUME = SMB_QFS_VOLUME,
1145 RAW_QFS_VOLUME_INFO = SMB_QFS_VOLUME_INFO,
1146 RAW_QFS_SIZE_INFO = SMB_QFS_SIZE_INFO,
1147 RAW_QFS_DEVICE_INFO = SMB_QFS_DEVICE_INFO,
1148 RAW_QFS_ATTRIBUTE_INFO = SMB_QFS_ATTRIBUTE_INFO,
1149 RAW_QFS_UNIX_INFO = SMB_QFS_UNIX_INFO,
1150 RAW_QFS_PROXY_INFO = SMB_QFS_PROXY_INFO,
1151 RAW_QFS_VOLUME_INFORMATION = SMB_QFS_VOLUME_INFORMATION,
1152 RAW_QFS_SIZE_INFORMATION = SMB_QFS_SIZE_INFORMATION,
1153 RAW_QFS_DEVICE_INFORMATION = SMB_QFS_DEVICE_INFORMATION,
1154 RAW_QFS_ATTRIBUTE_INFORMATION = SMB_QFS_ATTRIBUTE_INFORMATION,
1155 RAW_QFS_QUOTA_INFORMATION = SMB_QFS_QUOTA_INFORMATION,
1156 RAW_QFS_FULL_SIZE_INFORMATION = SMB_QFS_FULL_SIZE_INFORMATION,
1157 RAW_QFS_OBJECTID_INFORMATION = SMB_QFS_OBJECTID_INFORMATION};
1160 /* union for fsinfo() backend call. Note that there are no in
1161 structures, as this call only contains out parameters */
1162 union smb_fsinfo {
1163 /* generic interface */
1164 struct {
1165 enum smb_fsinfo_level level;
1166 struct smb2_handle handle; /* only for smb2 */
1168 struct {
1169 uint32_t block_size;
1170 uint64_t blocks_total;
1171 uint64_t blocks_free;
1172 uint32_t fs_id;
1173 NTTIME create_time;
1174 uint32_t serial_number;
1175 uint32_t fs_attr;
1176 uint32_t max_file_component_length;
1177 uint32_t device_type;
1178 uint32_t device_characteristics;
1179 uint64_t quota_soft;
1180 uint64_t quota_hard;
1181 uint64_t quota_flags;
1182 struct GUID guid;
1183 char *volume_name;
1184 char *fs_type;
1185 } out;
1186 } generic;
1188 /* SMBdskattr interface */
1189 struct {
1190 enum smb_fsinfo_level level;
1192 struct {
1193 uint16_t units_total;
1194 uint16_t blocks_per_unit;
1195 uint16_t block_size;
1196 uint16_t units_free;
1197 } out;
1198 } dskattr;
1200 /* trans2 RAW_QFS_ALLOCATION interface */
1201 struct {
1202 enum smb_fsinfo_level level;
1204 struct {
1205 uint32_t fs_id;
1206 uint32_t sectors_per_unit;
1207 uint32_t total_alloc_units;
1208 uint32_t avail_alloc_units;
1209 uint16_t bytes_per_sector;
1210 } out;
1211 } allocation;
1213 /* TRANS2 RAW_QFS_VOLUME interface */
1214 struct {
1215 enum smb_fsinfo_level level;
1217 struct {
1218 uint32_t serial_number;
1219 struct smb_wire_string volume_name;
1220 } out;
1221 } volume;
1223 /* TRANS2 RAW_QFS_VOLUME_INFO and RAW_QFS_VOLUME_INFORMATION interfaces */
1224 struct {
1225 enum smb_fsinfo_level level;
1226 struct smb2_handle handle; /* only for smb2 */
1228 struct {
1229 NTTIME create_time;
1230 uint32_t serial_number;
1231 struct smb_wire_string volume_name;
1232 } out;
1233 } volume_info;
1235 /* trans2 RAW_QFS_SIZE_INFO and RAW_QFS_SIZE_INFORMATION interfaces */
1236 struct {
1237 enum smb_fsinfo_level level;
1238 struct smb2_handle handle; /* only for smb2 */
1240 struct {
1241 uint64_t total_alloc_units;
1242 uint64_t avail_alloc_units; /* maps to call_avail_alloc_units */
1243 uint32_t sectors_per_unit;
1244 uint32_t bytes_per_sector;
1245 } out;
1246 } size_info;
1248 /* TRANS2 RAW_QFS_DEVICE_INFO and RAW_QFS_DEVICE_INFORMATION interfaces */
1249 struct {
1250 enum smb_fsinfo_level level;
1251 struct smb2_handle handle; /* only for smb2 */
1253 struct {
1254 uint32_t device_type;
1255 uint32_t characteristics;
1256 } out;
1257 } device_info;
1260 /* TRANS2 RAW_QFS_ATTRIBUTE_INFO and RAW_QFS_ATTRIBUTE_INFORMATION interfaces */
1261 struct {
1262 enum smb_fsinfo_level level;
1263 struct smb2_handle handle; /* only for smb2 */
1265 struct {
1266 uint32_t fs_attr;
1267 uint32_t max_file_component_length;
1268 struct smb_wire_string fs_type;
1269 } out;
1270 } attribute_info;
1273 /* TRANS2 RAW_QFS_UNIX_INFO interface */
1274 struct {
1275 enum smb_fsinfo_level level;
1277 struct {
1278 uint16_t major_version;
1279 uint16_t minor_version;
1280 uint64_t capability;
1281 } out;
1282 } unix_info;
1284 /* TRANS2 RAW_QFS_PROXY_INFO interface */
1285 struct {
1286 enum smb_fsinfo_level level;
1288 struct {
1289 uint16_t major_version;
1290 uint16_t minor_version;
1291 uint64_t capability;
1292 } out;
1293 } proxy_info;
1295 /* trans2 RAW_QFS_QUOTA_INFORMATION interface */
1296 struct {
1297 enum smb_fsinfo_level level;
1298 struct smb2_handle handle; /* only for smb2 */
1300 struct {
1301 uint64_t unknown[3];
1302 uint64_t quota_soft;
1303 uint64_t quota_hard;
1304 uint64_t quota_flags;
1305 } out;
1306 } quota_information;
1308 /* trans2 RAW_QFS_FULL_SIZE_INFORMATION interface */
1309 struct {
1310 enum smb_fsinfo_level level;
1311 struct smb2_handle handle; /* only for smb2 */
1313 struct {
1314 uint64_t total_alloc_units;
1315 uint64_t call_avail_alloc_units;
1316 uint64_t actual_avail_alloc_units;
1317 uint32_t sectors_per_unit;
1318 uint32_t bytes_per_sector;
1319 } out;
1320 } full_size_information;
1322 /* trans2 RAW_QFS_OBJECTID_INFORMATION interface */
1323 struct {
1324 enum smb_fsinfo_level level;
1325 struct smb2_handle handle; /* only for smb2 */
1327 struct {
1328 struct GUID guid;
1329 uint64_t unknown[6];
1330 } out;
1331 } objectid_information;
1336 enum smb_open_level {
1337 RAW_OPEN_OPEN,
1338 RAW_OPEN_OPENX,
1339 RAW_OPEN_MKNEW,
1340 RAW_OPEN_CREATE,
1341 RAW_OPEN_CTEMP,
1342 RAW_OPEN_SPLOPEN,
1343 RAW_OPEN_NTCREATEX,
1344 RAW_OPEN_T2OPEN,
1345 RAW_OPEN_NTTRANS_CREATE,
1346 RAW_OPEN_OPENX_READX,
1347 RAW_OPEN_SMB2
1350 /* the generic interface is defined to be equal to the NTCREATEX interface */
1351 #define RAW_OPEN_GENERIC RAW_OPEN_NTCREATEX
1353 /* union for open() backend call */
1354 union smb_open {
1356 * because the *.out.file structs are not aligned to the same offset for each level
1357 * we provide a hepler macro that should be used to find the current smb_handle structure
1359 #define SMB_OPEN_OUT_FILE(op, file) do { \
1360 switch (op->generic.level) { \
1361 case RAW_OPEN_OPEN: \
1362 file = &op->openold.out.file; \
1363 break; \
1364 case RAW_OPEN_OPENX: \
1365 file = &op->openx.out.file; \
1366 break; \
1367 case RAW_OPEN_MKNEW: \
1368 file = &op->mknew.out.file; \
1369 break; \
1370 case RAW_OPEN_CREATE: \
1371 file = &op->create.out.file; \
1372 break; \
1373 case RAW_OPEN_CTEMP: \
1374 file = &op->ctemp.out.file; \
1375 break; \
1376 case RAW_OPEN_SPLOPEN: \
1377 file = &op->splopen.out.file; \
1378 break; \
1379 case RAW_OPEN_NTCREATEX: \
1380 file = &op->ntcreatex.out.file; \
1381 break; \
1382 case RAW_OPEN_T2OPEN: \
1383 file = &op->t2open.out.file; \
1384 break; \
1385 case RAW_OPEN_NTTRANS_CREATE: \
1386 file = &op->nttrans.out.file; \
1387 break; \
1388 case RAW_OPEN_OPENX_READX: \
1389 file = &op->openxreadx.out.file; \
1390 break; \
1391 case RAW_OPEN_SMB2: \
1392 file = &op->smb2.out.file; \
1393 break; \
1394 default: \
1395 /* this must be a programmer error */ \
1396 file = NULL; \
1397 break; \
1399 } while (0)
1400 /* SMBNTCreateX, nttrans and generic interface */
1401 struct {
1402 enum smb_open_level level;
1403 struct {
1404 uint32_t flags;
1405 uint32_t root_fid;
1406 uint32_t access_mask;
1407 uint64_t alloc_size;
1408 uint32_t file_attr;
1409 uint32_t share_access;
1410 uint32_t open_disposition;
1411 uint32_t create_options;
1412 uint32_t impersonation;
1413 uint8_t security_flags;
1414 /* NOTE: fname can also be a pointer to a
1415 uint64_t file_id if create_options has the
1416 NTCREATEX_OPTIONS_OPEN_BY_FILE_ID flag set */
1417 const char *fname;
1419 /* these last 2 elements are only used in the
1420 NTTRANS varient of the call */
1421 struct security_descriptor *sec_desc;
1422 struct smb_ea_list *ea_list;
1424 /* some optional parameters from the SMB2 varient */
1425 bool query_maximal_access;
1426 } in;
1427 struct {
1428 union smb_handle file;
1429 uint8_t oplock_level;
1430 uint32_t create_action;
1431 NTTIME create_time;
1432 NTTIME access_time;
1433 NTTIME write_time;
1434 NTTIME change_time;
1435 uint32_t attrib;
1436 uint64_t alloc_size;
1437 uint64_t size;
1438 uint16_t file_type;
1439 uint16_t ipc_state;
1440 uint8_t is_directory;
1442 /* optional return values matching SMB2 tagged
1443 values in the call */
1444 uint32_t maximal_access;
1445 } out;
1446 } ntcreatex, nttrans, generic;
1448 /* TRANS2_OPEN interface */
1449 struct {
1450 enum smb_open_level level;
1451 struct {
1452 uint16_t flags;
1453 uint16_t open_mode;
1454 uint16_t search_attrs;
1455 uint16_t file_attrs;
1456 time_t write_time;
1457 uint16_t open_func;
1458 uint32_t size;
1459 uint32_t timeout;
1460 const char *fname;
1461 uint_t num_eas;
1462 struct ea_struct *eas;
1463 } in;
1464 struct {
1465 union smb_handle file;
1466 uint16_t attrib;
1467 time_t write_time;
1468 uint32_t size;
1469 uint16_t access;
1470 uint16_t ftype;
1471 uint16_t devstate;
1472 uint16_t action;
1473 uint32_t file_id;
1474 } out;
1475 } t2open;
1477 /* SMBopen interface */
1478 struct {
1479 enum smb_open_level level;
1480 struct {
1481 uint16_t open_mode;
1482 uint16_t search_attrs;
1483 const char *fname;
1484 } in;
1485 struct {
1486 union smb_handle file;
1487 uint16_t attrib;
1488 time_t write_time;
1489 uint32_t size;
1490 uint16_t rmode;
1491 } out;
1492 } openold;
1494 /* SMBopenX interface */
1495 struct {
1496 enum smb_open_level level;
1497 struct {
1498 uint16_t flags;
1499 uint16_t open_mode;
1500 uint16_t search_attrs; /* not honoured by win2003 */
1501 uint16_t file_attrs;
1502 time_t write_time; /* not honoured by win2003 */
1503 uint16_t open_func;
1504 uint32_t size; /* note that this sets the
1505 initial file size, not
1506 just allocation size */
1507 uint32_t timeout; /* not honoured by win2003 */
1508 const char *fname;
1509 } in;
1510 struct {
1511 union smb_handle file;
1512 uint16_t attrib;
1513 time_t write_time;
1514 uint32_t size;
1515 uint16_t access;
1516 uint16_t ftype;
1517 uint16_t devstate;
1518 uint16_t action;
1519 uint32_t unique_fid;
1520 uint32_t access_mask;
1521 uint32_t unknown;
1522 } out;
1523 } openx;
1525 /* SMBmknew interface */
1526 struct {
1527 enum smb_open_level level;
1528 struct {
1529 uint16_t attrib;
1530 time_t write_time;
1531 const char *fname;
1532 } in;
1533 struct {
1534 union smb_handle file;
1535 } out;
1536 } mknew, create;
1538 /* SMBctemp interface */
1539 struct {
1540 enum smb_open_level level;
1541 struct {
1542 uint16_t attrib;
1543 time_t write_time;
1544 const char *directory;
1545 } in;
1546 struct {
1547 union smb_handle file;
1548 /* temp name, relative to directory */
1549 char *name;
1550 } out;
1551 } ctemp;
1553 /* SMBsplopen interface */
1554 struct {
1555 enum smb_open_level level;
1556 struct {
1557 uint16_t setup_length;
1558 uint16_t mode;
1559 const char *ident;
1560 } in;
1561 struct {
1562 union smb_handle file;
1563 } out;
1564 } splopen;
1567 /* chained OpenX/ReadX interface */
1568 struct {
1569 enum smb_open_level level;
1570 struct {
1571 uint16_t flags;
1572 uint16_t open_mode;
1573 uint16_t search_attrs; /* not honoured by win2003 */
1574 uint16_t file_attrs;
1575 time_t write_time; /* not honoured by win2003 */
1576 uint16_t open_func;
1577 uint32_t size; /* note that this sets the
1578 initial file size, not
1579 just allocation size */
1580 uint32_t timeout; /* not honoured by win2003 */
1581 const char *fname;
1583 /* readx part */
1584 uint64_t offset;
1585 uint16_t mincnt;
1586 uint32_t maxcnt;
1587 uint16_t remaining;
1588 } in;
1589 struct {
1590 union smb_handle file;
1591 uint16_t attrib;
1592 time_t write_time;
1593 uint32_t size;
1594 uint16_t access;
1595 uint16_t ftype;
1596 uint16_t devstate;
1597 uint16_t action;
1598 uint32_t unique_fid;
1599 uint32_t access_mask;
1600 uint32_t unknown;
1602 /* readx part */
1603 uint8_t *data;
1604 uint16_t remaining;
1605 uint16_t compaction_mode;
1606 uint16_t nread;
1607 } out;
1608 } openxreadx;
1610 #define SMB2_CREATE_FLAG_REQUEST_OPLOCK 0x0100
1611 #define SMB2_CREATE_FLAG_REQUEST_EXCLUSIVE_OPLOCK 0x0800
1612 #define SMB2_CREATE_FLAG_GRANT_OPLOCK 0x0001
1613 #define SMB2_CREATE_FLAG_GRANT_EXCLUSIVE_OPLOCK 0x0080
1615 /* SMB2 Create */
1616 struct smb2_create {
1617 enum smb_open_level level;
1618 struct {
1619 /* static body buffer 56 (0x38) bytes */
1620 uint8_t security_flags; /* SMB2_SECURITY_* */
1621 uint8_t oplock_level; /* SMB2_OPLOCK_LEVEL_* */
1622 uint32_t impersonation_level; /* SMB2_IMPERSONATION_* */
1623 uint64_t create_flags;
1624 uint64_t reserved;
1625 uint32_t desired_access;
1626 uint32_t file_attributes;
1627 uint32_t share_access; /* NTCREATEX_SHARE_ACCESS_* */
1628 uint32_t create_disposition; /* NTCREATEX_DISP_* */
1629 uint32_t create_options; /* NTCREATEX_OPTIONS_* */
1631 /* uint16_t fname_ofs */
1632 /* uint16_t fname_size */
1633 /* uint32_t blob_ofs; */
1634 /* uint32_t blob_size; */
1636 /* dynamic body */
1637 const char *fname;
1639 /* now some optional parameters - encoded as tagged blobs */
1640 struct smb_ea_list eas;
1641 uint64_t alloc_size;
1642 struct security_descriptor *sec_desc;
1643 bool durable_open;
1644 struct smb2_handle *durable_handle;
1645 bool query_maximal_access;
1646 NTTIME timewarp;
1647 bool query_on_disk_id;
1649 /* and any additional blobs the caller wants */
1650 struct smb2_create_blobs {
1651 uint32_t num_blobs;
1652 struct smb2_create_blob {
1653 const char *tag;
1654 DATA_BLOB data;
1655 } *blobs;
1656 } blobs;
1657 } in;
1658 struct {
1659 union smb_handle file;
1661 /* static body buffer 88 (0x58) bytes */
1662 /* uint16_t buffer_code; 0x59 = 0x58 + 1 */
1663 uint8_t oplock_level;
1664 uint8_t reserved;
1665 uint32_t create_action;
1666 NTTIME create_time;
1667 NTTIME access_time;
1668 NTTIME write_time;
1669 NTTIME change_time;
1670 uint64_t alloc_size;
1671 uint64_t size;
1672 uint32_t file_attr;
1673 uint32_t reserved2;
1674 /* struct smb2_handle handle;*/
1675 /* uint32_t blob_ofs; */
1676 /* uint32_t blob_size; */
1678 /* optional return values matching tagged values in the call */
1679 uint32_t maximal_access;
1680 uint8_t on_disk_id[32];
1682 /* tagged blobs in the reply */
1683 struct smb2_create_blobs blobs;
1684 } out;
1685 } smb2;
1690 enum smb_read_level {
1691 RAW_READ_READBRAW,
1692 RAW_READ_LOCKREAD,
1693 RAW_READ_READ,
1694 RAW_READ_READX,
1695 RAW_READ_SMB2
1698 #define RAW_READ_GENERIC RAW_READ_READX
1700 /* union for read() backend call
1702 note that .infoX.out.data will be allocated before the backend is
1703 called. It will be big enough to hold the maximum size asked for
1705 union smb_read {
1706 /* SMBreadX (and generic) interface */
1707 struct {
1708 enum smb_read_level level;
1709 struct {
1710 union smb_handle file;
1711 uint64_t offset;
1712 uint32_t mincnt; /* enforced on SMB2, 16 bit on SMB */
1713 uint32_t maxcnt;
1714 uint16_t remaining;
1715 bool read_for_execute;
1716 } in;
1717 struct {
1718 uint8_t *data;
1719 uint16_t remaining;
1720 uint16_t compaction_mode;
1721 uint32_t nread;
1722 } out;
1723 } readx, generic;
1725 /* SMBreadbraw interface */
1726 struct {
1727 enum smb_read_level level;
1728 struct {
1729 union smb_handle file;
1730 uint64_t offset;
1731 uint16_t maxcnt;
1732 uint16_t mincnt;
1733 uint32_t timeout;
1734 } in;
1735 struct {
1736 uint8_t *data;
1737 uint32_t nread;
1738 } out;
1739 } readbraw;
1742 /* SMBlockandread interface */
1743 struct {
1744 enum smb_read_level level;
1745 struct {
1746 union smb_handle file;
1747 uint16_t count;
1748 uint32_t offset;
1749 uint16_t remaining;
1750 } in;
1751 struct {
1752 uint8_t *data;
1753 uint16_t nread;
1754 } out;
1755 } lockread;
1757 /* SMBread interface */
1758 struct {
1759 enum smb_read_level level;
1760 struct {
1761 union smb_handle file;
1762 uint16_t count;
1763 uint32_t offset;
1764 uint16_t remaining;
1765 } in;
1766 struct {
1767 uint8_t *data;
1768 uint16_t nread;
1769 } out;
1770 } read;
1772 /* SMB2 Read */
1773 struct smb2_read {
1774 enum smb_read_level level;
1775 struct {
1776 union smb_handle file;
1778 /* static body buffer 48 (0x30) bytes */
1779 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
1780 uint8_t _pad;
1781 uint8_t reserved;
1782 uint32_t length;
1783 uint64_t offset;
1784 /* struct smb2_handle handle; */
1785 uint32_t min_count;
1786 uint32_t channel;
1787 uint32_t remaining;
1788 /* the docs give no indication of what
1789 these channel variables are for */
1790 uint16_t channel_offset;
1791 uint16_t channel_length;
1792 } in;
1793 struct {
1794 /* static body buffer 16 (0x10) bytes */
1795 /* uint16_t buffer_code; 0x11 = 0x10 + 1 */
1796 /* uint8_t data_ofs; */
1797 /* uint8_t reserved; */
1798 /* uint32_t data_size; */
1799 uint32_t remaining;
1800 uint32_t reserved;
1802 /* dynamic body */
1803 DATA_BLOB data;
1804 } out;
1805 } smb2;
1809 enum smb_write_level {
1810 RAW_WRITE_WRITEUNLOCK,
1811 RAW_WRITE_WRITE,
1812 RAW_WRITE_WRITEX,
1813 RAW_WRITE_WRITECLOSE,
1814 RAW_WRITE_SPLWRITE,
1815 RAW_WRITE_SMB2
1818 #define RAW_WRITE_GENERIC RAW_WRITE_WRITEX
1820 /* union for write() backend call
1822 union smb_write {
1823 /* SMBwriteX interface */
1824 struct {
1825 enum smb_write_level level;
1826 struct {
1827 union smb_handle file;
1828 uint64_t offset;
1829 uint16_t wmode;
1830 uint16_t remaining;
1831 uint32_t count;
1832 const uint8_t *data;
1833 } in;
1834 struct {
1835 uint32_t nwritten;
1836 uint16_t remaining;
1837 } out;
1838 } writex, generic;
1840 /* SMBwriteunlock interface */
1841 struct {
1842 enum smb_write_level level;
1843 struct {
1844 union smb_handle file;
1845 uint16_t count;
1846 uint32_t offset;
1847 uint16_t remaining;
1848 const uint8_t *data;
1849 } in;
1850 struct {
1851 uint32_t nwritten;
1852 } out;
1853 } writeunlock;
1855 /* SMBwrite interface */
1856 struct {
1857 enum smb_write_level level;
1858 struct {
1859 union smb_handle file;
1860 uint16_t count;
1861 uint32_t offset;
1862 uint16_t remaining;
1863 const uint8_t *data;
1864 } in;
1865 struct {
1866 uint16_t nwritten;
1867 } out;
1868 } write;
1870 /* SMBwriteclose interface */
1871 struct {
1872 enum smb_write_level level;
1873 struct {
1874 union smb_handle file;
1875 uint16_t count;
1876 uint32_t offset;
1877 time_t mtime;
1878 const uint8_t *data;
1879 } in;
1880 struct {
1881 uint16_t nwritten;
1882 } out;
1883 } writeclose;
1885 /* SMBsplwrite interface */
1886 struct {
1887 enum smb_write_level level;
1888 struct {
1889 union smb_handle file;
1890 uint16_t count;
1891 const uint8_t *data;
1892 } in;
1893 } splwrite;
1895 /* SMB2 Write */
1896 struct smb2_write {
1897 enum smb_write_level level;
1898 struct {
1899 union smb_handle file;
1901 /* static body buffer 48 (0x30) bytes */
1902 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
1903 /* uint16_t data_ofs; */
1904 /* uint32_t data_size; */
1905 uint64_t offset;
1906 /* struct smb2_handle handle; */
1907 uint64_t unknown1; /* 0xFFFFFFFFFFFFFFFF */
1908 uint64_t unknown2; /* 0xFFFFFFFFFFFFFFFF */
1910 /* dynamic body */
1911 DATA_BLOB data;
1912 } in;
1913 struct {
1914 /* static body buffer 17 (0x11) bytes */
1915 /* uint16_t buffer_code; 0x11 = 0x10 + 1*/
1916 uint16_t _pad;
1917 uint32_t nwritten;
1918 uint64_t unknown1; /* 0x0000000000000000 */
1919 } out;
1920 } smb2;
1924 enum smb_lock_level {
1925 RAW_LOCK_LOCK,
1926 RAW_LOCK_UNLOCK,
1927 RAW_LOCK_LOCKX,
1928 RAW_LOCK_SMB2,
1929 RAW_LOCK_SMB2_BREAK
1932 #define RAW_LOCK_GENERIC RAW_LOCK_LOCKX
1934 /* union for lock() backend call
1936 union smb_lock {
1937 /* SMBlockingX and generic interface */
1938 struct {
1939 enum smb_lock_level level;
1940 struct {
1941 union smb_handle file;
1942 uint16_t mode;
1943 uint32_t timeout;
1944 uint16_t ulock_cnt;
1945 uint16_t lock_cnt;
1946 struct smb_lock_entry {
1947 uint32_t pid; /* 16 bits in SMB1 */
1948 uint64_t offset;
1949 uint64_t count;
1950 } *locks; /* unlocks are first in the arrray */
1951 } in;
1952 } generic, lockx;
1954 /* SMBlock and SMBunlock interface */
1955 struct {
1956 enum smb_lock_level level;
1957 struct {
1958 union smb_handle file;
1959 uint32_t count;
1960 uint32_t offset;
1961 } in;
1962 } lock, unlock;
1964 /* SMB2 Lock */
1965 struct smb2_lock {
1966 enum smb_lock_level level;
1967 struct {
1968 union smb_handle file;
1970 /* static body buffer 48 (0x30) bytes */
1971 /* uint16_t buffer_code; 0x30 */
1972 uint16_t lock_count;
1973 uint32_t reserved;
1974 /* struct smb2_handle handle; */
1975 struct smb2_lock_element {
1976 uint64_t offset;
1977 uint64_t length;
1978 /* these flags are the same as the SMB2 lock flags */
1979 #define SMB2_LOCK_FLAG_NONE 0x00000000
1980 #define SMB2_LOCK_FLAG_SHARED 0x00000001
1981 #define SMB2_LOCK_FLAG_EXCLUSIVE 0x00000002
1982 #define SMB2_LOCK_FLAG_UNLOCK 0x00000004
1983 #define SMB2_LOCK_FLAG_FAIL_IMMEDIATELY 0x00000010
1984 #define SMB2_LOCK_FLAG_ALL_MASK 0x00000017
1985 uint32_t flags;
1986 uint32_t reserved;
1987 } *locks;
1988 } in;
1989 struct {
1990 /* static body buffer 4 (0x04) bytes */
1991 /* uint16_t buffer_code; 0x04 */
1992 uint16_t reserved;
1993 } out;
1994 } smb2;
1996 /* SMB2 Break */
1997 struct smb2_break {
1998 enum smb_lock_level level;
1999 struct {
2000 union smb_handle file;
2002 /* static body buffer 24 (0x18) bytes */
2003 uint8_t oplock_level;
2004 uint8_t reserved;
2005 uint32_t reserved2;
2006 /* struct smb2_handle handle; */
2007 } in, out;
2008 } smb2_break;
2012 enum smb_close_level {
2013 RAW_CLOSE_CLOSE,
2014 RAW_CLOSE_SPLCLOSE,
2015 RAW_CLOSE_SMB2,
2016 RAW_CLOSE_GENERIC,
2020 union for close() backend call
2022 union smb_close {
2023 /* generic interface */
2024 struct {
2025 enum smb_close_level level;
2026 struct {
2027 union smb_handle file;
2028 time_t write_time;
2029 #define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
2030 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
2031 } in;
2032 struct {
2033 uint16_t flags;
2034 NTTIME create_time;
2035 NTTIME access_time;
2036 NTTIME write_time;
2037 NTTIME change_time;
2038 uint64_t alloc_size;
2039 uint64_t size;
2040 uint32_t file_attr;
2041 } out;
2042 } generic;
2044 /* SMBclose interface */
2045 struct {
2046 enum smb_close_level level;
2047 struct {
2048 union smb_handle file;
2049 time_t write_time;
2050 } in;
2051 } close;
2053 /* SMBsplclose interface - empty! */
2054 struct {
2055 enum smb_close_level level;
2056 struct {
2057 union smb_handle file;
2058 } in;
2059 } splclose;
2061 /* SMB2 Close */
2062 struct smb2_close {
2063 enum smb_close_level level;
2064 struct {
2065 union smb_handle file;
2067 /* static body buffer 24 (0x18) bytes */
2068 /* uint16_t buffer_code; 0x18 */
2069 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
2070 uint32_t _pad;
2071 } in;
2072 struct {
2073 /* static body buffer 60 (0x3C) bytes */
2074 /* uint16_t buffer_code; 0x3C */
2075 uint16_t flags;
2076 uint32_t _pad;
2077 NTTIME create_time;
2078 NTTIME access_time;
2079 NTTIME write_time;
2080 NTTIME change_time;
2081 uint64_t alloc_size;
2082 uint64_t size;
2083 uint32_t file_attr;
2084 } out;
2085 } smb2;
2089 enum smb_lpq_level {RAW_LPQ_GENERIC, RAW_LPQ_RETQ};
2092 union for lpq() backend
2094 union smb_lpq {
2095 /* generic interface */
2096 struct {
2097 enum smb_lpq_level level;
2099 } generic;
2102 /* SMBsplretq interface */
2103 struct {
2104 enum smb_lpq_level level;
2106 struct {
2107 uint16_t maxcount;
2108 uint16_t startidx;
2109 } in;
2110 struct {
2111 uint16_t count;
2112 uint16_t restart_idx;
2113 struct {
2114 time_t time;
2115 uint8_t status;
2116 uint16_t job;
2117 uint32_t size;
2118 char *user;
2119 } *queue;
2120 } out;
2121 } retq;
2124 enum smb_ioctl_level {
2125 RAW_IOCTL_IOCTL,
2126 RAW_IOCTL_NTIOCTL,
2127 RAW_IOCTL_SMB2,
2128 RAW_IOCTL_SMB2_NO_HANDLE
2132 union for ioctl() backend
2134 union smb_ioctl {
2135 /* generic interface */
2136 struct {
2137 enum smb_ioctl_level level;
2138 struct {
2139 union smb_handle file;
2140 } in;
2141 } generic;
2143 /* struct for SMBioctl */
2144 struct {
2145 enum smb_ioctl_level level;
2146 struct {
2147 union smb_handle file;
2148 uint32_t request;
2149 } in;
2150 struct {
2151 DATA_BLOB blob;
2152 } out;
2153 } ioctl;
2156 /* struct for NT ioctl call */
2157 struct {
2158 enum smb_ioctl_level level;
2159 struct {
2160 union smb_handle file;
2161 uint32_t function;
2162 bool fsctl;
2163 uint8_t filter;
2164 uint32_t max_data;
2165 DATA_BLOB blob;
2166 } in;
2167 struct {
2168 DATA_BLOB blob;
2169 } out;
2170 } ntioctl;
2172 /* SMB2 Ioctl */
2173 struct smb2_ioctl {
2174 enum smb_ioctl_level level;
2175 struct {
2176 union smb_handle file;
2178 /* static body buffer 56 (0x38) bytes */
2179 /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
2180 uint16_t _pad;
2181 uint32_t function;
2182 /*struct smb2_handle handle;*/
2183 /* uint32_t out_ofs; */
2184 /* uint32_t out_size; */
2185 uint32_t unknown2;
2186 /* uint32_t in_ofs; */
2187 /* uint32_t in_size; */
2188 uint32_t max_response_size;
2189 uint64_t flags;
2191 /* dynamic body */
2192 DATA_BLOB out;
2193 DATA_BLOB in;
2194 } in;
2195 struct {
2196 union smb_handle file;
2198 /* static body buffer 48 (0x30) bytes */
2199 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
2200 uint16_t _pad;
2201 uint32_t function;
2202 /* struct smb2_handle handle; */
2203 /* uint32_t in_ofs; */
2204 /* uint32_t in_size; */
2205 /* uint32_t out_ofs; */
2206 /* uint32_t out_size; */
2207 uint32_t unknown2;
2208 uint32_t unknown3;
2210 /* dynamic body */
2211 DATA_BLOB in;
2212 DATA_BLOB out;
2213 } out;
2214 } smb2;
2217 enum smb_flush_level {
2218 RAW_FLUSH_FLUSH,
2219 RAW_FLUSH_ALL,
2220 RAW_FLUSH_SMB2
2223 union smb_flush {
2224 /* struct for SMBflush */
2225 struct {
2226 enum smb_flush_level level;
2227 struct {
2228 union smb_handle file;
2229 } in;
2230 } flush, generic;
2232 /* SMBflush with 0xFFFF wildcard fnum */
2233 struct {
2234 enum smb_flush_level level;
2235 } flush_all;
2237 /* SMB2 Flush */
2238 struct smb2_flush {
2239 enum smb_flush_level level;
2240 struct {
2241 union smb_handle file;
2242 uint16_t reserved1;
2243 uint32_t reserved2;
2244 } in;
2245 struct {
2246 uint16_t reserved;
2247 } out;
2248 } smb2;
2251 /* struct for SMBcopy */
2252 struct smb_copy {
2253 struct {
2254 uint16_t tid2;
2255 uint16_t ofun;
2256 uint16_t flags;
2257 const char *path1;
2258 const char *path2;
2259 } in;
2260 struct {
2261 uint16_t count;
2262 } out;
2266 /* struct for transact/transact2 call */
2267 struct smb_trans2 {
2268 struct {
2269 uint16_t max_param;
2270 uint16_t max_data;
2271 uint8_t max_setup;
2272 uint16_t flags;
2273 uint32_t timeout;
2274 uint8_t setup_count;
2275 uint16_t *setup;
2276 const char *trans_name; /* SMBtrans only */
2277 DATA_BLOB params;
2278 DATA_BLOB data;
2279 } in;
2281 struct {
2282 uint8_t setup_count;
2283 uint16_t *setup;
2284 DATA_BLOB params;
2285 DATA_BLOB data;
2286 } out;
2289 /* struct for nttransact2 call */
2290 struct smb_nttrans {
2291 struct {
2292 uint8_t max_setup;
2293 uint32_t max_param;
2294 uint32_t max_data;
2295 uint8_t setup_count;
2296 uint16_t function;
2297 uint8_t *setup;
2298 DATA_BLOB params;
2299 DATA_BLOB data;
2300 } in;
2302 struct {
2303 uint8_t setup_count; /* in units of 16 bit words */
2304 uint8_t *setup;
2305 DATA_BLOB params;
2306 DATA_BLOB data;
2307 } out;
2310 enum smb_notify_level {
2311 RAW_NOTIFY_NTTRANS,
2312 RAW_NOTIFY_SMB2
2315 union smb_notify {
2316 /* struct for nttrans change notify call */
2317 struct {
2318 enum smb_notify_level level;
2320 struct {
2321 union smb_handle file;
2322 uint32_t buffer_size;
2323 uint32_t completion_filter;
2324 bool recursive;
2325 } in;
2327 struct {
2328 uint32_t num_changes;
2329 struct notify_changes {
2330 uint32_t action;
2331 struct smb_wire_string name;
2332 } *changes;
2333 } out;
2334 } nttrans;
2336 struct smb2_notify {
2337 enum smb_notify_level level;
2339 struct {
2340 union smb_handle file;
2341 /* static body buffer 32 (0x20) bytes */
2342 /* uint16_t buffer_code; 0x32 */
2343 uint16_t recursive;
2344 uint32_t buffer_size;
2345 /*struct smb2_handle file;*/
2346 uint32_t completion_filter;
2347 uint32_t unknown;
2348 } in;
2350 struct {
2351 /* static body buffer 8 (0x08) bytes */
2352 /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
2353 /* uint16_t blob_ofs; */
2354 /* uint16_t blob_size; */
2356 /* dynamic body */
2357 /*DATA_BLOB blob;*/
2359 /* DATA_BLOB content */
2360 uint32_t num_changes;
2361 struct notify_changes *changes;
2362 } out;
2363 } smb2;
2366 enum smb_search_level {
2367 RAW_SEARCH_SEARCH, /* SMBsearch */
2368 RAW_SEARCH_FFIRST, /* SMBffirst */
2369 RAW_SEARCH_FUNIQUE, /* SMBfunique */
2370 RAW_SEARCH_TRANS2, /* SMBtrans2 */
2371 RAW_SEARCH_SMB2 /* SMB2 Find */
2374 enum smb_search_data_level {
2375 RAW_SEARCH_DATA_GENERIC = 0x10000, /* only used in the smbcli_ code */
2376 RAW_SEARCH_DATA_SEARCH,
2377 RAW_SEARCH_DATA_STANDARD = SMB_FIND_STANDARD,
2378 RAW_SEARCH_DATA_EA_SIZE = SMB_FIND_EA_SIZE,
2379 RAW_SEARCH_DATA_EA_LIST = SMB_FIND_EA_LIST,
2380 RAW_SEARCH_DATA_DIRECTORY_INFO = SMB_FIND_DIRECTORY_INFO,
2381 RAW_SEARCH_DATA_FULL_DIRECTORY_INFO = SMB_FIND_FULL_DIRECTORY_INFO,
2382 RAW_SEARCH_DATA_NAME_INFO = SMB_FIND_NAME_INFO,
2383 RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO = SMB_FIND_BOTH_DIRECTORY_INFO,
2384 RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO = SMB_FIND_ID_FULL_DIRECTORY_INFO,
2385 RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
2386 RAW_SEARCH_DATA_UNIX_INFO = SMB_FIND_UNIX_INFO,
2387 RAW_SEARCH_DATA_UNIX_INFO2 = SMB_FIND_UNIX_INFO2
2390 /* union for file search */
2391 union smb_search_first {
2392 struct {
2393 enum smb_search_level level;
2394 enum smb_search_data_level data_level;
2395 } generic;
2397 /* search (old) findfirst interface.
2398 Also used for ffirst and funique. */
2399 struct {
2400 enum smb_search_level level;
2401 enum smb_search_data_level data_level;
2403 struct {
2404 uint16_t max_count;
2405 uint16_t search_attrib;
2406 const char *pattern;
2407 } in;
2408 struct {
2409 int16_t count;
2410 } out;
2411 } search_first;
2413 /* trans2 findfirst interface */
2414 struct {
2415 enum smb_search_level level;
2416 enum smb_search_data_level data_level;
2418 struct {
2419 uint16_t search_attrib;
2420 uint16_t max_count;
2421 uint16_t flags;
2422 uint32_t storage_type;
2423 const char *pattern;
2425 /* the ea names are only used for RAW_SEARCH_EA_LIST */
2426 uint_t num_names;
2427 struct ea_name *ea_names;
2428 } in;
2429 struct {
2430 uint16_t handle;
2431 uint16_t count;
2432 uint16_t end_of_search;
2433 } out;
2434 } t2ffirst;
2437 SMB2 uses different level numbers for the same old SMB trans2 search levels
2439 #define SMB2_FIND_DIRECTORY_INFO 0x01
2440 #define SMB2_FIND_FULL_DIRECTORY_INFO 0x02
2441 #define SMB2_FIND_BOTH_DIRECTORY_INFO 0x03
2442 #define SMB2_FIND_NAME_INFO 0x0C
2443 #define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25
2444 #define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26
2446 /* flags for SMB2 find */
2447 #define SMB2_CONTINUE_FLAG_RESTART 0x01
2448 #define SMB2_CONTINUE_FLAG_SINGLE 0x02
2449 #define SMB2_CONTINUE_FLAG_INDEX 0x04
2450 #define SMB2_CONTINUE_FLAG_REOPEN 0x10
2452 /* SMB2 Find */
2453 struct smb2_find {
2454 enum smb_search_level level;
2455 enum smb_search_data_level data_level;
2456 struct {
2457 union smb_handle file;
2459 /* static body buffer 32 (0x20) bytes */
2460 /* uint16_t buffer_code; 0x21 = 0x20 + 1 */
2461 uint8_t level;
2462 uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */
2463 uint32_t file_index;
2464 /* struct smb2_handle handle; */
2465 /* uint16_t pattern_ofs; */
2466 /* uint16_t pattern_size; */
2467 uint32_t max_response_size;
2469 /* dynamic body */
2470 const char *pattern;
2471 } in;
2472 struct {
2473 /* static body buffer 8 (0x08) bytes */
2474 /* uint16_t buffer_code; 0x08 */
2475 /* uint16_t blob_ofs; */
2476 /* uint32_t blob_size; */
2478 /* dynamic body */
2479 DATA_BLOB blob;
2480 } out;
2481 } smb2;
2484 /* union for file search continue */
2485 union smb_search_next {
2486 struct {
2487 enum smb_search_level level;
2488 enum smb_search_data_level data_level;
2489 } generic;
2491 /* search (old) findnext interface. Also used
2492 for ffirst when continuing */
2493 struct {
2494 enum smb_search_level level;
2495 enum smb_search_data_level data_level;
2497 struct {
2498 uint16_t max_count;
2499 uint16_t search_attrib;
2500 struct smb_search_id {
2501 uint8_t reserved;
2502 char name[11];
2503 uint8_t handle;
2504 uint32_t server_cookie;
2505 uint32_t client_cookie;
2506 } id;
2507 } in;
2508 struct {
2509 uint16_t count;
2510 } out;
2511 } search_next;
2513 /* trans2 findnext interface */
2514 struct {
2515 enum smb_search_level level;
2516 enum smb_search_data_level data_level;
2518 struct {
2519 uint16_t handle;
2520 uint16_t max_count;
2521 uint32_t resume_key;
2522 uint16_t flags;
2523 const char *last_name;
2525 /* the ea names are only used for RAW_SEARCH_EA_LIST */
2526 uint_t num_names;
2527 struct ea_name *ea_names;
2528 } in;
2529 struct {
2530 uint16_t count;
2531 uint16_t end_of_search;
2532 } out;
2533 } t2fnext;
2535 /* SMB2 Find */
2536 struct smb2_find smb2;
2539 /* union for search reply file data */
2540 union smb_search_data {
2542 * search (old) findfirst
2543 * RAW_SEARCH_DATA_SEARCH
2545 struct {
2546 uint16_t attrib;
2547 time_t write_time;
2548 uint32_t size;
2549 struct smb_search_id id;
2550 const char *name;
2551 } search;
2553 /* trans2 findfirst RAW_SEARCH_DATA_STANDARD level */
2554 struct {
2555 uint32_t resume_key;
2556 time_t create_time;
2557 time_t access_time;
2558 time_t write_time;
2559 uint32_t size;
2560 uint32_t alloc_size;
2561 uint16_t attrib;
2562 struct smb_wire_string name;
2563 } standard;
2565 /* trans2 findfirst RAW_SEARCH_DATA_EA_SIZE level */
2566 struct {
2567 uint32_t resume_key;
2568 time_t create_time;
2569 time_t access_time;
2570 time_t write_time;
2571 uint32_t size;
2572 uint32_t alloc_size;
2573 uint16_t attrib;
2574 uint32_t ea_size;
2575 struct smb_wire_string name;
2576 } ea_size;
2578 /* trans2 findfirst RAW_SEARCH_DATA_EA_LIST level */
2579 struct {
2580 uint32_t resume_key;
2581 time_t create_time;
2582 time_t access_time;
2583 time_t write_time;
2584 uint32_t size;
2585 uint32_t alloc_size;
2586 uint16_t attrib;
2587 struct smb_ea_list eas;
2588 struct smb_wire_string name;
2589 } ea_list;
2591 /* RAW_SEARCH_DATA_DIRECTORY_INFO interface */
2592 struct {
2593 uint32_t file_index;
2594 NTTIME create_time;
2595 NTTIME access_time;
2596 NTTIME write_time;
2597 NTTIME change_time;
2598 uint64_t size;
2599 uint64_t alloc_size;
2600 uint32_t attrib;
2601 struct smb_wire_string name;
2602 } directory_info;
2604 /* RAW_SEARCH_DATA_FULL_DIRECTORY_INFO interface */
2605 struct {
2606 uint32_t file_index;
2607 NTTIME create_time;
2608 NTTIME access_time;
2609 NTTIME write_time;
2610 NTTIME change_time;
2611 uint64_t size;
2612 uint64_t alloc_size;
2613 uint32_t attrib;
2614 uint32_t ea_size;
2615 struct smb_wire_string name;
2616 } full_directory_info;
2618 /* RAW_SEARCH_DATA_NAME_INFO interface */
2619 struct {
2620 uint32_t file_index;
2621 struct smb_wire_string name;
2622 } name_info;
2624 /* RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO interface */
2625 struct {
2626 uint32_t file_index;
2627 NTTIME create_time;
2628 NTTIME access_time;
2629 NTTIME write_time;
2630 NTTIME change_time;
2631 uint64_t size;
2632 uint64_t alloc_size;
2633 uint32_t attrib;
2634 uint32_t ea_size;
2635 struct smb_wire_string short_name;
2636 struct smb_wire_string name;
2637 } both_directory_info;
2639 /* RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO interface */
2640 struct {
2641 uint32_t file_index;
2642 NTTIME create_time;
2643 NTTIME access_time;
2644 NTTIME write_time;
2645 NTTIME change_time;
2646 uint64_t size;
2647 uint64_t alloc_size;
2648 uint32_t attrib;
2649 uint32_t ea_size;
2650 uint64_t file_id;
2651 struct smb_wire_string name;
2652 } id_full_directory_info;
2654 /* RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO interface */
2655 struct {
2656 uint32_t file_index;
2657 NTTIME create_time;
2658 NTTIME access_time;
2659 NTTIME write_time;
2660 NTTIME change_time;
2661 uint64_t size;
2662 uint64_t alloc_size;
2663 uint32_t attrib;
2664 uint32_t ea_size;
2665 uint64_t file_id;
2666 struct smb_wire_string short_name;
2667 struct smb_wire_string name;
2668 } id_both_directory_info;
2670 /* RAW_SEARCH_DATA_UNIX_INFO interface */
2671 struct {
2672 uint32_t file_index;
2673 uint64_t size;
2674 uint64_t alloc_size;
2675 NTTIME status_change_time;
2676 NTTIME access_time;
2677 NTTIME change_time;
2678 uint64_t uid;
2679 uint64_t gid;
2680 uint32_t file_type;
2681 uint64_t dev_major;
2682 uint64_t dev_minor;
2683 uint64_t unique_id;
2684 uint64_t permissions;
2685 uint64_t nlink;
2686 const char *name;
2687 } unix_info;
2689 /* RAW_SEARCH_DATA_UNIX_INFO2 interface */
2690 struct {
2691 uint32_t file_index;
2692 uint64_t end_of_file;
2693 uint64_t num_bytes;
2694 NTTIME status_change_time;
2695 NTTIME access_time;
2696 NTTIME change_time;
2697 uint64_t uid;
2698 uint64_t gid;
2699 uint32_t file_type;
2700 uint64_t dev_major;
2701 uint64_t dev_minor;
2702 uint64_t unique_id;
2703 uint64_t permissions;
2704 uint64_t nlink;
2705 NTTIME create_time;
2706 uint32_t file_flags;
2707 uint32_t flags_mask;
2708 struct smb_wire_string name;
2709 } unix_info2;
2712 /* Callback function passed to the raw search interface. */
2713 typedef bool (*smbcli_search_callback)(void *private, const union smb_search_data *file);
2715 enum smb_search_close_level {RAW_FINDCLOSE_GENERIC, RAW_FINDCLOSE_FCLOSE, RAW_FINDCLOSE_FINDCLOSE};
2717 /* union for file search close */
2718 union smb_search_close {
2719 struct {
2720 enum smb_search_close_level level;
2721 } generic;
2723 /* SMBfclose (old search) interface */
2724 struct {
2725 enum smb_search_close_level level;
2727 struct {
2728 /* max_count and search_attrib are not used, but are present */
2729 uint16_t max_count;
2730 uint16_t search_attrib;
2731 struct smb_search_id id;
2732 } in;
2733 } fclose;
2735 /* SMBfindclose interface */
2736 struct {
2737 enum smb_search_close_level level;
2739 struct {
2740 uint16_t handle;
2741 } in;
2742 } findclose;
2747 struct for SMBecho call
2749 struct smb_echo {
2750 struct {
2751 uint16_t repeat_count;
2752 uint16_t size;
2753 uint8_t *data;
2754 } in;
2755 struct {
2756 uint16_t count;
2757 uint16_t sequence_number;
2758 uint16_t size;
2759 uint8_t *data;
2760 } out;
2764 struct for shadow copy volumes
2766 struct smb_shadow_copy {
2767 struct {
2768 union smb_handle file;
2769 uint32_t max_data;
2770 } in;
2771 struct {
2772 uint32_t num_volumes;
2773 uint32_t num_names;
2774 const char **names;
2775 } out;
2778 #endif /* __LIBCLI_RAW_INTERFACES_H__ */