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