[PATCH] unexport open_softirq
[safe/jmp/linux-2.6] / fs / cifs / cifspdu.h
index 33e1859..8623902 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *   fs/cifs/cifspdu.h
  *
- *   Copyright (c) International Business Machines  Corp., 2002
+ *   Copyright (c) International Business Machines  Corp., 2002,2005
  *   Author(s): Steve French (sfrench@us.ibm.com)
  *
  *   This library is free software; you can redistribute it and/or modify
@@ -16,7 +16,7 @@
  *
  *   You should have received a copy of the GNU Lesser General Public License
  *   along with this library; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #ifndef _CIFSPDU_H
 
 #include <net/sock.h>
 
+#ifdef CONFIG_CIFS_WEAK_PW_HASH
+#define LANMAN_PROT 0
+#define CIFS_PROT   1
+#else
 #define CIFS_PROT   0
-#define BAD_PROT    CIFS_PROT+1
+#endif
+#define POSIX_PROT  CIFS_PROT+1
+#define BAD_PROT 0xFFFF
 
 /* SMB command codes */
 /* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
 #define NT_TRANSACT_GET_USER_QUOTA    0x07
 #define NT_TRANSACT_SET_USER_QUOTA    0x08
 
-#define MAX_CIFS_HDR_SIZE 256  /* is future chained NTCreateXReadX bigger? */
+#define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
+/* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
+/* among the requests (NTCreateX response is bigger with wct of 34) */
+#define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
+#define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */
 
 /* internal cifs vfs structures */
 /*****************************************************************
 /*
  * Size of the session key (crypto key encrypted with the password
  */
-#define CIFS_SESSION_KEY_SIZE (24)
+#define CIFS_SESS_KEY_SIZE (24)
 
 /*
  * Maximum user name length
@@ -396,6 +406,29 @@ typedef struct negotiate_req {
        unsigned char DialectsArray[1];
 } __attribute__((packed)) NEGOTIATE_REQ;
 
+/* Dialect index is 13 for LANMAN */
+
+typedef struct lanman_neg_rsp {
+       struct smb_hdr hdr;     /* wct = 13 */
+       __le16 DialectIndex;
+       __le16 SecurityMode;
+       __le16 MaxBufSize;
+       __le16 MaxMpxCount;
+       __le16 MaxNumberVcs;
+       __le16 RawMode;
+       __le32 SessionKey;
+       __le32 ServerTime;
+       __le16 ServerTimeZone;
+       __le16 EncryptionKeyLength;
+       __le16 Reserved;
+       __u16  ByteCount;
+       unsigned char EncryptionKey[1];
+} __attribute__((packed)) LANMAN_NEG_RSP;
+
+#define READ_RAW_ENABLE 1
+#define WRITE_RAW_ENABLE 2
+#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
+
 typedef struct negotiate_rsp {
        struct smb_hdr hdr;     /* wct = 17 */
        __le16 DialectIndex;
@@ -505,7 +538,7 @@ typedef union smb_com_session_setup_andx {
 /*      unsigned char  * NativeOS;      */
 /*     unsigned char  * NativeLanMan;  */
 /*      unsigned char  * PrimaryDomain; */
-       } __attribute__((packed)) resp;                 /* NTLM response format (with or without extended security */
+       } __attribute__((packed)) resp; /* NTLM response with or without extended sec*/
 
        struct {                /* request format */
                struct smb_hdr hdr;     /* wct = 10 */
@@ -516,15 +549,15 @@ typedef union smb_com_session_setup_andx {
                __le16 MaxMpxCount;
                __le16 VcNumber;
                __u32 SessionKey;
-               __le16 PassswordLength;
-               __u32 Reserved;
+               __le16 PasswordLength;
+               __u32 Reserved; /* encrypt key len and offset */
                __le16 ByteCount;
                unsigned char AccountPassword[1];       /* followed by */
                /* STRING AccountName */
                /* STRING PrimaryDomain */
                /* STRING NativeOS */
                /* STRING NativeLanMan */
-       } __attribute__((packed)) old_req;              /* pre-NTLM (LANMAN2.1) request format */
+       } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */
 
        struct {                /* default (NTLM) response format */
                struct smb_hdr hdr;     /* wct = 3 */
@@ -536,9 +569,29 @@ typedef union smb_com_session_setup_andx {
                unsigned char NativeOS[1];      /* followed by */
 /*     unsigned char * NativeLanMan; */
 /*      unsigned char * PrimaryDomain; */
-       } __attribute__((packed)) old_resp;             /* pre-NTLM (LANMAN2.1) response format */
+       } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */
 } __attribute__((packed)) SESSION_SETUP_ANDX;
 
+/* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
+
+struct ntlmssp2_name {
+       __le16 type;
+       __le16 length;
+/*     char   name[length]; */
+} __attribute__((packed));
+
+struct ntlmv2_resp {
+       char ntlmv2_hash[CIFS_ENCPWD_SIZE];
+       __le32 blob_signature;
+       __u32  reserved;
+       __le64  time;
+       __u64  client_chal; /* random */
+       __u32  reserved2;
+       struct ntlmssp2_name names[1];
+       /* array of name entries could follow ending in minimum 4 byte struct */
+} __attribute__((packed));
+
+
 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
 
 /* Capabilities bits (for NTLM SessSetup request) */
@@ -569,7 +622,9 @@ typedef struct smb_com_tconx_req {
 } __attribute__((packed)) TCONX_REQ;
 
 typedef struct smb_com_tconx_rsp {
-       struct smb_hdr hdr;     /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */
+       struct smb_hdr hdr;     /* wct = 3 note that Win2000 has sent wct = 7
+                                in some cases on responses. Four unspecified
+                                words followed OptionalSupport */
        __u8 AndXCommand;
        __u8 AndXReserved;
        __le16 AndXOffset;
@@ -855,7 +910,10 @@ typedef struct smb_com_lock_req {
        LOCKING_ANDX_RANGE Locks[1];
 } __attribute__((packed)) LOCK_REQ;
 
-
+/* lock type */
+#define CIFS_RDLCK     0
+#define CIFS_WRLCK     1
+#define CIFS_UNLCK      2
 typedef struct cifs_posix_lock {
        __le16  lock_type;  /* 0 = Read, 1 = Write, 2 = Unlock */
        __le16  lock_flags; /* 1 = Wait (only valid for setlock) */
@@ -1003,10 +1061,49 @@ typedef struct smb_com_setattr_rsp {
 
 /* empty wct response to setattr */
 
-/***************************************************/
-/* NT Transact structure defintions follow         */
-/* Currently only ioctl and notify are implemented */
-/***************************************************/
+/*******************************************************/
+/* NT Transact structure defintions follow             */
+/* Currently only ioctl, acl (get security descriptor) */  
+/* and notify are implemented                          */
+/*******************************************************/
+typedef struct smb_com_ntransact_req {
+        struct smb_hdr hdr; /* wct >= 19 */
+        __u8 MaxSetupCount;
+        __u16 Reserved;
+        __le32 TotalParameterCount;
+        __le32 TotalDataCount;
+        __le32 MaxParameterCount;
+        __le32 MaxDataCount;
+        __le32 ParameterCount;
+        __le32 ParameterOffset;
+        __le32 DataCount;
+        __le32 DataOffset;
+        __u8 SetupCount; /* four setup words follow subcommand */
+        /* SNIA spec incorrectly included spurious pad here */
+        __le16 SubCommand; /* 2 = IOCTL/FSCTL */
+       /* SetupCount words follow then */ 
+        __le16 ByteCount;
+        __u8 Pad[3];
+        __u8 Parms[0];
+} __attribute__((packed)) NTRANSACT_REQ;
+
+typedef struct smb_com_ntransact_rsp {
+       struct smb_hdr hdr;     /* wct = 18 */
+       __u8 Reserved[3];
+       __le32 TotalParameterCount;
+       __le32 TotalDataCount;
+       __le32 ParameterCount;
+       __le32 ParameterOffset;
+       __le32 ParameterDisplacement;
+       __le32 DataCount;
+       __le32 DataOffset;
+       __le32 DataDisplacement;
+       __u8 SetupCount;   /* 0 */
+       __u16 ByteCount;
+        /* __u8 Pad[3]; */
+       /* parms and data follow */
+} __attribute__((packed)) NTRANSACT_RSP;
+
 typedef struct smb_com_transaction_ioctl_req {
        struct smb_hdr hdr;     /* wct = 23 */
        __u8 MaxSetupCount;
@@ -1021,11 +1118,11 @@ typedef struct smb_com_transaction_ioctl_req {
        __le32 DataOffset;
        __u8 SetupCount; /* four setup words follow subcommand */
        /* SNIA spec incorrectly included spurious pad here */
-       __le16 SubCommand;/* 2 = IOCTL/FSCTL */
+       __le16 SubCommand; /* 2 = IOCTL/FSCTL */
        __le32 FunctionCode;
        __u16 Fid;
-       __u8 IsFsctl;    /* 1 = File System Control, 0 = device control (IOCTL)*/
-       __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS share)*/
+       __u8 IsFsctl;  /* 1 = File System Control 0 = device control (IOCTL) */
+       __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS*/
        __le16 ByteCount;
        __u8 Pad[3];
        __u8 Data[1];
@@ -1045,9 +1142,35 @@ typedef struct smb_com_transaction_ioctl_rsp {
        __u8 SetupCount;        /* 1 */
        __le16 ReturnedDataLen;
        __u16 ByteCount;
-       __u8 Pad[3];
 } __attribute__((packed)) TRANSACT_IOCTL_RSP;
 
+#define CIFS_ACL_OWNER 1
+#define CIFS_ACL_GROUP 2
+#define CIFS_ACL_DACL  4
+#define CIFS_ACL_SACL  8
+
+typedef struct smb_com_transaction_qsec_req {
+       struct smb_hdr hdr;     /* wct = 19 */
+       __u8 MaxSetupCount;
+       __u16 Reserved;
+       __le32 TotalParameterCount;
+       __le32 TotalDataCount;
+       __le32 MaxParameterCount;
+       __le32 MaxDataCount;
+       __le32 ParameterCount;
+       __le32 ParameterOffset;
+       __le32 DataCount;
+       __le32 DataOffset;
+       __u8 SetupCount; /* no setup words follow subcommand */
+       /* SNIA spec incorrectly included spurious pad here */
+       __le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */
+       __le16 ByteCount; /* bcc = 3 + 8 */
+       __u8 Pad[3];
+       __u16 Fid;
+       __u16 Reserved2;
+       __le32 AclFlags;
+} __attribute__((packed)) QUERY_SEC_DESC_REQ;
+
 typedef struct smb_com_transaction_change_notify_req {
        struct smb_hdr hdr;     /* wct = 23 */
        __u8 MaxSetupCount;
@@ -1068,10 +1191,12 @@ typedef struct smb_com_transaction_change_notify_req {
        __u8 WatchTree;  /* 1 = Monitor subdirectories */
        __u8 Reserved2;
        __le16 ByteCount;
-/* __u8 Pad[3];*/
+/*     __u8 Pad[3];*/
 /*     __u8 Data[1];*/
 } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;
 
+/* BB eventually change to use generic ntransact rsp struct 
+      and validation routine */
 typedef struct smb_com_transaction_change_notify_rsp {
        struct smb_hdr hdr;     /* wct = 18 */
        __u8 Reserved[3];
@@ -1249,6 +1374,9 @@ struct smb_t2_rsp {
 #define SMB_FILE_MAXIMUM_INFO           0x40d
 
 /* Find File infolevels */
+#define SMB_FIND_FILE_INFO_STANDARD       0x001
+#define SMB_FIND_FILE_QUERY_EA_SIZE       0x002
+#define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
 #define SMB_FIND_FILE_DIRECTORY_INFO      0x101
 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
 #define SMB_FIND_FILE_NAMES_INFO          0x103
@@ -1715,7 +1843,13 @@ typedef struct {
 #define CIFS_UNIX_POSIX_ACL_CAP         0x00000002 /* support getfacl/setfacl */
 #define CIFS_UNIX_XATTR_CAP             0x00000004 /* support new namespace   */
 #define CIFS_UNIX_EXTATTR_CAP           0x00000008 /* support chattr/chflag   */
-#define CIFS_UNIX_POSIX_PATHNAMES_CAP   0x00000010 /* Use POSIX pathnames on the wire. */
+#define CIFS_UNIX_POSIX_PATHNAMES_CAP   0x00000010 /* Allow POSIX path chars  */
+#ifdef CONFIG_CIFS_POSIX
+#define CIFS_UNIX_CAP_MASK              0x0000001b
+#else 
+#define CIFS_UNIX_CAP_MASK              0x00000013
+#endif /* CONFIG_CIFS_POSIX */
+
 
 #define CIFS_POSIX_EXTENSIONS           0x00000010 /* support for new QFSInfo */
 
@@ -1764,13 +1898,13 @@ typedef struct {
 typedef struct {
        __le32 DeviceType;
        __le32 DeviceCharacteristics;
-} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO;     /* device info, level 0x104 */
+} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
 
 typedef struct {
        __le32 Attributes;
        __le32 MaxPathNameComponentLength;
        __le32 FileSystemNameLen;
-       char FileSystemName[52]; /* do not really need to save this - so potentially get only subset of name */
+       char FileSystemName[52]; /* do not have to save this - get subset? */
 } __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
 
 /******************************************************************************/
@@ -1867,7 +2001,8 @@ typedef struct {
 
 struct file_allocation_info {
        __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
-} __attribute__((packed));     /* size used on disk, level 0x103 for set, 0x105 for query */
+} __attribute__((packed));     /* size used on disk, for level 0x103 for set,
+                                  0x105 for query */
 
 struct file_end_of_file_info {
        __le64 FileSize;                /* offset to end of file */
@@ -1974,7 +2109,7 @@ typedef struct {
        __le32 ExtFileAttributes;
        __le32 FileNameLength;
        char FileName[1];
-} __attribute__((packed)) FILE_DIRECTORY_INFO;   /* level 0x101 FF response data area */
+} __attribute__((packed)) FILE_DIRECTORY_INFO;   /* level 0x101 FF resp data */
 
 typedef struct {
        __le32 NextEntryOffset;
@@ -1989,7 +2124,7 @@ typedef struct {
        __le32 FileNameLength;
        __le32 EaSize; /* length of the xattrs */
        char FileName[1];
-} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO;   /* level 0x102 FF response data area */
+} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
 
 typedef struct {
        __le32 NextEntryOffset;
@@ -2006,7 +2141,7 @@ typedef struct {
        __le32 Reserved;
        __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
        char FileName[1];
-} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO;   /* level 0x105 FF response data area */
+} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
 
 typedef struct {
        __le32 NextEntryOffset;
@@ -2024,7 +2159,22 @@ typedef struct {
        __u8   Reserved;
        __u8   ShortName[12];
        char FileName[1];
-} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO;   /* level 0x104 FF response data area */
+} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
+
+typedef struct {
+       __u32  ResumeKey;
+       __le16 CreationDate; /* SMB Date */
+       __le16 CreationTime; /* SMB Time */
+       __le16 LastAccessDate;
+       __le16 LastAccessTime;
+       __le16 LastWriteDate;
+       __le16 LastWriteTime;
+       __le32 DataSize; /* File Size (EOF) */
+       __le32 AllocationSize;
+       __le16 Attributes; /* verify not u32 */
+       __u8   FileNameLength;
+       char FileName[1];
+} __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */
 
 
 struct win_dev {