/* the external state - will be queried by the caller */
enum smbcli_request_state state;
- /* the internal stage */
- uint16_t stage;
-
/* a private pointer for use by the composite function
implementation */
void *private;
CONNECT_TCON};
struct connect_state {
+ enum connect_stage stage;
struct smbcli_socket *sock;
struct smbcli_transport *transport;
struct smbcli_session *session;
state->req->async.fn = request_handler;
state->req->async.private = c;
- c->stage = CONNECT_NEGPROT;
+ state->stage = CONNECT_NEGPROT;
return NT_STATUS_OK;
}
state->req->async.fn = request_handler;
state->req->async.private = c;
- c->stage = CONNECT_TCON;
+ state->stage = CONNECT_TCON;
return NT_STATUS_OK;
}
state->creq->async.fn = composite_handler;
state->creq->async.private = c;
- c->stage = CONNECT_SESSION_SETUP;
+ state->stage = CONNECT_SESSION_SETUP;
return NT_STATUS_OK;
}
state->req->async.fn = request_handler;
state->req->async.private = c;
- c->stage = CONNECT_SESSION_REQUEST;
+ state->stage = CONNECT_SESSION_REQUEST;
return NT_STATUS_OK;
}
state->creq = smbcli_sock_connect_send(state->sock, address, state->io->in.port);
NT_STATUS_HAVE_NO_MEMORY(state->creq);
- c->stage = CONNECT_SOCKET;
+ state->stage = CONNECT_SOCKET;
state->creq->async.private = c;
state->creq->async.fn = composite_handler;
{
struct connect_state *state = talloc_get_type(c->private, struct connect_state);
- switch (c->stage) {
+ switch (state->stage) {
case CONNECT_RESOLVE:
c->status = connect_resolve(c, state->io);
break;
if (state->sock == NULL) goto failed;
state->io = io;
+ state->stage = CONNECT_RESOLVE;
c->state = SMBCLI_REQUEST_SEND;
- c->stage = CONNECT_RESOLVE;
c->event_ctx = state->sock->event.ctx;
c->private = state;
static void loadfile_handler(struct smbcli_request *req);
struct loadfile_state {
+ enum loadfile_stage stage;
struct smb_composite_loadfile *io;
struct smbcli_request *req;
union smb_open *io_open;
/* call the handler again when the close is done */
state->req->async.fn = loadfile_handler;
state->req->async.private = c;
- c->stage = LOADFILE_CLOSE;
+ state->stage = LOADFILE_CLOSE;
return NT_STATUS_OK;
}
/* call the handler again when the first read is done */
state->req->async.fn = loadfile_handler;
state->req->async.private = c;
- c->stage = LOADFILE_READ;
+ state->stage = LOADFILE_READ;
talloc_free(state->io_open);
/* when this handler is called, the stage indicates what
call has just finished */
- switch (c->stage) {
+ switch (state->stage) {
case LOADFILE_OPEN:
c->status = loadfile_open(c, state->io);
break;
/* setup the callback handler */
state->req->async.fn = loadfile_handler;
state->req->async.private = c;
- c->stage = LOADFILE_OPEN;
+ state->stage = LOADFILE_OPEN;
return c;
/* the stages of this call */
enum savefile_stage {SAVEFILE_OPEN, SAVEFILE_WRITE, SAVEFILE_CLOSE};
-
static void savefile_handler(struct smbcli_request *req);
struct savefile_state {
+ enum savefile_stage stage;
off_t total_written;
struct smb_composite_savefile *io;
union smb_open *io_open;
NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the close is done */
- c->stage = SAVEFILE_CLOSE;
+ state->stage = SAVEFILE_CLOSE;
state->req->async.fn = savefile_handler;
state->req->async.private = c;
NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the first write is done */
- c->stage = SAVEFILE_WRITE;
+ state->stage = SAVEFILE_WRITE;
state->req->async.fn = savefile_handler;
state->req->async.private = c;
talloc_free(state->io_open);
/* when this handler is called, the stage indicates what
call has just finished */
- switch (c->stage) {
+ switch (state->stage) {
case SAVEFILE_OPEN:
c->status = savefile_open(c, state->io);
break;
if (c == NULL) goto failed;
c->state = SMBCLI_REQUEST_SEND;
- c->stage = SAVEFILE_OPEN;
c->event_ctx = tree->session->transport->socket->event.ctx;
state = talloc(c, struct savefile_state);
if (state == NULL) goto failed;
+ state->stage = SAVEFILE_OPEN;
state->total_written = 0;
state->io = io;
this private structure is used during async connection handling
*/
struct clisocket_connect {
+ int port_num;
int *iports;
struct smbcli_socket *sock;
const char *dest_host;
}
/* that port failed - try the next port */
- for (i=c->stage+1;conn->iports[i];i++) {
- c->stage = i;
+ for (i=conn->port_num+1;conn->iports[i];i++) {
+ conn->port_num = i;
c->status = smbcli_sock_connect_one(conn->sock,
conn->dest_host,
conn->iports[i]);
/* startup the connect process for each port in turn until one
succeeds or tells us that it is pending */
for (i=0;conn->iports[i];i++) {
- c->stage = i;
+ conn->port_num = i;
conn->sock->port = conn->iports[i];
c->status = smbcli_sock_connect_one(sock,
conn->dest_host,