{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.flags);
NTSTATUS status;
DATA_BLOB blob = data_blob(NULL, 0);
- req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, 1);
+ req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, True, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.oplock_flags);
struct smb2_request *req;
NTSTATUS status;
- req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, 1);
+ req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, True, 0);
if (req == NULL) return NULL;
SCVAL(req->out.body, 0x02, io->in.level);
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0); /* pad? */
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, False, 0);
if (req == NULL) return NULL;
/* this seems to be a bug, they use 0x29 but only send 0x28 bytes */
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38,
+ req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38, True,
io->in.in.length+io->in.out.length);
if (req == NULL) return NULL;
{
struct smb2_request *req;
- req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, 0);
+ req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0);
{
struct smb2_request *req;
- req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, 0);
+ req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, False, 0);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
{
struct smb2_request *req;
- req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, 0);
+ req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, False, 0);
if (req == NULL) return NULL;
/* this seems to be a bug, they use 0x24 but the length is 0x26 */
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x31, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x31, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0); /* pad */
initialise a smb2 request
*/
struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_t opcode,
- uint16_t body_fixed_size, uint32_t body_dynamic_size)
+ uint16_t body_fixed_size, BOOL body_dynamic_present,
+ uint32_t body_dynamic_size)
{
struct smb2_request *req;
+ if (body_dynamic_present) {
+ if (body_dynamic_size == 0) {
+ body_dynamic_size = 1;
+ }
+ } else {
+ body_dynamic_size = 0;
+ }
+
req = talloc(transport, struct smb2_request);
if (req == NULL) return NULL;
initialise a smb2 request for tree operations
*/
struct smb2_request *smb2_request_init_tree(struct smb2_tree *tree, uint16_t opcode,
- uint16_t body_fixed_size, uint32_t body_dynamic_size)
+ uint16_t body_fixed_size, BOOL body_dynamic_present,
+ uint32_t body_dynamic_size)
{
struct smb2_request *req = smb2_request_init(tree->session->transport, opcode,
- body_fixed_size, body_dynamic_size);
+ body_fixed_size, body_dynamic_present,
+ body_dynamic_size);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
NTSTATUS status;
req = smb2_request_init(session->transport, SMB2_OP_SESSSETUP,
- 0x10, io->in.secblob.length);
+ 0x10, True, io->in.secblob.length);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, io->in.blob.length);
+ req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, True, io->in.blob.length);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.level);
NTSTATUS status;
req = smb2_request_init(tree->session->transport, SMB2_OP_TCON,
- 0x08, 1);
+ 0x08, True, 0);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0);
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, io->in.data.length);
+ req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, True, io->in.data.length);
if (req == NULL) return NULL;
status = smb2_push_o16s32_blob(&req->out, 0x02, io->in.data);
return;
}
- status = smb2srv_setup_reply(req, 0x04, 0);
+ status = smb2srv_setup_reply(req, 0x04, False, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
return;
}
- status = smb2srv_setup_reply(req, 0x40, io->out.secblob.length);
+ status = smb2srv_setup_reply(req, 0x40, True, io->out.secblob.length);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
return req;
}
-NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint_t body_fixed_size, size_t body_dynamic_size)
+NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint16_t body_fixed_size,
+ BOOL body_dynamic_present, uint32_t body_dynamic_size)
{
+ if (body_dynamic_present) {
+ if (body_dynamic_size == 0) {
+ body_dynamic_size = 1;
+ }
+ } else {
+ body_dynamic_size = 0;
+ }
+
req->out.size = SMB2_HDR_BODY+NBT_HDR_SIZE+body_fixed_size;
req->out.allocated = req->out.size + body_dynamic_size;
{
NTSTATUS status;
- status = smb2srv_setup_reply(req, 8, 1);
+ status = smb2srv_setup_reply(req, 8, True, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
return;
}
- status = smb2srv_setup_reply(req, 0x08, io->out.secblob.length);
+ status = smb2srv_setup_reply(req, 0x08, True, io->out.secblob.length);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
return;
}
- status = smb2srv_setup_reply(req, 0x04, 0);
+ status = smb2srv_setup_reply(req, 0x04, False, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
return;
}
- status = smb2srv_setup_reply(req, 0x10, 0);
+ status = smb2srv_setup_reply(req, 0x10, False, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
return;
}
- status = smb2srv_setup_reply(req, 0x04, 0);
+ status = smb2srv_setup_reply(req, 0x04, False, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
tree->session->transport->options.timeout = 3;
for (opcode=0;opcode<1000;opcode++) {
- req = smb2_request_init_tree(tree, opcode, 2, 0);
+ req = smb2_request_init_tree(tree, opcode, 2, False, 0);
SSVAL(req->out.body, 0, 0);
smb2_transport_send(req);
if (!smb2_request_receive(req)) {