Fix SMB2_CAP_DFS
[ira/wip.git] / source4 / libcli / smb2 / smb2.h
index ae66a6e0d3bd898916fcc36bf03d2924797b0b38..98e3c5b9316167dca5b51302b2e18393b06a5891 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifndef __LIBCLI_SMB2_SMB2_H__
+#define __LIBCLI_SMB2_SMB2_H__
+
 #include "libcli/raw/request.h"
+#include "libcli/raw/libcliraw.h"
 
 struct smb2_handle;
-
-struct smb2_options {
-       uint32_t timeout;
-};
+struct smb2_lease_break;
 
 /*
-  information returned from the negotiate response
+  information returned from the negotiate process
 */
 struct smb2_negotiate {
        DATA_BLOB secblob;
+       NTTIME system_time;
+       NTTIME server_start_time;
+       uint16_t security_mode;
+       uint16_t dialect_revision;
 };
 
 /* this is the context for the smb2 transport layer */
@@ -39,7 +44,6 @@ struct smb2_transport {
        /* socket level info */
        struct smbcli_socket *socket;
 
-       struct smb2_options options;
        struct smb2_negotiate negotiate;
 
        /* next seqnum to allocate */
@@ -57,7 +61,7 @@ struct smb2_transport {
           for a packet */
        struct {
                void (*func)(struct smb2_transport *, void *);
-               void *private;
+               void *private_data;
                uint_t period;
        } idle;
 
@@ -69,6 +73,19 @@ struct smb2_transport {
                /* private data passed to the oplock handler */
                void *private_data;
        } oplock;
+
+       struct {
+               /* a lease break request handler */
+               bool (*handler)(struct smb2_transport *transport,
+                               const struct smb2_lease_break *lease_break,
+                               void *private_data);
+               /* private data passed to the oplock handler */
+               void *private_data;
+       } lease;
+
+       struct smbcli_options options;
+
+       bool signing_required;
 };
 
 
@@ -88,6 +105,7 @@ struct smb2_session {
        struct gensec_security *gensec;
        uint64_t uid;
        DATA_BLOB session_key;
+       bool signing_active;
 };
 
 
@@ -165,12 +183,13 @@ struct smb2_request {
        */
        struct {
                void (*fn)(struct smb2_request *);
-               void *private;
+               void *private_data;
        } async;
 };
 
 
 #define SMB2_MIN_SIZE 0x42
+#define SMB2_MIN_SIZE_NO_BODY 0x40
 
 /* offsets into header elements for a sync SMB2 request */
 #define SMB2_HDR_PROTOCOL_ID    0x00
@@ -188,6 +207,13 @@ struct smb2_request {
 #define SMB2_HDR_SIGNATURE     0x30 /* 16 bytes */
 #define SMB2_HDR_BODY          0x40
 
+/* header flags */
+#define SMB2_HDR_FLAG_REDIRECT  0x01
+#define SMB2_HDR_FLAG_ASYNC     0x02
+#define SMB2_HDR_FLAG_CHAINED   0x04
+#define SMB2_HDR_FLAG_SIGNED    0x08
+#define SMB2_HDR_FLAG_DFS       0x10000000
+
 /* SMB2 opcodes */
 #define SMB2_OP_NEGPROT   0x00
 #define SMB2_OP_SESSSETUP 0x01
@@ -211,15 +237,17 @@ struct smb2_request {
 
 #define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */
 
-/* the dialect we support */
+/* the dialects we support */
 #define SMB2_DIALECT_REVISION           0x202
+#define SMB21_DIALECT_REVISION          0x210
+#define SMB2_LONGHORN_BETA_DIALECT_REVISION    0x0 /* early beta dialect */
 
 /* SMB2 negotiate security_mode */
 #define SMB2_NEGOTIATE_SIGNING_ENABLED   0x01
 #define SMB2_NEGOTIATE_SIGNING_REQUIRED  0x02
 
 /* SMB2 capabilities - only 1 so far. I'm sure more will be added */
-#define SMB2_CAP_DFS                     0x0
+#define SMB2_CAP_DFS                     0x00000001
 /* so we can spot new caps as added */
 #define SMB2_CAP_ALL                     SMB2_CAP_DFS 
 
@@ -245,6 +273,16 @@ struct smb2_request {
 #define SMB2_OPLOCK_LEVEL_II                             0x01
 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE                      0x08
 #define SMB2_OPLOCK_LEVEL_BATCH                          0x09
+#define SMB2_OPLOCK_LEVEL_LEASE                          0xFF
+
+/* SMB2 lease bits */
+#define SMB2_LEASE_NONE                                  0x00
+#define SMB2_LEASE_READ                                  0x01
+#define SMB2_LEASE_HANDLE                                0x02
+#define SMB2_LEASE_WRITE                                 0x04
+
+/* SMB2 lease break flags */
+#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED        0x01
 
 /* SMB2 impersonation levels */
 #define SMB2_IMPERSONATION_ANONYMOUS                     0x00
@@ -261,8 +299,11 @@ struct smb2_request {
 #define SMB2_CREATE_TAG_ALSI "AlSi"
 #define SMB2_CREATE_TAG_TWRP "TWrp"
 #define SMB2_CREATE_TAG_QFID "QFid"
+#define SMB2_CREATE_TAG_RQLS "RqLs"
 
-
+/* SMB2 Create ignore some more create_options */
+#define SMB2_CREATE_OPTIONS_NOT_SUPPORTED_MASK (NTCREATEX_OPTIONS_TREE_CONNECTION | \
+                                                NTCREATEX_OPTIONS_OPFILTER)
 
 /*
   check that a body has the expected size
@@ -282,3 +323,5 @@ struct smb2_request {
                return NT_STATUS_INVALID_PARAMETER; \
        } \
 } while (0)
+
+#endif