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