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