Sync smb_iconv_t type, convert_string return type with Samba 3 equivalents.
[ira/wip.git] / source3 / include / smb.h
index 3de782e8b8ab4593b6148c75c2761688a82f8152..189e370496d5bfc7ea6a3762f30979ebddab2bec 100644 (file)
@@ -27,7 +27,7 @@
 #define _SMB_H
 
 /* logged when starting the various Samba daemons */
-#define COPYRIGHT_STARTUP_MESSAGE      "Copyright Andrew Tridgell and the Samba Team 1992-2008"
+#define COPYRIGHT_STARTUP_MESSAGE      "Copyright Andrew Tridgell and the Samba Team 1992-2009"
 
 
 #if defined(LARGE_SMB_OFF_T)
@@ -167,10 +167,6 @@ typedef uint16 smb_ucs2_t;
 #define COPY_UCS2_CHAR(dest,src) (((unsigned char *)(dest))[0] = ((unsigned char *)(src))[0],\
                                ((unsigned char *)(dest))[1] = ((unsigned char *)(src))[1], (dest))
 
-/* Large data type for manipulating uint32 unicode codepoints */
-typedef uint32 codepoint_t;
-#define INVALID_CODEPOINT ((codepoint_t)-1)
-
 /* pipe string names */
 #define PIPE_LANMAN   "\\PIPE\\LANMAN"
 
@@ -209,18 +205,7 @@ typedef uint32 codepoint_t;
  *
  * @sa http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/accctrl_38yn.asp
  **/
-typedef struct dom_sid {
-       uint8  sid_rev_num;             /**< SID revision number */
-       uint8  num_auths;               /**< Number of sub-authorities */
-       uint8  id_auth[6];              /**< Identifier Authority */
-       /*
-        *  Pointer to sub-authorities.
-        *
-        * @note The values in these uint32's are in *native* byteorder, not
-        * neccessarily little-endian...... JRA.
-        */
-       uint32 sub_auths[MAXSUBAUTHS];  
-} DOM_SID;
+typedef struct dom_sid DOM_SID;
 
 enum id_mapping {
        ID_UNKNOWN = 0,
@@ -268,6 +253,7 @@ struct id_map {
 #include "librpc/gen_ndr/nbt.h"
 #include "librpc/gen_ndr/drsuapi.h"
 #include "librpc/gen_ndr/drsblobs.h"
+#include "librpc/gen_ndr/spoolss.h"
 
 struct lsa_dom_info {
        bool valid;
@@ -372,19 +358,20 @@ struct fd_handle {
        unsigned long gen_id;
 };
 
-struct event_context;
-struct fd_event;
-struct timed_event;
 struct idle_event;
 struct share_mode_entry;
 struct uuid;
 struct named_mutex;
 struct pcap_cache;
+struct wb_context;
+struct rpc_cli_smbd_conn;
 
 struct vfs_fsp_data {
     struct vfs_fsp_data *next;
     struct vfs_handle_struct *owner;
-    /* NOTE: This structure contains two pointers so that we can guarantee
+    void (*destroy)(void *p_data);
+    void *_dummy_;
+    /* NOTE: This structure contains four pointers so that we can guarantee
      * that the end of the structure is always both 4-byte and 8-byte aligned.
      */
 };
@@ -624,7 +611,9 @@ struct current_user {
        NT_USER_TOKEN *nt_user_token;
 };
 
+
 struct smb_request {
+       uint8_t cmd;
        uint16 flags2;
        uint16 smbpid;
        uint16 mid;
@@ -635,11 +624,37 @@ struct smb_request {
        uint16_t buflen;
        const uint8_t *buf;
        const uint8 *inbuf;
+
+       /*
+        * Async handling in the main smb processing loop is directed by
+        * outbuf: reply_xxx routines indicate sync behaviour by putting their
+        * reply into "outbuf". If they leave it as NULL, they take of it
+        * themselves, possibly later.
+        *
+        * If async handling is wanted, the reply_xxx routine must make sure
+        * that it talloc_move()s the smb_req somewhere else.
+        */
        uint8 *outbuf;
+
        size_t unread_bytes;
        bool encrypted;
        connection_struct *conn;
+       struct smb_perfcount_data pcd;
+
+       /*
+        * Chained request handling
+        */
        struct files_struct *chain_fsp;
+
+       /*
+        * Here we collect the outbufs from the chain handlers
+        */
+       uint8_t *chain_outbuf;
+
+       /*
+        * state information for async smb handling
+        */
+       void *async_priv;
 };
 
 /* Defines for the sent_oplock_break field above. */
@@ -650,7 +665,6 @@ struct smb_request {
 typedef struct {
        fstring smb_name; /* user name from the client */
        fstring unix_name; /* unix user name of a validated user */
-       fstring full_name; /* to store full name (such as "Joe Bloggs") from gecos field of password file */
        fstring domain; /* domain that the client specified */
 } userdom_struct;
 
@@ -702,14 +716,14 @@ struct interface {
 struct pending_message_list {
        struct pending_message_list *next, *prev;
        struct timeval request_time; /* When was this first issued? */
-       struct timeval end_time; /* When does this time out? */
+       struct timed_event *te;
+       struct smb_perfcount_data pcd;
        bool encrypted;
        DATA_BLOB buf;
        DATA_BLOB private_data;
 };
 
 #define SHARE_MODE_FLAG_POSIX_OPEN     0x1
-#define SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE      0x2
 
 /* struct returned by get_share_modes */
 struct share_mode_entry {
@@ -740,18 +754,19 @@ Offset  Data                      length.
 16     uint32 private_options  4
 20     uint32 time sec         4
 24     uint32 time usec        4
-28     SMB_DEV_T dev           8 bytes.
-36     SMB_INO_T inode         8 bytes
-44     unsigned long file_id   4 bytes
-48     uint32 uid              4 bytes
-52     uint16 flags            2 bytes
-54
+28     uint64 dev              8 bytes
+36     uint64 inode            8 bytes
+44     uint64 extid            8 bytes
+52     unsigned long file_id   4 bytes
+56     uint32 uid              4 bytes
+60     uint16 flags            2 bytes
+62
 
 */
 #ifdef CLUSTER_SUPPORT
-#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 58
+#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 66
 #else
-#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 54
+#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 62
 #endif
 
 struct share_mode_lock {
@@ -1247,7 +1262,7 @@ struct bitmap {
 /* Mapping of access rights to UNIX perms. for a UNIX directory. */
 #define UNIX_DIRECTORY_ACCESS_RWX              FILE_GENERIC_ALL
 #define UNIX_DIRECTORY_ACCESS_R                FILE_GENERIC_READ
-#define UNIX_DIRECTORY_ACCESS_W                        FILE_GENERIC_WRITE
+#define UNIX_DIRECTORY_ACCESS_W                        (FILE_GENERIC_WRITE|FILE_DELETE_CHILD)
 #define UNIX_DIRECTORY_ACCESS_X                        FILE_GENERIC_EXECUTE
 
 #if 0
@@ -1525,7 +1540,7 @@ enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
 enum schema_types {SCHEMA_COMPAT, SCHEMA_AD, SCHEMA_SAMBA};
 
 /* LDAP SSL options */
-enum ldap_ssl_types {LDAP_SSL_ON, LDAP_SSL_OFF, LDAP_SSL_START_TLS};
+enum ldap_ssl_types {LDAP_SSL_OFF, LDAP_SSL_START_TLS};
 
 /* LDAP PASSWD SYNC methods */
 enum ldap_passwd_sync_types {LDAP_PASSWD_SYNC_ON, LDAP_PASSWD_SYNC_OFF, LDAP_PASSWD_SYNC_ONLY};
@@ -1553,11 +1568,6 @@ enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
  */
 #define COPYBUF_SIZE (8*1024)
 
-/*
- * Used in chaining code.
- */
-extern int chain_size;
-
 /*
  * Map the Core and Extended Oplock requesst bits down
  * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
@@ -1607,48 +1617,43 @@ extern int chain_size;
 #define BATCH_OPLOCK_TYPE(lck) ((lck) & (unsigned int)BATCH_OPLOCK)
 #define LEVEL_II_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)LEVEL_II_OPLOCK|(unsigned int)FAKE_LEVEL_II_OPLOCK))
 
-struct inform_level2_message {
-       SMB_DEV_T dev;
-       SMB_INO_T inode;
-       uint16 mid;
-       unsigned long target_file_id;
-       unsigned long source_file_id;
-};
-
 /* kernel_oplock_message definition.
 
 struct kernel_oplock_message {
-       SMB_DEV_T dev;
-       SMB_INO_T inode;
+       uint64_t dev;
+       uint64_t inode;
+       unit64_t extid;
        unsigned long file_id;
 };
 
 Offset  Data                  length.
-0     SMB_DEV_T dev           8 bytes.
-8     SMB_INO_T inode         8 bytes
-16    unsigned long file_id   4 bytes
-20
+0     uint64_t dev            8 bytes
+8     uint64_t inode          8 bytes
+16    uint64_t extid          8 bytes
+24    unsigned long file_id   4 bytes
+28
 
 */
-#define MSG_SMB_KERNEL_BREAK_SIZE 20
+#define MSG_SMB_KERNEL_BREAK_SIZE 28
 
 /* file_renamed_message definition.
 
 struct file_renamed_message {
-       SMB_DEV_T dev;
-       SMB_INO_T inode;
+       uint64_t dev;
+       uint64_t inode;
        char names[1]; A variable area containing sharepath and filename.
 };
 
 Offset  Data                   length.
-0      SMB_DEV_T dev           8 bytes.
-8      SMB_INO_T inode         8 bytes
-16     char [] name            zero terminated namelen bytes
-minimum length == 18.
+0      uint64_t dev            8 bytes
+8      uint64_t inode          8 bytes
+16      unit64_t extid          8 bytes
+24     char [] name            zero terminated namelen bytes
+minimum length == 24.
 
 */
 
-#define MSG_FILE_RENAMED_MIN_SIZE 16
+#define MSG_FILE_RENAMED_MIN_SIZE 24
 
 /*
  * On the wire return values for oplock types.
@@ -1676,14 +1681,50 @@ enum smbd_capability {
     LEASE_CAPABILITY
 };
 
+/*
+ * Kernel oplocks capability flags.
+ */
+
+/* Level 2 oplocks are supported natively by kernel oplocks. */
+#define KOPLOCKS_LEVEL2_SUPPORTED              0x1
+
+/* The kernel notifies deferred openers when they can retry the open. */
+#define KOPLOCKS_DEFERRED_OPEN_NOTIFICATION    0x2
+
+/* The kernel notifies smbds when an oplock break times out. */
+#define KOPLOCKS_TIMEOUT_NOTIFICATION          0x4
+
+/* The kernel notifies smbds when an oplock is broken. */
+#define KOPLOCKS_OPLOCK_BROKEN_NOTIFICATION    0x8
+
+struct kernel_oplocks_ops;
+struct kernel_oplocks {
+       const struct kernel_oplocks_ops *ops;
+       uint32_t flags;
+       void *private_data;
+};
+
+enum level2_contention_type {
+       LEVEL2_CONTEND_ALLOC_SHRINK,
+       LEVEL2_CONTEND_ALLOC_GROW,
+       LEVEL2_CONTEND_SET_FILE_LEN,
+       LEVEL2_CONTEND_FILL_SPARSE,
+       LEVEL2_CONTEND_WRITE,
+       LEVEL2_CONTEND_WINDOWS_BRL,
+       LEVEL2_CONTEND_POSIX_BRL
+};
+
 /* if a kernel does support oplocks then a structure of the following
    typee is used to describe how to interact with the kernel */
-struct kernel_oplocks {
-       files_struct * (*receive_message)(fd_set *fds);
-       bool (*set_oplock)(files_struct *fsp, int oplock_type);
-       void (*release_oplock)(files_struct *fsp);
-       bool (*msg_waiting)(fd_set *fds);
-       int notification_fd;
+struct kernel_oplocks_ops {
+       bool (*set_oplock)(struct kernel_oplocks *ctx,
+                          files_struct *fsp, int oplock_type);
+       void (*release_oplock)(struct kernel_oplocks *ctx,
+                              files_struct *fsp, int oplock_type);
+       void (*contend_level2_oplocks_begin)(files_struct *fsp,
+                                            enum level2_contention_type type);
+       void (*contend_level2_oplocks_end)(files_struct *fsp,
+                                          enum level2_contention_type type);
 };
 
 #include "smb_macros.h"
@@ -1786,18 +1827,6 @@ struct unix_error_map {
 
 #define SAFE_NETBIOS_CHARS ". -_"
 
-/* generic iconv conversion structure */
-typedef struct _smb_iconv_t {
-       size_t (*direct)(void *cd, const char **inbuf, size_t *inbytesleft,
-                        char **outbuf, size_t *outbytesleft);
-       size_t (*pull)(void *cd, const char **inbuf, size_t *inbytesleft,
-                      char **outbuf, size_t *outbytesleft);
-       size_t (*push)(void *cd, const char **inbuf, size_t *inbytesleft,
-                      char **outbuf, size_t *outbytesleft);
-       void *cd_direct, *cd_pull, *cd_push;
-       char *from_name, *to_name;
-} *smb_iconv_t;
-
 /* The maximum length of a trust account password.
    Used when we randomly create it, 15 char passwords
    exceed NT4's max password length */
@@ -1894,4 +1923,16 @@ struct smb_extended_info {
        char   samba_version_string[SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH];
 };
 
+/*
+ * create_file_flags
+ */
+#define CFF_DOS_PATH           0x00000001
+
+/* time info */
+struct smb_file_time {
+       struct timespec mtime;
+       struct timespec atime;
+       struct timespec create_time;
+};
+
 #endif /* _SMB_H */