771dce8803b5bb860a954b5fc5ac25daadd321a0
[samba.git] / source4 / include / smb_interfaces.h
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    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22
23 /* Globally Unique ID */
24 #define GUID_SIZE 16
25
26 /* 64 bit time (100 nanosec) 1601 - cifs6.txt, section 3.5, page 30 */
27 typedef uint64_t NTTIME;
28
29 /* 8 byte aligned 'hyper' type from MS IDL */
30 typedef uint64_t HYPER_T;
31
32
33
34 /* this structure is just a wrapper for a string, the only reason we
35    bother with this is that it allows us to check the length provided
36    on the wire in testsuite test code to ensure that we are
37    terminating names in the same way that win2003 is. The *ONLY* time
38    you should ever look at the 'private_length' field in this
39    structure is inside compliance test code, in all other cases just
40    use the null terminated char* as the definitive definition of the
41    string
42
43    also note that this structure is only used in packets where there
44    is an explicit length provided on the wire (hence the name). That
45    length is placed in 'private_length'. For packets where the length
46    is always determined by NULL or packet termination a normal char*
47    is used in the structure definition.
48  */
49 typedef struct {
50         uint32_t private_length;
51         const char *s;
52 } WIRE_STRING;
53
54
55 /*
56   this header defines the structures and unions used between the SMB
57   parser and the backends.
58 */
59
60 /* struct used for SMBlseek call */
61 struct smb_seek {
62         struct {
63                 uint16_t fnum;
64                 uint16_t mode;
65                 int32_t  offset; /* signed */
66         } in;
67         struct {
68                 int32_t offset;
69         } out;
70 };
71
72
73 /* struct used in unlink() call */
74 struct smb_unlink {
75         struct {
76                 const char *pattern;
77                 uint16_t attrib;
78         } in;
79 };
80
81
82 /* struct used in chkpath() call */
83 struct smb_chkpath {
84         struct {
85                 const char *path;
86         } in;
87 };
88
89 enum smb_mkdir_level {RAW_MKDIR_GENERIC, RAW_MKDIR_MKDIR, RAW_MKDIR_T2MKDIR};
90
91 /* union used in mkdir() call */
92 union smb_mkdir {
93         /* generic level */
94         struct {
95                 enum smb_mkdir_level level;
96         } generic;
97
98         struct {
99                 enum smb_mkdir_level level;
100                 struct {
101                         const char *path;
102                 } in;
103         } mkdir;
104
105         struct {
106                 enum smb_mkdir_level level;
107                 struct {
108                         const char *path;
109                         uint_t num_eas;
110                         struct ea_struct *eas;                  
111                 } in;
112         } t2mkdir;
113 };
114
115 /* struct used in rmdir() call */
116 struct smb_rmdir {
117         struct {
118                 const char *path;
119         } in;
120 };
121
122 /* struct used in rename() call */
123 enum smb_rename_level {RAW_RENAME_RENAME, RAW_RENAME_NTRENAME};
124
125 union smb_rename {
126         struct {
127                 enum smb_rename_level level;
128         } generic;
129
130         /* SMBrename interface */
131         struct {
132                 enum smb_rename_level level;
133
134                 struct {
135                         const char *pattern1;
136                         const char *pattern2;
137                         uint16_t attrib;
138                 } in;
139         } rename;
140
141
142         /* SMBntrename interface */
143         struct {
144                 enum smb_rename_level level;
145
146                 struct {
147                         uint16_t attrib;
148                         uint16_t flags; /* see RENAME_FLAG_* */
149                         uint32_t cluster_size;
150                         const char *old_name;
151                         const char *new_name;
152                 } in;
153         } ntrename;
154 };
155
156 enum smb_tcon_level {RAW_TCON_TCON, RAW_TCON_TCONX};
157
158 /* union used in tree connect call */
159 union smb_tcon {
160         /* generic interface */
161         struct {
162                 enum smb_tcon_level level;
163         } generic;
164
165         /* SMBtcon interface */
166         struct {
167                 enum smb_tcon_level level;
168
169                 struct {
170                         const char *service;
171                         const char *password;
172                         const char *dev;
173                 } in;
174                 struct {
175                         uint16_t max_xmit;
176                         uint16_t cnum;
177                 } out;
178         } tcon;
179
180         /* SMBtconX interface */
181         struct {
182                 enum smb_tcon_level level;
183
184                 struct {
185                         uint16_t flags;
186                         DATA_BLOB password;
187                         const char *path;
188                         const char *device;
189                 } in;
190                 struct {
191                         uint16_t options;
192                         char *dev_type;
193                         char *fs_type;
194                         uint16_t cnum;
195                 } out;
196         } tconx;
197 };
198
199
200 enum smb_sesssetup_level {RAW_SESSSETUP_GENERIC, RAW_SESSSETUP_OLD, RAW_SESSSETUP_NT1, RAW_SESSSETUP_SPNEGO};
201
202 /* union used in session_setup call */
203 union smb_sesssetup {
204         
205         /* generic interface - used for auto selecting based on negotiated
206            protocol options */
207         struct {
208                 enum smb_sesssetup_level level;
209
210                 struct {
211                         uint32_t sesskey;
212                         uint32_t capabilities;
213                         const char *password;
214                         const char *user;
215                         const char *domain;
216                 } in;
217                 struct {
218                         uint16_t vuid;
219                         char *os;
220                         char *lanman;
221                         char *domain;
222                 } out;          
223         } generic;
224
225         /* the pre-NT1 interface */
226         struct {
227                 enum smb_sesssetup_level level;
228
229                 struct {
230                         uint16_t bufsize;
231                         uint16_t mpx_max;
232                         uint16_t vc_num;
233                         uint32_t sesskey;
234                         DATA_BLOB password;
235                         const char *user;
236                         const char *domain;
237                         const char *os;
238                         const char *lanman;
239                 } in;
240                 struct {
241                         uint16_t action;
242                         uint16_t vuid;
243                         char *os;
244                         char *lanman;
245                         char *domain;
246                 } out;
247         } old;
248
249         /* the NT1 interface */
250         struct {
251                 enum smb_sesssetup_level level;
252
253                 struct {
254                         uint16_t bufsize;
255                         uint16_t mpx_max;
256                         uint16_t vc_num;
257                         uint32_t sesskey;
258                         uint32_t capabilities;
259                         DATA_BLOB password1;
260                         DATA_BLOB password2;
261                         const char *user;
262                         const char *domain;
263                         const char *os;
264                         const char *lanman;
265                 } in;
266                 struct {
267                         uint16_t action;
268                         uint16_t vuid;
269                         char *os;
270                         char *lanman;
271                         char *domain;
272                 } out;
273         } nt1;
274
275
276         /* the SPNEGO interface */
277         struct {
278                 enum smb_sesssetup_level level;
279
280                 struct {
281                         uint16_t bufsize;
282                         uint16_t mpx_max;
283                         uint16_t vc_num;
284                         uint32_t sesskey;
285                         uint32_t capabilities;
286                         DATA_BLOB secblob;
287                         const char *os;
288                         const char *lanman;
289                         const char *domain;
290                 } in;
291                 struct {
292                         uint16_t action;
293                         DATA_BLOB secblob;
294                         char *os;
295                         char *lanman;
296                         char *domain;
297                         uint16_t vuid;
298                 } out;
299         } spnego;
300 };
301
302 /* Note that the specified enum values are identical to the actual info-levels used
303  * on the wire.
304  */
305 enum smb_fileinfo_level {
306                      RAW_FILEINFO_GENERIC                    = 0xF000, 
307                      RAW_FILEINFO_GETATTR,                   /* SMBgetatr */
308                      RAW_FILEINFO_GETATTRE,                  /* SMBgetattrE */
309                      RAW_FILEINFO_STANDARD                   = SMB_QFILEINFO_STANDARD,
310                      RAW_FILEINFO_EA_SIZE                    = SMB_QFILEINFO_EA_SIZE,
311                      RAW_FILEINFO_ALL_EAS                    = SMB_QFILEINFO_ALL_EAS,
312                      RAW_FILEINFO_IS_NAME_VALID              = SMB_QFILEINFO_IS_NAME_VALID,
313                      RAW_FILEINFO_BASIC_INFO                 = SMB_QFILEINFO_BASIC_INFO, 
314                      RAW_FILEINFO_STANDARD_INFO              = SMB_QFILEINFO_STANDARD_INFO,
315                      RAW_FILEINFO_EA_INFO                    = SMB_QFILEINFO_EA_INFO,
316                      RAW_FILEINFO_NAME_INFO                  = SMB_QFILEINFO_NAME_INFO, 
317                      RAW_FILEINFO_ALL_INFO                   = SMB_QFILEINFO_ALL_INFO,
318                      RAW_FILEINFO_ALT_NAME_INFO              = SMB_QFILEINFO_ALT_NAME_INFO,
319                      RAW_FILEINFO_STREAM_INFO                = SMB_QFILEINFO_STREAM_INFO,
320                      RAW_FILEINFO_COMPRESSION_INFO           = SMB_QFILEINFO_COMPRESSION_INFO,
321                      RAW_FILEINFO_UNIX_BASIC                 = SMB_QFILEINFO_UNIX_BASIC,
322                      RAW_FILEINFO_UNIX_LINK                  = SMB_QFILEINFO_UNIX_LINK,
323                      RAW_FILEINFO_BASIC_INFORMATION          = SMB_QFILEINFO_BASIC_INFORMATION,
324                      RAW_FILEINFO_STANDARD_INFORMATION       = SMB_QFILEINFO_STANDARD_INFORMATION,
325                      RAW_FILEINFO_INTERNAL_INFORMATION       = SMB_QFILEINFO_INTERNAL_INFORMATION,
326                      RAW_FILEINFO_EA_INFORMATION             = SMB_QFILEINFO_EA_INFORMATION,
327                      RAW_FILEINFO_ACCESS_INFORMATION         = SMB_QFILEINFO_ACCESS_INFORMATION,
328                      RAW_FILEINFO_NAME_INFORMATION           = SMB_QFILEINFO_NAME_INFORMATION,
329                      RAW_FILEINFO_POSITION_INFORMATION       = SMB_QFILEINFO_POSITION_INFORMATION,
330                      RAW_FILEINFO_MODE_INFORMATION           = SMB_QFILEINFO_MODE_INFORMATION,
331                      RAW_FILEINFO_ALIGNMENT_INFORMATION      = SMB_QFILEINFO_ALIGNMENT_INFORMATION,
332                      RAW_FILEINFO_ALL_INFORMATION            = SMB_QFILEINFO_ALL_INFORMATION,
333                      RAW_FILEINFO_ALT_NAME_INFORMATION       = SMB_QFILEINFO_ALT_NAME_INFORMATION,
334                      RAW_FILEINFO_STREAM_INFORMATION         = SMB_QFILEINFO_STREAM_INFORMATION,
335                      RAW_FILEINFO_COMPRESSION_INFORMATION    = SMB_QFILEINFO_COMPRESSION_INFORMATION,
336                      RAW_FILEINFO_NETWORK_OPEN_INFORMATION   = SMB_QFILEINFO_NETWORK_OPEN_INFORMATION,
337                      RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION  = SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION
338 };
339
340
341 /* union used in qfileinfo() and qpathinfo() backend calls */
342 union smb_fileinfo {
343         /* generic interface:
344          * matches RAW_FILEINFO_GENERIC */
345         struct {
346                 enum smb_fileinfo_level level;
347
348                 /* each level can be called on either a pathname or a
349                  * filename, in either case the return format is
350                  * identical */
351                 union smb_fileinfo_in {
352                         const char *fname;
353                         uint16_t fnum;
354                 } in;
355                 
356                 struct {
357                         uint32_t attrib;
358                         uint32_t ea_size;
359                         uint_t num_eas;
360                         struct ea_struct {
361                                 uint8_t flags;
362                                 WIRE_STRING name;
363                                 DATA_BLOB value;
364                         } *eas;         
365                         NTTIME create_time;
366                         NTTIME access_time;
367                         NTTIME write_time;
368                         NTTIME change_time;
369                         uint64_t alloc_size;
370                         uint64_t size;
371                         uint32_t nlink;
372                         WIRE_STRING fname;      
373                         WIRE_STRING alt_fname;  
374                         uint8_t delete_pending;
375                         uint8_t directory;
376                         uint64_t compressed_size;
377                         uint16_t format;
378                         uint8_t unit_shift;
379                         uint8_t chunk_shift;
380                         uint8_t cluster_shift;
381                         uint64_t file_id;
382                         uint32_t access_flags; /* seen 0x001f01ff from w2k3 */
383                         uint64_t position;
384                         uint32_t mode;
385                         uint32_t alignment_requirement;
386                         uint32_t reparse_tag;
387                         uint_t num_streams;
388                         struct stream_struct {
389                                 uint64_t size;
390                                 uint64_t alloc_size;
391                                 WIRE_STRING stream_name;
392                         } *streams;
393                 } out;
394         } generic;
395
396
397         /* SMBgetatr interface:
398          * matches RAW_FILEINFO_GETATTR */
399         struct {
400                 enum smb_fileinfo_level level;
401                 union smb_fileinfo_in in;
402
403                 struct {
404                         uint16_t attrib;
405                         uint32_t size;
406                         time_t write_time;
407                 } out;
408         } getattr;
409
410         /* SMBgetattrE and  RAW_FILEINFO_STANDARD interface */
411         struct {
412                 enum smb_fileinfo_level level;
413                 union smb_fileinfo_in in;
414
415                 struct {
416                         time_t create_time;
417                         time_t access_time;
418                         time_t write_time;
419                         uint32_t size;
420                         uint32_t alloc_size;
421                         uint16_t attrib;
422                 } out;
423         } getattre, standard;
424
425         /* trans2 RAW_FILEINFO_EA_SIZE interface */
426         struct {
427                 enum smb_fileinfo_level level;
428                 union smb_fileinfo_in in;
429
430                 struct {
431                         time_t create_time;
432                         time_t access_time;
433                         time_t write_time;
434                         uint32_t size;
435                         uint32_t alloc_size;
436                         uint16_t attrib;
437                         uint32_t ea_size;
438                 } out;
439         } ea_size;
440
441         /* trans2 RAW_FILEINFO_ALL_EAS interface */
442         struct {
443                 enum smb_fileinfo_level level;
444                 union smb_fileinfo_in in;
445
446                 struct {
447                         /* the ea_size is implied by the list */
448                         uint_t num_eas;
449                         struct ea_struct *eas;
450                 } out;
451         } all_eas;
452
453         /* trans2 qpathinfo RAW_FILEINFO_IS_NAME_VALID interface 
454            only valid for a QPATHNAME call - no returned data */
455         struct {
456                 enum smb_fileinfo_level level;
457                 union smb_fileinfo_in in;
458         } is_name_valid;
459
460         /* RAW_FILEINFO_BASIC_INFO and RAW_FILEINFO_BASIC_INFORMATION interfaces */
461         struct {
462                 enum smb_fileinfo_level level;
463                 union smb_fileinfo_in in;
464
465                 struct {
466                         NTTIME create_time;
467                         NTTIME access_time;
468                         NTTIME write_time;
469                         NTTIME change_time;
470                         uint32_t attrib;
471                 } out;
472         } basic_info;
473                 
474
475         /* RAW_FILEINFO_STANDARD_INFO and RAW_FILEINFO_STANDARD_INFORMATION interfaces */
476         struct {
477                 enum smb_fileinfo_level level;
478                 union smb_fileinfo_in in;
479
480                 struct {
481                         uint64_t alloc_size;
482                         uint64_t size;
483                         uint32_t nlink;
484                         BOOL delete_pending;
485                         BOOL directory;
486                 } out;
487         } standard_info;
488         
489         /* RAW_FILEINFO_EA_INFO and RAW_FILEINFO_EA_INFORMATION interfaces */
490         struct {
491                 enum smb_fileinfo_level level;
492                 union smb_fileinfo_in in;
493
494                 struct {
495                         uint32_t ea_size;
496                 } out;
497         } ea_info;
498
499         /* RAW_FILEINFO_NAME_INFO and RAW_FILEINFO_NAME_INFORMATION interfaces */
500         struct {
501                 enum smb_fileinfo_level level;
502                 union smb_fileinfo_in in;
503
504                 struct {
505                         WIRE_STRING fname;
506                 } out;
507         } name_info;
508
509         /* RAW_FILEINFO_ALL_INFO and RAW_FILEINFO_ALL_INFORMATION interfaces */
510         struct {
511                 enum smb_fileinfo_level level;
512                 union smb_fileinfo_in in;
513
514                 struct {
515                         NTTIME create_time;
516                         NTTIME access_time;
517                         NTTIME write_time;
518                         NTTIME change_time;
519                         uint32_t attrib;
520                         uint64_t alloc_size;
521                         uint64_t size;
522                         uint32_t nlink;
523                         uint8_t delete_pending;
524                         uint8_t directory;
525                         uint32_t ea_size;
526                         WIRE_STRING fname;
527                 } out;
528         } all_info;     
529
530         /* RAW_FILEINFO_ALT_NAME_INFO and RAW_FILEINFO_ALT_NAME_INFORMATION interfaces */
531         struct {
532                 enum smb_fileinfo_level level;
533                 union smb_fileinfo_in in;
534
535                 struct {
536                         WIRE_STRING fname;
537                 } out;
538         } alt_name_info;
539
540         /* RAW_FILEINFO_STREAM_INFO and RAW_FILEINFO_STREAM_INFORMATION interfaces */
541         struct {
542                 enum smb_fileinfo_level level;
543                 union smb_fileinfo_in in;
544
545                 struct {
546                         uint_t num_streams;
547                         struct stream_struct *streams;
548                 } out;
549         } stream_info;
550         
551         /* RAW_FILEINFO_COMPRESSION_INFO and RAW_FILEINFO_COMPRESSION_INFORMATION interfaces */
552         struct {
553                 enum smb_fileinfo_level level;
554                 union smb_fileinfo_in in;
555
556                 struct {
557                         uint64_t compressed_size;
558                         uint16_t format;
559                         uint8_t unit_shift;
560                         uint8_t chunk_shift;
561                         uint8_t cluster_shift;
562                 } out;
563         } compression_info;
564
565         /* RAW_FILEINFO_UNIX_BASIC interface */
566         struct {
567                 enum smb_fileinfo_level level;
568                 union smb_fileinfo_in in;
569
570                 struct {
571                         uint64_t end_of_file;
572                         uint64_t num_bytes;
573                         NTTIME status_change_time;
574                         NTTIME access_time;
575                         NTTIME change_time;
576                         uint64_t uid;
577                         uint64_t gid;
578                         uint32_t file_type;
579                         uint64_t dev_major;
580                         uint64_t dev_minor;
581                         uint64_t unique_id;
582                         uint64_t permissions;
583                         uint64_t nlink;
584                 } out;
585         } unix_basic_info;
586
587         /* RAW_FILEINFO_UNIX_LINK interface */
588         struct {
589                 enum smb_fileinfo_level level;
590                 union smb_fileinfo_in in;
591
592                 struct {
593                         WIRE_STRING link_dest;
594                 } out;
595         } unix_link_info;
596
597         /* RAW_FILEINFO_INTERNAL_INFORMATION interface */
598         struct {
599                 enum smb_fileinfo_level level;
600                 union smb_fileinfo_in in;
601
602                 struct {
603                         uint64_t file_id;
604                 } out;
605         } internal_information;
606
607         /* RAW_FILEINFO_ACCESS_INFORMATION interface */
608         struct {
609                 enum smb_fileinfo_level level;
610                 union smb_fileinfo_in in;
611
612                 struct {
613                         uint32_t access_flags; /* seen 0x001f01ff from w2k3 */
614                 } out;
615         } access_information;
616
617         /* RAW_FILEINFO_POSITION_INFORMATION interface */
618         struct {
619                 enum smb_fileinfo_level level;
620                 union smb_fileinfo_in in;
621
622                 struct {
623                         uint64_t position;
624                 } out;
625         } position_information;
626
627         /* RAW_FILEINFO_MODE_INFORMATION interface */
628         struct {
629                 enum smb_fileinfo_level level;
630                 union smb_fileinfo_in in;
631
632                 struct {
633                         uint32_t mode;
634                 } out;
635         } mode_information;
636
637         /* RAW_FILEINFO_ALIGNMENT_INFORMATION interface */
638         struct {
639                 enum smb_fileinfo_level level;
640                 union smb_fileinfo_in in;
641
642                 struct {
643                         uint32_t alignment_requirement;
644                 } out;
645         } alignment_information;
646
647         /* RAW_FILEINFO_NETWORK_OPEN_INFORMATION interface */
648         struct {
649                 enum smb_fileinfo_level level;
650                 union smb_fileinfo_in in;
651
652                 struct {
653                         NTTIME create_time;
654                         NTTIME access_time;
655                         NTTIME write_time;
656                         NTTIME change_time;
657                         uint64_t alloc_size;
658                         uint64_t size;
659                         uint32_t attrib;
660                 } out;
661         } network_open_information;
662
663
664         /* RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION interface */
665         struct {
666                 enum smb_fileinfo_level level;
667                 union smb_fileinfo_in in;
668
669                 struct {
670                         uint32_t attrib;
671                         uint32_t reparse_tag;
672                 } out;
673         } attribute_tag_information;
674 };
675
676
677 enum smb_setfileinfo_level {
678         RAW_SFILEINFO_GENERIC                 = 0xF000, 
679         RAW_SFILEINFO_SETATTR,                /* SMBsetatr */
680         RAW_SFILEINFO_SETATTRE,               /* SMBsetattrE */
681         RAW_SFILEINFO_STANDARD                = SMB_SFILEINFO_STANDARD,
682         RAW_SFILEINFO_EA_SET                  = SMB_SFILEINFO_EA_SET,
683         RAW_SFILEINFO_BASIC_INFO              = SMB_SFILEINFO_BASIC_INFO,
684         RAW_SFILEINFO_DISPOSITION_INFO        = SMB_SFILEINFO_DISPOSITION_INFO,
685         RAW_SFILEINFO_ALLOCATION_INFO         = SMB_SFILEINFO_ALLOCATION_INFO,
686         RAW_SFILEINFO_END_OF_FILE_INFO        = SMB_SFILEINFO_END_OF_FILE_INFO,
687         RAW_SFILEINFO_UNIX_BASIC              = SMB_SFILEINFO_UNIX_BASIC,
688         RAW_SFILEINFO_UNIX_LINK               = SMB_SFILEINFO_UNIX_LINK,
689         RAW_SFILEINFO_UNIX_HLINK              = SMB_SFILEINFO_UNIX_HLINK,
690         RAW_SFILEINFO_BASIC_INFORMATION       = SMB_SFILEINFO_BASIC_INFORMATION,
691         RAW_SFILEINFO_RENAME_INFORMATION      = SMB_SFILEINFO_RENAME_INFORMATION,
692         RAW_SFILEINFO_DISPOSITION_INFORMATION = SMB_SFILEINFO_DISPOSITION_INFORMATION,
693         RAW_SFILEINFO_POSITION_INFORMATION    = SMB_SFILEINFO_POSITION_INFORMATION,
694         RAW_SFILEINFO_MODE_INFORMATION        = SMB_SFILEINFO_MODE_INFORMATION,
695         RAW_SFILEINFO_ALLOCATION_INFORMATION  = SMB_SFILEINFO_ALLOCATION_INFORMATION,
696         RAW_SFILEINFO_END_OF_FILE_INFORMATION = SMB_SFILEINFO_END_OF_FILE_INFORMATION,
697         RAW_SFILEINFO_1023                    = SMB_SFILEINFO_1023,
698         RAW_SFILEINFO_1025                    = SMB_SFILEINFO_1025,
699         RAW_SFILEINFO_1029                    = SMB_SFILEINFO_1029,
700         RAW_SFILEINFO_1032                    = SMB_SFILEINFO_1032,
701         RAW_SFILEINFO_1039                    = SMB_SFILEINFO_1039,
702         RAW_SFILEINFO_1040                    = SMB_SFILEINFO_1040
703 };
704
705 /* union used in setfileinfo() and setpathinfo() calls */
706 union smb_setfileinfo {
707         /* generic interface */
708         struct {
709                 enum smb_setfileinfo_level level;
710
711                 /* we are combining setfileinfo and setpathinfo into one 
712                    interface */
713                 union setfileinfo_file {
714                         const char *fname;
715                         uint16_t fnum;
716                 } file;
717         } generic;
718
719         /* RAW_SFILEINFO_SETATTR (SMBsetatr) interface - only via setpathinfo() */
720         struct {
721                 enum smb_setfileinfo_level level;
722                 union setfileinfo_file file;
723                 struct {
724                         uint16_t attrib;
725                         time_t write_time;
726                 } in;
727         } setattr;
728
729         /* RAW_SFILEINFO_SETATTRE (SMBsetattrE) interface - only via setfileinfo() 
730            also RAW_SFILEINFO_STANDARD */
731         struct {
732                 enum smb_setfileinfo_level level;
733                 union setfileinfo_file file;
734
735                 struct {
736                         time_t create_time;
737                         time_t access_time;
738                         time_t write_time;
739                         /* notice that size, alloc_size and attrib are not settable,
740                            unlike the corresponding qfileinfo level */
741                 } in;
742         } setattre, standard;
743
744         /* RAW_SFILEINFO_EA_SET interface */
745         struct {
746                 enum smb_setfileinfo_level level;
747                 union setfileinfo_file file;
748                 struct {
749                         struct ea_struct ea;
750                 } in;
751         } ea_set;
752
753         /* RAW_SFILEINFO_BASIC_INFO and
754            RAW_SFILEINFO_BASIC_INFORMATION interfaces */
755         struct {
756                 enum smb_setfileinfo_level level;
757                 union setfileinfo_file file;
758
759                 struct {
760                         NTTIME create_time;
761                         NTTIME access_time;
762                         NTTIME write_time;
763                         NTTIME change_time;
764                         uint32_t attrib;
765                 } in;
766         } basic_info;
767
768         /* RAW_SFILEINFO_DISPOSITION_INFO and 
769            RAW_SFILEINFO_DISPOSITION_INFORMATION interfaces */
770         struct {
771                 enum smb_setfileinfo_level level;
772                 union setfileinfo_file file;
773
774                 struct {
775                         BOOL delete_on_close;
776                 } in;
777         } disposition_info;
778
779         /* RAW_SFILEINFO_ALLOCATION_INFO and 
780            RAW_SFILEINFO_ALLOCATION_INFORMATION interfaces */
781         struct {
782                 enum smb_setfileinfo_level level;
783                 union setfileinfo_file file;
784
785                 struct {
786                         /* w2k3 rounds this up to nearest 4096 */
787                         uint64_t alloc_size;
788                 } in;
789         } allocation_info;
790         
791         /* RAW_SFILEINFO_END_OF_FILE_INFO and 
792            RAW_SFILEINFO_END_OF_FILE_INFORMATION interfaces */
793         struct {
794                 enum smb_setfileinfo_level level;
795                 union setfileinfo_file file;
796
797                 struct {
798                         uint64_t size;
799                 } in;
800         } end_of_file_info;
801
802         /* RAW_SFILEINFO_RENAME_INFORMATION interface */
803         struct {
804                 enum smb_setfileinfo_level level;
805                 union setfileinfo_file file;
806
807                 struct {
808                         uint8_t overwrite;
809                         uint32_t root_fid;
810                         const char *new_name;
811                 } in;
812         } rename_information;
813
814         /* RAW_SFILEINFO_POSITION_INFORMATION interface */
815         struct {
816                 enum smb_setfileinfo_level level;
817                 union setfileinfo_file file;
818
819                 struct {
820                         uint64_t position;
821                 } in;
822         } position_information;
823
824         /* RAW_SFILEINFO_MODE_INFORMATION interface */
825         struct {
826                 enum smb_setfileinfo_level level;
827                 union setfileinfo_file file;
828
829                 struct {
830                         /* valid values seem to be 0, 2, 4 and 6 */
831                         uint32_t mode;
832                 } in;
833         } mode_information;
834
835
836
837         /* RAW_SFILEINFO_UNIX_BASIC interface */
838         struct {
839                 enum smb_setfileinfo_level level;
840                 union setfileinfo_file file;
841                 struct {
842                         uint32_t mode; /* yuck - this field remains to fix compile of libcli/clifile.c */
843                         uint64_t end_of_file;
844                         uint64_t num_bytes;
845                         NTTIME status_change_time;
846                         NTTIME access_time;
847                         NTTIME change_time;
848                         uint64_t uid;
849                         uint64_t gid;
850                         uint32_t file_type;
851                         uint64_t dev_major;
852                         uint64_t dev_minor;
853                         uint64_t unique_id;
854                         uint64_t permissions;
855                         uint64_t nlink;
856                 } in;
857         } unix_basic;
858         
859         /* RAW_SFILEINFO_UNIX_LINK, RAW_SFILEINFO_UNIX_HLINK interface */
860         struct {
861                 enum smb_setfileinfo_level level;
862                 union setfileinfo_file file;
863                 struct {
864                         const char *link_dest;
865                 } in;
866         } unix_link, unix_hlink;
867 };
868
869
870 enum smb_fsinfo_level {
871                    RAW_QFS_GENERIC                        = 0xF000, 
872                    RAW_QFS_DSKATTR,                         /* SMBdskattr */
873                    RAW_QFS_ALLOCATION                     = SMB_QFS_ALLOCATION,
874                    RAW_QFS_VOLUME                         = SMB_QFS_VOLUME,
875                    RAW_QFS_VOLUME_INFO                    = SMB_QFS_VOLUME_INFO,
876                    RAW_QFS_SIZE_INFO                      = SMB_QFS_SIZE_INFO,
877                    RAW_QFS_DEVICE_INFO                    = SMB_QFS_DEVICE_INFO,
878                    RAW_QFS_ATTRIBUTE_INFO                 = SMB_QFS_ATTRIBUTE_INFO,
879                    RAW_QFS_UNIX_INFO                      = SMB_QFS_UNIX_INFO,
880                    RAW_QFS_VOLUME_INFORMATION             = SMB_QFS_VOLUME_INFORMATION,
881                    RAW_QFS_SIZE_INFORMATION               = SMB_QFS_SIZE_INFORMATION,
882                    RAW_QFS_DEVICE_INFORMATION             = SMB_QFS_DEVICE_INFORMATION,
883                    RAW_QFS_ATTRIBUTE_INFORMATION          = SMB_QFS_ATTRIBUTE_INFORMATION,
884                    RAW_QFS_QUOTA_INFORMATION              = SMB_QFS_QUOTA_INFORMATION,
885                    RAW_QFS_FULL_SIZE_INFORMATION          = SMB_QFS_FULL_SIZE_INFORMATION,
886                    RAW_QFS_OBJECTID_INFORMATION           = SMB_QFS_OBJECTID_INFORMATION};
887
888
889 /* union for fsinfo() backend call. Note that there are no in
890    structures, as this call only contains out parameters */
891 union smb_fsinfo {
892         /* generic interface */
893         struct {
894                 enum smb_fsinfo_level level;
895
896                 struct {
897                         uint32_t block_size;
898                         uint64_t blocks_total;
899                         uint64_t blocks_free;
900                         uint32_t fs_id;
901                         NTTIME create_time;
902                         uint32_t serial_number;
903                         uint32_t fs_attr;
904                         uint32_t max_file_component_length;
905                         uint32_t device_type;
906                         uint32_t device_characteristics;
907                         uint64_t quota_soft;
908                         uint64_t quota_hard;
909                         uint64_t quota_flags;
910                         struct GUID guid;
911                         char *volume_name;
912                         char *fs_type;
913                 } out;
914         } generic;
915
916         /* SMBdskattr interface */
917         struct {
918                 enum smb_fsinfo_level level;
919
920                 struct {
921                         uint16_t units_total;
922                         uint16_t blocks_per_unit;
923                         uint16_t block_size;
924                         uint16_t units_free;
925                 } out;
926         } dskattr;
927
928         /* trans2 RAW_QFS_ALLOCATION interface */
929         struct {
930                 enum smb_fsinfo_level level;
931
932                 struct {
933                         uint32_t fs_id;
934                         uint32_t sectors_per_unit;
935                         uint32_t total_alloc_units;
936                         uint32_t avail_alloc_units;
937                         uint16_t bytes_per_sector;
938                 } out;
939         } allocation;
940
941         /* TRANS2 RAW_QFS_VOLUME interface */
942         struct {
943                 enum smb_fsinfo_level level;
944
945                 struct {
946                         uint32_t serial_number;
947                         WIRE_STRING volume_name;
948                 } out;
949         } volume;
950
951         /* TRANS2 RAW_QFS_VOLUME_INFO and RAW_QFS_VOLUME_INFORMATION interfaces */
952         struct {
953                 enum smb_fsinfo_level level;
954
955                 struct {
956                         NTTIME create_time;
957                         uint32_t serial_number;
958                         WIRE_STRING volume_name;
959                 } out;
960         } volume_info;
961
962         /* trans2 RAW_QFS_SIZE_INFO and RAW_QFS_SIZE_INFORMATION interfaces */
963         struct {
964                 enum smb_fsinfo_level level;
965
966                 struct {
967                         uint64_t total_alloc_units;
968                         uint64_t avail_alloc_units; /* maps to call_avail_alloc_units */
969                         uint32_t sectors_per_unit;
970                         uint32_t bytes_per_sector;
971                 } out;
972         } size_info;
973
974         /* TRANS2 RAW_QFS_DEVICE_INFO and RAW_QFS_DEVICE_INFORMATION interfaces */
975         struct {
976                 enum smb_fsinfo_level level;
977
978                 struct {
979                         uint32_t device_type;
980                         uint32_t characteristics;
981                 } out;
982         } device_info;
983
984
985         /* TRANS2 RAW_QFS_ATTRIBUTE_INFO and RAW_QFS_ATTRIBUTE_INFORMATION interfaces */
986         struct {
987                 enum smb_fsinfo_level level;
988
989                 struct {
990                         uint32_t fs_attr;
991                         uint32_t max_file_component_length;
992                         WIRE_STRING fs_type;
993                 } out;
994         } attribute_info;
995
996
997         /* TRANS2 RAW_QFS_UNIX_INFO interface */
998         struct {
999                 enum smb_fsinfo_level level;
1000
1001                 struct {
1002                         uint16_t major_version;
1003                         uint16_t minor_version;
1004                         uint64_t capability;
1005                 } out;
1006         } unix_info;
1007
1008         /* trans2 RAW_QFS_QUOTA_INFORMATION interface */
1009         struct {
1010                 enum smb_fsinfo_level level;
1011
1012                 struct {
1013                         uint64_t unknown[3];
1014                         uint64_t quota_soft;
1015                         uint64_t quota_hard;
1016                         uint64_t quota_flags;
1017                 } out;
1018         } quota_information;    
1019
1020         /* trans2 RAW_QFS_FULL_SIZE_INFORMATION interface */
1021         struct {
1022                 enum smb_fsinfo_level level;
1023
1024                 struct {
1025                         uint64_t total_alloc_units;
1026                         uint64_t call_avail_alloc_units;
1027                         uint64_t actual_avail_alloc_units;
1028                         uint32_t sectors_per_unit;
1029                         uint32_t bytes_per_sector;
1030                 } out;
1031         } full_size_information;
1032
1033         /* trans2 RAW_QFS_OBJECTID_INFORMATION interface */
1034         struct {
1035                 enum smb_fsinfo_level level;
1036
1037                 struct {
1038                         struct GUID  guid;
1039                         uint64_t unknown[6];
1040                 } out;
1041         } objectid_information; 
1042 };
1043
1044
1045
1046 enum smb_open_level {
1047                  RAW_OPEN_OPEN, RAW_OPEN_OPENX, 
1048                  RAW_OPEN_MKNEW, RAW_OPEN_CREATE, 
1049                  RAW_OPEN_CTEMP, RAW_OPEN_SPLOPEN,
1050                  RAW_OPEN_NTCREATEX, RAW_OPEN_T2OPEN};
1051
1052 /* the generic interface is defined to be equal to the NTCREATEX interface */
1053 #define RAW_OPEN_GENERIC RAW_OPEN_NTCREATEX
1054
1055 /* union for open() backend call */
1056 union smb_open {
1057         /* SMBNTCreateX interface */
1058         struct {
1059                 enum smb_open_level level;
1060
1061                 struct {
1062                         uint32_t flags;
1063                         uint32_t root_fid;
1064                         uint32_t access_mask;
1065                         uint64_t alloc_size;
1066                         uint32_t file_attr;
1067                         uint32_t share_access;
1068                         uint32_t open_disposition;
1069                         uint32_t create_options;
1070                         uint32_t impersonation;
1071                         uint8_t  security_flags;
1072                         /* NOTE: fname can also be a pointer to a
1073                          uint64_t file_id if create_options has the
1074                          NTCREATEX_OPTIONS_OPEN_BY_FILE_ID flag set */
1075                         const char *fname;
1076                 } in;
1077
1078                 struct {
1079                         uint8_t oplock_level;
1080                         uint16_t fnum;
1081                         uint32_t create_action;
1082                         NTTIME create_time;
1083                         NTTIME access_time;
1084                         NTTIME write_time;
1085                         NTTIME change_time;
1086                         uint32_t attrib;
1087                         uint64_t alloc_size;
1088                         uint64_t size;
1089                         uint16_t file_type;
1090                         uint16_t ipc_state;
1091                         uint8_t  is_directory;
1092                 } out;
1093         } ntcreatex, generic;
1094
1095         /* TRANS2_OPEN interface */
1096         struct {
1097                 enum smb_open_level level;
1098
1099                 struct {
1100                         uint16_t flags;
1101                         uint16_t open_mode;
1102                         uint16_t file_attrs;
1103                         time_t write_time;
1104                         uint16_t open_func;
1105                         uint32_t size;
1106                         uint32_t timeout;
1107                         const char *fname;
1108                         uint_t num_eas;
1109                         struct ea_struct *eas;                  
1110                 } in;
1111
1112                 struct {
1113                         uint16_t fnum;
1114                         uint16_t attrib;
1115                         time_t write_time;
1116                         uint32_t size;
1117                         uint16_t access;
1118                         uint16_t ftype;
1119                         uint16_t devstate;
1120                         uint16_t action;
1121                         uint32_t unknown;
1122                 } out;
1123         } t2open;
1124
1125         /* SMBopen interface */
1126         struct {
1127                 enum smb_open_level level;
1128
1129                 struct {
1130                         uint16_t flags;
1131                         uint16_t search_attrs;
1132                         const char *fname;
1133                 } in;
1134                 struct {
1135                         uint16_t fnum;
1136                         uint16_t attrib;
1137                         time_t write_time;
1138                         uint32_t size;
1139                         uint16_t rmode;
1140                 } out;
1141         } open;
1142
1143         /* SMBopenX interface */
1144         struct {
1145                 enum smb_open_level level;
1146
1147                 struct {
1148                         uint16_t flags;
1149                         uint16_t open_mode;
1150                         uint16_t search_attrs; /* not honoured by win2003 */
1151                         uint16_t file_attrs;
1152                         time_t write_time; /* not honoured by win2003 */
1153                         uint16_t open_func;
1154                         uint32_t size; /* note that this sets the
1155                                         initial file size, not
1156                                         just allocation size */
1157                         uint32_t timeout; /* not honoured by win2003 */
1158                         const char *fname;
1159                 } in;
1160                 struct {
1161                         uint16_t fnum;
1162                         uint16_t attrib;
1163                         time_t write_time;
1164                         uint32_t size;
1165                         uint16_t access;
1166                         uint16_t ftype;
1167                         uint16_t devstate;
1168                         uint16_t action;
1169                         uint32_t unique_fid;
1170                         uint32_t access_mask;
1171                         uint32_t unknown;
1172                 } out;
1173         } openx;
1174
1175         /* SMBmknew interface */
1176         struct {
1177                 enum smb_open_level level;
1178
1179                 struct {
1180                         uint16_t attrib;
1181                         time_t write_time;
1182                         const char *fname;
1183                 } in;
1184                 struct {
1185                         uint16_t fnum;
1186                 } out;
1187         } mknew, create;
1188
1189         /* SMBctemp interface */
1190         struct {
1191                 enum smb_open_level level;
1192
1193                 struct {
1194                         uint16_t attrib;
1195                         time_t write_time;
1196                         const char *directory;
1197                 } in;
1198                 struct {
1199                         uint16_t fnum;
1200                         /* temp name, relative to directory */
1201                         char *name; 
1202                 } out;
1203         } ctemp;
1204
1205         /* SMBsplopen interface */
1206         struct {
1207                 enum smb_open_level level;
1208
1209                 struct {
1210                         uint16_t setup_length;
1211                         uint16_t mode;
1212                         const char *ident;
1213                 } in;
1214                 struct {
1215                         uint16_t fnum;
1216                 } out;
1217         } splopen;
1218 };
1219
1220
1221
1222 enum smb_read_level {RAW_READ_READBRAW, RAW_READ_LOCKREAD, RAW_READ_READ, RAW_READ_READX};
1223
1224 #define RAW_READ_GENERIC RAW_READ_READX
1225
1226 /* union for read() backend call 
1227
1228    note that .infoX.out.data will be allocated before the backend is
1229    called. It will be big enough to hold the maximum size asked for
1230 */
1231 union smb_read {
1232         /* SMBreadX (and generic) interface */
1233         struct {
1234                 enum smb_read_level level;
1235
1236                 struct {
1237                         uint16_t fnum;
1238                         uint64_t offset;
1239                         uint16_t mincnt;
1240                         uint32_t maxcnt;
1241                         uint16_t remaining;
1242                 } in;
1243                 struct {
1244                         char *data;
1245                         uint16_t remaining;
1246                         uint16_t compaction_mode;
1247                         uint16_t nread;
1248                 } out;
1249         } readx, generic;
1250
1251         /* SMBreadbraw interface */
1252         struct {
1253                 enum smb_read_level level;
1254
1255                 struct {
1256                         uint16_t fnum;
1257                         uint64_t offset;
1258                         uint16_t  maxcnt;
1259                         uint16_t  mincnt;
1260                         uint32_t  timeout;
1261                 } in;
1262                 struct {
1263                         char *data;
1264                         uint32_t nread;
1265                 } out;
1266         } readbraw;
1267
1268
1269         /* SMBlockandread interface */
1270         struct {
1271                 enum smb_read_level level;
1272
1273                 struct {
1274                         uint16_t fnum;
1275                         uint16_t count;
1276                         uint32_t offset;
1277                         uint16_t remaining;
1278                 } in;
1279                 struct {
1280                         char *data;
1281                         uint16_t nread;
1282                 } out;
1283         } lockread;
1284
1285         /* SMBread interface */
1286         struct {
1287                 enum smb_read_level level;
1288
1289                 struct {
1290                         uint16_t fnum;
1291                         uint16_t count;
1292                         uint32_t offset;
1293                         uint16_t remaining;
1294                 } in;
1295                 struct {
1296                         char *data;
1297                         uint16_t nread;
1298                 } out;
1299         } read;
1300 };
1301
1302
1303 enum smb_write_level {RAW_WRITE_WRITEUNLOCK, RAW_WRITE_WRITE, 
1304                       RAW_WRITE_WRITEX, RAW_WRITE_WRITECLOSE, 
1305                       RAW_WRITE_SPLWRITE};
1306
1307 #define RAW_WRITE_GENERIC RAW_WRITE_WRITEX
1308
1309 /* union for write() backend call 
1310 */
1311 union smb_write {
1312         /* SMBwriteX interface */
1313         struct {
1314                 enum smb_write_level level;
1315
1316                 struct {
1317                         uint16_t fnum;
1318                         uint64_t offset;
1319                         uint16_t wmode;
1320                         uint16_t remaining;
1321                         uint32_t count;
1322                         const char *data;
1323                 } in;
1324                 struct {
1325                         uint32_t nwritten;
1326                         uint16_t remaining;
1327                 } out;
1328         } writex, generic;
1329
1330         /* SMBwriteunlock interface */
1331         struct {
1332                 enum smb_write_level level;
1333
1334                 struct {
1335                         uint16_t fnum;
1336                         uint16_t count;
1337                         uint32_t offset;
1338                         uint16_t remaining;
1339                         const char *data;
1340                 } in;
1341                 struct {
1342                         uint32_t nwritten;
1343                 } out;
1344         } writeunlock;
1345
1346         /* SMBwrite interface */
1347         struct {
1348                 enum smb_write_level level;
1349
1350                 struct {
1351                         uint16_t fnum;
1352                         uint16_t count;
1353                         uint32_t offset;
1354                         uint16_t remaining;
1355                         const char *data;
1356                 } in;
1357                 struct {
1358                         uint16_t nwritten;
1359                 } out;
1360         } write;
1361
1362         /* SMBwriteclose interface */
1363         struct {
1364                 enum smb_write_level level;
1365
1366                 struct {
1367                         uint16_t fnum;
1368                         uint16_t count;
1369                         uint32_t offset;
1370                         time_t mtime;
1371                         const char *data;
1372                 } in;
1373                 struct {
1374                         uint16_t nwritten;
1375                 } out;
1376         } writeclose;
1377
1378         /* SMBsplwrite interface */
1379         struct {
1380                 enum smb_write_level level;
1381
1382                 struct {
1383                         uint16_t fnum;
1384                         uint16_t count;
1385                         const char *data;
1386                 } in;
1387         } splwrite;
1388 };
1389
1390
1391 enum smb_lock_level {RAW_LOCK_LOCK, RAW_LOCK_UNLOCK, RAW_LOCK_LOCKX};
1392
1393 /* the generic interface is defined to be equal to the lockingX interface */
1394 #define RAW_LOCK_GENERIC RAW_LOCK_LOCKX
1395
1396 /* union for lock() backend call 
1397 */
1398 union smb_lock {
1399         /* SMBlockingX (and generic) interface */
1400         struct {
1401                 enum smb_lock_level level;
1402
1403                 struct {
1404                         uint16_t fnum;
1405                         uint16_t mode;
1406                         uint32_t timeout;
1407                         uint16_t ulock_cnt;
1408                         uint16_t lock_cnt;
1409                         struct smb_lock_entry {
1410                                 uint16_t pid;
1411                                 uint64_t offset;
1412                                 uint64_t count;
1413                         } *locks; /* unlocks are first in the arrray */
1414                 } in;
1415         } lockx, generic;
1416
1417         /* SMBlock and SMBunlock interface */
1418         struct {
1419                 enum smb_lock_level level;
1420
1421                 struct {
1422                         uint16_t fnum;
1423                         uint32_t count;
1424                         uint32_t offset;
1425                 } in;
1426         } lock, unlock;
1427 };
1428
1429
1430 enum smb_close_level {RAW_CLOSE_CLOSE, RAW_CLOSE_SPLCLOSE};
1431
1432 #define RAW_CLOSE_GENERIC RAW_CLOSE_CLOSE
1433
1434 /*
1435   union for close() backend call
1436 */
1437 union smb_close {
1438         /* SMBclose (and generic) interface */
1439         struct {
1440                 enum smb_close_level level;
1441
1442                 struct {
1443                         uint16_t fnum;
1444                         time_t write_time;
1445                 } in;
1446         } close, generic;
1447
1448         /* SMBsplclose interface - empty! */
1449         struct {
1450                 enum smb_close_level level;
1451
1452                 struct {
1453                         uint16_t fnum;
1454                 } in;
1455         } splclose;
1456 };
1457
1458
1459 enum smb_lpq_level {RAW_LPQ_GENERIC, RAW_LPQ_RETQ};
1460
1461 /*
1462   union for lpq() backend
1463 */
1464 union smb_lpq {
1465         /* generic interface */
1466         struct {
1467                 enum smb_lpq_level level;
1468
1469         } generic;
1470
1471
1472         /* SMBsplretq interface */
1473         struct {
1474                 enum smb_lpq_level level;
1475
1476                 struct {
1477                         uint16_t maxcount;
1478                         uint16_t startidx;
1479                 } in;
1480                 struct {
1481                         uint16_t count;
1482                         uint16_t restart_idx;
1483                         struct {
1484                                 time_t time;
1485                                 uint8_t status;
1486                                 uint16_t job;
1487                                 uint32_t size;
1488                                 char *user;
1489                         } *queue;
1490                 } out;
1491         } retq;
1492 };
1493
1494 enum smb_ioctl_level {RAW_IOCTL_IOCTL, RAW_IOCTL_NTIOCTL};
1495
1496 /*
1497   union for ioctl() backend
1498 */
1499 union smb_ioctl {
1500         /* generic interface */
1501         struct {
1502                 enum smb_ioctl_level level;
1503
1504         } generic;
1505
1506         /* struct for SMBioctl */
1507         struct {
1508                 enum smb_ioctl_level level;
1509                 struct {
1510                         uint16_t fnum;
1511                         uint32_t request;
1512                 } in;
1513                 struct {
1514                         DATA_BLOB blob;
1515                 } out;
1516         } ioctl;
1517
1518
1519         /* struct for NT ioctl call */
1520         struct {
1521                 enum smb_ioctl_level level;
1522                 struct {
1523                         uint32_t function;
1524                         uint16_t fnum;
1525                         BOOL fsctl;
1526                         uint8_t filter;
1527                 } in;
1528                 struct {
1529                         DATA_BLOB blob;
1530                 } out;
1531         } ntioctl;
1532 };
1533
1534 /* struct for SMBflush */
1535 struct smb_flush {
1536         struct {
1537                 uint16_t fnum;
1538         } in;
1539 };
1540
1541
1542 /* struct for SMBcopy */
1543 struct smb_copy {
1544         struct {
1545                 uint16_t tid2;
1546                 uint16_t ofun;
1547                 uint16_t flags;
1548                 const char *path1;
1549                 const char *path2;
1550         } in;
1551         struct {
1552                 uint16_t count;
1553         } out;
1554 };
1555
1556
1557 /* struct for transact/transact2 call */
1558 struct smb_trans2 {
1559         struct {
1560                 uint16_t max_param;
1561                 uint16_t max_data;
1562                 uint8_t  max_setup;
1563                 uint16_t flags;
1564                 uint32_t timeout;
1565                 uint8_t  setup_count;
1566                 uint16_t *setup;
1567                 const char *trans_name; /* SMBtrans only */
1568                 DATA_BLOB params;
1569                 DATA_BLOB data;
1570         } in;
1571
1572         struct {
1573                 uint8_t  setup_count;
1574                 uint16_t *setup;
1575                 DATA_BLOB params;
1576                 DATA_BLOB data;
1577         } out;
1578 };
1579
1580 /* struct for nttransact2 call */
1581 struct smb_nttrans {
1582         struct {
1583                 uint8_t  max_setup;
1584                 uint32_t max_param;
1585                 uint32_t max_data;
1586                 uint32_t setup_count;
1587                 uint16_t function;
1588                 uint16_t *setup;
1589                 DATA_BLOB params;
1590                 DATA_BLOB data;
1591         } in;
1592
1593         struct {
1594                 uint8_t  setup_count;
1595                 uint16_t *setup;
1596                 DATA_BLOB params;
1597                 DATA_BLOB data;
1598         } out;
1599 };
1600
1601
1602 /* struct for nttrans change notify call */
1603 struct smb_notify {
1604         struct {
1605                 uint32_t buffer_size;
1606                 uint32_t completion_filter;
1607                 uint16_t fnum;
1608                 BOOL recursive;
1609         } in;
1610
1611         struct {
1612                 uint32_t num_changes;
1613                 struct {
1614                         uint32_t action;
1615                         WIRE_STRING name;
1616                 } *changes;
1617         } out;
1618 };
1619
1620
1621 enum smb_search_level {RAW_SEARCH_GENERIC                 = 0xF000, 
1622                        RAW_SEARCH_SEARCH,                 /* SMBsearch */ 
1623                        RAW_SEARCH_FFIRST,                 /* SMBffirst */ 
1624                        RAW_SEARCH_FUNIQUE,                /* SMBfunique */ 
1625                        RAW_SEARCH_STANDARD                = SMB_FIND_STANDARD,
1626                        RAW_SEARCH_EA_SIZE                 = SMB_FIND_EA_SIZE,
1627                        RAW_SEARCH_DIRECTORY_INFO          = SMB_FIND_DIRECTORY_INFO,
1628                        RAW_SEARCH_FULL_DIRECTORY_INFO     = SMB_FIND_FULL_DIRECTORY_INFO,
1629                        RAW_SEARCH_NAME_INFO               = SMB_FIND_NAME_INFO,
1630                        RAW_SEARCH_BOTH_DIRECTORY_INFO     = SMB_FIND_BOTH_DIRECTORY_INFO,
1631                        RAW_SEARCH_ID_FULL_DIRECTORY_INFO  = SMB_FIND_ID_FULL_DIRECTORY_INFO,
1632                        RAW_SEARCH_ID_BOTH_DIRECTORY_INFO  = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
1633                        RAW_SEARCH_UNIX_INFO               = SMB_FIND_UNIX_INFO};
1634
1635         
1636 /* union for file search */
1637 union smb_search_first {
1638         struct {
1639                 enum smb_search_level level;
1640         } generic;
1641         
1642         /* search (old) findfirst interface. 
1643            Also used for ffirst and funique. */
1644         struct {
1645                 enum smb_search_level level;
1646         
1647                 struct {
1648                         uint16_t max_count;
1649                         uint16_t search_attrib;
1650                         const char *pattern;
1651                 } in;
1652                 struct {
1653                         int16_t count;
1654                 } out;
1655         } search_first;
1656
1657         /* trans2 findfirst interface */
1658         struct {
1659                 enum smb_search_level level;
1660                 
1661                 struct {
1662                         uint16_t search_attrib;
1663                         uint16_t max_count;
1664                         uint16_t flags;
1665                         uint32_t storage_type;
1666                         const char *pattern;
1667                 } in;
1668                 struct {
1669                         uint16_t handle;
1670                         uint16_t count;
1671                         uint16_t end_of_search;
1672                 } out;
1673         } t2ffirst;
1674 };
1675
1676 /* union for file search continue */
1677 union smb_search_next {
1678         struct {
1679                 enum smb_search_level level;
1680         } generic;
1681
1682         /* search (old) findnext interface. Also used
1683            for ffirst when continuing */
1684         struct {
1685                 enum smb_search_level level;
1686         
1687                 struct {
1688                         uint16_t max_count;
1689                         uint16_t search_attrib;
1690                         struct smb_search_id {
1691                                 uint8_t reserved;
1692                                 char name[11];
1693                                 uint8_t handle;
1694                                 uint32_t server_cookie;
1695                                 uint32_t client_cookie;
1696                         } id;
1697                 } in;
1698                 struct {
1699                         uint16_t count;
1700                 } out;
1701         } search_next;
1702         
1703         /* trans2 findnext interface */
1704         struct {
1705                 enum smb_search_level level;
1706                 
1707                 struct {
1708                         uint16_t handle;
1709                         uint16_t max_count;
1710                         uint32_t resume_key;
1711                         uint16_t flags;
1712                         const char *last_name;
1713                 } in;
1714                 struct {
1715                         uint16_t count;
1716                         uint16_t end_of_search;
1717                 } out;
1718         } t2fnext;
1719 };
1720
1721 /* union for search reply file data */
1722 union smb_search_data {
1723         /* search (old) findfirst */
1724         struct {
1725                 uint16_t attrib;
1726                 time_t write_time;
1727                 uint32_t size;
1728                 struct smb_search_id id;
1729                 const char *name;
1730         } search;
1731         
1732         /* trans2 findfirst RAW_SEARCH_STANDARD level */
1733         struct {
1734                 uint32_t resume_key;
1735                 time_t create_time;
1736                 time_t access_time;
1737                 time_t write_time;
1738                 uint32_t size;
1739                 uint32_t alloc_size;
1740                 uint16_t attrib;
1741                 WIRE_STRING name;
1742         } standard;
1743
1744         /* trans2 findfirst RAW_SEARCH_EA_SIZE level */
1745         struct {
1746                 uint32_t resume_key;
1747                 time_t create_time;
1748                 time_t access_time;
1749                 time_t write_time;
1750                 uint32_t size;
1751                 uint32_t alloc_size;
1752                 uint16_t attrib;
1753                 uint32_t ea_size;
1754                 WIRE_STRING name;
1755         } ea_size;
1756
1757         /* RAW_SEARCH_DIRECTORY_INFO interface */
1758         struct {
1759                 uint32_t file_index;
1760                 NTTIME create_time;
1761                 NTTIME access_time;
1762                 NTTIME write_time;
1763                 NTTIME change_time;
1764                 uint64_t  size;
1765                 uint64_t  alloc_size;
1766                 uint32_t   attrib;
1767                 WIRE_STRING name;
1768         } directory_info;
1769
1770         /* RAW_SEARCH_FULL_DIRECTORY_INFO interface */
1771         struct {
1772                 uint32_t file_index;
1773                 NTTIME create_time;
1774                 NTTIME access_time;
1775                 NTTIME write_time;
1776                 NTTIME change_time;
1777                 uint64_t  size;
1778                 uint64_t  alloc_size;
1779                 uint32_t   attrib;
1780                 uint32_t   ea_size;
1781                 WIRE_STRING name;
1782         } full_directory_info;
1783
1784         /* RAW_SEARCH_NAME_INFO interface */
1785         struct {
1786                 uint32_t file_index;
1787                 WIRE_STRING name;
1788         } name_info;
1789
1790         /* RAW_SEARCH_BOTH_DIRECTORY_INFO interface */
1791         struct {
1792                 uint32_t file_index;
1793                 NTTIME create_time;
1794                 NTTIME access_time;
1795                 NTTIME write_time;
1796                 NTTIME change_time;
1797                 uint64_t  size;
1798                 uint64_t  alloc_size;
1799                 uint32_t   attrib;
1800                 uint32_t   ea_size;
1801                 WIRE_STRING short_name;
1802                 WIRE_STRING name;
1803         } both_directory_info;
1804
1805         /* RAW_SEARCH_ID_FULL_DIRECTORY_INFO interface */
1806         struct {
1807                 uint32_t file_index;
1808                 NTTIME create_time;
1809                 NTTIME access_time;
1810                 NTTIME write_time;
1811                 NTTIME change_time;
1812                 uint64_t size;
1813                 uint64_t alloc_size;
1814                 uint32_t attrib;
1815                 uint32_t ea_size;
1816                 uint64_t file_id;
1817                 WIRE_STRING name;
1818         } id_full_directory_info;
1819
1820         /* RAW_SEARCH_ID_BOTH_DIRECTORY_INFO interface */
1821         struct {
1822                 uint32_t file_index;
1823                 NTTIME create_time;
1824                 NTTIME access_time;
1825                 NTTIME write_time;
1826                 NTTIME change_time;
1827                 uint64_t size;
1828                 uint64_t alloc_size;
1829                 uint32_t  attrib;
1830                 uint32_t  ea_size;
1831                 uint64_t file_id;
1832                 WIRE_STRING short_name;
1833                 WIRE_STRING name;
1834         } id_both_directory_info;
1835
1836         /* RAW_SEARCH_UNIX_INFO interface */
1837         struct {
1838                 uint32_t file_index;
1839                 uint64_t size;
1840                 uint64_t alloc_size;
1841                 NTTIME status_change_time;
1842                 NTTIME access_time;
1843                 NTTIME change_time;
1844                 uint64_t uid;
1845                 uint64_t gid;
1846                 uint32_t file_type;
1847                 uint64_t dev_major;
1848                 uint64_t dev_minor;
1849                 uint64_t unique_id;
1850                 uint64_t permissions;
1851                 uint64_t nlink;         
1852                 const char *name;
1853         } unix_info;
1854 };
1855
1856
1857 enum smb_search_close_level {RAW_FINDCLOSE_GENERIC, RAW_FINDCLOSE_FCLOSE, RAW_FINDCLOSE_FINDCLOSE};
1858
1859 /* union for file search close */
1860 union smb_search_close {
1861         struct {
1862                 enum smb_search_close_level level;
1863         } generic;
1864
1865         /* SMBfclose (old search) interface */
1866         struct {
1867                 enum smb_search_close_level level;
1868         
1869                 struct {
1870                         /* max_count and search_attrib are not used, but are present */
1871                         uint16_t max_count;
1872                         uint16_t search_attrib;
1873                         struct smb_search_id id;
1874                 } in;
1875         } fclose;
1876         
1877         /* SMBfindclose interface */
1878         struct {
1879                 enum smb_search_close_level level;
1880                 
1881                 struct {
1882                         uint16_t handle;
1883                 } in;
1884         } findclose;
1885 };
1886