r4387: added a TODO about the NTCREATEX_FLAGS_OPEN_DIRECTORY flag - it seems to open
[samba.git] / source4 / include / smb.h
index d0a8e43e813640ba5f221352f56b714b3d825d54..078e9b39c896a092fbf55bc07d84c11a4b80035b 100644 (file)
 #define SMB_PORT2 139
 #define SMB_PORTS "445 139"
 
-#define False (0)
-#define True (1)
-#define Auto (2)
-
-#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
-#define DEF_CREATE_MASK (0755)
-#endif
-
-/* string manipulation flags - see clistr.c and srvstr.c */
-#define STR_TERMINATE 1
-#define STR_UPPER 2
-#define STR_ASCII 4
-#define STR_UNICODE 8
-#define STR_NOALIGN 16
-#define STR_NO_RANGE_CHECK 32
-#define STR_LEN8BIT 64
-#define STR_TERMINATE_ASCII 128 /* only terminate if ascii */
-#define STR_LEN_NOTERM 256 /* the length field is the unterminated length */
-
-/* Debugging stuff */
-#include "debug.h"
-
-/* types of socket errors */
-enum socket_error {SOCKET_READ_TIMEOUT,
-                  SOCKET_READ_EOF,
-                  SOCKET_READ_ERROR,
-                  SOCKET_WRITE_ERROR,
-                  SOCKET_READ_BAD_SIG};
+enum smb_signing_state {SMB_SIGNING_OFF, SMB_SIGNING_SUPPORTED, 
+                       SMB_SIGNING_REQUIRED, SMB_SIGNING_AUTO};
 
 /* deny modes */
 #define DENY_DOS 0
@@ -153,7 +120,8 @@ enum socket_error {SOCKET_READ_TIMEOUT,
 /* ntcreatex flags field. */
 #define NTCREATEX_FLAGS_REQUEST_OPLOCK       0x02
 #define NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK 0x04
-#define NTCREATEX_FLAGS_OPEN_DIRECTORY       0x08
+#define NTCREATEX_FLAGS_OPEN_DIRECTORY       0x08 /* TODO: opens parent? we need
+                                                    a test suite for this */
 #define NTCREATEX_FLAGS_EXTENDED             0x10
 
 /* the ntcreatex access_mask field 
@@ -185,17 +153,24 @@ enum socket_error {SOCKET_READ_TIMEOUT,
 #define NTCREATEX_DISP_OVERWRITE_IF 5  /* if exists overwrite, else create */
 
 /* ntcreatex create_options field */
-#define NTCREATEX_OPTIONS_DIRECTORY            0x0001
-#define NTCREATEX_OPTIONS_WRITE_THROUGH        0x0002
-#define NTCREATEX_OPTIONS_SEQUENTIAL_ONLY      0x0004
-#define NTCREATEX_OPTIONS_SYNC_ALERT          0x0010
-#define NTCREATEX_OPTIONS_ASYNC_ALERT         0x0020
-#define NTCREATEX_OPTIONS_NON_DIRECTORY_FILE   0x0040
-#define NTCREATEX_OPTIONS_NO_EA_KNOWLEDGE      0x0200
-#define NTCREATEX_OPTIONS_EIGHT_DOT_THREE_ONLY 0x0400
-#define NTCREATEX_OPTIONS_RANDOM_ACCESS        0x0800
-#define NTCREATEX_OPTIONS_DELETE_ON_CLOSE      0x1000
-#define NTCREATEX_OPTIONS_OPEN_BY_FILE_ID      0x2000
+#define NTCREATEX_OPTIONS_DIRECTORY                0x0001
+#define NTCREATEX_OPTIONS_WRITE_THROUGH            0x0002
+#define NTCREATEX_OPTIONS_SEQUENTIAL_ONLY          0x0004
+#define NTCREATEX_OPTIONS_SYNC_ALERT              0x0010
+#define NTCREATEX_OPTIONS_ASYNC_ALERT             0x0020
+#define NTCREATEX_OPTIONS_NON_DIRECTORY_FILE       0x0040
+#define NTCREATEX_OPTIONS_NO_EA_KNOWLEDGE          0x0200
+#define NTCREATEX_OPTIONS_EIGHT_DOT_THREE_ONLY     0x0400
+#define NTCREATEX_OPTIONS_RANDOM_ACCESS            0x0800
+#define NTCREATEX_OPTIONS_DELETE_ON_CLOSE          0x1000
+#define NTCREATEX_OPTIONS_OPEN_BY_FILE_ID          0x2000
+
+/* create options these bits are for private use by backends, they are
+   not valid on the wire */
+#define NTCREATEX_OPTIONS_PRIVATE_MASK         0xFF000000
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS     0x01000000
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB     0x02000000
+
 
 /* ntcreatex impersonation field */
 #define NTCREATEX_IMPERSONATION_ANONYMOUS      0
@@ -216,546 +191,27 @@ enum socket_error {SOCKET_READ_TIMEOUT,
 #define NTCREATEX_ACTION_UNKNOWN 5
 
 
-
-/* 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"
-
-/* this is a trade with jeremy - I agreed to use uint_t instead of
- * bare unsigned if he agreed to not use non-braced if statements
- * (13/4/2003 - train to gottenginen) */
-#ifndef IRIX
-typedef unsigned int uint_t;
-#endif
-
-/*
- * SMB UCS2 (16-bit unicode) internal type.
- */
-
-typedef uint16 smb_ucs2_t;
-
-/* ucs2 string types. */
-typedef smb_ucs2_t wpstring[PSTRING_LEN];
-typedef smb_ucs2_t wfstring[FSTRING_LEN];
-
-/* This error code can go into the client smb_rw_error. */
-#define WRITE_ERROR 4
-
-#ifdef WORDS_BIGENDIAN
-#define UCS2_SHIFT 8
-#else
-#define UCS2_SHIFT 0
-#endif
-
-/* turn a 7 bit character into a ucs2 character */
-#define UCS2_CHAR(c) ((c) << UCS2_SHIFT)
-
-/* 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 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_MAX_PIPES           9
-
-/* Allowable account control bits */
-#define ACB_DISABLED   0x0001  /* 1 = User account disabled */
-#define ACB_HOMDIRREQ  0x0002  /* 1 = Home directory required */
-#define ACB_PWNOTREQ   0x0004  /* 1 = User password not required */
-#define ACB_TEMPDUP    0x0008  /* 1 = Temporary duplicate account */
-#define ACB_NORMAL     0x0010  /* 1 = Normal user account */
-#define ACB_MNS        0x0020  /* 1 = MNS logon user account */
-#define ACB_DOMTRUST   0x0040  /* 1 = Interdomain trust account */
-#define ACB_WSTRUST    0x0080  /* 1 = Workstation trust account */
-#define ACB_SVRTRUST   0x0100  /* 1 = Server trust account */
-#define ACB_PWNOEXP    0x0200  /* 1 = User password does not expire */
-#define ACB_AUTOLOCK   0x0400  /* 1 = Account auto locked */
-#define MAX_HOURS_LEN 32
-
-#ifndef MAXSUBAUTHS
-#define MAXSUBAUTHS 15 /* max sub authorities in a SID */
-#endif
-
-/* SID Types */
-enum SID_NAME_USE
-{
-       SID_NAME_USE_NONE = 0,/* NOTUSED */
-       SID_NAME_USER    = 1, /* user */
-       SID_NAME_DOM_GRP = 2, /* domain group */
-       SID_NAME_DOMAIN  = 3, /* domain: don't know what this is */
-       SID_NAME_ALIAS   = 4, /* local group */
-       SID_NAME_WKN_GRP = 5, /* well-known group */
-       SID_NAME_DELETED = 6, /* deleted account: needed for c2 rating */
-       SID_NAME_INVALID = 7, /* invalid account */
-       SID_NAME_UNKNOWN = 8  /* oops. */
+struct security_token {
+       struct dom_sid *user_sid;
+       struct dom_sid *group_sid;
+       uint32_t num_sids;
+       struct dom_sid **sids;
+       uint64_t privilege_mask;
 };
 
-/**
- * @brief Security Identifier
- *
- * @sa http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/accctrl_38yn.asp
- **/
-typedef struct sid_info
-{
-  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;
-
-/*
- * The complete list of SIDS belonging to this user.
- * Created when a vuid is registered.
- * The definition of the user_sids array is as follows :
- *
- * token->user_sids[0] = primary user SID.
- * token->user_sids[1] = primary group SID.
- * token->user_sids[2..num_sids] = supplementary group SIDS.
- */
-
-#define PRIMARY_USER_SID_INDEX 0
-#define PRIMARY_GROUP_SID_INDEX 1
-
-typedef struct _nt_user_token {
-       size_t num_sids;
-       DOM_SID *user_sids;
-} NT_USER_TOKEN;
-
-/*** query a local group, get a list of these: shows who is in that group ***/
-
-/* local group member info */
-typedef struct local_grp_member_info
-{
-       DOM_SID sid    ; /* matches with name */
-       uint8   sid_use; /* usr=1 grp=2 dom=3 alias=4 wkng=5 del=6 inv=7 unk=8 */
-       fstring name   ; /* matches with sid: must be of the form "DOMAIN\account" */
-
-} LOCAL_GRP_MEMBER;
-
-/* enumerate these to get list of local groups */
-
-/* local group info */
-typedef struct local_grp_info
-{
-       fstring name;
-       fstring comment;
-
-} LOCAL_GRP;
-
-/*** enumerate these to get list of domain groups ***/
-
-/* domain group member info */
-typedef struct domain_grp_info
-{
-       fstring name;
-       fstring comment;
-       uint32  rid; /* group rid */
-       uint8   attr; /* attributes forced to be set to 0x7: SE_GROUP_xxx */
-
-} DOMAIN_GRP;
-
-/*** query a domain group, get a list of these: shows who is in that group ***/
-
-/* domain group info */
-typedef struct domain_grp_member_info
-{
-       fstring name;
-       uint8   attr; /* attributes forced to be set to 0x7: SE_GROUP_xxx */
-
-} DOMAIN_GRP_MEMBER;
-
-/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
-typedef struct time_info
-{
-  uint32 time;
-} UTIME;
-
 /* used to hold an arbitrary blob of data */
 typedef struct data_blob {
-       uint8 *data;
+       uint8_t *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.
- */
-
-typedef struct
-{
-  time_t modify_time;
-  time_t status_time;
-} dir_status_struct;
-
-struct vuid_cache {
-  unsigned int entries;
-  uint16 list[VUID_CACHE_SIZE];
-};
-
-/* Include VFS stuff */
-
-#include "smb_acls.h"
-#include "enums.h"
-#include "events.h"
-#include "context.h"
-#include "smb_interfaces.h"
-#include "dcerpc_interfaces.h"
-#include "ntvfs.h"
-
-typedef struct smb_vfs_handle_struct
-{
-    void *data;
-    /* Handle on dlopen() call */
-    void *handle;
-    struct smb_vfs_handle_struct  *next, *prev;
-    
-} smb_vfs_handle_struct;
-
-struct tcon_context {
-       struct tcon_context *next, *prev;
-
-       /* the server context that this was created on */
-       struct server_context *smb;
-
-       /* a talloc context for all data in this structure */
-       TALLOC_CTX *mem_ctx;
-
-       /* a private structure used by the active NTVFS backend */
-       void *ntvfs_private;
-
-       uint16 cnum; /* an index passed over the wire (the TID) */
-       int service;
-       enum ntvfs_type type;
-       BOOL read_only;
-       BOOL admin_user;
-
-       /* the NTVFS operations - see source/ntvfs/ and include/ntvfs.h for details */
-       struct ntvfs_ops *ntvfs_ops;
-
-       /* the reported filesystem type */
-       char *fs_type;
-
-       /* the reported device type */
-       char *dev_type;
-};
-
-struct current_user
-{
-       struct tcon_context *conn;
-       uint16 vuid;
-       uid_t uid;
-       gid_t gid;
-       int ngroups;
-       gid_t *groups;
-       NT_USER_TOKEN *nt_user_token;
-};
-
-/* Defines for the sent_oplock_break field above. */
-#define NO_BREAK_SENT 0
-#define EXCLUSIVE_BREAK_SENT 1
-#define LEVEL_II_BREAK_SENT 2
-
-typedef struct userdom_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;
-
-/* used for server information: client, nameserv and ipc */
-struct server_info_struct
-{
-  fstring name;
-  uint32 type;
-  fstring comment;
-  fstring domain; /* used ONLY in ipc.c NOT namework.c */
-  BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
-};
-
-
-/* used for network interfaces */
-struct interface
-{
-       struct interface *next, *prev;
-       struct in_addr ip;
-       struct in_addr bcast;
-       struct in_addr nmask;
-};
-
-/* struct returned by get_share_modes */
-typedef struct {
-       pid_t pid;
-       uint16 op_port;
-       uint16 op_type;
-       int share_mode;
-       uint32 desired_access;
-       struct timeval time;
-       SMB_DEV_T dev;
-       SMB_INO_T inode;
-       unsigned long share_file_id;
-} share_mode_entry;
-
-
-#define SHAREMODE_FN_CAST() \
-       void (*)(share_mode_entry *, char*)
-
-#define SHAREMODE_FN(fn) \
-       void (*fn)(share_mode_entry *, char*)
-
-#define NT_HASH_LEN 16
-#define LM_HASH_LEN 16
-
-/*
- * bit flags representing initialized fields in SAM_ACCOUNT
- */
-enum pdb_elements {
-       PDB_UNINIT,
-       PDB_UID,
-       PDB_GID,
-       PDB_SMBHOME,
-       PDB_PROFILE,
-       PDB_DRIVE,
-       PDB_LOGONSCRIPT,
-       PDB_LOGONTIME,
-       PDB_LOGOFFTIME,
-       PDB_KICKOFFTIME,
-       PDB_CANCHANGETIME,
-       PDB_MUSTCHANGETIME,
-       PDB_PLAINTEXT_PW,
-       PDB_USERNAME,
-       PDB_FULLNAME,
-       PDB_DOMAIN,
-       PDB_NTUSERNAME,
-       PDB_HOURSLEN,
-       PDB_LOGONDIVS,
-       PDB_USERSID,
-       PDB_GROUPSID,
-       PDB_ACCTCTRL,
-       PDB_PASSLASTSET,
-       PDB_UNIXHOMEDIR,
-       PDB_ACCTDESC,
-       PDB_WORKSTATIONS,
-       PDB_UNKNOWNSTR,
-       PDB_MUNGEDDIAL,
-       PDB_HOURS,
-       PDB_UNKNOWN3,
-       PDB_UNKNOWN5,
-       PDB_UNKNOWN6,
-       PDB_LMPASSWD,
-       PDB_NTPASSWD,
-
-       /* this must be the last element */
-       PDB_COUNT,
-};
-
-enum pdb_value_state {
-       PDB_DEFAULT=0,
-       PDB_SET,
-       PDB_CHANGED
-};
-
-#define IS_SAM_UNIX_USER(x) \
-       (( pdb_get_init_flags(x, PDB_UID) != PDB_DEFAULT ) \
-        && ( pdb_get_init_flags(x,PDB_GID) != PDB_DEFAULT ))
-
-#define IS_SAM_SET(x, flag)    (pdb_get_init_flags(x, flag) == PDB_SET)
-#define IS_SAM_CHANGED(x, flag)        (pdb_get_init_flags(x, flag) == PDB_CHANGED)
-#define IS_SAM_DEFAULT(x, flag)        (pdb_get_init_flags(x, flag) == PDB_DEFAULT)
-               
-typedef struct sam_passwd
-{
-       TALLOC_CTX *mem_ctx;
-       
-       void (*free_fn)(struct sam_passwd **);
-
-       struct pdb_methods *methods;
-
-       struct user_data {
-               /* initiailization flags */
-               struct bitmap *change_flags;
-               struct bitmap *set_flags;
-
-               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 */
-               
-               const char * username;     /* UNIX username string */
-               const char * domain;       /* Windows Domain name */
-               const char * nt_username;  /* Windows username string */
-               const char * full_name;    /* user's full name string */
-               const char * unix_home_dir;     /* UNIX home directory string */
-               const char * home_dir;     /* home directory string */
-               const char * dir_drive;    /* home directory drive string */
-               const char * logon_script; /* logon script string */
-               const char * profile_path; /* profile path string */
-               const char * acct_desc  ;  /* user description string */
-               const char * workstations; /* login from workstations string */
-               const char * unknown_str ; /* don't know what this is, yet. */
-               const char * munged_dial ; /* munged path name and dial-back tel number */
-               
-               uid_t uid;          /* this is a unix uid_t */
-               gid_t gid;          /* this is a unix gid_t */
-               DOM_SID user_sid;    /* Primary User SID */
-               DOM_SID group_sid;   /* Primary Group SID */
-               
-               DATA_BLOB lm_pw; /* .data is Null if no password */
-               DATA_BLOB nt_pw; /* .data is Null if no password */
-               char* plaintext_pw; /* is Null if not available */
-               
-               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 */
-       } private;
-
-       /* Lets see if the remaining code can get the hint that you
-          are meant to use the pdb_...() functions. */
-       
-} SAM_ACCOUNT;
+/* 64 bit time (100 nanosec) 1601 - cifs6.txt, section 3.5, page 30 */
+typedef uint64_t NTTIME;
+/* 64 bit time (1 sec) 1601 - in the NDR blob but mapped to NTTIME  */
+#define NTTIME_1sec NTTIME
 
-/*
- * 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
-
-
-/*
- * Flags for local user manipulation.
- */
-
-#define LOCAL_ADD_USER 0x1
-#define LOCAL_DELETE_USER 0x2
-#define LOCAL_DISABLE_USER 0x4
-#define LOCAL_ENABLE_USER 0x8
-#define LOCAL_TRUST_ACCOUNT 0x10
-#define LOCAL_SET_NO_PASSWORD 0x20
-#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 {
-       pid_t pid;
-       int cnum;
-       fstring name;
-};
-
-struct connections_data {
-       int magic;
-       pid_t pid;
-       int cnum;
-       uid_t uid;
-       gid_t gid;
-       char name[24];
-       char addr[24];
-       char machine[FSTRING_LEN];
-       time_t start;
-       uint32 bcast_msg_flags;
-};
-
-/* the following are used by loadparm for option lists */
-typedef enum
-{
-  P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,P_LIST,
-  P_STRING,P_USTRING,P_ENUM,P_SEP
-} parm_type;
-
-typedef enum
-{
-  P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
-} parm_class;
-
-struct enum_list {
-       int value;
-       const char *name;
-};
-
-struct parm_struct
-{
-       const char *label;
-       parm_type type;
-       parm_class class;
-       void *ptr;
-       BOOL (*special)(const char *, char **);
-       const struct enum_list *enum_list;
-       unsigned flags;
-       union {
-               BOOL bvalue;
-               int ivalue;
-               char *svalue;
-               char cvalue;
-               char **lvalue;
-       } def;
-};
-
-struct bitmap {
-       uint32 *b;
-       unsigned int n;
-};
-
-#define FLAG_BASIC     0x0001 /* fundamental options */
-#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 the wizard will operate on */
-#define FLAG_DEVELOPER         0x0040 /* Parameters that the wizard will operate on */
-#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_CMDLINE    0x8000 /* this option was set from the command line */
-
-#ifndef LOCKING_VERSION
-#define LOCKING_VERSION 4
-#endif /* LOCKING_VERSION */
+/* 8 byte aligned 'hyper' type from MS IDL */
+typedef uint64_t HYPER_T;
 
 
 /* the basic packet size, assuming no words or bytes. Does not include the NBT header */
@@ -1027,56 +483,6 @@ struct bitmap {
    otherwise NT will not honour the announce packets */
 #define MAX_SERVER_STRING_LENGTH 48
 
-
-#define SMB_SUCCESS 0  /* The request was successful. */
-
-#ifdef WITH_DFS
-void dfs_unlogin(void);
-extern int dcelogin_atmost_once;
-#endif
-
-#ifdef NOSTRDUP
-char *strdup(char *s);
-#endif
-
-#ifndef SIGNAL_CAST
-#define SIGNAL_CAST (RETSIGTYPE (*)(int))
-#endif
-
-#ifndef SELECT_CAST
-#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
@@ -1104,40 +510,37 @@ char *strdup(char *s);
 #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_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_READ_PERMIT_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 */
-
-#define CAP_RAW_MODE         0x0001
-#define CAP_MPX_MODE         0x0002
-#define CAP_UNICODE          0x0004
-#define CAP_LARGE_FILES      0x0008
-#define CAP_NT_SMBS          0x0010
-#define CAP_RPC_REMOTE_APIS  0x0020
-#define CAP_STATUS32         0x0040
-#define CAP_LEVEL_II_OPLOCKS 0x0080
-#define CAP_LOCK_AND_READ    0x0100
-#define CAP_NT_FIND          0x0200
-#define CAP_DFS              0x1000
-#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
+
+/* CIFS protocol capabilities */
+#define CAP_RAW_MODE           0x00000001
+#define CAP_MPX_MODE           0x00000002
+#define CAP_UNICODE            0x00000004
+#define CAP_LARGE_FILES                0x00000008
+#define CAP_NT_SMBS            0x00000010
+#define CAP_RPC_REMOTE_APIS    0x00000020
+#define CAP_STATUS32           0x00000040
+#define CAP_LEVEL_II_OPLOCKS   0x00000080
+#define CAP_LOCK_AND_READ      0x00000100
+#define CAP_NT_FIND            0x00000200
+#define CAP_DFS                        0x00001000
+#define CAP_W2K_SMBS           0x00002000
+#define CAP_LARGE_READX                0x00004000
+#define CAP_LARGE_WRITEX       0x00008000
+#define CAP_UNIX               0x00800000 /* Capabilities for UNIX extensions. Created by HP. */
+#define CAP_EXTENDED_SECURITY  0x80000000
 
 /*
- * Global value meaing that the smb_uid field should be
+ * Global value meaning that the smb_uid field should be
  * ingored (in share level security and protocol level == CORE)
  */
 
@@ -1145,24 +548,20 @@ char *strdup(char *s);
 #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
 
 /* Lock types. */
-#define LOCKING_ANDX_SHARED_LOCK 0x1
-#define LOCKING_ANDX_OPLOCK_RELEASE 0x2
-#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4
-#define LOCKING_ANDX_CANCEL_LOCK 0x8
-#define LOCKING_ANDX_LARGE_FILES 0x10
-
-/* Oplock levels */
-#define OPLOCKLEVEL_NONE 0
-#define OPLOCKLEVEL_II 1
+#define LOCKING_ANDX_SHARED_LOCK     0x01
+#define LOCKING_ANDX_OPLOCK_RELEASE  0x02
+#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
+#define LOCKING_ANDX_CANCEL_LOCK     0x08
+#define LOCKING_ANDX_LARGE_FILES     0x10
 
 /*
  * Bits we test with.
  */
 
-#define NO_OPLOCK 0
-#define EXCLUSIVE_OPLOCK 1
-#define BATCH_OPLOCK 2
-#define LEVEL_II_OPLOCK 4
+#define OPLOCK_NONE      0
+#define OPLOCK_EXCLUSIVE 1
+#define OPLOCK_BATCH     2
+#define OPLOCK_LEVEL_II  4
 
 #define CORE_OPLOCK_GRANTED (1<<5)
 #define EXTENDED_OPLOCK_GRANTED (1<<15)
@@ -1176,198 +575,46 @@ char *strdup(char *s);
 #define BATCH_OPLOCK_RETURN 2
 #define LEVEL_II_OPLOCK_RETURN 3
 
-/*
- * Loopback command offsets.
- */
-
-#define OPBRK_CMD_LEN_OFFSET 0
-#define OPBRK_CMD_PORT_OFFSET 4
-#define OPBRK_CMD_HEADER_LEN 6
-
-#define OPBRK_MESSAGE_CMD_OFFSET 0
-
-/* 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.
- */
-
-#define KERNEL_OPLOCK_CAPABILITY 0x1
-
-/*
- * Oplock break command code sent via the kernel interface (if it exists).
- *
- * Form of this is :
- *
- *  0     2       2+devsize 2+devsize+inodesize
- *  +----+--------+--------+----------+
- *  | cmd| dev    |  inode |  fileid  |
- *  +----+--------+--------+----------+
- */
-#define KERNEL_OPLOCK_BREAK_DEV_OFFSET 2
-#define KERNEL_OPLOCK_BREAK_INODE_OFFSET (KERNEL_OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))
-#define KERNEL_OPLOCK_BREAK_FILEID_OFFSET (KERNEL_OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
-#define KERNEL_OPLOCK_BREAK_MSG_LEN (KERNEL_OPLOCK_BREAK_FILEID_OFFSET + sizeof(unsigned long))
-
-
 #define CMD_REPLY 0x8000
 
-#include "smb_macros.h"
-
-/* A netbios name structure. */
-struct nmb_name {
-       char         name[17];
-       char         scope[64];
-       unsigned int name_type;
-};
-
-
-/* A netbios node status array element. */
-struct node_status {
-       char name[16];
-       unsigned char type;
-       unsigned char flags;
-};
-
-struct pwd_info
-{
-       BOOL null_pwd;
-       BOOL cleartext;
-       BOOL crypted;
-
-       fstring password;
-
-       uchar smb_lm_pwd[16];
-       uchar smb_nt_pwd[16];
-
-       uchar smb_lm_owf[24];
-       uchar smb_nt_owf[128];
-       size_t nt_owf_len;
-
-       uchar lm_cli_chal[8];
-       uchar nt_cli_chal[128];
-       size_t nt_cli_chal_len;
-
-       uchar sess_key[16];
-};
-
-#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;
-       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;
-       char *homedir;
-       char *unix_homedir;
-       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;
-
-       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;
-
-
-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
- * hold 11 ACB characters, plus the surrounding [] and a terminating null.
- * Do not change unless you are adding new ACB bits!
- */
-
-#define NEW_PW_FORMAT_SPACE_PADDED_LEN 14
-
-/*
-   Do you want session setups at user level security with a invalid
-   password to be rejected or allowed in as guest? WinNT rejects them
-   but it can be a pain as it means "net view" needs to use a password
-
-   You have 3 choices in the setting of map_to_guest:
-
-   "NEVER_MAP_TO_GUEST" means session setups with an invalid password
-   are rejected. This is the default.
-
-   "MAP_TO_GUEST_ON_BAD_USER" means session setups with an invalid password
-   are rejected, unless the username does not exist, in which case it
-   is treated as a guest login
-
-   "MAP_TO_GUEST_ON_BAD_PASSWORD" means session setups with an invalid password
-   are treated as a guest login
-
-   Note that map_to_guest only has an effect in user or server
-   level security.
-*/
-
-#define NEVER_MAP_TO_GUEST 0
-#define MAP_TO_GUEST_ON_BAD_USER 1
-#define MAP_TO_GUEST_ON_BAD_PASSWORD 2
-
-#define SAFE_NETBIOS_CHARS ". -_"
-
-/* generic iconv conversion structure */
-typedef struct {
-       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 */
 
 #define DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH 14
 
-/* Module support */
-typedef int (init_module_function) (void);
+/* passed to br lock code */
+enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_READ_LOCK, PENDING_WRITE_LOCK};
 
+/* string manipulation flags - see clistr.c and srvstr.c */
+#define STR_TERMINATE 1
+#define STR_UPPER 2
+#define STR_ASCII 4
+#define STR_UNICODE 8
+#define STR_NOALIGN 16
+#define STR_NO_RANGE_CHECK 32
+#define STR_LEN8BIT 64
+#define STR_TERMINATE_ASCII 128 /* only terminate if ascii */
+#define STR_LEN_NOTERM 256 /* the length field is the unterminated length */
 
-/* a set of flags to control handling of request structures */
-#define REQ_CONTROL_PROTECTED (1<<0) /* don't destroy this request */
-#define REQ_CONTROL_LARGE     (1<<1) /* allow replies larger than max_xmit */
-#define REQ_CONTROL_ASYNC     (1<<2) /* the backend will answer this one later */
 
-/* passed to br lock code */
-enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_LOCK};
+/*
+  filesystem attribute bits
+*/
+#define FS_ATTR_CASE_SENSITIVE_SEARCH             0x00000001
+#define FS_ATTR_CASE_PRESERVED_NAMES              0x00000002
+#define FS_ATTR_UNICODE_ON_DISK                   0x00000004
+#define FS_ATTR_PERSISTANT_ACLS                   0x00000008
+#define FS_ATTR_COMPRESSION                       0x00000010
+#define FS_ATTR_QUOTAS                            0x00000020
+#define FS_ATTR_SPARSE_FILES                      0x00000040
+#define FS_ATTR_REPARSE_POINTS                    0x00000080
+#define FS_ATTR_REMOTE_STORAGE                    0x00000100
+#define FS_ATTR_LFN_SUPPORT                       0x00004000
+#define FS_ATTR_IS_COMPRESSED                     0x00008000
+#define FS_ATTR_OBJECT_IDS                        0x00010000
+#define FS_ATTR_ENCRYPTION                        0x00020000
+#define FS_ATTR_NAMED_STREAMS                     0x00040000
 
-#include "popt_common.h"
 
 #endif /* _SMB_H */