r23163: Convert locking.tdb to dbwrap
[samba.git] / source3 / include / smb.h
index b167e4ee126b7099ee84d2ae751a6f4ffb85ca13..2375d47fdcd8514937bc9ff1f67a90c74e7e854a 100644 (file)
@@ -28,7 +28,7 @@
 #define _SMB_H
 
 /* logged when starting the various Samba daemons */
-#define COPYRIGHT_STARTUP_MESSAGE      "Copyright Andrew Tridgell and the Samba Team 1992-2006"
+#define COPYRIGHT_STARTUP_MESSAGE      "Copyright Andrew Tridgell and the Samba Team 1992-2007"
 
 
 #if defined(LARGE_SMB_OFF_T)
 #define Auto (2)
 #define Required (3)
 
-#ifndef _BOOL
-typedef int BOOL;
-#define _BOOL       /* So we don't typedef BOOL again in vfs.h */
-#endif
-
 #define SIZEOFWORD 2
 
 #ifndef DEF_CREATE_MASK
@@ -84,6 +79,7 @@ typedef int BOOL;
 #define WRITE_ERROR 4 /* This error code can go into the client smb_rw_error. */
 #define READ_BAD_SIG 5
 #define DO_NOT_DO_TDIS 6 /* cli_close_connection() check for this when smbfs wants to keep tree connected */
+#define READ_BAD_DECRYPT 7
 
 #define DIR_STRUCT_SIZE 43
 
@@ -138,13 +134,6 @@ typedef int BOOL;
 #define OPENX_FILE_CREATE_IF_NOT_EXIST 0x10
 #define OPENX_FILE_FAIL_IF_NOT_EXIST 0
 
-/* share types */
-#define STYPE_DISKTREE  0      /* Disk drive */
-#define STYPE_PRINTQ    1      /* Spooler queue */
-#define STYPE_DEVICE    2      /* Serial device */
-#define STYPE_IPC       3      /* Interprocess communication (IPC) */
-#define STYPE_HIDDEN    0x80000000 /* share is a hidden one (ends with $) */
-
 #include "doserr.h"
 
 typedef union unid_t {
@@ -179,6 +168,10 @@ typedef smb_ucs2_t wfstring[FSTRING_LEN];
 #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"
@@ -194,9 +187,10 @@ typedef smb_ucs2_t wfstring[FSTRING_LEN];
 #define PIPE_NETDFS   "\\PIPE\\netdfs"
 #define PIPE_ECHO     "\\PIPE\\rpcecho"
 #define PIPE_SHUTDOWN "\\PIPE\\initshutdown"
-#define PIPE_EPM      "\\PIPE\\epmapper"
+#define PIPE_EPMAPPER "\\PIPE\\epmapper"
 #define PIPE_SVCCTL   "\\PIPE\\svcctl"
 #define PIPE_EVENTLOG "\\PIPE\\eventlog"
+#define PIPE_UNIXINFO    "\\PIPE\\unixinfo"
 
 #define PIPE_NETLOGON_PLAIN "\\NETLOGON"
 
@@ -209,18 +203,17 @@ typedef smb_ucs2_t wfstring[FSTRING_LEN];
 #define PI_WINREG              6
 #define PI_SPOOLSS             7
 #define PI_NETDFS              8
-#define PI_ECHO                9
-#define PI_SHUTDOWN            10
+#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
+#define PI_UNIXINFO            13
+#define PI_NTSVCS              14
+#define PI_EPMAPPER            15
+#define PI_MAX_PIPES           16
 
 /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
-typedef struct nttime_info {
-       uint32 low;
-       uint32 high;
-} NTTIME;
+typedef uint64_t NTTIME;
 
 
 /* Allowable account control bits */
@@ -243,6 +236,8 @@ typedef struct nttime_info {
 #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
 
@@ -252,25 +247,11 @@ typedef struct nttime_info {
 
 #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 */
-};
-
 #define LOOKUP_NAME_ISOLATED 1 /* Look up unqualified names */
 #define LOOKUP_NAME_REMOTE   2  /* Ask others */
 #define LOOKUP_NAME_ALL (LOOKUP_NAME_ISOLATED|LOOKUP_NAME_REMOTE)
 
-#define LOOKUP_NAME_GROUP    4  /* This is a NASTY hack for valid users = @foo
+#define LOOKUP_NAME_GROUP    4  /* (unused) This is a NASTY hack for valid users = @foo
                                 * where foo also exists in as user. */
 
 /**
@@ -278,7 +259,7 @@ enum SID_NAME_USE {
  *
  * @sa http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/accctrl_38yn.asp
  **/
-typedef struct sid_info {
+typedef struct dom_sid {
        uint8  sid_rev_num;             /**< SID revision number */
        uint8  num_auths;               /**< Number of sub-authorities */
        uint8  id_auth[6];              /**< Identifier Authority */
@@ -291,6 +272,45 @@ typedef struct sid_info {
        uint32 sub_auths[MAXSUBAUTHS];  
 } DOM_SID;
 
+#define dom_sid2 dom_sid
+#define dom_sid28 dom_sid
+
+enum id_mapping {
+       ID_UNKNOWN = 0,
+       ID_MAPPED,
+       ID_UNMAPPED,
+       ID_EXPIRED
+};
+
+enum id_type {
+       ID_TYPE_NOT_SPECIFIED = 0,
+       ID_TYPE_UID,
+       ID_TYPE_GID
+};
+
+struct unixid {
+       uint32_t id;
+       enum id_type type;
+};
+
+struct id_map {
+       DOM_SID *sid;
+       struct unixid xid;
+       enum id_mapping status;
+};
+
+#include "librpc/ndr/misc.h"
+#include "librpc/ndr/security.h"
+#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/unixinfo.h"
+#include "librpc/gen_ndr/lsa.h"
+#include "librpc/gen_ndr/dfs.h"
+#include "librpc/gen_ndr/initshutdown.h"
+#include "librpc/gen_ndr/winreg.h"
+#include "librpc/gen_ndr/eventlog.h"
+#include "librpc/gen_ndr/srvsvc.h"
+#include "librpc/gen_ndr/wkssvc.h"
+
 struct lsa_dom_info {
        BOOL valid;
        DOM_SID sid;
@@ -301,7 +321,7 @@ struct lsa_dom_info {
 
 struct lsa_name_info {
        uint32 rid;
-       enum SID_NAME_USE type;
+       enum lsa_SidType type;
        const char *name;
        int dom_idx;
 };
@@ -328,6 +348,7 @@ extern const DOM_SID global_sid_Builtin_Server_Operators;
 extern const DOM_SID global_sid_Builtin_Print_Operators;
 extern const DOM_SID global_sid_Builtin_Backup_Operators;
 extern const DOM_SID global_sid_Builtin_Replicator;
+extern const DOM_SID global_sid_Builtin_PreWin2kAccess;
 extern const DOM_SID global_sid_Unix_Users;
 extern const DOM_SID global_sid_Unix_Groups;
 
@@ -401,11 +422,62 @@ struct fd_handle {
                                 * DELETE_ON_CLOSE is not stored in the share
                                 * mode database.
                                 */
+       unsigned long file_id;
 };
 
+struct event_context;
+struct fd_event;
 struct timed_event;
 struct idle_event;
 struct share_mode_entry;
+struct uuid;
+
+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
+     * that the end of the structure is always both 4-byte and 8-byte aligned.
+     */
+};
+
+/* the basic packet size, assuming no words or bytes */
+#define smb_size 39
+
+struct notify_change {
+       uint32_t action;
+       const char *name;
+};
+
+struct notify_mid_map;
+struct notify_entry;
+struct notify_event;
+struct notify_change_request;
+struct sys_notify_backend;
+struct sys_notify_context {
+       struct event_context *ev;
+       struct connection_struct *conn;
+       void *private_data;     /* For use by the system backend */
+};
+
+struct notify_change_buf {
+       /*
+        * If no requests are pending, changes are queued here. Simple array,
+        * we only append.
+        */
+
+       /*
+        * num_changes == -1 means that we have got a catch-all change, when
+        * asked we just return NT_STATUS_OK without specific changes.
+        */
+       int num_changes;
+       struct notify_change *changes;
+
+       /*
+        * If no changes are around requests are queued here. Using a linked
+        * list, because we have to append at the end and delete from the top.
+        */
+       struct notify_change_request *requests;
+};
 
 typedef struct files_struct {
        struct files_struct *next, *prev;
@@ -426,16 +498,17 @@ typedef struct files_struct {
        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;
-       time_t pending_modtime;
-       time_t last_write_time;
+       struct timespec pending_modtime;
+       struct timespec last_write_time;
        int oplock_type;
        int sent_oplock_break;
        struct timed_event *oplock_timeout;
+       struct lock_struct last_lock_failure;
+       int current_lock_count; /* Count the number of outstanding locks and pending locks. */
 
        struct share_mode_entry *pending_break_messages;
        int num_pending_break_messages;
 
-       unsigned long file_id;
        BOOL can_lock;
        BOOL can_read;
        BOOL can_write;
@@ -443,21 +516,29 @@ typedef struct files_struct {
        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 posix_open;
        char *fsp_name;
+
+       struct vfs_fsp_data *vfs_extension;
        FAKE_FILE_HANDLE *fake_file_handle;
+
+       struct notify_change_buf *notify;
 } files_struct;
 
 #include "ntquotas.h"
 #include "sysquotas.h"
 
 /* used to hold an arbitrary blob of data */
-typedef struct data_blob_ {
+typedef struct data_blob {
        uint8 *data;
        size_t length;
-       void (*free)(struct data_blob_ *data_blob);
+       void (*free)(struct data_blob *data_blob);
 } DATA_BLOB;
 
+extern const DATA_BLOB data_blob_null;
+
 /*
  * Structure used to keep directory state information around.
  * Used in NT change-notify code.
@@ -484,6 +565,36 @@ typedef struct {
        BOOL is_wild;
 } name_compare_entry;
 
+struct trans_state {
+       struct trans_state *next, *prev;
+       uint16 vuid;
+       uint16 mid;
+
+       uint32 max_param_return;
+       uint32 max_data_return;
+       uint32 max_setup_return;
+
+       uint8 cmd;              /* SMBtrans or SMBtrans2 */
+
+       fstring name;           /* for trans requests */
+       uint16 call;            /* for trans2 and nttrans requests */
+
+       BOOL close_on_completion;
+       BOOL one_way;
+
+       unsigned int setup_count;
+       uint16 *setup;
+
+       size_t received_data;
+       size_t received_param;
+
+       size_t total_param;
+       char *param;
+
+       size_t total_data;
+       char *data;
+};
+
 /* Include VFS stuff */
 
 #include "smb_acls.h"
@@ -499,11 +610,19 @@ struct dfree_cached_info {
 
 struct dptr_struct;
 
+struct share_params {
+       int service;
+};
+
+struct share_iterator {
+       int next_id;
+};
+
 typedef struct connection_struct {
        struct connection_struct *next, *prev;
-       TALLOC_CTX *mem_ctx;
+       TALLOC_CTX *mem_ctx; /* long-lived memory context for things hanging off this struct. */
        unsigned cnum; /* an index passed over the wire */
-       int service;
+       struct share_params *params;
        BOOL force_user;
        BOOL force_group;
        struct vuid_cache vuid_cache;
@@ -535,6 +654,7 @@ typedef struct connection_struct {
        NT_USER_TOKEN *nt_user_token;
        
        time_t lastused;
+       time_t lastused_count;
        BOOL used;
        int num_files_open;
        unsigned int num_smb_operations; /* Count of smb operations on this tree. */
@@ -546,8 +666,9 @@ typedef struct connection_struct {
        name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
        name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
        name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */       
-       name_compare_entry *aio_write_behind_list; /* Per-share list of files to use aio write behind on. */       
        struct dfree_cached_info *dfree_info;
+       struct trans_state *pending_trans;
+       struct notify_context *notify_ctx;
 } connection_struct;
 
 struct current_user {
@@ -620,9 +741,12 @@ struct pending_message_list {
        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 {
-       struct process_id pid;
+       struct server_id pid;
        uint16 op_mid;
        uint16 op_type;
        uint32 access_mask;             /* NTCreateX access bits (FILE_READ_DATA etc.) */
@@ -635,12 +759,14 @@ struct share_mode_entry {
        SMB_DEV_T dev;
        SMB_INO_T inode;
        unsigned long share_file_id;
+       uint32 uid;             /* uid of file opener. */
+       uint16 flags;           /* See SHARE_MODE_XX above. */
 };
 
 /* oplock break message definition - linearization of share_mode_entry.
 
 Offset  Data                   length.
-0      struct process_id pid   4
+0      struct server_id pid    4
 4      uint16 op_mid           2
 6      uint16 op_type          2
 8      uint32 access_mask      4
@@ -651,10 +777,12 @@ Offset  Data                      length.
 28     SMB_DEV_T dev           8 bytes.
 36     SMB_INO_T inode         8 bytes
 44     unsigned long file_id   4 bytes
-48
+48     uint32 uid              4 bytes
+52     uint16 flags            2 bytes
+54
 
 */
-#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 48
+#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 54
 
 struct share_mode_lock {
        const char *servicepath; /* canonicalized. */
@@ -665,11 +793,45 @@ struct share_mode_lock {
        struct share_mode_entry *share_modes;
        UNIX_USER_TOKEN *delete_token;
        BOOL delete_on_close;
-       BOOL initial_delete_on_close;
        BOOL fresh;
        BOOL modified;
+       struct db_record *record;
 };
 
+/*
+ * Internal structure of locking.tdb share mode db.
+ * Used by locking.c and libsmbsharemodes.c
+ */
+
+struct locking_data {
+       union {
+               struct {
+                       int num_share_mode_entries;
+                       BOOL delete_on_close;
+                       uint32 delete_token_size; /* Only valid if either of
+                                                    the two previous fields
+                                                    are True. */
+               } s;
+               struct share_mode_entry dummy; /* Needed for alignment. */
+       } u;
+       /* The following four entries are implicit
+          struct share_mode_entry modes[num_share_mode_entries];
+          char unix_token[delete_token_size] (divisible by 4).
+          char share_name[];
+          char file_name[];
+        */
+};
+
+/* Used to store pipe open records for NetFileEnum() */
+
+struct pipe_open_rec {
+       struct server_id pid;
+       uid_t uid;
+       int pnum;
+       fstring name;
+};
+
+
 #define NT_HASH_LEN 16
 #define LM_HASH_LEN 16
 
@@ -677,6 +839,7 @@ struct share_mode_lock {
 #define PW_HISTORY_SALT_LEN 16
 #define SALTED_MD5_HASH_LEN 16
 #define PW_HISTORY_ENTRY_LEN (PW_HISTORY_SALT_LEN+SALTED_MD5_HASH_LEN)
+#define MAX_PW_HISTORY_LEN 24
 
 /*
  * Flags for account policy.
@@ -709,18 +872,18 @@ struct share_mode_lock {
 
 /* key and data in the connections database - used in smbstatus and smbd */
 struct connections_key {
-       struct process_id pid;
+       struct server_id pid;
        int cnum;
        fstring name;
 };
 
 struct connections_data {
        int magic;
-       struct process_id pid;
+       struct server_id pid;
        int cnum;
        uid_t uid;
        gid_t gid;
-       char name[24];
+       char servicename[FSTRING_LEN];
        char addr[24];
        char machine[FSTRING_LEN];
        time_t start;
@@ -738,22 +901,11 @@ typedef enum {
        P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
 } parm_class;
 
-/* passed to br lock code */
-enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_LOCK};
-
 struct enum_list {
        int value;
        const char *name;
 };
 
-#define BRLOCK_FN_CAST() \
-       void (*)(SMB_DEV_T dev, SMB_INO_T ino, struct process_id pid, \
-                                enum brl_type lock_type, \
-                                br_off start, br_off size)
-#define BRLOCK_FN(fn) \
-       void (*fn)(SMB_DEV_T dev, SMB_INO_T ino, struct process_id pid, \
-                                enum brl_type lock_type, \
-                                br_off start, br_off size)
 struct parm_struct {
        const char *label;
        parm_type type;
@@ -771,11 +923,6 @@ struct parm_struct {
        } def;
 };
 
-struct bitmap {
-       uint32 *b;
-       unsigned int n;
-};
-
 /* The following flags are used in SWAT */
 #define FLAG_BASIC     0x0001 /* Display only in BASIC view */
 #define FLAG_SHARE     0x0002 /* file sharing options */
@@ -788,13 +935,10 @@ struct bitmap {
 #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
-#endif /* LOCKING_VERSION */
-
-
-/* the basic packet size, assuming no words or bytes */
-#define smb_size 39
+struct bitmap {
+       uint32 *b;
+       unsigned int n;
+};
 
 /* offsets into message for common items */
 #define smb_com 8
@@ -857,7 +1001,7 @@ struct bitmap {
 #define SMBunlock     0x0D   /* unlock byte range */
 #define SMBctemp      0x0E   /* create temporary file */
 #define SMBmknew      0x0F   /* make new file */
-#define SMBchkpth     0x10   /* check directory path */
+#define SMBcheckpath  0x10   /* check directory path */
 #define SMBexit       0x11   /* process exit */
 #define SMBlseek      0x12   /* seek */
 #define SMBtcon       0x70   /* tree connect */
@@ -1103,17 +1247,24 @@ 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)
 
+/* This maps to 0x120089 */
 #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_EXECUTE (STANDARD_RIGHTS_EXECUTE_ACCESS|\
                                                                FILE_EXECUTE|SYNCHRONIZE_ACCESS)
 
+/* Share specific rights. */
+#define SHARE_ALL_ACCESS      FILE_GENERIC_ALL
+#define SHARE_READ_ONLY       (FILE_GENERIC_READ|FILE_EXECUTE)
+
 /* Mapping of access rights to UNIX perms. */
 #define UNIX_ACCESS_RWX                FILE_GENERIC_ALL
 #define UNIX_ACCESS_R          FILE_GENERIC_READ
@@ -1246,7 +1397,7 @@ struct bitmap {
 #define FILE_READ_ONLY_VOLUME           0x00080000
 
 /* ChangeNotify flags. */
-#define FILE_NOTIFY_CHANGE_FILE        0x001
+#define FILE_NOTIFY_CHANGE_FILE_NAME   0x001
 #define FILE_NOTIFY_CHANGE_DIR_NAME    0x002
 #define FILE_NOTIFY_CHANGE_ATTRIBUTES  0x004
 #define FILE_NOTIFY_CHANGE_SIZE        0x008
@@ -1255,7 +1406,23 @@ struct bitmap {
 #define FILE_NOTIFY_CHANGE_CREATION    0x040
 #define FILE_NOTIFY_CHANGE_EA          0x080
 #define FILE_NOTIFY_CHANGE_SECURITY    0x100
-#define FILE_NOTIFY_CHANGE_FILE_NAME   0x200
+#define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
+#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
+#define FILE_NOTIFY_CHANGE_STREAM_WRITE        0x00000800
+
+#define FILE_NOTIFY_CHANGE_NAME \
+       (FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME)
+
+/* change notify action results */
+#define NOTIFY_ACTION_ADDED 1
+#define NOTIFY_ACTION_REMOVED 2
+#define NOTIFY_ACTION_MODIFIED 3
+#define NOTIFY_ACTION_OLD_NAME 4
+#define NOTIFY_ACTION_NEW_NAME 5
+#define NOTIFY_ACTION_ADDED_STREAM 6
+#define NOTIFY_ACTION_REMOVED_STREAM 7
+#define NOTIFY_ACTION_MODIFIED_STREAM 8
+
 
 /* where to find the base of the SMB packet proper */
 #define smb_base(buf) (((char *)(buf))+4)
@@ -1284,36 +1451,6 @@ char *strdup(char *s);
 #define SELECT_CAST
 #endif
 
-/* these are used in NetServerEnum to choose what to receive */
-#define SV_TYPE_WORKSTATION         0x00000001
-#define SV_TYPE_SERVER              0x00000002
-#define SV_TYPE_SQLSERVER           0x00000004
-#define SV_TYPE_DOMAIN_CTRL         0x00000008
-#define SV_TYPE_DOMAIN_BAKCTRL      0x00000010
-#define SV_TYPE_TIME_SOURCE         0x00000020
-#define SV_TYPE_AFP                 0x00000040
-#define SV_TYPE_NOVELL              0x00000080
-#define SV_TYPE_DOMAIN_MEMBER       0x00000100
-#define SV_TYPE_PRINTQ_SERVER       0x00000200
-#define SV_TYPE_DIALIN_SERVER       0x00000400
-#define SV_TYPE_SERVER_UNIX         0x00000800
-#define SV_TYPE_NT                  0x00001000
-#define SV_TYPE_WFW                 0x00002000
-#define SV_TYPE_SERVER_MFPN         0x00004000
-#define SV_TYPE_SERVER_NT           0x00008000
-#define SV_TYPE_POTENTIAL_BROWSER   0x00010000
-#define SV_TYPE_BACKUP_BROWSER      0x00020000
-#define SV_TYPE_MASTER_BROWSER      0x00040000
-#define SV_TYPE_DOMAIN_MASTER       0x00080000
-#define SV_TYPE_SERVER_OSF          0x00100000
-#define SV_TYPE_SERVER_VMS          0x00200000
-#define SV_TYPE_WIN95_PLUS          0x00400000
-#define SV_TYPE_DFS_SERVER         0x00800000
-#define SV_TYPE_ALTERNATE_XPORT     0x20000000  
-#define SV_TYPE_LOCAL_LIST_ONLY     0x40000000  
-#define SV_TYPE_DOMAIN_ENUM         0x80000000
-#define SV_TYPE_ALL                 0xFFFFFFFF  
-
 /* This was set by JHT in liaison with Jeremy Allison early 1997
  * History:
  * Version 4.0 - never made public
@@ -1345,6 +1482,7 @@ char *strdup(char *s);
 #define FLAGS2_LONG_PATH_COMPONENTS    0x0001
 #define FLAGS2_EXTENDED_ATTRIBUTES     0x0002
 #define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
+#define FLAGS2_UNKNOWN_BIT4            0x0010
 #define FLAGS2_IS_LONG_NAME            0x0040
 #define FLAGS2_EXTENDED_SECURITY       0x0800 
 #define FLAGS2_DFS_PATHNAMES           0x1000
@@ -1354,6 +1492,9 @@ char *strdup(char *s);
 
 #define FLAGS2_WIN2K_SIGNATURE         0xC852 /* Hack alert ! For now... JRA. */
 
+/* TCONX Flag (smb_vwv2). */
+#define TCONX_FLAG_EXTENDED_RESPONSE   0x8
+
 /* Capabilities.  see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
 
 #define CAP_RAW_MODE         0x0001
@@ -1392,7 +1533,7 @@ enum server_types {
 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
                     PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ,
                     PRINT_CUPS,PRINT_LPRNT,PRINT_LPROS2,PRINT_IPRINT
-#ifdef DEVELOPER
+#if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
 ,PRINT_TEST,PRINT_VLP
 #endif /* DEVELOPER */
 };
@@ -1408,11 +1549,14 @@ 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_SAMBA, RA_CIFSFS};
+                       RA_WIN2K, RA_WINXP, RA_WIN2K3, RA_VISTA,
+                       RA_SAMBA, RA_CIFSFS};
 
 /* case handling */
 enum case_handling {CASE_LOWER,CASE_UPPER};
 
+/* ACL compatibility */
+enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
 /*
  * Global value meaing that the smb_uid field should be
  * ingored (in share level security and protocol level == CORE)
@@ -1456,18 +1600,25 @@ extern int chain_size;
 
 /*
  * Bits we test with.
+ * Note these must fit into 16-bits.
  */
-                                                                                                                              
-#define NO_OPLOCK 0
-#define EXCLUSIVE_OPLOCK 1
-#define BATCH_OPLOCK 2
-#define LEVEL_II_OPLOCK 4
-#define INTERNAL_OPEN_ONLY 8
-#define FAKE_LEVEL_II_OPLOCK 16        /* Client requested no_oplock, but we have to
+
+#define NO_OPLOCK                      0x0
+#define EXCLUSIVE_OPLOCK               0x1
+#define BATCH_OPLOCK                   0x2
+#define LEVEL_II_OPLOCK                0x4
+
+/* The following are Samba-private. */
+#define INTERNAL_OPEN_ONLY             0x8
+#define FAKE_LEVEL_II_OPLOCK           0x10    /* Client requested no_oplock, but we have to
                                 * inform potential level2 holders on
                                 * write. */
-#define DEFERRED_OPEN_ENTRY 32
-#define UNUSED_SHARE_MODE_ENTRY 64
+#define DEFERRED_OPEN_ENTRY            0x20
+#define UNUSED_SHARE_MODE_ENTRY        0x40
+#define FORCE_OPLOCK_BREAK_TO_NONE     0x80
+
+/* None of the following should ever appear in fsp->oplock_request. */
+#define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY|DEFERRED_OPEN_ENTRY|UNUSED_SHARE_MODE_ENTRY|FORCE_OPLOCK_BREAK_TO_NONE)
 
 #define EXCLUSIVE_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)EXCLUSIVE_OPLOCK|(unsigned int)BATCH_OPLOCK))
 #define BATCH_OPLOCK_TYPE(lck) ((lck) & (unsigned int)BATCH_OPLOCK)
@@ -1536,7 +1687,10 @@ minimum length == 18.
  * Capabilities abstracted for different systems.
  */
 
-#define KERNEL_OPLOCK_CAPABILITY 0x1
+enum smbd_capability {
+    KERNEL_OPLOCK_CAPABILITY,
+    DMAPI_ACCESS_CAPABILITY
+};
 
 /* if a kernel does support oplocks then a structure of the following
    typee is used to describe how to interact with the kernel */
@@ -1548,16 +1702,6 @@ struct kernel_oplocks {
        int notification_fd;
 };
 
-
-/* this structure defines the functions for doing change notify in
-   various implementations */
-struct cnotify_fns {
-       void * (*register_notify)(connection_struct *conn, char *path, uint32 flags);
-       BOOL (*check_notify)(connection_struct *conn, uint16 vuid, char *path, uint32 flags, void *data, time_t t);
-       void (*remove_notify)(void *data);
-       int select_time;
-};
-
 #include "smb_macros.h"
 
 #define MAX_NETBIOSNAME_LEN 16
@@ -1593,6 +1737,15 @@ struct pwd_info {
        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. */
@@ -1600,9 +1753,9 @@ typedef struct user_struct {
        gid_t gid; /* gid of a validated user */
 
        userdom_struct user;
-       char *homedir;
-       char *unix_homedir;
-       char *logon_script;
+       const char *homedir;
+       const char *unix_homedir;
+       const char *logon_script;
        
        BOOL guest;
 
@@ -1622,7 +1775,6 @@ typedef struct user_struct {
        struct auth_serversupplied_info *server_info;
 
        struct auth_ntlmssp_state *auth_ntlmssp_state;
-
 } user_struct;
 
 struct unix_error_map {
@@ -1699,6 +1851,9 @@ struct ip_service {
        unsigned port;
 };
 
+/* 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 {
@@ -1730,13 +1885,6 @@ struct ea_list {
 /* EA to use for DOS attributes */
 #define SAMBA_XATTR_DOS_ATTRIB "user.DOSATTRIB"
 
-struct uuid {
-       uint32 time_low;
-       uint16 time_mid;
-       uint16 time_hi_and_version;
-       uint8  clock_seq[2];
-       uint8  node[6];
-};
 #define UUID_SIZE 16
 
 #define UUID_FLAT_SIZE 16
@@ -1766,4 +1914,6 @@ enum usershare_err {
 /* Different reasons for closing a file. */
 enum file_close_type {NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE};
 
+#include "librpc/gen_ndr/epmapper.h"
+
 #endif /* _SMB_H */