summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-02-07 13:24:41 +0100
committerVolker Lendecke <vl@samba.org>2010-02-20 18:59:29 +0100
commit89e6a5263e29759c4edd1a8e856443f59dff0c31 (patch)
tree84d28e739df6f65bab419f8f99c7ff3cf579b7cd
parenta7036a9e47382e738f6ebedf13719222950611d6 (diff)
downloadsamba-89e6a5263e29759c4edd1a8e856443f59dff0c31.tar.gz
samba-89e6a5263e29759c4edd1a8e856443f59dff0c31.tar.bz2
samba-89e6a5263e29759c4edd1a8e856443f59dff0c31.zip
s3: Add cli_smb()
This is a sync wrapper around cli_smb_send/cli_smb_recv. This is a hack to speed up converting libsmb/ away from cli_send_smb/cli_receive_smb. Some routines in libsmb/ are only called in one place in smbtorture for example, where making it async right now is not worth it. With cli_smb_send/cli_smb_recv in place, pushing the asynchronosity out one level is "just" boilerplate code that is easy to do should it become necessary.
-rw-r--r--source3/include/proto.h7
-rw-r--r--source3/libsmb/clientgen.c36
2 files changed, 43 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c10a885396..b120cb1a92 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2327,6 +2327,13 @@ NTSTATUS cli_echo_recv(struct tevent_req *req);
NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
bool cli_ucs2(struct cli_state *cli);
bool is_andx_req(uint8_t cmd);
+NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+ uint8_t smb_command, uint8_t additional_flags,
+ uint8_t wct, uint16_t *vwv,
+ uint32_t num_bytes, const uint8_t *bytes,
+ struct tevent_req **result_parent,
+ uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
+ uint32_t *pnum_bytes, uint8_t **pbytes);
/* The following definitions come from libsmb/clierror.c */
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index bdc06f1c74..0afa9e6be7 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -961,3 +961,39 @@ bool is_andx_req(uint8_t cmd)
return false;
}
+
+NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+ uint8_t smb_command, uint8_t additional_flags,
+ uint8_t wct, uint16_t *vwv,
+ uint32_t num_bytes, const uint8_t *bytes,
+ struct tevent_req **result_parent,
+ uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
+ uint32_t *pnum_bytes, uint8_t **pbytes)
+{
+ struct tevent_context *ev;
+ struct tevent_req *req = NULL;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ if (cli_has_async_calls(cli)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ ev = tevent_context_init(mem_ctx);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = cli_smb_send(mem_ctx, ev, cli, smb_command, additional_flags,
+ wct, vwv, num_bytes, bytes);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = cli_smb_recv(req, min_wct, pwct, pvwv, pnum_bytes, pbytes);
+fail:
+ TALLOC_FREE(ev);
+ if (NT_STATUS_IS_OK(status)) {
+ *result_parent = req;
+ }
+ return status;
+}