diff options
author | Andrew Tridgell <tridge@samba.org> | 2008-05-28 16:27:38 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2008-05-28 16:27:38 +1000 |
commit | 773f5cce80322d8674ac0b99b0e0ea641991af1b (patch) | |
tree | 5b38037011a04670c8d586ce63c072efb0121d7f /source4/libcli | |
parent | 2173169e191754887acddb669a937b872b7ce017 (diff) | |
download | samba-773f5cce80322d8674ac0b99b0e0ea641991af1b.tar.gz samba-773f5cce80322d8674ac0b99b0e0ea641991af1b.tar.bz2 samba-773f5cce80322d8674ac0b99b0e0ea641991af1b.zip |
expose a function for pushing all SMB2 create blobs
(This used to be commit f5985a0490e4105a9b0208f6b7b19e635db324f9)
Diffstat (limited to 'source4/libcli')
-rw-r--r-- | source4/libcli/smb2/create.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c index 4a97f8aafb..b976b528f1 100644 --- a/source4/libcli/smb2/create.c +++ b/source4/libcli/smb2/create.c @@ -125,6 +125,35 @@ static NTSTATUS smb2_create_blob_push_one(TALLOC_CTX *mem_ctx, DATA_BLOB *buffer return NT_STATUS_OK; } + +/* + create a buffer of a set of create blobs +*/ +NTSTATUS smb2_create_blob_push(TALLOC_CTX *mem_ctx, DATA_BLOB *buffer, + const struct smb2_create_blobs blobs) +{ + int i; + NTSTATUS status; + + *buffer = data_blob(NULL, 0); + for (i=0; i < blobs.num_blobs; i++) { + bool last = false; + const struct smb2_create_blob *c; + + if ((i + 1) == blobs.num_blobs) { + last = true; + } + + c = &blobs.blobs[i]; + status = smb2_create_blob_push_one(mem_ctx, buffer, c, last); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + } + return NT_STATUS_OK; +} + + NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, struct smb2_create_blobs *b, const char *tag, DATA_BLOB data) { @@ -160,8 +189,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create { struct smb2_request *req; NTSTATUS status; - DATA_BLOB blob = data_blob(NULL, 0); - uint32_t i; + DATA_BLOB blob; struct smb2_create_blobs blobs = io->in.blobs; req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, true, 0); @@ -281,21 +309,10 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create } /* and any custom blobs */ - for (i=0; i < blobs.num_blobs; i++) { - bool last = false; - const struct smb2_create_blob *c; - - if ((i + 1) == blobs.num_blobs) { - last = true; - } - - c = &blobs.blobs[i]; - status = smb2_create_blob_push_one(req, &blob, - c, last); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(req); - return NULL; - } + status = smb2_create_blob_push(req, &blob, blobs); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(req); + return NULL; } status = smb2_push_o32s32_blob(&req->out, 0x30, blob); @@ -304,6 +321,8 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create return NULL; } + data_blob_free(&blob); + smb2_transport_send(req); return req; |