tests/krb5: Add tests for account salt calculation
[Samba.git] / source4 / libcli / raw / interfaces.h
blob5b398ee2ced6a932bd49de59fb8ae9f566465394
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 RAW_FILEINFO_NORMALIZED_NAME_INFORMATION= SMB_QFILEINFO_NORMALIZED_NAME_INFORMATION,
465 /* SMB2 specific levels */
466 RAW_FILEINFO_SMB2_ALL_EAS = 0x0f01,
467 RAW_FILEINFO_SMB2_ALL_INFORMATION = 0x1201,
468 RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION = 0x1501
471 /* union used in qfileinfo() and qpathinfo() backend calls */
472 union smb_fileinfo {
473 /* generic interface:
474 * matches RAW_FILEINFO_GENERIC */
475 struct {
476 enum smb_fileinfo_level level;
477 struct {
478 union smb_handle_or_path file;
479 } in;
480 struct {
481 uint32_t attrib;
482 uint32_t ea_size;
483 unsigned int num_eas;
484 struct ea_struct {
485 uint8_t flags;
486 struct smb_wire_string name;
487 DATA_BLOB value;
488 } *eas;
489 NTTIME create_time;
490 NTTIME access_time;
491 NTTIME write_time;
492 NTTIME change_time;
493 uint64_t alloc_size;
494 uint64_t size;
495 uint32_t nlink;
496 struct smb_wire_string fname;
497 struct smb_wire_string alt_fname;
498 uint8_t delete_pending;
499 uint8_t directory;
500 uint64_t compressed_size;
501 uint16_t format;
502 uint8_t unit_shift;
503 uint8_t chunk_shift;
504 uint8_t cluster_shift;
505 uint64_t file_id;
506 uint32_t access_flags; /* seen 0x001f01ff from w2k3 */
507 uint64_t position;
508 uint32_t mode;
509 uint32_t alignment_requirement;
510 uint32_t reparse_tag;
511 unsigned int num_streams;
512 struct stream_struct {
513 uint64_t size;
514 uint64_t alloc_size;
515 struct smb_wire_string stream_name;
516 } *streams;
517 } out;
518 } generic;
521 /* SMBgetatr interface:
522 * matches RAW_FILEINFO_GETATTR */
523 struct {
524 enum smb_fileinfo_level level;
525 struct {
526 union smb_handle_or_path file;
527 } in;
528 struct {
529 uint16_t attrib;
530 uint32_t size;
531 time_t write_time;
532 } out;
533 } getattr;
535 /* SMBgetattrE and RAW_FILEINFO_STANDARD interface */
536 struct {
537 enum smb_fileinfo_level level;
538 struct {
539 union smb_handle_or_path file;
540 } in;
541 struct {
542 time_t create_time;
543 time_t access_time;
544 time_t write_time;
545 uint32_t size;
546 uint32_t alloc_size;
547 uint16_t attrib;
548 } out;
549 } getattre, standard;
551 /* trans2 RAW_FILEINFO_EA_SIZE interface */
552 struct {
553 enum smb_fileinfo_level level;
554 struct {
555 union smb_handle_or_path file;
556 } in;
557 struct {
558 time_t create_time;
559 time_t access_time;
560 time_t write_time;
561 uint32_t size;
562 uint32_t alloc_size;
563 uint16_t attrib;
564 uint32_t ea_size;
565 } out;
566 } ea_size;
568 /* trans2 RAW_FILEINFO_EA_LIST interface */
569 struct {
570 enum smb_fileinfo_level level;
571 struct {
572 union smb_handle_or_path file;
573 unsigned int num_names;
574 struct ea_name {
575 struct smb_wire_string name;
576 } *ea_names;
577 } in;
579 struct smb_ea_list {
580 unsigned int num_eas;
581 struct ea_struct *eas;
582 } out;
583 } ea_list;
585 /* trans2 RAW_FILEINFO_ALL_EAS and RAW_FILEINFO_FULL_EA_INFORMATION interfaces */
586 struct {
587 enum smb_fileinfo_level level;
588 struct {
589 union smb_handle_or_path file;
590 /* SMB2 only - SMB2_CONTINUE_FLAG_* */
591 uint8_t continue_flags;
592 } in;
593 struct smb_ea_list out;
594 } all_eas;
596 /* trans2 qpathinfo RAW_FILEINFO_IS_NAME_VALID interface
597 only valid for a QPATHNAME call - no returned data */
598 struct {
599 enum smb_fileinfo_level level;
600 struct {
601 union smb_handle_or_path file;
602 } in;
603 } is_name_valid;
605 /* RAW_FILEINFO_BASIC_INFO and RAW_FILEINFO_BASIC_INFORMATION interfaces */
606 struct {
607 enum smb_fileinfo_level level;
608 struct {
609 union smb_handle_or_path file;
610 } in;
611 struct {
612 NTTIME create_time;
613 NTTIME access_time;
614 NTTIME write_time;
615 NTTIME change_time;
616 uint32_t attrib;
617 } out;
618 } basic_info;
621 /* RAW_FILEINFO_STANDARD_INFO and RAW_FILEINFO_STANDARD_INFORMATION interfaces */
622 struct {
623 enum smb_fileinfo_level level;
624 struct {
625 union smb_handle_or_path file;
626 } in;
627 struct {
628 uint64_t alloc_size;
629 uint64_t size;
630 uint32_t nlink;
631 bool delete_pending;
632 bool directory;
633 } out;
634 } standard_info;
636 /* RAW_FILEINFO_EA_INFO and RAW_FILEINFO_EA_INFORMATION interfaces */
637 struct {
638 enum smb_fileinfo_level level;
639 struct {
640 union smb_handle_or_path file;
641 } in;
642 struct {
643 uint32_t ea_size;
644 } out;
645 } ea_info;
647 /* RAW_FILEINFO_NAME_INFO and RAW_FILEINFO_NAME_INFORMATION interfaces */
648 /* RAW_FILEINFO_ALT_NAME_INFO and RAW_FILEINFO_ALT_NAME_INFORMATION interfaces */
649 /* RAW_FILEINFO_NORMALIZED_NAME_INFORMATION interface */
650 /* RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION interface */
651 struct {
652 enum smb_fileinfo_level level;
653 struct {
654 union smb_handle_or_path file;
655 } in;
656 struct {
657 struct smb_wire_string fname;
658 } out;
659 } name_info, alt_name_info, normalized_name_info;
661 /* RAW_FILEINFO_ALL_INFO and RAW_FILEINFO_ALL_INFORMATION interfaces */
662 struct {
663 enum smb_fileinfo_level level;
664 struct {
665 union smb_handle_or_path file;
666 } in;
667 struct {
668 NTTIME create_time;
669 NTTIME access_time;
670 NTTIME write_time;
671 NTTIME change_time;
672 uint32_t attrib;
673 uint64_t alloc_size;
674 uint64_t size;
675 uint32_t nlink;
676 uint8_t delete_pending;
677 uint8_t directory;
678 uint32_t ea_size;
679 struct smb_wire_string fname;
680 } out;
681 } all_info;
683 /* RAW_FILEINFO_SMB2_ALL_INFORMATION interface */
684 struct {
685 enum smb_fileinfo_level level;
686 struct {
687 union smb_handle_or_path file;
688 } in;
689 struct {
690 NTTIME create_time;
691 NTTIME access_time;
692 NTTIME write_time;
693 NTTIME change_time;
694 uint32_t attrib;
695 uint32_t unknown1;
696 uint64_t alloc_size;
697 uint64_t size;
698 uint32_t nlink;
699 uint8_t delete_pending;
700 uint8_t directory;
701 /* uint16_t _pad; */
702 uint64_t file_id;
703 uint32_t ea_size;
704 uint32_t access_mask;
705 uint64_t position;
706 uint32_t mode;
707 uint32_t alignment_requirement;
708 struct smb_wire_string fname;
709 } out;
710 } all_info2;
712 /* RAW_FILEINFO_STREAM_INFO and RAW_FILEINFO_STREAM_INFORMATION interfaces */
713 struct {
714 enum smb_fileinfo_level level;
715 struct {
716 union smb_handle_or_path file;
717 } in;
718 struct stream_information {
719 unsigned int num_streams;
720 struct stream_struct *streams;
721 } out;
722 } stream_info;
724 /* RAW_FILEINFO_COMPRESSION_INFO and RAW_FILEINFO_COMPRESSION_INFORMATION interfaces */
725 struct {
726 enum smb_fileinfo_level level;
727 struct {
728 union smb_handle_or_path file;
729 } in;
730 struct {
731 uint64_t compressed_size;
732 uint16_t format;
733 uint8_t unit_shift;
734 uint8_t chunk_shift;
735 uint8_t cluster_shift;
736 } out;
737 } compression_info;
739 /* RAW_FILEINFO_UNIX_BASIC interface */
740 struct {
741 enum smb_fileinfo_level level;
742 struct {
743 union smb_handle_or_path file;
744 } in;
745 struct {
746 uint64_t end_of_file;
747 uint64_t num_bytes;
748 NTTIME status_change_time;
749 NTTIME access_time;
750 NTTIME change_time;
751 uint64_t uid;
752 uint64_t gid;
753 uint32_t file_type;
754 uint64_t dev_major;
755 uint64_t dev_minor;
756 uint64_t unique_id;
757 uint64_t permissions;
758 uint64_t nlink;
759 } out;
760 } unix_basic_info;
762 /* RAW_FILEINFO_UNIX_INFO2 interface */
763 struct {
764 enum smb_fileinfo_level level;
765 struct {
766 union smb_handle_or_path file;
767 } in;
768 struct {
769 uint64_t end_of_file;
770 uint64_t num_bytes;
771 NTTIME status_change_time;
772 NTTIME access_time;
773 NTTIME change_time;
774 uint64_t uid;
775 uint64_t gid;
776 uint32_t file_type;
777 uint64_t dev_major;
778 uint64_t dev_minor;
779 uint64_t unique_id;
780 uint64_t permissions;
781 uint64_t nlink;
782 NTTIME create_time;
783 uint32_t file_flags;
784 uint32_t flags_mask;
785 } out;
786 } unix_info2;
788 /* RAW_FILEINFO_UNIX_LINK interface */
789 struct {
790 enum smb_fileinfo_level level;
791 struct {
792 union smb_handle_or_path file;
793 } in;
794 struct {
795 struct smb_wire_string link_dest;
796 } out;
797 } unix_link_info;
799 /* RAW_FILEINFO_INTERNAL_INFORMATION interface */
800 struct {
801 enum smb_fileinfo_level level;
802 struct {
803 union smb_handle_or_path file;
804 } in;
805 struct {
806 uint64_t file_id;
807 } out;
808 } internal_information;
810 /* RAW_FILEINFO_ACCESS_INFORMATION interface */
811 struct {
812 enum smb_fileinfo_level level;
813 struct {
814 union smb_handle_or_path file;
815 } in;
816 struct {
817 uint32_t access_flags;
818 } out;
819 } access_information;
821 /* RAW_FILEINFO_POSITION_INFORMATION interface */
822 struct {
823 enum smb_fileinfo_level level;
824 struct {
825 union smb_handle_or_path file;
826 } in;
827 struct {
828 uint64_t position;
829 } out;
830 } position_information;
832 /* RAW_FILEINFO_MODE_INFORMATION interface */
833 struct {
834 enum smb_fileinfo_level level;
835 struct {
836 union smb_handle_or_path file;
837 } in;
838 struct {
839 uint32_t mode;
840 } out;
841 } mode_information;
843 /* RAW_FILEINFO_ALIGNMENT_INFORMATION interface */
844 struct {
845 enum smb_fileinfo_level level;
846 struct {
847 union smb_handle_or_path file;
848 } in;
849 struct {
850 uint32_t alignment_requirement;
851 } out;
852 } alignment_information;
854 /* RAW_FILEINFO_NETWORK_OPEN_INFORMATION interface */
855 struct {
856 enum smb_fileinfo_level level;
857 struct {
858 union smb_handle_or_path file;
859 } in;
860 struct {
861 NTTIME create_time;
862 NTTIME access_time;
863 NTTIME write_time;
864 NTTIME change_time;
865 uint64_t alloc_size;
866 uint64_t size;
867 uint32_t attrib;
868 } out;
869 } network_open_information;
872 /* RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION interface */
873 struct {
874 enum smb_fileinfo_level level;
875 struct {
876 union smb_handle_or_path file;
877 } in;
878 struct {
879 uint32_t attrib;
880 uint32_t reparse_tag;
881 } out;
882 } attribute_tag_information;
884 /* RAW_FILEINFO_SEC_DESC */
885 struct {
886 enum smb_fileinfo_level level;
887 struct {
888 union smb_handle_or_path file;
889 uint32_t secinfo_flags;
890 } in;
891 struct {
892 struct security_descriptor *sd;
893 } out;
894 } query_secdesc;
898 enum smb_setfileinfo_level {
899 RAW_SFILEINFO_GENERIC = 0xF000,
900 RAW_SFILEINFO_SETATTR, /* SMBsetatr */
901 RAW_SFILEINFO_SETATTRE, /* SMBsetattrE */
902 RAW_SFILEINFO_SEC_DESC, /* NT_TRANSACT_SET_SECURITY_DESC */
903 RAW_SFILEINFO_STANDARD = SMB_SFILEINFO_STANDARD,
904 RAW_SFILEINFO_EA_SET = SMB_SFILEINFO_EA_SET,
905 RAW_SFILEINFO_BASIC_INFO = SMB_SFILEINFO_BASIC_INFO,
906 RAW_SFILEINFO_DISPOSITION_INFO = SMB_SFILEINFO_DISPOSITION_INFO,
907 RAW_SFILEINFO_ALLOCATION_INFO = SMB_SFILEINFO_ALLOCATION_INFO,
908 RAW_SFILEINFO_END_OF_FILE_INFO = SMB_SFILEINFO_END_OF_FILE_INFO,
909 RAW_SFILEINFO_UNIX_BASIC = SMB_SFILEINFO_UNIX_BASIC,
910 RAW_SFILEINFO_UNIX_INFO2 = SMB_SFILEINFO_UNIX_INFO2,
911 RAW_SFILEINFO_UNIX_LINK = SMB_SET_FILE_UNIX_LINK,
912 RAW_SFILEINFO_UNIX_HLINK = SMB_SET_FILE_UNIX_HLINK,
913 RAW_SFILEINFO_BASIC_INFORMATION = SMB_SFILEINFO_BASIC_INFORMATION,
914 RAW_SFILEINFO_RENAME_INFORMATION = SMB_SFILEINFO_RENAME_INFORMATION,
915 RAW_SFILEINFO_LINK_INFORMATION = SMB_SFILEINFO_LINK_INFORMATION,
916 RAW_SFILEINFO_DISPOSITION_INFORMATION = SMB_SFILEINFO_DISPOSITION_INFORMATION,
917 RAW_SFILEINFO_POSITION_INFORMATION = SMB_SFILEINFO_POSITION_INFORMATION,
918 RAW_SFILEINFO_FULL_EA_INFORMATION = SMB_SFILEINFO_FULL_EA_INFORMATION,
919 RAW_SFILEINFO_MODE_INFORMATION = SMB_SFILEINFO_MODE_INFORMATION,
920 RAW_SFILEINFO_ALLOCATION_INFORMATION = SMB_SFILEINFO_ALLOCATION_INFORMATION,
921 RAW_SFILEINFO_END_OF_FILE_INFORMATION = SMB_SFILEINFO_END_OF_FILE_INFORMATION,
922 RAW_SFILEINFO_PIPE_INFORMATION = SMB_SFILEINFO_PIPE_INFORMATION,
923 RAW_SFILEINFO_VALID_DATA_INFORMATION = SMB_SFILEINFO_VALID_DATA_INFORMATION,
924 RAW_SFILEINFO_SHORT_NAME_INFORMATION = SMB_SFILEINFO_SHORT_NAME_INFORMATION,
925 RAW_SFILEINFO_1025 = SMB_SFILEINFO_1025,
926 RAW_SFILEINFO_1027 = SMB_SFILEINFO_1027,
927 RAW_SFILEINFO_1029 = SMB_SFILEINFO_1029,
928 RAW_SFILEINFO_1030 = SMB_SFILEINFO_1030,
929 RAW_SFILEINFO_1031 = SMB_SFILEINFO_1031,
930 RAW_SFILEINFO_1032 = SMB_SFILEINFO_1032,
931 RAW_SFILEINFO_1036 = SMB_SFILEINFO_1036,
932 RAW_SFILEINFO_1041 = SMB_SFILEINFO_1041,
933 RAW_SFILEINFO_1042 = SMB_SFILEINFO_1042,
934 RAW_SFILEINFO_1043 = SMB_SFILEINFO_1043,
935 RAW_SFILEINFO_1044 = SMB_SFILEINFO_1044,
937 /* cope with breakage in SMB2 */
938 RAW_SFILEINFO_RENAME_INFORMATION_SMB2 = SMB_SFILEINFO_RENAME_INFORMATION|0x80000000,
941 /* union used in setfileinfo() and setpathinfo() calls */
942 union smb_setfileinfo {
943 /* generic interface */
944 struct {
945 enum smb_setfileinfo_level level;
946 struct {
947 union smb_handle_or_path file;
948 } in;
949 } generic;
951 /* RAW_SFILEINFO_SETATTR (SMBsetatr) interface - only via setpathinfo() */
952 struct {
953 enum smb_setfileinfo_level level;
954 struct {
955 union smb_handle_or_path file;
956 uint16_t attrib;
957 time_t write_time;
958 } in;
959 } setattr;
961 /* RAW_SFILEINFO_SETATTRE (SMBsetattrE) interface - only via setfileinfo()
962 also RAW_SFILEINFO_STANDARD */
963 struct {
964 enum smb_setfileinfo_level level;
965 struct {
966 union smb_handle_or_path file;
967 time_t create_time;
968 time_t access_time;
969 time_t write_time;
970 /* notice that size, alloc_size and attrib are not settable,
971 unlike the corresponding qfileinfo level */
972 } in;
973 } setattre, standard;
975 /* RAW_SFILEINFO_EA_SET interface */
976 struct {
977 enum smb_setfileinfo_level level;
978 struct {
979 union smb_handle_or_path file;
980 unsigned int num_eas;
981 struct ea_struct *eas;
982 } in;
983 } ea_set;
985 /* RAW_SFILEINFO_BASIC_INFO and
986 RAW_SFILEINFO_BASIC_INFORMATION interfaces */
987 struct {
988 enum smb_setfileinfo_level level;
989 struct {
990 union smb_handle_or_path file;
991 NTTIME create_time;
992 NTTIME access_time;
993 NTTIME write_time;
994 NTTIME change_time;
995 uint32_t attrib;
996 uint32_t reserved;
997 } in;
998 } basic_info;
1000 /* RAW_SFILEINFO_DISPOSITION_INFO and
1001 RAW_SFILEINFO_DISPOSITION_INFORMATION interfaces */
1002 struct {
1003 enum smb_setfileinfo_level level;
1004 struct {
1005 union smb_handle_or_path file;
1006 bool delete_on_close;
1007 } in;
1008 } disposition_info;
1010 /* RAW_SFILEINFO_ALLOCATION_INFO and
1011 RAW_SFILEINFO_ALLOCATION_INFORMATION interfaces */
1012 struct {
1013 enum smb_setfileinfo_level level;
1014 struct {
1015 union smb_handle_or_path file;
1016 /* w2k3 rounds this up to nearest 4096 */
1017 uint64_t alloc_size;
1018 } in;
1019 } allocation_info;
1021 /* RAW_SFILEINFO_END_OF_FILE_INFO and
1022 RAW_SFILEINFO_END_OF_FILE_INFORMATION interfaces */
1023 struct {
1024 enum smb_setfileinfo_level level;
1025 struct {
1026 union smb_handle_or_path file;
1027 uint64_t size;
1028 } in;
1029 } end_of_file_info;
1031 /* RAW_SFILEINFO_RENAME_INFORMATION interface */
1032 struct {
1033 enum smb_setfileinfo_level level;
1034 struct {
1035 union smb_handle_or_path file;
1036 uint8_t overwrite;
1037 uint64_t root_fid;
1038 const char *new_name;
1039 } in;
1040 } rename_information;
1042 /* RAW_SFILEINFO_LINK_INFORMATION interface */
1043 struct {
1044 enum smb_setfileinfo_level level;
1045 struct {
1046 union smb_handle_or_path file;
1047 uint8_t overwrite;
1048 uint64_t root_fid;
1049 const char *new_name;
1050 } in;
1051 } link_information;
1053 /* RAW_SFILEINFO_POSITION_INFORMATION interface */
1054 struct {
1055 enum smb_setfileinfo_level level;
1056 struct {
1057 union smb_handle_or_path file;
1058 uint64_t position;
1059 } in;
1060 } position_information;
1062 /* RAW_SFILEINFO_MODE_INFORMATION interface */
1063 struct {
1064 enum smb_setfileinfo_level level;
1065 struct {
1066 union smb_handle_or_path file;
1067 /* valid values seem to be 0, 2, 4 and 6 */
1068 uint32_t mode;
1069 } in;
1070 } mode_information;
1072 /* RAW_SFILEINFO_UNIX_BASIC interface */
1073 struct {
1074 enum smb_setfileinfo_level level;
1075 struct {
1076 union smb_handle_or_path file;
1077 uint32_t mode; /* yuck - this field remains to fix compile of libcli/clifile.c */
1078 uint64_t end_of_file;
1079 uint64_t num_bytes;
1080 NTTIME status_change_time;
1081 NTTIME access_time;
1082 NTTIME change_time;
1083 uint64_t uid;
1084 uint64_t gid;
1085 uint32_t file_type;
1086 uint64_t dev_major;
1087 uint64_t dev_minor;
1088 uint64_t unique_id;
1089 uint64_t permissions;
1090 uint64_t nlink;
1091 } in;
1092 } unix_basic;
1094 /* RAW_SFILEINFO_UNIX_INFO2 interface */
1095 struct {
1096 enum smb_setfileinfo_level level;
1097 struct {
1098 union smb_handle_or_path file;
1099 uint64_t end_of_file;
1100 uint64_t num_bytes;
1101 NTTIME status_change_time;
1102 NTTIME access_time;
1103 NTTIME change_time;
1104 uint64_t uid;
1105 uint64_t gid;
1106 uint32_t file_type;
1107 uint64_t dev_major;
1108 uint64_t dev_minor;
1109 uint64_t unique_id;
1110 uint64_t permissions;
1111 uint64_t nlink;
1112 NTTIME create_time;
1113 uint32_t file_flags;
1114 uint32_t flags_mask;
1115 } in;
1116 } unix_info2;
1118 /* RAW_SFILEINFO_UNIX_LINK, RAW_SFILEINFO_UNIX_HLINK interface */
1119 struct {
1120 enum smb_setfileinfo_level level;
1121 struct {
1122 union smb_handle_or_path file;
1123 const char *link_dest;
1124 } in;
1125 } unix_link, unix_hlink;
1127 /* RAW_SFILEINFO_SEC_DESC */
1128 struct {
1129 enum smb_setfileinfo_level level;
1130 struct {
1131 union smb_handle_or_path file;
1132 uint32_t secinfo_flags;
1133 struct security_descriptor *sd;
1134 } in;
1135 } set_secdesc;
1137 /* RAW_SFILEINFO_FULL_EA_INFORMATION */
1138 struct {
1139 enum smb_setfileinfo_level level;
1140 struct {
1141 union smb_handle_or_path file;
1142 struct smb_ea_list eas;
1143 } in;
1144 } full_ea_information;
1148 enum smb_fsinfo_level {
1149 RAW_QFS_GENERIC = 0xF000,
1150 RAW_QFS_DSKATTR, /* SMBdskattr */
1151 RAW_QFS_ALLOCATION = SMB_QFS_ALLOCATION,
1152 RAW_QFS_VOLUME = SMB_QFS_VOLUME,
1153 RAW_QFS_VOLUME_INFO = SMB_QFS_VOLUME_INFO,
1154 RAW_QFS_SIZE_INFO = SMB_QFS_SIZE_INFO,
1155 RAW_QFS_DEVICE_INFO = SMB_QFS_DEVICE_INFO,
1156 RAW_QFS_ATTRIBUTE_INFO = SMB_QFS_ATTRIBUTE_INFO,
1157 RAW_QFS_UNIX_INFO = SMB_QFS_UNIX_INFO,
1158 RAW_QFS_VOLUME_INFORMATION = SMB_QFS_VOLUME_INFORMATION,
1159 RAW_QFS_SIZE_INFORMATION = SMB_QFS_SIZE_INFORMATION,
1160 RAW_QFS_DEVICE_INFORMATION = SMB_QFS_DEVICE_INFORMATION,
1161 RAW_QFS_ATTRIBUTE_INFORMATION = SMB_QFS_ATTRIBUTE_INFORMATION,
1162 RAW_QFS_QUOTA_INFORMATION = SMB_QFS_QUOTA_INFORMATION,
1163 RAW_QFS_FULL_SIZE_INFORMATION = SMB_QFS_FULL_SIZE_INFORMATION,
1164 RAW_QFS_OBJECTID_INFORMATION = SMB_QFS_OBJECTID_INFORMATION,
1165 RAW_QFS_SECTOR_SIZE_INFORMATION = SMB_QFS_SECTOR_SIZE_INFORMATION,
1169 /* union for fsinfo() backend call. Note that there are no in
1170 structures, as this call only contains out parameters */
1171 union smb_fsinfo {
1172 /* generic interface */
1173 struct {
1174 enum smb_fsinfo_level level;
1175 struct smb2_handle handle; /* only for smb2 */
1177 struct {
1178 uint32_t block_size;
1179 uint64_t blocks_total;
1180 uint64_t blocks_free;
1181 uint32_t fs_id;
1182 NTTIME create_time;
1183 uint32_t serial_number;
1184 uint32_t fs_attr;
1185 uint32_t max_file_component_length;
1186 uint32_t device_type;
1187 uint32_t device_characteristics;
1188 uint64_t quota_soft;
1189 uint64_t quota_hard;
1190 uint64_t quota_flags;
1191 struct GUID guid;
1192 char *volume_name;
1193 char *fs_type;
1194 } out;
1195 } generic;
1197 /* SMBdskattr interface */
1198 struct {
1199 enum smb_fsinfo_level level;
1201 struct {
1202 uint16_t units_total;
1203 uint16_t blocks_per_unit;
1204 uint16_t block_size;
1205 uint16_t units_free;
1206 } out;
1207 } dskattr;
1209 /* trans2 RAW_QFS_ALLOCATION interface */
1210 struct {
1211 enum smb_fsinfo_level level;
1213 struct {
1214 uint32_t fs_id;
1215 uint32_t sectors_per_unit;
1216 uint32_t total_alloc_units;
1217 uint32_t avail_alloc_units;
1218 uint16_t bytes_per_sector;
1219 } out;
1220 } allocation;
1222 /* TRANS2 RAW_QFS_VOLUME interface */
1223 struct {
1224 enum smb_fsinfo_level level;
1226 struct {
1227 uint32_t serial_number;
1228 struct smb_wire_string volume_name;
1229 } out;
1230 } volume;
1232 /* TRANS2 RAW_QFS_VOLUME_INFO and RAW_QFS_VOLUME_INFORMATION interfaces */
1233 struct {
1234 enum smb_fsinfo_level level;
1235 struct smb2_handle handle; /* only for smb2 */
1237 struct {
1238 NTTIME create_time;
1239 uint32_t serial_number;
1240 struct smb_wire_string volume_name;
1241 } out;
1242 } volume_info;
1244 /* trans2 RAW_QFS_SIZE_INFO and RAW_QFS_SIZE_INFORMATION interfaces */
1245 struct {
1246 enum smb_fsinfo_level level;
1247 struct smb2_handle handle; /* only for smb2 */
1249 struct {
1250 uint64_t total_alloc_units;
1251 uint64_t avail_alloc_units; /* maps to call_avail_alloc_units */
1252 uint32_t sectors_per_unit;
1253 uint32_t bytes_per_sector;
1254 } out;
1255 } size_info;
1257 /* TRANS2 RAW_QFS_DEVICE_INFO and RAW_QFS_DEVICE_INFORMATION interfaces */
1258 struct {
1259 enum smb_fsinfo_level level;
1260 struct smb2_handle handle; /* only for smb2 */
1262 struct {
1263 uint32_t device_type;
1264 uint32_t characteristics;
1265 } out;
1266 } device_info;
1269 /* TRANS2 RAW_QFS_ATTRIBUTE_INFO and RAW_QFS_ATTRIBUTE_INFORMATION interfaces */
1270 struct {
1271 enum smb_fsinfo_level level;
1272 struct smb2_handle handle; /* only for smb2 */
1274 struct {
1275 uint32_t fs_attr;
1276 uint32_t max_file_component_length;
1277 struct smb_wire_string fs_type;
1278 } out;
1279 } attribute_info;
1282 /* TRANS2 RAW_QFS_UNIX_INFO interface */
1283 struct {
1284 enum smb_fsinfo_level level;
1286 struct {
1287 uint16_t major_version;
1288 uint16_t minor_version;
1289 uint64_t capability;
1290 } out;
1291 } unix_info;
1293 /* trans2 RAW_QFS_QUOTA_INFORMATION interface */
1294 struct {
1295 enum smb_fsinfo_level level;
1296 struct smb2_handle handle; /* only for smb2 */
1298 struct {
1299 uint64_t unknown[3];
1300 uint64_t quota_soft;
1301 uint64_t quota_hard;
1302 uint64_t quota_flags;
1303 } out;
1304 } quota_information;
1306 /* trans2 RAW_QFS_FULL_SIZE_INFORMATION interface */
1307 struct {
1308 enum smb_fsinfo_level level;
1309 struct smb2_handle handle; /* only for smb2 */
1311 struct {
1312 uint64_t total_alloc_units;
1313 uint64_t call_avail_alloc_units;
1314 uint64_t actual_avail_alloc_units;
1315 uint32_t sectors_per_unit;
1316 uint32_t bytes_per_sector;
1317 } out;
1318 } full_size_information;
1320 /* trans2 RAW_QFS_OBJECTID_INFORMATION interface */
1321 struct {
1322 enum smb_fsinfo_level level;
1323 struct smb2_handle handle; /* only for smb2 */
1325 struct {
1326 struct GUID guid;
1327 uint64_t unknown[6];
1328 } out;
1329 } objectid_information;
1331 /* trans2 RAW_QFS_SECTOR_SIZE_INFORMATION interface */
1332 struct {
1333 enum smb_fsinfo_level level;
1334 struct smb2_handle handle; /* only for smb2 */
1336 struct {
1337 uint32_t logical_bytes_per_sector;
1338 uint32_t phys_bytes_per_sector_atomic;
1339 uint32_t phys_bytes_per_sector_perf;
1340 uint32_t fs_effective_phys_bytes_per_sector_atomic;
1341 uint32_t flags;
1342 uint32_t byte_off_sector_align;
1343 uint32_t byte_off_partition_align;
1344 } out;
1345 } sector_size_info;
1349 enum smb_setfsinfo_level {
1350 RAW_SETFS_UNIX_INFO = SMB_SET_CIFS_UNIX_INFO};
1352 union smb_setfsinfo {
1353 /* generic interface */
1354 struct {
1355 enum smb_setfsinfo_level level;
1356 } generic;
1358 /* TRANS2 RAW_QFS_UNIX_INFO interface */
1359 struct {
1360 enum smb_setfsinfo_level level;
1362 struct {
1363 uint16_t major_version;
1364 uint16_t minor_version;
1365 uint64_t capability;
1366 } in;
1367 } unix_info;
1370 enum smb_open_level {
1371 RAW_OPEN_OPEN,
1372 RAW_OPEN_OPENX,
1373 RAW_OPEN_MKNEW,
1374 RAW_OPEN_CREATE,
1375 RAW_OPEN_CTEMP,
1376 RAW_OPEN_SPLOPEN,
1377 RAW_OPEN_NTCREATEX,
1378 RAW_OPEN_T2OPEN,
1379 RAW_OPEN_NTTRANS_CREATE,
1380 RAW_OPEN_OPENX_READX,
1381 RAW_OPEN_NTCREATEX_READX,
1382 RAW_OPEN_SMB2
1385 /* the generic interface is defined to be equal to the NTCREATEX interface */
1386 #define RAW_OPEN_GENERIC RAW_OPEN_NTCREATEX
1388 /* union for open() backend call */
1389 union smb_open {
1391 * because the *.out.file structs are not aligned to the same offset for each level
1392 * we provide a hepler macro that should be used to find the current smb_handle structure
1394 #define SMB_OPEN_OUT_FILE(op, file) do { \
1395 switch (op->generic.level) { \
1396 case RAW_OPEN_OPEN: \
1397 file = &op->openold.out.file; \
1398 break; \
1399 case RAW_OPEN_OPENX: \
1400 file = &op->openx.out.file; \
1401 break; \
1402 case RAW_OPEN_MKNEW: \
1403 file = &op->mknew.out.file; \
1404 break; \
1405 case RAW_OPEN_CREATE: \
1406 file = &op->create.out.file; \
1407 break; \
1408 case RAW_OPEN_CTEMP: \
1409 file = &op->ctemp.out.file; \
1410 break; \
1411 case RAW_OPEN_SPLOPEN: \
1412 file = &op->splopen.out.file; \
1413 break; \
1414 case RAW_OPEN_NTCREATEX: \
1415 file = &op->ntcreatex.out.file; \
1416 break; \
1417 case RAW_OPEN_T2OPEN: \
1418 file = &op->t2open.out.file; \
1419 break; \
1420 case RAW_OPEN_NTTRANS_CREATE: \
1421 file = &op->nttrans.out.file; \
1422 break; \
1423 case RAW_OPEN_OPENX_READX: \
1424 file = &op->openxreadx.out.file; \
1425 break; \
1426 case RAW_OPEN_NTCREATEX_READX: \
1427 file = &op->ntcreatexreadx.out.file; \
1428 break; \
1429 case RAW_OPEN_SMB2: \
1430 file = &op->smb2.out.file; \
1431 break; \
1432 default: \
1433 /* this must be a programmer error */ \
1434 file = NULL; \
1435 break; \
1437 } while (0)
1438 /* SMBNTCreateX, nttrans and generic interface */
1439 struct {
1440 enum smb_open_level level;
1441 struct {
1442 uint32_t flags;
1443 union smb_handle root_fid;
1444 uint32_t access_mask;
1445 uint64_t alloc_size;
1446 uint32_t file_attr;
1447 uint32_t share_access;
1448 uint32_t open_disposition;
1449 uint32_t create_options;
1450 uint32_t impersonation;
1451 uint8_t security_flags;
1452 /* NOTE: fname can also be a pointer to a
1453 uint64_t file_id if create_options has the
1454 NTCREATEX_OPTIONS_OPEN_BY_FILE_ID flag set */
1455 const char *fname;
1457 /* these last 2 elements are only used in the
1458 NTTRANS varient of the call */
1459 struct security_descriptor *sec_desc;
1460 struct smb_ea_list *ea_list;
1462 /* some optional parameters from the SMB2 varient */
1463 bool query_maximal_access;
1464 bool query_on_disk_id;
1466 /* private flags for internal use only */
1467 uint8_t private_flags;
1468 } in;
1469 struct {
1470 union smb_handle file;
1471 uint8_t oplock_level;
1472 uint32_t create_action;
1473 NTTIME create_time;
1474 NTTIME access_time;
1475 NTTIME write_time;
1476 NTTIME change_time;
1477 uint32_t attrib;
1478 uint64_t alloc_size;
1479 uint64_t size;
1480 uint16_t file_type;
1481 uint16_t ipc_state;
1482 uint8_t is_directory;
1484 /* optional return values matching SMB2 tagged
1485 values in the call */
1486 uint32_t maximal_access;
1487 uint8_t on_disk_id[32];
1488 } out;
1489 } ntcreatex, nttrans, generic;
1491 /* TRANS2_OPEN interface */
1492 struct {
1493 enum smb_open_level level;
1494 struct {
1495 uint16_t flags;
1496 uint16_t open_mode;
1497 uint16_t search_attrs;
1498 uint16_t file_attrs;
1499 time_t write_time;
1500 uint16_t open_func;
1501 uint32_t size;
1502 uint32_t timeout;
1503 const char *fname;
1504 unsigned int num_eas;
1505 struct ea_struct *eas;
1506 } in;
1507 struct {
1508 union smb_handle file;
1509 uint16_t attrib;
1510 time_t write_time;
1511 uint32_t size;
1512 uint16_t access;
1513 uint16_t ftype;
1514 uint16_t devstate;
1515 uint16_t action;
1516 uint32_t file_id;
1517 } out;
1518 } t2open;
1520 /* SMBopen interface */
1521 struct {
1522 enum smb_open_level level;
1523 struct {
1524 uint16_t open_mode;
1525 uint16_t search_attrs;
1526 const char *fname;
1527 } in;
1528 struct {
1529 union smb_handle file;
1530 uint16_t attrib;
1531 time_t write_time;
1532 uint32_t size;
1533 uint16_t rmode;
1534 } out;
1535 } openold;
1537 /* SMBopenX interface */
1538 struct {
1539 enum smb_open_level level;
1540 struct {
1541 uint16_t flags;
1542 uint16_t open_mode;
1543 uint16_t search_attrs; /* not honoured by win2003 */
1544 uint16_t file_attrs;
1545 time_t write_time; /* not honoured by win2003 */
1546 uint16_t open_func;
1547 uint32_t size; /* note that this sets the
1548 initial file size, not
1549 just allocation size */
1550 uint32_t timeout; /* not honoured by win2003 */
1551 const char *fname;
1552 } in;
1553 struct {
1554 union smb_handle file;
1555 uint16_t attrib;
1556 time_t write_time;
1557 uint32_t size;
1558 uint16_t access;
1559 uint16_t ftype;
1560 uint16_t devstate;
1561 uint16_t action;
1562 uint32_t unique_fid;
1563 uint32_t access_mask;
1564 uint32_t unknown;
1565 } out;
1566 } openx;
1568 /* SMBmknew interface */
1569 struct {
1570 enum smb_open_level level;
1571 struct {
1572 uint16_t attrib;
1573 time_t write_time;
1574 const char *fname;
1575 } in;
1576 struct {
1577 union smb_handle file;
1578 } out;
1579 } mknew, create;
1581 /* SMBctemp interface */
1582 struct {
1583 enum smb_open_level level;
1584 struct {
1585 uint16_t attrib;
1586 time_t write_time;
1587 const char *directory;
1588 } in;
1589 struct {
1590 union smb_handle file;
1591 /* temp name, relative to directory */
1592 char *name;
1593 } out;
1594 } ctemp;
1596 /* SMBsplopen interface */
1597 struct {
1598 enum smb_open_level level;
1599 struct {
1600 uint16_t setup_length;
1601 uint16_t mode;
1602 const char *ident;
1603 } in;
1604 struct {
1605 union smb_handle file;
1606 } out;
1607 } splopen;
1610 /* chained OpenX/ReadX interface */
1611 struct {
1612 enum smb_open_level level;
1613 struct {
1614 uint16_t flags;
1615 uint16_t open_mode;
1616 uint16_t search_attrs; /* not honoured by win2003 */
1617 uint16_t file_attrs;
1618 time_t write_time; /* not honoured by win2003 */
1619 uint16_t open_func;
1620 uint32_t size; /* note that this sets the
1621 initial file size, not
1622 just allocation size */
1623 uint32_t timeout; /* not honoured by win2003 */
1624 const char *fname;
1626 /* readx part */
1627 uint64_t offset;
1628 uint16_t mincnt;
1629 uint32_t maxcnt;
1630 uint16_t remaining;
1631 } in;
1632 struct {
1633 union smb_handle file;
1634 uint16_t attrib;
1635 time_t write_time;
1636 uint32_t size;
1637 uint16_t access;
1638 uint16_t ftype;
1639 uint16_t devstate;
1640 uint16_t action;
1641 uint32_t unique_fid;
1642 uint32_t access_mask;
1643 uint32_t unknown;
1645 /* readx part */
1646 uint8_t *data;
1647 uint16_t remaining;
1648 uint16_t compaction_mode;
1649 uint16_t nread;
1650 } out;
1651 } openxreadx;
1653 /* chained NTCreateX/ReadX interface */
1654 struct {
1655 enum smb_open_level level;
1656 struct {
1657 uint32_t flags;
1658 union smb_handle root_fid;
1659 uint32_t access_mask;
1660 uint64_t alloc_size;
1661 uint32_t file_attr;
1662 uint32_t share_access;
1663 uint32_t open_disposition;
1664 uint32_t create_options;
1665 uint32_t impersonation;
1666 uint8_t security_flags;
1667 /* NOTE: fname can also be a pointer to a
1668 uint64_t file_id if create_options has the
1669 NTCREATEX_OPTIONS_OPEN_BY_FILE_ID flag set */
1670 const char *fname;
1672 /* readx part */
1673 uint64_t offset;
1674 uint16_t mincnt;
1675 uint32_t maxcnt;
1676 uint16_t remaining;
1677 } in;
1678 struct {
1679 union smb_handle file;
1680 uint8_t oplock_level;
1681 uint32_t create_action;
1682 NTTIME create_time;
1683 NTTIME access_time;
1684 NTTIME write_time;
1685 NTTIME change_time;
1686 uint32_t attrib;
1687 uint64_t alloc_size;
1688 uint64_t size;
1689 uint16_t file_type;
1690 uint16_t ipc_state;
1691 uint8_t is_directory;
1693 /* readx part */
1694 uint8_t *data;
1695 uint16_t remaining;
1696 uint16_t compaction_mode;
1697 uint16_t nread;
1698 } out;
1699 } ntcreatexreadx;
1701 #define SMB2_CREATE_FLAG_REQUEST_OPLOCK 0x0100
1702 #define SMB2_CREATE_FLAG_REQUEST_EXCLUSIVE_OPLOCK 0x0800
1703 #define SMB2_CREATE_FLAG_GRANT_OPLOCK 0x0001
1704 #define SMB2_CREATE_FLAG_GRANT_EXCLUSIVE_OPLOCK 0x0080
1706 /* SMB2 Create */
1707 struct smb2_create {
1708 enum smb_open_level level;
1709 struct {
1710 /* static body buffer 56 (0x38) bytes */
1711 uint8_t security_flags; /* SMB2_SECURITY_* */
1712 uint8_t oplock_level; /* SMB2_OPLOCK_LEVEL_* */
1713 uint32_t impersonation_level; /* SMB2_IMPERSONATION_* */
1714 uint64_t create_flags;
1715 uint64_t reserved;
1716 uint32_t desired_access;
1717 uint32_t file_attributes;
1718 uint32_t share_access; /* NTCREATEX_SHARE_ACCESS_* */
1719 uint32_t create_disposition; /* NTCREATEX_DISP_* */
1720 uint32_t create_options; /* NTCREATEX_OPTIONS_* */
1722 /* uint16_t fname_ofs */
1723 /* uint16_t fname_size */
1724 /* uint32_t blob_ofs; */
1725 /* uint32_t blob_size; */
1727 /* dynamic body */
1728 const char *fname;
1730 /* now some optional parameters - encoded as tagged blobs */
1731 struct smb_ea_list eas;
1732 uint64_t alloc_size;
1733 struct security_descriptor *sec_desc;
1734 bool durable_open;
1735 struct smb2_handle *durable_handle;
1737 /* data for durable handle v2 */
1738 bool durable_open_v2;
1739 struct GUID create_guid;
1740 bool persistent_open;
1741 uint32_t timeout;
1742 struct smb2_handle *durable_handle_v2;
1744 bool query_maximal_access;
1745 NTTIME timewarp;
1746 bool query_on_disk_id;
1747 struct smb2_lease *lease_request;
1748 struct smb2_lease *lease_request_v2;
1750 struct GUID *app_instance_id;
1752 /* and any additional blobs the caller wants */
1753 struct smb2_create_blobs blobs;
1754 } in;
1755 struct {
1756 union smb_handle file;
1758 /* static body buffer 88 (0x58) bytes */
1759 /* uint16_t buffer_code; 0x59 = 0x58 + 1 */
1760 uint8_t oplock_level;
1761 uint8_t reserved;
1762 uint32_t create_action;
1763 NTTIME create_time;
1764 NTTIME access_time;
1765 NTTIME write_time;
1766 NTTIME change_time;
1767 uint64_t alloc_size;
1768 uint64_t size;
1769 uint32_t file_attr;
1770 uint32_t reserved2;
1771 /* struct smb2_handle handle;*/
1772 /* uint32_t blob_ofs; */
1773 /* uint32_t blob_size; */
1775 /* optional return values matching tagged values in the call */
1776 uint32_t maximal_access_status;
1777 uint32_t maximal_access;
1778 uint8_t on_disk_id[32];
1779 struct smb2_lease lease_response;
1780 struct smb2_lease lease_response_v2;
1781 bool durable_open;
1783 /* durable handle v2 */
1784 bool durable_open_v2;
1785 bool persistent_open;
1786 uint32_t timeout;
1788 /* tagged blobs in the reply */
1789 struct smb2_create_blobs blobs;
1790 } out;
1791 } smb2;
1796 enum smb_read_level {
1797 RAW_READ_READBRAW,
1798 RAW_READ_LOCKREAD,
1799 RAW_READ_READ,
1800 RAW_READ_READX,
1801 RAW_READ_SMB2
1804 #define RAW_READ_GENERIC RAW_READ_READX
1806 /* union for read() backend call
1808 note that .infoX.out.data will be allocated before the backend is
1809 called. It will be big enough to hold the maximum size asked for
1811 union smb_read {
1812 /* SMBreadX (and generic) interface */
1813 struct {
1814 enum smb_read_level level;
1815 struct {
1816 union smb_handle file;
1817 uint64_t offset;
1818 uint32_t mincnt; /* enforced on SMB2, 16 bit on SMB */
1819 uint32_t maxcnt;
1820 uint16_t remaining;
1821 bool read_for_execute;
1822 } in;
1823 struct {
1824 uint8_t *data;
1825 uint16_t remaining;
1826 uint16_t compaction_mode;
1827 uint32_t nread;
1828 uint16_t flags2;
1829 uint16_t data_offset;
1830 } out;
1831 } readx, generic;
1833 /* SMBreadbraw interface */
1834 struct {
1835 enum smb_read_level level;
1836 struct {
1837 union smb_handle file;
1838 uint64_t offset;
1839 uint16_t maxcnt;
1840 uint16_t mincnt;
1841 uint32_t timeout;
1842 } in;
1843 struct {
1844 uint8_t *data;
1845 uint32_t nread;
1846 } out;
1847 } readbraw;
1850 /* SMBlockandread interface */
1851 struct {
1852 enum smb_read_level level;
1853 struct {
1854 union smb_handle file;
1855 uint16_t count;
1856 uint32_t offset;
1857 uint16_t remaining;
1858 } in;
1859 struct {
1860 uint8_t *data;
1861 uint16_t nread;
1862 } out;
1863 } lockread;
1865 /* SMBread interface */
1866 struct {
1867 enum smb_read_level level;
1868 struct {
1869 union smb_handle file;
1870 uint16_t count;
1871 uint32_t offset;
1872 uint16_t remaining;
1873 } in;
1874 struct {
1875 uint8_t *data;
1876 uint16_t nread;
1877 } out;
1878 } read;
1880 /* SMB2 Read */
1881 struct smb2_read {
1882 enum smb_read_level level;
1883 struct {
1884 union smb_handle file;
1886 /* static body buffer 48 (0x30) bytes */
1887 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
1888 uint8_t _pad;
1889 uint8_t reserved;
1890 uint32_t length;
1891 uint64_t offset;
1892 /* struct smb2_handle handle; */
1893 uint32_t min_count;
1894 uint32_t channel;
1895 uint32_t remaining;
1896 /* the docs give no indication of what
1897 these channel variables are for */
1898 uint16_t channel_offset;
1899 uint16_t channel_length;
1900 } in;
1901 struct {
1902 /* static body buffer 16 (0x10) bytes */
1903 /* uint16_t buffer_code; 0x11 = 0x10 + 1 */
1904 /* uint8_t data_ofs; */
1905 /* uint8_t reserved; */
1906 /* uint32_t data_size; */
1907 uint32_t remaining;
1908 uint32_t reserved;
1910 /* dynamic body */
1911 DATA_BLOB data;
1912 } out;
1913 } smb2;
1917 enum smb_write_level {
1918 RAW_WRITE_WRITEUNLOCK,
1919 RAW_WRITE_WRITE,
1920 RAW_WRITE_WRITEX,
1921 RAW_WRITE_WRITECLOSE,
1922 RAW_WRITE_SPLWRITE,
1923 RAW_WRITE_SMB2
1926 #define RAW_WRITE_GENERIC RAW_WRITE_WRITEX
1928 /* union for write() backend call
1930 union smb_write {
1931 /* SMBwriteX interface */
1932 struct {
1933 enum smb_write_level level;
1934 struct {
1935 union smb_handle file;
1936 uint64_t offset;
1937 uint16_t wmode;
1938 uint16_t remaining;
1939 uint32_t count;
1940 const uint8_t *data;
1941 } in;
1942 struct {
1943 uint32_t nwritten;
1944 uint16_t remaining;
1945 } out;
1946 } writex, generic;
1948 /* SMBwriteunlock interface */
1949 struct {
1950 enum smb_write_level level;
1951 struct {
1952 union smb_handle file;
1953 uint16_t count;
1954 uint32_t offset;
1955 uint16_t remaining;
1956 const uint8_t *data;
1957 } in;
1958 struct {
1959 uint32_t nwritten;
1960 } out;
1961 } writeunlock;
1963 /* SMBwrite interface */
1964 struct {
1965 enum smb_write_level level;
1966 struct {
1967 union smb_handle file;
1968 uint16_t count;
1969 uint32_t offset;
1970 uint16_t remaining;
1971 const uint8_t *data;
1972 } in;
1973 struct {
1974 uint16_t nwritten;
1975 } out;
1976 } write;
1978 /* SMBwriteclose interface */
1979 struct {
1980 enum smb_write_level level;
1981 struct {
1982 union smb_handle file;
1983 uint16_t count;
1984 uint32_t offset;
1985 time_t mtime;
1986 const uint8_t *data;
1987 } in;
1988 struct {
1989 uint16_t nwritten;
1990 } out;
1991 } writeclose;
1993 /* SMBsplwrite interface */
1994 struct {
1995 enum smb_write_level level;
1996 struct {
1997 union smb_handle file;
1998 uint16_t count;
1999 const uint8_t *data;
2000 } in;
2001 } splwrite;
2003 /* SMB2 Write */
2004 struct smb2_write {
2005 enum smb_write_level level;
2006 struct {
2007 union smb_handle file;
2009 /* static body buffer 48 (0x30) bytes */
2010 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
2011 /* uint16_t data_ofs; */
2012 /* uint32_t data_size; */
2013 uint64_t offset;
2014 /* struct smb2_handle handle; */
2015 uint64_t unknown1; /* 0xFFFFFFFFFFFFFFFF */
2016 uint64_t unknown2; /* 0xFFFFFFFFFFFFFFFF */
2018 /* dynamic body */
2019 DATA_BLOB data;
2020 } in;
2021 struct {
2022 /* static body buffer 17 (0x11) bytes */
2023 /* uint16_t buffer_code; 0x11 = 0x10 + 1*/
2024 uint16_t _pad;
2025 uint32_t nwritten;
2026 uint64_t unknown1; /* 0x0000000000000000 */
2027 } out;
2028 } smb2;
2032 enum smb_lock_level {
2033 RAW_LOCK_LOCK,
2034 RAW_LOCK_UNLOCK,
2035 RAW_LOCK_LOCKX,
2036 RAW_LOCK_SMB2,
2037 RAW_LOCK_SMB2_BREAK
2040 #define RAW_LOCK_GENERIC RAW_LOCK_LOCKX
2042 /* union for lock() backend call
2044 union smb_lock {
2045 /* SMBlockingX and generic interface */
2046 struct {
2047 enum smb_lock_level level;
2048 struct {
2049 union smb_handle file;
2050 uint16_t mode;
2051 uint32_t timeout;
2052 uint16_t ulock_cnt;
2053 uint16_t lock_cnt;
2054 struct smb_lock_entry {
2055 uint32_t pid; /* 16 bits in SMB1 */
2056 uint64_t offset;
2057 uint64_t count;
2058 } *locks; /* unlocks are first in the arrray */
2059 } in;
2060 } generic, lockx;
2062 /* SMBlock and SMBunlock interface */
2063 struct {
2064 enum smb_lock_level level;
2065 struct {
2066 union smb_handle file;
2067 uint32_t count;
2068 uint32_t offset;
2069 } in;
2070 } lock, unlock;
2072 /* SMB2 Lock */
2073 struct smb2_lock {
2074 enum smb_lock_level level;
2075 struct {
2076 union smb_handle file;
2078 /* static body buffer 48 (0x30) bytes */
2079 /* uint16_t buffer_code; 0x30 */
2080 uint16_t lock_count;
2081 uint32_t lock_sequence;
2082 /* struct smb2_handle handle; */
2083 struct smb2_lock_element *locks;
2084 } in;
2085 struct {
2086 /* static body buffer 4 (0x04) bytes */
2087 /* uint16_t buffer_code; 0x04 */
2088 uint16_t reserved;
2089 } out;
2090 } smb2;
2092 /* SMB2 Break */
2093 struct smb2_break {
2094 enum smb_lock_level level;
2095 struct {
2096 union smb_handle file;
2098 /* static body buffer 24 (0x18) bytes */
2099 uint8_t oplock_level;
2100 uint8_t reserved;
2101 uint32_t reserved2;
2102 /* struct smb2_handle handle; */
2103 } in, out;
2104 } smb2_break;
2106 /* SMB2 Lease Break Ack (same opcode as smb2_break) */
2107 struct smb2_lease_break_ack {
2108 struct {
2109 uint32_t reserved;
2110 struct smb2_lease lease;
2111 } in, out;
2112 } smb2_lease_break_ack;
2116 enum smb_close_level {
2117 RAW_CLOSE_CLOSE,
2118 RAW_CLOSE_SPLCLOSE,
2119 RAW_CLOSE_SMB2,
2120 RAW_CLOSE_GENERIC,
2124 union for close() backend call
2126 union smb_close {
2127 /* generic interface */
2128 struct {
2129 enum smb_close_level level;
2130 struct {
2131 union smb_handle file;
2132 time_t write_time;
2133 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
2134 } in;
2135 struct {
2136 uint16_t flags;
2137 NTTIME create_time;
2138 NTTIME access_time;
2139 NTTIME write_time;
2140 NTTIME change_time;
2141 uint64_t alloc_size;
2142 uint64_t size;
2143 uint32_t file_attr;
2144 } out;
2145 } generic;
2147 /* SMBclose interface */
2148 struct {
2149 enum smb_close_level level;
2150 struct {
2151 union smb_handle file;
2152 time_t write_time;
2153 } in;
2154 } close;
2156 /* SMBsplclose interface - empty! */
2157 struct {
2158 enum smb_close_level level;
2159 struct {
2160 union smb_handle file;
2161 } in;
2162 } splclose;
2164 /* SMB2 Close */
2165 struct smb2_close {
2166 enum smb_close_level level;
2167 struct {
2168 union smb_handle file;
2170 /* static body buffer 24 (0x18) bytes */
2171 /* uint16_t buffer_code; 0x18 */
2172 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
2173 uint32_t _pad;
2174 } in;
2175 struct {
2176 /* static body buffer 60 (0x3C) bytes */
2177 /* uint16_t buffer_code; 0x3C */
2178 uint16_t flags;
2179 uint32_t _pad;
2180 NTTIME create_time;
2181 NTTIME access_time;
2182 NTTIME write_time;
2183 NTTIME change_time;
2184 uint64_t alloc_size;
2185 uint64_t size;
2186 uint32_t file_attr;
2187 } out;
2188 } smb2;
2192 enum smb_lpq_level {RAW_LPQ_GENERIC, RAW_LPQ_RETQ};
2195 union for lpq() backend
2197 union smb_lpq {
2198 /* generic interface */
2199 struct {
2200 enum smb_lpq_level level;
2202 } generic;
2205 /* SMBsplretq interface */
2206 struct {
2207 enum smb_lpq_level level;
2209 struct {
2210 uint16_t maxcount;
2211 uint16_t startidx;
2212 } in;
2213 struct {
2214 uint16_t count;
2215 uint16_t restart_idx;
2216 struct {
2217 time_t time;
2218 uint8_t status;
2219 uint16_t job;
2220 uint32_t size;
2221 char *user;
2222 } *queue;
2223 } out;
2224 } retq;
2227 enum smb_ioctl_level {
2228 RAW_IOCTL_IOCTL,
2229 RAW_IOCTL_NTIOCTL,
2230 RAW_IOCTL_SMB2,
2231 RAW_IOCTL_SMB2_NO_HANDLE
2235 union for ioctl() backend
2237 union smb_ioctl {
2238 /* generic interface */
2239 struct {
2240 enum smb_ioctl_level level;
2241 struct {
2242 union smb_handle file;
2243 } in;
2244 } generic;
2246 /* struct for SMBioctl */
2247 struct {
2248 enum smb_ioctl_level level;
2249 struct {
2250 union smb_handle file;
2251 uint32_t request;
2252 } in;
2253 struct {
2254 DATA_BLOB blob;
2255 } out;
2256 } ioctl;
2259 /* struct for NT ioctl call */
2260 struct {
2261 enum smb_ioctl_level level;
2262 struct {
2263 union smb_handle file;
2264 uint32_t function;
2265 bool fsctl;
2266 uint8_t filter;
2267 uint32_t max_data;
2268 DATA_BLOB blob;
2269 } in;
2270 struct {
2271 DATA_BLOB blob;
2272 } out;
2273 } ntioctl;
2275 /* SMB2 Ioctl */
2276 struct smb2_ioctl {
2277 enum smb_ioctl_level level;
2278 struct {
2279 union smb_handle file;
2281 /* static body buffer 56 (0x38) bytes */
2282 /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
2283 uint16_t reserved;
2284 uint32_t function;
2285 /*struct smb2_handle handle;*/
2286 /* uint32_t out_ofs; */
2287 /* uint32_t out_size; */
2288 uint32_t max_input_response;
2289 /* uint32_t in_ofs; */
2290 /* uint32_t in_size; */
2291 uint32_t max_output_response;
2292 uint32_t flags;
2293 uint32_t reserved2;
2295 /* dynamic body */
2296 DATA_BLOB out;
2297 DATA_BLOB in;
2298 } in;
2299 struct {
2300 union smb_handle file;
2302 /* static body buffer 48 (0x30) bytes */
2303 /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
2304 uint16_t reserved;
2305 uint32_t function;
2306 /* struct smb2_handle handle; */
2307 /* uint32_t in_ofs; */
2308 /* uint32_t in_size; */
2309 /* uint32_t out_ofs; */
2310 /* uint32_t out_size; */
2311 uint32_t flags;
2312 uint32_t reserved2;
2314 /* dynamic body */
2315 DATA_BLOB in;
2316 DATA_BLOB out;
2317 } out;
2318 } smb2;
2321 enum smb_flush_level {
2322 RAW_FLUSH_FLUSH,
2323 RAW_FLUSH_ALL,
2324 RAW_FLUSH_SMB2
2327 union smb_flush {
2328 /* struct for SMBflush */
2329 struct {
2330 enum smb_flush_level level;
2331 struct {
2332 union smb_handle file;
2333 } in;
2334 } flush, generic;
2336 /* SMBflush with 0xFFFF wildcard fnum */
2337 struct {
2338 enum smb_flush_level level;
2339 } flush_all;
2341 /* SMB2 Flush */
2342 struct smb2_flush {
2343 enum smb_flush_level level;
2344 struct {
2345 union smb_handle file;
2346 uint16_t reserved1;
2347 uint32_t reserved2;
2348 } in;
2349 struct {
2350 uint16_t reserved;
2351 } out;
2352 } smb2;
2355 /* struct for SMBcopy */
2356 struct smb_copy {
2357 struct {
2358 uint16_t tid2;
2359 uint16_t ofun;
2360 uint16_t flags;
2361 const char *path1;
2362 const char *path2;
2363 } in;
2364 struct {
2365 uint16_t count;
2366 } out;
2370 /* struct for transact/transact2 call */
2371 struct smb_trans2 {
2372 struct {
2373 uint16_t max_param;
2374 uint16_t max_data;
2375 uint8_t max_setup;
2376 uint16_t flags;
2377 uint32_t timeout;
2378 uint8_t setup_count;
2379 uint16_t *setup;
2380 const char *trans_name; /* SMBtrans only */
2381 DATA_BLOB params;
2382 DATA_BLOB data;
2383 } in;
2385 struct {
2386 uint8_t setup_count;
2387 uint16_t *setup;
2388 DATA_BLOB params;
2389 DATA_BLOB data;
2390 } out;
2393 /* struct for nttransact2 call */
2394 struct smb_nttrans {
2395 struct {
2396 uint8_t max_setup;
2397 uint32_t max_param;
2398 uint32_t max_data;
2399 uint8_t setup_count;
2400 uint16_t function;
2401 uint8_t *setup;
2402 DATA_BLOB params;
2403 DATA_BLOB data;
2404 } in;
2406 struct {
2407 uint8_t setup_count; /* in units of 16 bit words */
2408 uint8_t *setup;
2409 DATA_BLOB params;
2410 DATA_BLOB data;
2411 } out;
2414 enum smb_notify_level {
2415 RAW_NOTIFY_NTTRANS,
2416 RAW_NOTIFY_SMB2
2419 union smb_notify {
2420 /* struct for nttrans change notify call */
2421 struct {
2422 enum smb_notify_level level;
2424 struct {
2425 union smb_handle file;
2426 uint32_t buffer_size;
2427 uint32_t completion_filter;
2428 bool recursive;
2429 } in;
2431 struct {
2432 uint32_t num_changes;
2433 struct notify_changes {
2434 uint32_t action;
2435 struct smb_wire_string name;
2436 } *changes;
2437 } out;
2438 } nttrans;
2440 struct smb2_notify {
2441 enum smb_notify_level level;
2443 struct {
2444 union smb_handle file;
2445 /* static body buffer 32 (0x20) bytes */
2446 /* uint16_t buffer_code; 0x32 */
2447 uint16_t recursive;
2448 uint32_t buffer_size;
2449 /*struct smb2_handle file;*/
2450 uint32_t completion_filter;
2451 uint32_t unknown;
2452 } in;
2454 struct {
2455 /* static body buffer 8 (0x08) bytes */
2456 /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
2457 /* uint16_t blob_ofs; */
2458 /* uint16_t blob_size; */
2460 /* dynamic body */
2461 /*DATA_BLOB blob;*/
2463 /* DATA_BLOB content */
2464 uint32_t num_changes;
2465 struct notify_changes *changes;
2466 } out;
2467 } smb2;
2470 enum smb_search_level {
2471 RAW_SEARCH_SEARCH, /* SMBsearch */
2472 RAW_SEARCH_FFIRST, /* SMBffirst */
2473 RAW_SEARCH_FUNIQUE, /* SMBfunique */
2474 RAW_SEARCH_TRANS2, /* SMBtrans2 */
2475 RAW_SEARCH_SMB2 /* SMB2 Find */
2478 enum smb_search_data_level {
2479 RAW_SEARCH_DATA_GENERIC = 0x10000, /* only used in the smbcli_ code */
2480 RAW_SEARCH_DATA_SEARCH,
2481 RAW_SEARCH_DATA_STANDARD = SMB_FIND_STANDARD,
2482 RAW_SEARCH_DATA_EA_SIZE = SMB_FIND_EA_SIZE,
2483 RAW_SEARCH_DATA_EA_LIST = SMB_FIND_EA_LIST,
2484 RAW_SEARCH_DATA_DIRECTORY_INFO = SMB_FIND_DIRECTORY_INFO,
2485 RAW_SEARCH_DATA_FULL_DIRECTORY_INFO = SMB_FIND_FULL_DIRECTORY_INFO,
2486 RAW_SEARCH_DATA_NAME_INFO = SMB_FIND_NAME_INFO,
2487 RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO = SMB_FIND_BOTH_DIRECTORY_INFO,
2488 RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO = SMB_FIND_ID_FULL_DIRECTORY_INFO,
2489 RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
2490 RAW_SEARCH_DATA_UNIX_INFO = SMB_FIND_UNIX_INFO,
2491 RAW_SEARCH_DATA_UNIX_INFO2 = SMB_FIND_UNIX_INFO2
2494 /* union for file search */
2495 union smb_search_first {
2496 struct {
2497 enum smb_search_level level;
2498 enum smb_search_data_level data_level;
2499 } generic;
2501 /* search (old) findfirst interface.
2502 Also used for ffirst and funique. */
2503 struct {
2504 enum smb_search_level level;
2505 enum smb_search_data_level data_level;
2507 struct {
2508 uint16_t max_count;
2509 uint16_t search_attrib;
2510 const char *pattern;
2511 } in;
2512 struct {
2513 int16_t count;
2514 } out;
2515 } search_first;
2517 /* trans2 findfirst interface */
2518 struct {
2519 enum smb_search_level level;
2520 enum smb_search_data_level data_level;
2522 struct {
2523 uint16_t search_attrib;
2524 uint16_t max_count;
2525 uint16_t flags;
2526 uint32_t storage_type;
2527 const char *pattern;
2529 /* the ea names are only used for RAW_SEARCH_EA_LIST */
2530 unsigned int num_names;
2531 struct ea_name *ea_names;
2532 } in;
2533 struct {
2534 uint16_t handle;
2535 uint16_t count;
2536 uint16_t end_of_search;
2537 } out;
2538 } t2ffirst;
2540 /* SMB2 Find */
2541 struct smb2_find {
2542 enum smb_search_level level;
2543 enum smb_search_data_level data_level;
2544 struct {
2545 union smb_handle file;
2547 /* static body buffer 32 (0x20) bytes */
2548 /* uint16_t buffer_code; 0x21 = 0x20 + 1 */
2549 uint8_t level;
2550 uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */
2551 uint32_t file_index;
2552 /* struct smb2_handle handle; */
2553 /* uint16_t pattern_ofs; */
2554 /* uint16_t pattern_size; */
2555 uint32_t max_response_size;
2557 /* dynamic body */
2558 const char *pattern;
2559 } in;
2560 struct {
2561 /* static body buffer 8 (0x08) bytes */
2562 /* uint16_t buffer_code; 0x08 */
2563 /* uint16_t blob_ofs; */
2564 /* uint32_t blob_size; */
2566 /* dynamic body */
2567 DATA_BLOB blob;
2568 } out;
2569 } smb2;
2572 /* union for file search continue */
2573 union smb_search_next {
2574 struct {
2575 enum smb_search_level level;
2576 enum smb_search_data_level data_level;
2577 } generic;
2579 /* search (old) findnext interface. Also used
2580 for ffirst when continuing */
2581 struct {
2582 enum smb_search_level level;
2583 enum smb_search_data_level data_level;
2585 struct {
2586 uint16_t max_count;
2587 uint16_t search_attrib;
2588 struct smb_search_id {
2589 uint8_t reserved;
2590 char name[11];
2591 uint8_t handle;
2592 uint32_t server_cookie;
2593 uint32_t client_cookie;
2594 } id;
2595 } in;
2596 struct {
2597 uint16_t count;
2598 } out;
2599 } search_next;
2601 /* trans2 findnext interface */
2602 struct {
2603 enum smb_search_level level;
2604 enum smb_search_data_level data_level;
2606 struct {
2607 uint16_t handle;
2608 uint16_t max_count;
2609 uint32_t resume_key;
2610 uint16_t flags;
2611 const char *last_name;
2613 /* the ea names are only used for RAW_SEARCH_EA_LIST */
2614 unsigned int num_names;
2615 struct ea_name *ea_names;
2616 } in;
2617 struct {
2618 uint16_t count;
2619 uint16_t end_of_search;
2620 } out;
2621 } t2fnext;
2623 /* SMB2 Find */
2624 struct smb2_find smb2;
2627 /* union for search reply file data */
2628 union smb_search_data {
2630 * search (old) findfirst
2631 * RAW_SEARCH_DATA_SEARCH
2633 struct {
2634 uint16_t attrib;
2635 time_t write_time;
2636 uint32_t size;
2637 struct smb_search_id id;
2638 const char *name;
2639 } search;
2641 /* trans2 findfirst RAW_SEARCH_DATA_STANDARD level */
2642 struct {
2643 uint32_t resume_key;
2644 time_t create_time;
2645 time_t access_time;
2646 time_t write_time;
2647 uint32_t size;
2648 uint32_t alloc_size;
2649 uint16_t attrib;
2650 struct smb_wire_string name;
2651 } standard;
2653 /* trans2 findfirst RAW_SEARCH_DATA_EA_SIZE level */
2654 struct {
2655 uint32_t resume_key;
2656 time_t create_time;
2657 time_t access_time;
2658 time_t write_time;
2659 uint32_t size;
2660 uint32_t alloc_size;
2661 uint16_t attrib;
2662 uint32_t ea_size;
2663 struct smb_wire_string name;
2664 } ea_size;
2666 /* trans2 findfirst RAW_SEARCH_DATA_EA_LIST level */
2667 struct {
2668 uint32_t resume_key;
2669 time_t create_time;
2670 time_t access_time;
2671 time_t write_time;
2672 uint32_t size;
2673 uint32_t alloc_size;
2674 uint16_t attrib;
2675 struct smb_ea_list eas;
2676 struct smb_wire_string name;
2677 } ea_list;
2679 /* RAW_SEARCH_DATA_DIRECTORY_INFO interface */
2680 struct {
2681 uint32_t file_index;
2682 NTTIME create_time;
2683 NTTIME access_time;
2684 NTTIME write_time;
2685 NTTIME change_time;
2686 uint64_t size;
2687 uint64_t alloc_size;
2688 uint32_t attrib;
2689 struct smb_wire_string name;
2690 } directory_info;
2692 /* RAW_SEARCH_DATA_FULL_DIRECTORY_INFO interface */
2693 struct {
2694 uint32_t file_index;
2695 NTTIME create_time;
2696 NTTIME access_time;
2697 NTTIME write_time;
2698 NTTIME change_time;
2699 uint64_t size;
2700 uint64_t alloc_size;
2701 uint32_t attrib;
2702 uint32_t ea_size;
2703 struct smb_wire_string name;
2704 } full_directory_info;
2706 /* RAW_SEARCH_DATA_NAME_INFO interface */
2707 struct {
2708 uint32_t file_index;
2709 struct smb_wire_string name;
2710 } name_info;
2712 /* RAW_SEARCH_DATA_BOTH_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 struct smb_wire_string short_name;
2724 struct smb_wire_string name;
2725 } both_directory_info;
2727 /* RAW_SEARCH_DATA_ID_FULL_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 name;
2740 } id_full_directory_info;
2742 /* RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO interface */
2743 struct {
2744 uint32_t file_index;
2745 NTTIME create_time;
2746 NTTIME access_time;
2747 NTTIME write_time;
2748 NTTIME change_time;
2749 uint64_t size;
2750 uint64_t alloc_size;
2751 uint32_t attrib;
2752 uint32_t ea_size;
2753 uint64_t file_id;
2754 uint8_t short_name_buf[24];
2755 struct smb_wire_string short_name;
2756 struct smb_wire_string name;
2757 } id_both_directory_info;
2759 /* RAW_SEARCH_DATA_UNIX_INFO interface */
2760 struct {
2761 uint32_t file_index;
2762 uint64_t size;
2763 uint64_t alloc_size;
2764 NTTIME status_change_time;
2765 NTTIME access_time;
2766 NTTIME change_time;
2767 uint64_t uid;
2768 uint64_t gid;
2769 uint32_t file_type;
2770 uint64_t dev_major;
2771 uint64_t dev_minor;
2772 uint64_t unique_id;
2773 uint64_t permissions;
2774 uint64_t nlink;
2775 const char *name;
2776 } unix_info;
2778 /* RAW_SEARCH_DATA_UNIX_INFO2 interface */
2779 struct {
2780 uint32_t file_index;
2781 uint64_t end_of_file;
2782 uint64_t num_bytes;
2783 NTTIME status_change_time;
2784 NTTIME access_time;
2785 NTTIME change_time;
2786 uint64_t uid;
2787 uint64_t gid;
2788 uint32_t file_type;
2789 uint64_t dev_major;
2790 uint64_t dev_minor;
2791 uint64_t unique_id;
2792 uint64_t permissions;
2793 uint64_t nlink;
2794 NTTIME create_time;
2795 uint32_t file_flags;
2796 uint32_t flags_mask;
2797 struct smb_wire_string name;
2798 } unix_info2;
2801 /* Callback function passed to the raw search interface. */
2802 typedef bool (*smbcli_search_callback)(void *private_data, const union smb_search_data *file);
2804 enum smb_search_close_level {RAW_FINDCLOSE_GENERIC, RAW_FINDCLOSE_FCLOSE, RAW_FINDCLOSE_FINDCLOSE};
2806 /* union for file search close */
2807 union smb_search_close {
2808 struct {
2809 enum smb_search_close_level level;
2810 } generic;
2812 /* SMBfclose (old search) interface */
2813 struct {
2814 enum smb_search_close_level level;
2816 struct {
2817 /* max_count and search_attrib are not used, but are present */
2818 uint16_t max_count;
2819 uint16_t search_attrib;
2820 struct smb_search_id id;
2821 } in;
2822 } fclose;
2824 /* SMBfindclose interface */
2825 struct {
2826 enum smb_search_close_level level;
2828 struct {
2829 uint16_t handle;
2830 } in;
2831 } findclose;
2836 struct for SMBecho call
2838 struct smb_echo {
2839 struct {
2840 uint16_t repeat_count;
2841 uint16_t size;
2842 uint8_t *data;
2843 } in;
2844 struct {
2845 uint16_t count;
2846 uint16_t sequence_number;
2847 uint16_t size;
2848 uint8_t *data;
2849 } out;
2853 struct for shadow copy volumes
2855 struct smb_shadow_copy {
2856 struct {
2857 union smb_handle file;
2858 uint32_t max_data;
2859 } in;
2860 struct {
2861 uint32_t num_volumes;
2862 uint32_t num_names;
2863 const char **names;
2864 } out;
2867 #endif /* __LIBCLI_RAW_INTERFACES_H__ */