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