libcli/smb: Change smb2cli_create() and smb2cli_create_recv() to return a parameter...
authorJeremy Allison <jra@samba.org>
Wed, 7 Aug 2013 22:01:50 +0000 (15:01 -0700)
committerStefan Metzmacher <metze@samba.org>
Thu, 15 Aug 2013 07:07:06 +0000 (09:07 +0200)
Will use in the smb2 client code.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
libcli/smb/smb2_create_blob.h
libcli/smb/smb2cli_create.c
libcli/smb/smbXcli_base.h
source3/libsmb/cli_np_tstream.c
source3/torture/test_smb2.c

index 008befe41a56d99bc1393aa4a17bd2c3a3e87fe5..2f915b3afefed52cfaabfc7f6e7909de22889f0f 100644 (file)
@@ -33,6 +33,18 @@ struct smb2_create_blobs {
        struct smb2_create_blob *blobs;
 };
 
+struct smb2_create_returns {
+       uint8_t oplock_level;
+       uint32_t create_action;
+       NTTIME creation_time;
+       NTTIME last_access_time;
+       NTTIME last_write_time;
+       NTTIME change_time;
+       uint64_t allocation_size;
+       uint64_t end_of_file;
+       uint32_t file_attributes;
+};
+
 /*
   parse a set of SMB2 create blobs
 */
index 627bdcb9353d7fcc9c134d493d07f7a957bc0448..020a4685cbcc8ec57903a46c964ff55737ddc030 100644 (file)
 struct smb2cli_create_state {
        uint8_t fixed[56];
 
-       uint8_t oplock_level;
-       uint32_t create_action;
-       NTTIME creation_time;
-       NTTIME last_access_time;
-       NTTIME last_write_time;
-       NTTIME change_time;
-       uint64_t allocation_size;
-       uint64_t end_of_file;
-       uint32_t file_attributes;
        uint64_t fid_persistent;
        uint64_t fid_volatile;
+       struct smb2_create_returns cr;
        struct smb2_create_blobs blobs;
 };
 
@@ -179,15 +171,15 @@ static void smb2cli_create_done(struct tevent_req *subreq)
 
        body = (uint8_t *)iov[1].iov_base;
 
-       state->oplock_level     = CVAL(body, 2);
-       state->create_action    = IVAL(body, 4);
-       state->creation_time    = BVAL(body, 8);
-       state->last_access_time = BVAL(body, 16);
-       state->last_write_time  = BVAL(body, 24);
-       state->change_time      = BVAL(body, 32);
-       state->allocation_size  = BVAL(body, 40);
-       state->end_of_file      = BVAL(body, 48);
-       state->file_attributes  = IVAL(body, 56);
+       state->cr.oplock_level  = CVAL(body, 2);
+       state->cr.create_action = IVAL(body, 4);
+       state->cr.creation_time = BVAL(body, 8);
+       state->cr.last_access_time = BVAL(body, 16);
+       state->cr.last_write_time = BVAL(body, 24);
+       state->cr.change_time   = BVAL(body, 32);
+       state->cr.allocation_size = BVAL(body, 40);
+       state->cr.end_of_file   = BVAL(body, 48);
+       state->cr.file_attributes = IVAL(body, 56);
        state->fid_persistent   = BVAL(body, 64);
        state->fid_volatile     = BVAL(body, 72);
 
@@ -213,7 +205,8 @@ static void smb2cli_create_done(struct tevent_req *subreq)
 
 NTSTATUS smb2cli_create_recv(struct tevent_req *req,
                             uint64_t *fid_persistent,
-                            uint64_t *fid_volatile)
+                            uint64_t *fid_volatile,
+                            struct smb2_create_returns *cr)
 {
        struct smb2cli_create_state *state =
                tevent_req_data(req,
@@ -225,6 +218,9 @@ NTSTATUS smb2cli_create_recv(struct tevent_req *req,
        }
        *fid_persistent = state->fid_persistent;
        *fid_volatile = state->fid_volatile;
+       if (cr) {
+               *cr = state->cr;
+       }
        return NT_STATUS_OK;
 }
 
@@ -242,7 +238,8 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
                        uint32_t create_options,
                        struct smb2_create_blobs *blobs,
                        uint64_t *fid_persistent,
-                       uint64_t *fid_volatile)
+                       uint64_t *fid_volatile,
+                       struct smb2_create_returns *cr)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
@@ -273,7 +270,7 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
        if (!tevent_req_poll_ntstatus(req, ev, &status)) {
                goto fail;
        }
-       status = smb2cli_create_recv(req, fid_persistent, fid_volatile);
+       status = smb2cli_create_recv(req, fid_persistent, fid_volatile, cr);
  fail:
        TALLOC_FREE(frame);
        return status;
index 997869ba0799581560c8647bcdb2e83b173ec0de..a497e1376f9fe152cafe22cecc7e485bfff1763a 100644 (file)
@@ -28,6 +28,7 @@ struct smb_trans_enc_state;
 struct GUID;
 struct iovec;
 struct smb2_create_blobs;
+struct smb2_create_returns;
 
 struct smbXcli_conn *smbXcli_conn_create(TALLOC_CTX *mem_ctx,
                                         int fd,
@@ -353,7 +354,8 @@ struct tevent_req *smb2cli_create_send(
        struct smb2_create_blobs *blobs);
 NTSTATUS smb2cli_create_recv(struct tevent_req *req,
                             uint64_t *fid_persistent,
-                            uint64_t *fid_volatile);
+                            uint64_t *fid_volatile,
+                            struct smb2_create_returns *cr);
 NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
                        uint32_t timeout_msec,
                        struct smbXcli_session *session,
@@ -368,7 +370,8 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
                        uint32_t create_options,
                        struct smb2_create_blobs *blobs,
                        uint64_t *fid_persistent,
-                       uint64_t *fid_volatile);
+                       uint64_t *fid_volatile,
+                       struct smb2_create_returns *cr);
 
 struct tevent_req *smb2cli_close_send(TALLOC_CTX *mem_ctx,
                                      struct tevent_context *ev,
index 07835a5bc2ee1f48170805be8a4a22bb707efba1..f3a9962f82345ce0fc22fa8821c74b85ed04692b 100644 (file)
@@ -208,7 +208,8 @@ static void tstream_cli_np_open_done(struct tevent_req *subreq)
        } else {
                status = smb2cli_create_recv(subreq,
                                             &state->fid_persistent,
-                                            &state->fid_volatile);
+                                            &state->fid_volatile,
+                                            NULL);
        }
        TALLOC_FREE(subreq);
        if (!NT_STATUS_IS_OK(status)) {
index 7ca9f49d1a413fe06b00b9f0f9679deaaa51cc0b..3bcd2ed75c1145a2397748dfc83622ca99aad3d9 100644 (file)
@@ -83,7 +83,8 @@ bool run_smb2_basic(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_create returned %s\n", nt_errstr(status));
                return false;
@@ -145,7 +146,8 @@ bool run_smb2_basic(int dummy)
                        FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_create returned %s\n", nt_errstr(status));
                return false;
@@ -341,7 +343,8 @@ bool run_smb2_session_reconnect(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_create on cli1 %s\n", nt_errstr(status));
                return false;
@@ -575,7 +578,8 @@ bool run_smb2_session_reconnect(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) &&
            !NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) {
                printf("smb2cli_create on cli2 %s\n", nt_errstr(status));
@@ -635,7 +639,8 @@ bool run_smb2_session_reconnect(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED) &&
            !NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED))
        {
@@ -662,7 +667,8 @@ bool run_smb2_session_reconnect(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_create on cli2 %s\n", nt_errstr(status));
                return false;
@@ -757,7 +763,8 @@ bool run_smb2_tcon_dependence(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_create on cli %s\n", nt_errstr(status));
                return false;
@@ -1164,7 +1171,8 @@ bool run_smb2_multi_channel(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_create on cli2 %s\n", nt_errstr(status));
                return false;
@@ -1324,7 +1332,8 @@ bool run_smb2_multi_channel(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
                printf("smb2cli_create %s\n", nt_errstr(status));
                return false;
@@ -1341,7 +1350,8 @@ bool run_smb2_multi_channel(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
                printf("smb2cli_create %s\n", nt_errstr(status));
                return false;
@@ -1358,7 +1368,8 @@ bool run_smb2_multi_channel(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
                printf("smb2cli_create %s\n", nt_errstr(status));
                return false;
@@ -1489,7 +1500,8 @@ bool run_smb2_session_reauth(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_create %s\n", nt_errstr(status));
                return false;
@@ -1508,7 +1520,8 @@ bool run_smb2_session_reauth(int dummy)
                        FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &dir_persistent,
-                       &dir_volatile);
+                       &dir_volatile,
+                       NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_create returned %s\n", nt_errstr(status));
                return false;
@@ -1691,7 +1704,8 @@ bool run_smb2_session_reauth(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
                printf("smb2cli_create %s\n", nt_errstr(status));
                return false;
@@ -1710,7 +1724,8 @@ bool run_smb2_session_reauth(int dummy)
                        FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &dir_persistent,
-                       &dir_volatile);
+                       &dir_volatile,
+                       NULL);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
                printf("smb2cli_create returned %s\n", nt_errstr(status));
                return false;
@@ -1865,7 +1880,8 @@ bool run_smb2_session_reauth(int dummy)
                        FILE_DELETE_ON_CLOSE, /* create_options, */
                        NULL, /* smb2_create_blobs *blobs */
                        &fid_persistent,
-                       &fid_volatile);
+                       &fid_volatile,
+                       NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_create %s\n", nt_errstr(status));
                return false;