4e6ba6b13ba4cd7e1589434544e4f872a982824a
[jelmer/samba4-debian.git] / source / 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 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 mkdir_level level;
96         } generic;
97
98         struct {
99                 enum mkdir_level level;
100                 struct {
101                         const char *path;
102                 } in;
103         } mkdir;
104
105         struct {
106                 enum 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 rename_level {RAW_RENAME_RENAME, RAW_RENAME_NTRENAME};
124
125 union smb_rename {
126         struct {
127                 enum rename_level level;
128         } generic;
129
130         /* SMBrename interface */
131         struct {
132                 enum 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 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 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 tcon_level level;
163         } generic;
164
165         /* SMBtcon interface */
166         struct {
167                 enum 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 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 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 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 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 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 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 fileinfo_level {RAW_FILEINFO_GENERIC                    = 0xF000, 
306                      RAW_FILEINFO_GETATTR,                   /* SMBgetatr */
307                      RAW_FILEINFO_GETATTRE,                  /* SMBgetattrE */
308                      RAW_FILEINFO_STANDARD                   = SMB_QFILEINFO_STANDARD,
309                      RAW_FILEINFO_EA_SIZE                    = SMB_QFILEINFO_EA_SIZE,
310                      RAW_FILEINFO_ALL_EAS                    = SMB_QFILEINFO_ALL_EAS,
311                      RAW_FILEINFO_IS_NAME_VALID              = SMB_QFILEINFO_IS_NAME_VALID,
312                      RAW_FILEINFO_BASIC_INFO                 = SMB_QFILEINFO_BASIC_INFO, 
313                      RAW_FILEINFO_STANDARD_INFO              = SMB_QFILEINFO_STANDARD_INFO,
314                      RAW_FILEINFO_EA_INFO                    = SMB_QFILEINFO_EA_INFO,
315                      RAW_FILEINFO_NAME_INFO                  = SMB_QFILEINFO_NAME_INFO, 
316                      RAW_FILEINFO_ALL_INFO                   = SMB_QFILEINFO_ALL_INFO,
317                      RAW_FILEINFO_ALT_NAME_INFO              = SMB_QFILEINFO_ALT_NAME_INFO,
318                      RAW_FILEINFO_STREAM_INFO                = SMB_QFILEINFO_STREAM_INFO,
319                      RAW_FILEINFO_COMPRESSION_INFO           = SMB_QFILEINFO_COMPRESSION_INFO,
320                      RAW_FILEINFO_UNIX_BASIC                 = SMB_QFILEINFO_UNIX_BASIC,
321                      RAW_FILEINFO_UNIX_LINK                  = SMB_QFILEINFO_UNIX_LINK,
322                      RAW_FILEINFO_BASIC_INFORMATION          = SMB_QFILEINFO_BASIC_INFORMATION,
323                      RAW_FILEINFO_STANDARD_INFORMATION       = SMB_QFILEINFO_STANDARD_INFORMATION,
324                      RAW_FILEINFO_INTERNAL_INFORMATION       = SMB_QFILEINFO_INTERNAL_INFORMATION,
325                      RAW_FILEINFO_EA_INFORMATION             = SMB_QFILEINFO_EA_INFORMATION,
326                      RAW_FILEINFO_ACCESS_INFORMATION         = SMB_QFILEINFO_ACCESS_INFORMATION,
327                      RAW_FILEINFO_NAME_INFORMATION           = SMB_QFILEINFO_NAME_INFORMATION,
328                      RAW_FILEINFO_POSITION_INFORMATION       = SMB_QFILEINFO_POSITION_INFORMATION,
329                      RAW_FILEINFO_MODE_INFORMATION           = SMB_QFILEINFO_MODE_INFORMATION,
330                      RAW_FILEINFO_ALIGNMENT_INFORMATION      = SMB_QFILEINFO_ALIGNMENT_INFORMATION,
331                      RAW_FILEINFO_ALL_INFORMATION            = SMB_QFILEINFO_ALL_INFORMATION,
332                      RAW_FILEINFO_ALT_NAME_INFORMATION       = SMB_QFILEINFO_ALT_NAME_INFORMATION,
333                      RAW_FILEINFO_STREAM_INFORMATION         = SMB_QFILEINFO_STREAM_INFORMATION,
334                      RAW_FILEINFO_COMPRESSION_INFORMATION    = SMB_QFILEINFO_COMPRESSION_INFORMATION,
335                      RAW_FILEINFO_NETWORK_OPEN_INFORMATION   = SMB_QFILEINFO_NETWORK_OPEN_INFORMATION,
336                      RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION  = SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION
337 };
338
339
340 /* union used in qfileinfo() and qpathinfo() backend calls */
341 union smb_fileinfo {
342         /* generic interface:
343          * matches RAW_FILEINFO_GENERIC */
344         struct {
345                 enum fileinfo_level level;
346
347                 /* each level can be called on either a pathname or a
348                  * filename, in either case the return format is
349                  * identical */
350                 union smb_fileinfo_in {
351                         const char *fname;
352                         uint16_t fnum;
353                 } in;
354                 
355                 struct {
356                         uint16_t attrib;
357                         uint32_t ea_size;
358                         uint_t num_eas;
359                         struct ea_struct {
360                                 uint8 flags;
361                                 WIRE_STRING name;
362                                 DATA_BLOB value;
363                         } *eas;         
364                         NTTIME create_time;
365                         NTTIME access_time;
366                         NTTIME write_time;
367                         NTTIME change_time;
368                         uint32_t ex_attrib;     
369                         uint64_t alloc_size;
370                         uint64_t size;
371                         uint32_t nlink;
372                         WIRE_STRING fname;      
373                         WIRE_STRING alt_fname;  
374                         uint8 delete_pending;
375                         uint8 directory;
376                         uint64_t compressed_size;
377                         uint16_t format;
378                         uint8 unit_shift;
379                         uint8 chunk_shift;
380                         uint8 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 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 interface */
411         struct {
412                 enum 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;
424
425         /* trans2 RAW_FILEINFO_STANDARD interface */
426         struct {
427                 enum 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                 } out;
438         } standard;
439
440         /* trans2 RAW_FILEINFO_EA_SIZE interface */
441         struct {
442                 enum fileinfo_level level;
443                 union smb_fileinfo_in in;
444
445                 struct {
446                         time_t create_time;
447                         time_t access_time;
448                         time_t write_time;
449                         uint32_t size;
450                         uint32_t alloc_size;
451                         uint16_t attrib;
452                         uint32_t ea_size;
453                 } out;
454         } ea_size;
455
456         /* trans2 RAW_FILEINFO_ALL_EAS interface */
457         struct {
458                 enum fileinfo_level level;
459                 union smb_fileinfo_in in;
460
461                 struct {
462                         /* the ea_size is implied by the list */
463                         uint_t num_eas;
464                         struct ea_struct *eas;
465                 } out;
466         } all_eas;
467
468         /* trans2 qpathinfo RAW_FILEINFO_IS_NAME_VALID interface 
469            only valid for a QPATHNAME call - no returned data */
470         struct {
471                 enum fileinfo_level level;
472                 union smb_fileinfo_in in;
473         } is_name_valid;
474
475         /* RAW_FILEINFO_BASIC_INFO and RAW_FILEINFO_BASIC_INFORMATION interfaces */
476         struct {
477                 enum fileinfo_level level;
478                 union smb_fileinfo_in in;
479
480                 struct {
481                         NTTIME create_time;
482                         NTTIME access_time;
483                         NTTIME write_time;
484                         NTTIME change_time;
485                         uint32_t attrib;
486                 } out;
487         } basic_info;
488                 
489
490         /* RAW_FILEINFO_STANDARD_INFO and RAW_FILEINFO_STANDARD_INFORMATION interfaces */
491         struct {
492                 enum fileinfo_level level;
493                 union smb_fileinfo_in in;
494
495                 struct {
496                         uint64_t alloc_size;
497                         uint64_t size;
498                         uint32_t nlink;
499                         BOOL delete_pending;
500                         BOOL directory;
501                 } out;
502         } standard_info;
503         
504         /* RAW_FILEINFO_EA_INFO and RAW_FILEINFO_EA_INFORMATION interfaces */
505         struct {
506                 enum fileinfo_level level;
507                 union smb_fileinfo_in in;
508
509                 struct {
510                         uint32_t ea_size;
511                 } out;
512         } ea_info;
513
514         /* RAW_FILEINFO_NAME_INFO and RAW_FILEINFO_NAME_INFORMATION interfaces */
515         struct {
516                 enum fileinfo_level level;
517                 union smb_fileinfo_in in;
518
519                 struct {
520                         WIRE_STRING fname;
521                 } out;
522         } name_info;
523
524         /* RAW_FILEINFO_ALL_INFO and RAW_FILEINFO_ALL_INFORMATION interfaces */
525         struct {
526                 enum fileinfo_level level;
527                 union smb_fileinfo_in in;
528
529                 struct {
530                         NTTIME create_time;
531                         NTTIME access_time;
532                         NTTIME write_time;
533                         NTTIME change_time;
534                         uint32_t attrib;
535                         uint64_t alloc_size;
536                         uint64_t size;
537                         uint32_t nlink;
538                         uint8 delete_pending;
539                         uint8 directory;
540                         uint32_t ea_size;
541                         WIRE_STRING fname;
542                 } out;
543         } all_info;     
544
545         /* RAW_FILEINFO_ALT_NAME_INFO and RAW_FILEINFO_ALT_NAME_INFORMATION interfaces */
546         struct {
547                 enum fileinfo_level level;
548                 union smb_fileinfo_in in;
549
550                 struct {
551                         WIRE_STRING fname;
552                 } out;
553         } alt_name_info;
554
555         /* RAW_FILEINFO_STREAM_INFO and RAW_FILEINFO_STREAM_INFORMATION interfaces */
556         struct {
557                 enum fileinfo_level level;
558                 union smb_fileinfo_in in;
559
560                 struct {
561                         uint_t num_streams;
562                         struct stream_struct *streams;
563                 } out;
564         } stream_info;
565         
566         /* RAW_FILEINFO_COMPRESSION_INFO and RAW_FILEINFO_COMPRESSION_INFORMATION interfaces */
567         struct {
568                 enum fileinfo_level level;
569                 union smb_fileinfo_in in;
570
571                 struct {
572                         uint64_t compressed_size;
573                         uint16_t format;
574                         uint8 unit_shift;
575                         uint8 chunk_shift;
576                         uint8 cluster_shift;
577                 } out;
578         } compression_info;
579
580         /* RAW_FILEINFO_UNIX_BASIC interface */
581         struct {
582                 enum fileinfo_level level;
583                 union smb_fileinfo_in in;
584
585                 struct {
586                         uint64_t end_of_file;
587                         uint64_t num_bytes;
588                         NTTIME status_change_time;
589                         NTTIME access_time;
590                         NTTIME change_time;
591                         uint64_t uid;
592                         uint64_t gid;
593                         uint32_t file_type;
594                         uint64_t dev_major;
595                         uint64_t dev_minor;
596                         uint64_t unique_id;
597                         uint64_t permissions;
598                         uint64_t nlink;
599                 } out;
600         } unix_basic_info;
601
602         /* RAW_FILEINFO_UNIX_LINK interface */
603         struct {
604                 enum fileinfo_level level;
605                 union smb_fileinfo_in in;
606
607                 struct {
608                         WIRE_STRING link_dest;
609                 } out;
610         } unix_link_info;
611
612         /* RAW_FILEINFO_INTERNAL_INFORMATION interface */
613         struct {
614                 enum fileinfo_level level;
615                 union smb_fileinfo_in in;
616
617                 struct {
618                         uint64_t file_id;
619                 } out;
620         } internal_information;
621
622         /* RAW_FILEINFO_ACCESS_INFORMATION interface */
623         struct {
624                 enum fileinfo_level level;
625                 union smb_fileinfo_in in;
626
627                 struct {
628                         uint32_t access_flags; /* seen 0x001f01ff from w2k3 */
629                 } out;
630         } access_information;
631
632         /* RAW_FILEINFO_POSITION_INFORMATION interface */
633         struct {
634                 enum fileinfo_level level;
635                 union smb_fileinfo_in in;
636
637                 struct {
638                         uint64_t position;
639                 } out;
640         } position_information;
641
642         /* RAW_FILEINFO_MODE_INFORMATION interface */
643         struct {
644                 enum fileinfo_level level;
645                 union smb_fileinfo_in in;
646
647                 struct {
648                         uint32_t mode;
649                 } out;
650         } mode_information;
651
652         /* RAW_FILEINFO_ALIGNMENT_INFORMATION interface */
653         struct {
654                 enum fileinfo_level level;
655                 union smb_fileinfo_in in;
656
657                 struct {
658                         uint32_t alignment_requirement;
659                 } out;
660         } alignment_information;
661
662         /* RAW_FILEINFO_NETWORK_OPEN_INFORMATION interface */
663         struct {
664                 enum fileinfo_level level;
665                 union smb_fileinfo_in in;
666
667                 struct {
668                         NTTIME create_time;
669                         NTTIME access_time;
670                         NTTIME write_time;
671                         NTTIME change_time;
672                         uint64_t alloc_size;
673                         uint64_t size;
674                         uint32_t attrib;
675                 } out;
676         } network_open_information;
677
678
679         /* RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION interface */
680         struct {
681                 enum fileinfo_level level;
682                 union smb_fileinfo_in in;
683
684                 struct {
685                         uint32_t attrib;
686                         uint32_t reparse_tag;
687                 } out;
688         } attribute_tag_information;
689 };
690
691
692 enum setfileinfo_level {
693         RAW_SFILEINFO_GENERIC                 = 0xF000, 
694         RAW_SFILEINFO_SETATTR,                /* SMBsetatr */
695         RAW_SFILEINFO_SETATTRE,               /* SMBsetattrE */
696         RAW_SFILEINFO_STANDARD                = SMB_SFILEINFO_STANDARD,
697         RAW_SFILEINFO_EA_SET                  = SMB_SFILEINFO_EA_SET,
698         RAW_SFILEINFO_BASIC_INFO              = SMB_SFILEINFO_BASIC_INFO,
699         RAW_SFILEINFO_DISPOSITION_INFO        = SMB_SFILEINFO_DISPOSITION_INFO,
700         RAW_SFILEINFO_ALLOCATION_INFO         = SMB_SFILEINFO_ALLOCATION_INFO,
701         RAW_SFILEINFO_END_OF_FILE_INFO        = SMB_SFILEINFO_END_OF_FILE_INFO,
702         RAW_SFILEINFO_UNIX_BASIC              = SMB_SFILEINFO_UNIX_BASIC,
703         RAW_SFILEINFO_UNIX_LINK               = SMB_SFILEINFO_UNIX_LINK,
704         RAW_SFILEINFO_UNIX_HLINK              = SMB_SFILEINFO_UNIX_HLINK,
705         RAW_SFILEINFO_BASIC_INFORMATION       = SMB_SFILEINFO_BASIC_INFORMATION,
706         RAW_SFILEINFO_RENAME_INFORMATION      = SMB_SFILEINFO_RENAME_INFORMATION,
707         RAW_SFILEINFO_DISPOSITION_INFORMATION = SMB_SFILEINFO_DISPOSITION_INFORMATION,
708         RAW_SFILEINFO_POSITION_INFORMATION    = SMB_SFILEINFO_POSITION_INFORMATION,
709         RAW_SFILEINFO_MODE_INFORMATION        = SMB_SFILEINFO_MODE_INFORMATION,
710         RAW_SFILEINFO_ALLOCATION_INFORMATION  = SMB_SFILEINFO_ALLOCATION_INFORMATION,
711         RAW_SFILEINFO_END_OF_FILE_INFORMATION = SMB_SFILEINFO_END_OF_FILE_INFORMATION,
712         RAW_SFILEINFO_1023                    = SMB_SFILEINFO_1023,
713         RAW_SFILEINFO_1025                    = SMB_SFILEINFO_1025,
714         RAW_SFILEINFO_1029                    = SMB_SFILEINFO_1029,
715         RAW_SFILEINFO_1032                    = SMB_SFILEINFO_1032,
716         RAW_SFILEINFO_1039                    = SMB_SFILEINFO_1039,
717         RAW_SFILEINFO_1040                    = SMB_SFILEINFO_1040
718 };
719
720 /* union used in setfileinfo() and setpathinfo() calls */
721 union smb_setfileinfo {
722         /* generic interface */
723         struct {
724                 enum setfileinfo_level level;
725
726                 /* we are combining setfileinfo and setpathinfo into one 
727                    interface */
728                 union setfileinfo_file {
729                         const char *fname;
730                         uint16_t fnum;
731                 } file;
732         } generic;
733
734         /* RAW_SFILEINFO_SETATTR (SMBsetatr) interface - only via setpathinfo() */
735         struct {
736                 enum setfileinfo_level level;
737                 union setfileinfo_file file;
738                 struct {
739                         uint16_t attrib;
740                         time_t write_time;
741                 } in;
742         } setattr;
743
744         /* RAW_SFILEINFO_SETATTRE (SMBsetattrE) interface - only via setfileinfo() */
745         struct {
746                 enum setfileinfo_level level;
747                 union setfileinfo_file file;
748
749                 struct {
750                         time_t create_time;
751                         time_t access_time;
752                         time_t write_time;
753                 } in;
754         } setattre;
755
756         
757         /* RAW_SFILEINFO_STANDARD interface */
758         struct {
759                 enum setfileinfo_level level;
760                 union setfileinfo_file file;
761                 struct {
762                         time_t create_time;
763                         time_t access_time;
764                         time_t write_time;
765                         /* notice that size, alloc_size and attrib are not settable,
766                            unlike the corresponding qfileinfo level */
767                 } in;
768         } standard;
769
770         /* RAW_SFILEINFO_EA_SET interface */
771         struct {
772                 enum setfileinfo_level level;
773                 union setfileinfo_file file;
774                 struct {
775                         struct ea_struct ea;
776                 } in;
777         } ea_set;
778
779         /* RAW_SFILEINFO_BASIC_INFO and
780            RAW_SFILEINFO_BASIC_INFORMATION interfaces */
781         struct {
782                 enum setfileinfo_level level;
783                 union setfileinfo_file file;
784
785                 struct {
786                         NTTIME create_time;
787                         NTTIME access_time;
788                         NTTIME write_time;
789                         NTTIME change_time;
790                         uint32_t attrib;
791                 } in;
792         } basic_info;
793
794         /* RAW_SFILEINFO_DISPOSITION_INFO and 
795            RAW_SFILEINFO_DISPOSITION_INFORMATION interfaces */
796         struct {
797                 enum setfileinfo_level level;
798                 union setfileinfo_file file;
799
800                 struct {
801                         BOOL delete_on_close;
802                 } in;
803         } disposition_info;
804
805         /* RAW_SFILEINFO_ALLOCATION_INFO and 
806            RAW_SFILEINFO_ALLOCATION_INFORMATION interfaces */
807         struct {
808                 enum setfileinfo_level level;
809                 union setfileinfo_file file;
810
811                 struct {
812                         /* w2k3 rounds this up to nearest 4096 */
813                         uint64_t alloc_size;
814                 } in;
815         } allocation_info;
816         
817         /* RAW_SFILEINFO_END_OF_FILE_INFO and 
818            RAW_SFILEINFO_END_OF_FILE_INFORMATION interfaces */
819         struct {
820                 enum setfileinfo_level level;
821                 union setfileinfo_file file;
822
823                 struct {
824                         uint64_t size;
825                 } in;
826         } end_of_file_info;
827
828         /* RAW_SFILEINFO_RENAME_INFORMATION interface */
829         struct {
830                 enum setfileinfo_level level;
831                 union setfileinfo_file file;
832
833                 struct {
834                         uint8 overwrite;
835                         uint32_t root_fid;
836                         const char *new_name;
837                 } in;
838         } rename_information;
839
840         /* RAW_SFILEINFO_POSITION_INFORMATION interface */
841         struct {
842                 enum setfileinfo_level level;
843                 union setfileinfo_file file;
844
845                 struct {
846                         uint64_t position;
847                 } in;
848         } position_information;
849
850         /* RAW_SFILEINFO_MODE_INFORMATION interface */
851         struct {
852                 enum setfileinfo_level level;
853                 union setfileinfo_file file;
854
855                 struct {
856                         /* valid values seem to be 0, 2, 4 and 6 */
857                         uint32_t mode;
858                 } in;
859         } mode_information;
860
861
862
863         /* RAW_SFILEINFO_UNIX_BASIC interface */
864         struct {
865                 enum setfileinfo_level level;
866                 union setfileinfo_file file;
867                 struct {
868                         uint32_t mode; /* yuck - this field remains to fix compile of libcli/clifile.c */
869                         uint64_t end_of_file;
870                         uint64_t num_bytes;
871                         NTTIME status_change_time;
872                         NTTIME access_time;
873                         NTTIME change_time;
874                         uint64_t uid;
875                         uint64_t gid;
876                         uint32_t file_type;
877                         uint64_t dev_major;
878                         uint64_t dev_minor;
879                         uint64_t unique_id;
880                         uint64_t permissions;
881                         uint64_t nlink;
882                 } in;
883         } unix_basic;
884         
885         /* RAW_SFILEINFO_UNIX_LINK, RAW_SFILEINFO_UNIX_HLINK interface */
886         struct {
887                 enum setfileinfo_level level;
888                 union setfileinfo_file file;
889                 struct {
890                         const char *link_dest;
891                 } in;
892         } unix_link, unix_hlink;
893 };
894
895
896 enum fsinfo_level {RAW_QFS_GENERIC                        = 0xF000, 
897                    RAW_QFS_DSKATTR,                         /* SMBdskattr */
898                    RAW_QFS_ALLOCATION                     = SMB_QFS_ALLOCATION,
899                    RAW_QFS_VOLUME                         = SMB_QFS_VOLUME,
900                    RAW_QFS_VOLUME_INFO                    = SMB_QFS_VOLUME_INFO,
901                    RAW_QFS_SIZE_INFO                      = SMB_QFS_SIZE_INFO,
902                    RAW_QFS_DEVICE_INFO                    = SMB_QFS_DEVICE_INFO,
903                    RAW_QFS_ATTRIBUTE_INFO                 = SMB_QFS_ATTRIBUTE_INFO,
904                    RAW_QFS_UNIX_INFO                      = SMB_QFS_UNIX_INFO,
905                    RAW_QFS_VOLUME_INFORMATION             = SMB_QFS_VOLUME_INFORMATION,
906                    RAW_QFS_SIZE_INFORMATION               = SMB_QFS_SIZE_INFORMATION,
907                    RAW_QFS_DEVICE_INFORMATION             = SMB_QFS_DEVICE_INFORMATION,
908                    RAW_QFS_ATTRIBUTE_INFORMATION          = SMB_QFS_ATTRIBUTE_INFORMATION,
909                    RAW_QFS_QUOTA_INFORMATION              = SMB_QFS_QUOTA_INFORMATION,
910                    RAW_QFS_FULL_SIZE_INFORMATION          = SMB_QFS_FULL_SIZE_INFORMATION,
911                    RAW_QFS_OBJECTID_INFORMATION           = SMB_QFS_OBJECTID_INFORMATION};
912
913
914 /* union for fsinfo() backend call. Note that there are no in
915    structures, as this call only contains out parameters */
916 union smb_fsinfo {
917         /* generic interface */
918         struct {
919                 enum fsinfo_level level;
920
921                 struct {
922                         uint32_t block_size;
923                         uint64_t blocks_total;
924                         uint64_t blocks_free;
925                         uint32_t fs_id;
926                         NTTIME create_time;
927                         uint32_t serial_number;
928                         uint32_t fs_attr;
929                         uint32_t max_file_component_length;
930                         uint32_t device_type;
931                         uint32_t device_characteristics;
932                         uint64_t quota_soft;
933                         uint64_t quota_hard;
934                         uint64_t quota_flags;
935                         struct GUID guid;
936                         char *volume_name;
937                         char *fs_type;
938                 } out;
939         } generic;
940
941         /* SMBdskattr interface */
942         struct {
943                 enum fsinfo_level level;
944
945                 struct {
946                         uint16_t units_total;
947                         uint16_t blocks_per_unit;
948                         uint16_t block_size;
949                         uint16_t units_free;
950                 } out;
951         } dskattr;
952
953         /* trans2 RAW_QFS_ALLOCATION interface */
954         struct {
955                 enum fsinfo_level level;
956
957                 struct {
958                         uint32_t fs_id;
959                         uint32_t sectors_per_unit;
960                         uint32_t total_alloc_units;
961                         uint32_t avail_alloc_units;
962                         uint16_t bytes_per_sector;
963                 } out;
964         } allocation;
965
966         /* TRANS2 RAW_QFS_VOLUME interface */
967         struct {
968                 enum fsinfo_level level;
969
970                 struct {
971                         uint32_t serial_number;
972                         WIRE_STRING volume_name;
973                 } out;
974         } volume;
975
976         /* TRANS2 RAW_QFS_VOLUME_INFO and RAW_QFS_VOLUME_INFORMATION interfaces */
977         struct {
978                 enum fsinfo_level level;
979
980                 struct {
981                         NTTIME create_time;
982                         uint32_t serial_number;
983                         WIRE_STRING volume_name;
984                 } out;
985         } volume_info;
986
987         /* trans2 RAW_QFS_SIZE_INFO and RAW_QFS_SIZE_INFORMATION interfaces */
988         struct {
989                 enum fsinfo_level level;
990
991                 struct {
992                         uint64_t total_alloc_units;
993                         uint64_t avail_alloc_units; /* maps to call_avail_alloc_units */
994                         uint32_t sectors_per_unit;
995                         uint32_t bytes_per_sector;
996                 } out;
997         } size_info;
998
999         /* TRANS2 RAW_QFS_DEVICE_INFO and RAW_QFS_DEVICE_INFORMATION interfaces */
1000         struct {
1001                 enum fsinfo_level level;
1002
1003                 struct {
1004                         uint32_t device_type;
1005                         uint32_t characteristics;
1006                 } out;
1007         } device_info;
1008
1009
1010         /* TRANS2 RAW_QFS_ATTRIBUTE_INFO and RAW_QFS_ATTRIBUTE_INFORMATION interfaces */
1011         struct {
1012                 enum fsinfo_level level;
1013
1014                 struct {
1015                         uint32_t fs_attr;
1016                         uint32_t max_file_component_length;
1017                         WIRE_STRING fs_type;
1018                 } out;
1019         } attribute_info;
1020
1021
1022         /* TRANS2 RAW_QFS_UNIX_INFO interface */
1023         struct {
1024                 enum fsinfo_level level;
1025
1026                 struct {
1027                         uint16_t major_version;
1028                         uint16_t minor_version;
1029                         uint64_t capability;
1030                 } out;
1031         } unix_info;
1032
1033         /* trans2 RAW_QFS_QUOTA_INFORMATION interface */
1034         struct {
1035                 enum fsinfo_level level;
1036
1037                 struct {
1038                         uint64_t unknown[3];
1039                         uint64_t quota_soft;
1040                         uint64_t quota_hard;
1041                         uint64_t quota_flags;
1042                 } out;
1043         } quota_information;    
1044
1045         /* trans2 RAW_QFS_FULL_SIZE_INFORMATION interface */
1046         struct {
1047                 enum fsinfo_level level;
1048
1049                 struct {
1050                         uint64_t total_alloc_units;
1051                         uint64_t call_avail_alloc_units;
1052                         uint64_t actual_avail_alloc_units;
1053                         uint32_t sectors_per_unit;
1054                         uint32_t bytes_per_sector;
1055                 } out;
1056         } full_size_information;
1057
1058         /* trans2 RAW_QFS_OBJECTID_INFORMATION interface */
1059         struct {
1060                 enum fsinfo_level level;
1061
1062                 struct {
1063                         struct GUID  guid;
1064                         uint64_t unknown[6];
1065                 } out;
1066         } objectid_information; 
1067 };
1068
1069
1070
1071 enum open_level {RAW_OPEN_OPEN, RAW_OPEN_OPENX, 
1072                  RAW_OPEN_MKNEW, RAW_OPEN_CREATE, 
1073                  RAW_OPEN_CTEMP, RAW_OPEN_SPLOPEN,
1074                  RAW_OPEN_NTCREATEX, RAW_OPEN_T2OPEN};
1075
1076 /* the generic interface is defined to be equal to the NTCREATEX interface */
1077 #define RAW_OPEN_GENERIC RAW_OPEN_NTCREATEX
1078
1079 /* union for open() backend call */
1080 union smb_open {
1081         /* SMBNTCreateX interface */
1082         struct {
1083                 enum open_level level;
1084
1085                 struct {
1086                         uint32_t flags;
1087                         uint32_t root_fid;
1088                         uint32_t access_mask;
1089                         uint64_t alloc_size;
1090                         uint32_t file_attr;
1091                         uint32_t share_access;
1092                         uint32_t open_disposition;
1093                         uint32_t create_options;
1094                         uint32_t impersonation;
1095                         uint8  security_flags;
1096                         const char *fname;
1097                 } in;
1098
1099                 struct {
1100                         uint8 oplock_level;
1101                         uint16_t fnum;
1102                         uint32_t create_action;
1103                         NTTIME create_time;
1104                         NTTIME access_time;
1105                         NTTIME write_time;
1106                         NTTIME change_time;
1107                         uint32_t attrib;
1108                         uint64_t alloc_size;
1109                         uint64_t size;
1110                         uint16_t file_type;
1111                         uint16_t ipc_state;
1112                         uint8  is_directory;
1113                 } out;
1114         } ntcreatex, generic;
1115
1116         /* TRANS2_OPEN interface */
1117         struct {
1118                 enum open_level level;
1119
1120                 struct {
1121                         uint16_t flags;
1122                         uint16_t open_mode;
1123                         uint16_t file_attrs;
1124                         time_t write_time;
1125                         uint16_t open_func;
1126                         uint32_t size;
1127                         uint32_t timeout;
1128                         const char *fname;
1129                         uint_t num_eas;
1130                         struct ea_struct *eas;                  
1131                 } in;
1132
1133                 struct {
1134                         uint16_t fnum;
1135                         uint16_t attrib;
1136                         time_t write_time;
1137                         uint32_t size;
1138                         uint16_t access;
1139                         uint16_t ftype;
1140                         uint16_t devstate;
1141                         uint16_t action;
1142                         uint32_t unknown;
1143                 } out;
1144         } t2open;
1145
1146         /* SMBopen interface */
1147         struct {
1148                 enum open_level level;
1149
1150                 struct {
1151                         uint16_t flags;
1152                         uint16_t search_attrs;
1153                         const char *fname;
1154                 } in;
1155                 struct {
1156                         uint16_t fnum;
1157                         uint16_t attrib;
1158                         time_t write_time;
1159                         uint32_t size;
1160                         uint16_t rmode;
1161                 } out;
1162         } open;
1163
1164         /* SMBopenX interface */
1165         struct {
1166                 enum open_level level;
1167
1168                 struct {
1169                         uint16_t flags;
1170                         uint16_t open_mode;
1171                         uint16_t search_attrs; /* not honoured by win2003 */
1172                         uint16_t file_attrs;
1173                         time_t write_time; /* not honoured by win2003 */
1174                         uint16_t open_func;
1175                         uint32_t size; /* note that this sets the
1176                                         initial file size, not
1177                                         just allocation size */
1178                         uint32_t timeout; /* not honoured by win2003 */
1179                         const char *fname;
1180                 } in;
1181                 struct {
1182                         uint16_t fnum;
1183                         uint16_t attrib;
1184                         time_t write_time;
1185                         uint32_t size;
1186                         uint16_t access;
1187                         uint16_t ftype;
1188                         uint16_t devstate;
1189                         uint16_t action;
1190                         uint32_t unique_fid;
1191                         uint32_t access_mask;
1192                         uint32_t unknown;
1193                 } out;
1194         } openx;
1195
1196         /* SMBmknew interface */
1197         struct {
1198                 enum open_level level;
1199
1200                 struct {
1201                         uint16_t attrib;
1202                         time_t write_time;
1203                         const char *fname;
1204                 } in;
1205                 struct {
1206                         uint16_t fnum;
1207                 } out;
1208         } mknew, create;
1209
1210         /* SMBctemp interface */
1211         struct {
1212                 enum open_level level;
1213
1214                 struct {
1215                         uint16_t attrib;
1216                         time_t write_time;
1217                         const char *directory;
1218                 } in;
1219                 struct {
1220                         uint16_t fnum;
1221                         /* temp name, relative to directory */
1222                         char *name; 
1223                 } out;
1224         } ctemp;
1225
1226         /* SMBsplopen interface */
1227         struct {
1228                 enum open_level level;
1229
1230                 struct {
1231                         uint16_t setup_length;
1232                         uint16_t mode;
1233                         const char *ident;
1234                 } in;
1235                 struct {
1236                         uint16_t fnum;
1237                 } out;
1238         } splopen;
1239 };
1240
1241
1242
1243 enum read_level {RAW_READ_GENERIC, RAW_READ_READBRAW, RAW_READ_LOCKREAD, RAW_READ_READ, RAW_READ_READX};
1244
1245 /* union for read() backend call 
1246
1247    note that .infoX.out.data will be allocated before the backend is
1248    called. It will be big enough to hold the maximum size asked for
1249 */
1250 union smb_read {
1251         /* generic interface */
1252         struct {
1253                 enum read_level level;
1254
1255                 struct {
1256                         uint16_t fnum;
1257                         uint64_t offset;
1258                         uint32_t    size;
1259                 } in;
1260                 struct {
1261                         char *data;
1262                         uint32_t nread;
1263                 } out;
1264         } generic;
1265
1266
1267         /* SMBreadbraw interface */
1268         struct {
1269                 enum read_level level;
1270
1271                 struct {
1272                         uint16_t fnum;
1273                         uint64_t offset;
1274                         uint16_t  maxcnt;
1275                         uint16_t  mincnt;
1276                         uint32_t  timeout;
1277                 } in;
1278                 struct {
1279                         char *data;
1280                         uint32_t nread;
1281                 } out;
1282         } readbraw;
1283
1284
1285         /* SMBlockandread interface */
1286         struct {
1287                 enum 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         } lockread;
1300
1301         /* SMBread interface */
1302         struct {
1303                 enum read_level level;
1304
1305                 struct {
1306                         uint16_t fnum;
1307                         uint16_t count;
1308                         uint32_t offset;
1309                         uint16_t remaining;
1310                 } in;
1311                 struct {
1312                         char *data;
1313                         uint16_t nread;
1314                 } out;
1315         } read;
1316
1317         /* SMBreadX interface */
1318         struct {
1319                 enum read_level level;
1320
1321                 struct {
1322                         uint16_t fnum;
1323                         uint64_t offset;
1324                         uint16_t mincnt;
1325                         uint16_t maxcnt;
1326                         uint16_t remaining;
1327                 } in;
1328                 struct {
1329                         char *data;
1330                         uint16_t remaining;
1331                         uint16_t compaction_mode;
1332                         uint16_t nread;
1333                 } out;
1334         } readx;
1335 };
1336
1337
1338 enum write_level {RAW_WRITE_GENERIC, RAW_WRITE_WRITEUNLOCK, RAW_WRITE_WRITE, 
1339                   RAW_WRITE_WRITEX, RAW_WRITE_WRITECLOSE, RAW_WRITE_SPLWRITE};
1340
1341 /* union for write() backend call 
1342 */
1343 union smb_write {
1344         /* generic interface */
1345         struct {
1346                 enum write_level level;
1347
1348                 struct {
1349                         uint16_t fnum;
1350                         uint64_t offset;
1351                         uint32_t    count;
1352                         const char *data;
1353                 } in;
1354                 struct {
1355                         uint32_t nwritten;
1356                 } out;
1357         } generic;
1358
1359
1360         /* SMBwriteunlock interface */
1361         struct {
1362                 enum write_level level;
1363
1364                 struct {
1365                         uint16_t fnum;
1366                         uint16_t count;
1367                         uint32_t offset;
1368                         uint16_t remaining;
1369                         const char *data;
1370                 } in;
1371                 struct {
1372                         uint32_t nwritten;
1373                 } out;
1374         } writeunlock;
1375
1376         /* SMBwrite interface */
1377         struct {
1378                 enum write_level level;
1379
1380                 struct {
1381                         uint16_t fnum;
1382                         uint16_t count;
1383                         uint32_t offset;
1384                         uint16_t remaining;
1385                         const char *data;
1386                 } in;
1387                 struct {
1388                         uint16_t nwritten;
1389                 } out;
1390         } write;
1391
1392         /* SMBwriteX interface */
1393         struct {
1394                 enum write_level level;
1395
1396                 struct {
1397                         uint16_t fnum;
1398                         uint64_t offset;
1399                         uint16_t wmode;
1400                         uint16_t remaining;
1401                         uint32_t count;
1402                         const char *data;
1403                 } in;
1404                 struct {
1405                         uint32_t nwritten;
1406                         uint16_t remaining;
1407                 } out;
1408         } writex;
1409
1410         /* SMBwriteclose interface */
1411         struct {
1412                 enum write_level level;
1413
1414                 struct {
1415                         uint16_t fnum;
1416                         uint16_t count;
1417                         uint32_t offset;
1418                         time_t mtime;
1419                         const char *data;
1420                 } in;
1421                 struct {
1422                         uint16_t nwritten;
1423                 } out;
1424         } writeclose;
1425
1426         /* SMBsplwrite interface */
1427         struct {
1428                 enum write_level level;
1429
1430                 struct {
1431                         uint16_t fnum;
1432                         uint16_t count;
1433                         const char *data;
1434                 } in;
1435         } splwrite;
1436 };
1437
1438
1439 enum lock_level {RAW_LOCK_GENERIC, RAW_LOCK_LOCK, RAW_LOCK_UNLOCK, RAW_LOCK_LOCKX};
1440
1441 /* union for lock() backend call 
1442 */
1443 union smb_lock {
1444         /* generic interface */
1445         struct {
1446                 enum lock_level level;
1447
1448         } generic;
1449
1450         /* SMBlock interface */
1451         struct {
1452                 enum lock_level level;
1453
1454                 struct {
1455                         uint16_t fnum;
1456                         uint32_t count;
1457                         uint32_t offset;
1458                 } in;
1459         } lock;
1460
1461         /* SMBunlock interface */
1462         struct {
1463                 enum lock_level level;
1464
1465                 struct {
1466                         uint16_t fnum;
1467                         uint32_t count;
1468                         uint32_t offset;
1469                 } in;
1470         } unlock;
1471
1472         /* SMBlockingX interface */
1473         struct {
1474                 enum lock_level level;
1475
1476                 struct {
1477                         uint16_t fnum;
1478                         uint16_t mode;
1479                         uint32_t timeout;
1480                         uint16_t ulock_cnt;
1481                         uint16_t lock_cnt;
1482                         struct smb_lock_entry {
1483                                 uint16_t pid;
1484                                 uint64_t offset;
1485                                 uint64_t count;
1486                         } *locks; /* unlocks are first in the arrray */
1487                 } in;
1488         } lockx;
1489 };
1490
1491
1492 enum close_enum {RAW_CLOSE_GENERIC, RAW_CLOSE_CLOSE, RAW_CLOSE_SPLCLOSE};
1493
1494 /*
1495   union for close() backend call
1496 */
1497 union smb_close {
1498         /* generic interface */
1499         struct {
1500                 enum close_enum level;
1501
1502                 struct {
1503                         uint16_t fnum;
1504                 } in;
1505         } generic;
1506
1507         /* SMBclose interface */
1508         struct {
1509                 enum close_enum level;
1510
1511                 struct {
1512                         uint16_t fnum;
1513                         time_t write_time;
1514                 } in;
1515         } close;
1516
1517         /* SMBsplclose interface - empty! */
1518         struct {
1519                 enum close_enum level;
1520
1521                 struct {
1522                         uint16_t fnum;
1523                 } in;
1524         } splclose;
1525 };
1526
1527
1528 enum lpq_level {RAW_LPQ_GENERIC, RAW_LPQ_RETQ};
1529
1530 /*
1531   union for lpq() backend
1532 */
1533 union smb_lpq {
1534         /* generic interface */
1535         struct {
1536                 enum lpq_level level;
1537
1538         } generic;
1539
1540
1541         /* SMBsplretq interface */
1542         struct {
1543                 enum lpq_level level;
1544
1545                 struct {
1546                         uint16_t maxcount;
1547                         uint16_t startidx;
1548                 } in;
1549                 struct {
1550                         uint16_t count;
1551                         uint16_t restart_idx;
1552                         struct {
1553                                 time_t time;
1554                                 uint8 status;
1555                                 uint16_t job;
1556                                 uint32_t size;
1557                                 char *user;
1558                         } *queue;
1559                 } out;
1560         } retq;
1561 };
1562
1563 enum ioctl_level {RAW_IOCTL_IOCTL, RAW_IOCTL_NTIOCTL};
1564
1565 /*
1566   union for ioctl() backend
1567 */
1568 union smb_ioctl {
1569         /* generic interface */
1570         struct {
1571                 enum ioctl_level level;
1572
1573         } generic;
1574
1575         /* struct for SMBioctl */
1576         struct {
1577                 enum ioctl_level level;
1578                 struct {
1579                         uint16_t fnum;
1580                         uint32_t request;
1581                 } in;
1582                 struct {
1583                         DATA_BLOB blob;
1584                 } out;
1585         } ioctl;
1586
1587
1588         /* struct for NT ioctl call */
1589         struct {
1590                 enum ioctl_level level;
1591                 struct {
1592                         uint32_t function;
1593                         uint16_t fnum;
1594                         BOOL fsctl;
1595                         uint8 filter;
1596                 } in;
1597                 struct {
1598                         DATA_BLOB blob;
1599                 } out;
1600         } ntioctl;
1601 };
1602
1603 /* struct for SMBflush */
1604 struct smb_flush {
1605         struct {
1606                 uint16_t fnum;
1607         } in;
1608 };
1609
1610
1611 /* struct for SMBcopy */
1612 struct smb_copy {
1613         struct {
1614                 uint16_t tid2;
1615                 uint16_t ofun;
1616                 uint16_t flags;
1617                 const char *path1;
1618                 const char *path2;
1619         } in;
1620         struct {
1621                 uint16_t count;
1622         } out;
1623 };
1624
1625
1626 /* struct for transact/transact2 call */
1627 struct smb_trans2 {
1628         struct {
1629                 uint16_t max_param;
1630                 uint16_t max_data;
1631                 uint8  max_setup;
1632                 uint16_t flags;
1633                 uint32_t timeout;
1634                 uint8  setup_count;
1635                 uint16_t *setup;
1636                 const char *trans_name; /* SMBtrans only */
1637                 DATA_BLOB params;
1638                 DATA_BLOB data;
1639         } in;
1640
1641         struct {
1642                 uint8  setup_count;
1643                 uint16_t *setup;
1644                 DATA_BLOB params;
1645                 DATA_BLOB data;
1646         } out;
1647 };
1648
1649 /* struct for nttransact2 call */
1650 struct smb_nttrans {
1651         struct {
1652                 uint8  max_setup;
1653                 uint32_t max_param;
1654                 uint32_t max_data;
1655                 uint32_t setup_count;
1656                 uint16_t function;
1657                 uint16_t *setup;
1658                 DATA_BLOB params;
1659                 DATA_BLOB data;
1660         } in;
1661
1662         struct {
1663                 uint8  setup_count;
1664                 uint16_t *setup;
1665                 DATA_BLOB params;
1666                 DATA_BLOB data;
1667         } out;
1668 };
1669
1670
1671 /* struct for nttrans change notify call */
1672 struct smb_notify {
1673         struct {
1674                 uint32_t buffer_size;
1675                 uint32_t completion_filter;
1676                 uint16_t fnum;
1677                 BOOL recursive;
1678         } in;
1679
1680         struct {
1681                 uint32_t num_changes;
1682                 struct {
1683                         uint32_t action;
1684                         WIRE_STRING name;
1685                 } *changes;
1686         } out;
1687 };
1688
1689
1690 enum search_level {RAW_SEARCH_GENERIC                 = 0xF000, 
1691                    RAW_SEARCH_SEARCH,                 /* SMBsearch */ 
1692                    RAW_SEARCH_FCLOSE,                             /* SMBfclose */
1693                    RAW_SEARCH_STANDARD                = SMB_FIND_STANDARD,
1694                    RAW_SEARCH_EA_SIZE                 = SMB_FIND_EA_SIZE,
1695                    RAW_SEARCH_DIRECTORY_INFO          = SMB_FIND_DIRECTORY_INFO,
1696                    RAW_SEARCH_FULL_DIRECTORY_INFO     = SMB_FIND_FULL_DIRECTORY_INFO,
1697                    RAW_SEARCH_NAME_INFO               = SMB_FIND_NAME_INFO,
1698                    RAW_SEARCH_BOTH_DIRECTORY_INFO     = SMB_FIND_BOTH_DIRECTORY_INFO,
1699                    RAW_SEARCH_ID_FULL_DIRECTORY_INFO  = SMB_FIND_ID_FULL_DIRECTORY_INFO,
1700                    RAW_SEARCH_ID_BOTH_DIRECTORY_INFO  = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
1701                    RAW_SEARCH_UNIX_INFO               = SMB_FIND_UNIX_INFO};
1702
1703         
1704 /* union for file search */
1705 union smb_search_first {
1706         struct {
1707                 enum search_level level;
1708         } generic;
1709         
1710         /* search (old) findfirst interface */
1711         struct {
1712                 enum search_level level;
1713         
1714                 struct {
1715                         uint16_t max_count;
1716                         uint16_t search_attrib;
1717                         const char *pattern;
1718                 } in;
1719                 struct {
1720                         int16_t count;
1721                 } out;
1722         } search_first;
1723
1724         /* trans2 findfirst interface */
1725         struct {
1726                 enum search_level level;
1727                 
1728                 struct {
1729                         uint16_t search_attrib;
1730                         uint16_t max_count;
1731                         uint16_t flags;
1732                         uint32_t storage_type;
1733                         const char *pattern;
1734                 } in;
1735                 struct {
1736                         uint16_t handle;
1737                         uint16_t count;
1738                         uint16_t end_of_search;
1739                 } out;
1740         } t2ffirst;
1741 };
1742
1743 /* union for file search continue */
1744 union smb_search_next {
1745         struct {
1746                 enum search_level level;
1747         } generic;
1748
1749         /* search (old) findnext interface */
1750         struct {
1751                 enum search_level level;
1752         
1753                 struct {
1754                         uint16_t max_count;
1755                         uint16_t search_attrib;
1756                         DATA_BLOB search_id;
1757                 } in;
1758                 struct {
1759                         uint16_t count;
1760                 } out;
1761         } search_next;
1762         
1763         /* trans2 findnext interface */
1764         struct {
1765                 enum search_level level;
1766                 
1767                 struct {
1768                         uint16_t handle;
1769                         uint16_t max_count;
1770                         uint32_t resume_key;
1771                         uint16_t flags;
1772                         const char *last_name;
1773                 } in;
1774                 struct {
1775                         uint16_t count;
1776                         uint16_t end_of_search;
1777                 } out;
1778         } t2fnext;
1779 };
1780
1781 /* union for search reply file data */
1782 union smb_search_data {
1783         /* search (old) findfirst */
1784         struct {
1785                 uint16_t attrib;
1786                 time_t write_time;
1787                 uint32_t size;
1788                 DATA_BLOB search_id;  /* used to resume search from this point */
1789                 char *name;
1790         } search;
1791         
1792         /* trans2 findfirst RAW_SEARCH_STANDARD level */
1793         struct {
1794                 uint32_t resume_key;
1795                 time_t create_time;
1796                 time_t access_time;
1797                 time_t write_time;
1798                 uint32_t size;
1799                 uint32_t alloc_size;
1800                 uint16_t attrib;
1801                 WIRE_STRING name;
1802         } standard;
1803
1804         /* trans2 findfirst RAW_SEARCH_EA_SIZE level */
1805         struct {
1806                 uint32_t resume_key;
1807                 time_t create_time;
1808                 time_t access_time;
1809                 time_t write_time;
1810                 uint32_t size;
1811                 uint32_t alloc_size;
1812                 uint16_t attrib;
1813                 uint32_t ea_size;
1814                 WIRE_STRING name;
1815         } ea_size;
1816
1817         /* RAW_SEARCH_DIRECTORY_INFO interface */
1818         struct {
1819                 uint32_t file_index;
1820                 NTTIME create_time;
1821                 NTTIME access_time;
1822                 NTTIME write_time;
1823                 NTTIME change_time;
1824                 uint64_t  size;
1825                 uint64_t  alloc_size;
1826                 uint32_t   attrib;
1827                 WIRE_STRING name;
1828         } directory_info;
1829
1830         /* RAW_SEARCH_FULL_DIRECTORY_INFO interface */
1831         struct {
1832                 uint32_t file_index;
1833                 NTTIME create_time;
1834                 NTTIME access_time;
1835                 NTTIME write_time;
1836                 NTTIME change_time;
1837                 uint64_t  size;
1838                 uint64_t  alloc_size;
1839                 uint32_t   attrib;
1840                 uint32_t   ea_size;
1841                 WIRE_STRING name;
1842         } full_directory_info;
1843
1844         /* RAW_SEARCH_NAME_INFO interface */
1845         struct {
1846                 uint32_t file_index;
1847                 WIRE_STRING name;
1848         } name_info;
1849
1850         /* RAW_SEARCH_BOTH_DIRECTORY_INFO interface */
1851         struct {
1852                 uint32_t file_index;
1853                 NTTIME create_time;
1854                 NTTIME access_time;
1855                 NTTIME write_time;
1856                 NTTIME change_time;
1857                 uint64_t  size;
1858                 uint64_t  alloc_size;
1859                 uint32_t   attrib;
1860                 uint32_t   ea_size;
1861                 WIRE_STRING short_name;
1862                 WIRE_STRING name;
1863         } both_directory_info;
1864
1865         /* RAW_SEARCH_ID_FULL_DIRECTORY_INFO interface */
1866         struct {
1867                 uint32_t file_index;
1868                 NTTIME create_time;
1869                 NTTIME access_time;
1870                 NTTIME write_time;
1871                 NTTIME change_time;
1872                 uint64_t size;
1873                 uint64_t alloc_size;
1874                 uint32_t attrib;
1875                 uint32_t ea_size;
1876                 uint64_t file_id;
1877                 WIRE_STRING name;
1878         } id_full_directory_info;
1879
1880         /* RAW_SEARCH_ID_BOTH_DIRECTORY_INFO interface */
1881         struct {
1882                 uint32_t file_index;
1883                 NTTIME create_time;
1884                 NTTIME access_time;
1885                 NTTIME write_time;
1886                 NTTIME change_time;
1887                 uint64_t size;
1888                 uint64_t alloc_size;
1889                 uint32_t  attrib;
1890                 uint32_t  ea_size;
1891                 uint64_t file_id;
1892                 WIRE_STRING short_name;
1893                 WIRE_STRING name;
1894         } id_both_directory_info;
1895
1896         /* RAW_SEARCH_UNIX_INFO interface */
1897         struct {
1898                 uint32_t file_index;
1899                 uint64_t size;
1900                 uint64_t alloc_size;
1901                 NTTIME status_change_time;
1902                 NTTIME access_time;
1903                 NTTIME change_time;
1904                 uint64_t uid;
1905                 uint64_t gid;
1906                 uint32_t file_type;
1907                 uint64_t dev_major;
1908                 uint64_t dev_minor;
1909                 uint64_t unique_id;
1910                 uint64_t permissions;
1911                 uint64_t nlink;         
1912                 const char *name;
1913         } unix_info;
1914 };
1915
1916
1917 enum search_close_level {RAW_FINDCLOSE_GENERIC, RAW_FINDCLOSE_CLOSE};
1918
1919 /* union for file search close */
1920 union smb_search_close {
1921         struct {
1922                 enum search_close_level level;
1923         } generic;
1924
1925         /* SMBfclose (old search) interface */
1926         struct {
1927                 enum search_level level;
1928         
1929                 struct {
1930                         uint16_t max_count;
1931                         uint16_t search_attrib;
1932                         DATA_BLOB search_id;
1933                 } in;
1934                 struct {
1935                         uint16_t count;
1936                 } out;
1937         } search_next;
1938         
1939         /* SMBfindclose interface */
1940         struct {
1941                 enum search_close_level level;
1942                 
1943                 struct {
1944                         uint16_t handle;
1945                 } in;
1946         } findclose;
1947 };
1948