s4:librpc/rpc: don't ask for auth_length if we ask for auth data only
[sharpe/samba-autobuild/.git] / source4 / smb_server / smb_server.h
index ac3e0f3bd3d48da003d436768d18c487dbcd6cc4..40af4a64bb36fd95e4ec6951faa1d435376d1d84 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 */
@@ -258,8 +266,6 @@ struct smbsrv_request {
        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 
  */
@@ -293,7 +299,7 @@ struct smbsrv_connection {
                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,13 +361,15 @@ 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 */
        struct {
-               enum security_types security;
                bool nt_status_support;
        } config;
 
@@ -377,16 +385,19 @@ struct smbsrv_connection {
 
        struct loadparm_context *lp_ctx;
 
-       bool doing_signing;
+       bool smb2_signing_required;
+
+       uint64_t highest_smb2_seqnum;
 };
 
 struct model_ops;
 struct loadparm_context;
 
-NTSTATUS smbsrv_add_socket(struct event_context *event_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);
+                          const struct model_ops *model_ops,
+                          const char *address);
 
 struct loadparm_context;
 
@@ -464,7 +475,7 @@ struct loadparm_context;
 #define SMBSRV_CALL_NTVFS_BACKEND(cmd) do { \
        req->ntvfs->async_states->status = cmd; \
        if (req->ntvfs->async_states->state & NTVFS_ASYNC_STATE_ASYNC) { \
-               DLIST_ADD_END(req->smb_conn->requests, req, struct smbsrv_request *); \
+               DLIST_ADD_END(req->smb_conn->requests, req); \
        } else { \
                req->ntvfs->async_states->send_fn(req->ntvfs); \
        } \
@@ -473,6 +484,11 @@ struct loadparm_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; \
@@ -484,6 +500,11 @@ struct loadparm_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; \
@@ -496,3 +517,5 @@ struct loadparm_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"