svn commit: samba r11895 - in branches/SAMBA_4_0/source/libcli/smb2: .

metze at samba.org metze at samba.org
Fri Nov 25 08:24:37 GMT 2005


Author: metze
Date: 2005-11-25 08:24:36 +0000 (Fri, 25 Nov 2005)
New Revision: 11895

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11895

Log:
- reorder some code to make it easier to follow, how the fields appear on the wire
- add some comments to the header file, to represent the wire format

metze
Modified:
   branches/SAMBA_4_0/source/libcli/smb2/find.c
   branches/SAMBA_4_0/source/libcli/smb2/setinfo.c
   branches/SAMBA_4_0/source/libcli/smb2/smb2_calls.h
   branches/SAMBA_4_0/source/libcli/smb2/trans.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/smb2/find.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/smb2/find.c	2005-11-25 06:50:29 UTC (rev 11894)
+++ branches/SAMBA_4_0/source/libcli/smb2/find.c	2005-11-25 08:24:36 UTC (rev 11895)
@@ -40,7 +40,6 @@
 	SCVAL(req->out.body, 0x03, io->in.continue_flags);
 	SIVAL(req->out.body, 0x04, io->in.unknown);
 	smb2_push_handle(req->out.body+0x08, &io->in.handle);
-	SIVAL(req->out.body, 0x1C, io->in.max_response_size);
 
 	status = smb2_push_o16s16_string(&req->out, 0x18, io->in.pattern);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -48,6 +47,8 @@
 		return NULL;
 	}
 
+	SIVAL(req->out.body, 0x1C, io->in.max_response_size);
+
 	smb2_transport_send(req);
 
 	return req;

Modified: branches/SAMBA_4_0/source/libcli/smb2/setinfo.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/smb2/setinfo.c	2005-11-25 06:50:29 UTC (rev 11894)
+++ branches/SAMBA_4_0/source/libcli/smb2/setinfo.c	2005-11-25 08:24:36 UTC (rev 11895)
@@ -30,13 +30,20 @@
 */
 struct smb2_request *smb2_setinfo_send(struct smb2_tree *tree, struct smb2_setinfo *io)
 {
+	NTSTATUS status;
 	struct smb2_request *req;
 
 	req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, io->in.blob.length);
 	if (req == NULL) return NULL;
 
 	SSVAL(req->out.body, 0x02, io->in.level);
-	smb2_push_s32o32_blob(&req->out, 0x04, io->in.blob);
+
+	status = smb2_push_s32o32_blob(&req->out, 0x04, io->in.blob);
+	if (!NT_STATUS_IS_OK(status)) {
+		talloc_free(req);
+		return NULL;
+	}
+
 	SIVAL(req->out.body, 0x0C, io->in.flags);
 	smb2_push_handle(req->out.body+0x10, &io->in.handle);
 

Modified: branches/SAMBA_4_0/source/libcli/smb2/smb2_calls.h
===================================================================
--- branches/SAMBA_4_0/source/libcli/smb2/smb2_calls.h	2005-11-25 06:50:29 UTC (rev 11894)
+++ branches/SAMBA_4_0/source/libcli/smb2/smb2_calls.h	2005-11-25 08:24:36 UTC (rev 11895)
@@ -291,15 +291,27 @@
 
 struct smb2_find {
 	struct {
+		/* static body buffer 32 (0x20) bytes */
+		/* uint16_t buffer_code;  0x21 = 0x20 + 1 */
 		uint8_t level;
 		uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */
 		uint32_t unknown; /* perhaps a continue token? */
 		struct smb2_handle handle;
+		/* uint16_t pattern_ofs; */
+		/* uint32_t pattern_size; */
 		uint32_t max_response_size;
+
+		/* dynamic body */
 		const char *pattern;
 	} in;
 
 	struct {
+		/* static body buffer 8 (0x08) bytes */
+		/* uint16_t buffer_code;  0x08 */
+		/* uint16_t blob_ofs; */
+		/* uint32_t blob_size; */
+
+		/* dynamic body */
 		DATA_BLOB blob;
 	} out;
 };
@@ -308,20 +320,38 @@
 
 struct smb2_trans {
 	struct {
+		/* static body buffer 56 (0x38) bytes */
+		/* uint16_t buffer_code;  0x39 = 0x38 + 1 */
+		uint16_t _pad;
 		uint32_t pipe_flags;
 		struct smb2_handle handle;
+		/* uint32_t out_ofs; */
+		/* uint32_t out_size; */
 		uint32_t unknown2;
+		/* uint32_t in_ofs; */
+		/* uint32_t in_size; */
 		uint32_t max_response_size;
 		uint64_t flags;
+
+		/* dynamic body */
+		DATA_BLOB out;
 		DATA_BLOB in;
-		DATA_BLOB out;
 	} in;
 
 	struct {
-		uint32_t unknown1;
+		/* static body buffer 48 (0x30) bytes */
+		/* uint16_t buffer_code;  0x31 = 0x30 + 1 */
+		uint16_t _pad;
+		uint32_t pipe_flags;
 		struct smb2_handle handle;
+		/* uint32_t in_ofs; */
+		/* uint32_t in_size; */
+		/* uint32_t out_ofs; */
+		/* uint32_t out_size; */
 		uint32_t unknown2;
 		uint32_t unknown3;
+
+		/* dynamic body */
 		DATA_BLOB in;
 		DATA_BLOB out;
 	} out;

Modified: branches/SAMBA_4_0/source/libcli/smb2/trans.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/smb2/trans.c	2005-11-25 06:50:29 UTC (rev 11894)
+++ branches/SAMBA_4_0/source/libcli/smb2/trans.c	2005-11-25 08:24:36 UTC (rev 11895)
@@ -37,12 +37,9 @@
 				     io->in.in.length+io->in.out.length);
 	if (req == NULL) return NULL;
 
-	SSVAL(req->out.body, 0x02, 0); /* pad */
+	SSVAL(req->out.body, 0x02, io->in._pad);
 	SIVAL(req->out.body, 0x04, io->in.pipe_flags);
 	smb2_push_handle(req->out.body+0x08, &io->in.handle);
-	SIVAL(req->out.body, 0x20, io->in.unknown2);
-	SIVAL(req->out.body, 0x2C, io->in.max_response_size);
-	SBVAL(req->out.body, 0x30, io->in.flags);
 
 	status = smb2_push_o32s32_blob(&req->out, 0x18, io->in.out);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -50,12 +47,17 @@
 		return NULL;
 	}
 
+	SIVAL(req->out.body, 0x20, io->in.unknown2);
+
 	status = smb2_push_o32s32_blob(&req->out, 0x24, io->in.in);
 	if (!NT_STATUS_IS_OK(status)) {
 		talloc_free(req);
 		return NULL;
 	}
 
+	SIVAL(req->out.body, 0x2C, io->in.max_response_size);
+	SBVAL(req->out.body, 0x30, io->in.flags);
+
 	smb2_transport_send(req);
 
 	return req;
@@ -77,8 +79,10 @@
 
 	SMB2_CHECK_PACKET_RECV(req, 0x30, True);
 
-	io->out.unknown1 = IVAL(req->in.body, 0x04);
+	io->out._pad       = SVAL(req->in.body, 0x02);
+	io->out.pipe_flags = IVAL(req->in.body, 0x04);
 	smb2_pull_handle(req->in.body+0x08, &io->out.handle);
+
 	status = smb2_pull_o32s32_blob(&req->in, mem_ctx, req->in.body+0x18, &io->out.in);
 	if (!NT_STATUS_IS_OK(status)) {
 		smb2_request_destroy(req);
@@ -91,7 +95,6 @@
 		return status;
 	}
 
-
 	io->out.unknown2 = IVAL(req->in.body, 0x28);
 	io->out.unknown3 = IVAL(req->in.body, 0x2C);
 



More information about the samba-cvs mailing list