s3-smb: Remove the obsolete signal type cast.
[ira/wip.git] / source3 / include / smb.h
index 744acd719f874ebd2f4640c2a9c9957eff42e1d2..de998cbe0a77b9bea2a913cdba76573566211efe 100644 (file)
@@ -27,7 +27,7 @@
 #define _SMB_H
 
 /* logged when starting the various Samba daemons */
-#define COPYRIGHT_STARTUP_MESSAGE      "Copyright Andrew Tridgell and the Samba Team 1992-2008"
+#define COPYRIGHT_STARTUP_MESSAGE      "Copyright Andrew Tridgell and the Samba Team 1992-2010"
 
 
 #if defined(LARGE_SMB_OFF_T)
@@ -137,7 +137,7 @@ enum smb_read_errors {
 #define OPENX_FILE_CREATE_IF_NOT_EXIST 0x10
 #define OPENX_FILE_FAIL_IF_NOT_EXIST 0
 
-#include "doserr.h"
+#include "../libcli/util/doserr.h"
 
 typedef union unid_t {
        uid_t uid;
@@ -149,8 +149,6 @@ typedef union unid_t {
  * smb_ucs2_t is *always* in little endian format.
  */
 
-typedef uint16 smb_ucs2_t;
-
 #ifdef WORDS_BIGENDIAN
 #define UCS2_SHIFT 8
 #else
@@ -167,73 +165,8 @@ typedef uint16 smb_ucs2_t;
 #define COPY_UCS2_CHAR(dest,src) (((unsigned char *)(dest))[0] = ((unsigned char *)(src))[0],\
                                ((unsigned char *)(dest))[1] = ((unsigned char *)(src))[1], (dest))
 
-/* Large data type for manipulating uint32 unicode codepoints */
-typedef uint32 codepoint_t;
-#define INVALID_CODEPOINT ((codepoint_t)-1)
-
 /* pipe string names */
 #define PIPE_LANMAN   "\\PIPE\\LANMAN"
-#define PIPE_SRVSVC   "\\PIPE\\srvsvc"
-#define PIPE_SAMR     "\\PIPE\\samr"
-#define PIPE_WINREG   "\\PIPE\\winreg"
-#define PIPE_WKSSVC   "\\PIPE\\wkssvc"
-#define PIPE_NETLOGON "\\PIPE\\NETLOGON"
-#define PIPE_NTLSA    "\\PIPE\\ntlsa"
-#define PIPE_NTSVCS   "\\PIPE\\ntsvcs"
-#define PIPE_LSASS    "\\PIPE\\lsass"
-#define PIPE_LSARPC   "\\PIPE\\lsarpc"
-#define PIPE_SPOOLSS  "\\PIPE\\spoolss"
-#define PIPE_NETDFS   "\\PIPE\\netdfs"
-#define PIPE_ECHO     "\\PIPE\\rpcecho"
-#define PIPE_SHUTDOWN "\\PIPE\\initshutdown"
-#define PIPE_EPM      "\\PIPE\\epmapper"
-#define PIPE_SVCCTL   "\\PIPE\\svcctl"
-#define PIPE_EVENTLOG "\\PIPE\\eventlog"
-
-#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_RPCECHO             9
-#define PI_INITSHUTDOWN                10
-#define PI_SVCCTL              11
-#define PI_EVENTLOG            12
-#define PI_NTSVCS              13
-#define PI_MAX_PIPES           14
-
-/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
-typedef uint64_t NTTIME;
-
-
-/* Allowable account control bits */
-#define ACB_DISABLED                   0x00000001  /* 1 = User account disabled */
-#define ACB_HOMDIRREQ                  0x00000002  /* 1 = Home directory required */
-#define ACB_PWNOTREQ                   0x00000004  /* 1 = User password not required */
-#define ACB_TEMPDUP                    0x00000008  /* 1 = Temporary duplicate account */
-#define ACB_NORMAL                     0x00000010  /* 1 = Normal user account */
-#define ACB_MNS                                0x00000020  /* 1 = MNS logon user account */
-#define ACB_DOMTRUST                   0x00000040  /* 1 = Interdomain trust account */
-#define ACB_WSTRUST                    0x00000080  /* 1 = Workstation trust account */
-#define ACB_SVRTRUST                   0x00000100  /* 1 = Server trust account (BDC) */
-#define ACB_PWNOEXP                    0x00000200  /* 1 = User password does not expire */
-#define ACB_AUTOLOCK                   0x00000400  /* 1 = Account auto locked */
-
-/* only valid for > Windows 2000 */
-#define ACB_ENC_TXT_PWD_ALLOWED                0x00000800  /* 1 = Text password encryped */
-#define ACB_SMARTCARD_REQUIRED         0x00001000  /* 1 = Smart Card required */
-#define ACB_TRUSTED_FOR_DELEGATION     0x00002000  /* 1 = Trusted for Delegation */
-#define ACB_NOT_DELEGATED              0x00004000  /* 1 = Not delegated */
-#define ACB_USE_DES_KEY_ONLY           0x00008000  /* 1 = Use DES key only */
-#define ACB_DONT_REQUIRE_PREAUTH       0x00010000  /* 1 = Preauth not required */
-#define ACB_PWEXPIRED                  0x00020000  /* 1 = Password is expired */
-#define ACB_NO_AUTH_DATA_REQD          0x00080000  /* 1 = No authorization data required */
 
 #define MAX_HOURS_LEN 32
 
@@ -249,9 +182,8 @@ typedef uint64_t NTTIME;
 #define LOOKUP_NAME_GROUP                0x00000004  /* (unused) This is a NASTY hack for 
                                                        valid users = @foo where foo also
                                                        exists in as user. */
-#define LOOKUP_NAME_EXPLICIT             0x00000008  /* Only include
-                                                       explicitly mapped names and not 
-                                                       the Unix {User,Group} domain */
+#define LOOKUP_NAME_NO_NSS              0x00000008  /* no NSS calls to avoid
+                                                       winbind recursions */
 #define LOOKUP_NAME_BUILTIN            0x00000010 /* builtin names */
 #define LOOKUP_NAME_WKN                        0x00000020 /* well known names */
 #define LOOKUP_NAME_DOMAIN             0x00000040 /* only lookup own domain */
@@ -270,21 +202,7 @@ typedef uint64_t NTTIME;
  *
  * @sa http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/accctrl_38yn.asp
  **/
-typedef struct dom_sid {
-       uint8  sid_rev_num;             /**< SID revision number */
-       uint8  num_auths;               /**< Number of sub-authorities */
-       uint8  id_auth[6];              /**< Identifier Authority */
-       /*
-        *  Pointer to sub-authorities.
-        *
-        * @note The values in these uint32's are in *native* byteorder, not
-        * neccessarily little-endian...... JRA.
-        */
-       uint32 sub_auths[MAXSUBAUTHS];  
-} DOM_SID;
-
-#define dom_sid2 dom_sid
-#define dom_sid28 dom_sid
+typedef struct dom_sid DOM_SID;
 
 enum id_mapping {
        ID_UNKNOWN = 0,
@@ -310,8 +228,8 @@ struct id_map {
        enum id_mapping status;
 };
 
-#include "librpc/ndr/misc.h"
-#include "librpc/ndr/security.h"
+#include "librpc/gen_ndr/misc.h"
+#include "librpc/gen_ndr/security.h"
 #include "librpc/ndr/libndr.h"
 #include "librpc/gen_ndr/lsa.h"
 #include "librpc/gen_ndr/dfs.h"
@@ -322,8 +240,20 @@ struct id_map {
 #include "librpc/gen_ndr/wkssvc.h"
 #include "librpc/gen_ndr/echo.h"
 #include "librpc/gen_ndr/svcctl.h"
+#include "librpc/gen_ndr/netlogon.h"
+#include "librpc/gen_ndr/samr.h"
+#include "librpc/gen_ndr/dssetup.h"
+#include "librpc/gen_ndr/epmapper.h"
 #include "librpc/gen_ndr/libnet_join.h"
-
+#include "librpc/gen_ndr/krb5pac.h"
+#include "librpc/gen_ndr/ntsvcs.h"
+#include "librpc/gen_ndr/nbt.h"
+#include "librpc/gen_ndr/drsuapi.h"
+#include "librpc/gen_ndr/drsblobs.h"
+#include "librpc/gen_ndr/spoolss.h"
+#include "librpc/gen_ndr/dcerpc.h"
+#include "librpc/gen_ndr/ndr_dcerpc.h"
+#include "librpc/gen_ndr/ntlmssp.h"
 
 struct lsa_dom_info {
        bool valid;
@@ -385,10 +315,10 @@ typedef struct nt_user_token {
        SE_PRIV privileges;
 } NT_USER_TOKEN;
 
-typedef struct _unix_token {
+typedef struct unix_user_token {
        uid_t uid;
        gid_t gid;
-       int ngroups;
+       size_t ngroups;
        gid_t *groups;
 } UNIX_USER_TOKEN;
 
@@ -405,18 +335,12 @@ typedef struct write_cache {
        char *data;
 } write_cache;
 
-typedef struct {
-       smb_ucs2_t *origname;
-       smb_ucs2_t *filename;
-       SMB_STRUCT_STAT *statinfo;
-} smb_filename;
-
 #include "fake_file.h"
 
 struct fd_handle {
        size_t ref_count;
        int fd;
-       SMB_BIG_UINT position_information;
+       uint64_t position_information;
        SMB_OFF_T pos;
        uint32 private_options; /* NT Create options, but we only look at
                                 * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and
@@ -428,17 +352,21 @@ struct fd_handle {
        unsigned long gen_id;
 };
 
-struct event_context;
-struct fd_event;
-struct timed_event;
 struct idle_event;
 struct share_mode_entry;
 struct uuid;
+struct named_mutex;
+struct pcap_cache;
+struct wb_context;
+struct rpc_cli_smbd_conn;
+struct fncall_context;
 
 struct vfs_fsp_data {
     struct vfs_fsp_data *next;
     struct vfs_handle_struct *owner;
-    /* NOTE: This structure contains two pointers so that we can guarantee
+    void (*destroy)(void *p_data);
+    void *_dummy_;
+    /* NOTE: This structure contains four pointers so that we can guarantee
      * that the end of the structure is always both 4-byte and 8-byte aligned.
      */
 };
@@ -490,7 +418,7 @@ typedef struct files_struct {
        unsigned int num_smb_operations;
        uint16 rap_print_jobid;
        struct file_id file_id;
-       SMB_BIG_UINT initial_allocation_size; /* Faked up initial allocation on disk. */
+       uint64_t initial_allocation_size; /* Faked up initial allocation on disk. */
        mode_t mode;
        uint16 file_pid;
        uint16 vuid;
@@ -498,9 +426,13 @@ typedef struct files_struct {
        struct timeval open_time;
        uint32 access_mask;             /* NTCreateX access bits (FILE_READ_DATA etc.) */
        uint32 share_access;            /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */
-       bool pending_modtime_owner;
-       struct timespec pending_modtime;
-       struct timespec last_write_time;
+
+       bool update_write_time_triggered;
+       struct timed_event *update_write_time_event;
+       bool update_write_time_on_close;
+       struct timespec close_write_time;
+       bool write_time_forced;
+
        int oplock_type;
        int sent_oplock_break;
        struct timed_event *oplock_timeout;
@@ -516,49 +448,43 @@ typedef struct files_struct {
        bool print_file;
        bool modified;
        bool is_directory;
-       bool is_stat;
        bool aio_write_behind;
        bool lockdb_clean;
        bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */
+       bool delete_on_close;
        bool posix_open;
-       char *fsp_name;
+       struct smb_filename *fsp_name;
 
        struct vfs_fsp_data *vfs_extension;
-       FAKE_FILE_HANDLE *fake_file_handle;
+       struct fake_file_handle *fake_file_handle;
 
        struct notify_change_buf *notify;
-} files_struct;
 
-#include "ntquotas.h"
-#include "sysquotas.h"
+       struct files_struct *base_fsp; /* placeholder for delete on close */
 
-/* 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;
-
-extern const DATA_BLOB data_blob_null;
+       /*
+        * Read-only cached brlock record, thrown away when the
+        * brlock.tdb seqnum changes. This avoids fetching data from
+        * the brlock.tdb on every read/write call.
+        */
+       int brlock_seqnum;
+       struct byte_range_lock *brlock_rec;
 
-/*
- * Structure used to keep directory state information around.
- * Used in NT change-notify code.
- */
+       struct dptr_struct *dptr;
+} files_struct;
 
-typedef struct {
-       time_t modify_time;
-       time_t status_time;
-} dir_status_struct;
+#include "ntquotas.h"
+#include "sysquotas.h"
 
 struct vuid_cache_entry {
-       uint16 vuid;
+       struct auth_serversupplied_info *server_info;
+       uint16_t vuid;
        bool read_only;
        bool admin_user;
 };
 
 struct vuid_cache {
-       unsigned int entries;
+       unsigned int next_entry;
        struct vuid_cache_entry array[VUID_CACHE_SIZE];
 };
 
@@ -597,6 +523,16 @@ struct trans_state {
        char *data;
 };
 
+/*
+ * Info about an alternate data stream
+ */
+
+struct stream_struct {
+       SMB_OFF_T size;
+       SMB_OFF_T alloc_size;
+       char *name;
+};
+
 /* Include VFS stuff */
 
 #include "smb_acls.h"
@@ -604,10 +540,10 @@ struct trans_state {
 
 struct dfree_cached_info {
        time_t last_dfree_time;
-       SMB_BIG_UINT dfree_ret;
-       SMB_BIG_UINT bsize;
-       SMB_BIG_UINT dfree;
-       SMB_BIG_UINT dsize;
+       uint64_t dfree_ret;
+       uint64_t bsize;
+       uint64_t dfree;
+       uint64_t dsize;
 };
 
 struct dptr_struct;
@@ -622,39 +558,40 @@ struct share_iterator {
 
 typedef struct connection_struct {
        struct connection_struct *next, *prev;
-       TALLOC_CTX *mem_ctx; /* long-lived memory context for things hanging off this struct. */
+       struct smbd_server_connection *sconn; /* can be NULL */
        unsigned cnum; /* an index passed over the wire */
        struct share_params *params;
        bool force_user;
-       bool force_group;
        struct vuid_cache vuid_cache;
-       struct dptr_struct *dirptr;
        bool printer;
        bool ipc;
        bool read_only; /* Attributes for the current user of the share. */
        bool admin_user; /* Attributes for the current user of the share. */
-       char *dirpath;
+       /* Does this filesystem honor
+          sub second timestamps on files
+          and directories when setting time ? */
+       enum timestamp_set_resolution ts_res;
        char *connectpath;
        char *origpath;
 
-       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 */
-       gid_t gid; /* gid of user who *opened* this connection */
+       /*
+        * This represents the user information on this connection. Depending
+        * on the vuid using this tid, this might change per SMB request.
+        */
+       struct auth_serversupplied_info *server_info;
+
+       /*
+        * If the "force group" parameter is set, this is the primary gid that
+        * may be used in the users token, depending on the vuid using this tid.
+        */
+       gid_t force_group_gid;
+
        char client_address[INET6_ADDRSTRLEN]; /* String version of client IP address. */
 
        uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
 
-       /* following groups stuff added by ih */
-
-       /* This groups info is valid for the user that *opened* the connection */
-       size_t ngroups;
-       gid_t *groups;
-       NT_USER_TOKEN *nt_user_token;
-       
        time_t lastused;
        time_t lastused_count;
        bool used;
@@ -687,18 +624,53 @@ struct current_user {
        NT_USER_TOKEN *nt_user_token;
 };
 
+
 struct smb_request {
+       uint8_t cmd;
        uint16 flags2;
        uint16 smbpid;
        uint16 mid;
+       uint32_t seqnum;
        uint16 vuid;
        uint16 tid;
        uint8  wct;
+       uint16_t *vwv;
+       uint16_t buflen;
+       const uint8_t *buf;
        const uint8 *inbuf;
+
+       /*
+        * Async handling in the main smb processing loop is directed by
+        * outbuf: reply_xxx routines indicate sync behaviour by putting their
+        * reply into "outbuf". If they leave it as NULL, they take of it
+        * themselves, possibly later.
+        *
+        * If async handling is wanted, the reply_xxx routine must make sure
+        * that it talloc_move()s the smb_req somewhere else.
+        */
        uint8 *outbuf;
+
        size_t unread_bytes;
        bool encrypted;
        connection_struct *conn;
+       struct smb_perfcount_data pcd;
+
+       /*
+        * Chained request handling
+        */
+       struct files_struct *chain_fsp;
+
+       /*
+        * Here we collect the outbufs from the chain handlers
+        */
+       uint8_t *chain_outbuf;
+
+       /*
+        * state information for async smb handling
+        */
+       void *async_priv;
+
+       bool done;
 };
 
 /* Defines for the sent_oplock_break field above. */
@@ -709,7 +681,6 @@ struct smb_request {
 typedef struct {
        fstring smb_name; /* user name from the client */
        fstring unix_name; /* unix user name of a validated user */
-       fstring full_name; /* to store full name (such as "Joe Bloggs") from gecos field of password file */
        fstring domain; /* domain that the client specified */
 } userdom_struct;
 
@@ -761,14 +732,16 @@ struct interface {
 struct pending_message_list {
        struct pending_message_list *next, *prev;
        struct timeval request_time; /* When was this first issued? */
-       struct timeval end_time; /* When does this time out? */
+       struct timed_event *te;
+       struct smb_perfcount_data pcd;
+       uint32_t seqnum;
        bool encrypted;
+       bool processed;
        DATA_BLOB buf;
        DATA_BLOB private_data;
 };
 
 #define SHARE_MODE_FLAG_POSIX_OPEN     0x1
-#define SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE      0x2
 
 /* struct returned by get_share_modes */
 struct share_mode_entry {
@@ -799,28 +772,32 @@ Offset  Data                      length.
 16     uint32 private_options  4
 20     uint32 time sec         4
 24     uint32 time usec        4
-28     SMB_DEV_T dev           8 bytes.
-36     SMB_INO_T inode         8 bytes
-44     unsigned long file_id   4 bytes
-48     uint32 uid              4 bytes
-52     uint16 flags            2 bytes
-54
+28     uint64 dev              8 bytes
+36     uint64 inode            8 bytes
+44     uint64 extid            8 bytes
+52     unsigned long file_id   4 bytes
+56     uint32 uid              4 bytes
+60     uint16 flags            2 bytes
+62
 
 */
 #ifdef CLUSTER_SUPPORT
-#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 58
+#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 66
 #else
-#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 54
+#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 62
 #endif
 
 struct share_mode_lock {
        const char *servicepath; /* canonicalized. */
-       const char *filename;
+       const char *base_name;
+       const char *stream_name;
        struct file_id id;
        int num_share_modes;
        struct share_mode_entry *share_modes;
        UNIX_USER_TOKEN *delete_token;
        bool delete_on_close;
+       struct timespec old_write_time;
+       struct timespec changed_write_time;
        bool fresh;
        bool modified;
        struct db_record *record;
@@ -836,6 +813,8 @@ struct locking_data {
                struct {
                        int num_share_mode_entries;
                        bool delete_on_close;
+                       struct timespec old_write_time;
+                       struct timespec changed_write_time;
                        uint32 delete_token_size; /* Only valid if either of
                                                     the two previous fields
                                                     are True. */
@@ -869,20 +848,6 @@ struct pipe_open_rec {
 #define PW_HISTORY_ENTRY_LEN (PW_HISTORY_SALT_LEN+SALTED_MD5_HASH_LEN)
 #define MAX_PW_HISTORY_LEN 24
 
-/*
- * Flags for account policy.
- */
-#define AP_MIN_PASSWORD_LEN            1
-#define AP_PASSWORD_HISTORY            2
-#define AP_USER_MUST_LOGON_TO_CHG_PASS 3
-#define AP_MAX_PASSWORD_AGE            4
-#define AP_MIN_PASSWORD_AGE            5
-#define AP_LOCK_ACCOUNT_DURATION       6
-#define AP_RESET_COUNT_TIME            7
-#define AP_BAD_ATTEMPT_LOCKOUT         8
-#define AP_TIME_TO_LOGOUT              9
-#define AP_REFUSE_MACHINE_PW_CHANGE    10
-
 /*
  * Flags for local user manipulation.
  */
@@ -962,6 +927,7 @@ struct parm_struct {
 #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. */
+#define FLAG_META      0x8000 /* A meta directive - not a real parameter */
 
 struct bitmap {
        uint32 *b;
@@ -1276,18 +1242,29 @@ struct bitmap {
 /* Mapping of generic access rights for files to specific rights. */
 
 /* This maps to 0x1F01FF */
-#define FILE_GENERIC_ALL (STANDARD_RIGHTS_REQUIRED_ACCESS| SYNCHRONIZE_ACCESS|FILE_ALL_ACCESS)
+#define FILE_GENERIC_ALL (STANDARD_RIGHTS_REQUIRED_ACCESS|\
+                         SYNCHRONIZE_ACCESS|\
+                         FILE_ALL_ACCESS)
 
 /* This maps to 0x120089 */
-#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ_ACCESS|FILE_READ_DATA|FILE_READ_ATTRIBUTES|\
-                                                       FILE_READ_EA|SYNCHRONIZE_ACCESS)
+#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ_ACCESS|\
+                          FILE_READ_DATA|\
+                          FILE_READ_ATTRIBUTES|\
+                          FILE_READ_EA|\
+                          SYNCHRONIZE_ACCESS)
 
 /* This maps to 0x120116 */
-#define FILE_GENERIC_WRITE (STD_RIGHT_READ_CONTROL_ACCESS|FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES|\
-                                                       FILE_WRITE_EA|FILE_APPEND_DATA|SYNCHRONIZE_ACCESS)
+#define FILE_GENERIC_WRITE (STD_RIGHT_READ_CONTROL_ACCESS|\
+                           FILE_WRITE_DATA|\
+                           FILE_WRITE_ATTRIBUTES|\
+                           FILE_WRITE_EA|\
+                           FILE_APPEND_DATA|\
+                           SYNCHRONIZE_ACCESS)
 
 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE_ACCESS|\
-                                                               FILE_EXECUTE|SYNCHRONIZE_ACCESS)
+                             FILE_READ_ATTRIBUTES|\
+                             FILE_EXECUTE|\
+                             SYNCHRONIZE_ACCESS)
 
 /* Share specific rights. */
 #define SHARE_ALL_ACCESS      FILE_GENERIC_ALL
@@ -1302,7 +1279,7 @@ struct bitmap {
 /* Mapping of access rights to UNIX perms. for a UNIX directory. */
 #define UNIX_DIRECTORY_ACCESS_RWX              FILE_GENERIC_ALL
 #define UNIX_DIRECTORY_ACCESS_R                FILE_GENERIC_READ
-#define UNIX_DIRECTORY_ACCESS_W                        FILE_GENERIC_WRITE
+#define UNIX_DIRECTORY_ACCESS_W                        (FILE_GENERIC_WRITE|FILE_DELETE_CHILD)
 #define UNIX_DIRECTORY_ACCESS_X                        FILE_GENERIC_EXECUTE
 
 #if 0
@@ -1371,16 +1348,37 @@ struct bitmap {
 #define FILE_DIRECTORY_FILE       0x0001
 #define FILE_WRITE_THROUGH        0x0002
 #define FILE_SEQUENTIAL_ONLY      0x0004
+#define FILE_NO_INTERMEDIATE_BUFFERING 0x0008
+#define FILE_SYNCHRONOUS_IO_ALERT      0x0010  /* may be ignored */
+#define FILE_SYNCHRONOUS_IO_NONALERT   0x0020  /* may be ignored */
 #define FILE_NON_DIRECTORY_FILE   0x0040
+#define FILE_CREATE_TREE_CONNECTION    0x0080  /* ignore, should be zero */
+#define FILE_COMPLETE_IF_OPLOCKED      0x0100  /* ignore, should be zero */
 #define FILE_NO_EA_KNOWLEDGE      0x0200
-#define FILE_EIGHT_DOT_THREE_ONLY 0x0400
+#define FILE_EIGHT_DOT_THREE_ONLY 0x0400 /* aka OPEN_FOR_RECOVERY: ignore, should be zero */
 #define FILE_RANDOM_ACCESS        0x0800
 #define FILE_DELETE_ON_CLOSE      0x1000
 #define FILE_OPEN_BY_FILE_ID     0x2000
+#define FILE_OPEN_FOR_BACKUP_INTENT    0x4000
+#define FILE_NO_COMPRESSION       0x8000
+#define FILE_RESERVER_OPFILTER    0x00100000   /* ignore, should be zero */
+#define FILE_OPEN_REPARSE_POINT   0x00200000
+#define FILE_OPEN_NO_RECALL       0x00400000
+#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 /* ignore should be zero */
+
+#define NTCREATEX_OPTIONS_MUST_IGNORE_MASK      (0x008F0480)
+
+#define NTCREATEX_OPTIONS_INVALID_PARAM_MASK    (0xFF100030)
 
-/* Private create options used by the ntcreatex processing code. From Samba4. */
-#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS     0x01000000
-#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB     0x02000000
+/*
+ * Private create options used by the ntcreatex processing code. From Samba4.
+ * We reuse some ignored flags for private use.
+ */
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS     0x00010000
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB     0x00020000
+
+/* Private options for streams support */
+#define NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE 0x00040000
 
 /* Responses when opening a file. */
 #define FILE_WAS_SUPERSEDED 0
@@ -1471,10 +1469,6 @@ extern int dcelogin_atmost_once;
 char *strdup(char *s);
 #endif
 
-#ifndef SIGNAL_CAST
-#define SIGNAL_CAST (RETSIGTYPE (*)(int))
-#endif
-
 #ifndef SELECT_CAST
 #define SELECT_CAST
 #endif
@@ -1523,6 +1517,15 @@ char *strdup(char *s);
 /* TCONX Flag (smb_vwv2). */
 #define TCONX_FLAG_EXTENDED_RESPONSE   0x8
 
+/* File Status Flags. See:
+
+http://msdn.microsoft.com/en-us/library/cc246334(PROT.13).aspx
+*/
+
+#define NO_EAS                 0x1
+#define NO_SUBSTREAMS          0x2
+#define NO_REPARSETAG          0x4
+
 /* Capabilities.  see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
 
 #define CAP_RAW_MODE         0x0001
@@ -1544,7 +1547,15 @@ char *strdup(char *s);
 
 /* protocol types. It assumes that higher protocols include lower protocols
    as subsets */
-enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
+enum protocol_types {
+       PROTOCOL_NONE,
+       PROTOCOL_CORE,
+       PROTOCOL_COREPLUS,
+       PROTOCOL_LANMAN1,
+       PROTOCOL_LANMAN2,
+       PROTOCOL_NT1,
+       PROTOCOL_SMB2
+};
 
 /* security levels */
 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN,SEC_ADS};
@@ -1570,7 +1581,7 @@ enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
 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};
+enum ldap_ssl_types {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};
@@ -1578,7 +1589,7 @@ enum ldap_passwd_sync_types {LDAP_PASSWD_SYNC_ON, LDAP_PASSWD_SYNC_OFF, LDAP_PAS
 /* Remote architectures we know about. */
 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT,
                        RA_WIN2K, RA_WINXP, RA_WIN2K3, RA_VISTA,
-                       RA_SAMBA, RA_CIFSFS};
+                       RA_SAMBA, RA_CIFSFS, RA_WINXP64};
 
 /* case handling */
 enum case_handling {CASE_LOWER,CASE_UPPER};
@@ -1598,11 +1609,6 @@ enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
  */
 #define COPYBUF_SIZE (8*1024)
 
-/*
- * Used in chaining code.
- */
-extern int chain_size;
-
 /*
  * Map the Core and Extended Oplock requesst bits down
  * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
@@ -1652,48 +1658,43 @@ extern int chain_size;
 #define BATCH_OPLOCK_TYPE(lck) ((lck) & (unsigned int)BATCH_OPLOCK)
 #define LEVEL_II_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)LEVEL_II_OPLOCK|(unsigned int)FAKE_LEVEL_II_OPLOCK))
 
-struct inform_level2_message {
-       SMB_DEV_T dev;
-       SMB_INO_T inode;
-       uint16 mid;
-       unsigned long target_file_id;
-       unsigned long source_file_id;
-};
-
 /* kernel_oplock_message definition.
 
 struct kernel_oplock_message {
-       SMB_DEV_T dev;
-       SMB_INO_T inode;
+       uint64_t dev;
+       uint64_t inode;
+       unit64_t extid;
        unsigned long file_id;
 };
 
 Offset  Data                  length.
-0     SMB_DEV_T dev           8 bytes.
-8     SMB_INO_T inode         8 bytes
-16    unsigned long file_id   4 bytes
-20
+0     uint64_t dev            8 bytes
+8     uint64_t inode          8 bytes
+16    uint64_t extid          8 bytes
+24    unsigned long file_id   4 bytes
+28
 
 */
-#define MSG_SMB_KERNEL_BREAK_SIZE 20
+#define MSG_SMB_KERNEL_BREAK_SIZE 28
 
 /* file_renamed_message definition.
 
 struct file_renamed_message {
-       SMB_DEV_T dev;
-       SMB_INO_T inode;
+       uint64_t dev;
+       uint64_t inode;
        char names[1]; A variable area containing sharepath and filename.
 };
 
 Offset  Data                   length.
-0      SMB_DEV_T dev           8 bytes.
-8      SMB_INO_T inode         8 bytes
-16     char [] name            zero terminated namelen bytes
-minimum length == 18.
+0      uint64_t dev            8 bytes
+8      uint64_t inode          8 bytes
+16      unit64_t extid          8 bytes
+24     char [] name            zero terminated namelen bytes
+minimum length == 24.
 
 */
 
-#define MSG_FILE_RENAMED_MIN_SIZE 16
+#define MSG_FILE_RENAMED_MIN_SIZE 24
 
 /*
  * On the wire return values for oplock types.
@@ -1717,17 +1718,55 @@ minimum length == 18.
 
 enum smbd_capability {
     KERNEL_OPLOCK_CAPABILITY,
-    DMAPI_ACCESS_CAPABILITY
+    DMAPI_ACCESS_CAPABILITY,
+    LEASE_CAPABILITY,
+    KILL_CAPABILITY
+};
+
+/*
+ * Kernel oplocks capability flags.
+ */
+
+/* Level 2 oplocks are supported natively by kernel oplocks. */
+#define KOPLOCKS_LEVEL2_SUPPORTED              0x1
+
+/* The kernel notifies deferred openers when they can retry the open. */
+#define KOPLOCKS_DEFERRED_OPEN_NOTIFICATION    0x2
+
+/* The kernel notifies smbds when an oplock break times out. */
+#define KOPLOCKS_TIMEOUT_NOTIFICATION          0x4
+
+/* The kernel notifies smbds when an oplock is broken. */
+#define KOPLOCKS_OPLOCK_BROKEN_NOTIFICATION    0x8
+
+struct kernel_oplocks_ops;
+struct kernel_oplocks {
+       const struct kernel_oplocks_ops *ops;
+       uint32_t flags;
+       void *private_data;
+};
+
+enum level2_contention_type {
+       LEVEL2_CONTEND_ALLOC_SHRINK,
+       LEVEL2_CONTEND_ALLOC_GROW,
+       LEVEL2_CONTEND_SET_FILE_LEN,
+       LEVEL2_CONTEND_FILL_SPARSE,
+       LEVEL2_CONTEND_WRITE,
+       LEVEL2_CONTEND_WINDOWS_BRL,
+       LEVEL2_CONTEND_POSIX_BRL
 };
 
 /* if a kernel does support oplocks then a structure of the following
    typee is used to describe how to interact with the kernel */
-struct kernel_oplocks {
-       files_struct * (*receive_message)(fd_set *fds);
-       bool (*set_oplock)(files_struct *fsp, int oplock_type);
-       void (*release_oplock)(files_struct *fsp);
-       bool (*msg_waiting)(fd_set *fds);
-       int notification_fd;
+struct kernel_oplocks_ops {
+       bool (*set_oplock)(struct kernel_oplocks *ctx,
+                          files_struct *fsp, int oplock_type);
+       void (*release_oplock)(struct kernel_oplocks *ctx,
+                              files_struct *fsp, int oplock_type);
+       void (*contend_level2_oplocks_begin)(files_struct *fsp,
+                                            enum level2_contention_type type);
+       void (*contend_level2_oplocks_end)(files_struct *fsp,
+                                          enum level2_contention_type type);
 };
 
 #include "smb_macros.h"
@@ -1758,43 +1797,9 @@ struct node_status_extra {
        /* There really is more here ... */ 
 };
 
-struct pwd_info {
-       bool null_pwd;
-       bool cleartext;
-
-       fstring password;
-};
-
-/* For split krb5 SPNEGO blobs. */
-struct pending_auth_data {
-       struct pending_auth_data *prev, *next;
-       uint16 vuid; /* Tag for this entry. */
-       uint16 smbpid; /* Alternate tag for this entry. */
-       size_t needed_len;
-       DATA_BLOB partial_data;
-};
-
 typedef struct user_struct {
        struct user_struct *next, *prev;
        uint16 vuid; /* Tag for this entry. */
-       uid_t uid; /* uid of a validated user */
-       gid_t gid; /* gid of a validated user */
-
-       userdom_struct user;
-       const char *homedir;
-       const char *unix_homedir;
-       const char *logon_script;
-       
-       bool guest;
-
-       /* following groups stuff added by ih */
-       /* This groups info is needed for when we become_user() for this uid */
-       int n_groups;
-       gid_t *groups;
-
-       NT_USER_TOKEN *nt_user_token;
-
-       DATA_BLOB session_key;
 
        char *session_keystr; /* used by utmp and pam session code.  
                                 TDB key string */
@@ -1848,18 +1853,6 @@ struct unix_error_map {
 
 #define SAFE_NETBIOS_CHARS ". -_"
 
-/* generic iconv conversion structure */
-typedef struct _smb_iconv_t {
-       size_t (*direct)(void *cd, const char **inbuf, size_t *inbytesleft,
-                        char **outbuf, size_t *outbytesleft);
-       size_t (*pull)(void *cd, const char **inbuf, size_t *inbytesleft,
-                      char **outbuf, size_t *outbytesleft);
-       size_t (*push)(void *cd, const char **inbuf, size_t *inbytesleft,
-                      char **outbuf, size_t *outbytesleft);
-       void *cd_direct, *cd_pull, *cd_push;
-       char *from_name, *to_name;
-} *smb_iconv_t;
-
 /* The maximum length of a trust account password.
    Used when we randomly create it, 15 char passwords
    exceed NT4's max password length */
@@ -1872,6 +1865,7 @@ typedef struct _smb_iconv_t {
 #ifndef LDAP_PORT
 #define LDAP_PORT      389
 #endif
+#define LDAP_GC_PORT    3268
 
 /* used by the IP comparison function */
 struct ip_service {
@@ -1882,21 +1876,6 @@ struct ip_service {
 /* Special name type used to cause a _kerberos DNS lookup. */
 #define KDC_NAME_TYPE 0xDCDC
 
-/* 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)(const char *inbuf, struct smb_sign_info *si, bool must_be_ok);
-       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;
-       bool seen_valid; /* Have I ever seen a validly signed packet? */
-} smb_sign_info;
-
 struct ea_struct {
        uint8 flags;
        char *name;
@@ -1912,6 +1891,10 @@ struct ea_list {
 #define SAMBA_POSIX_INHERITANCE_EA_NAME "user.SAMBA_PAI"
 /* EA to use for DOS attributes */
 #define SAMBA_XATTR_DOS_ATTRIB "user.DOSATTRIB"
+/* Prefix for DosStreams in the vfs_streams_xattr module */
+#define SAMBA_XATTR_DOSSTREAM_PREFIX "user.DosStream."
+/* Prefix for xattrs storing streams. */
+#define SAMBA_XATTR_MARKER "user.SAMBA_STREAMS"
 
 #define UUID_SIZE 16
 
@@ -1942,4 +1925,47 @@ enum usershare_err {
 /* Different reasons for closing a file. */
 enum file_close_type {NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE};
 
+/* Used in SMB_FS_OBJECTID_INFORMATION requests.  Must be exactly 48 bytes. */
+#define SAMBA_EXTENDED_INFO_MAGIC 0x536d4261 /* "SmBa" */
+#define SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH 28
+struct smb_extended_info {
+       uint32 samba_magic;             /* Always SAMBA_EXTRA_INFO_MAGIC */
+       uint32 samba_version;           /* Major/Minor/Release/Revision */
+       uint32 samba_subversion;        /* Prerelease/RC/Vendor patch */
+       NTTIME samba_gitcommitdate;
+       char   samba_version_string[SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH];
+};
+
+/* time info */
+struct smb_file_time {
+       struct timespec mtime;
+       struct timespec atime;
+       struct timespec ctime;
+       struct timespec create_time;
+};
+
+/*
+ * unix_convert_flags
+ */
+#define UCF_SAVE_LCOMP                 0x00000001
+#define UCF_ALWAYS_ALLOW_WCARD_LCOMP   0x00000002
+#define UCF_COND_ALLOW_WCARD_LCOMP     0x00000004
+#define UCF_POSIX_PATHNAMES            0x00000008
+
+/*
+ * smb_filename
+ */
+struct smb_filename {
+       char *base_name;
+       char *stream_name;
+       char *original_lcomp;
+       SMB_STRUCT_STAT st;
+};
+
+/* struct for maintaining the child processes that get spawned from smbd */
+struct child_pid {
+       struct child_pid *prev, *next;
+       pid_t pid;
+};
+
 #endif /* _SMB_H */