s3:smbd: move global oplocks vars to smbd_server_connection
[samba.git] / source3 / smbd / globals.h
index 77eed19289b10eeafca35002ee22a178bb52e616..f49cdbb473988447311cca2d938b8b3bc19f9f81 100644 (file)
@@ -108,19 +108,12 @@ extern struct vfs_init_function_entry *backends;
 extern char *sparse_buf;
 extern char *LastDir;
 
-/* Current number of oplocks we have outstanding. */
-extern int32_t exclusive_oplocks_open;
-extern int32_t level_II_oplocks_open;
 extern struct kernel_oplocks *koplocks;
 
-extern int am_parent;
-extern struct event_context *smbd_event_ctx;
-extern struct messaging_context *smbd_msg_ctx;
+struct smbd_parent_context;
+extern struct smbd_parent_context *am_parent;
 extern struct memcache *smbd_memcache_ctx;
 extern bool exit_firsttime;
-struct child_pid;
-extern struct child_pid *children;
-extern int num_children;
 
 struct tstream_context;
 struct smbd_smb2_request;
@@ -218,7 +211,6 @@ bool smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
 
 NTSTATUS smbd_calculate_access_mask(connection_struct *conn,
                                    const struct smb_filename *smb_fname,
-                                   bool file_existed,
                                    uint32_t access_mask,
                                    uint32_t *access_mask_out);
 
@@ -230,8 +222,6 @@ void smbd_server_connection_terminate_ex(struct smbd_server_connection *sconn,
 #define smbd_server_connection_terminate(sconn, reason) \
        smbd_server_connection_terminate_ex(sconn, reason, __location__)
 
-struct server_id sconn_server_id(const struct smbd_server_connection *sconn);
-
 const char *smb2_opcode_name(uint16_t opcode);
 bool smbd_is_smb2_header(const uint8_t *inbuf, size_t size);
 
@@ -259,11 +249,15 @@ NTSTATUS smbd_smb2_send_oplock_break(struct smbd_server_connection *sconn,
                                     uint8_t oplock_level);
 
 NTSTATUS smbd_smb2_request_pending_queue(struct smbd_smb2_request *req,
-                                        struct tevent_req *subreq);
+                                        struct tevent_req *subreq,
+                                        uint32_t defer_time);
 
 struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req);
 void remove_smb2_chained_fsp(files_struct *fsp);
 
+NTSTATUS smbd_smb2_request_verify_creditcharge(struct smbd_smb2_request *req,
+                                              uint32_t data_length);
+
 NTSTATUS smbd_smb2_request_verify_sizes(struct smbd_smb2_request *req,
                                        size_t expected_body_size);
 
@@ -329,6 +323,41 @@ bool push_deferred_open_message_smb2(struct smbd_smb2_request *smb2req,
                        char *private_data,
                        size_t priv_len);
 
+struct smbXsrv_connection {
+       struct smbd_server_connection *sconn;
+
+       const struct tsocket_address *local_address;
+       const struct tsocket_address *remote_address;
+       const char *remote_hostname;
+
+       struct tevent_context *ev_ctx;
+       struct messaging_context *msg_ctx;
+
+       enum protocol_types protocol;
+
+       struct {
+               struct {
+                       uint32_t capabilities;
+                       struct GUID guid;
+                       uint16_t security_mode;
+                       uint16_t num_dialects;
+                       uint16_t *dialects;
+               } client;
+               struct {
+                       uint32_t capabilities;
+                       struct GUID guid;
+                       uint16_t security_mode;
+                       uint16_t dialect;
+                       uint32_t max_trans;
+                       uint32_t max_read;
+                       uint32_t max_write;
+               } server;
+       } smb2;
+};
+
+NTSTATUS smbXsrv_connection_init_tables(struct smbXsrv_connection *conn,
+                                       enum protocol_types protocol);
+
 struct smbd_smb2_request {
        struct smbd_smb2_request *prev, *next;
 
@@ -416,7 +445,7 @@ struct smbd_smb2_session {
        struct smbd_server_connection *sconn;
        NTSTATUS status;
        uint64_t vuid;
-       struct auth_ntlmssp_state *auth_ntlmssp_state;
+       struct gensec_security *gensec_security;
        struct auth_session_info *session_info;
        DATA_BLOB session_key;
        bool do_signing;
@@ -450,33 +479,31 @@ struct smbd_server_connection {
        const struct tsocket_address *local_address;
        const struct tsocket_address *remote_address;
        const char *remote_hostname;
+       struct tevent_context *ev_ctx;
        struct messaging_context *msg_ctx;
+       struct sys_notify_context *sys_notify_ctx;
+       struct notify_context *notify_ctx;
        struct {
                bool got_session;
        } nbt;
        bool using_smb2;
        int trans_num;
 
-       /*
-        * Cache for calling poll(2) to avoid allocations in our
-        * central event loop
-        */
-       struct pollfd *pfds;
+       size_t num_users;
+       struct user_struct *users;
+
+       size_t num_connections;
+       struct connection_struct *connections;
 
+       size_t num_files;
        struct files_struct *files;
+
        struct bitmap *file_bmap;
        int real_max_open_files;
-       int files_used;
        struct fsp_singleton_cache fsp_fi_cache;
        unsigned long file_gen_counter;
        int first_file;
 
-       /* Try GENSEC hook */
-       bool use_gensec_hook;
-
-       /* number of open connections (tcons) */
-       int num_tcons_open;
-
        struct pending_message_list *deferred_open_queue;
 
 
@@ -489,6 +516,12 @@ struct smbd_server_connection {
 
        uint64_t num_requests;
 
+       /* Current number of oplocks we have outstanding. */
+       struct {
+               int32_t exclusive_open;
+               int32_t level_II_open;
+       } oplocks;
+
        struct {
                struct fd_event *fde;
 
@@ -519,7 +552,7 @@ struct smbd_server_connection {
                struct {
                        bool encrypted_passwords;
                        bool spnego;
-                       struct auth_context *auth_context;
+                       struct auth4_context *auth_context;
                        bool done;
                        /*
                         * Size of the data we can receive. Set by us.
@@ -545,26 +578,17 @@ struct smbd_server_connection {
                        int max_send;
                        uint16_t last_session_tag;
 
-                       /* users from session setup */
-                       char *session_userlist;
-                       /* workgroup from session setup. */
-                       char *session_workgroup;
                        /*
                         * this holds info on user ids that are already
                         * validated for this VC
                         */
-                       user_struct *validated_users;
                        uint16_t next_vuid;
-                       int num_validated_vuids;
                } sessions;
                struct {
-                       connection_struct *Connections;
                        /* number of open connections */
                        struct bitmap *bmap;
                } tcons;
                struct smb_signing_state *signing_state;
-               /* List to store partial SPNEGO auth fragments. */
-               struct pending_auth_data *pd_list;
 
                struct notify_mid_map *notify_mid_maps;
 
@@ -582,7 +606,6 @@ struct smbd_server_connection {
                } locks;
        } smb1;
        struct {
-               struct tevent_context *event_ctx;
                struct tevent_queue *recv_queue;
                struct tevent_queue *send_queue;
                struct tstream_context *stream;
@@ -610,13 +633,14 @@ struct smbd_server_connection {
                uint32_t max_trans;
                uint32_t max_read;
                uint32_t max_write;
+               bool supports_multicredit;
                struct bitmap *credits_bitmap;
                bool compound_related_in_progress;
        } smb2;
-};
 
-extern struct smbd_server_connection *smbd_server_conn;
+       struct smbXsrv_connection *conn;
+};
 
-struct smbd_server_connection *msg_ctx_to_sconn(struct messaging_context *msg_ctx);
+extern struct smbXsrv_connection *global_smbXsrv_connection;
 
 void smbd_init_globals(void);