r11895: - reorder some code to make it easier to follow, how the fields appear on...
authorStefan Metzmacher <metze@samba.org>
Fri, 25 Nov 2005 08:24:36 +0000 (08:24 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:46:43 +0000 (13:46 -0500)
- add some comments to the header file, to represent the wire format

metze

source/libcli/smb2/find.c
source/libcli/smb2/setinfo.c
source/libcli/smb2/smb2_calls.h
source/libcli/smb2/trans.c

index 273c3cad6ae3eaf54580b924f0733851e5304d96..aa14347022881871d4b5b441e5f59f890bc52584 100644 (file)
@@ -40,7 +40,6 @@ struct smb2_request *smb2_find_send(struct smb2_tree *tree, struct smb2_find *io
        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 @@ struct smb2_request *smb2_find_send(struct smb2_tree *tree, struct smb2_find *io
                return NULL;
        }
 
+       SIVAL(req->out.body, 0x1C, io->in.max_response_size);
+
        smb2_transport_send(req);
 
        return req;
index d6c5555a336e14bb4241a4e41ac88fdbc81f1eef..ce03a6948203dd6cc56535d9a32838df6ff2b290 100644 (file)
 */
 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);
 
index e0a78937d589aa5d2280fa0f6b9d415a04059d76..cd0e80f5ae8a00ef3e87663287b3d9a82325c073 100644 (file)
@@ -291,15 +291,27 @@ struct smb2_read {
 
 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_find {
 
 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;
-               DATA_BLOB in;
+
+               /* dynamic body */
                DATA_BLOB out;
+               DATA_BLOB in;
        } 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;
index cc03209c76c7fa189b8e353fabeb5f9c7c4f444f..de4ff1d827c31a10e0ef3c4cc0dc9ac439a05cd2 100644 (file)
@@ -37,12 +37,9 @@ struct smb2_request *smb2_trans_send(struct smb2_tree *tree, struct smb2_trans *
                                     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 @@ struct smb2_request *smb2_trans_send(struct smb2_tree *tree, struct smb2_trans *
                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 @@ NTSTATUS smb2_trans_recv(struct smb2_request *req,
 
        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 @@ NTSTATUS smb2_trans_recv(struct smb2_request *req,
                return status;
        }
 
-
        io->out.unknown2 = IVAL(req->in.body, 0x28);
        io->out.unknown3 = IVAL(req->in.body, 0x2C);