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