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

mimir at samba.org mimir at samba.org
Tue Dec 6 08:58:21 GMT 2005


Author: mimir
Date: 2005-12-06 08:58:21 +0000 (Tue, 06 Dec 2005)
New Revision: 12088

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

Log:
Use a structure to pass arguments to dcerpc connection functions
and move migrated (async) code to a new file.


rafal


Modified:
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h	2005-12-06 08:56:13 UTC (rev 12087)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h	2005-12-06 08:58:21 UTC (rev 12088)
@@ -195,6 +195,16 @@
 };
 
 
+struct dcerpc_pipe_connect {
+	struct dcerpc_pipe *pipe;
+	struct dcerpc_binding *binding;
+	const char *pipe_uuid;
+	const char *pipe_name;
+	uint32_t pipe_version;
+	struct cli_credentials *creds;
+};
+
+
 enum rpc_request_state {
 	RPC_REQUEST_PENDING,
 	RPC_REQUEST_DONE

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2005-12-06 08:56:13 UTC (rev 12087)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2005-12-06 08:58:21 UTC (rev 12088)
@@ -28,6 +28,7 @@
 #include "librpc/gen_ndr/ndr_dcerpc.h"
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "libcli/raw/libcliraw.h"
+#include "libcli/composite/composite.h"
 #include "libcli/smb_composite/smb_composite.h"
 
 /*
@@ -1015,65 +1016,6 @@
 }
 
 
-/* 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_smb(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 smb_composite_connect conn;
-	struct smbcli_state *cli;
-	const char *pipe_name = NULL;
-
-	conn.in.dest_host              = binding->host;
-	conn.in.port                   = 0;
-	conn.in.called_name            = strupper_talloc(tmp_ctx, binding->host);
-	conn.in.service                = "IPC$";
-	conn.in.service_type           = NULL;
-	conn.in.fallback_to_anonymous  = False;
-	conn.in.workgroup              = lp_workgroup();
-
-	if (binding->flags & DCERPC_SCHANNEL) {
-		struct cli_credentials *anon_creds
-			= cli_credentials_init(tmp_ctx);
-		cli_credentials_set_anonymous(anon_creds);
-		cli_credentials_guess(anon_creds);
-
-		conn.in.credentials = anon_creds;
-		status = smb_composite_connect(&conn, p->conn, p->conn->event_ctx);
-
-	} else {
-
-		conn.in.credentials = credentials;
-		status = smb_composite_connect(&conn, p->conn, 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;
-	}
-
-	cli = smbcli_state_init(p->conn);
-	cli->tree      = conn.out.tree;
-	cli->session   = conn.out.tree->session;
-	cli->transport = conn.out.tree->session->transport;
-
-	pipe_name = binding->endpoint;
-
-	status = dcerpc_pipe_open_smb(p->conn, cli->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;
-	}
-
-	return NT_STATUS_OK;
-}
-
 /* 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, 
@@ -1117,18 +1059,14 @@
 /* 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 *p, 
-					     struct dcerpc_binding *binding,
-					     const char *pipe_uuid, 
-					     uint32_t pipe_version,
-					     struct cli_credentials *credentials)
+					     struct dcerpc_pipe_connect *io)
 {
-	if (binding->flags & DCERPC_SMB2) {
-		return dcerpc_pipe_connect_ncacn_np_smb2(tmp_ctx, p, binding, pipe_uuid, 
-							 pipe_version, credentials);
+	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_smb(tmp_ctx, p, binding, pipe_uuid, 
-						pipe_version, credentials);
+	return dcerpc_pipe_connect_ncacn_np_smb(tmp_ctx, io);
 }
 
 /* open a rpc connection to a rpc pipe on SMP using the binding
@@ -1215,6 +1153,7 @@
 {
 	NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
 	struct dcerpc_pipe *p; 
+	struct dcerpc_pipe_connect pc;
 	
 	TALLOC_CTX *tmp_ctx;
 
@@ -1249,11 +1188,17 @@
 		break;
 	}
 
+	pc.pipe          = p;
+	pc.binding       = binding;
+	pc.pipe_uuid     = pipe_uuid;
+	pc.pipe_version  = pipe_version;
+	pc.creds         = credentials;
+
 	switch (binding->transport) {
 	case NCACN_NP:
-		status = dcerpc_pipe_connect_ncacn_np(tmp_ctx, 
-						      p, binding, pipe_uuid, pipe_version, credentials);
+		status = dcerpc_pipe_connect_ncacn_np(tmp_ctx, &pc);
 		break;
+
 	case NCACN_IP_TCP:
 		status = dcerpc_pipe_connect_ncacn_ip_tcp(tmp_ctx, 
 							  p, binding, pipe_uuid, pipe_version);



More information about the samba-cvs mailing list