summaryrefslogtreecommitdiff
path: root/source3/libsmb/async_smb.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-08-01 23:14:51 +0200
committerVolker Lendecke <vl@samba.org>2008-08-28 17:53:36 +0200
commit58aa97c0d9db06588d1aba4f06a3c98ed2098d8f (patch)
tree601782ac1e5f1d214e7df883b421100f3409f505 /source3/libsmb/async_smb.c
parent52e23fe460ed662e10137503abd08f4bd6596651 (diff)
downloadsamba-58aa97c0d9db06588d1aba4f06a3c98ed2098d8f.tar.gz
samba-58aa97c0d9db06588d1aba4f06a3c98ed2098d8f.tar.bz2
samba-58aa97c0d9db06588d1aba4f06a3c98ed2098d8f.zip
Refactoring: Add the routine cli_request_send()
cli_request_send() is supposed to bundle all generic SMB-header handling. This makes cli_request_new static to async_smb.c. (This used to be commit 7e73dd4e7622db64d30d48ba106892e0895fc188)
Diffstat (limited to 'source3/libsmb/async_smb.c')
-rw-r--r--source3/libsmb/async_smb.c62
1 files changed, 57 insertions, 5 deletions
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 58bba2bfc7..454bd8169b 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -114,11 +114,11 @@ static int cli_request_destructor(struct cli_request *req)
* Create a fresh async smb request
*/
-struct async_req *cli_request_new(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint8_t num_words, size_t num_bytes,
- struct cli_request **preq)
+static struct async_req *cli_request_new(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint8_t num_words, size_t num_bytes,
+ struct cli_request **preq)
{
struct async_req *result;
struct cli_request *cli_req;
@@ -161,6 +161,58 @@ struct async_req *cli_request_new(TALLOC_CTX *mem_ctx,
}
/*
+ * Ship a new smb request to the server
+ */
+struct async_req *cli_request_send(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+ uint8_t smb_command,
+ uint8_t additional_flags,
+ uint8_t wct, const uint16_t *vwv,
+ uint16_t num_bytes, const uint8_t *bytes)
+{
+ struct async_req *result;
+ struct cli_request *req;
+
+ result = cli_request_new(mem_ctx, cli->event_ctx, cli, wct, num_bytes,
+ &req);
+ if (result == NULL) {
+ DEBUG(0, ("cli_request_new failed\n"));
+ return NULL;
+ }
+
+ cli_set_message(req->outbuf, wct, num_bytes, false);
+ SCVAL(req->outbuf, smb_com, smb_command);
+ SSVAL(req->outbuf, smb_tid, cli->cnum);
+ cli_setup_packet_buf(cli, req->outbuf);
+
+ memcpy(req->outbuf + smb_vwv0, vwv, sizeof(uint16_t) * wct);
+ memcpy(smb_buf(req->outbuf), bytes, num_bytes);
+ SSVAL(req->outbuf, smb_mid, req->mid);
+ SCVAL(cli->outbuf, smb_flg,
+ CVAL(cli->outbuf,smb_flg) | additional_flags);
+
+ cli_calculate_sign_mac(cli, req->outbuf);
+
+ if (cli_encryption_on(cli)) {
+ NTSTATUS status;
+ char *enc_buf;
+
+ status = cli_encrypt_message(cli, req->outbuf, &enc_buf);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Error in encrypting client message. "
+ "Error %s\n", nt_errstr(status)));
+ TALLOC_FREE(req);
+ return NULL;
+ }
+ req->outbuf = enc_buf;
+ req->enc_state = cli->trans_enc_state;
+ }
+
+ event_fd_set_writeable(cli->fd_event);
+
+ return result;
+}
+
+/*
* Convenience function to get the SMB part out of an async_req
*/