libds: moved enum security_types to a common header
[samba.git] / source4 / smb_server / smb_server.h
index 8ebd3e683fbe5a830f7814934037a18c09e2b8d4..6fcd9787bb705876fac37983d59afc73744fa40d 100644 (file)
 
 #include "libcli/raw/request.h"
 #include "libcli/raw/interfaces.h"
-#include "lib/events/events.h"
 #include "lib/socket/socket.h"
-#include "lib/util/dlinklist.h"
+#include "libds/common/roles.h"
+#include "../lib/util/dlinklist.h"
+#include "../librpc/gen_ndr/nbt.h"
+
+struct tevent_context;
 
 /*
   this header declares the core context structures associated with smb
@@ -100,6 +103,11 @@ struct smbsrv_session {
 
        struct auth_session_info *session_info;
 
+       struct {
+               bool required;
+               bool active;
+       } smb2_signing;
+
        /* some statistics for the management tools */
        struct {
                /* the time when the session setup started */
@@ -254,12 +262,10 @@ struct smbsrv_request {
        /* the sequence number for signing */
        uint64_t seq_num;
 
-       struct request_buffer in;
-       struct request_buffer out;
+       struct smb_request_buffer in;
+       struct smb_request_buffer out;
 };
 
-enum security_types {SEC_SHARE,SEC_USER};
-
 /* smb server context structure. This should contain all the state
  * information associated with a SMB server connection 
  */
@@ -291,9 +297,9 @@ struct smbsrv_connection {
        
                /* the negotiatiated protocol */
                enum protocol_types protocol;
-       
+
                /* authentication context for multi-part negprot */
-               struct auth_context *auth_context;
+               struct auth4_context *auth_context;
        
                /* reference to the kerberos keytab, or machine trust account */
                struct cli_credentials *server_credentials;
@@ -355,8 +361,11 @@ struct smbsrv_connection {
        struct smbsrv_trans_partial {
                struct smbsrv_trans_partial *next, *prev;
                struct smbsrv_request *req;
-               struct smb_trans2 *trans;
                uint8_t command;
+               union {
+                       struct smb_trans2 *trans;
+                       struct smb_nttrans *nttrans;
+               } u;
        } *trans_partial;
 
        /* configuration parameters */
@@ -374,13 +383,24 @@ struct smbsrv_connection {
        } statistics;
 
        struct share_context *share_context;
+
+       struct loadparm_context *lp_ctx;
+
+       bool smb2_signing_required;
+
+       uint64_t highest_smb2_seqnum;
 };
 
 struct model_ops;
+struct loadparm_context;
+
+NTSTATUS smbsrv_add_socket(TALLOC_CTX *mem_ctx,
+                          struct tevent_context *event_context,
+                          struct loadparm_context *lp_ctx,
+                          const struct model_ops *model_ops,
+                          const char *address);
 
-NTSTATUS smbsrv_add_socket(struct event_context *event_context,
-                              const struct model_ops *model_ops,
-                              const char *address);
+struct loadparm_context;
 
 #include "smb_server/smb_server_proto.h"
 #include "smb_server/smb/smb_proto.h"
@@ -465,6 +485,11 @@ NTSTATUS smbsrv_add_socket(struct event_context *event_context,
 /* check req->ntvfs->async_states->status and if not OK then send an error reply */
 #define SMBSRV_CHECK_ASYNC_STATUS_ERR_SIMPLE do { \
        req = talloc_get_type(ntvfs->async_states->private_data, struct smbsrv_request); \
+       if (ntvfs->async_states->state & NTVFS_ASYNC_STATE_CLOSE || NT_STATUS_EQUAL(ntvfs->async_states->status, NT_STATUS_NET_WRITE_FAULT)) { \
+               smbsrv_terminate_connection(req->smb_conn, get_friendly_nt_error_msg (ntvfs->async_states->status)); \
+               talloc_free(req); \
+               return; \
+       } \
        if (NT_STATUS_IS_ERR(ntvfs->async_states->status)) { \
                smbsrv_send_error(req, ntvfs->async_states->status); \
                return; \
@@ -476,6 +501,11 @@ NTSTATUS smbsrv_add_socket(struct event_context *event_context,
 } while (0)
 #define SMBSRV_CHECK_ASYNC_STATUS_SIMPLE do { \
        req = talloc_get_type(ntvfs->async_states->private_data, struct smbsrv_request); \
+       if (ntvfs->async_states->state & NTVFS_ASYNC_STATE_CLOSE || NT_STATUS_EQUAL(ntvfs->async_states->status, NT_STATUS_NET_WRITE_FAULT)) { \
+               smbsrv_terminate_connection(req->smb_conn, get_friendly_nt_error_msg (ntvfs->async_states->status)); \
+               talloc_free(req); \
+               return; \
+       } \
        if (!NT_STATUS_IS_OK(ntvfs->async_states->status)) { \
                smbsrv_send_error(req, ntvfs->async_states->status); \
                return; \
@@ -488,3 +518,5 @@ NTSTATUS smbsrv_add_socket(struct event_context *event_context,
 
 /* zero out some reserved fields in a reply */
 #define SMBSRV_VWV_RESERVED(start, count) memset(req->out.vwv + VWV(start), 0, (count)*2)
+
+#include "smb_server/service_smb_proto.h"