r12694: Move some headers to the directory of the subsystem they belong to.
[samba.git] / source4 / libcli / smb2 / smb2.h
index e99e8d39453c3487ca91a34575e94882f488ccb3..cf84f344422070182b47c04332a044e991c7f1ef 100644 (file)
@@ -20,6 +20,8 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include "smb.h"
+
 struct smb2_options {
        uint32_t timeout;
 };
@@ -66,6 +68,7 @@ struct smb2_session {
        struct smb2_transport *transport;
        struct gensec_security *gensec;
        uint64_t uid;
+       DATA_BLOB session_key;
 };
 
 
@@ -87,13 +90,11 @@ struct smb2_request_buffer {
        /* the packet body */
        uint8_t *body;
        uint_t body_size;
-       
-       /* ptr is used as a moving pointer into the data area
-        * of the packet. The reason its here and not a local
-        * variable in each function is that when a realloc of
-        * a send packet is done we need to move this
-        * pointer */
-       uint8_t *ptr;
+
+       /* this point to the next dynamic byte that can be used
+        * this will be moved when some dynamic data is pushed
+        */
+       uint8_t *dynamic;
 };
 
 
@@ -140,7 +141,7 @@ struct smb2_request {
 };
 
 
-#define SMB2_MIN_SIZE 0x40
+#define SMB2_MIN_SIZE 0x42
 
 /* offsets into header elements */
 #define SMB2_HDR_LENGTH  0x04
@@ -160,13 +161,18 @@ struct smb2_request {
 /* SMB2 opcodes */
 #define SMB2_OP_NEGPROT   0x00
 #define SMB2_OP_SESSSETUP 0x01
+#define SMB2_OP_LOGOFF    0x02
 #define SMB2_OP_TCON      0x03
 #define SMB2_OP_TDIS      0x04
 #define SMB2_OP_CREATE    0x05
 #define SMB2_OP_CLOSE     0x06
+#define SMB2_OP_FLUSH     0x07
 #define SMB2_OP_READ      0x08
 #define SMB2_OP_WRITE     0x09
+#define SMB2_OP_LOCK      0x0a
+#define SMB2_OP_IOCTL     0x0b
 #define SMB2_OP_CANCEL    0x0c
+#define SMB2_OP_KEEPALIVE 0x0d
 #define SMB2_OP_FIND      0x0e
 #define SMB2_OP_NOTIFY    0x0f
 #define SMB2_OP_GETINFO   0x10
@@ -176,13 +182,22 @@ struct smb2_request {
 #define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */
 
 /*
-  check that a buffer code matches the expected value
+  check that a body has the expected size
 */
-#define SMB2_CHECK_BUFFER_CODE(req, code) do { \
-       io->out.buffer_code = SVAL(req->in.body, 0); \
-       if (io->out.buffer_code != (code)) { \
-               DEBUG(0,("Unexpected buffer code 0x%x. Expected 0x%x\n", \
-                        io->out.buffer_code, code)); \
+#define SMB2_CHECK_PACKET_RECV(req, size, dynamic) do { \
+       uint_t is_size = req->in.body_size; \
+       uint16_t field_size = SVAL(req->in.body, 0); \
+       uint16_t want_size = ((dynamic)?(size)+1:(size)); \
+       if (is_size < (size)) { \
+               DEBUG(0,("%s: buffer too small 0x%x. Expected 0x%x\n", \
+                        __location__, is_size, want_size)); \
+               return NT_STATUS_BUFFER_TOO_SMALL; \
+       }\
+       if (field_size != want_size) { \
+               DEBUG(0,("%s: unexpected fixed body size 0x%x. Expected 0x%x\n", \
+                        __location__, field_size, want_size)); \
                return NT_STATUS_INVALID_PARAMETER; \
        } \
 } while (0)
+
+#include "libcli/smb2/smb2_proto.h"