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