added extra fields to struct smb_passwd
[kai/samba.git] / source / include / smb.h
index a67b3c02c96fee3a22970f8b2294139eff9f0221..11e7409a9a80565b4da3516b18d76d5a18c4dd18 100644 (file)
@@ -2,8 +2,10 @@
    Unix SMB/Netbios implementation.
    Version 1.9.
    SMB parameters and setup
-   Copyright (C) Andrew Tridgell 1992-1997
-   Copyright (C) John H Terpstra 1996-1997
+   Copyright (C) Andrew Tridgell 1992-1998
+   Copyright (C) John H Terpstra 1996-1998
+   Copyright (C) Luke Kenneth Casson Leighton 1996-1998
+   Copyright (C) Paul Ashton 1998
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #ifndef _SMB_H
 #define _SMB_H
 
-#ifndef MAX_CONNECTIONS
-#define MAX_CONNECTIONS 127
-#endif
-
-#ifndef MAX_OPEN_FILES
-#define MAX_OPEN_FILES 50
-#endif
-
-#ifndef GUEST_ACCOUNT
-#define GUEST_ACCOUNT "nobody"
-#endif
-
 #define BUFFER_SIZE (0xFFFF)
 #define SAFETY_MARGIN 1024
 
-/* Default size of shared memory used for share mode locking */
-#ifndef SHMEM_SIZE
-#define SHMEM_SIZE 102400
-#endif
-
-/* Default number of hash buckets used in shared memory share mode */
-#ifndef SHMEM_HASH_SIZE
-#define SHMEM_HASH_SIZE 113
-#endif
-
 #define NMB_PORT 137
 #define DGRAM_PORT 138
 #define SMB_PORT 139
 #define BOOLSTR(b) ((b) ? "Yes" : "No")
 #define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
 #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
+
+#define IS_BITS_SET_ALL(var,bit) (((var)&(bit))==(bit))
+#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0)
+#define IS_BITS_CLR_ALL(var,bit) (((var)&(~(bit)))==0)
+
 #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
 
 typedef int BOOL;
 
-/* offset in shared memory */
-typedef  int smb_shm_offset_t;
-#define NULL_OFFSET (smb_shm_offset_t)(0)
-
+/* limiting size of ipc replies */
+#define REALLOC(ptr,size) Realloc(ptr,MAX((size),4*1024))
 
 /*
    Samba needs type definitions for int16, int32, uint16 and uint32.
@@ -80,6 +63,10 @@ typedef short int16;
 typedef int int32;
 #endif
 
+#ifndef uint8
+typedef unsigned char uint8;
+#endif
+
 #ifndef uint16
 typedef unsigned short uint16;
 #endif
@@ -150,10 +137,11 @@ implemented */
 #define DENY_FCB 7
 
 /* 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_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 $) */
 
 /* SMB X/Open error codes for the ERRdos error class */
 #define ERRbadfunc 1 /* Invalid function (or system call) */
@@ -252,21 +240,145 @@ typedef char fstring[128];
 typedef fstring string;
 
 
-struct smb_passwd {
-       int smb_userid;
-       char *smb_name;
+/* pipe strings */
+#define PIPE_LANMAN   "\\PIPE\\LANMAN"
+#define PIPE_SRVSVC   "\\PIPE\\srvsvc"
+#define PIPE_SAMR     "\\PIPE\\samr"
+#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"
+
+/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
+typedef struct nttime_info
+{
+  uint32 low;
+  uint32 high;
+
+} NTTIME;
+
+/* 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
+
+struct smb_passwd
+{
+       time_t logon_time;            /* logon time */
+       time_t logoff_time;           /* logoff time */
+       time_t kickoff_time;          /* kickoff time */
+       time_t pass_last_set_time;    /* password last set time */
+       time_t pass_can_change_time;  /* password can change time */
+       time_t pass_must_change_time; /* password must change time */
+
+       char *smb_name;     /* username unicode string */
+       char *full_name;    /* user's full name unicode string */
+       char *home_dir;     /* home directory unicode string */
+       char *dir_drive;    /* home directory drive unicode string */
+       char *logon_script; /* logon script unicode string */
+       char *profile_path; /* profile path unicode string */
+       char *acct_desc  ;  /* user description unicode string */
+       char *workstations; /* login from workstations unicode string */
+       char *unknown_str ; /* don't know what this is, yet. */
+       char *munged_dial ; /* munged path name and dial-back tel number */
+
+       int smb_userid;       /* this is actually the unix uid_t */
+       uint32 user_rid;      /* Primary User ID */
+       uint32 group_rid;     /* Primary Group ID */
+
        unsigned char *smb_passwd; /* Null if no password */
        unsigned char *smb_nt_passwd; /* Null if no password */
-       /* Other fields / flags may be added later */
+
+       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 */
 };
 
 
-struct current_user {
-  int cnum, id;
+/* DOM_CHAL - challenge info */
+typedef struct chal_info
+{
+  uchar data[8]; /* credentials */
+} DOM_CHAL;
+
+/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
+typedef struct time_info
+{
+  uint32 time;
+
+} UTIME;
+
+/* DOM_CREDs - timestamped client or server credentials */
+typedef struct cred_info
+{  
+  DOM_CHAL challenge; /* credentials */
+  UTIME timestamp;    /* credential time-stamp */
+
+} DOM_CRED;
+
+struct cli_state {
+  int fd;
+  int cnum;
+  int pid;
+  int mid;
+  int uid;
+  int protocol;
+  int sec_mode;
+  int rap_error;
+  int privilages;
+  fstring eff_name;
+  fstring desthost;
+  char cryptkey[8];
+  uint32 sesskey;
+  int serverzone;
+  uint32 servertime;
+  int readbraw_supported;
+  int writebraw_supported;
+  int timeout;
+  int max_xmit;
+  char *outbuf;
+  char *inbuf;
+  int bufsize;
+  int initialised;
+  /*
+   * Only used in NT domain calls.
+   */
+  uint32 nt_error;                   /* NT RPC error code. */
+  uint16 nt_pipe_fnum;               /* Pipe handle. */
+  unsigned char sess_key[16];        /* Current session key. */
+  DOM_CRED clnt_cred;                /* Client credential. */
+  fstring mach_acct;                 /* MYNAME$. */
+  fstring srv_name_slash;            /* \\remote server. */
+  fstring clnt_name_slash;            /* \\local client. */
+};
+
+
+struct current_user
+{
+  int cnum, vuid;
   int uid, gid;
   int ngroups;
   gid_t *groups;
   int *igroups;
+  int *attrs;
 };
 
 typedef struct
@@ -280,6 +392,7 @@ typedef struct
   time_t atime;
   time_t ctime;
   pstring name;
+
 } file_info;
 
 
@@ -318,7 +431,7 @@ typedef struct
   int pos;
   uint32 size;
   int mode;
-  int uid;
+  int vuid;
   char *mmap_ptr;
   uint32 mmap_size;
   write_bmpx_struct *wbmpx_ptr;
@@ -330,6 +443,9 @@ typedef struct
   BOOL share_mode;
   BOOL print_file;
   BOOL modified;
+  BOOL granted_oplock;
+  BOOL sent_oplock_break;
+  BOOL reserved;
   char *name;
 } files_struct;
 
@@ -362,35 +478,61 @@ typedef struct
   char *user; /* name of user who *opened* this connection */
   int uid; /* uid of user who *opened* this connection */
   int gid; /* gid of user who *opened* this connection */
+
   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 */
   int ngroups;
   gid_t *groups;
   int *igroups; /* an integer version - some OSes are broken :-( */
+  int *attrs;
+
   time_t lastused;
   BOOL used;
   int num_files_open;
   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. */
+
 } connection_struct;
 
+/* Domain controller authentication protocol info */
+struct dcinfo
+{
+  DOM_CHAL clnt_chal; /* Initial challenge received from client */
+  DOM_CHAL srv_chal;  /* Initial server challenge */
+  DOM_CRED clnt_cred; /* Last client credential */
+  DOM_CRED srv_cred;  /* Last server credential */
+
+  uchar  sess_key[8]; /* Session key */
+  uchar  md4pw[16];   /* md4(machine password) */
+};
 
 typedef struct
 {
   int uid; /* uid of a validated user */
   int gid; /* gid of a validated user */
-  fstring name; /* name of a validated user */
+
+  fstring requested_name; /* user name from the client */
+  fstring name; /* unix user name of a validated user */
+  fstring real_name;   /* to store real name from password file - simeon */
   BOOL guest;
+
   /* following groups stuff added by ih */
   /* This groups info is needed for when we become_user() for this uid */
-  int user_ngroups;
-  gid_t *user_groups;
-  int *user_igroups; /* an integer version - some OSes are broken :-( */
-#if (defined(NETGROUP) && defined(AUTOMOUNT))
-  char *home_share;  /* to store NIS home of a user - simeon */
-#endif
-  char *real_name;   /* to store real name from password file - simeon */
+  int n_groups;
+  gid_t *groups;
+  int *igroups; /* an integer version - some OSes are broken :-( */
+  int *attrs; /* attributes associated with each gid */
+
+  int n_sids;
+  int *sids;
+
+  /* per-user authentication information on NT RPCs */
+  struct dcinfo dc;
+
 } user_struct;
 
 
@@ -435,46 +577,46 @@ struct interface
        struct in_addr nmask;
 };
 
-/* share mode record pointed to in shared memory hash bucket */
-typedef struct
-{
-  smb_shm_offset_t next_offset; /* offset of next record in chain from hash bucket */
-  int locking_version;
-  int32 st_dev;
-  int32 st_ino;
-  int num_share_mode_entries;
-  smb_shm_offset_t share_mode_entries; /* Chain of share mode entries for this file */
-  char file_name[1];
-} share_mode_record;
-
-/* share mode entry pointed to by share_mode_record struct */
+/* struct returned by get_share_modes */
 typedef struct
 {
-  smb_shm_offset_t next_share_mode_entry;
   int pid;
-#ifdef USE_OPLOCKS
   uint16 op_port;
-#endif /* USE_OPLOCKS */
+  uint16 op_type;
   int share_mode;
   struct timeval time;
 } share_mode_entry;
 
-/* struct returned by get_share_modes */
-typedef struct
-{
-  int pid;
-#ifdef USE_OPLOCKS
-  uint16 op_port;
-#endif /* USE_OPLOCKS */
-  int share_mode;
-  struct timeval time;
-} min_share_mode_entry;
 
-/* Token returned by lock_share_entry (actually ignored by FAST_SHARE_MODES code) */
-typedef int share_lock_token;
+/* each implementation of the share mode code needs
+   to support the following operations */
+struct share_ops {
+       BOOL (*stop_mgmt)(void);
+       BOOL (*lock_entry)(int , uint32 , uint32 , int *);
+       BOOL (*unlock_entry)(int , uint32 , uint32 , int );
+       int (*get_entries)(int , int , uint32 , uint32 , share_mode_entry **);
+       void (*del_entry)(int , int );
+       BOOL (*set_entry)(int , int , uint16 , uint16 );
+       BOOL (*remove_oplock)(int , int);
+       int (*forall)(void (*)(share_mode_entry *, char *));
+       void (*status)(FILE *);
+};
+
+/* each implementation of the shared memory code needs
+   to support the following operations */
+struct shmem_ops {
+       BOOL (*shm_close)( void );
+       int (*shm_alloc)(int );
+       BOOL (*shm_free)(int );
+       int (*get_userdef_off)(void);
+       void *(*offset2addr)(int );
+       int (*addr2offset)(void *addr);
+       BOOL (*lock_hash_entry)(unsigned int);
+       BOOL (*unlock_hash_entry)( unsigned int );
+       BOOL (*get_usage)(int *,int *,int *);
+       unsigned (*hash_size)(void);
+};
 
-/* Conversion to hash entry index from device and inode numbers. */
-#define HASH_ENTRY(dev,ino) ((( (uint32)(dev) )* ( (uint32)(ino) )) % lp_shmem_hash_size())
 
 /* this is used for smbstatus */
 struct connect_record
@@ -490,12 +632,67 @@ struct connect_record
   time_t start;
 };
 
+/* This is used by smbclient to send it to a smbfs mount point */
+struct connection_options {
+  int protocol;
+  /* Connection-Options */
+  uint32 max_xmit;
+  uint16 server_uid;
+  uint16 tid;
+  /* The following are LANMAN 1.0 options */
+  uint16 sec_mode;
+  uint16 max_mux;
+  uint16 max_vcs;
+  uint16 rawmode;
+  uint32 sesskey;
+  /* The following are NT LM 0.12 options */
+  uint32 maxraw;
+  uint32 capabilities;
+  uint16 serverzone;
+};
+
+/* the following are used by loadparm for option lists */
+typedef enum
+{
+  P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,
+  P_STRING,P_USTRING,P_GSTRING,P_UGSTRING,P_ENUM,P_SEP
+} parm_type;
+
+typedef enum
+{
+  P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
+} parm_class;
+
+struct enum_list {
+       int value;
+       char *name;
+};
+
+struct parm_struct
+{
+       char *label;
+       parm_type type;
+       parm_class class;
+       void *ptr;
+       BOOL (*special)(char *, char **);
+       struct enum_list *enum_list;
+       unsigned flags;
+       union {
+               BOOL bvalue;
+               int ivalue;
+               char *svalue;
+               char cvalue;
+       } def;
+};
+
+
+#define FLAG_BASIC 1 /* fundamental options */
+#define FLAG_HIDE  2 /* options that should be hidden in SWAT */
+#define FLAG_PRINT 4 /* printing options */
+#define FLAG_GLOBAL 8 /* local options that should be globally settable in SWAT */
+
 #ifndef LOCKING_VERSION
-#ifdef USE_OPLOCKS
 #define LOCKING_VERSION 4
-#else /* USE_OPLOCKS */
-#define LOCKING_VERSION 3
-#endif /* USE_OPLOCKS */
 #endif /* LOCKING_VERSION */
 
 /* these are useful macros for checking validity of handles */
@@ -536,6 +733,7 @@ struct connect_record
 #define MAP_ARCHIVE(cnum)   (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
 #define IS_HIDDEN_PATH(cnum,path)  (is_in_path((path),Connections[(cnum)].hide_list))
 #define IS_VETO_PATH(cnum,path)  (is_in_path((path),Connections[(cnum)].veto_list))
+#define IS_VETO_OPLOCK_PATH(cnum,path)  (is_in_path((path),Connections[(cnum)].veto_oplock_list))
 
 #define SMBENCRYPT()       (lp_encrypted_passwords())
 
@@ -657,23 +855,38 @@ struct connect_record
 #define SMBfindnclose    0x35   /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
 #define SMBulogoffX      0x74   /* user logoff */
 
-
-/* these are the TRANS2 sub commands */
-#define TRANSACT2_OPEN          0
-#define TRANSACT2_FINDFIRST     1
-#define TRANSACT2_FINDNEXT      2
-#define TRANSACT2_QFSINFO       3
-#define TRANSACT2_SETFSINFO     4
-#define TRANSACT2_QPATHINFO     5
-#define TRANSACT2_SETPATHINFO   6
-#define TRANSACT2_QFILEINFO     7
-#define TRANSACT2_SETFILEINFO   8
-#define TRANSACT2_FSCTL         9
-#define TRANSACT2_IOCTL           10
-#define TRANSACT2_FINDNOTIFYFIRST 11
-#define TRANSACT2_FINDNOTIFYNEXT  12
-#define TRANSACT2_MKDIR           13
-
+/* NT SMB extensions. */
+#define SMBnttrans       0xA0   /* NT transact */
+#define SMBnttranss      0xA1   /* NT transact secondary */
+#define SMBntcreateX     0xA2   /* NT create and X */
+#define SMBntcancel      0xA4   /* NT cancel */
+
+/* These are the TRANS2 sub commands */
+#define TRANSACT2_OPEN                        0
+#define TRANSACT2_FINDFIRST                   1
+#define TRANSACT2_FINDNEXT                    2
+#define TRANSACT2_QFSINFO                     3
+#define TRANSACT2_SETFSINFO                   4
+#define TRANSACT2_QPATHINFO                   5
+#define TRANSACT2_SETPATHINFO                 6
+#define TRANSACT2_QFILEINFO                   7
+#define TRANSACT2_SETFILEINFO                 8
+#define TRANSACT2_FSCTL                       9
+#define TRANSACT2_IOCTL                     0xA
+#define TRANSACT2_FINDNOTIFYFIRST           0xB
+#define TRANSACT2_FINDNOTIFYNEXT            0xC
+#define TRANSACT2_MKDIR                     0xD
+#define TRANSACT2_SESSION_SETUP             0xE
+#define TRANSACT2_GET_DFS_REFERRAL         0x10
+#define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
+
+/* These are the NT transact sub commands. */
+#define NT_TRANSACT_CREATE                1
+#define NT_TRANSACT_IOCTL                 2
+#define NT_TRANSACT_SET_SECURITY_DESC     3
+#define NT_TRANSACT_NOTIFY_CHANGE         4
+#define NT_TRANSACT_RENAME                5
+#define NT_TRANSACT_QUERY_SECURITY_DESC   6
 
 /* these are the trans2 sub fields for primary requests */
 #define smb_tpscnt smb_vwv0
@@ -712,11 +925,36 @@ struct connect_record
 #define smb_droff smb_vwv7
 #define smb_drdisp smb_vwv8
 
+/* these are for the NT trans primary request. */
+#define smb_nt_MaxSetupCount smb_vwv0
+#define smb_nt_Flags (smb_vwv0 + 1)
+#define smb_nt_TotalParameterCount (smb_vwv0 + 3)
+#define smb_nt_TotalDataCount (smb_vwv0 + 7)
+#define smb_nt_MaxParameterCount (smb_vwv0 + 11)
+#define smb_nt_MaxDataCount (smb_vwv0 + 15)
+#define smb_nt_ParameterCount (smb_vwv0 + 19)
+#define smb_nt_ParameterOffset (smb_vwv0 + 23)
+#define smb_nt_DataCount (smb_vwv0 + 27)
+#define smb_nt_DataOffset (smb_vwv0 + 31)
+#define smb_nt_SetupCount (smb_vwv0 + 35)
+#define smb_nt_Function (smb_vwv0 + 36)
+#define smb_nt_SetupStart (smb_vwv0 + 39)
+
+/* these are for the NT trans secondary request. */
+#define smb_nts_TotalParameterCount (smb_vwv0 + 3)
+#define smb_nts_TotalDataCount (smb_vwv0 + 7)
+#define smb_nts_ParameterCount (smb_vwv0 + 11)
+#define smb_nts_ParameterOffset (smb_vwv0 + 15)
+#define smb_nts_ParameterDisplacement (smb_vwv0 + 19)
+#define smb_nts_DataCount (smb_vwv0 + 23)
+#define smb_nts_DataOffset (smb_vwv0 + 27)
+#define smb_nts_DataDisplacement (smb_vwv0 + 31)
+
 /* where to find the base of the SMB packet proper */
 #define smb_base(buf) (((char *)(buf))+4)
 
 
-#define SUCCESS 0  /* The request was successful. */
+#define SMB_SUCCESS 0  /* The request was successful. */
 #define ERRDOS 0x01 /*  Error is from the core DOS operating system set. */
 #define ERRSRV 0x02  /* Error is generated by the server network file manager.*/
 #define ERRHRD 0x03  /* Error is an hardware error. */
@@ -860,6 +1098,14 @@ char *Strstr(char *s, char *p);
 #define BROWSER_ELECTION_VERSION       0x010f
 #define BROWSER_CONSTANT       0xaa55
 
+/* NT Flags2 bits - cifs6.txt section 3.1.2 */
+   
+#define FLAGS2_LONG_PATH_COMPONENTS   0x0001
+#define FLAGS2_EXTENDED_ATTRIBUTES    0x0002
+#define FLAGS2_DFS_PATHNAMES          0x1000
+#define FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
+#define FLAGS2_32_BIT_ERROR_CODES     0x4000 
+#define FLAGS2_UNICODE_STRINGS        0x8000
 
 /* Capabilities.  see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
 
@@ -881,11 +1127,11 @@ char *Strstr(char *s, char *p);
 enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
 
 /* security levels */
-enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
+enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN};
 
 /* printing types */
 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
-                    PRINT_QNX,PRINT_PLP,PRINT_LPRNG};
+                    PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ};
 
 /* Remote architectures we know about. */
 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA};
@@ -931,22 +1177,105 @@ enum case_handling {CASE_LOWER,CASE_UPPER};
 #define UID_FIELD_INVALID 0
 #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
 
-#endif 
-
 /* Defines needed for multi-codepage support. */
+#define MSDOS_LATIN_1_CODEPAGE 850
 #define KANJI_CODEPAGE 932
+#define HANGUL_CODEPAGE 949
+#define BIG5_CODEPAGE 950
+#define SIMPLIFIED_CHINESE_CODEPAGE 936
 
 #ifdef KANJI
-/* Default client code page - Japanese */
+/* 
+ * Default client code page - Japanese 
+ */
 #define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE
 #else /* KANJI */
-/* Default client code page - 850 - Western European */
-#define DEFAULT_CLIENT_CODE_PAGE 850
+/* 
+ * Default client code page - 850 - Western European 
+ */
+#define DEFAULT_CLIENT_CODE_PAGE MSDOS_LATIN_1_CODEPAGE
 #endif /* KANJI */
-/* Size of buffer to use when moving files across filesystems. */
+
+/* 
+ * Size of buffer to use when moving files across filesystems. 
+ */
 #define COPYBUF_SIZE (8*1024)
 
-/* Integers used to override error codes. */
+/* 
+ * Integers used to override error codes. 
+ */
 extern int unix_ERR_class;
 extern int unix_ERR_code;
+
+/*
+ * Map the Core and Extended Oplock requesst bits down
+ * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
+ */
+
+/*
+ * Core protocol.
+ */
+#define CORE_OPLOCK_REQUEST(inbuf) ((CVAL(inbuf,smb_flg)&((1<<5)|(1<<6)))>>5)
+
+/*
+ * Extended protocol.
+ */
+#define EXTENDED_OPLOCK_REQUEST(inbuf) ((SVAL(inbuf,smb_vwv2)&((1<<1)|(1<<2)))>>1)
+
+/* 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
+
+/*
+ * Bits we test with.
+ */
+#define EXCLUSIVE_OPLOCK 1
+#define BATCH_OPLOCK 2
+
+#define CORE_OPLOCK_GRANTED (1<<5)
+#define EXTENDED_OPLOCK_GRANTED (1<<15)
+
+/*
+ * Loopback command offsets.
+ */
+
+#define UDP_CMD_LEN_OFFSET 0
+#define UDP_CMD_PORT_OFFSET 4
+#define UDP_CMD_HEADER_LEN 6
+
+#define UDP_MESSAGE_CMD_OFFSET 0
+
+/*
+ * Oplock break command code to send over the udp socket.
+ * 
+ * Form of this is :
+ *
+ *  0     2       6        10       14      18       22
+ *  +----+--------+--------+--------+-------+--------+
+ *  | cmd| pid    | dev    | inode  | sec   |  usec  |
+ *  +----+--------+--------+--------+-------+--------+
+ */
+
+#define OPLOCK_BREAK_CMD 0x1
+#define OPLOCK_BREAK_PID_OFFSET 2
+#define OPLOCK_BREAK_DEV_OFFSET 6
+#define OPLOCK_BREAK_INODE_OFFSET 10
+#define OPLOCK_BREAK_SEC_OFFSET 14
+#define OPLOCK_BREAK_USEC_OFFSET 18
+#define OPLOCK_BREAK_MSG_LEN 22
+
+
+#define CMD_REPLY 0x8000
+
+#endif /* _SMB_H */
+
+#include "ntdomain.h"
+
 /* _SMB_H */