svn commit: samba r12135 - in branches/SAMBA_4_0/source/librpc/rpc: .

mimir at samba.org mimir at samba.org
Fri Dec 9 00:04:39 GMT 2005


Author: mimir
Date: 2005-12-09 00:04:38 +0000 (Fri, 09 Dec 2005)
New Revision: 12135

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12135

Log:
Move named pipe connect on smb2 function to async implementation.
Completely untested, it's a bit difficult without having vista
around (yet), so - Andrew, please test it and let me know what's
wrong.


rafal


Modified:
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_connect.c
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_connect.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_connect.c	2005-12-08 23:34:10 UTC (rev 12134)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_connect.c	2005-12-09 00:04:38 UTC (rev 12135)
@@ -194,3 +194,121 @@
 	c = dcerpc_pipe_connect_ncacn_np_smb_send(tmp_ctx, io);
 	return dcerpc_pipe_connect_ncacn_np_smb_recv(c);
 }
+
+
+struct pipe_np_smb2_state {
+	struct smb2_tree *tree;
+	struct dcerpc_pipe_connect io;
+};
+
+
+void continue_pipe_open_smb2(struct composite_context *ctx)
+{
+	struct composite_context *c = talloc_get_type(ctx->async.private_data,
+						      struct composite_context);
+	struct pipe_np_smb2_state *s = talloc_get_type(c->private_data,
+						       struct pipe_np_smb2_state);
+
+	c->status = dcerpc_pipe_open_smb2_recv(ctx);
+	if (!NT_STATUS_IS_OK(c->status)) {
+		DEBUG(0,("Failed to open pipe %s - %s\n", s->io.pipe_name, nt_errstr(c->status)));
+		composite_error(c, c->status);
+		return;
+	}
+
+	composite_done(c);
+}
+
+
+void continue_smb2_connect(struct composite_context *ctx)
+{
+	struct composite_context *open_req;
+	struct composite_context *c = talloc_get_type(ctx->async.private_data,
+						      struct composite_context);
+	struct pipe_np_smb2_state *s = talloc_get_type(c->private_data,
+						       struct pipe_np_smb2_state);
+
+	c->status = smb2_connect_recv(ctx, c, &s->tree);
+	if (!NT_STATUS_IS_OK(c->status)) {
+		DEBUG(0,("Failed to connect to %s - %s\n", s->io.binding->host, nt_errstr(c->status)));
+		composite_error(c, c->status);
+		return;
+	}
+	
+	s->io.pipe_name = s->io.binding->endpoint;
+
+	open_req = dcerpc_pipe_open_smb2_send(s->io.pipe->conn, s->tree, s->io.pipe_name);
+	if (open_req == NULL) {
+		composite_error(c, NT_STATUS_NO_MEMORY);
+		return;
+	}
+
+	composite_continue(c, open_req, continue_pipe_open_smb2, c);
+}
+
+
+struct composite_context *dcerpc_pipe_connect_ncacn_np_smb2_send(TALLOC_CTX *mem_ctx,
+								 struct dcerpc_pipe_connect *io)
+{
+	struct composite_context *c;
+	struct pipe_np_smb2_state *s;
+	struct composite_context *conn_req;
+
+	c = talloc_zero(mem_ctx, struct composite_context);
+	if (c == NULL) return NULL;
+
+	s = talloc_zero(c, struct pipe_np_smb2_state);
+	if (s == NULL) {
+		composite_error(c, NT_STATUS_NO_MEMORY);
+		goto done;
+	}
+	
+	c->state = COMPOSITE_STATE_IN_PROGRESS;
+	c->private_data = s;
+	c->event_ctx = io->pipe->conn->event_ctx;
+
+	s->io = *io;
+
+	if (s->io.binding->flags & DCERPC_SCHANNEL) {
+		s->io.creds = cli_credentials_init(mem_ctx);
+		if (s->io.creds) {
+			composite_error(c, NT_STATUS_NO_MEMORY);
+			goto done;
+		}
+
+		cli_credentials_set_anonymous(s->io.creds);
+		cli_credentials_guess(s->io.creds);
+	}
+
+	conn_req = smb2_connect_send(mem_ctx, s->io.binding->host, "IPC$", s->io.creds,
+				     c->event_ctx);
+	if (conn_req == NULL) {
+		composite_error(c, NT_STATUS_NO_MEMORY);
+		goto done;
+	}
+
+	composite_continue(c, conn_req, continue_smb2_connect, c);
+
+done:
+	return c;
+}
+
+
+NTSTATUS dcerpc_pipe_connect_ncacn_np_smb2_recv(struct composite_context *c)
+{
+	NTSTATUS status = composite_wait(c);
+	
+	talloc_free(c);
+	return status;
+}
+
+
+/* open a rpc connection to a rpc pipe on SMB2 using the binding
+   structure to determine the endpoint and options */
+NTSTATUS dcerpc_pipe_connect_ncacn_np_smb2(TALLOC_CTX *mem_ctx,
+					   struct dcerpc_pipe_connect *io)
+{
+	struct composite_context *c;
+	c = dcerpc_pipe_connect_ncacn_np_smb2_send(mem_ctx, io);
+	return dcerpc_pipe_connect_ncacn_np_smb2_recv(c);
+}

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2005-12-08 23:34:10 UTC (rev 12134)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2005-12-09 00:04:38 UTC (rev 12135)
@@ -1016,59 +1016,19 @@
 }
 
 
-/* open a rpc connection to a rpc pipe on SMB2 using the binding
-   structure to determine the endpoint and options */
-static NTSTATUS dcerpc_pipe_connect_ncacn_np_smb2(TALLOC_CTX *tmp_ctx, 
-						  struct dcerpc_pipe *p, 
-						  struct dcerpc_binding *binding,
-						  const char *pipe_uuid, 
-						  uint32_t pipe_version,
-						  struct cli_credentials *credentials)
-{
-	NTSTATUS status;
-	struct smb2_tree *tree;
-	const char *pipe_name = NULL;
-
-	if (binding->flags & DCERPC_SCHANNEL) {
-		credentials = cli_credentials_init(tmp_ctx);
-		cli_credentials_set_anonymous(credentials);
-		cli_credentials_guess(credentials);
-	}
-	status = smb2_connect(tmp_ctx, binding->host, "IPC$", credentials, &tree,
-			      p->conn->event_ctx);
-	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(0,("Failed to connect to %s - %s\n", 
-			 binding->host, nt_errstr(status)));
-		return status;
-	}
-
-	pipe_name = binding->endpoint;
-
-	status = dcerpc_pipe_open_smb2(p->conn, tree, pipe_name);
-	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(0,("Failed to open pipe %s - %s\n", pipe_name, nt_errstr(status)));
-		return status;
-	}
-
-	talloc_steal(p->conn, tree);
-
-	return NT_STATUS_OK;
-}
-
-
 /* open a rpc connection to a rpc pipe on SMB using the binding
    structure to determine the endpoint and options */
 static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx, 
 					     struct dcerpc_pipe_connect *io)
 {
 	if (io->binding->flags & DCERPC_SMB2) {
-		return dcerpc_pipe_connect_ncacn_np_smb2(tmp_ctx, io->pipe, io->binding,
-							 io->pipe_uuid, io->pipe_version,
-							 io->creds);
+		return dcerpc_pipe_connect_ncacn_np_smb2(tmp_ctx, io);
+
 	}
 	return dcerpc_pipe_connect_ncacn_np_smb(tmp_ctx, io);
 }
 
+
 /* open a rpc connection to a rpc pipe on SMP using the binding
    structure to determine the endpoint and options */
 static NTSTATUS dcerpc_pipe_connect_ncalrpc(TALLOC_CTX *tmp_ctx, 



More information about the samba-cvs mailing list