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