summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/libcli/composite/composite.h6
-rw-r--r--source4/libcli/composite/connect.c68
-rw-r--r--source4/libcli/composite/loadfile.c54
-rw-r--r--source4/libcli/composite/savefile.c52
-rw-r--r--source4/libcli/composite/sesssetup.c22
5 files changed, 88 insertions, 114 deletions
diff --git a/source4/libcli/composite/composite.h b/source4/libcli/composite/composite.h
index 2e50d0b1ed..fba458795c 100644
--- a/source4/libcli/composite/composite.h
+++ b/source4/libcli/composite/composite.h
@@ -36,10 +36,8 @@ struct smbcli_composite {
/* the internal stage */
uint16_t stage;
- /* the currently running sub-request */
- void *req;
-
- /* a private pointer for use by the composite code */
+ /* a private pointer for use by the composite function
+ implementation */
void *private;
/* status code when finished */
diff --git a/source4/libcli/composite/connect.c b/source4/libcli/composite/connect.c
index aa5afae9e9..bc39cc99fc 100644
--- a/source4/libcli/composite/connect.c
+++ b/source4/libcli/composite/connect.c
@@ -39,6 +39,8 @@ struct connect_state {
struct smb_composite_connect *io;
union smb_tcon *io_tcon;
struct smb_composite_sesssetup *io_setup;
+ struct smbcli_request *req;
+ struct smbcli_composite *creq;
};
@@ -52,15 +54,13 @@ static NTSTATUS connect_send_negprot(struct smbcli_composite *c,
struct smb_composite_connect *io)
{
struct connect_state *state = c->private;
- struct smbcli_request *req;
- req = smb_raw_negotiate_send(state->transport, lp_maxprotocol());
- NT_STATUS_HAVE_NO_MEMORY(req);
+ state->req = smb_raw_negotiate_send(state->transport, lp_maxprotocol());
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
- req->async.fn = request_handler;
- req->async.private = c;
+ state->req->async.fn = request_handler;
+ state->req->async.private = c;
c->stage = CONNECT_NEGPROT;
- c->req = req;
return NT_STATUS_OK;
}
@@ -73,10 +73,9 @@ static NTSTATUS connect_tcon(struct smbcli_composite *c,
struct smb_composite_connect *io)
{
struct connect_state *state = c->private;
- struct smbcli_request *req = c->req;
NTSTATUS status;
- status = smb_tree_connect_recv(req, c, state->io_tcon);
+ status = smb_tree_connect_recv(state->req, c, state->io_tcon);
NT_STATUS_NOT_OK_RETURN(status);
io->out.tree->tid = state->io_tcon->tconx.out.tid;
@@ -106,11 +105,9 @@ static NTSTATUS connect_session_setup(struct smbcli_composite *c,
struct smb_composite_connect *io)
{
struct connect_state *state = c->private;
- struct smbcli_composite *req = c->req;
- struct smbcli_request *req2;
NTSTATUS status;
- status = smb_composite_sesssetup_recv(req);
+ status = smb_composite_sesssetup_recv(state->creq);
NT_STATUS_NOT_OK_RETURN(status);
state->session->vuid = state->io_setup->out.vuid;
@@ -138,12 +135,11 @@ static NTSTATUS connect_session_setup(struct smbcli_composite *c,
state->io_tcon->tconx.in.device = io->in.service_type;
}
- req2 = smb_tree_connect_send(io->out.tree, state->io_tcon);
- NT_STATUS_HAVE_NO_MEMORY(req2);
+ state->req = smb_tree_connect_send(io->out.tree, state->io_tcon);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
- req2->async.fn = request_handler;
- req2->async.private = c;
- c->req = req2;
+ state->req->async.fn = request_handler;
+ state->req->async.private = c;
c->stage = CONNECT_TCON;
return NT_STATUS_OK;
@@ -156,11 +152,9 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c,
struct smb_composite_connect *io)
{
struct connect_state *state = c->private;
- struct smbcli_request *req = c->req;
- struct smbcli_composite *req2;
NTSTATUS status;
- status = smb_raw_negotiate_recv(req);
+ status = smb_raw_negotiate_recv(state->req);
NT_STATUS_NOT_OK_RETURN(status);
/* next step is a session setup */
@@ -180,12 +174,11 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c,
state->io_setup->in.user = io->in.user;
state->io_setup->in.password = io->in.password;
- req2 = smb_composite_sesssetup_send(state->session, state->io_setup);
- NT_STATUS_HAVE_NO_MEMORY(req2);
+ state->creq = smb_composite_sesssetup_send(state->session, state->io_setup);
+ NT_STATUS_HAVE_NO_MEMORY(state->creq);
- req2->async.fn = composite_handler;
- req2->async.private = c;
- c->req = req2;
+ state->creq->async.fn = composite_handler;
+ state->creq->async.private = c;
c->stage = CONNECT_SESSION_SETUP;
return NT_STATUS_OK;
@@ -198,10 +191,10 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c,
static NTSTATUS connect_session_request(struct smbcli_composite *c,
struct smb_composite_connect *io)
{
- struct smbcli_request *req = c->req;
+ struct connect_state *state = c->private;
NTSTATUS status;
- status = smbcli_transport_connect_recv(req);
+ status = smbcli_transport_connect_recv(state->req);
NT_STATUS_NOT_OK_RETURN(status);
/* next step is a negprot */
@@ -216,10 +209,9 @@ static NTSTATUS connect_socket(struct smbcli_composite *c,
{
struct connect_state *state = c->private;
NTSTATUS status;
- struct smbcli_request *req;
struct nmb_name calling, called;
- status = smbcli_sock_connect_recv(c->req);
+ status = smbcli_sock_connect_recv(state->creq);
NT_STATUS_NOT_OK_RETURN(status);
/* the socket is up - we can initialise the smbcli transport layer */
@@ -236,13 +228,12 @@ static NTSTATUS connect_socket(struct smbcli_composite *c,
make_nmb_name(&calling, io->in.calling_name, 0x0);
choose_called_name(&called, io->in.called_name, 0x20);
- req = smbcli_transport_connect_send(state->transport, &calling, &called);
- NT_STATUS_HAVE_NO_MEMORY(req);
+ state->req = smbcli_transport_connect_send(state->transport, &calling, &called);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
- req->async.fn = request_handler;
- req->async.private = c;
+ state->req->async.fn = request_handler;
+ state->req->async.private = c;
c->stage = CONNECT_SESSION_REQUEST;
- c->req = req;
return NT_STATUS_OK;
}
@@ -306,7 +297,7 @@ static void composite_handler(struct smbcli_composite *req)
*/
struct smbcli_composite *smb_composite_connect_send(struct smb_composite_connect *io)
{
- struct smbcli_composite *c, *req;
+ struct smbcli_composite *c;
struct connect_state *state;
c = talloc_zero(NULL, struct smbcli_composite);
@@ -325,12 +316,11 @@ struct smbcli_composite *smb_composite_connect_send(struct smb_composite_connect
c->event_ctx = state->sock->event.ctx;
c->private = state;
- req = smbcli_sock_connect_send(state->sock, io->in.dest_host, io->in.port);
- if (req == NULL) goto failed;
+ state->creq = smbcli_sock_connect_send(state->sock, io->in.dest_host, io->in.port);
+ if (state->creq == NULL) goto failed;
- req->async.private = c;
- req->async.fn = composite_handler;
- c->req = req;
+ state->creq->async.private = c;
+ state->creq->async.fn = composite_handler;
return c;
failed:
diff --git a/source4/libcli/composite/loadfile.c b/source4/libcli/composite/loadfile.c
index e219707bc0..2d38096c88 100644
--- a/source4/libcli/composite/loadfile.c
+++ b/source4/libcli/composite/loadfile.c
@@ -34,6 +34,7 @@ static void loadfile_handler(struct smbcli_request *req);
struct loadfile_state {
struct smb_composite_loadfile *io;
+ struct smbcli_request *req;
union smb_open *io_open;
union smb_read *io_read;
};
@@ -44,7 +45,7 @@ struct loadfile_state {
static NTSTATUS setup_close(struct smbcli_composite *c,
struct smbcli_tree *tree, uint16_t fnum)
{
- struct smbcli_request *req;
+ struct loadfile_state *state = c->private;
union smb_close *io_close;
/* nothing to read, setup the close */
@@ -55,13 +56,12 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
io_close->close.in.fnum = fnum;
io_close->close.in.write_time = 0;
- req = smb_raw_close_send(tree, io_close);
- NT_STATUS_HAVE_NO_MEMORY(req);
+ state->req = smb_raw_close_send(tree, io_close);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the close is done */
- req->async.fn = loadfile_handler;
- req->async.private = c;
- c->req = req;
+ state->req->async.fn = loadfile_handler;
+ state->req->async.private = c;
c->stage = LOADFILE_CLOSE;
return NT_STATUS_OK;
@@ -75,11 +75,10 @@ static NTSTATUS loadfile_open(struct smbcli_composite *c,
struct smb_composite_loadfile *io)
{
struct loadfile_state *state = c->private;
- struct smbcli_request *req = c->req;
- struct smbcli_tree *tree = req->tree;
+ struct smbcli_tree *tree = state->req->tree;
NTSTATUS status;
- status = smb_raw_open_recv(req, c, state->io_open);
+ status = smb_raw_open_recv(state->req, c, state->io_open);
NT_STATUS_NOT_OK_RETURN(status);
/* don't allow stupidly large loads */
@@ -108,13 +107,12 @@ static NTSTATUS loadfile_open(struct smbcli_composite *c,
state->io_read->readx.in.remaining = 0;
state->io_read->readx.out.data = io->out.data;
- req = smb_raw_read_send(tree, state->io_read);
- NT_STATUS_HAVE_NO_MEMORY(req);
+ state->req = smb_raw_read_send(tree, state->io_read);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the first read is done */
- req->async.fn = loadfile_handler;
- req->async.private = c;
- c->req = req;
+ state->req->async.fn = loadfile_handler;
+ state->req->async.private = c;
c->stage = LOADFILE_READ;
talloc_free(state->io_open);
@@ -131,11 +129,10 @@ static NTSTATUS loadfile_read(struct smbcli_composite *c,
struct smb_composite_loadfile *io)
{
struct loadfile_state *state = c->private;
- struct smbcli_request *req = c->req;
- struct smbcli_tree *tree = req->tree;
+ struct smbcli_tree *tree = state->req->tree;
NTSTATUS status;
- status = smb_raw_read_recv(req, state->io_read);
+ status = smb_raw_read_recv(state->req, state->io_read);
NT_STATUS_NOT_OK_RETURN(status);
/* we might be done */
@@ -149,13 +146,12 @@ static NTSTATUS loadfile_read(struct smbcli_composite *c,
state->io_read->readx.in.mincnt = MIN(32768, io->out.size - state->io_read->readx.in.offset);
state->io_read->readx.out.data = io->out.data + state->io_read->readx.in.offset;
- req = smb_raw_read_send(tree, state->io_read);
- NT_STATUS_HAVE_NO_MEMORY(req);
+ state->req = smb_raw_read_send(tree, state->io_read);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the read is done */
- req->async.fn = loadfile_handler;
- req->async.private = c;
- c->req = req;
+ state->req->async.fn = loadfile_handler;
+ state->req->async.private = c;
return NT_STATUS_OK;
}
@@ -166,10 +162,10 @@ static NTSTATUS loadfile_read(struct smbcli_composite *c,
static NTSTATUS loadfile_close(struct smbcli_composite *c,
struct smb_composite_loadfile *io)
{
+ struct loadfile_state *state = c->private;
NTSTATUS status;
- struct smbcli_request *req = c->req;
- status = smbcli_request_simple_recv(req);
+ status = smbcli_request_simple_recv(state->req);
NT_STATUS_NOT_OK_RETURN(status);
c->state = SMBCLI_REQUEST_DONE;
@@ -221,7 +217,6 @@ struct smbcli_composite *smb_composite_loadfile_send(struct smbcli_tree *tree,
struct smb_composite_loadfile *io)
{
struct smbcli_composite *c;
- struct smbcli_request *req;
struct loadfile_state *state;
c = talloc_zero(tree, struct smbcli_composite);
@@ -250,13 +245,12 @@ struct smbcli_composite *smb_composite_loadfile_send(struct smbcli_tree *tree,
state->io_open->ntcreatex.in.fname = io->in.fname;
/* send the open on its way */
- req = smb_raw_open_send(tree, state->io_open);
- if (req == NULL) goto failed;
+ state->req = smb_raw_open_send(tree, state->io_open);
+ if (state->req == NULL) goto failed;
/* setup the callback handler */
- req->async.fn = loadfile_handler;
- req->async.private = c;
- c->req = req;
+ state->req->async.fn = loadfile_handler;
+ state->req->async.private = c;
c->stage = LOADFILE_OPEN;
return c;
diff --git a/source4/libcli/composite/savefile.c b/source4/libcli/composite/savefile.c
index 9abe5f5329..f516939c2b 100644
--- a/source4/libcli/composite/savefile.c
+++ b/source4/libcli/composite/savefile.c
@@ -37,6 +37,7 @@ struct savefile_state {
struct smb_composite_savefile *io;
union smb_open *io_open;
union smb_write *io_write;
+ struct smbcli_request *req;
};
@@ -46,8 +47,8 @@ struct savefile_state {
static NTSTATUS setup_close(struct smbcli_composite *c,
struct smbcli_tree *tree, uint16_t fnum)
{
+ struct savefile_state *state = c->private;
union smb_close *io_close;
- struct smbcli_request *req = c->req;
/* nothing to write, setup the close */
io_close = talloc(c, union smb_close);
@@ -57,14 +58,13 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
io_close->close.in.fnum = fnum;
io_close->close.in.write_time = 0;
- req = smb_raw_close_send(tree, io_close);
- NT_STATUS_HAVE_NO_MEMORY(req);
+ state->req = smb_raw_close_send(tree, io_close);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the close is done */
c->stage = SAVEFILE_CLOSE;
- req->async.fn = savefile_handler;
- req->async.private = c;
- c->req = req;
+ state->req->async.fn = savefile_handler;
+ state->req->async.private = c;
return NT_STATUS_OK;
}
@@ -78,12 +78,11 @@ static NTSTATUS savefile_open(struct smbcli_composite *c,
{
struct savefile_state *state = c->private;
union smb_write *io_write;
- struct smbcli_request *req = c->req;
- struct smbcli_tree *tree = req->tree;
+ struct smbcli_tree *tree = state->req->tree;
NTSTATUS status;
uint32_t max_xmit = tree->session->transport->negotiate.max_xmit;
- status = smb_raw_open_recv(c->req, c, state->io_open);
+ status = smb_raw_open_recv(state->req, c, state->io_open);
NT_STATUS_NOT_OK_RETURN(status);
if (io->in.size == 0) {
@@ -103,14 +102,13 @@ static NTSTATUS savefile_open(struct smbcli_composite *c,
io_write->writex.in.data = io->in.data;
state->io_write = io_write;
- req = smb_raw_write_send(tree, io_write);
- NT_STATUS_HAVE_NO_MEMORY(req);
+ state->req = smb_raw_write_send(tree, io_write);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the first write is done */
c->stage = SAVEFILE_WRITE;
- req->async.fn = savefile_handler;
- req->async.private = c;
- c->req = req;
+ state->req->async.fn = savefile_handler;
+ state->req->async.private = c;
talloc_free(state->io_open);
return NT_STATUS_OK;
@@ -125,12 +123,11 @@ static NTSTATUS savefile_write(struct smbcli_composite *c,
struct smb_composite_savefile *io)
{
struct savefile_state *state = c->private;
- struct smbcli_request *req = c->req;
- struct smbcli_tree *tree = req->tree;
+ struct smbcli_tree *tree = state->req->tree;
NTSTATUS status;
uint32_t max_xmit = tree->session->transport->negotiate.max_xmit;
- status = smb_raw_write_recv(c->req, state->io_write);
+ status = smb_raw_write_recv(state->req, state->io_write);
NT_STATUS_NOT_OK_RETURN(status);
state->total_written += state->io_write->writex.out.nwritten;
@@ -147,13 +144,12 @@ static NTSTATUS savefile_write(struct smbcli_composite *c,
io->in.size - state->total_written);
state->io_write->writex.in.data = io->in.data + state->total_written;
- req = smb_raw_write_send(tree, state->io_write);
- NT_STATUS_HAVE_NO_MEMORY(req);
+ state->req = smb_raw_write_send(tree, state->io_write);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the write is done */
- req->async.fn = savefile_handler;
- req->async.private = c;
- c->req = req;
+ state->req->async.fn = savefile_handler;
+ state->req->async.private = c;
return NT_STATUS_OK;
}
@@ -167,7 +163,7 @@ static NTSTATUS savefile_close(struct smbcli_composite *c,
struct savefile_state *state = c->private;
NTSTATUS status;
- status = smbcli_request_simple_recv(c->req);
+ status = smbcli_request_simple_recv(state->req);
NT_STATUS_NOT_OK_RETURN(status);
if (state->total_written != io->in.size) {
@@ -224,7 +220,6 @@ struct smbcli_composite *smb_composite_savefile_send(struct smbcli_tree *tree,
{
struct smbcli_composite *c;
struct savefile_state *state;
- struct smbcli_request *req;
union smb_open *io_open;
c = talloc_zero(tree, struct smbcli_composite);
@@ -255,14 +250,13 @@ struct smbcli_composite *smb_composite_savefile_send(struct smbcli_tree *tree,
state->io_open = io_open;
/* send the open on its way */
- req = smb_raw_open_send(tree, io_open);
- if (req == NULL) goto failed;
+ state->req = smb_raw_open_send(tree, io_open);
+ if (state->req == NULL) goto failed;
/* setup the callback handler */
- req->async.fn = savefile_handler;
- req->async.private = c;
+ state->req->async.fn = savefile_handler;
+ state->req->async.private = c;
c->private = state;
- c->req = req;
return c;
diff --git a/source4/libcli/composite/sesssetup.c b/source4/libcli/composite/sesssetup.c
index 7053c9f9e5..fdc638837c 100644
--- a/source4/libcli/composite/sesssetup.c
+++ b/source4/libcli/composite/sesssetup.c
@@ -31,6 +31,7 @@ struct sesssetup_state {
union smb_sesssetup setup;
NTSTATUS session_key_err;
struct smb_composite_sesssetup *io;
+ struct smbcli_request *req;
};
@@ -134,10 +135,9 @@ static void request_handler(struct smbcli_request *req)
smbcli_transport_simple_set_signing(session->transport, session_key, null_data_blob);
}
- req = smb_raw_session_setup_send(session, &state->setup);
- req->async.fn = request_handler;
- req->async.private = c;
- c->req = req;
+ state->req = smb_raw_session_setup_send(session, &state->setup);
+ state->req->async.fn = request_handler;
+ state->req->async.private = c;
return;
}
@@ -338,7 +338,6 @@ struct smbcli_composite *smb_composite_sesssetup_send(struct smbcli_session *ses
{
struct smbcli_composite *c;
struct sesssetup_state *state;
- struct smbcli_request *req = NULL;
c = talloc_zero(session, struct smbcli_composite);
if (c == NULL) goto failed;
@@ -361,19 +360,18 @@ struct smbcli_composite *smb_composite_sesssetup_send(struct smbcli_session *ses
/* see what session setup interface we will use */
if (session->transport->negotiate.protocol < PROTOCOL_NT1) {
- req = session_setup_old(c, session, io);
+ state->req = session_setup_old(c, session, io);
} else if (!session->transport->options.use_spnego ||
!(io->in.capabilities & CAP_EXTENDED_SECURITY)) {
- req = session_setup_nt1(c, session, io);
+ state->req = session_setup_nt1(c, session, io);
} else {
- req = session_setup_spnego(c, session, io);
+ state->req = session_setup_spnego(c, session, io);
}
- if (req == NULL) goto failed;
+ if (state->req == NULL) goto failed;
- req->async.fn = request_handler;
- req->async.private = c;
- c->req = req;
+ state->req->async.fn = request_handler;
+ state->req->async.private = c;
return c;