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