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