r20854: Ok, now I think we're at a point where looking at notify starts to make sense
[abartlet/samba.git/.git] / source3 / include / smb.h
index c5115a551febc55bde9248887f6d5a021ebb4dba..fc3acf6d6c00ea7369bb356bc6e8cf0a00df9066 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 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 {
@@ -174,6 +167,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"
@@ -205,22 +202,16 @@ 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_UNIXINFO            13
 #define PI_NTSVCS              14
 #define PI_MAX_PIPES           15
 
-typedef struct uint64_s
-{
-       uint32 low;
-       uint32 high;
-} UINT64_S;
-
 /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
-typedef UINT64_S NTTIME;
+typedef uint64_t NTTIME;
 
 
 /* Allowable account control bits */
@@ -254,20 +245,6 @@ typedef UINT64_S NTTIME;
 
 #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)
@@ -280,7 +257,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 */
@@ -293,6 +270,43 @@ 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,
+       ID_MAPPED,
+       ID_UNMAPPED
+};
+
+enum id_type {
+       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;
@@ -303,7 +317,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;
 };
@@ -410,6 +424,7 @@ struct fd_handle {
 struct timed_event;
 struct idle_event;
 struct share_mode_entry;
+struct uuid;
 
 struct vfs_fsp_data {
     struct vfs_fsp_data *next;
@@ -419,6 +434,49 @@ struct vfs_fsp_data {
      */
 };
 
+/* the basic packet size, assuming no words or bytes */
+#define smb_size 39
+
+struct notify_change {
+       uint32_t action;
+       char *name;
+};
+
+struct notify_change_request {
+       struct notify_change_request *prev, *next;
+       struct files_struct *fsp;       /* backpointer for cancel by mid */
+       char request_buf[smb_size];
+       uint32 filter;
+       uint32 max_param_count;
+       struct notify_mid_map *mid_map;
+};
+
+/*
+ * For NTCancel, we need to find the notify_change_request indexed by
+ * mid. Separate list here.
+ */
+
+struct notify_mid_map {
+       struct notify_mid_map *prev, *next;
+       struct notify_change_request *req;
+       uint16 mid;
+};
+
+struct notify_change_buf {
+       /*
+        * If no requests are pending, changes are queued here. Simple array,
+        * we only append.
+        */
+       unsigned 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;
        int fnum;
@@ -461,6 +519,8 @@ typedef struct files_struct {
 
        struct vfs_fsp_data *vfs_extension;
        FAKE_FILE_HANDLE *fake_file_handle;
+
+       struct notify_change_buf *notify;
 } files_struct;
 
 #include "ntquotas.h"
@@ -554,7 +614,7 @@ struct share_iterator {
 
 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 */
        struct share_params *params;
        BOOL force_user;
@@ -870,9 +930,6 @@ struct bitmap {
        unsigned int n;
 };
 
-/* the basic packet size, assuming no words or bytes */
-#define smb_size 39
-
 /* offsets into message for common items */
 #define smb_com 8
 #define smb_rcls 9
@@ -934,7 +991,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 */
@@ -1334,6 +1391,20 @@ struct bitmap {
 #define FILE_NOTIFY_CHANGE_SECURITY    0x100
 #define FILE_NOTIFY_CHANGE_FILE_NAME   0x200
 
+#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)
 
@@ -1361,36 +1432,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
@@ -1789,6 +1830,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 {
@@ -1820,13 +1864,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