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