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