Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include "smb.h"
+
struct smb2_options {
uint32_t timeout;
};
struct smb2_transport *transport;
struct gensec_security *gensec;
uint64_t uid;
+ DATA_BLOB session_key;
};
/* 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;
};
};
-#define SMB2_MIN_SIZE 0x40
+#define SMB2_MIN_SIZE 0x42
/* offsets into header elements */
#define SMB2_HDR_LENGTH 0x04
/* 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
#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"