ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / fs / cifs / cifspdu.h
1 /*
2  *   fs/cifs/cifspdu.h
3  *
4  *   Copyright (c) International Business Machines  Corp., 2002
5  *   Author(s): Steve French (sfrench@us.ibm.com)
6  *
7  *   This library is free software; you can redistribute it and/or modify
8  *   it under the terms of the GNU Lesser General Public License as published
9  *   by the Free Software Foundation; either version 2.1 of the License, or
10  *   (at your option) any later version.
11  *
12  *   This library 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
15  *   the GNU Lesser General Public License for more details.
16  *
17  *   You should have received a copy of the GNU Lesser General Public License
18  *   along with this library; if not, write to the Free Software
19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
20  */
21
22 #ifndef _CIFSPDU_H
23 #define _CIFSPDU_H
24
25 #include <net/sock.h>
26
27 #define CIFS_PROT   0
28 #define BAD_PROT    CIFS_PROT+1
29
30 /* SMB command codes */
31 #define SMB_COM_CREATE_DIRECTORY      0x00
32 #define SMB_COM_DELETE_DIRECTORY      0x01
33 #define SMB_COM_CLOSE                 0x04
34 #define SMB_COM_DELETE                0x06
35 #define SMB_COM_RENAME                0x07
36 #define SMB_COM_LOCKING_ANDX          0x24
37 #define SMB_COM_READ_ANDX             0x2E
38 #define SMB_COM_WRITE_ANDX            0x2F
39 #define SMB_COM_TRANSACTION2          0x32
40 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
41 #define SMB_COM_FIND_CLOSE2           0x34
42 #define SMB_COM_TREE_DISCONNECT       0x71
43 #define SMB_COM_NEGOTIATE             0x72
44 #define SMB_COM_SESSION_SETUP_ANDX    0x73
45 #define SMB_COM_LOGOFF_ANDX           0x74
46 #define SMB_COM_TREE_CONNECT_ANDX     0x75
47 #define SMB_COM_NT_TRANSACT           0xA0
48 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
49 #define SMB_COM_NT_CREATE_ANDX        0xA2
50 #define SMB_COM_NT_RENAME             0xA5
51
52 /* Transact2 subcommand codes */
53 #define TRANS2_OPEN                   0x00
54 #define TRANS2_FIND_FIRST             0x01
55 #define TRANS2_FIND_NEXT              0x02
56 #define TRANS2_QUERY_FS_INFORMATION   0x03
57 #define TRANS2_QUERY_PATH_INFORMATION 0x05
58 #define TRANS2_SET_PATH_INFORMATION   0x06
59 #define TRANS2_QUERY_FILE_INFORMATION 0x07
60 #define TRANS2_SET_FILE_INFORMATION   0x08
61 #define TRANS2_GET_DFS_REFERRAL       0x10
62 #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
63
64 /* NT Transact subcommand codes */
65 #define NT_TRANSACT_CREATE            0x01
66 #define NT_TRANSACT_IOCTL             0x02
67 #define NT_TRANSACT_SET_SECURITY_DESC 0x03
68 #define NT_TRANSACT_NOTIFY_CHANGE     0x04
69 #define NT_TRANSACT_RENAME            0x05
70 #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
71 #define NT_TRANSACT_GET_USER_QUOTA    0x07
72 #define NT_TRANSACT_SET_USER_QUOTA    0x08
73
74 #define MAX_CIFS_HDR_SIZE 256   /* chained NTCreateXReadX will probably be biggest */
75
76 /* internal cifs vfs structures */
77 /*****************************************************************
78  * All constants go here
79  *****************************************************************
80  */
81
82 /*
83  * Starting value for maximum SMB size negotiation
84  */
85 #define CIFS_MAX_MSGSIZE (4*4096)
86
87 /*
88  * Size of encrypted user password in bytes
89  */
90 #define CIFS_ENCPWD_SIZE (16)
91
92 /*
93  * Size of the crypto key returned on the negotiate SMB in bytes
94  */
95 #define CIFS_CRYPTO_KEY_SIZE (8)
96
97 /*
98  * Size of the session key (crypto key encrypted with the password
99  */
100 #define CIFS_SESSION_KEY_SIZE (24)
101
102 /*
103  * Maximum user name length
104  */
105 #define CIFS_UNLEN (20)
106
107 /*
108  * Flags on SMB open
109  */
110 #define SMBOPEN_WRITE_THROUGH 0x4000
111 #define SMBOPEN_DENY_ALL      0x0010
112 #define SMBOPEN_DENY_WRITE    0x0020
113 #define SMBOPEN_DENY_READ     0x0030
114 #define SMBOPEN_DENY_NONE     0x0040
115 #define SMBOPEN_READ          0x0000
116 #define SMBOPEN_WRITE         0x0001
117 #define SMBOPEN_READWRITE     0x0002
118 #define SMBOPEN_EXECUTE       0x0003
119
120 #define SMBOPEN_OCREATE       0x0010
121 #define SMBOPEN_OTRUNC        0x0002
122 #define SMBOPEN_OAPPEND       0x0001
123
124 /*
125  * SMB flag definitions 
126  */
127 #define SMBFLG_EXTD_LOCK 0x01   /* server supports lock-read write-unlock primitives */
128 #define SMBFLG_RCV_POSTED 0x02  /* obsolete */
129 #define SMBFLG_RSVD 0x04
130 #define SMBFLG_CASELESS 0x08    /* all pathnames treated as caseless (off implies case sensitive file handling requested) */
131 #define SMBFLG_CANONICAL_PATH_FORMAT 0x10       /* obsolete */
132 #define SMBFLG_OLD_OPLOCK 0x20  /* obsolete */
133 #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40   /* obsolete */
134 #define SMBFLG_RESPONSE 0x80    /* this PDU is a response from server */
135
136 /*
137  * SMB flag2 definitions 
138  */
139 #define SMBFLG2_KNOWS_LONG_NAMES 0x0001 /* can send long (non-8.3) path names in response */
140 #define SMBFLG2_KNOWS_EAS 0x0002
141 #define SMBFLG2_SECURITY_SIGNATURE 0x0004
142 #define SMBFLG2_IS_LONG_NAME 0x0040
143 #define SMBFLG2_EXT_SEC 0x0800
144 #define SMBFLG2_DFS 0x1000
145 #define SMBFLG2_PAGING_IO 0x2000
146 #define SMBFLG2_ERR_STATUS 0x4000
147 #define SMBFLG2_UNICODE 0x8000
148
149 /*
150  * These are the file access permission bits defined in CIFS for the
151  * NTCreateAndX as well as the level 0x107
152  * TRANS2_QUERY_PATH_INFORMATION API.  The level 0x107, SMB_QUERY_FILE_ALL_INFO
153  * responds with the AccessFlags.
154  * The AccessFlags specifies the access permissions a caller has to the
155  * file and can have any suitable combination of the following values:
156  */
157
158 #define FILE_READ_DATA        0x00000001        /* Data can be read from the file   */
159 #define FILE_WRITE_DATA       0x00000002        /* Data can be written to the file  */
160 #define FILE_APPEND_DATA      0x00000004        /* Data can be appended to the file */
161 #define FILE_READ_EA          0x00000008        /* Extended attributes associated   */
162                                          /* with the file can be read        */
163 #define FILE_WRITE_EA         0x00000010        /* Extended attributes associated   */
164                                          /* with the file can be written     */
165 #define FILE_EXECUTE          0x00000020        /*Data can be read into memory from */
166                                          /* the file using system paging I/O */
167 #define FILE_DELETE_CHILD     0x00000040
168 #define FILE_READ_ATTRIBUTES  0x00000080        /* Attributes associated with the   */
169                                          /* file can be read                 */
170 #define FILE_WRITE_ATTRIBUTES 0x00000100        /* Attributes associated with the   */
171                                          /* file can be written              */
172 #define DELETE                0x00010000        /* The file can be deleted          */
173 #define READ_CONTROL          0x00020000        /* The access control list and      */
174                                          /* ownership associated with the    */
175                                          /* file can be read                 */
176 #define WRITE_DAC             0x00040000        /* The access control list and      */
177                                          /* ownership associated with the    */
178                                          /* file can be written.             */
179 #define WRITE_OWNER           0x00080000        /* Ownership information associated */
180                                          /* with the file can be written     */
181 #define SYNCHRONIZE           0x00100000        /* The file handle can waited on to */
182                                          /* synchronize with the completion  */
183                                          /* of an input/output request       */
184 #define GENERIC_ALL           0x10000000
185 #define GENERIC_EXECUTE       0x20000000
186 #define GENERIC_WRITE         0x40000000
187 #define GENERIC_READ          0x80000000
188                                          /* In summary - Relevant file       */
189                                          /* access flags from CIFS are       */
190                                          /* file_read_data, file_write_data  */
191                                          /* file_execute, file_read_attributes */
192                                          /* write_dac, and delete.           */
193
194 /*
195  * Invalid readdir handle
196  */
197 #define CIFS_NO_HANDLE        0xFFFF
198
199 /* IPC$ in ASCII */
200 #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
201
202 /* IPC$ in Unicode */
203 #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
204
205 /* Unicode Null terminate 2 bytes of 0 */
206 #define UNICODE_NULL "\x00\x00"
207 #define ASCII_NULL 0x00
208
209 /*
210  * Server type values (returned on EnumServer API
211  */
212 #define CIFS_SV_TYPE_DC     0x00000008
213 #define CIFS_SV_TYPE_BACKDC 0x00000010
214
215 /*
216  * Alias type flags (From EnumAlias API call
217  */
218 #define CIFS_ALIAS_TYPE_FILE 0x0001
219 #define CIFS_SHARE_TYPE_FILE 0x0000
220
221 /*
222  * File Attribute flags
223  */
224 #define ATTR_READONLY  0x0001
225 #define ATTR_HIDDEN    0x0002
226 #define ATTR_SYSTEM    0x0004
227 #define ATTR_VOLUME    0x0008
228 #define ATTR_DIRECTORY 0x0010
229 #define ATTR_ARCHIVE   0x0020
230 #define ATTR_DEVICE    0x0040
231 #define ATTR_NORMAL    0x0080
232 #define ATTR_TEMPORARY 0x0100
233 #define ATTR_SPARSE    0x0200
234 #define ATTR_REPARSE   0x0400
235 #define ATTR_COMPRESSED 0x0800
236 #define ATTR_OFFLINE    0x1000  /* ie file not immediately available - offline storage */
237 #define ATTR_NOT_CONTENT_INDEXED 0x2000
238 #define ATTR_ENCRYPTED  0x4000
239 #define ATTR_POSIX_SEMANTICS 0x01000000
240 #define ATTR_BACKUP_SEMANTICS 0x02000000
241 #define ATTR_DELETE_ON_CLOSE 0x04000000
242 #define ATTR_SEQUENTIAL_SCAN 0x08000000
243 #define ATTR_RANDOM_ACCESS   0x10000000
244 #define ATTR_NO_BUFFERING    0x20000000
245 #define ATTR_WRITE_THROUGH   0x80000000
246
247 /* ShareAccess flags */
248 #define FILE_NO_SHARE     0x00000000
249 #define FILE_SHARE_READ   0x00000001
250 #define FILE_SHARE_WRITE  0x00000002
251 #define FILE_SHARE_DELETE 0x00000004
252 #define FILE_SHARE_ALL    0x00000007
253
254 /* CreateDisposition flags */
255 #define FILE_SUPERSEDE    0x00000000
256 #define FILE_OPEN         0x00000001
257 #define FILE_CREATE       0x00000002
258 #define FILE_OPEN_IF      0x00000003
259 #define FILE_OVERWRITE    0x00000004
260 #define FILE_OVERWRITE_IF 0x00000005
261
262 /* CreateOptions */
263 #define CREATE_NOT_FILE         0x00000001      /* if set must not be file */
264 #define CREATE_WRITE_THROUGH    0x00000002
265 #define CREATE_NOT_DIR          0x00000040      /* if set must not be directory */
266 #define CREATE_RANDOM_ACCESS    0x00000800
267 #define CREATE_DELETE_ON_CLOSE  0x00001000
268 #define OPEN_REPARSE_POINT      0x00200000
269
270 /* ImpersonationLevel flags */
271 #define SECURITY_ANONYMOUS      0
272 #define SECURITY_IDENTIFICATION 1
273 #define SECURITY_IMPERSONATION  2
274 #define SECURITY_DELEGATION     3
275
276 /* SecurityFlags */
277 #define SECURITY_CONTEXT_TRACKING 0x01
278 #define SECURITY_EFFECTIVE_ONLY   0x02
279
280 /*
281  * Default PID value, used in all SMBs where the PID is not important
282  */
283 #define CIFS_DFT_PID  0x1234
284
285 /*
286  * We use the same routine for Copy and Move SMBs.  This flag is used to
287  * distinguish
288  */
289 #define CIFS_COPY_OP 1
290 #define CIFS_RENAME_OP 2
291
292 #define GETU16(var)  (*((__u16 *)var))  /* BB check for endian issues */
293 #define GETU32(var)  (*((__u32 *)var))  /* BB check for endian issues */
294
295 #pragma pack(1)
296
297 struct smb_hdr {
298         __u32 smb_buf_length;   /* big endian on wire *//* BB length is only two or three bytes - with one or two byte type preceding it but that is always zero - we could mask the type byte off just in case BB */
299         __u8 Protocol[4];
300         __u8 Command;
301         union {
302                 struct {
303                         __u8 ErrorClass;
304                         __u8 Reserved;
305                         __u16 Error;    /* note: treated as little endian (le) on wire */
306                 } DosError;
307                 __u32 CifsError;        /* note: le */
308         } Status;
309         __u8 Flags;
310         __u16 Flags2;           /* note: le */
311         __u16 PidHigh;          /* note: le */
312         union {
313                 struct {
314                         __u32 SequenceNumber;  /* le */
315                         __u32 Reserved; /* zero */
316                 } Sequence;
317                 __u8 SecuritySignature[8];      /* le */
318         } Signature;
319         __u8 pad[2];
320         __u16 Tid;
321         __u16 Pid;              /* note: le */
322         __u16 Uid;
323         __u16 Mid;
324         __u8 WordCount;
325 };
326 /* given a pointer to an smb_hdr retrieve the value of byte count */
327 #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
328
329 /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
330 #define pByteArea(smb_var) ((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 )
331
332 /*
333  * Computer Name Length
334  */
335 #define CNLEN 15
336
337 /*
338  * Share Name Length                                      @S8A
339  * Note:  This length is limited by the SMB used to get   @S8A
340  *        the Share info.   NetShareEnum only returns 13  @S8A
341  *        chars, including the null termination.          @S8A 
342  */
343 #define SNLEN 12                /*@S8A */
344
345 /*
346  * Comment Length
347  */
348 #define MAXCOMMENTLEN 40
349
350 /*
351  * The OS/2 maximum path name
352  */
353 #define MAX_PATHCONF 256
354
355 /*
356  *  SMB frame definitions  (following must be packed structs)
357  *  See the SNIA CIFS Specification for details.
358  *
359  *  The Naming convention is the lower case version of the
360  *  smb command code name for the struct and this is typedef to the
361  *  uppercase version of the same name with the prefix SMB_ removed 
362  *  for brevity.  Although typedefs are not commonly used for 
363  *  structure definitions in the Linux kernel, their use in the
364  *  CIFS standards document, which this code is based on, may
365  *  make this one of the cases where typedefs for structures make
366  *  sense to improve readability for readers of the standards doc.
367  *  Typedefs can always be removed later if they are too distracting
368  *  and they are only used for the CIFSs PDUs themselves, not
369  *  internal cifs vfs structures
370  *  
371  */
372
373 typedef struct negotiate_req {
374         struct smb_hdr hdr;     /* wct = 0 */
375         __u16 ByteCount;
376         unsigned char DialectsArray[1];
377 } NEGOTIATE_REQ;
378
379 typedef struct negotiate_rsp {
380         struct smb_hdr hdr;     /* wct = 17 */
381         __u16 DialectIndex;
382         __u8 SecurityMode;
383         __u16 MaxMpxCount;
384         __u16 MaxNumberVcs;
385         __u32 MaxBufferSize;
386         __u32 MaxRawSize;
387         __u32 SessionKey;
388         __u32 Capabilities;     /* see below */
389         __u32 SystemTimeLow;
390         __u32 SystemTimeHigh;
391         __u16 ServerTimeZone;
392         __u8 EncryptionKeyLength;
393         __u16 ByteCount;
394         union {
395                 unsigned char EncryptionKey[1]; /* if cap extended security is off */
396                 /* followed by Domain name - if extended security is off */
397                 /* followed by 16 bytes of server GUID */
398                 /* followed by security blob if cap_extended_security negotiated */
399                 struct {
400                         unsigned char GUID[16];
401                         unsigned char SecurityBlob[1];
402                 } extended_response;
403         } u;
404 } NEGOTIATE_RSP;
405
406 /* SecurityMode bits */
407 #define SECMODE_USER          0x01      /* off indicates share level security */
408 #define SECMODE_PW_ENCRYPT    0x02
409 #define SECMODE_SIGN_ENABLED  0x04      /* SMB security signatures enabled */
410 #define SECMODE_SIGN_REQUIRED 0x08      /* SMB security signatures required */
411
412 /* Negotiate response Capabilities */
413 #define CAP_RAW_MODE           0x00000001
414 #define CAP_MPX_MODE           0x00000002
415 #define CAP_UNICODE            0x00000004
416 #define CAP_LARGE_FILES        0x00000008
417 #define CAP_NT_SMBS            0x00000010       /* implies CAP_NT_FIND */
418 #define CAP_RPC_REMOTE_APIS    0x00000020
419 #define CAP_STATUS32           0x00000040
420 #define CAP_LEVEL_II_OPLOCKS   0x00000080
421 #define CAP_LOCK_AND_READ      0x00000100
422 #define CAP_NT_FIND            0x00000200
423 #define CAP_DFS                0x00001000
424 #define CAP_INFOLEVEL_PASSTHRU 0x00002000
425 #define CAP_LARGE_READ_X       0x00004000
426 #define CAP_LARGE_WRITE_X      0x00008000
427 #define CAP_UNIX               0x00800000
428 #define CAP_RESERVED           0x02000000
429 #define CAP_BULK_TRANSFER      0x20000000
430 #define CAP_COMPRESSED_DATA    0x40000000
431 #define CAP_EXTENDED_SECURITY  0x80000000
432
433 typedef union smb_com_session_setup_andx {
434         struct {                /* request format */
435                 struct smb_hdr hdr;     /* wct = 12 */
436                 __u8 AndXCommand;
437                 __u8 AndXReserved;
438                 __u16 AndXOffset;
439                 __u16 MaxBufferSize;
440                 __u16 MaxMpxCount;
441                 __u16 VcNumber;
442                 __u32 SessionKey;
443                 __u16 SecurityBlobLength;
444                 __u32 Reserved;
445                 __u32 Capabilities;     /* see below */
446                 __u16 ByteCount;
447                 unsigned char SecurityBlob[1];  /* followed by */
448                 /* STRING NativeOS */
449                 /* STRING NativeLanMan */
450         } req;                  /* NTLM request format (with extended security */
451
452         struct {                /* request format */
453                 struct smb_hdr hdr;     /* wct = 13 */
454                 __u8 AndXCommand;
455                 __u8 AndXReserved;
456                 __u16 AndXOffset;
457                 __u16 MaxBufferSize;
458                 __u16 MaxMpxCount;
459                 __u16 VcNumber;
460                 __u32 SessionKey;
461                 __u16 CaseInsensitivePasswordLength;    /* ASCII password length */
462                 __u16 CaseSensitivePasswordLength;      /* Unicode password length */
463                 __u32 Reserved; /* see below */
464                 __u32 Capabilities;
465                 __u16 ByteCount;
466                 unsigned char CaseInsensitivePassword[1];       /* followed by: */
467                 /* unsigned char * CaseSensitivePassword; */
468                 /* STRING AccountName */
469                 /* STRING PrimaryDomain */
470                 /* STRING NativeOS */
471                 /* STRING NativeLanMan */
472         } req_no_secext;        /* NTLM request format (without extended security */
473
474         struct {                /* default (NTLM) response format */
475                 struct smb_hdr hdr;     /* wct = 4 */
476                 __u8 AndXCommand;
477                 __u8 AndXReserved;
478                 __u16 AndXOffset;
479                 __u16 Action;   /* see below */
480                 __u16 SecurityBlobLength;
481                 __u16 ByteCount;
482                 unsigned char SecurityBlob[1];  /* followed by */
483 /*      unsigned char  * NativeOS;      */
484 /*      unsigned char  * NativeLanMan;  */
485 /*      unsigned char  * PrimaryDomain; */
486         } resp;                 /* NTLM response format (with or without extended security */
487
488         struct {                /* request format */
489                 struct smb_hdr hdr;     /* wct = 10 */
490                 __u8 AndXCommand;
491                 __u8 AndXReserved;
492                 __u16 AndXOffset;
493                 __u16 MaxBufferSize;
494                 __u16 MaxMpxCount;
495                 __u16 VcNumber;
496                 __u32 SessionKey;
497                 __u16 PassswordLength;
498                 __u32 Reserved;
499                 __u16 ByteCount;
500                 unsigned char AccountPassword[1];       /* followed by */
501                 /* STRING AccountName */
502                 /* STRING PrimaryDomain */
503                 /* STRING NativeOS */
504                 /* STRING NativeLanMan */
505         } old_req;              /* pre-NTLM (LANMAN2.1) request format */
506
507         struct {                /* default (NTLM) response format */
508                 struct smb_hdr hdr;     /* wct = 3 */
509                 __u8 AndXCommand;
510                 __u8 AndXReserved;
511                 __u16 AndXOffset;
512                 __u16 Action;   /* see below */
513                 __u16 ByteCount;
514                 unsigned char NativeOS[1];      /* followed by */
515 /*      unsigned char * NativeLanMan; */
516 /*      unsigned char * PrimaryDomain; */
517         } old_resp;             /* pre-NTLM (LANMAN2.1) response format */
518 } SESSION_SETUP_ANDX;
519
520 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
521
522 /* Capabilities bits (for NTLM SessSetup request) */
523 #define CAP_UNICODE            0x00000004
524 #define CAP_LARGE_FILES        0x00000008
525 #define CAP_NT_SMBS            0x00000010
526 #define CAP_STATUS32           0x00000040
527 #define CAP_LEVEL_II_OPLOCKS   0x00000080
528 #define CAP_NT_FIND            0x00000200       /* reserved should be zero (presumably because NT_SMBs implies the same thing) */
529 #define CAP_BULK_TRANSFER      0x20000000
530 #define CAP_EXTENDED_SECURITY  0x80000000
531
532 /* Action bits */
533 #define GUEST_LOGIN 1
534
535 typedef struct smb_com_tconx_req {
536         struct smb_hdr hdr;     /* wct = 4 */
537         __u8 AndXCommand;
538         __u8 AndXReserved;
539         __u16 AndXOffset;
540         __u16 Flags;            /* see below */
541         __u16 PasswordLength;
542         __u16 ByteCount;
543         unsigned char Password[1];      /* followed by */
544 /* STRING Path    *//* \\server\share name */
545         /* STRING Service */
546 } TCONX_REQ;
547
548 typedef struct smb_com_tconx_rsp {
549         struct smb_hdr hdr;     /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */
550         __u8 AndXCommand;
551         __u8 AndXReserved;
552         __u16 AndXOffset;
553         __u16 OptionalSupport;  /* see below */
554         __u16 ByteCount;
555         unsigned char Service[1];       /* always ASCII, not Unicode */
556         /* STRING NativeFileSystem */
557 } TCONX_RSP;
558
559 /* tree connect Flags */
560 #define DISCONNECT_TID          0x0001
561 #define TCON_EXTENDED_SECINFO   0x0008
562 /* OptionalSupport bits */
563 #define SMB_SUPPORT_SEARCH_BITS 0x0001  /* must have bits (exclusive searches suppt. */
564 #define SMB_SHARE_IS_IN_DFS     0x0002
565
566 typedef struct smb_com_logoff_andx_req {
567
568         struct smb_hdr hdr;     /* wct = 2 */
569         __u8 AndXCommand;
570         __u8 AndXReserved;
571         __u16 AndXOffset;
572         __u16 ByteCount;
573 } LOGOFF_ANDX_REQ;
574
575 typedef struct smb_com_logoff_andx_rsp {
576         struct smb_hdr hdr;     /* wct = 2 */
577         __u8 AndXCommand;
578         __u8 AndXReserved;
579         __u16 AndXOffset;
580         __u16 ByteCount;
581 } LOGOFF_ANDX_RSP;
582
583 typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on tree_connect PDU to effect disconnect *//* probably the simplest SMB PDU */
584         struct {
585                 struct smb_hdr hdr;     /* wct = 0 */
586                 __u16 ByteCount;        /* bcc = 0 */
587         } req;
588         struct {
589                 struct smb_hdr hdr;     /* wct = 0 */
590                 __u16 ByteCount;        /* bcc = 0 */
591         } resp;
592 } TREE_DISCONNECT;
593
594 typedef struct smb_com_close_req {
595         struct smb_hdr hdr;     /* wct = 3 */
596         __u16 FileID;
597         __u32 LastWriteTime;    /* should be zero */
598         __u16 ByteCount;        /* 0 */
599 } CLOSE_REQ;
600
601 typedef struct smb_com_close_rsp {
602         struct smb_hdr hdr;     /* wct = 0 */
603         __u16 ByteCount;        /* bct = 0 */
604 } CLOSE_RSP;
605
606 typedef struct smb_com_findclose_req {
607         struct smb_hdr hdr; /* wct = 1 */
608         __u16 FileID;
609         __u16 ByteCount;    /* 0 */
610 } FINDCLOSE_REQ;
611
612 /* OpenFlags */
613 #define REQ_OPLOCK         0x00000002
614 #define REQ_BATCHOPLOCK    0x00000004
615 #define REQ_OPENDIRONLY    0x00000008
616
617 typedef struct smb_com_open_req {       /* also handles create */
618         struct smb_hdr hdr;     /* wct = 24 */
619         __u8 AndXCommand;
620         __u8 AndXReserved;
621         __u16 AndXOffset;
622         __u8 Reserved;          /* Must Be Zero */
623         __u16 NameLength;
624         __u32 OpenFlags;
625         __u32 RootDirectoryFid;
626         __u32 DesiredAccess;
627         __u64 AllocationSize;
628         __u32 FileAttributes;
629         __u32 ShareAccess;
630         __u32 CreateDisposition;
631         __u32 CreateOptions;
632         __u32 ImpersonationLevel;
633         __u8 SecurityFlags;
634         __u16 ByteCount;
635         char fileName[1];
636 } OPEN_REQ;
637
638 /* open response: oplock levels */
639 #define OPLOCK_NONE      0
640 #define OPLOCK_EXCLUSIVE 1
641 #define OPLOCK_BATCH     2
642 #define OPLOCK_READ      3  /* level 2 oplock */
643
644 /* open response for CreateAction shifted left */
645 #define CIFS_CREATE_ACTION 0x20000 /* file created */
646
647 typedef struct smb_com_open_rsp {
648         struct smb_hdr hdr;     /* wct = 34 BB */
649         __u8 AndXCommand;
650         __u8 AndXReserved;
651         __u16 AndXOffset;
652         __u8 OplockLevel;
653         __u16 Fid;
654         __u32 CreateAction;
655         __u64 CreationTime;
656         __u64 LastAccessTime;
657         __u64 LastWriteTime;
658         __u64 ChangeTime;
659         __u32 FileAttributes;
660         __u64 AllocationSize;
661         __u64 EndOfFile;
662         __u16 FileType;
663         __u16 DeviceState;
664         __u8 DirectoryFlag;
665         __u16 ByteCount;        /* bct = 0 */
666 } OPEN_RSP;
667
668 typedef struct smb_com_write_req {
669         struct smb_hdr hdr;     /* wct = 14 */
670         __u8 AndXCommand;
671         __u8 AndXReserved;
672         __u16 AndXOffset;
673         __u16 Fid;
674         __u32 OffsetLow;
675         __u32 Reserved;
676         __u16 WriteMode;
677         __u16 Remaining;
678         __u16 DataLengthHigh;
679         __u16 DataLengthLow;
680         __u16 DataOffset;
681         __u32 OffsetHigh;
682         __u16 ByteCount;
683         __u8 Pad;               /* BB check for whether padded to DWORD boundary and optimum performance here */
684         char Data[1];
685 } WRITE_REQ;
686
687 typedef struct smb_com_write_rsp {
688         struct smb_hdr hdr;     /* wct = 6 */
689         __u8 AndXCommand;
690         __u8 AndXReserved;
691         __u16 AndXOffset;
692         __u16 Count;
693         __u16 Remaining;
694         __u32 Reserved;
695         __u16 ByteCount;
696 } WRITE_RSP;
697
698 typedef struct smb_com_read_req {
699         struct smb_hdr hdr;     /* wct = 12 */
700         __u8 AndXCommand;
701         __u8 AndXReserved;
702         __u16 AndXOffset;
703         __u16 Fid;
704         __u32 OffsetLow;
705         __u16 MaxCount;
706         __u16 MinCount;         /* obsolete */
707         __u32 MaxCountHigh;
708         __u16 Remaining;
709         __u32 OffsetHigh;
710         __u16 ByteCount;
711 } READ_REQ;
712
713 typedef struct smb_com_read_rsp {
714         struct smb_hdr hdr;     /* wct = 12 */
715         __u8 AndXCommand;
716         __u8 AndXReserved;
717         __u16 AndXOffset;
718         __u16 Remaining;
719         __u16 DataCompactionMode;
720         __u16 Reserved;
721         __u16 DataLength;
722         __u16 DataOffset;
723         __u16 DataLengthHigh;
724         __u64 Reserved2;
725         __u16 ByteCount;
726         __u8 Pad;               /* BB check for whether padded to DWORD boundary and optimum performance here */
727         char Data[1];
728 } READ_RSP;
729
730 typedef struct locking_andx_range {
731         __u16 Pid;
732         __u16 Pad;
733         __u32 OffsetHigh;
734         __u32 OffsetLow;
735         __u32 LengthHigh;
736         __u32 LengthLow;
737 } LOCKING_ANDX_RANGE;
738
739 #define LOCKING_ANDX_SHARED_LOCK     0x01
740 #define LOCKING_ANDX_OPLOCK_RELEASE  0x02
741 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
742 #define LOCKING_ANDX_CANCEL_LOCK     0x08
743 #define LOCKING_ANDX_LARGE_FILES     0x10       /* always on for us */
744
745 typedef struct smb_com_lock_req {
746         struct smb_hdr hdr;     /* wct = 8 */
747         __u8 AndXCommand;
748         __u8 AndXReserved;
749         __u16 AndXOffset;
750         __u16 Fid;
751         __u8 LockType;
752         __u8 OplockLevel;
753         __u32 Timeout;
754         __u16 NumberOfUnlocks;
755         __u16 NumberOfLocks;
756         __u16 ByteCount;
757         LOCKING_ANDX_RANGE Locks[1];
758 } LOCK_REQ;
759
760 typedef struct smb_com_lock_rsp {
761         struct smb_hdr hdr;     /* wct = 2 */
762         __u8 AndXCommand;
763         __u8 AndXReserved;
764         __u16 AndXOffset;
765         __u16 ByteCount;
766 } LOCK_RSP;
767
768 typedef struct smb_com_rename_req {
769         struct smb_hdr hdr;     /* wct = 1 */
770         __u16 SearchAttributes; /* target file attributes */
771         __u16 ByteCount;
772         __u8 BufferFormat;      /* 4 = ASCII or Unicode */
773         unsigned char OldFileName[1];
774         /* followed by __u8 BufferFormat2 */
775         /* followed by NewFileName */
776 } RENAME_REQ;
777
778 #define CREATE_HARD_LINK                0x103
779 #define MOVEFILE_COPY_ALLOWED           0x0002
780 #define MOVEFILE_REPLACE_EXISTING       0x0001
781
782 typedef struct smb_com_nt_rename_req {  /* A5 - also used for create hardlink */
783         struct smb_hdr hdr;     /* wct = 4 */
784         __u16 SearchAttributes; /* target file attributes */
785         __u16 Flags;            /* spec says Information Level */
786         __u32 ClusterCount;
787         __u16 ByteCount;
788         __u8 BufferFormat;      /* 4 = ASCII or Unicode */
789         unsigned char OldFileName[1];
790         /* followed by __u8 BufferFormat2 */
791         /* followed by NewFileName */
792 } NT_RENAME_REQ;
793
794 typedef struct smb_com_rename_rsp {
795         struct smb_hdr hdr;     /* wct = 0 */
796         __u16 ByteCount;        /* bct = 0 */
797 } RENAME_RSP;
798
799 typedef struct smb_com_delete_file_req {
800         struct smb_hdr hdr;     /* wct = 1 */
801         __u16 SearchAttributes;
802         __u16 ByteCount;
803         __u8 BufferFormat;      /* 4 = ASCII */
804         unsigned char fileName[1];
805 } DELETE_FILE_REQ;
806
807 typedef struct smb_com_delete_file_rsp {
808         struct smb_hdr hdr;     /* wct = 0 */
809         __u16 ByteCount;        /* bct = 0 */
810 } DELETE_FILE_RSP;
811
812 typedef struct smb_com_delete_directory_req {
813         struct smb_hdr hdr;     /* wct = 0 */
814         __u16 ByteCount;
815         __u8 BufferFormat;      /* 4 = ASCII */
816         unsigned char DirName[1];
817 } DELETE_DIRECTORY_REQ;
818
819 typedef struct smb_com_delete_directory_rsp {
820         struct smb_hdr hdr;     /* wct = 0 */
821         __u16 ByteCount;        /* bct = 0 */
822 } DELETE_DIRECTORY_RSP;
823
824 typedef struct smb_com_create_directory_req {
825         struct smb_hdr hdr;     /* wct = 0 */
826         __u16 ByteCount;
827         __u8 BufferFormat;      /* 4 = ASCII */
828         unsigned char DirName[1];
829 } CREATE_DIRECTORY_REQ;
830
831 typedef struct smb_com_create_directory_rsp {
832         struct smb_hdr hdr;     /* wct = 0 */
833         __u16 ByteCount;        /* bct = 0 */
834 } CREATE_DIRECTORY_RSP;
835
836 typedef struct smb_com_transaction_ioctl_req {
837         struct smb_hdr hdr;     /* wct = 23 */
838         __u8 MaxSetupCount;
839         __u16 Reserved;
840         __u32 TotalParameterCount;
841         __u32 TotalDataCount;
842         __u32 MaxParameterCount;
843         __u32 MaxDataCount;
844         __u32 ParameterCount;
845         __u32 ParameterOffset;
846         __u32 DataCount;
847         __u32 DataOffset;
848         __u8 SetupCount; /* four setup words follow subcommand */
849         /* SNIA spec incorrectly included spurious pad here */
850         __u16 SubCommand;/* 2 = IOCTL/FSCTL */
851         __u32 FunctionCode;
852         __u16 Fid;
853         __u8 IsFsctl;    /* 1 = File System Control, 0 = device control (IOCTL)*/
854         __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS share)*/
855         __u16 ByteCount;
856         __u8 Pad[3];
857         __u8 Data[1];
858 } TRANSACT_IOCTL_REQ;
859
860 typedef struct smb_com_transaction_ioctl_rsp {
861         struct smb_hdr hdr;     /* wct = 19 */
862         __u8 Reserved[3];
863         __u32 TotalParameterCount;
864         __u32 TotalDataCount;
865         __u32 ParameterCount;
866         __u32 ParameterOffset;
867         __u32 ParameterDisplacement;
868         __u32 DataCount;
869         __u32 DataOffset;
870         __u32 DataDisplacement;
871         __u8 SetupCount;        /* 1 */
872         __u16 ReturnedDataLen;
873         __u16 ByteCount;
874         __u8 Pad[3];
875 } TRANSACT_IOCTL_RSP;
876
877 typedef struct smb_com_transaction_change_notify_req {
878         struct smb_hdr hdr;     /* wct = 23 */
879         __u8 MaxSetupCount;
880         __u16 Reserved;
881         __u32 TotalParameterCount;
882         __u32 TotalDataCount;
883         __u32 MaxParameterCount;
884         __u32 MaxDataCount;
885         __u32 ParameterCount;
886         __u32 ParameterOffset;
887         __u32 DataCount;
888         __u32 DataOffset;
889         __u8 SetupCount; /* four setup words follow subcommand */
890         /* SNIA spec incorrectly included spurious pad here */
891         __u16 SubCommand;/* 4 = Change Notify */
892         __u32 CompletionFilter;  /* operation to monitor */
893         __u16 Fid;
894         __u8 WatchTree;  /* 1 = Monitor subdirectories */
895         __u16 ByteCount;
896         __u8 Pad[3];
897         __u8 Data[1];
898 } TRANSACT_CHANGE_NOTIFY_REQ;
899
900 /* Completion Filter flags */
901 #define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001
902 #define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002
903 #define FILE_NOTIFY_CHANGE_NAME         0x00000003
904 #define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004
905 #define FILE_NOTIFY_CHANGE_SIZE         0x00000008
906 #define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010
907 #define FILE_NOTIFY_CHANGE_LAST_ACCESS  0x00000020
908 #define FILE_NOTIFY_CHANGE_CREATION     0x00000040
909 #define FILE_NOTIFY_CHANGE_EA           0x00000080
910 #define FILE_NOTIFY_CHANGE_SECURITY     0x00000100
911 #define FILE_NOTIFY_CHANGE_STREAM_NAME  0x00000200
912 #define FILE_NOTIFY_CHANGE_STREAM_SIZE  0x00000400
913 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
914
915 /* response contains array of the following structures */
916 struct file_notify_information {
917         __u32 NextEntryOffset;
918         __u32 Action;
919         __u32 FileNameLength;
920         __u8  FileName[1];
921 }; 
922
923 struct reparse_data {
924         __u32   ReparseTag;
925         __u16   ReparseDataLength;
926         __u16   Reserved;
927         __u16   AltNameOffset;
928         __u16   AltNameLen;
929         __u16   TargetNameOffset;
930         __u16   TargetNameLen;
931         char    LinkNamesBuf[1];
932 };
933
934 struct cifs_quota_data {
935         __u32   rsrvd1;  /* 0 */
936         __u32   sid_size;
937         __u64   rsrvd2;  /* 0 */
938         __u64   space_used;
939         __u64   soft_limit;
940         __u64   hard_limit;
941         char    sid[1];  /* variable size? */
942 };
943
944 /* quota sub commands */
945 #define QUOTA_LIST_CONTINUE         0
946 #define QUOTA_LIST_START        0x100
947 #define QUOTA_FOR_SID           0x101
948
949 typedef union smb_com_transaction2 {
950         struct {
951                 struct smb_hdr hdr;     /* wct = 14+ */
952                 __u16 TotalParameterCount;
953                 __u16 TotalDataCount;
954                 __u16 MaxParameterCount;
955                 __u16 MaxDataCount;
956                 __u8 MaxSetupCount;
957                 __u8 Reserved;
958                 __u16 Flags;
959                 __u32 Timeout;
960                 __u16 Reserved2;
961                 __u16 ParameterCount;
962                 __u16 ParameterOffset;
963                 __u16 DataCount;
964                 __u16 DataOffset;
965                 __u8 SetupCount;
966                 __u8 Reserved3;
967                 __u16 SubCommand;       /* 1st setup word - can be followed by SetupCount words */
968                 __u16 ByteCount;        /* careful - setupcount is not always one */
969         } req;
970         struct {
971                 struct smb_hdr hdr;     /* wct = 0 */
972                 __u16 TotalParameterCount;
973                 __u16 TotalDataCount;
974                 __u16 Reserved;
975                 __u16 ParameterCount;
976                 __u16 ParamterOffset;
977                 __u16 ParameterDisplacement;
978                 __u16 DataCount;
979                 __u16 DataOffset;
980                 __u16 DataDisplacement;
981                 __u8 SetupCount;
982                 __u8 Reserved1; /* should be zero setup words following */
983                 __u16 ByteCount;
984                 __u16 Reserved2;        /* parameter word reserved - present for infolevels > 100 */
985                 /* data area follows */
986         } resp;
987 } TRANSACTION2;
988
989 /* PathInfo/FileInfo infolevels */
990 #define SMB_INFO_STANDARD                   1
991 #define SMB_INFO_IS_NAME_VALID              6
992 #define SMB_QUERY_FILE_BASIC_INFO       0x101
993 #define SMB_QUERY_FILE_STANDARD_INFO    0x102
994 #define SMB_QUERY_FILE_NAME_INFO        0x104
995 #define SMB_QUERY_FILE_ALLOCATION_INFO  0x105
996 #define SMB_QUERY_FILE_END_OF_FILEINFO  0x106
997 #define SMB_QUERY_FILE_ALL_INFO         0x107
998 #define SMB_QUERY_ALT_NAME_INFO         0x108
999 #define SMB_QUERY_FILE_STREAM_INFO      0x109
1000 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1001 #define SMB_QUERY_FILE_UNIX_BASIC       0x200
1002 #define SMB_QUERY_FILE_UNIX_LINK        0x201
1003
1004 #define SMB_SET_FILE_BASIC_INFO         0x101
1005 #define SMB_SET_FILE_DISPOSITION_INFO   0x102
1006 #define SMB_SET_FILE_ALLOCATION_INFO    0x103
1007 #define SMB_SET_FILE_END_OF_FILE_INFO   0x104
1008 #define SMB_SET_FILE_UNIX_BASIC         0x200
1009 #define SMB_SET_FILE_UNIX_LINK          0x201
1010 #define SMB_SET_FILE_UNIX_HLINK         0x203
1011 #define SMB_SET_FILE_BASIC_INFO2        0x3ec
1012 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2
1013 #define SMB_SET_FILE_ALLOCATION_INFO2   0x3fb
1014 #define SMB_SET_FILE_END_OF_FILE_INFO2  0x3fc
1015
1016 /* Find File infolevels */
1017 #define SMB_FIND_FILE_DIRECTORY_INFO      0x101
1018 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1019 #define SMB_FIND_FILE_NAMES_INFO          0x103
1020 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1021 #define SMB_FIND_FILE_UNIX                0x202
1022
1023 typedef struct smb_com_transaction2_qpi_req {
1024         struct smb_hdr hdr;     /* wct = 14+ */
1025         __u16 TotalParameterCount;
1026         __u16 TotalDataCount;
1027         __u16 MaxParameterCount;
1028         __u16 MaxDataCount;
1029         __u8 MaxSetupCount;
1030         __u8 Reserved;
1031         __u16 Flags;
1032         __u32 Timeout;
1033         __u16 Reserved2;
1034         __u16 ParameterCount;
1035         __u16 ParameterOffset;
1036         __u16 DataCount;
1037         __u16 DataOffset;
1038         __u8 SetupCount;
1039         __u8 Reserved3;
1040         __u16 SubCommand;       /* one setup word */
1041         __u16 ByteCount;
1042         __u8 Pad;
1043         __u16 InformationLevel;
1044         __u32 Reserved4;
1045         char FileName[1];
1046 } TRANSACTION2_QPI_REQ;
1047
1048 typedef struct smb_com_transaction2_qpi_rsp {
1049         struct smb_hdr hdr;     /* wct = 10 + SetupCount */
1050         __u16 TotalParameterCount;
1051         __u16 TotalDataCount;
1052         __u16 Reserved;
1053         __u16 ParameterCount;
1054         __u16 ParameterOffset;
1055         __u16 ParameterDisplacement;
1056         __u16 DataCount;
1057         __u16 DataOffset;
1058         __u16 DataDisplacement;
1059         __u8 SetupCount;
1060         __u8 Reserved1;         /* should be zero setup words following */
1061         __u16 ByteCount;
1062         __u16 Reserved2;        /* parameter word reserved - present for infolevels > 100 */
1063 } TRANSACTION2_QPI_RSP;
1064
1065 typedef struct smb_com_transaction2_spi_req {
1066         struct smb_hdr hdr;     /* wct = 15 */
1067         __u16 TotalParameterCount;
1068         __u16 TotalDataCount;
1069         __u16 MaxParameterCount;
1070         __u16 MaxDataCount;
1071         __u8 MaxSetupCount;
1072         __u8 Reserved;
1073         __u16 Flags;
1074         __u32 Timeout;
1075         __u16 Reserved2;
1076         __u16 ParameterCount;
1077         __u16 ParameterOffset;
1078         __u16 DataCount;
1079         __u16 DataOffset;
1080         __u8 SetupCount;
1081         __u8 Reserved3;
1082         __u16 SubCommand;       /* one setup word */
1083         __u16 ByteCount;
1084         __u8 Pad;
1085         __u16 Pad1;
1086         __u16 InformationLevel;
1087         __u32 Reserved4;
1088         char FileName[1];
1089 } TRANSACTION2_SPI_REQ;
1090
1091 typedef struct smb_com_transaction2_spi_rsp {
1092         struct smb_hdr hdr;     /* wct = 10 + SetupCount */
1093         __u16 TotalParameterCount;
1094         __u16 TotalDataCount;
1095         __u16 Reserved;
1096         __u16 ParameterCount;
1097         __u16 ParameterOffset;
1098         __u16 ParameterDisplacement;
1099         __u16 DataCount;
1100         __u16 DataOffset;
1101         __u16 DataDisplacement;
1102         __u8 SetupCount;
1103         __u8 Reserved1;         /* should be zero setup words following */
1104         __u16 ByteCount;
1105         __u16 Reserved2;        /* parameter word reserved - present for infolevels > 100 */
1106 } TRANSACTION2_SPI_RSP;
1107
1108 struct set_file_rename {
1109         __u32 overwrite;   /* 1 = overwrite dest */
1110         __u32 root_fid;   /* zero */
1111         __u32 target_name_len;
1112         char  target_name[0];  /* Must be unicode */
1113 };
1114
1115 struct smb_com_transaction2_sfi_req {
1116         struct smb_hdr hdr;     /* wct = 15 */
1117         __u16 TotalParameterCount;
1118         __u16 TotalDataCount;
1119         __u16 MaxParameterCount;
1120         __u16 MaxDataCount;
1121         __u8 MaxSetupCount;
1122         __u8 Reserved;
1123         __u16 Flags;
1124         __u32 Timeout;
1125         __u16 Reserved2;
1126         __u16 ParameterCount;
1127         __u16 ParameterOffset;
1128         __u16 DataCount;
1129         __u16 DataOffset;
1130         __u8 SetupCount;
1131         __u8 Reserved3;
1132         __u16 SubCommand;       /* one setup word */
1133         __u16 ByteCount;
1134         __u8 Pad;
1135         __u16 Pad1;
1136         __u16 Fid;
1137         __u16 InformationLevel;
1138         __u16 Reserved4;        
1139 };
1140
1141 struct smb_com_transaction2_sfi_rsp {
1142         struct smb_hdr hdr;     /* wct = 10 + SetupCount */
1143         __u16 TotalParameterCount;
1144         __u16 TotalDataCount;
1145         __u16 Reserved;
1146         __u16 ParameterCount;
1147         __u16 ParameterOffset;
1148         __u16 ParameterDisplacement;
1149         __u16 DataCount;
1150         __u16 DataOffset;
1151         __u16 DataDisplacement;
1152         __u8 SetupCount;
1153         __u8 Reserved1;         /* should be zero setup words following */
1154         __u16 ByteCount;
1155         __u16 Reserved2;        /* parameter word reserved - present for infolevels > 100 */
1156 };
1157
1158
1159 /*
1160  * Flags on T2 FINDFIRST and FINDNEXT 
1161  */
1162 #define CIFS_SEARCH_CLOSE_ALWAYS  0x0001
1163 #define CIFS_SEARCH_CLOSE_AT_END  0x0002
1164 #define CIFS_SEARCH_RETURN_RESUME 0x0004
1165 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1166 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1167
1168 /*
1169  * Size of the resume key on FINDFIRST and FINDNEXT calls
1170  */
1171 #define CIFS_SMB_RESUME_KEY_SIZE 4
1172
1173 typedef struct smb_com_transaction2_ffirst_req {
1174         struct smb_hdr hdr;     /* wct = 15 */
1175         __u16 TotalParameterCount;
1176         __u16 TotalDataCount;
1177         __u16 MaxParameterCount;
1178         __u16 MaxDataCount;
1179         __u8 MaxSetupCount;
1180         __u8 Reserved;
1181         __u16 Flags;
1182         __u32 Timeout;
1183         __u16 Reserved2;
1184         __u16 ParameterCount;
1185         __u16 ParameterOffset;
1186         __u16 DataCount;
1187         __u16 DataOffset;
1188         __u8 SetupCount;        /* one */
1189         __u8 Reserved3;
1190         __u16 SubCommand;       /* TRANS2_FIND_FIRST */
1191         __u16 ByteCount;
1192         __u8 Pad;
1193         __u16 SearchAttributes;
1194         __u16 SearchCount;
1195         __u16 SearchFlags;
1196         __u16 InformationLevel;
1197         __u32 SearchStorageType;
1198         char FileName[1];
1199 } TRANSACTION2_FFIRST_REQ;
1200
1201 typedef struct smb_com_transaction2_ffirst_rsp {
1202         struct smb_hdr hdr;     /* wct = 10 */
1203         __u16 TotalParameterCount;
1204         __u16 TotalDataCount;
1205         __u16 Reserved;
1206         __u16 ParameterCount;
1207         __u16 ParameterOffset;
1208         __u16 ParameterDisplacement;
1209         __u16 DataCount;
1210         __u16 DataOffset;
1211         __u16 DataDisplacement;
1212         __u8 SetupCount;
1213         __u8 Reserved1;         /* should be zero setup words following */
1214         __u16 ByteCount;
1215 } TRANSACTION2_FFIRST_RSP;
1216
1217 typedef struct smb_com_transaction2_ffirst_rsp_parms {
1218         __u16 SearchHandle;
1219         __u16 SearchCount;
1220         __u16 EndofSearch;
1221         __u16 EAErrorOffset;
1222         __u16 LastNameOffset;
1223 } T2_FFIRST_RSP_PARMS;
1224
1225 typedef struct smb_com_transaction2_fnext_req {
1226         struct smb_hdr hdr;     /* wct = 15 */
1227         __u16 TotalParameterCount;
1228         __u16 TotalDataCount;
1229         __u16 MaxParameterCount;
1230         __u16 MaxDataCount;
1231         __u8 MaxSetupCount;
1232         __u8 Reserved;
1233         __u16 Flags;
1234         __u32 Timeout;
1235         __u16 Reserved2;
1236         __u16 ParameterCount;
1237         __u16 ParameterOffset;
1238         __u16 DataCount;
1239         __u16 DataOffset;
1240         __u8 SetupCount;        /* one */
1241         __u8 Reserved3;
1242         __u16 SubCommand;       /* TRANS2_FIND_NEXT */
1243         __u16 ByteCount;
1244         __u8 Pad;
1245         __u16 SearchHandle;
1246         __u16 SearchCount;
1247         __u16 InformationLevel;
1248         __u32 ResumeKey;
1249         __u16 SearchFlags;
1250         char ResumeFileName[1];
1251 } TRANSACTION2_FNEXT_REQ;
1252
1253 typedef struct smb_com_transaction2_fnext_rsp {
1254         struct smb_hdr hdr;     /* wct = 10 */
1255         __u16 TotalParameterCount;
1256         __u16 TotalDataCount;
1257         __u16 Reserved;
1258         __u16 ParameterCount;
1259         __u16 ParameterOffset;
1260         __u16 ParameterDisplacement;
1261         __u16 DataCount;
1262         __u16 DataOffset;
1263         __u16 DataDisplacement;
1264         __u8 SetupCount;
1265         __u8 Reserved1;         /* should be zero setup words following */
1266         __u16 ByteCount;
1267 } TRANSACTION2_FNEXT_RSP;
1268
1269 typedef struct smb_com_transaction2_fnext_rsp_parms {
1270         __u16 SearchCount;
1271         __u16 EndofSearch;
1272         __u16 EAErrorOffset;
1273         __u16 LastNameOffset;
1274 } T2_FNEXT_RSP_PARMS;
1275
1276 #define SMB_INFO_ALLOCATION         1
1277 #define SMB_INFO_VOLUME             2
1278 #define SMB_QUERY_FS_VOLUME_INFO    0x102
1279 #define SMB_QUERY_FS_SIZE_INFO      0x103
1280 #define SMB_QUERY_FS_DEVICE_INFO    0x104
1281 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1282 #define SMB_QUERY_CIFS_UNIX_INFO    0x200
1283
1284 typedef struct smb_com_transaction2_qfsi_req {
1285         struct smb_hdr hdr;     /* wct = 14+ */
1286         __u16 TotalParameterCount;
1287         __u16 TotalDataCount;
1288         __u16 MaxParameterCount;
1289         __u16 MaxDataCount;
1290         __u8 MaxSetupCount;
1291         __u8 Reserved;
1292         __u16 Flags;
1293         __u32 Timeout;
1294         __u16 Reserved2;
1295         __u16 ParameterCount;
1296         __u16 ParameterOffset;
1297         __u16 DataCount;
1298         __u16 DataOffset;
1299         __u8 SetupCount;
1300         __u8 Reserved3;
1301         __u16 SubCommand;       /* one setup word */
1302         __u16 ByteCount;
1303         __u8 Pad;
1304         __u16 InformationLevel;
1305 } TRANSACTION2_QFSI_REQ;
1306
1307 typedef struct smb_com_transaction_qfsi_rsp {
1308         struct smb_hdr hdr;     /* wct = 10 + SetupCount */
1309         __u16 TotalParameterCount;
1310         __u16 TotalDataCount;
1311         __u16 Reserved;
1312         __u16 ParameterCount;
1313         __u16 ParameterOffset;
1314         __u16 ParameterDisplacement;
1315         __u16 DataCount;
1316         __u16 DataOffset;
1317         __u16 DataDisplacement;
1318         __u8 SetupCount;
1319         __u8 Reserved1;         /* should be zero setup words following */
1320         __u16 ByteCount;
1321         __u8 Pad;               /* may be three bytes *//* followed by data area */
1322 } TRANSACTION2_QFSI_RSP;
1323
1324 typedef struct smb_com_transaction2_get_dfs_refer_req {
1325         struct smb_hdr hdr;     /* wct = 15 */
1326         __u16 TotalParameterCount;
1327         __u16 TotalDataCount;
1328         __u16 MaxParameterCount;
1329         __u16 MaxDataCount;
1330         __u8 MaxSetupCount;
1331         __u8 Reserved;
1332         __u16 Flags;
1333         __u32 Timeout;
1334         __u16 Reserved2;
1335         __u16 ParameterCount;
1336         __u16 ParameterOffset;
1337         __u16 DataCount;
1338         __u16 DataOffset;
1339         __u8 SetupCount;
1340         __u8 Reserved3;
1341         __u16 SubCommand;       /* one setup word */
1342         __u16 ByteCount;
1343         __u8 Pad[3];            /* Win2K has sent 0x0F01 (max resp length perhaps?) followed by one byte pad - doesn't seem to matter though */
1344         __u16 MaxReferralLevel;
1345         char RequestFileName[1];
1346 } TRANSACTION2_GET_DFS_REFER_REQ;
1347
1348 typedef struct dfs_referral_level_3 {
1349         __u16 VersionNumber;
1350         __u16 ReferralSize;
1351         __u16 ServerType;       /* 0x0001 = CIFS server */
1352         __u16 ReferralFlags;    /* or proximity - not clear which since always set to zero - SNIA spec says 0x01 means strip off PathConsumed chars before submitting RequestFileName to remote node */
1353         __u16 TimeToLive;
1354         __u16 Proximity;
1355         __u16 DfsPathOffset;
1356         __u16 DfsAlternatePathOffset;
1357         __u16 NetworkAddressOffset;
1358 } REFERRAL3;
1359
1360 typedef struct smb_com_transaction_get_dfs_refer_rsp {
1361         struct smb_hdr hdr;     /* wct = 10 */
1362         __u16 TotalParameterCount;
1363         __u16 TotalDataCount;
1364         __u16 Reserved;
1365         __u16 ParameterCount;
1366         __u16 ParameterOffset;
1367         __u16 ParameterDisplacement;
1368         __u16 DataCount;
1369         __u16 DataOffset;
1370         __u16 DataDisplacement;
1371         __u8 SetupCount;
1372         __u8 Reserved1;         /* zero setup words following */
1373         __u16 ByteCount;
1374         __u8 Pad;
1375         __u16 PathConsumed;
1376         __u16 NumberOfReferrals;
1377         __u16 DFSFlags;
1378         __u16 Pad2;
1379         REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */
1380         /* followed by the strings pointed to by the referral structures */
1381 } TRANSACTION2_GET_DFS_REFER_RSP;
1382
1383 /* DFS Flags */
1384 #define DFSREF_REFERRAL_SERVER  0x0001
1385 #define DFSREF_STORAGE_SERVER   0x0002
1386
1387 /* IOCTL information */
1388 /* List of ioctl function codes that look to be of interest to remote clients like this. */
1389 /* Need to do some experimentation to make sure they all work remotely.                  */
1390 /* Some of the following such as the encryption/compression ones would be                */
1391 /* invoked from tools via a specialized hook into the VFS rather than via the            */
1392 /* standard vfs entry points */
1393 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1394 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1395 #define FSCTL_REQUEST_BATCH_OPLOCK   0x00090008
1396 #define FSCTL_LOCK_VOLUME            0x00090018
1397 #define FSCTL_UNLOCK_VOLUME          0x0009001C
1398 #define FSCTL_GET_COMPRESSION        0x0009003C
1399 #define FSCTL_SET_COMPRESSION        0x0009C040
1400 #define FSCTL_REQUEST_FILTER_OPLOCK  0x0009008C
1401 #define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1402 #define FSCTL_SET_REPARSE_POINT      0x000900A4
1403 #define FSCTL_GET_REPARSE_POINT      0x000900A8
1404 #define FSCTL_DELETE_REPARSE_POINT   0x000900AC
1405 #define FSCTL_SET_SPARSE             0x000900C4
1406 #define FSCTL_SET_ZERO_DATA          0x000900C8
1407 #define FSCTL_SET_ENCRYPTION         0x000900D7
1408 #define FSCTL_ENCRYPTION_FSCTL_IO    0x000900DB
1409 #define FSCTL_WRITE_RAW_ENCRYPTED    0x000900DF
1410 #define FSCTL_READ_RAW_ENCRYPTED     0x000900E3
1411 #define FSCTL_SIS_COPYFILE           0x00090100
1412 #define FSCTL_SIS_LINK_FILES         0x0009C104
1413
1414 #define IO_REPARSE_TAG_MOUNT_POINT   0xA0000003
1415 #define IO_REPARSE_TAG_HSM           0xC0000004
1416 #define IO_REPARSE_TAG_SIS           0x80000007
1417
1418 /*
1419  ************************************************************************
1420  * All structs for everything above the SMB PDUs themselves
1421  * (such as the T2 level specific data) go here                  
1422  ************************************************************************
1423  */
1424
1425 /*
1426  * Information on a server
1427  */
1428
1429 struct serverInfo {
1430         char name[16];
1431         unsigned char versionMajor;
1432         unsigned char versionMinor;
1433         unsigned long type;
1434         unsigned int commentOffset;
1435 };
1436
1437 /*
1438  * The following structure is the format of the data returned on a NetShareEnum
1439  * with level "90" (x5A)
1440  */
1441
1442 struct shareInfo {
1443         char shareName[13];
1444         char pad;
1445         unsigned short type;
1446         unsigned int commentOffset;
1447 };
1448
1449 struct aliasInfo {
1450         char aliasName[9];
1451         char pad;
1452         unsigned int commentOffset;
1453         unsigned char type[2];
1454 };
1455
1456 struct aliasInfo92 {
1457         int aliasNameOffset;
1458         int serverNameOffset;
1459         int shareNameOffset;
1460 };
1461
1462 typedef struct {
1463         __u64 TotalAllocationUnits;
1464         __u64 FreeAllocationUnits;
1465         __u32 SectorsPerAllocationUnit;
1466         __u32 BytesPerSector;
1467 } FILE_SYSTEM_INFO;             /* size info, level 0x103 */
1468
1469 typedef struct {
1470         __u16 MajorVersionNumber;
1471         __u16 MinorVersionNumber;
1472         __u64 Capability;
1473 } FILE_SYSTEM_UNIX_INFO;        /* Unix extensions info, level 0x200 */
1474 /* Linux/Unix extensions capability flags */
1475 #define CIFS_UNIX_FCNTL_CAP             0x00000001 /* support for fcntl locks */
1476 #define CIFS_UNIX_POSIX_ACL_CAP         0x00000002
1477
1478 /* DeviceType Flags */
1479 #define FILE_DEVICE_CD_ROM              0x00000002
1480 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
1481 #define FILE_DEVICE_DFS                 0x00000006
1482 #define FILE_DEVICE_DISK                0x00000007
1483 #define FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
1484 #define FILE_DEVICE_FILE_SYSTEM         0x00000009
1485 #define FILE_DEVICE_NAMED_PIPE          0x00000011
1486 #define FILE_DEVICE_NETWORK             0x00000012
1487 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1488 #define FILE_DEVICE_NULL                0x00000015
1489 #define FILE_DEVICE_PARALLEL_PORT       0x00000016
1490 #define FILE_DEVICE_PRINTER             0x00000018
1491 #define FILE_DEVICE_SERIAL_PORT         0x0000001b
1492 #define FILE_DEVICE_STREAMS             0x0000001e
1493 #define FILE_DEVICE_TAPE                0x0000001f
1494 #define FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
1495 #define FILE_DEVICE_VIRTUAL_DISK        0x00000024
1496 #define FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
1497
1498 typedef struct {
1499         __u32 DeviceType;
1500         __u32 DeviceCharacteristics;
1501 } FILE_SYSTEM_DEVICE_INFO;      /* device info, level 0x104 */
1502
1503 typedef struct {
1504         __u32 Attributes;
1505         __u32 MaxPathNameComponentLength;
1506         __u32 FileSystemNameLen;
1507         char FileSystemName[52];        /* do not really need to save this - so potentially get only subset of name */
1508 } FILE_SYSTEM_ATTRIBUTE_INFO;
1509
1510 typedef struct {                /* data block encoding of response to level 263 QPathInfo */
1511         __u64 CreationTime;
1512         __u64 LastAccessTime;
1513         __u64 LastWriteTime;
1514         __u64 ChangeTime;
1515         __u32 Attributes;
1516         __u32 Pad1;
1517         __u64 AllocationSize;
1518         __u64 EndOfFile;        /* size ie offset to first free byte in file */
1519         __u32 NumberOfLinks;    /* hard links */
1520         __u8 DeletePending;
1521         __u8 Directory;
1522         __u16 Pad2;
1523         __u64 IndexNumber;
1524         __u32 EASize;
1525         __u32 AccessFlags;
1526         __u64 IndexNumber1;
1527         __u64 CurrentByteOffset;
1528         __u32 Mode;
1529         __u32 AlignmentRequirement;
1530         __u32 FileNameLength;
1531         char FileName[1];
1532 } FILE_ALL_INFO;                /* level 263 QPathInfo */
1533
1534 typedef struct {
1535         __u64 EndOfFile;
1536         __u64 NumOfBytes;
1537         __u64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */
1538         __u64 LastAccessTime;
1539         __u64 LastModificationTime;
1540         __u64 Uid;
1541         __u64 Gid;
1542         __u32 Type;
1543         __u64 DevMajor;
1544         __u64 DevMinor;
1545         __u64 UniqueId;
1546         __u64 Permissions;
1547         __u64 Nlinks;
1548 } FILE_UNIX_BASIC_INFO;         /* level 512 QPathInfo */
1549
1550 typedef struct {
1551         char LinkDest[1];
1552 } FILE_UNIX_LINK_INFO;          /* level 513 QPathInfo */
1553
1554 /* defines for enumerating possible values of the Unix type field below */
1555 #define UNIX_FILE      0
1556 #define UNIX_DIR       1
1557 #define UNIX_SYMLINK   2
1558 #define UNIX_CHARDEV   3
1559 #define UNIX_BLOCKDEV  4
1560 #define UNIX_FIFO      5
1561 #define UNIX_SOCKET    6
1562
1563 typedef struct {
1564         __u32 NextEntryOffset;
1565         __u32 ResumeKey;
1566         __u64 EndOfFile;
1567         __u64 NumOfBytes;
1568         __u64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */
1569         __u64 LastAccessTime;
1570         __u64 LastModificationTime;
1571         __u64 Uid;
1572         __u64 Gid;
1573         __u32 Type;
1574         __u64 DevMajor;
1575         __u64 DevMinor;
1576         __u64 UniqueId;
1577         __u64 Permissions;
1578         __u64 Nlinks;
1579         char FileName[1];
1580 } FILE_UNIX_INFO;
1581
1582 typedef struct {
1583         __u64 CreationTime;
1584         __u64 LastAccessTime;
1585         __u64 LastWriteTime;
1586         __u64 ChangeTime;
1587         __u32 Attributes;
1588         __u32 Pad;
1589 } FILE_BASIC_INFO;              /* size info, level 0x101 */
1590
1591 struct file_allocation_info {
1592         __u64 AllocationSize;
1593 };              /* size info, level 0x103 */
1594
1595 struct file_end_of_file_info {
1596         __u64 FileSize;         /* offset to end of file */
1597 };      /* size info, level 0x104 */
1598
1599 typedef struct {
1600         __u32 NextEntryOffset;
1601         __u32 FileIndex;
1602         __u64 CreationTime;
1603         __u64 LastAccessTime;
1604         __u64 LastWriteTime;
1605         __u64 ChangeTime;
1606         __u64 EndOfFile;
1607         __u64 AllocationSize;
1608         __u32 ExtFileAttributes;
1609         __u32 FileNameLength;
1610         char FileName[1];
1611 } FILE_DIRECTORY_INFO;   /* level 257 FF response data area */
1612
1613 struct gea {
1614         unsigned char cbName;
1615         char szName[1];
1616 };
1617
1618 struct gealist {
1619         unsigned long cbList;
1620         struct gea list[1];
1621 };
1622
1623 struct fea {
1624         unsigned char fEA;
1625         unsigned char cbName;
1626         unsigned short cbValue;
1627         char szName[1];
1628 };
1629 /* flags for _FEA.fEA */
1630 #define FEA_NEEDEA         0x80 /* need EA bit */
1631
1632 struct fealist {
1633         unsigned long cbList;
1634         struct fea list[1];
1635 };
1636
1637 /* used to hold an arbitrary blob of data */
1638 struct data_blob {
1639         __u8 *data;
1640         size_t length;
1641         void (*free) (struct data_blob * data_blob);
1642 };
1643
1644 #pragma pack()                  /* resume default structure packing */
1645
1646 #endif                          /* _CIFSPDU_H */