summaryrefslogtreecommitdiff
path: root/source3/lib/netapi/cm.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-07-20 17:59:30 +0200
committerVolker Lendecke <vl@samba.org>2008-07-21 14:36:27 +0200
commit798b56edaec88206b0d61d2852af41777d53aef2 (patch)
tree562ea623ec18a357fb65485bfa731900095db88c /source3/lib/netapi/cm.c
parent739e9cfbe0b5eff80bdcba1cf10bd5bfe6873d6a (diff)
downloadsamba-798b56edaec88206b0d61d2852af41777d53aef2.tar.gz
samba-798b56edaec88206b0d61d2852af41777d53aef2.tar.bz2
samba-798b56edaec88206b0d61d2852af41777d53aef2.zip
Refactoring: libnetapi_open_pipe takes an interface instead of pipe_idx
(This used to be commit 726e56c72fdb685ab5eddefd2fd8b043dc38d6ad)
Diffstat (limited to 'source3/lib/netapi/cm.c')
-rw-r--r--source3/lib/netapi/cm.c76
1 files changed, 37 insertions, 39 deletions
diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c
index fe5490c73b..8eaabb3cda 100644
--- a/source3/lib/netapi/cm.c
+++ b/source3/lib/netapi/cm.c
@@ -91,75 +91,70 @@ static struct client_pipe_connection *pipe_connections;
/********************************************************************
********************************************************************/
-static struct rpc_pipe_client *pipe_cm_find(struct cli_state *cli,
- int pipe_idx,
- NTSTATUS *status)
+static NTSTATUS pipe_cm_find(struct cli_state *cli,
+ const struct ndr_syntax_id *interface,
+ struct rpc_pipe_client **presult)
{
struct client_pipe_connection *p;
for (p = pipe_connections; p; p = p->next) {
if (!rpc_pipe_np_smb_conn(p->pipe)) {
- *status = NT_STATUS_PIPE_EMPTY;
- return NULL;
+ return NT_STATUS_PIPE_EMPTY;
}
- if (strequal(cli->desthost, p->pipe->desthost) &&
- rpccli_is_pipe_idx(p->pipe, pipe_idx)) {
- *status = NT_STATUS_OK;
- return p->pipe;
+ if (strequal(cli->desthost, p->pipe->desthost)
+ && ndr_syntax_id_equal(&p->pipe->abstract_syntax,
+ interface)) {
+ *presult = p->pipe;
+ return NT_STATUS_OK;
}
}
- *status = NT_STATUS_PIPE_NOT_AVAILABLE;
-
- return NULL;
+ return NT_STATUS_PIPE_NOT_AVAILABLE;
}
/********************************************************************
********************************************************************/
-static struct rpc_pipe_client *pipe_cm_connect(TALLOC_CTX *mem_ctx,
- struct cli_state *cli,
- int pipe_idx,
- NTSTATUS *status)
+static NTSTATUS pipe_cm_connect(TALLOC_CTX *mem_ctx,
+ struct cli_state *cli,
+ const struct ndr_syntax_id *interface,
+ struct rpc_pipe_client **presult)
{
struct client_pipe_connection *p;
+ NTSTATUS status;
p = TALLOC_ZERO_ARRAY(mem_ctx, struct client_pipe_connection, 1);
if (!p) {
- *status = NT_STATUS_NO_MEMORY;
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
- *status = cli_rpc_pipe_open_noauth(cli, cli_get_iface(pipe_idx),
- &p->pipe);
- if (!NT_STATUS_IS_OK(*status)) {
+ status = cli_rpc_pipe_open_noauth(cli, interface, &p->pipe);
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(p);
- return NULL;
+ return status;
}
DLIST_ADD(pipe_connections, p);
- return p->pipe;
+ *presult = p->pipe;
+ return NT_STATUS_OK;
}
/********************************************************************
********************************************************************/
-static struct rpc_pipe_client *pipe_cm_open(TALLOC_CTX *ctx,
- struct cli_state *cli,
- int pipe_idx,
- NTSTATUS *status)
+static NTSTATUS pipe_cm_open(TALLOC_CTX *ctx,
+ struct cli_state *cli,
+ const struct ndr_syntax_id *interface,
+ struct rpc_pipe_client **presult)
{
- struct rpc_pipe_client *p;
-
- p = pipe_cm_find(cli, pipe_idx, status);
- if (!p) {
- p = pipe_cm_connect(ctx, cli, pipe_idx, status);
+ if (NT_STATUS_IS_OK(pipe_cm_find(cli, interface, presult))) {
+ return NT_STATUS_OK;
}
- return p;
+ return pipe_cm_connect(ctx, cli, interface, presult);
}
/********************************************************************
@@ -167,23 +162,26 @@ static struct rpc_pipe_client *pipe_cm_open(TALLOC_CTX *ctx,
WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx,
struct cli_state *cli,
- int pipe_idx,
- struct rpc_pipe_client **pipe_cli)
+ const struct ndr_syntax_id *interface,
+ struct rpc_pipe_client **presult)
{
+ struct rpc_pipe_client *result;
NTSTATUS status;
- if (!cli || !pipe_cli) {
+ if (!cli || !presult) {
return WERR_INVALID_PARAM;
}
- *pipe_cli = pipe_cm_open(ctx, cli, pipe_idx, &status);
- if (!*pipe_cli) {
+ status = pipe_cm_open(ctx, cli, interface, &result);
+ if (!NT_STATUS_IS_OK(status)) {
libnetapi_set_error_string(ctx, "failed to open PIPE %s: %s",
- cli_get_pipe_name(pipe_idx),
+ cli_get_pipe_name_from_iface(debug_ctx(), cli,
+ interface),
get_friendly_nt_error_msg(status));
return WERR_DEST_NOT_FOUND;
}
+ *presult = result;
return WERR_OK;
}