sync 3.0 into HEAD for the last time
[tprouty/samba.git] / source / include / smb.h
index 8c0491a004b88deccb99fab9f7e16036434f8faf..8c6f47f23fbbb087d8d5a7a1f2c163e9bb05a15a 100644 (file)
@@ -1,11 +1,13 @@
 /* 
-   Unix SMB/Netbios implementation.
-   Version 1.9.
-   SMB parameters and setup
+   Unix SMB/CIFS implementation.
+   SMB parameters and setup, plus a whole lot more.
+   
    Copyright (C) Andrew Tridgell              1992-2000
-   Copyright (C) John H Terpstra              1996-2000
+   Copyright (C) John H Terpstra              1996-2002
    Copyright (C) Luke Kenneth Casson Leighton 1996-2000
    Copyright (C) Paul Ashton                  1998-2000
+   Copyright (C) Simo Sorce                   2001-2002
+   Copyright (C) Martin Pool                 2002
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #ifndef _SMB_H
 #define _SMB_H
 
+#if defined(LARGE_SMB_OFF_T)
+#define BUFFER_SIZE (128*1024)
+#else /* no large readwrite possible */
 #define BUFFER_SIZE (0xFFFF)
+#endif
+
 #define SAFETY_MARGIN 1024
 #define LARGE_WRITEX_HDR_SIZE 65
 
 #define NMB_PORT 137
 #define DGRAM_PORT 138
-#define SMB_PORT 139
+#define SMB_PORT1 445
+#define SMB_PORT2 139
+#define SMB_PORTS "445 139"
 
+#define Undefined (-1)
 #define False (0)
 #define True (1)
 #define Auto (2)
+#define Required (3)
 
 #ifndef _BOOL
 typedef int BOOL;
@@ -57,6 +68,7 @@ typedef int BOOL;
 #define STR_ASCII 4
 #define STR_UNICODE 8
 #define STR_NOALIGN 16
+#define STR_TERMINATE_ASCII 128
 
 /* how long to wait for secondary SMB packets (milli-seconds) */
 #define SMB_SECONDARY_WAIT (60*1000)
@@ -68,23 +80,18 @@ typedef int BOOL;
 #define READ_TIMEOUT 1
 #define READ_EOF 2
 #define READ_ERROR 3
-
+#define WRITE_ERROR 4 /* This error code can go into the client smb_rw_error. */
+#define READ_BAD_SIG 5
 
 #define DIR_STRUCT_SIZE 43
 
-/* these define all the command types recognised by the server - there
-are lots of gaps so probably there are some rare commands that are not
-implemented */
-
-#define pSETDIR '\377'
-
 /* these define the attribute byte as seen by DOS */
-#define aRONLY (1L<<0)
-#define aHIDDEN (1L<<1)
-#define aSYSTEM (1L<<2)
-#define aVOLID (1L<<3)
-#define aDIR (1L<<4)
-#define aARCH (1L<<5)
+#define aRONLY (1L<<0)         /* 0x01 */
+#define aHIDDEN (1L<<1)                /* 0x02 */
+#define aSYSTEM (1L<<2)                /* 0x04 */
+#define aVOLID (1L<<3)         /* 0x08 */
+#define aDIR (1L<<4)           /* 0x10 */
+#define aARCH (1L<<5)          /* 0x20 */
 
 /* deny modes */
 #define DENY_DOS 0
@@ -123,11 +130,6 @@ implemented */
 #define GET_DELETE_ON_CLOSE_FLAG(x) (((x) & DELETE_ON_CLOSE_FLAG) ? True : False)
 #define SET_DELETE_ON_CLOSE_FLAG(x) ((x) ? DELETE_ON_CLOSE_FLAG : 0)
 
-/* was delete access requested in NT open ? */
-#define DELETE_ACCESS_REQUESTED (1<<17)
-#define GET_DELETE_ACCESS_REQUESTED(x) (((x) & DELETE_ACCESS_REQUESTED) ? True : False)
-#define SET_DELETE_ACCESS_REQUESTED(x) ((x) ? DELETE_ACCESS_REQUESTED : 0)
-
 /* open disposition values */
 #define FILE_EXISTS_FAIL 0
 #define FILE_EXISTS_OPEN 1
@@ -154,17 +156,10 @@ implemented */
 
 #include "doserr.h"
 
-#ifndef _PSTRING
-
-#define PSTRING_LEN 1024
-#define FSTRING_LEN 256
-
-typedef char pstring[PSTRING_LEN];
-typedef char fstring[FSTRING_LEN];
-
-#define _PSTRING
-
-#endif
+typedef union unid_t {
+       uid_t uid;
+       gid_t gid;
+} unid_t;
 
 /*
  * SMB UCS2 (16-bit unicode) internal type.
@@ -176,7 +171,6 @@ typedef uint16 smb_ucs2_t;
 typedef smb_ucs2_t wpstring[PSTRING_LEN];
 typedef smb_ucs2_t wfstring[FSTRING_LEN];
 
-
 #ifdef WORDS_BIGENDIAN
 #define UCS2_SHIFT 8
 #else
@@ -199,6 +193,21 @@ typedef smb_ucs2_t wfstring[FSTRING_LEN];
 #define PIPE_LSARPC   "\\PIPE\\lsarpc"
 #define PIPE_SPOOLSS  "\\PIPE\\spoolss"
 #define PIPE_NETDFS   "\\PIPE\\netdfs"
+#define PIPE_ECHO     "\\PIPE\\rpcecho"
+
+#define PIPE_NETLOGON_PLAIN "\\NETLOGON"
+
+#define PI_LSARPC              0
+#define PI_LSARPC_DS           1
+#define PI_SAMR                        2
+#define PI_NETLOGON            3
+#define PI_SRVSVC              4
+#define PI_WKSSVC              5
+#define PI_WINREG              6
+#define PI_SPOOLSS             7
+#define PI_NETDFS              8
+#define PI_ECHO                9
+#define PI_MAX_PIPES           10
 
 /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
 typedef struct nttime_info
@@ -208,37 +217,6 @@ typedef struct nttime_info
 } NTTIME;
 
 
-/* the following rather strange looking definitions of NTSTATUS and WERROR
-   and there in order to catch common coding errors where different error types
-   are mixed up. This is especially important as we slowly convert Samba
-   from using BOOL for internal functions 
-*/
-#if defined(HAVE_IMMEDIATE_STRUCTURES)
-typedef struct {uint32 v;} NTSTATUS;
-#define NT_STATUS(x) ((NTSTATUS) { x })
-#define NT_STATUS_V(x) ((x).v)
-#else
-typedef uint32 NTSTATUS;
-#define NT_STATUS(x) (x)
-#define NT_STATUS_V(x) (x)
-#endif
-
-#if defined(HAVE_IMMEDIATE_STRUCTURES)
-typedef struct {uint32 v;} WERROR;
-#define W_ERROR(x) ((WERROR) { x })
-#define W_ERROR_V(x) ((x).v)
-#else
-typedef uint32 WERROR;
-#define W_ERROR(x) (x)
-#define W_ERROR_V(x) (x)
-#endif
-
-#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
-#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
-#define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y))
-#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
-
-
 /* Allowable account control bits */
 #define ACB_DISABLED   0x0001  /* 1 = User account disabled */
 #define ACB_HOMDIRREQ  0x0002  /* 1 = Home directory required */
@@ -254,29 +232,35 @@ typedef uint32 WERROR;
  
 #define MAX_HOURS_LEN 32
 
-typedef struct
-{
-        uint32 pid;
-        uint16 vuid;
-
-}
-vuser_key;
-
+/* 
+ * window during which we must talk to the PDC to avoid
+ * sam sync delays; expressed in seconds (15 minutes is the 
+ * default period for SAM replication under Windows NT 4.0
+ */
+#define SAM_SYNC_WINDOW                900
 
-struct use_info
-{
-       BOOL connected;
-       char *srv_name;
-       vuser_key key;
-       char *user_name;
-       char *domain;
-};
 
 #ifndef MAXSUBAUTHS
 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
 #endif
 
-#ifndef _DOM_SID
+#define SID_MAX_SIZE ((size_t)(8+(MAXSUBAUTHS*4)))
+
+/* SID Types */
+enum SID_NAME_USE
+{
+       SID_NAME_USE_NONE = 0,
+       SID_NAME_USER    = 1, /* user */
+       SID_NAME_DOM_GRP,     /* domain group */
+       SID_NAME_DOMAIN,      /* domain sid */
+       SID_NAME_ALIAS,       /* local group */
+       SID_NAME_WKN_GRP,     /* well-known group */
+       SID_NAME_DELETED,     /* deleted account: needed for c2 rating */
+       SID_NAME_INVALID,     /* invalid account */
+       SID_NAME_UNKNOWN,     /* unknown sid type */
+       SID_NAME_COMPUTER     /* sid for a computer */
+};
+
 /**
  * @brief Security Identifier
  *
@@ -296,8 +280,6 @@ typedef struct sid_info
   uint32 sub_auths[MAXSUBAUTHS];  
 
 } DOM_SID;
-#define _DOM_SID
-#endif
 
 /*
  * The complete list of SIDS belonging to this user.
@@ -312,13 +294,10 @@ typedef struct sid_info
 #define PRIMARY_USER_SID_INDEX 0
 #define PRIMARY_GROUP_SID_INDEX 1
 
-#ifndef _NT_USER_TOKEN
 typedef struct _nt_user_token {
        size_t num_sids;
        DOM_SID *user_sids;
 } NT_USER_TOKEN;
-#define _NT_USER_TOKEN
-#endif
 
 /*** query a local group, get a list of these: shows who is in that group ***/
 
@@ -391,13 +370,12 @@ typedef struct write_cache
 
 typedef struct
 {
-       smb_ucs2_t *path;
-       smb_ucs2_t *name;
-       smb_ucs2_t *unixname;
-       smb_ucs2_t *dosname;
+       smb_ucs2_t *origname;
+       smb_ucs2_t *filename;
        SMB_STRUCT_STAT *statinfo;
 } smb_filename;
 
+#include "fake_file.h"
 
 typedef struct files_struct
 {
@@ -405,18 +383,22 @@ typedef struct files_struct
        int fnum;
        struct connection_struct *conn;
        int fd;
-       int print_jobid;
+       uint16 rap_print_jobid;
        SMB_DEV_T dev;
        SMB_INO_T inode;
        BOOL delete_on_close;
        SMB_OFF_T pos;
-       SMB_OFF_T size;
+       SMB_BIG_UINT size;
+       SMB_BIG_UINT initial_allocation_size; /* Faked up initial allocation on disk. */
+       SMB_BIG_UINT position_information;
        mode_t mode;
+       uint16 file_pid;
        uint16 vuid;
        write_bmpx_struct *wbmpx_ptr;
        write_cache *wcp;
        struct timeval open_time;
        int share_mode;
+       uint32 desired_access;
        time_t pending_modtime;
        int oplock_type;
        int sent_oplock_break;
@@ -427,11 +409,22 @@ typedef struct files_struct
        BOOL print_file;
        BOOL modified;
        BOOL is_directory;
+       BOOL is_stat;
        BOOL directory_delete_on_close;
-       BOOL stat_open;
        char *fsp_name;
+       FAKE_FILE_HANDLE *fake_file_handle;
 } files_struct;
 
+#include "ntquotas.h"
+#include "sysquotas.h"
+
+/* used to hold an arbitrary blob of data */
+typedef struct data_blob {
+       uint8 *data;
+       size_t length;
+       void (*free)(struct data_blob *data_blob);
+} DATA_BLOB;
+
 /*
  * Structure used to keep directory state information around.
  * Used in NT change-notify code.
@@ -443,9 +436,9 @@ typedef struct
   time_t status_time;
 } dir_status_struct;
 
-struct uid_cache {
-  int entries;
-  uid_t list[UID_CACHE_SIZE];
+struct vuid_cache {
+  unsigned int entries;
+  uint16 list[VUID_CACHE_SIZE];
 };
 
 typedef struct
@@ -456,15 +449,18 @@ typedef struct
 
 /* Include VFS stuff */
 
+#include "smb_acls.h"
 #include "vfs.h"
 
 typedef struct connection_struct
 {
        struct connection_struct *next, *prev;
+       TALLOC_CTX *mem_ctx;
        unsigned cnum; /* an index passed over the wire */
        int service;
        BOOL force_user;
-       struct uid_cache uid_cache;
+       BOOL force_group;
+       struct vuid_cache vuid_cache;
        void *dirptr;
        BOOL printer;
        BOOL ipc;
@@ -474,9 +470,9 @@ typedef struct connection_struct
        char *connectpath;
        char *origpath;
 
-       struct vfs_ops vfs_ops;                   /* Filesystem operations */
-       /* Handle on dlopen() call */
-       void *dl_handle;
+       struct vfs_ops vfs;                   /* Filesystem operations */
+       struct vfs_ops vfs_opaque;                      /* OPAQUE Filesystem operations */
+       struct vfs_handle_struct *vfs_handles;          /* for the new plugins */
 
        char *user; /* name of user who *opened* this connection */
        uid_t uid; /* uid of user who *opened* this connection */
@@ -533,11 +529,12 @@ typedef struct _print_queue_struct
 {
   int job;
   int size;
+  int page_count;
   int status;
   int priority;
   time_t time;
-  fstring user;
-  fstring file;
+  fstring fs_user;
+  fstring fs_file;
 } print_queue_struct;
 
 enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
@@ -575,6 +572,7 @@ typedef struct {
        uint16 op_port;
        uint16 op_type;
        int share_mode;
+       uint32 desired_access;
        struct timeval time;
        SMB_DEV_T dev;
        SMB_INO_T inode;
@@ -588,47 +586,8 @@ typedef struct {
 #define SHAREMODE_FN(fn) \
        void (*fn)(share_mode_entry *, char*)
 
-typedef struct sam_passwd
-{
-       time_t logon_time;            /* logon time */
-       time_t logoff_time;           /* logoff time */
-       time_t kickoff_time;          /* kickoff time */
-       time_t pass_last_set_time;    /* password last set time */
-       time_t pass_can_change_time;  /* password can change time */
-       time_t pass_must_change_time; /* password must change time */
-
-       pstring username;     /* UNIX username string */
-       pstring domain;       /* Windows Domain name */
-       pstring nt_username;  /* Windows username string */
-       pstring full_name;    /* user's full name string */
-       pstring home_dir;     /* home directory string */
-       pstring dir_drive;    /* home directory drive string */
-       pstring logon_script; /* logon script string */
-       pstring profile_path; /* profile path string */
-       pstring acct_desc  ;  /* user description string */
-       pstring workstations; /* login from workstations string */
-       pstring unknown_str ; /* don't know what this is, yet. */
-       pstring munged_dial ; /* munged path name and dial-back tel number */
-
-        uid_t *uid;          /* this is a pointer to the unix uid_t */
-        gid_t *gid;          /* this is a pointer to the unix gid_t */
-        uint32 user_rid;    /* Primary User ID */
-        uint32 group_rid;   /* Primary Group ID */
-
-        unsigned char *lm_pw; /* Null if no password */
-        unsigned char *nt_pw; /* Null if no password */
-
-        uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
-        uint32 unknown_3; /* 0x00ff ffff */
-
-        uint16 logon_divs; /* 168 - number of hours in a week */
-        uint32 hours_len; /* normally 21 bytes */
-        uint8 hours[MAX_HOURS_LEN];
-
-        uint32 unknown_5; /* 0x0002 0000 */
-        uint32 unknown_6; /* 0x0000 04ec */
-       
-} SAM_ACCOUNT;
+#define NT_HASH_LEN 16
+#define LM_HASH_LEN 16
 
 /*
  * Flags for account policy.
@@ -657,6 +616,7 @@ typedef struct sam_passwd
 #define LOCAL_SET_PASSWORD 0x40
 #define LOCAL_SET_LDAP_ADMIN_PW 0x80
 #define LOCAL_INTERDOM_ACCOUNT 0x100
+#define LOCAL_AM_ROOT 0x200  /* Act as root */
 
 /* key and data in the connections database - used in smbstatus and smbd */
 struct connections_key {
@@ -675,6 +635,7 @@ struct connections_data {
        char addr[24];
        char machine[FSTRING_LEN];
        time_t start;
+       uint32 bcast_msg_flags;
 };
 
 
@@ -709,11 +670,11 @@ typedef enum
 } parm_class;
 
 /* passed to br lock code */
-enum brl_type {READ_LOCK, WRITE_LOCK};
+enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_LOCK};
 
 struct enum_list {
        int value;
-       char *name;
+       const char *name;
 };
 
 #define BRLOCK_FN_CAST() \
@@ -726,12 +687,12 @@ struct enum_list {
                                 br_off start, br_off size)
 struct parm_struct
 {
-       char *label;
+       const char *label;
        parm_type type;
        parm_class class;
        void *ptr;
-       BOOL (*special)(char *, char **);
-       struct enum_list *enum_list;
+       BOOL (*special)(const char *, char **);
+       const struct enum_list *enum_list;
        unsigned flags;
        union {
                BOOL bvalue;
@@ -744,15 +705,20 @@ struct parm_struct
 
 struct bitmap {
        uint32 *b;
-       int n;
+       unsigned int n;
 };
 
-#define FLAG_BASIC     0x01 /* fundamental options */
-#define FLAG_SHARE     0x02 /* file sharing options */
-#define FLAG_PRINT     0x04 /* printing options */
-#define FLAG_GLOBAL    0x08 /* local options that should be globally settable in SWAT */
-#define FLAG_DEPRECATED 0x10 /* options that should no longer be used */
-#define FLAG_HIDE      0x20 /* options that should be hidden in SWAT */
+/* The following flags are used in SWAT */
+#define FLAG_BASIC     0x0001 /* Display only in BASIC view */
+#define FLAG_SHARE     0x0002 /* file sharing options */
+#define FLAG_PRINT     0x0004 /* printing options */
+#define FLAG_GLOBAL    0x0008 /* local options that should be globally settable in SWAT */
+#define FLAG_WIZARD    0x0010 /* Parameters that the wizard will operate on */
+#define FLAG_ADVANCED  0x0020 /* Parameters that will be visible in advanced view */
+#define FLAG_DEVELOPER         0x0040 /* No longer used */
+#define FLAG_DEPRECATED 0x1000 /* options that should no longer be used */
+#define FLAG_HIDE      0x2000 /* options that should be hidden in SWAT */
+#define FLAG_DOS_STRING 0x4000 /* convert from UNIX to DOS codepage when reading this string. */
 
 #ifndef LOCKING_VERSION
 #define LOCKING_VERSION 4
@@ -769,7 +735,8 @@ struct bitmap {
 #define smb_err 11
 #define smb_flg 13
 #define smb_flg2 14
-#define smb_reb 13
+#define smb_pidhigh 16
+#define smb_ss_field 18
 #define smb_tid 28
 #define smb_pid 30
 #define smb_uid 32
@@ -893,24 +860,29 @@ struct bitmap {
 #define SMBntcreateX     0xA2   /* NT create and X */
 #define SMBntcancel      0xA4   /* NT cancel */
 
+/* These are the trans subcommands */
+#define TRANSACT_SETNAMEDPIPEHANDLESTATE  0x01 
+#define TRANSACT_DCERPCCMD                0x26
+#define TRANSACT_WAITNAMEDPIPEHANDLESTATE 0x53
+
 /* These are the TRANS2 sub commands */
-#define TRANSACT2_OPEN                        0
-#define TRANSACT2_FINDFIRST                   1
-#define TRANSACT2_FINDNEXT                    2
-#define TRANSACT2_QFSINFO                     3
-#define TRANSACT2_SETFSINFO                   4
-#define TRANSACT2_QPATHINFO                   5
-#define TRANSACT2_SETPATHINFO                 6
-#define TRANSACT2_QFILEINFO                   7
-#define TRANSACT2_SETFILEINFO                 8
-#define TRANSACT2_FSCTL                       9
-#define TRANSACT2_IOCTL                     0xA
-#define TRANSACT2_FINDNOTIFYFIRST           0xB
-#define TRANSACT2_FINDNOTIFYNEXT            0xC
-#define TRANSACT2_MKDIR                     0xD
-#define TRANSACT2_SESSION_SETUP             0xE
-#define TRANSACT2_GET_DFS_REFERRAL         0x10
-#define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
+#define TRANSACT2_OPEN                         0x00
+#define TRANSACT2_FINDFIRST                    0x01
+#define TRANSACT2_FINDNEXT                     0x02
+#define TRANSACT2_QFSINFO                      0x03
+#define TRANSACT2_SETFSINFO                    0x04
+#define TRANSACT2_QPATHINFO                    0x05
+#define TRANSACT2_SETPATHINFO                  0x06
+#define TRANSACT2_QFILEINFO                    0x07
+#define TRANSACT2_SETFILEINFO                  0x08
+#define TRANSACT2_FSCTL                                0x09
+#define TRANSACT2_IOCTL                                0x0A
+#define TRANSACT2_FINDNOTIFYFIRST              0x0B
+#define TRANSACT2_FINDNOTIFYNEXT               0x0C
+#define TRANSACT2_MKDIR                                0x0D
+#define TRANSACT2_SESSION_SETUP                        0x0E
+#define TRANSACT2_GET_DFS_REFERRAL             0x10
+#define TRANSACT2_REPORT_DFS_INCONSISTANCY     0x11
 
 /* These are the NT transact sub commands. */
 #define NT_TRANSACT_CREATE                1
@@ -919,6 +891,13 @@ struct bitmap {
 #define NT_TRANSACT_NOTIFY_CHANGE         4
 #define NT_TRANSACT_RENAME                5
 #define NT_TRANSACT_QUERY_SECURITY_DESC   6
+#define NT_TRANSACT_GET_USER_QUOTA       7
+#define NT_TRANSACT_SET_USER_QUOTA       8
+
+/* These are the NT transact_get_user_quota sub commands */
+#define TRANSACT_GET_USER_QUOTA_LIST_CONTINUE  0x0000
+#define TRANSACT_GET_USER_QUOTA_LIST_START     0x0100
+#define TRANSACT_GET_USER_QUOTA_FOR_SID                0x0101
 
 /* Relevant IOCTL codes */
 #define IOCTL_QUERY_JOB_INFO      0x530060
@@ -1016,42 +995,38 @@ struct bitmap {
 #define PIPE_RAW_MODE 0x4
 #define PIPE_START_MESSAGE 0x8
 
-/* these are the constants used in the above call. */
-/* DesiredAccess */
-/* File Specific access rights. */
-#define FILE_READ_DATA        0x001
-#define FILE_WRITE_DATA       0x002
-#define FILE_APPEND_DATA      0x004
-#define FILE_READ_EA          0x008
-#define FILE_WRITE_EA         0x010
-#define FILE_EXECUTE          0x020
-#define FILE_DELETE_CHILD     0x040
-#define FILE_READ_ATTRIBUTES  0x080
-#define FILE_WRITE_ATTRIBUTES 0x100
-
-#define FILE_ALL_ACCESS       0x1FF
+/* File Specific access rights */
+#define FILE_READ_DATA        0x00000001
+#define FILE_WRITE_DATA       0x00000002
+#define FILE_APPEND_DATA      0x00000004
+#define FILE_READ_EA          0x00000008 /* File and directory */
+#define FILE_WRITE_EA         0x00000010 /* File and directory */
+#define FILE_EXECUTE          0x00000020
+#define FILE_DELETE_CHILD     0x00000040
+#define FILE_READ_ATTRIBUTES  0x00000080
+#define FILE_WRITE_ATTRIBUTES 0x00000100
+
+#define FILE_ALL_ACCESS       0x000001FF
+
+/* Directory specific access rights */
+#define FILE_LIST_DIRECTORY   0x00000001
+#define FILE_ADD_FILE         0x00000002
+#define FILE_ADD_SUBDIRECTORY 0x00000004
+#define FILE_TRAVERSE         0x00000020
+#define FILE_DELETE_CHILD     0x00000040
 
 /* the desired access to use when opening a pipe */
 #define DESIRED_ACCESS_PIPE 0x2019f
  
 /* Generic access masks & rights. */
-#define SPECIFIC_RIGHTS_MASK 0x00FFFFL
-#define STANDARD_RIGHTS_MASK 0xFF0000L
 #define DELETE_ACCESS        (1L<<16) /* 0x00010000 */
 #define READ_CONTROL_ACCESS  (1L<<17) /* 0x00020000 */
 #define WRITE_DAC_ACCESS     (1L<<18) /* 0x00040000 */
 #define WRITE_OWNER_ACCESS   (1L<<19) /* 0x00080000 */
 #define SYNCHRONIZE_ACCESS   (1L<<20) /* 0x00100000 */
 
-/* Combinations of standard masks. */
-#define STANDARD_RIGHTS_ALL_ACCESS (DELETE_ACCESS|READ_CONTROL_ACCESS|WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS|SYNCHRONIZE_ACCESS)
-#define STANDARD_RIGHTS_EXECUTE_ACCESS (READ_CONTROL_ACCESS)
-#define STANDARD_RIGHTS_READ_ACCESS (READ_CONTROL_ACCESS)
-#define STANDARD_RIGHTS_REQUIRED_ACCESS (DELETE_ACCESS|READ_CONTROL_ACCESS|WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS)
-#define STANDARD_RIGHTS_WRITE_ACCESS (READ_CONTROL_ACCESS)
-
-#define SYSTEM_SECURITY_ACCESS (1L<<24)                  /* 0x01000000 */
-#define MAXIMUM_ALLOWED_ACCESS (1L<<25)                  /* 0x02000000 */
+#define SYSTEM_SECURITY_ACCESS (1L<<24)           /* 0x01000000 */
+#define MAXIMUM_ALLOWED_ACCESS (1L<<25)           /* 0x02000000 */
 #define GENERIC_ALL_ACCESS     (1<<28)            /* 0x10000000 */
 #define GENERIC_EXECUTE_ACCESS (1<<29)            /* 0x20000000 */
 #define GENERIC_WRITE_ACCESS   (1<<30)            /* 0x40000000 */
@@ -1105,17 +1080,17 @@ struct bitmap {
 #define FILE_SHARE_DELETE 4
 
 /* FileAttributesField */
-#define FILE_ATTRIBUTE_READONLY aRONLY
-#define FILE_ATTRIBUTE_HIDDEN aHIDDEN
-#define FILE_ATTRIBUTE_SYSTEM aSYSTEM
-#define FILE_ATTRIBUTE_DIRECTORY aDIR
-#define FILE_ATTRIBUTE_ARCHIVE aARCH
-#define FILE_ATTRIBUTE_NORMAL 0x80L
-#define FILE_ATTRIBUTE_TEMPORARY 0x100L
-#define FILE_ATTRIBUTE_SPARSE 0x200L
-#define FILE_ATTRIBUTE_COMPRESSED 0x800L
-#define FILE_ATTRIBUTE_NONINDEXED 0x2000L
-#define SAMBA_ATTRIBUTES_MASK 0x7F
+#define FILE_ATTRIBUTE_READONLY                0x001L
+#define FILE_ATTRIBUTE_HIDDEN          0x002L
+#define FILE_ATTRIBUTE_SYSTEM          0x004L
+#define FILE_ATTRIBUTE_DIRECTORY       0x010L
+#define FILE_ATTRIBUTE_ARCHIVE         0x020L
+#define FILE_ATTRIBUTE_NORMAL          0x080L
+#define FILE_ATTRIBUTE_TEMPORARY       0x100L
+#define FILE_ATTRIBUTE_SPARSE          0x200L
+#define FILE_ATTRIBUTE_COMPRESSED      0x800L
+#define FILE_ATTRIBUTE_NONINDEXED      0x2000L
+#define SAMBA_ATTRIBUTES_MASK          0x7F
 
 /* Flags - combined with attributes. */
 #define FILE_FLAG_WRITE_THROUGH    0x80000000L
@@ -1143,8 +1118,10 @@ struct bitmap {
 #define FILE_EIGHT_DOT_THREE_ONLY 0x0400
 #define FILE_RANDOM_ACCESS        0x0800
 #define FILE_DELETE_ON_CLOSE      0x1000
+#define FILE_OPEN_BY_FILE_ID     0x2000
 
 /* Responses when opening a file. */
+#define FILE_WAS_SUPERSEDED 0
 #define FILE_WAS_OPENED 1
 #define FILE_WAS_CREATED 2
 #define FILE_WAS_OVERWRITTEN 3
@@ -1161,18 +1138,23 @@ struct bitmap {
 #define RENAME_REPLACE_IF_EXISTS 1
 
 /* Filesystem Attributes. */
-#define FILE_CASE_SENSITIVE_SEARCH 0x01
-#define FILE_CASE_PRESERVED_NAMES 0x02
-#define FILE_UNICODE_ON_DISK 0x04
+#define FILE_CASE_SENSITIVE_SEARCH      0x00000001
+#define FILE_CASE_PRESERVED_NAMES       0x00000002
+#define FILE_UNICODE_ON_DISK            0x00000004
 /* According to cifs9f, this is 4, not 8 */
 /* Acconding to testing, this actually sets the security attribute! */
-#define FILE_PERSISTENT_ACLS 0x08
-/* These entries added from cifs9f --tsb */
-#define FILE_FILE_COMPRESSION 0x10
-#define FILE_VOLUME_QUOTAS 0x20
-/* I think this is wrong. JRA #define FILE_DEVICE_IS_MOUNTED 0x20 */
-#define FILE_VOLUME_SPARSE_FILE 0x40
-#define FILE_VOLUME_IS_COMPRESSED 0x8000
+#define FILE_PERSISTENT_ACLS            0x00000008
+#define FILE_FILE_COMPRESSION           0x00000010
+#define FILE_VOLUME_QUOTAS              0x00000020
+#define FILE_SUPPORTS_SPARSE_FILES      0x00000040
+#define FILE_SUPPORTS_REPARSE_POINTS    0x00000080
+#define FILE_SUPPORTS_REMOTE_STORAGE    0x00000100
+#define FS_LFN_APIS                     0x00004000
+#define FILE_VOLUME_IS_COMPRESSED       0x00008000
+#define FILE_SUPPORTS_OBJECT_IDS        0x00010000
+#define FILE_SUPPORTS_ENCRYPTION        0x00020000
+#define FILE_NAMED_STREAMS              0x00040000
+#define FILE_READ_ONLY_VOLUME           0x00080000
 
 /* ChangeNotify flags. */
 #define FILE_NOTIFY_CHANGE_FILE        0x001
@@ -1257,23 +1239,31 @@ char *strdup(char *s);
  */
  
 #define DEFAULT_MAJOR_VERSION 0x04
-#define DEFAULT_MINOR_VERSION 0x05
+#define DEFAULT_MINOR_VERSION 0x09
 
 /* Browser Election Values */
 #define BROWSER_ELECTION_VERSION       0x010f
 #define BROWSER_CONSTANT       0xaa55
 
+/* Sercurity mode bits. */
+#define NEGOTIATE_SECURITY_USER_LEVEL          0x01
+#define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE  0x02
+#define NEGOTIATE_SECURITY_SIGNATURES_ENABLED  0x04
+#define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
+
 /* NT Flags2 bits - cifs6.txt section 3.1.2 */
    
-#define FLAGS2_LONG_PATH_COMPONENTS   0x0001
-#define FLAGS2_EXTENDED_ATTRIBUTES    0x0002
-#define FLAGS2_EXTENDED_SECURITY      0x0800 
-#define FLAGS2_DFS_PATHNAMES          0x1000
-#define FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
-#define FLAGS2_32_BIT_ERROR_CODES     0x4000 
-#define FLAGS2_UNICODE_STRINGS        0x8000
-
-#define FLAGS2_WIN2K_SIGNATURE        0xC852 /* Hack alert ! For now... JRA. */
+#define FLAGS2_LONG_PATH_COMPONENTS    0x0001
+#define FLAGS2_EXTENDED_ATTRIBUTES     0x0002
+#define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
+#define FLAGS2_IS_LONG_NAME            0x0040
+#define FLAGS2_EXTENDED_SECURITY       0x0800 
+#define FLAGS2_DFS_PATHNAMES           0x1000
+#define FLAGS2_READ_PERMIT_NO_EXECUTE  0x2000
+#define FLAGS2_32_BIT_ERROR_CODES      0x4000 
+#define FLAGS2_UNICODE_STRINGS         0x8000
+
+#define FLAGS2_WIN2K_SIGNATURE         0xC852 /* Hack alert ! For now... JRA. */
 
 /* Capabilities.  see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
 
@@ -1291,6 +1281,7 @@ char *strdup(char *s);
 #define CAP_W2K_SMBS         0x2000
 #define CAP_LARGE_READX      0x4000
 #define CAP_LARGE_WRITEX     0x8000
+#define CAP_UNIX             0x800000 /* Capabilities for UNIX extensions. Created by HP. */
 #define CAP_EXTENDED_SECURITY 0x80000000
 
 /* protocol types. It assumes that higher protocols include lower protocols
@@ -1324,17 +1315,15 @@ enum schema_types {SCHEMA_COMPAT, SCHEMA_AD, SCHEMA_SAMBA};
 /* LDAP SSL options */
 enum ldap_ssl_types {LDAP_SSL_ON, LDAP_SSL_OFF, LDAP_SSL_START_TLS};
 
+/* LDAP PASSWD SYNC methods */
+enum ldap_passwd_sync_types {LDAP_PASSWD_SYNC_ON, LDAP_PASSWD_SYNC_OFF, LDAP_PASSWD_SYNC_ONLY};
+
 /* Remote architectures we know about. */
-enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_WIN2K, RA_SAMBA};
+enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_WIN2K, RA_WINXP, RA_WIN2K3, RA_SAMBA};
 
 /* case handling */
 enum case_handling {CASE_LOWER,CASE_UPPER};
 
-#ifdef WITH_SSL
-/* SSL version options */
-enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1};
-#endif /* WITH_SSL */
-
 /*
  * Global value meaing that the smb_uid field should be
  * ingored (in share level security and protocol level == CORE)
@@ -1343,40 +1332,17 @@ enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1};
 #define UID_FIELD_INVALID 0
 #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
 
-/* Defines needed for multi-codepage support. */
-#define MSDOS_LATIN_1_CODEPAGE 850
-#define KANJI_CODEPAGE 932
-#define HANGUL_CODEPAGE 949
-#define BIG5_CODEPAGE 950
-#define SIMPLIFIED_CHINESE_CODEPAGE 936
-
-#ifdef KANJI
-/* 
- * Default client code page - Japanese 
- */
-#define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE
-#else /* KANJI */
-/* 
- * Default client code page - 850 - Western European 
- */
-#define DEFAULT_CLIENT_CODE_PAGE MSDOS_LATIN_1_CODEPAGE
-#endif /* KANJI */
-
-/* Global val set if multibyte codepage. */
-extern int global_is_multibyte_codepage;
-
-#define get_character_len(x) (global_is_multibyte_codepage ? skip_multibyte_char((x)) : 0)
-
 /* 
  * Size of buffer to use when moving files across filesystems. 
  */
 #define COPYBUF_SIZE (8*1024)
 
 /* 
- * Integers used to override error codes. 
+ * Values used to override error codes. 
  */
 extern int unix_ERR_class;
 extern int unix_ERR_code;
+extern NTSTATUS unix_ERR_ntstatus;
 
 /*
  * Used in chaining code.
@@ -1457,15 +1423,17 @@ extern int chain_size;
  *  +----+--------+-------+--------+---------+
  */
 
-#define OPLOCK_BREAK_CMD 0x1
 #define OPLOCK_BREAK_PID_OFFSET 2
 #define OPLOCK_BREAK_DEV_OFFSET (OPLOCK_BREAK_PID_OFFSET + sizeof(pid_t))
 #define OPLOCK_BREAK_INODE_OFFSET (OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))
 #define OPLOCK_BREAK_FILEID_OFFSET (OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
 #define OPLOCK_BREAK_MSG_LEN (OPLOCK_BREAK_FILEID_OFFSET + sizeof(unsigned long))
 
+/* Message types */
+#define OPLOCK_BREAK_CMD 0x1
 #define KERNEL_OPLOCK_BREAK_CMD 0x2
 #define LEVEL_II_OPLOCK_BREAK_CMD 0x3
+#define ASYNC_LEVEL_II_OPLOCK_BREAK_CMD 0x4
 
 /*
  * Capabilities abstracted for different systems.
@@ -1516,27 +1484,23 @@ struct cnotify_fns {
 
 #include "smb_macros.h"
 
+typedef char nstring[16];
+
 /* A netbios name structure. */
 struct nmb_name {
-  char         name[17];
-  char         scope[64];
-  unsigned int name_type;
+       nstring      name;
+       char         scope[64];
+       unsigned int name_type;
 };
 
 
 /* A netbios node status array element. */
 struct node_status {
-       char name[16];
+       nstring name;
        unsigned char type;
        unsigned char flags;
 };
 
-
-
-#define AGENT_CMD_CON       0
-#define AGENT_CMD_CON_ANON  2
-#define AGENT_CMD_CON_REUSE 1
-
 struct pwd_info
 {
        BOOL null_pwd;
@@ -1559,23 +1523,6 @@ struct pwd_info
        uchar sess_key[16];
 };
 
-/*
- * Network Computing Architechture Context Name Named Pipe
- * See MSDN docs for more information
- */
-struct ncacn_np
-{
-        fstring pipe_name;
-        struct cli_state *smb;
-        uint16 fnum;
-        BOOL initialised;
-};
-
-#include "rpc_creds.h"
-#include "rpc_misc.h"
-#include "rpc_secdes.h"
-#include "nt_printing.h"
-
 typedef struct user_struct
 {
        struct user_struct *next, *prev;
@@ -1584,6 +1531,10 @@ typedef struct user_struct
        gid_t gid; /* gid of a validated user */
 
        userdom_struct user;
+       char *homedir;
+       char *unix_homedir;
+       char *logon_script;
+       
        BOOL guest;
 
        /* following groups stuff added by ih */
@@ -1593,19 +1544,29 @@ typedef struct user_struct
 
        NT_USER_TOKEN *nt_user_token;
 
-       int session_id; /* used by utmp and pam session code */
+       uint8 session_key[16];
+
+       char *session_keystr; /* used by utmp and pam session code.  
+                                TDB key string */
+       int homes_snum;
+
+       struct auth_serversupplied_info *server_info;
+
 } user_struct;
 
-/* used to hold an arbitrary blob of data */
-typedef struct {
-       uint8 *data;
-       size_t length;
-} DATA_BLOB;
 
+struct unix_error_map {
+       int unix_error;
+       int dos_class;
+       int dos_code;
+       NTSTATUS nt_error;
+};
 
+/*
 #include "ntdomain.h"
 
 #include "client.h"
+*/
 
 /*
  * Size of new password account encoding string.  This is enough space to
@@ -1642,9 +1603,6 @@ typedef struct {
 
 #define SAFE_NETBIOS_CHARS ". -_"
 
-#include "nsswitch/winbindd_nss.h"
-#include "smb_acls.h"
-
 /* generic iconv conversion structure */
 typedef struct {
        size_t (*direct)(void *cd, char **inbuf, size_t *inbytesleft,
@@ -1663,4 +1621,31 @@ typedef struct {
 
 #define DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH 14
 
+#include "popt_common.h"
+
+#define PORT_NONE      0
+#ifndef LDAP_PORT
+#define LDAP_PORT      389
+#endif
+
+/* used by the IP comparison function */
+struct ip_service {
+       struct in_addr ip;
+       unsigned port;
+};
+
+/* Used by the SMB signing functions. */
+
+typedef struct smb_sign_info {
+       void (*sign_outgoing_message)(char *outbuf, struct smb_sign_info *si);
+       BOOL (*check_incoming_message)(char *inbuf, struct smb_sign_info *si);
+       void (*free_signing_context)(struct smb_sign_info *si);
+       void *signing_context;
+
+       BOOL negotiated_smb_signing;
+       BOOL allow_smb_signing;
+       BOOL doing_signing;
+       BOOL mandatory_signing;
+} smb_sign_info;
+
 #endif /* _SMB_H */